file
stringlengths 18
26
| data
stringlengths 3
1.04M
|
---|---|
the_stack_data/675023.c
|
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <math.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
volatile uint64_t *rx_data, *tx_data;
volatile uint32_t *rx_freq, *rx_rate, *tx_freq, *tx_rate;
volatile uint16_t *gpio, *rx_cntr, *tx_cntr;
volatile uint8_t *rx_rst, *tx_rst;
int sock_thread[4] = {-1, -1, -1, -1};
void *rx_ctrl_handler(void *arg);
void *rx_data_handler(void *arg);
void *tx_ctrl_handler(void *arg);
void *tx_data_handler(void *arg);
int main(int argc, char *argv[])
{
int fd, sock_server, sock_client;
pthread_t thread;
void *(*handler[4])(void *) =
{
rx_ctrl_handler,
rx_data_handler,
tx_ctrl_handler,
tx_data_handler
};
volatile void *cfg, *sts;
char *end, *name = "/dev/mem";
struct sockaddr_in addr;
uint16_t port;
uint32_t command;
ssize_t result;
int yes = 1;
long number;
errno = 0;
number = (argc == 2) ? strtol(argv[1], &end, 10) : -1;
if(errno != 0 || end == argv[1] || number < 1 || number > 2)
{
printf("Usage: sdr-transceiver-emb 1|2\n");
return EXIT_FAILURE;
}
if((fd = open(name, O_RDWR)) < 0)
{
perror("open");
return EXIT_FAILURE;
}
switch(number)
{
case 1:
port = 1001;
cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40000000);
sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40001000);
rx_data = mmap(NULL, 2*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40002000);
tx_data = mmap(NULL, 2*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40004000);
break;
case 2:
port = 1002;
cfg = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40006000);
sts = mmap(NULL, sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40007000);
rx_data = mmap(NULL, 2*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x40008000);
tx_data = mmap(NULL, 2*sysconf(_SC_PAGESIZE), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0x4000A000);
break;
}
gpio = ((uint16_t *)(cfg + 2));
rx_rst = ((uint8_t *)(cfg + 0));
rx_freq = ((uint32_t *)(cfg + 4));
rx_rate = ((uint32_t *)(cfg + 8));
rx_cntr = ((uint16_t *)(sts + 0));
tx_rst = ((uint8_t *)(cfg + 1));
tx_freq = ((uint32_t *)(cfg + 12));
tx_rate = ((uint32_t *)(cfg + 16));
tx_cntr = ((uint16_t *)(sts + 2));
/* set PTT pin to low */
*gpio = 0;
/* set default rx phase increment */
*rx_freq = (uint32_t)floor(600000/125.0e6*(1<<30)+0.5);
/* set default rx sample rate */
*rx_rate = 1250;
/* set default tx phase increment */
*tx_freq = (uint32_t)floor(600000/125.0e6*(1<<30)+0.5);
/* set default tx sample rate */
*tx_rate = 1250;
if((sock_server = socket(AF_INET, SOCK_STREAM, 0)) < 0)
{
perror("socket");
return EXIT_FAILURE;
}
setsockopt(sock_server, SOL_SOCKET, SO_REUSEADDR, (void *)&yes , sizeof(yes));
/* setup listening address */
memset(&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(port);
if(bind(sock_server, (struct sockaddr *)&addr, sizeof(addr)) < 0)
{
perror("bind");
return EXIT_FAILURE;
}
listen(sock_server, 1024);
while(1)
{
if((sock_client = accept(sock_server, NULL, NULL)) < 0)
{
perror("accept");
return EXIT_FAILURE;
}
result = recv(sock_client, (char *)&command, 4, MSG_WAITALL);
if(result <= 0 || command > 3 || sock_thread[command] > -1)
{
close(sock_client);
continue;
}
sock_thread[command] = sock_client;
if(pthread_create(&thread, NULL, handler[command], NULL) < 0)
{
perror("pthread_create");
return EXIT_FAILURE;
}
pthread_detach(thread);
}
close(sock_server);
return EXIT_SUCCESS;
}
void *rx_ctrl_handler(void *arg)
{
int sock_client = sock_thread[0];
uint32_t command, freq;
uint32_t freq_min = 50000;
uint32_t freq_max = 60000000;
/* set default rx phase increment */
*rx_freq = (uint32_t)floor(600000/125.0e6*(1<<30)+0.5);
/* set default rx sample rate */
*rx_rate = 1250;
while(1)
{
if(recv(sock_client, (char *)&command, 4, MSG_WAITALL) <= 0) break;
switch(command >> 28)
{
case 0:
/* set rx phase increment */
freq = command & 0xfffffff;
if(freq < freq_min || freq > freq_max) continue;
*rx_freq = (uint32_t)floor(freq/125.0e6*(1<<30)+0.5);
break;
case 1:
/* set rx sample rate */
switch(command & 3)
{
case 0:
freq_min = 12000;
*rx_rate = 2500;
break;
case 1:
freq_min = 24000;
*rx_rate = 1250;
break;
case 2:
freq_min = 48000;
*rx_rate = 625;
break;
}
break;
}
}
/* set default rx phase increment */
*rx_freq = (uint32_t)floor(600000/125.0e6*(1<<30)+0.5);
/* set default rx sample rate */
*rx_rate = 1250;
close(sock_client);
sock_thread[0] = -1;
return NULL;
}
void *rx_data_handler(void *arg)
{
int i, sock_client = sock_thread[1];
uint64_t buffer[512];
*rx_rst |= 1;
*rx_rst &= ~1;
while(1)
{
if(*rx_cntr >= 2048)
{
*rx_rst |= 1;
*rx_rst &= ~1;
}
while(*rx_cntr < 1024) usleep(1000);
for(i = 0; i < 512; ++i) buffer[i] = *rx_data;
if(send(sock_client, buffer, 4096, MSG_NOSIGNAL) < 0) break;
}
close(sock_client);
sock_thread[1] = -1;
return NULL;
}
void *tx_ctrl_handler(void *arg)
{
int sock_client = sock_thread[2];
uint32_t command, freq;
uint32_t freq_min = 50000;
uint32_t freq_max = 60000000;
/* set PTT pin to low */
*gpio = 0;
/* set default tx phase increment */
*tx_freq = (uint32_t)floor(600000/125.0e6*(1<<30)+0.5);
/* set default tx sample rate */
*tx_rate = 1250;
while(1)
{
if(recv(sock_client, (char *)&command, 4, MSG_WAITALL) <= 0) break;
switch(command >> 28)
{
case 0:
/* set tx phase increment */
freq = command & 0xfffffff;
if(freq < freq_min || freq > freq_max) continue;
*tx_freq = (uint32_t)floor(freq/125.0e6*(1<<30)+0.5);
break;
case 1:
/* set tx sample rate */
switch(command & 3)
{
case 0:
freq_min = 12000;
*tx_rate = 2500;
break;
case 1:
freq_min = 24000;
*tx_rate = 1250;
break;
case 2:
freq_min = 48000;
*tx_rate = 625;
break;
}
break;
case 2:
/* set PTT pin to high */
*gpio = 1;
break;
case 3:
/* set PTT pin to low */
*gpio = 0;
break;
}
}
/* set PTT pin to low */
*gpio = 0;
/* set default tx phase increment */
*tx_freq = (uint32_t)floor(600000/125.0e6*(1<<30)+0.5);
/* set default tx sample rate */
*tx_rate = 1250;
close(sock_client);
sock_thread[2] = -1;
return NULL;
}
void *tx_data_handler(void *arg)
{
int i, sock_client = sock_thread[3];
uint64_t buffer[512];
*tx_rst |= 1;
*tx_rst &= ~1;
while(1)
{
while(*tx_cntr > 1024) usleep(1000);
if(*tx_cntr == 0)
{
for(i = 0; i < 512; ++i) *tx_data = 0;
}
if(recv(sock_client, buffer, 4096, 0) <= 0) break;
for(i = 0; i < 512; ++i) *tx_data = buffer[i];
}
close(sock_client);
sock_thread[3] = -1;
return NULL;
}
|
the_stack_data/72299.c
|
// test52.c
char *str = "Hello world";
|
the_stack_data/93457.c
|
/* APPLE LOCAL file 6951876 */
/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
/* { dg-options "-O2" } */
/* Kludge: assuming PIC-base labels have a particular format: */
/* { dg-final { scan-assembler "\"L00\[0-9\]*\\\$pb\":" } } */
extern unsigned char*GetLine(int *s, int y);
typedef struct {
int dst;
} PIXWEIGHT ;
typedef union {
int i;
float f;
} INTTORFLOAT;
void __Rescale(int *src)
{
int i, y;
INTTORFLOAT bias;
INTTORFLOAT f;
bias.i = 22;
for (;;)
{
GetLine(src, y);
float * dstata;
PIXWEIGHT * _p;
f.f-=bias.f;
dstata[_p->dst] += f.f;
}
}
|
the_stack_data/200142973.c
|
/**
* @file minSize0.c Defines MinSize set of 0
* @brief
* Done in this way to be able to assemble various alternative sorting
* arrangements staticly, rather than requiring one to recompile an
* application as part of running a test suite. In this regard, we traded
* off the low-overhead of having lots of very small functions that do
* very little with the benefit of writing easy Makefiles that select
* which minimum size to use at static linking time.
*
* @author George Heineman
* @date 6/15/08
*/
int minSize = 0;
|
the_stack_data/1203852.c
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#define SIZE 20
struct DataItem {
int data;
int key;
};
struct DataItem* hashArray[SIZE];
struct DataItem* dummyItem;
struct DataItem* item;
int hashCode(int key) {
return key % SIZE;
}
struct DataItem *search(int key) {
int hashIndex = hashCode(key);
while(hashArray[hashIndex] != NULL) {
if(hashArray[hashIndex]->key == key)
return hashArray[hashIndex];
++hashIndex;
hashIndex %= SIZE;
}
return NULL;
}
void insert(int key,int data) {
struct DataItem *item = (struct DataItem*) malloc(sizeof(struct DataItem));
item->data = data;
item->key = key;
int hashIndex = hashCode(key);
while(hashArray[hashIndex] != NULL && hashArray[hashIndex]->key != -1) {
++hashIndex;
hashIndex %= SIZE;
}
hashArray[hashIndex] = item;
}
struct DataItem* delete(struct DataItem* item) {
int key = item->key;
int hashIndex = hashCode(key);
while(hashArray[hashIndex] != NULL) {
if(hashArray[hashIndex]->key == key) {
struct DataItem* temp = hashArray[hashIndex];
hashArray[hashIndex] = dummyItem;
return temp;
}
++hashIndex;
hashIndex %= SIZE;
}
return NULL;
}
void display() {
int i = 0;
for(i = 0; i<SIZE; i++) {
if(hashArray[i] != NULL)
printf(" (%d,%d)",hashArray[i]->key,hashArray[i]->data);
else
printf(" ~~ ");
}
printf("\n");
}
int main() {
dummyItem = (struct DataItem*) malloc(sizeof(struct DataItem));
dummyItem->data = -1;
dummyItem->key = -1;
insert(1, 20);
insert(2, 70);
insert(42, 80);
insert(4, 25);
insert(12, 44);
insert(14, 32);
insert(17, 11);
insert(13, 78);
insert(37, 97);
display();
item = search(13);
if(item != NULL) {
printf("Element found: %d\n", item->data);
} else {
printf("Element not found\n");
}
delete(item);
item = search(13);
if(item != NULL) {
printf("Element found: %d\n", item->data);
} else {
printf("Element not found\n");
}
}
|
the_stack_data/695565.c
|
# 1 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir_test.c"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir_test.c"
# 46 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir_test.c"
# 1 "/usr/include/stdio.h" 1 3 4
# 27 "/usr/include/stdio.h" 3 4
# 1 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/features.h" 1 3 4
# 339 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/features.h" 3 4
# 1 "/usr/include/sys/cdefs.h" 1 3 4
# 392 "/usr/include/sys/cdefs.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 393 "/usr/include/sys/cdefs.h" 2 3 4
# 340 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/features.h" 2 3 4
# 362 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/features.h" 3 4
# 1 "/usr/include/gnu/stubs.h" 1 3 4
# 10 "/usr/include/gnu/stubs.h" 3 4
# 1 "/usr/include/gnu/stubs-64.h" 1 3 4
# 11 "/usr/include/gnu/stubs.h" 2 3 4
# 363 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/features.h" 2 3 4
# 28 "/usr/include/stdio.h" 2 3 4
# 1 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stddef.h" 1 3 4
# 212 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stddef.h" 3 4
typedef long unsigned int size_t;
# 34 "/usr/include/stdio.h" 2 3 4
# 1 "/usr/include/bits/types.h" 1 3 4
# 27 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 28 "/usr/include/bits/types.h" 2 3 4
typedef unsigned char __u_char;
typedef unsigned short int __u_short;
typedef unsigned int __u_int;
typedef unsigned long int __u_long;
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
typedef signed short int __int16_t;
typedef unsigned short int __uint16_t;
typedef signed int __int32_t;
typedef unsigned int __uint32_t;
typedef signed long int __int64_t;
typedef unsigned long int __uint64_t;
typedef long int __quad_t;
typedef unsigned long int __u_quad_t;
# 130 "/usr/include/bits/types.h" 3 4
# 1 "/usr/include/bits/typesizes.h" 1 3 4
# 131 "/usr/include/bits/types.h" 2 3 4
typedef unsigned long int __dev_t;
typedef unsigned int __uid_t;
typedef unsigned int __gid_t;
typedef unsigned long int __ino_t;
typedef unsigned long int __ino64_t;
typedef unsigned int __mode_t;
typedef unsigned long int __nlink_t;
typedef long int __off_t;
typedef long int __off64_t;
typedef int __pid_t;
typedef struct { int __val[2]; } __fsid_t;
typedef long int __clock_t;
typedef unsigned long int __rlim_t;
typedef unsigned long int __rlim64_t;
typedef unsigned int __id_t;
typedef long int __time_t;
typedef unsigned int __useconds_t;
typedef long int __suseconds_t;
typedef int __daddr_t;
typedef int __key_t;
typedef int __clockid_t;
typedef void * __timer_t;
typedef long int __blksize_t;
typedef long int __blkcnt_t;
typedef long int __blkcnt64_t;
typedef unsigned long int __fsblkcnt_t;
typedef unsigned long int __fsblkcnt64_t;
typedef unsigned long int __fsfilcnt_t;
typedef unsigned long int __fsfilcnt64_t;
typedef long int __fsword_t;
typedef long int __ssize_t;
typedef long int __syscall_slong_t;
typedef unsigned long int __syscall_ulong_t;
typedef __off64_t __loff_t;
typedef __quad_t *__qaddr_t;
typedef char *__caddr_t;
typedef long int __intptr_t;
typedef unsigned int __socklen_t;
# 36 "/usr/include/stdio.h" 2 3 4
# 44 "/usr/include/stdio.h" 3 4
struct _IO_FILE;
typedef struct _IO_FILE FILE;
# 64 "/usr/include/stdio.h" 3 4
typedef struct _IO_FILE __FILE;
# 74 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/libio.h" 1 3 4
# 32 "/usr/include/libio.h" 3 4
# 1 "/usr/include/_G_config.h" 1 3 4
# 15 "/usr/include/_G_config.h" 3 4
# 1 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stddef.h" 1 3 4
# 16 "/usr/include/_G_config.h" 2 3 4
# 1 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/wchar.h" 1 3 4
# 57 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/wchar.h" 3 4
# 1 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stddef.h" 1 3 4
# 353 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stddef.h" 3 4
typedef unsigned int wint_t;
# 58 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/wchar.h" 2 3 4
# 1 "/usr/include/bits/wchar.h" 1 3 4
# 22 "/usr/include/bits/wchar.h" 3 4
# 1 "/usr/include/bits/wordsize.h" 1 3 4
# 23 "/usr/include/bits/wchar.h" 2 3 4
# 60 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/wchar.h" 2 3 4
# 85 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include-fixed/wchar.h" 3 4
typedef struct
{
int __count;
union
{
wint_t __wch;
char __wchb[4];
} __value;
} __mbstate_t;
# 21 "/usr/include/_G_config.h" 2 3 4
typedef struct
{
__off_t __pos;
__mbstate_t __state;
} _G_fpos_t;
typedef struct
{
__off64_t __pos;
__mbstate_t __state;
} _G_fpos64_t;
# 33 "/usr/include/libio.h" 2 3 4
# 50 "/usr/include/libio.h" 3 4
# 1 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stdarg.h" 1 3 4
# 40 "/afs/ece.cmu.edu/support/xilinx/xilinx.release/Vivado-2017.2/Vivado_HLS/2017.2/lnx64/tools/gcc/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.6.3/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
# 51 "/usr/include/libio.h" 2 3 4
# 145 "/usr/include/libio.h" 3 4
struct _IO_jump_t; struct _IO_FILE;
# 155 "/usr/include/libio.h" 3 4
typedef void _IO_lock_t;
struct _IO_marker {
struct _IO_marker *_next;
struct _IO_FILE *_sbuf;
int _pos;
# 178 "/usr/include/libio.h" 3 4
};
enum __codecvt_result
{
__codecvt_ok,
__codecvt_partial,
__codecvt_error,
__codecvt_noconv
};
# 246 "/usr/include/libio.h" 3 4
struct _IO_FILE {
int _flags;
char* _IO_read_ptr;
char* _IO_read_end;
char* _IO_read_base;
char* _IO_write_base;
char* _IO_write_ptr;
char* _IO_write_end;
char* _IO_buf_base;
char* _IO_buf_end;
char *_IO_save_base;
char *_IO_backup_base;
char *_IO_save_end;
struct _IO_marker *_markers;
struct _IO_FILE *_chain;
int _fileno;
int _flags2;
__off_t _old_offset;
unsigned short _cur_column;
signed char _vtable_offset;
char _shortbuf[1];
_IO_lock_t *_lock;
# 294 "/usr/include/libio.h" 3 4
__off64_t _offset;
# 303 "/usr/include/libio.h" 3 4
void *__pad1;
void *__pad2;
void *__pad3;
void *__pad4;
size_t __pad5;
int _mode;
char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
};
typedef struct _IO_FILE _IO_FILE;
struct _IO_FILE_plus;
extern struct _IO_FILE_plus _IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
# 339 "/usr/include/libio.h" 3 4
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
size_t __n);
typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
typedef int __io_close_fn (void *__cookie);
# 391 "/usr/include/libio.h" 3 4
extern int __underflow (_IO_FILE *);
extern int __uflow (_IO_FILE *);
extern int __overflow (_IO_FILE *, int);
# 435 "/usr/include/libio.h" 3 4
extern int _IO_getc (_IO_FILE *__fp);
extern int _IO_putc (int __c, _IO_FILE *__fp);
extern int _IO_feof (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_ferror (_IO_FILE *__fp) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_peekc_locked (_IO_FILE *__fp);
extern void _IO_flockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern void _IO_funlockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
extern int _IO_ftrylockfile (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
# 465 "/usr/include/libio.h" 3 4
extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
__gnuc_va_list, int *__restrict);
extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
__gnuc_va_list);
extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
extern void _IO_free_backup_area (_IO_FILE *) __attribute__ ((__nothrow__ , __leaf__));
# 75 "/usr/include/stdio.h" 2 3 4
typedef __gnuc_va_list va_list;
# 90 "/usr/include/stdio.h" 3 4
typedef __off_t off_t;
# 102 "/usr/include/stdio.h" 3 4
typedef __ssize_t ssize_t;
typedef _G_fpos_t fpos_t;
# 164 "/usr/include/stdio.h" 3 4
# 1 "/usr/include/bits/stdio_lim.h" 1 3 4
# 165 "/usr/include/stdio.h" 2 3 4
extern struct _IO_FILE *stdin;
extern struct _IO_FILE *stdout;
extern struct _IO_FILE *stderr;
extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__));
extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__));
extern FILE *tmpfile (void) ;
# 209 "/usr/include/stdio.h" 3 4
extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ;
# 227 "/usr/include/stdio.h" 3 4
extern char *tempnam (const char *__dir, const char *__pfx)
__attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ;
extern int fclose (FILE *__stream);
extern int fflush (FILE *__stream);
# 252 "/usr/include/stdio.h" 3 4
extern int fflush_unlocked (FILE *__stream);
# 266 "/usr/include/stdio.h" 3 4
extern FILE *fopen (const char *__restrict __filename,
const char *__restrict __modes) ;
extern FILE *freopen (const char *__restrict __filename,
const char *__restrict __modes,
FILE *__restrict __stream) ;
# 295 "/usr/include/stdio.h" 3 4
# 306 "/usr/include/stdio.h" 3 4
extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ;
# 319 "/usr/include/stdio.h" 3 4
extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
__attribute__ ((__nothrow__ , __leaf__)) ;
extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__));
extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__));
extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
size_t __size) __attribute__ ((__nothrow__ , __leaf__));
extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int fprintf (FILE *__restrict __stream,
const char *__restrict __format, ...);
extern int printf (const char *__restrict __format, ...);
extern int sprintf (char *__restrict __s,
const char *__restrict __format, ...) __attribute__ ((__nothrow__));
extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
__gnuc_va_list __arg);
extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
extern int vsprintf (char *__restrict __s, const char *__restrict __format,
__gnuc_va_list __arg) __attribute__ ((__nothrow__));
extern int snprintf (char *__restrict __s, size_t __maxlen,
const char *__restrict __format, ...)
__attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4)));
extern int vsnprintf (char *__restrict __s, size_t __maxlen,
const char *__restrict __format, __gnuc_va_list __arg)
__attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0)));
# 412 "/usr/include/stdio.h" 3 4
extern int vdprintf (int __fd, const char *__restrict __fmt,
__gnuc_va_list __arg)
__attribute__ ((__format__ (__printf__, 2, 0)));
extern int dprintf (int __fd, const char *__restrict __fmt, ...)
__attribute__ ((__format__ (__printf__, 2, 3)));
extern int fscanf (FILE *__restrict __stream,
const char *__restrict __format, ...) ;
extern int scanf (const char *__restrict __format, ...) ;
extern int sscanf (const char *__restrict __s,
const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__));
# 463 "/usr/include/stdio.h" 3 4
# 526 "/usr/include/stdio.h" 3 4
extern int fgetc (FILE *__stream);
extern int getc (FILE *__stream);
extern int getchar (void);
# 550 "/usr/include/stdio.h" 3 4
extern int getc_unlocked (FILE *__stream);
extern int getchar_unlocked (void);
# 561 "/usr/include/stdio.h" 3 4
extern int fgetc_unlocked (FILE *__stream);
extern int fputc (int __c, FILE *__stream);
extern int putc (int __c, FILE *__stream);
extern int putchar (int __c);
# 594 "/usr/include/stdio.h" 3 4
extern int fputc_unlocked (int __c, FILE *__stream);
extern int putc_unlocked (int __c, FILE *__stream);
extern int putchar_unlocked (int __c);
extern int getw (FILE *__stream);
extern int putw (int __w, FILE *__stream);
extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
;
# 638 "/usr/include/stdio.h" 3 4
extern char *gets (char *__s) __attribute__ ((__deprecated__));
# 665 "/usr/include/stdio.h" 3 4
extern __ssize_t __getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) ;
extern __ssize_t getdelim (char **__restrict __lineptr,
size_t *__restrict __n, int __delimiter,
FILE *__restrict __stream) ;
extern __ssize_t getline (char **__restrict __lineptr,
size_t *__restrict __n,
FILE *__restrict __stream) ;
extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
extern int puts (const char *__s);
extern int ungetc (int __c, FILE *__stream);
extern size_t fread (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite (const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __s);
# 737 "/usr/include/stdio.h" 3 4
extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream) ;
extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
size_t __n, FILE *__restrict __stream);
extern int fseek (FILE *__stream, long int __off, int __whence);
extern long int ftell (FILE *__stream) ;
extern void rewind (FILE *__stream);
# 773 "/usr/include/stdio.h" 3 4
extern int fseeko (FILE *__stream, __off_t __off, int __whence);
extern __off_t ftello (FILE *__stream) ;
# 792 "/usr/include/stdio.h" 3 4
extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
extern int fsetpos (FILE *__stream, const fpos_t *__pos);
# 815 "/usr/include/stdio.h" 3 4
# 824 "/usr/include/stdio.h" 3 4
extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void perror (const char *__s);
# 1 "/usr/include/bits/sys_errlist.h" 1 3 4
# 26 "/usr/include/bits/sys_errlist.h" 3 4
extern int sys_nerr;
extern const char *const sys_errlist[];
# 854 "/usr/include/stdio.h" 2 3 4
extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
# 873 "/usr/include/stdio.h" 3 4
extern FILE *popen (const char *__command, const char *__modes) ;
extern int pclose (FILE *__stream);
extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__));
# 913 "/usr/include/stdio.h" 3 4
extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ;
extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__));
# 943 "/usr/include/stdio.h" 3 4
# 47 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir_test.c" 2
# 1 "/usr/include/math.h" 1 3 4
# 29 "/usr/include/math.h" 3 4
# 1 "/usr/include/bits/huge_val.h" 1 3 4
# 34 "/usr/include/math.h" 2 3 4
# 46 "/usr/include/math.h" 3 4
# 1 "/usr/include/bits/mathdef.h" 1 3 4
# 47 "/usr/include/math.h" 2 3 4
# 70 "/usr/include/math.h" 3 4
# 1 "/usr/include/bits/mathcalls.h" 1 3 4
# 52 "/usr/include/bits/mathcalls.h" 3 4
extern double acos (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __acos (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double asin (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __asin (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double atan (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __atan (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double atan2 (double __y, double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __atan2 (double __y, double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double cos (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __cos (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double sin (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __sin (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double tan (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __tan (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double cosh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __cosh (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double sinh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __sinh (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double tanh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __tanh (double __x) __attribute__ ((__nothrow__ , __leaf__));
# 86 "/usr/include/bits/mathcalls.h" 3 4
extern double acosh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __acosh (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double asinh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __asinh (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double atanh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __atanh (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double exp (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __exp (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double frexp (double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); extern double __frexp (double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__));
extern double ldexp (double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); extern double __ldexp (double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__));
extern double log (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double log10 (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log10 (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double modf (double __x, double *__iptr) __attribute__ ((__nothrow__ , __leaf__)); extern double __modf (double __x, double *__iptr) __attribute__ ((__nothrow__ , __leaf__))
__attribute__ ((__nonnull__ (2)));
# 127 "/usr/include/bits/mathcalls.h" 3 4
extern double expm1 (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __expm1 (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double log1p (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log1p (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double logb (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __logb (double __x) __attribute__ ((__nothrow__ , __leaf__));
# 152 "/usr/include/bits/mathcalls.h" 3 4
extern double pow (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __pow (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
extern double sqrt (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __sqrt (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double hypot (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __hypot (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
extern double cbrt (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __cbrt (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern double fabs (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __fabs (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern double floor (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __floor (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern double fmod (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __fmod (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
extern int __isinf (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int __finite (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int isinf (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int finite (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern double drem (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __drem (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
extern double significand (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __significand (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double copysign (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __copysign (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
# 231 "/usr/include/bits/mathcalls.h" 3 4
extern int __isnan (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int isnan (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern double j0 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __j0 (double) __attribute__ ((__nothrow__ , __leaf__));
extern double j1 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __j1 (double) __attribute__ ((__nothrow__ , __leaf__));
extern double jn (int, double) __attribute__ ((__nothrow__ , __leaf__)); extern double __jn (int, double) __attribute__ ((__nothrow__ , __leaf__));
extern double y0 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __y0 (double) __attribute__ ((__nothrow__ , __leaf__));
extern double y1 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __y1 (double) __attribute__ ((__nothrow__ , __leaf__));
extern double yn (int, double) __attribute__ ((__nothrow__ , __leaf__)); extern double __yn (int, double) __attribute__ ((__nothrow__ , __leaf__));
extern double erf (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __erf (double) __attribute__ ((__nothrow__ , __leaf__));
extern double erfc (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __erfc (double) __attribute__ ((__nothrow__ , __leaf__));
extern double lgamma (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __lgamma (double) __attribute__ ((__nothrow__ , __leaf__));
# 265 "/usr/include/bits/mathcalls.h" 3 4
extern double gamma (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __gamma (double) __attribute__ ((__nothrow__ , __leaf__));
extern double lgamma_r (double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); extern double __lgamma_r (double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__));
extern double rint (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __rint (double __x) __attribute__ ((__nothrow__ , __leaf__));
extern double nextafter (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __nextafter (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern double remainder (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __remainder (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__));
extern double scalbn (double __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); extern double __scalbn (double __x, int __n) __attribute__ ((__nothrow__ , __leaf__));
extern int ilogb (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern int __ilogb (double __x) __attribute__ ((__nothrow__ , __leaf__));
# 359 "/usr/include/bits/mathcalls.h" 3 4
extern double scalb (double __x, double __n) __attribute__ ((__nothrow__ , __leaf__)); extern double __scalb (double __x, double __n) __attribute__ ((__nothrow__ , __leaf__));
# 71 "/usr/include/math.h" 2 3 4
# 89 "/usr/include/math.h" 3 4
# 1 "/usr/include/bits/mathcalls.h" 1 3 4
# 52 "/usr/include/bits/mathcalls.h" 3 4
extern float acosf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __acosf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float asinf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __asinf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float atanf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __atanf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float atan2f (float __y, float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __atan2f (float __y, float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float cosf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __cosf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float sinf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __sinf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float tanf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __tanf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float coshf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __coshf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float sinhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __sinhf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float tanhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __tanhf (float __x) __attribute__ ((__nothrow__ , __leaf__));
# 86 "/usr/include/bits/mathcalls.h" 3 4
extern float acoshf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __acoshf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float asinhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __asinhf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float atanhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __atanhf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float expf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __expf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float frexpf (float __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); extern float __frexpf (float __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__));
extern float ldexpf (float __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); extern float __ldexpf (float __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__));
extern float logf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __logf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float log10f (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __log10f (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float modff (float __x, float *__iptr) __attribute__ ((__nothrow__ , __leaf__)); extern float __modff (float __x, float *__iptr) __attribute__ ((__nothrow__ , __leaf__))
__attribute__ ((__nonnull__ (2)));
# 127 "/usr/include/bits/mathcalls.h" 3 4
extern float expm1f (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __expm1f (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float log1pf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __log1pf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float logbf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __logbf (float __x) __attribute__ ((__nothrow__ , __leaf__));
# 152 "/usr/include/bits/mathcalls.h" 3 4
extern float powf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __powf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__));
extern float sqrtf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __sqrtf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float hypotf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __hypotf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__));
extern float cbrtf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __cbrtf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float ceilf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __ceilf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern float fabsf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __fabsf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern float floorf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __floorf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern float fmodf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __fmodf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__));
extern int __isinff (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int __finitef (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int isinff (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int finitef (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern float dremf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __dremf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__));
extern float significandf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __significandf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float copysignf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
# 231 "/usr/include/bits/mathcalls.h" 3 4
extern int __isnanf (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int isnanf (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern float j0f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __j0f (float) __attribute__ ((__nothrow__ , __leaf__));
extern float j1f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __j1f (float) __attribute__ ((__nothrow__ , __leaf__));
extern float jnf (int, float) __attribute__ ((__nothrow__ , __leaf__)); extern float __jnf (int, float) __attribute__ ((__nothrow__ , __leaf__));
extern float y0f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __y0f (float) __attribute__ ((__nothrow__ , __leaf__));
extern float y1f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __y1f (float) __attribute__ ((__nothrow__ , __leaf__));
extern float ynf (int, float) __attribute__ ((__nothrow__ , __leaf__)); extern float __ynf (int, float) __attribute__ ((__nothrow__ , __leaf__));
extern float erff (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __erff (float) __attribute__ ((__nothrow__ , __leaf__));
extern float erfcf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __erfcf (float) __attribute__ ((__nothrow__ , __leaf__));
extern float lgammaf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __lgammaf (float) __attribute__ ((__nothrow__ , __leaf__));
# 265 "/usr/include/bits/mathcalls.h" 3 4
extern float gammaf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __gammaf (float) __attribute__ ((__nothrow__ , __leaf__));
extern float lgammaf_r (float, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); extern float __lgammaf_r (float, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__));
extern float rintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __rintf (float __x) __attribute__ ((__nothrow__ , __leaf__));
extern float nextafterf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __nextafterf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern float remainderf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __remainderf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__));
extern float scalbnf (float __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); extern float __scalbnf (float __x, int __n) __attribute__ ((__nothrow__ , __leaf__));
extern int ilogbf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern int __ilogbf (float __x) __attribute__ ((__nothrow__ , __leaf__));
# 359 "/usr/include/bits/mathcalls.h" 3 4
extern float scalbf (float __x, float __n) __attribute__ ((__nothrow__ , __leaf__)); extern float __scalbf (float __x, float __n) __attribute__ ((__nothrow__ , __leaf__));
# 90 "/usr/include/math.h" 2 3 4
# 133 "/usr/include/math.h" 3 4
# 1 "/usr/include/bits/mathcalls.h" 1 3 4
# 52 "/usr/include/bits/mathcalls.h" 3 4
extern long double acosl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __acosl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double asinl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __asinl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double atanl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __atanl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double atan2l (long double __y, long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __atan2l (long double __y, long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double cosl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __cosl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double sinl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __sinl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double tanl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __tanl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double coshl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __coshl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double sinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __sinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double tanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __tanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
# 86 "/usr/include/bits/mathcalls.h" 3 4
extern long double acoshl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __acoshl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double asinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __asinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double atanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __atanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double expl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __expl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double frexpl (long double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); extern long double __frexpl (long double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__));
extern long double ldexpl (long double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); extern long double __ldexpl (long double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__));
extern long double logl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __logl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double log10l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __log10l (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double modfl (long double __x, long double *__iptr) __attribute__ ((__nothrow__ , __leaf__)); extern long double __modfl (long double __x, long double *__iptr) __attribute__ ((__nothrow__ , __leaf__))
__attribute__ ((__nonnull__ (2)));
# 127 "/usr/include/bits/mathcalls.h" 3 4
extern long double expm1l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __expm1l (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double log1pl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __log1pl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double logbl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __logbl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
# 152 "/usr/include/bits/mathcalls.h" 3 4
extern long double powl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __powl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__));
extern long double sqrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __sqrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double hypotl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __hypotl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__));
extern long double cbrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __cbrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double ceill (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __ceill (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern long double fabsl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __fabsl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern long double floorl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __floorl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern long double fmodl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __fmodl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__));
extern int __isinfl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int __finitel (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int isinfl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int finitel (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern long double dreml (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __dreml (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__));
extern long double significandl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __significandl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double copysignl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
# 231 "/usr/include/bits/mathcalls.h" 3 4
extern int __isnanl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern int isnanl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern long double j0l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __j0l (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double j1l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __j1l (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double jnl (int, long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __jnl (int, long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double y0l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __y0l (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double y1l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __y1l (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double ynl (int, long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __ynl (int, long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double erfl (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __erfl (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double erfcl (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __erfcl (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double lgammal (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __lgammal (long double) __attribute__ ((__nothrow__ , __leaf__));
# 265 "/usr/include/bits/mathcalls.h" 3 4
extern long double gammal (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __gammal (long double) __attribute__ ((__nothrow__ , __leaf__));
extern long double lgammal_r (long double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); extern long double __lgammal_r (long double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__));
extern long double rintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __rintl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
extern long double nextafterl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __nextafterl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__));
extern long double remainderl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __remainderl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__));
extern long double scalbnl (long double __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); extern long double __scalbnl (long double __x, int __n) __attribute__ ((__nothrow__ , __leaf__));
extern int ilogbl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern int __ilogbl (long double __x) __attribute__ ((__nothrow__ , __leaf__));
# 359 "/usr/include/bits/mathcalls.h" 3 4
extern long double scalbl (long double __x, long double __n) __attribute__ ((__nothrow__ , __leaf__)); extern long double __scalbl (long double __x, long double __n) __attribute__ ((__nothrow__ , __leaf__));
# 134 "/usr/include/math.h" 2 3 4
# 149 "/usr/include/math.h" 3 4
extern int signgam;
# 288 "/usr/include/math.h" 3 4
typedef enum
{
_IEEE_ = -1,
_SVID_,
_XOPEN_,
_POSIX_,
_ISOC_
} _LIB_VERSION_TYPE;
extern _LIB_VERSION_TYPE _LIB_VERSION;
# 313 "/usr/include/math.h" 3 4
struct exception
{
int type;
char *name;
double arg1;
double arg2;
double retval;
};
extern int matherr (struct exception *__exc);
# 475 "/usr/include/math.h" 3 4
# 48 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir_test.c" 2
# 1 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.h" 1
# 50 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir.h"
typedef int coef_t;
typedef int data_t;
typedef int acc_t;
void fir (
data_t *y,
coef_t c[11 +1],
data_t x
);
# 49 "/afs/ece.cmu.edu/usr/markb1/Documents/fpga_sandbox/RecComp/Lab2/ug871-design-files/Introduction/lab1/fir_test.c" 2
int main () {
const int SAMPLES=600;
FILE *fp;
data_t signal, output;
coef_t taps[11] = {0,-10,-9,23,56,63,56,23,-9,-10,0,};
int i, ramp_up;
signal = 0;
ramp_up = 1;
fp=fopen("out.dat","w");
for (i=0;i<=SAMPLES;i++) {
if (ramp_up == 1)
signal = signal + 1;
else
signal = signal - 1;
fir(&output,taps,signal);
if ((ramp_up == 1) && (signal >= 75))
ramp_up = 0;
else if ((ramp_up == 0) && (signal <= -75))
ramp_up = 1;
fprintf(fp,"%i %d %d\n",i,signal,output);
}
fclose(fp);
printf ("Comparing against output data \n");
if (system("diff -w out.dat out.gold.dat")) {
fprintf(stdout, "*******************************************\n");
fprintf(stdout, "FAIL: Output DOES NOT match the golden output\n");
fprintf(stdout, "*******************************************\n");
return 1;
} else {
fprintf(stdout, "*******************************************\n");
fprintf(stdout, "PASS: The output matches the golden output!\n");
fprintf(stdout, "*******************************************\n");
return 0;
}
}
|
the_stack_data/73111.c
|
#include<stdio.h>
#include<math.h>
int main()
{
long long int a,b,x,p,i,j,k,t;
scanf("%lld",&t);
for(i=0;i<t;i++)
{
scanf("%lld %lld %lld",&a,&b,&x);
p=pow(a,b);
k=p%x;
if(k>x/2)
{
printf("%lld\n",(p/x)*x+x);
}
else
{
printf("%lld\n",(p/x)*x);
}
}
return 0;
}
|
the_stack_data/218892305.c
|
#define ROW_ARGS (unsigned char *source_row_start, unsigned char *source_row_end, unsigned char *destination_row_start, int srcMask, int destMask)
void _left_right_alpha_src_dest_mask ROW_ARGS
{
unsigned char *source_row_ptr;
unsigned char *destination_row_ptr = destination_row_start;
for ( source_row_ptr = source_row_start; source_row_ptr < source_row_end ; source_row_ptr++ )
{
if (*source_row_ptr) *destination_row_ptr= (*destination_row_ptr &~destMask) | (srcMask & *source_row_ptr);
destination_row_ptr++;
}
}
void _right_left_alpha_src_dest_mask ROW_ARGS
{
unsigned char *source_row_ptr;
unsigned char *destination_row_ptr = destination_row_start;
for ( source_row_ptr = source_row_end-1; source_row_ptr >= source_row_start ; source_row_ptr-- )
{
if (*source_row_ptr) *destination_row_ptr= (*destination_row_ptr &~destMask) | ( srcMask & *source_row_ptr);
destination_row_ptr++;
}
}
|
the_stack_data/54657.c
|
/*
* Copyright (c) 2011, 2012, 2013, 2014, 2015 Jonas 'Sortie' Termansen.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* stdio/fputs_unlocked.c
* Writes a string to a FILE.
*/
#include <stdio.h>
#include <string.h>
int fputs_unlocked(const char* str, FILE* fp)
{
size_t stringlen = strlen(str);
if ( fwrite_unlocked(str, 1, stringlen, fp) < stringlen )
return EOF;
return 0;
}
|
the_stack_data/91904.c
|
#include<stdio.h>
int main()
{
int n,sum=0,a[20];
float avg;
printf("Enter a no : ");
scanf("%d",&n);
printf("\nThe values : ");
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int i=0;i<n;i++)
sum+=a[i];
printf("\nAvg= %f",sum/(n*1.0));
return 0;
}
|
the_stack_data/19600.c
|
#include <stdio.h>
#include <math.h>
#define EXIT_SUCCESS 0
#define EXIT_FAILURE -9
#define MAX_M 1024
typedef long RANDOM_TYPE;
/*********************************/
int main(void) {
long i, j;
RANDOM_TYPE a, b, m, seed, randomNumber;
RANDOM_TYPE randomSeen[MAX_M+1];
a = 7;
b = 7;
m = 10;
seed = 7;
seed = seed % m;
printf("a = %ld b = %ld m = %ld I0 = %ld\n",
a, b, m, seed);
for(i = 1; i <= m; i++){
randomSeen[i] = 0;
}
randomNumber = seed;
randomSeen[randomNumber] = 1;
if(m > MAX_M){
printf("Errore: m troppo grande.\n");
exit(EXIT_FAILURE);
}
for(i = 1; i <= m; i++){
randomNumber = (a * randomNumber + b) % m;
if(randomSeen[randomNumber]>0){
printf("Fatto: T = %ld\n", i + 1 - randomSeen[randomNumber]);
exit(EXIT_SUCCESS);
}else{
randomSeen[randomNumber] = i + 1;
}
}
printf("Errore (inconsistenza grave): periodo non trovato.\n");
exit(EXIT_FAILURE);
}
|
the_stack_data/247017071.c
|
#include <time.h>
char* asctime(const struct tm* timeptr)
{
static char buf[26];
return asctime_r(timeptr, buf);
}
|
the_stack_data/1086553.c
|
// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
int* a = &(int){1};
struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
_Complex double * x = &(_Complex double){1.0f};
typedef int v4i32 __attribute((vector_size(16)));
v4i32 *y = &(v4i32){1,2,3,4};
void xxx() {
int* a = &(int){1};
struct s {int a, b, c;} * b = &(struct s) {1, 2, 3};
_Complex double * x = &(_Complex double){1.0f};
}
// CHECK: define void @f()
void f() {
typedef struct S { int x,y; } S;
// CHECK: [[S:%[a-zA-Z0-9.]+]] = alloca [[STRUCT:%[a-zA-Z0-9.]+]],
struct S s;
// CHECK-NEXT: [[COMPOUNDLIT:%[a-zA-Z0-9.]+]] = alloca [[STRUCT]]
// CHECK-NEXT: [[CX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 0
// CHECK-NEXT: [[SY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 1
// CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SY]]
// CHECK-NEXT: store i32 [[TMP]], i32* [[CX]]
// CHECK-NEXT: [[CY:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[COMPOUNDLIT]], i32 0, i32 1
// CHECK-NEXT: [[SX:%[a-zA-Z0-9.]+]] = getelementptr inbounds [[STRUCT]]* [[S]], i32 0, i32 0
// CHECK-NEXT: [[TMP:%[a-zA-Z0-9.]+]] = load i32* [[SX]]
// CHECK-NEXT: store i32 [[TMP]], i32* [[CY]]
// CHECK-NEXT: [[SI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[S]] to i8*
// CHECK-NEXT: [[COMPOUNDLITI8:%[a-zA-Z0-9.]+]] = bitcast [[STRUCT]]* [[COMPOUNDLIT]] to i8*
// CHECK-NEXT: call void @llvm.memcpy{{.*}}(i8* [[SI8]], i8* [[COMPOUNDLITI8]]
s = (S){s.y,s.x};
// CHECK-NEXT: ret void
}
// CHECK: define i48 @g(
struct G { short x, y, z; };
struct G g(int x, int y, int z) {
// CHECK: [[RESULT:%.*]] = alloca [[G:%.*]], align 2
// CHECK-NEXT: [[X:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[Y:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[Z:%.*]] = alloca i32, align 4
// CHECK-NEXT: [[COERCE_TEMP:%.*]] = alloca i48
// CHECK-NEXT: store i32
// CHECK-NEXT: store i32
// CHECK-NEXT: store i32
// Evaluate the compound literal directly in the result value slot.
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[G]]* [[RESULT]], i32 0, i32 0
// CHECK-NEXT: [[T1:%.*]] = load i32* [[X]], align 4
// CHECK-NEXT: [[T2:%.*]] = trunc i32 [[T1]] to i16
// CHECK-NEXT: store i16 [[T2]], i16* [[T0]], align 2
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[G]]* [[RESULT]], i32 0, i32 1
// CHECK-NEXT: [[T1:%.*]] = load i32* [[Y]], align 4
// CHECK-NEXT: [[T2:%.*]] = trunc i32 [[T1]] to i16
// CHECK-NEXT: store i16 [[T2]], i16* [[T0]], align 2
// CHECK-NEXT: [[T0:%.*]] = getelementptr inbounds [[G]]* [[RESULT]], i32 0, i32 2
// CHECK-NEXT: [[T1:%.*]] = load i32* [[Z]], align 4
// CHECK-NEXT: [[T2:%.*]] = trunc i32 [[T1]] to i16
// CHECK-NEXT: store i16 [[T2]], i16* [[T0]], align 2
return (struct G) { x, y, z };
// CHECK-NEXT: [[T0:%.*]] = bitcast i48* [[COERCE_TEMP]] to i8*
// CHECK-NEXT: [[T1:%.*]] = bitcast [[G]]* [[RESULT]] to i8*
// CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[T0]], i8* [[T1]], i64 6
// CHECK-NEXT: [[T0:%.*]] = load i48* [[COERCE_TEMP]]
// CHECK-NEXT: ret i48 [[T0]]
}
|
the_stack_data/1148726.c
|
// Generated automatically from mod/strings.oba. Do not edit.
const char* stringsModSource =
"// Trim removes leading and trailing whitespace from a string.\n"
"fn trim s {\n"
"return __native_string_trim(s)\n"
"}\n";
|
the_stack_data/18588.c
|
#include <stdio.h>
#include <math.h>
int b[10001],a[103];
int max (int a, int b){
if (a>b){ return a;}
else { return b;}
}
int min (int a, int b){
if(a<b){ return a;}
else { return b;}
}
int H(int m,int n){
int a=b[m];
for (m; m+1 <=n; ++m) {
a=a^b[m+1];
}
return a;}
int N(int m,int n,int k){int a=0;
for (m; m <=n ;m++){
a+=b[m]%k;
a%=k;
}
return a;}
int M(int m, int n,int k){
int a=1;
for (m; m <=n ;m++) {
a*=b[m]%k;
a%=k;
}
return a;
}
int main()
{
int m,n;
int a_1,a_2;
scanf("%d%d",&m,&n);
for (int i = 0; i < m; ++i) {
scanf("%d",&b[i]);
}
for (int j = 0; j <n ; ++j) {
{ scanf("%d%d",&a_1,&a_2) ;a[j]=H(min(N(a_1,a_2,m),M(a_1,a_2,m)),max(N(a_1,a_2,m),M(a_1,a_2,m)));
}}
for (int k = 0; k <n ; ++k) {printf("%d\n",a[k]);
}
return 0;
}
|
the_stack_data/110039.c
|
/* Name: 5-3.c
Purpose: Exercise 5-3.
Author: K.N. King.
Date: 22.03.2022 */
#include <stdio.h>
int main(void)
{
int i, j, k;
/*(a)*/
i = 3; j = 4; k = 5;
printf("%d ", i < j || ++j < k);
printf("%d %d %d\n", i, j, k);
/*(b)*/
i = 7; j = 8; k = 9;
printf("%d ", i - 7 && j++ < k);
printf("%d %d %d\n", i, j, k);
/*(c)*/
i = 7; j = 8; k = 9;
printf("%d ", (i = j) || (j = k));
printf("%d %d %d\n", i, j, k);
/*(d)*/
i = 1; j = 1; k = 1;
printf("%d ", ++i || ++j && ++k);
printf("%d %d %d\n", i, j, k);
return 0;
}
|
the_stack_data/28263132.c
|
/* Andre Augusto Giannotti Scota (https://sites.google.com/view/a2gs/) */
#include <stdio.h>
#include <math.h>
#define LR_OK (0)
#define LR_ERRO (1)
static inline float AngularCoefficientLR(unsigned int n, float sumXY, float sumX, float sumY, float sumXsquare)
{
return(((n * sumXY) - (sumX * sumY)) / ((n * sumXsquare) - powf(sumX, 2.0)));
}
static inline float InterceptLR(unsigned int n, float sumY, float angulCoef, float sumX)
{
return(((sumY - (angulCoef * sumX)) / n));
}
static inline float CorrelationCoefficientLR(unsigned int n, float sumX, float sumY, float sumXY, float sumXsquare, float sumYsquare)
{
return(((n * sumXY) - (sumX * sumY)) / (sqrtf(((n * sumXsquare) - (powf(sumX, 2.0)))) * sqrtf(((n * sumYsquare) - (powf(sumY, 2.0))))));
}
static inline void SummarizationLR(float points[][2], unsigned int n, float *sumX, float *sumY, float *sumXY, float *sumXsquare, float *sumYsquare)
{
unsigned int i = 0;
for(i = 0, *sumX = 0.0, *sumY = 0.0, *sumXY = 0.0, *sumXsquare = 0.0, *sumYsquare = 0.0; i < n; i++){
*sumX += points[i][0];
*sumY += points[i][1];
*sumXsquare += powf(points[i][0], 2.0);
*sumYsquare += powf(points[i][1], 2.0);
*sumXY += points[i][0] * points[i][1];
}
return;
}
int LinearRegression(float points[][2], const unsigned int n, float *intercept, float *angulCoef, float *correlatCoef)
{
float sumX = 0.0;
float sumY = 0.0;
float sumXY = 0.0;
float sumXsquare = 0.0;
float sumYsquare = 0.0;
SummarizationLR(points, n, &sumX, &sumY, &sumXY, &sumXsquare, &sumYsquare);
*angulCoef = AngularCoefficientLR(n, sumXY, sumX, sumY, sumXsquare);
*intercept = InterceptLR(n, sumY, *angulCoef, sumX);
*correlatCoef = CorrelationCoefficientLR(n, sumX, sumY, sumXY, sumXsquare, sumYsquare);
return(LR_OK);
}
int main(int argc, char *argv[])
{
int n = 4;
float m[4][2] = {{3.0, 7.0}, {2.0, 5.0}, {-1.0, -1.0}, {4.0, 9.0}};
float a = 0.0, b = 0.0;
float cc = 0.0;
printf("Sample:\n");
printf(" X | Y\n");
printf("------+------\n");
printf("%02.02f | %02.02f\n", m[0][0], m[0][1]);
printf("%02.02f | %02.02f\n", m[1][0], m[1][1]);
printf("%02.02f | %02.02f\n", m[2][0], m[2][1]);
printf("%02.02f | %02.02f\n\n", m[3][0], m[3][1]);
if(LinearRegression(m, n, &a, &b, &cc) == LR_ERRO){
printf("Linear Regression error.\n");
return(-1);
}
printf("f(x) = [%02.02f]x + [%02.02f]\n", a, b);
printf("Correlation coefficient: [%02.02f]\n", cc);
return(0);
}
|
the_stack_data/98575105.c
|
#include <unistd.h>
#include <sys/syscall.h>
int
main() {
long rtn = syscall(0xc, 0);
asm ("int3");
}
|
the_stack_data/36074772.c
|
#include <stdio.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
int main()
{
int soc, n;
int bytesReceived = 0;
char buffer[1024], fname[100];
struct sockaddr_in addr;
soc = socket(PF_INET, SOCK_STREAM, 0);
addr.sin_family = AF_INET;
addr.sin_port = htons(5000);
addr.sin_addr.s_addr = inet_addr("127.0.0.1");
while(connect(soc, (struct sockaddr *) &addr, sizeof(addr))) ;
printf("\nClient is connected to Server");
printf("\nEnter file name: ");
scanf("%s", fname);
send(soc, fname, sizeof(fname), 0);
printf("\nRecieved response\n");
FILE *fp;
fp = fopen(fname, "ab");
if(NULL == fp)
{
printf("File does not exist");
return 1;
}
long double sz=1;
while((bytesReceived = read(soc, buffer, 1024)) > 0)
{
sz++;
fflush(stdout);
fwrite(buffer, 1,bytesReceived,fp);
// printf("%s \n", buffer);
}
printf("\nFile Recieved Completed\n");
return 0;
}
|
the_stack_data/1201501.c
|
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <math.h>
int main(){
char a = 'a';
printf("%c\n", toupper(a));
return 0;
}
|
the_stack_data/571253.c
|
#include <stdio.h>
#include <math.h>
void main() {
float f_pi = acos(-1.0);
double d_pi = acos(-1.0);
printf("%f\n",f_pi);
printf("%lf\n",d_pi);
printf("%.20f\n",f_pi);
printf("%.20lf\n",d_pi);
f_pi = f_pi * 7.0;
d_pi = d_pi * 7.0;
f_pi = f_pi * (1.0 / 7.0);
d_pi = d_pi * (1.0 / 7.0);
printf("%.20f\n",f_pi);
printf("%.20lf\n",d_pi);
int i;
for (i = 2; i < 20; i++) {
f_pi = f_pi * (float)i;
d_pi = d_pi * (double)i;
}
for (i = 2; i < 20; i++) {
f_pi = f_pi * (1.0 / (float)i);
d_pi = d_pi * (1.0 / (double)i);
}
printf("%.20f\n",f_pi);
printf("%.20lf\n",d_pi);
return;
}
/*
On a 64bit linux system this program produces the following:
[root@pilgrim ~]# gcc 02_26.c
[root@pilgrim ~]# ./a.out
3.141593
3.141593
3.14159274101257324219
3.14159265358979311600
3.14159274101257324219
3.14159265358979311600
3.14159297943115234375
3.14159265358979267191
[root@pilgrim ~]#
*/
|
the_stack_data/935512.c
|
/* text version of maze 'mazefiles/binary/uk2001f.maz'
generated by mazetool (c) Peter Harrison 2018
o---o---o---o---o---o---o---o---o---o---o---o---o---o---o---o---o
| | | | |
o o o o---o o---o o o---o o---o---o---o---o o o
| | | | | | | | | | |
o o---o---o o---o o o o o---o o o o o o o
| | | | | | | | | | | | |
o o o---o o o o---o---o---o o o o o---o o o
| | | | | | | | | | |
o o o---o o o---o---o o o o o o---o---o---o o
| | | | | | | |
o o---o---o o---o---o---o---o o o o---o---o---o---o o
| | | | | | |
o o---o o---o---o o---o---o o o o---o---o---o---o o
| | | | |
o o---o---o o---o o---o---o---o---o---o---o o---o---o---o
| | | | | | | |
o o---o---o---o o---o---o o o o---o o---o o---o o
| | | | |
o o---o---o o---o---o---o o---o o o---o---o---o---o o
| | | | | | |
o o---o o o---o o o---o o o o o---o---o---o o
| | | | | | | |
o o---o---o---o o---o o o o o o o---o---o o---o
| | | | | | | | | |
o o o---o o---o o o o o o o o---o---o---o o
| | | | | | | |
o o---o o---o---o o o---o o o---o---o---o---o---o o
| | | | | | | |
o---o o o---o o o o---o o o o---o o---o o o
| | | | | | | | | |
o o---o o---o---o---o---o---o---o---o---o o---o---o o o
| | | |
o---o---o---o---o---o---o---o---o---o---o---o---o---o---o---o---o
*/
int uk2001f_maz[] ={
0x0E, 0x09, 0x0E, 0x08, 0x0A, 0x08, 0x08, 0x08, 0x08, 0x0A, 0x08, 0x08, 0x0A, 0x0A, 0x0A, 0x09,
0x0D, 0x06, 0x09, 0x04, 0x09, 0x05, 0x05, 0x05, 0x05, 0x0D, 0x05, 0x04, 0x0A, 0x09, 0x0E, 0x01,
0x04, 0x08, 0x02, 0x03, 0x07, 0x04, 0x03, 0x07, 0x05, 0x04, 0x01, 0x05, 0x0D, 0x07, 0x0C, 0x01,
0x05, 0x05, 0x0D, 0x0C, 0x09, 0x06, 0x08, 0x09, 0x06, 0x01, 0x06, 0x02, 0x00, 0x0A, 0x01, 0x05,
0x05, 0x04, 0x03, 0x07, 0x06, 0x09, 0x07, 0x04, 0x0B, 0x05, 0x0D, 0x0C, 0x02, 0x09, 0x06, 0x01,
0x05, 0x06, 0x0A, 0x0A, 0x0B, 0x06, 0x0B, 0x05, 0x0C, 0x02, 0x01, 0x05, 0x0E, 0x02, 0x09, 0x05,
0x05, 0x0E, 0x0A, 0x0A, 0x0A, 0x08, 0x09, 0x07, 0x07, 0x0D, 0x07, 0x07, 0x0D, 0x0C, 0x02, 0x03,
0x05, 0x0D, 0x0D, 0x0E, 0x08, 0x03, 0x06, 0x08, 0x09, 0x05, 0x0D, 0x0E, 0x01, 0x04, 0x0A, 0x09,
0x05, 0x06, 0x02, 0x08, 0x02, 0x0A, 0x09, 0x06, 0x03, 0x04, 0x02, 0x0A, 0x03, 0x06, 0x09, 0x07,
0x05, 0x0E, 0x08, 0x02, 0x0A, 0x0A, 0x02, 0x08, 0x09, 0x04, 0x0A, 0x0A, 0x0A, 0x0B, 0x04, 0x0B,
0x05, 0x0E, 0x01, 0x0C, 0x0A, 0x0A, 0x08, 0x01, 0x07, 0x04, 0x08, 0x08, 0x0A, 0x0A, 0x03, 0x0D,
0x04, 0x0B, 0x05, 0x04, 0x08, 0x08, 0x01, 0x04, 0x09, 0x05, 0x05, 0x04, 0x0A, 0x0A, 0x0B, 0x05,
0x05, 0x0C, 0x01, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06, 0x03, 0x05, 0x07, 0x0C, 0x0A, 0x09, 0x05,
0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x04, 0x09, 0x0D, 0x05, 0x0D, 0x05, 0x0E, 0x03, 0x05,
0x06, 0x02, 0x01, 0x05, 0x04, 0x01, 0x05, 0x05, 0x05, 0x05, 0x07, 0x05, 0x06, 0x0A, 0x0A, 0x01,
0x0E, 0x0A, 0x02, 0x02, 0x03, 0x06, 0x02, 0x02, 0x03, 0x06, 0x0A, 0x02, 0x0A, 0x0A, 0x0A, 0x03,
};
/* end of mazefile */
|
the_stack_data/128633.c
|
//
// main.c
// 1072 - Calm Down
//
// Created by Anirudha on 5/30/14.
// Copyright (c) 2014 Anirudha Paul. All rights reserved.
//
#include <stdio.h>
#include <math.h>
#define PI 3.14159265358979
int main()
{
int cases, caseNo;
scanf("%d",&cases);
for(caseNo = 0; caseNo < cases; caseNo++)
{
double big_radius, small_radius, sides;
scanf("%lf",&big_radius);
scanf("%lf", &sides);
small_radius = (big_radius * sin((180.0 * PI / 180.0)/sides)) / (1 + sin((180.0 * PI / 180.0)/sides));
printf("Case %d: %.10lf\n", caseNo+1, small_radius);
}
return 0;
}
|
the_stack_data/20382.c
|
/**
* @file smComT1oI2C.c
* @author NXP Semiconductors
* @version 1.0
* @par License
* Copyright 2016-2018 NXP
*
* This software is owned or controlled by NXP and may only be used
* strictly in accordance with the applicable license terms. By expressly
* accepting such terms or by downloading, installing, activating and/or
* otherwise using the software, you are agreeing that you have read, and
* that you agree to comply with and are bound by, such license terms. If
* you do not agree to be bound by the applicable license terms, then you
* may not retain, install, activate or otherwise use the software.
*
* @par Description
* This file implements the SmCom T1oI2C communication layer.
*
*****************************************************************************/
#ifdef T1oI2C
#include <assert.h>
#include "smComT1oI2C.h"
#include "phNxpEse_Api.h"
#include "phNxpEseProto7816_3.h"
#include "i2c_a7.h"
#include "sm_printf.h"
#include "phEseStatus.h"
#include "sm_apdu.h"
#ifdef FLOW_VERBOSE
#define NX_LOG_ENABLE_SMCOM_DEBUG 1
#else
//#define NX_LOG_ENABLE_SMCOM_DEBUG 1
#endif
#include "nxLog_smCom.h"
#include "nxEnsure.h"
static U32 smComT1oI2C_Transceive(apdu_t * pApdu);
static U32 smComT1oI2C_TransceiveRaw(U8 * pTx, U16 txLen, U8 * pRx, U32 * pRxLen);
U16 smComT1oI2C_AnswerToReset(U8 *T1oI2Catr, U16 *T1oI2CatrLen);
U16 smComT1oI2C_Close(U8 mode)
{
ESESTATUS status;
status=phNxpEse_EndOfApdu();
//status=phNxpEse_chipReset();
if(status ==ESESTATUS_SUCCESS)
{
status=phNxpEse_close();
}
else
{
LOG_E("Failed to close session ");
return SMCOM_COM_FAILED;
}
return SMCOM_OK;
}
U16 smComT1oI2C_Open(U8 mode, U8 seqCnt, U8 *T1oI2Catr, U16 *T1oI2CatrLen)
{
ESESTATUS ret;
phNxpEse_data AtrRsp;
AtrRsp.len = *T1oI2CatrLen;
AtrRsp.p_data = T1oI2Catr;
phNxpEse_initParams initParams;
initParams.initMode = ESE_MODE_NORMAL;
ret=phNxpEse_open(initParams);
if (ret != ESESTATUS_SUCCESS)
{
LOG_E(" Failed to create physical connection with ESE ");
return SMCOM_COM_FAILED;
}
ret=phNxpEse_init(initParams, &AtrRsp);
if (ret != ESESTATUS_SUCCESS)
{
*T1oI2CatrLen=0;
LOG_E(" Failed to Open session ");
return SMCOM_COM_FAILED;
}
else
{
*T1oI2CatrLen = AtrRsp.len ; /*Retrive INF FIELD*/
}
smCom_Init(&smComT1oI2C_Transceive, &smComT1oI2C_TransceiveRaw);
return SMCOM_OK;
}
static U32 smComT1oI2C_Transceive(apdu_t * pApdu)
{
U32 respLen= MAX_APDU_BUF_LENGTH;
U32 retCode = SMCOM_COM_FAILED;
ENSURE_OR_GO_EXIT(pApdu != NULL);
retCode = smComT1oI2C_TransceiveRaw((U8 *)pApdu->pBuf, pApdu->buflen, pApdu->pBuf, &respLen);
pApdu->rxlen = (U16)respLen;
exit:
return retCode;
}
static U32 smComT1oI2C_TransceiveRaw(U8 * pTx, U16 txLen, U8 * pRx, U32 * pRxLen)
{
phNxpEse_data pCmdTrans;
phNxpEse_data pRspTrans={0};
ESESTATUS txnStatus;
pCmdTrans.len = txLen;
pCmdTrans.p_data = pTx;
pRspTrans.len = *pRxLen;
pRspTrans.p_data = pRx;
LOG_MAU8_D("APDU Tx>", pTx, txLen);
txnStatus = phNxpEse_Transceive(&pCmdTrans, &pRspTrans);
if ( txnStatus == ESESTATUS_SUCCESS )
{
*pRxLen = pRspTrans.len;
memcpy(pRx, pRspTrans.p_data ,pRspTrans.len);
LOG_MAU8_D("APDU Rx<", pRx, pRspTrans.len);
}
else
{
*pRxLen = 0;
LOG_E(" Transcive Failed ");
return SMCOM_SND_FAILED;
}
return SMCOM_OK;
}
U16 smComT1oI2C_AnswerToReset(U8 *T1oI2Catr, U16 *T1oI2CatrLen)
{
phNxpEse_data pRsp= {0};
ESESTATUS txnStatus;
U16 status = SMCOM_NO_ATR;
ENSURE_OR_GO_EXIT(T1oI2Catr != NULL);
ENSURE_OR_GO_EXIT(T1oI2CatrLen != NULL);
#if defined(T1oI2C_UM1225_SE050)
txnStatus= phNxpEse_getAtr(&pRsp);
#elif defined(T1oI2C_GP)
txnStatus= phNxpEse_getCip(&pRsp);
#endif
if(txnStatus == ESESTATUS_SUCCESS)
{
*T1oI2CatrLen = pRsp.len;
if (pRsp.len > 0) {
memcpy(T1oI2Catr, pRsp.p_data, pRsp.len);
status = SMCOM_OK;
}
else {
LOG_E(" ATR/CIP Length is improper!!!");
}
}
else
{
*T1oI2CatrLen = 0;
LOG_E(" Failed to Retrieve ATR/CIP status ");
}
exit:
return status;
}
U16 smComT1oI2C_ComReset()
{
ESESTATUS status = ESESTATUS_SUCCESS;
status = phNxpEse_deInit();
if(status !=ESESTATUS_SUCCESS)
{
LOG_E("Failed to Reset 7816 protocol instance ");
return SMCOM_COM_FAILED;
}
return SMCOM_OK;
}
#endif /* T1oI2C */
|
the_stack_data/22012908.c
|
#include<fcntl.h>
#include<sys/shm.h>
#include<sys/ipc.h>
#include<unistd.h>
#include<errno.h>
#include<stdio.h>
int main(int argc , char* argv[])
{
int key,id,fd,n;
void *data;
char str[101];
key=ftok(".",10);
id=shmget(key,1000,0);
data=shmat(id,(void*)0,0);
//printf("%s\n",(char*)data);
//shmdt(data);
fd=open(argv[1],O_WRONLY|O_CREAT|O_TRUNC,0666);
//printf("%d\n",fd);
//while((n=read((int*)data,str,100))>0)
write(fd,(char*)data,1000);
shmdt(data);
shmctl(id,IPC_RMID,NULL);
return 0;
}
|
the_stack_data/100163.c
|
/* Overlapping symbol sizes test program.
Copyright 2007-2016 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#ifdef SYMBOL_PREFIX
#define SYMBOL(str) SYMBOL_PREFIX #str
#else
#define SYMBOL(str) #str
#endif
void
trap (void)
{
asm ("int $0x03");
}
/* Jump from a function with its symbol size set, to a function
named by a local label. GDB should report the `main' function
even for the rest, after the global `inner' ends. */
asm(".text\n"
" .align 8\n"
" .globl " SYMBOL (main) "\n"
SYMBOL (main) ":\n"
" pushl %ebp\n"
" mov %esp, %ebp\n"
" call .Lfunc\n"
" ret\n"
SYMBOL (inner) ":\n"
" ret\n"
" .size " SYMBOL (inner) ", .-" SYMBOL (inner) "\n"
".Lfunc:\n"
" pushl %ebp\n"
" mov %esp, %ebp\n"
" call " SYMBOL (trap) "\n"
" .size " SYMBOL (main) ", .-" SYMBOL (main) "\n");
|
the_stack_data/127625.c
|
#include <stdio.h>
#include <string.h>
main()
{
char palavra[15]="", concat[25]="";
int numpalavras=0;
inicio:
printf("\nDigite uma palavra: ");
gets(palavra);
if(strlen(palavra) > 12)
{
printf("\nPalavra excede limite de 12 caracteres.");
goto inicio;
}
else
{
strcat(concat, palavra);
numpalavras++;
if(numpalavras == 2)
printf("\nConcatenacao: %s", concat);
else
goto inicio;
}
}
|
the_stack_data/145452480.c
|
/* cypher2.c -- 改变输入,只保留非字母字符 */
#include <stdio.h>
#include <ctype.h>
#define SPACE ' ' /* SPACE 相当于 "引号-空格-引号"*/
int main(int argc, char const *argv[])
{
char ch;
while((ch = getchar()) != '\n'){
if(isalpha(ch))
putchar(ch + 1);
else
putchar(ch);
}
// 等同于printf("%c", ch);
putchar(ch);
return 0;
}
|
the_stack_data/100141625.c
|
#include <stdlib.h>
#include <stdint.h>
void do_stub() {}
void* run_it() {
return malloc(128);
}
|
the_stack_data/92325647.c
|
//Program:-
#include<stdio.h>
#include<string.h>
#include<unistd.h>
#include<sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include<time.h>
#define r 3
#define c 3
char matrix[r][c];
char new[r][c];
int count;
char final[r][c] = {{'1','2','3'},{'4','5','6'},{'7','8',' '}};
int i,j;
char z ;
int p,q,x,y;
int t =0;
int result = 0;
void load()
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(new[i][j] == '0')
{
matrix[i][j]= ' ';
continue;
}
matrix[i][j]= new[i][j];
}
}
}
void blank()
{
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
new[i][j]= ' ';
}
}
}
int main()
{
time_t T= time(NULL);
struct tm tm = *localtime(&T);
char f[4];
int rsl ;
int random,t;
int randvalues[9];
main:
count = 0;
blank();
T= time(NULL);
tm = *localtime(&T);
srand(tm.tm_sec);
while(count!=9)
{
rsl=rand()%9;
sprintf(f,"%d",rsl);
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if((new[i][j]) == f[0])
{
i = 4; j = 4;
continue;
}else if((new[i][j]) == ' ')
{
new[i][j] = f[0];
i = 4; j = 4;
count++;
}
}
}
}
load();
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("|%c|",matrix[i][j]);
}
printf("\n");
}
while(1)
{
printf("enter value to change its position to blank space\n");
scanf(" %c",&z);
if(z=='q')
{
printf("\n*****You Quit*****\n");
goto main;
break;
}
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if((matrix[i][j])== z)
{
p = i;
q = j;
}else if((matrix[i][j])== ' ')
{
x = i;
y = j;
}
}
}
t =0;
int m , n ;
m = p - 1;
n = q ;
if(m>=0)
{
if((matrix[m][n])== ' ')t=1;
}
m = p + 1;
if(m<=2)
{
if((matrix[m][n])== ' ')t=1;
}
m = p;
n = q - 1 ;
if(n>=0)
{
if((matrix[m][n])== ' ')t=1;
}
n = q + 1 ;
if(n<=2)
{
if((matrix[m][n])== ' ')t=1;
}
if(t==1)
{
matrix[x][y] = z;
matrix[p][q] = ' ';
}
t = 0;
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
if((matrix[i][j])== final[i][j])
{
t++;
}
}
}
system("clear");
for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
{
printf("|%c|",matrix[i][j]);
}
printf("\n");
}
if(t==9)
{
printf("\n****you Win****\n");
break;
}
}
return 1;
}
|
the_stack_data/190768279.c
|
n, i, t, x, y, a[111], b[111];
char s[111];
main() {
scanf("%d%s", &n, s);
for (i = 0; i < n; i++) scanf("%d%d", a + i, b + i);
for (t = 0; t < 1000; t++) {
x = 0;
for (i = 0; i < n; i++) {
if (t < b[i])
x += s[i] == '1';
else
x += ((t - b[i]) / a[i] % 2) ^ (s[i] == '0');
}
y = x > y ? x : y;
}
printf("%d", y);
}
|
the_stack_data/232956243.c
|
// BFS algorithm using Adjacency list for undirected graph
#include <stdio.h>
#include <stdlib.h>
#define SIZE 40
struct queue
{
int items[SIZE];
int front;
int rear;
};
typedef struct stack
{
int top;
int arr[SIZE];
} STACK;
STACK *createStack();
void push(STACK *, int);
int pop(STACK *);
void display(STACK *);
int isFull(STACK *);
int isEmpty(STACK *);
struct node
{
int vertex;
struct node *next;
};
struct node *createNode(int);
struct Graph
{
int numVertices;
struct node **adjLists;
int *visited;
};
// BFS algorithm
void dfs(struct Graph *graph, int v)
{
STACK *s = createStack();
push(s, v);
while (!isEmpty(s))
{
v = pop(s);
if (graph->visited[v] == 0)
{
graph->visited[v] = 1;
printf("Visited %d\n", v);
struct node *temp = graph->adjLists[v];
while (temp != NULL)
{
if (graph->visited[temp->vertex] == 0)
{
push(s, temp->vertex);
}
temp = temp->next;
}
}
}
}
struct node *createNode(int v)
{
struct node *newNode = malloc(sizeof(struct node));
newNode->vertex = v;
newNode->next = NULL;
return newNode;
}
struct Graph *createGraph(int vertices)
{
struct Graph *graph = malloc(sizeof(struct Graph));
graph->numVertices = vertices;
graph->adjLists = malloc(vertices * sizeof(struct node *));
graph->visited = malloc(vertices * sizeof(int));
int i;
for (i = 0; i < vertices; i++)
{
graph->adjLists[i] = NULL;
graph->visited[i] = 0;
}
return graph;
}
void addEdge(struct Graph *graph, int src, int dest)
{
struct node *newNode = createNode(dest);
newNode->next = graph->adjLists[src];
graph->adjLists[src] = newNode;
newNode = createNode(src);
newNode->next = graph->adjLists[dest];
graph->adjLists[dest] = newNode;
}
void printGraph(struct Graph* graph) {
printf("Graph is \n");
int v;
for (v = 0; v < graph->numVertices; v++) {
struct node* temp = graph->adjLists[v];
printf("Vertex %d : ", v);
while (temp!=NULL) {
printf("%d -> ", temp->vertex);
temp = temp->next;
}
printf(" NULL\n");
}
}
STACK *createStack()
{
STACK *s = malloc(sizeof(STACK));
s->top = -1;
return s;
}
int isFull(STACK *s)
{
if (s->top == SIZE - 1)
{
return 1;
}
else
{
return 0;
}
}
int isEmpty(STACK *s)
{
if (s->top == -1)
{
return 1;
}
else
{
return 0;
}
}
void push(STACK *s, int ele)
{
if (isFull(s))
{
printf("Stack Overflow");
}
else
{
s->arr[++(s->top)] = ele;
}
// printf("%d", s->top);
}
int pop(STACK *s)
{
if (isEmpty(s))
{
printf("Underflow");
}
else
{
return s->arr[(s->top)--];
}
}
void display(STACK *s)
{
if (isEmpty(s))
{
printf("Empty stack");
}
else
{
printf("Stack is \n");
for (int i = 0; i <= s->top; i++)
{
printf("%d ", s->arr[i]);
}
}
}
int main()
{
// //User-Entered code
// int v, e, v1, v2;
// printf("Enter no of Vertex\n");
// scanf("%d", &v);
// struct Graph *graph = createGraph(v);
// printf("Enter no of Edges\n");
// scanf("%d", &e);
// for (int i = 0; i < e; i++)
// {
// printf("Enter the vertex that are connected \n");
// scanf("%d", &v1);
// scanf("%d", &v2);
// addEdge(graph, v1, v2);
// }
// printGraph(graph);
// for (int i = 0; i < v; i++)
// {
// if (graph->visited[i] == 0)
// {
// dfs(graph, i);
// }
// }
//Hard-coded Value
struct Graph* graph = createGraph(9);
addEdge(graph,0,8);
addEdge(graph,0,3);
addEdge(graph,0,1);
addEdge(graph,4,8);
addEdge(graph,3,4);
addEdge(graph,3,2);
addEdge(graph,1,7);
addEdge(graph,2,7);
addEdge(graph,2,5);
addEdge(graph,5,6);
printGraph(graph);
for (int i = 0; i < 9; i++)
{
if (graph->visited[i] == 0)
{
dfs(graph, i);
}
}
return 0;
}
|
the_stack_data/145453708.c
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
typedef unsigned char byte;
typedef unsigned long size;
static struct {
unsigned char pre[16];
union {
unsigned short kShort;
unsigned long kLong;
unsigned long long kLongLong;
float kFloat;
double kDouble;
long double kLongDouble;
} data;
unsigned char post[16];
} dataBlk, maskBlk;
/*
kShort = { -1, 0x0123, -1};
kLong = { -1, 0x01234567, -1};
kLongLong = { -1, 0x0123456789abcdef, -1};
kFloat = { -1, (1.0 / 9.0 + 0.46), -1};
kDouble = { -1, (2.0 / 9.0 + 0.28), -1};
kLongDouble = { -1, (1.0 / 9.0), -1};
*/
void prepBlocks(void)
{
memset(&dataBlk, 0x55, sizeof(dataBlk));
memset(&maskBlk, 0xAA, sizeof(maskBlk));
}
void processBlocks(void)
{
byte *d = (byte *)&dataBlk;
byte *m = (byte *)&maskBlk;
size i, l = sizeof(dataBlk);
for (i = 0; i < l; ++i)
{
*m = (*m ^ 0xAA) | (*d ^ 0x55);
++m; ++d;
}
d = (byte *)&dataBlk;
m = (byte *)&maskBlk;
printf("[");
for (i = 0; i < l; ++i)
{
if (*m) { printf(" %02x", *d); }
++d; ++m;
}
printf(" ]\n");
}
int main( int argc, char *argv[] )
{
prepBlocks();
dataBlk.data.kShort = 0x1234;
maskBlk.data.kShort = 0x1234;
printf(" short: "); processBlocks();
prepBlocks();
dataBlk.data.kLong = 0x12345678;
maskBlk.data.kLong = 0x12345678;
printf(" long: "); processBlocks();
prepBlocks();
dataBlk.data.kLongLong = 0x0123456789abcdef;
maskBlk.data.kLongLong = 0x0123456789abcdef;
printf(" long long: "); processBlocks();
/* IEEE single: 32 bits, as 1 bit sign, 8 bit exponent, 23 bit mantessa */
/* |s.eeeeeee|e.mmmmmmm|mmmmmmmm|mmmmmmmm| */
prepBlocks();
dataBlk.data.kFloat = (1.0 / 9.0 + 0.46);
maskBlk.data.kFloat = (1.0 / 9.0 + 0.46);
printf(" float: "); processBlocks();
/* IEEE double: 64 bits, as 1 bit sign, 11 bit exponent, 52 bit mantessa */
/* |s.eeeeeee|eeee.mmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm| */
prepBlocks();
dataBlk.data.kDouble = (2.0 / 9.0 + 0.28);
maskBlk.data.kDouble = (2.0 / 9.0 + 0.28);
printf(" double: "); processBlocks();
/* Extended precision: 80 bits, as 1 bit sign, 15 bit exponent, 1 bit integer, 63 bit mantessa */
/* |s.eeeeeee|eeeeeeee|i.mmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm|mmmmmmmm| */
prepBlocks();
dataBlk.data.kLongDouble = (2.0 / 9.0 + 0.28);
maskBlk.data.kLongDouble = (2.0 / 9.0 + 0.28);
printf("long double: "); processBlocks();
}
|
the_stack_data/125140942.c
|
#include <stdio.h>
#include <stdlib.h>
/* define node */
typedef struct n{
int info;
struct n * next;
}Node;
/* define list */
typedef Node * List;
/* function prototypes */
int isEmpty (List l);
int CalcoloSomma (List l);
int CalcoloNElementi (List l);
List Push (List l, int n);
List Append (List l, int n);
void freeList (List l);
/* functions body */
List Push(List l, int n){
/* allocate a new element to the list */
Node * newPtr = (Node*)malloc(sizeof(Node));
newPtr->info = n;
newPtr->next = l;
return newPtr;
}
List Append(List l, int n){
Node * newPtr =(Node*)malloc(sizeof(Node));
if(l == NULL){
l = Push(l, n);
}
else{
for(newPtr = l; newPtr->next != NULL; newPtr = newPtr->next);
newPtr->next =(Node*)malloc(sizeof(Node));
newPtr->next->info = n;
newPtr->next->next = NULL;
}
return l;
}
int isEmpty(List l){
return l == NULL;
}
int CalcoloSomma(List l){
List aux = l;
int somma = 0;
while(aux != NULL){
somma += aux->info;
aux = aux->next;
}
return somma;
}
int CalcoloNElementi(List l){
List aux = l;
int count = 0;
int search = CalcoloSomma(l)/4;
while(aux != NULL){
if(aux->info > search){
count++;
}
aux = aux->next;
}
return count;
}
void freeList(List l){
Node * temp;
while(l != NULL){
temp = l;
l = l->next;
free(temp);
}
return;
}
/* main function */
int main(void){
int x;
List lista = NULL;
scanf("%d", &x);
while(x > -1){
lista = Append(lista, x);
scanf("%d", &x);
}
if(isEmpty(lista)){
printf("%d\n%d\n", 0, 0);
}else{
printf("%d\n%d\n", CalcoloSomma(lista), CalcoloNElementi(lista));
}
freeList(lista);
return 0;
}
|
the_stack_data/138769.c
|
/*
* Stack-less Just-In-Time compiler
*
* Copyright Zoltan Herczeg ([email protected]). All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND CONTRIBUTORS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE COPYRIGHT HOLDER(S) 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.
*/
/* ------------------------------------------------------------------------ */
/* Locks */
/* ------------------------------------------------------------------------ */
/* Executable Allocator */
#if (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) \
&& !(defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)
#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
#define SLJIT_ALLOCATOR_LOCK()
#define SLJIT_ALLOCATOR_UNLOCK()
#elif !(defined _WIN32)
#include <pthread.h>
static pthread_mutex_t allocator_lock = PTHREAD_MUTEX_INITIALIZER;
#define SLJIT_ALLOCATOR_LOCK() pthread_mutex_lock(&allocator_lock)
#define SLJIT_ALLOCATOR_UNLOCK() pthread_mutex_unlock(&allocator_lock)
#else /* windows */
static HANDLE allocator_lock;
static SLJIT_INLINE void allocator_grab_lock(void)
{
HANDLE lock;
if (SLJIT_UNLIKELY(!allocator_lock)) {
lock = CreateMutex(NULL, FALSE, NULL);
if (InterlockedCompareExchangePointer(&allocator_lock, lock, NULL))
CloseHandle(lock);
}
WaitForSingleObject(allocator_lock, INFINITE);
}
#define SLJIT_ALLOCATOR_LOCK() allocator_grab_lock()
#define SLJIT_ALLOCATOR_UNLOCK() ReleaseMutex(allocator_lock)
#endif /* thread implementation */
#endif /* SLJIT_EXECUTABLE_ALLOCATOR && !SLJIT_WX_EXECUTABLE_ALLOCATOR */
/* ------------------------------------------------------------------------ */
/* Stack */
/* ------------------------------------------------------------------------ */
#if ((defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) \
&& !(defined SLJIT_UTIL_SIMPLE_STACK_ALLOCATION && SLJIT_UTIL_SIMPLE_STACK_ALLOCATION)) \
|| ((defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR) \
&& !((defined SLJIT_PROT_EXECUTABLE_ALLOCATOR && SLJIT_PROT_EXECUTABLE_ALLOCATOR) \
|| (defined SLJIT_WX_EXECUTABLE_ALLOCATOR && SLJIT_WX_EXECUTABLE_ALLOCATOR)))
#ifndef _WIN32
/* Provides mmap function. */
#include <sys/types.h>
#include <sys/mman.h>
#ifndef MAP_ANON
#ifdef MAP_ANONYMOUS
#define MAP_ANON MAP_ANONYMOUS
#endif /* MAP_ANONYMOUS */
#endif /* !MAP_ANON */
#ifndef MAP_ANON
#include <fcntl.h>
#ifdef O_CLOEXEC
#define SLJIT_CLOEXEC O_CLOEXEC
#else /* !O_CLOEXEC */
#define SLJIT_CLOEXEC 0
#endif /* O_CLOEXEC */
/* Some old systems do not have MAP_ANON. */
static int dev_zero = -1;
#if (defined SLJIT_SINGLE_THREADED && SLJIT_SINGLE_THREADED)
static SLJIT_INLINE int open_dev_zero(void)
{
dev_zero = open("/dev/zero", O_RDWR | SLJIT_CLOEXEC);
return dev_zero < 0;
}
#else /* !SLJIT_SINGLE_THREADED */
#include <pthread.h>
static pthread_mutex_t dev_zero_mutex = PTHREAD_MUTEX_INITIALIZER;
static SLJIT_INLINE int open_dev_zero(void)
{
pthread_mutex_lock(&dev_zero_mutex);
if (SLJIT_UNLIKELY(dev_zero < 0))
dev_zero = open("/dev/zero", O_RDWR | SLJIT_CLOEXEC);
pthread_mutex_unlock(&dev_zero_mutex);
return dev_zero < 0;
}
#endif /* SLJIT_SINGLE_THREADED */
#undef SLJIT_CLOEXEC
#endif /* !MAP_ANON */
#endif /* !_WIN32 */
#endif /* open_dev_zero */
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK) \
|| (defined SLJIT_EXECUTABLE_ALLOCATOR && SLJIT_EXECUTABLE_ALLOCATOR)
#ifdef _WIN32
static SLJIT_INLINE sljit_sw get_page_alignment(void) {
SYSTEM_INFO si;
static sljit_sw sljit_page_align;
if (!sljit_page_align) {
GetSystemInfo(&si);
sljit_page_align = si.dwPageSize - 1;
}
return sljit_page_align;
}
#else
#include <unistd.h>
static SLJIT_INLINE sljit_sw get_page_alignment(void) {
static sljit_sw sljit_page_align;
if (!sljit_page_align) {
sljit_page_align = sysconf(_SC_PAGESIZE);
/* Should never happen. */
if (sljit_page_align < 0)
sljit_page_align = 4096;
sljit_page_align--;
}
return sljit_page_align;
}
#endif /* _WIN32 */
#endif /* get_page_alignment() */
#if (defined SLJIT_UTIL_STACK && SLJIT_UTIL_STACK)
#if (defined SLJIT_UTIL_SIMPLE_STACK_ALLOCATION && SLJIT_UTIL_SIMPLE_STACK_ALLOCATION)
SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_FUNC sljit_allocate_stack(sljit_uw start_size, sljit_uw max_size, void *allocator_data)
{
struct sljit_stack *stack;
void *ptr;
SLJIT_UNUSED_ARG(allocator_data);
if (start_size > max_size || start_size < 1)
return NULL;
stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack), allocator_data);
if (stack == NULL)
return NULL;
ptr = SLJIT_MALLOC(max_size, allocator_data);
if (ptr == NULL) {
SLJIT_FREE(stack, allocator_data);
return NULL;
}
stack->min_start = (sljit_u8 *)ptr;
stack->end = stack->min_start + max_size;
stack->start = stack->end - start_size;
stack->top = stack->end;
return stack;
}
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
{
SLJIT_UNUSED_ARG(allocator_data);
SLJIT_FREE((void*)stack->min_start, allocator_data);
SLJIT_FREE(stack, allocator_data);
}
SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_stack *stack, sljit_u8 *new_start)
{
if ((new_start < stack->min_start) || (new_start >= stack->end))
return NULL;
stack->start = new_start;
return new_start;
}
#else /* !SLJIT_UTIL_SIMPLE_STACK_ALLOCATION */
#ifdef _WIN32
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
{
SLJIT_UNUSED_ARG(allocator_data);
VirtualFree((void*)stack->min_start, 0, MEM_RELEASE);
SLJIT_FREE(stack, allocator_data);
}
#else /* !_WIN32 */
SLJIT_API_FUNC_ATTRIBUTE void SLJIT_FUNC sljit_free_stack(struct sljit_stack *stack, void *allocator_data)
{
SLJIT_UNUSED_ARG(allocator_data);
munmap((void*)stack->min_start, stack->end - stack->min_start);
SLJIT_FREE(stack, allocator_data);
}
#endif /* _WIN32 */
SLJIT_API_FUNC_ATTRIBUTE struct sljit_stack* SLJIT_FUNC sljit_allocate_stack(sljit_uw start_size, sljit_uw max_size, void *allocator_data)
{
struct sljit_stack *stack;
void *ptr;
sljit_sw page_align;
SLJIT_UNUSED_ARG(allocator_data);
if (start_size > max_size || start_size < 1)
return NULL;
stack = (struct sljit_stack*)SLJIT_MALLOC(sizeof(struct sljit_stack), allocator_data);
if (stack == NULL)
return NULL;
/* Align max_size. */
page_align = get_page_alignment();
max_size = (max_size + page_align) & ~page_align;
#ifdef _WIN32
ptr = VirtualAlloc(NULL, max_size, MEM_RESERVE, PAGE_READWRITE);
if (!ptr) {
SLJIT_FREE(stack, allocator_data);
return NULL;
}
stack->min_start = (sljit_u8 *)ptr;
stack->end = stack->min_start + max_size;
stack->start = stack->end;
if (sljit_stack_resize(stack, stack->end - start_size) == NULL) {
sljit_free_stack(stack, allocator_data);
return NULL;
}
#else /* !_WIN32 */
#ifdef MAP_ANON
ptr = mmap(NULL, max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
#else /* !MAP_ANON */
if (SLJIT_UNLIKELY((dev_zero < 0) && open_dev_zero())) {
SLJIT_FREE(stack, allocator_data);
return NULL;
}
ptr = mmap(NULL, max_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, dev_zero, 0);
#endif /* MAP_ANON */
if (ptr == MAP_FAILED) {
SLJIT_FREE(stack, allocator_data);
return NULL;
}
stack->min_start = (sljit_u8 *)ptr;
stack->end = stack->min_start + max_size;
stack->start = stack->end - start_size;
#endif /* _WIN32 */
stack->top = stack->end;
return stack;
}
SLJIT_API_FUNC_ATTRIBUTE sljit_u8 *SLJIT_FUNC sljit_stack_resize(struct sljit_stack *stack, sljit_u8 *new_start)
{
#if defined _WIN32 || defined(POSIX_MADV_DONTNEED)
sljit_uw aligned_old_start;
sljit_uw aligned_new_start;
sljit_sw page_align;
#endif
if ((new_start < stack->min_start) || (new_start >= stack->end))
return NULL;
#ifdef _WIN32
page_align = get_page_alignment();
aligned_new_start = (sljit_uw)new_start & ~page_align;
aligned_old_start = ((sljit_uw)stack->start) & ~page_align;
if (aligned_new_start != aligned_old_start) {
if (aligned_new_start < aligned_old_start) {
if (!VirtualAlloc((void*)aligned_new_start, aligned_old_start - aligned_new_start, MEM_COMMIT, PAGE_READWRITE))
return NULL;
}
else {
if (!VirtualFree((void*)aligned_old_start, aligned_new_start - aligned_old_start, MEM_DECOMMIT))
return NULL;
}
}
#elif defined(POSIX_MADV_DONTNEED)
if (stack->start < new_start) {
page_align = get_page_alignment();
aligned_new_start = (sljit_uw)new_start & ~page_align;
aligned_old_start = ((sljit_uw)stack->start) & ~page_align;
if (aligned_new_start > aligned_old_start) {
posix_madvise((void*)aligned_old_start, aligned_new_start - aligned_old_start, POSIX_MADV_DONTNEED);
#ifdef MADV_FREE
madvise((void*)aligned_old_start, aligned_new_start - aligned_old_start, MADV_FREE);
#endif /* MADV_FREE */
}
}
#endif /* _WIN32 */
stack->start = new_start;
return new_start;
}
#endif /* SLJIT_UTIL_SIMPLE_STACK_ALLOCATION */
#endif /* SLJIT_UTIL_STACK */
|
the_stack_data/247018067.c
|
/*
* sha512.c - mbed TLS (formerly known as PolarSSL) implementation of SHA512
*
* Modifications Copyright 2017 Google Inc.
* Modifications Author: Joe Richey ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/*
* FIPS-180-2 compliant SHA-512 implementation
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
/*
* The SHA-512 Secure Hash Standard was published by NIST in 2002.
*
* http://csrc.nist.gov/publications/fips/fips180-2/fips180-2.pdf
*/
#include "sha512.h"
#include <string.h> // (memset_s or explicit_bzero if available)
#if defined(_MSC_VER) || defined(__WATCOMC__)
#define UL64(x) x##ui64
#else
#define UL64(x) x##ULL
#endif
/* We either use dedicated memory clearing functions or volatile dereference. */
void secure_wipe(uint8_t *v, uint32_t n) {
#if defined memset_s
memset_s(v, n, 0, n);
#elif defined explicit_bzero
explicit_bzero(v, n);
#else
volatile uint8_t *p = v;
while (n--) *p++ = 0;
#endif
}
/*
* SHA-512 context structure
*/
typedef struct {
uint64_t total[2]; /*!< number of bytes processed */
uint64_t state[8]; /*!< intermediate digest state */
unsigned char buffer[128]; /*!< data block being processed */
} mbedtls_sha512_context;
/*
* 64-bit integer manipulation macros (big endian)
*/
#ifndef GET_UINT64_BE
#define GET_UINT64_BE(n, b, i) \
{ \
(n) = ((uint64_t)(b)[(i)] << 56) | ((uint64_t)(b)[(i) + 1] << 48) | \
((uint64_t)(b)[(i) + 2] << 40) | ((uint64_t)(b)[(i) + 3] << 32) | \
((uint64_t)(b)[(i) + 4] << 24) | ((uint64_t)(b)[(i) + 5] << 16) | \
((uint64_t)(b)[(i) + 6] << 8) | ((uint64_t)(b)[(i) + 7]); \
}
#endif /* GET_UINT64_BE */
#ifndef PUT_UINT64_BE
#define PUT_UINT64_BE(n, b, i) \
{ \
(b)[(i)] = (unsigned char)((n) >> 56); \
(b)[(i) + 1] = (unsigned char)((n) >> 48); \
(b)[(i) + 2] = (unsigned char)((n) >> 40); \
(b)[(i) + 3] = (unsigned char)((n) >> 32); \
(b)[(i) + 4] = (unsigned char)((n) >> 24); \
(b)[(i) + 5] = (unsigned char)((n) >> 16); \
(b)[(i) + 6] = (unsigned char)((n) >> 8); \
(b)[(i) + 7] = (unsigned char)((n)); \
}
#endif /* PUT_UINT64_BE */
static void mbedtls_sha512_init(mbedtls_sha512_context *ctx) {
memset(ctx, 0, sizeof(mbedtls_sha512_context));
}
/*
* SHA-512 context setup
*/
static void mbedtls_sha512_starts(mbedtls_sha512_context *ctx) {
ctx->total[0] = 0;
ctx->total[1] = 0;
// ctx->state[0] = UL64(0x6A09E667F3BCC908);
// ctx->state[1] = UL64(0xBB67AE8584CAA73B);
// ctx->state[2] = UL64(0x3C6EF372FE94F82B);
// ctx->state[3] = UL64(0xA54FF53A5F1D36F1);
// ctx->state[4] = UL64(0x510E527FADE682D1);
// ctx->state[5] = UL64(0x9B05688C2B3E6C1F);
// ctx->state[6] = UL64(0x1F83D9ABFB41BD6B);
// ctx->state[7] = UL64(0x5BE0CD19137E2179);
ctx->state[0] = UL64(0x22312194fc2bf72c);
ctx->state[1] = UL64(0x9f555fa3c84c64c2);
ctx->state[2] = UL64(0x2393b86b6f53b151);
ctx->state[3] = UL64(0x963877195940eabd);
ctx->state[4] = UL64(0x96283ee2a88effe3);
ctx->state[5] = UL64(0xbe5e1e2553863992);
ctx->state[6] = UL64(0x2b0199fc2c85b8aa);
ctx->state[7] = UL64(0x0eb72ddc81c52ca2);
}
/*
* Round constants
*/
static const uint64_t K[80] = {
UL64(0x428A2F98D728AE22), UL64(0x7137449123EF65CD),
UL64(0xB5C0FBCFEC4D3B2F), UL64(0xE9B5DBA58189DBBC),
UL64(0x3956C25BF348B538), UL64(0x59F111F1B605D019),
UL64(0x923F82A4AF194F9B), UL64(0xAB1C5ED5DA6D8118),
UL64(0xD807AA98A3030242), UL64(0x12835B0145706FBE),
UL64(0x243185BE4EE4B28C), UL64(0x550C7DC3D5FFB4E2),
UL64(0x72BE5D74F27B896F), UL64(0x80DEB1FE3B1696B1),
UL64(0x9BDC06A725C71235), UL64(0xC19BF174CF692694),
UL64(0xE49B69C19EF14AD2), UL64(0xEFBE4786384F25E3),
UL64(0x0FC19DC68B8CD5B5), UL64(0x240CA1CC77AC9C65),
UL64(0x2DE92C6F592B0275), UL64(0x4A7484AA6EA6E483),
UL64(0x5CB0A9DCBD41FBD4), UL64(0x76F988DA831153B5),
UL64(0x983E5152EE66DFAB), UL64(0xA831C66D2DB43210),
UL64(0xB00327C898FB213F), UL64(0xBF597FC7BEEF0EE4),
UL64(0xC6E00BF33DA88FC2), UL64(0xD5A79147930AA725),
UL64(0x06CA6351E003826F), UL64(0x142929670A0E6E70),
UL64(0x27B70A8546D22FFC), UL64(0x2E1B21385C26C926),
UL64(0x4D2C6DFC5AC42AED), UL64(0x53380D139D95B3DF),
UL64(0x650A73548BAF63DE), UL64(0x766A0ABB3C77B2A8),
UL64(0x81C2C92E47EDAEE6), UL64(0x92722C851482353B),
UL64(0xA2BFE8A14CF10364), UL64(0xA81A664BBC423001),
UL64(0xC24B8B70D0F89791), UL64(0xC76C51A30654BE30),
UL64(0xD192E819D6EF5218), UL64(0xD69906245565A910),
UL64(0xF40E35855771202A), UL64(0x106AA07032BBD1B8),
UL64(0x19A4C116B8D2D0C8), UL64(0x1E376C085141AB53),
UL64(0x2748774CDF8EEB99), UL64(0x34B0BCB5E19B48A8),
UL64(0x391C0CB3C5C95A63), UL64(0x4ED8AA4AE3418ACB),
UL64(0x5B9CCA4F7763E373), UL64(0x682E6FF3D6B2B8A3),
UL64(0x748F82EE5DEFB2FC), UL64(0x78A5636F43172F60),
UL64(0x84C87814A1F0AB72), UL64(0x8CC702081A6439EC),
UL64(0x90BEFFFA23631E28), UL64(0xA4506CEBDE82BDE9),
UL64(0xBEF9A3F7B2C67915), UL64(0xC67178F2E372532B),
UL64(0xCA273ECEEA26619C), UL64(0xD186B8C721C0C207),
UL64(0xEADA7DD6CDE0EB1E), UL64(0xF57D4F7FEE6ED178),
UL64(0x06F067AA72176FBA), UL64(0x0A637DC5A2C898A6),
UL64(0x113F9804BEF90DAE), UL64(0x1B710B35131C471B),
UL64(0x28DB77F523047D84), UL64(0x32CAAB7B40C72493),
UL64(0x3C9EBE0A15C9BEBC), UL64(0x431D67C49C100D4C),
UL64(0x4CC5D4BECB3E42B6), UL64(0x597F299CFC657E2A),
UL64(0x5FCB6FAB3AD6FAEC), UL64(0x6C44198C4A475817)};
static void mbedtls_sha512_process(mbedtls_sha512_context *ctx,
const unsigned char data[128]) {
int i;
uint64_t temp1, temp2, W[80];
uint64_t A, B, C, D, E, F, G, H;
#define SHR(x, n) (x >> n)
#define ROTR(x, n) (SHR(x, n) | (x << (64 - n)))
#define S0(x) (ROTR(x, 1) ^ ROTR(x, 8) ^ SHR(x, 7))
#define S1(x) (ROTR(x, 19) ^ ROTR(x, 61) ^ SHR(x, 6))
#define S2(x) (ROTR(x, 28) ^ ROTR(x, 34) ^ ROTR(x, 39))
#define S3(x) (ROTR(x, 14) ^ ROTR(x, 18) ^ ROTR(x, 41))
#define F0(x, y, z) ((x & y) | (z & (x | y)))
#define F1(x, y, z) (z ^ (x & (y ^ z)))
#define P(a, b, c, d, e, f, g, h, x, K) \
{ \
temp1 = h + S3(e) + F1(e, f, g) + K + x; \
temp2 = S2(a) + F0(a, b, c); \
d += temp1; \
h = temp1 + temp2; \
}
for (i = 0; i < 16; i++) {
GET_UINT64_BE(W[i], data, i << 3);
}
for (; i < 80; i++) {
W[i] = S1(W[i - 2]) + W[i - 7] + S0(W[i - 15]) + W[i - 16];
}
A = ctx->state[0];
B = ctx->state[1];
C = ctx->state[2];
D = ctx->state[3];
E = ctx->state[4];
F = ctx->state[5];
G = ctx->state[6];
H = ctx->state[7];
i = 0;
do {
P(A, B, C, D, E, F, G, H, W[i], K[i]);
i++;
P(H, A, B, C, D, E, F, G, W[i], K[i]);
i++;
P(G, H, A, B, C, D, E, F, W[i], K[i]);
i++;
P(F, G, H, A, B, C, D, E, W[i], K[i]);
i++;
P(E, F, G, H, A, B, C, D, W[i], K[i]);
i++;
P(D, E, F, G, H, A, B, C, W[i], K[i]);
i++;
P(C, D, E, F, G, H, A, B, W[i], K[i]);
i++;
P(B, C, D, E, F, G, H, A, W[i], K[i]);
i++;
} while (i < 80);
ctx->state[0] += A;
ctx->state[1] += B;
ctx->state[2] += C;
ctx->state[3] += D;
ctx->state[4] += E;
ctx->state[5] += F;
ctx->state[6] += G;
ctx->state[7] += H;
}
/*
* SHA-512 process buffer
*/
static void mbedtls_sha512_update(mbedtls_sha512_context *ctx,
const unsigned char *input, size_t ilen) {
size_t fill;
unsigned int left;
if (ilen == 0) return;
left = (unsigned int) (ctx->total[0] & 0x7F);
fill = 128 - left;
ctx->total[0] += (uint64_t) ilen;
if (ctx->total[0] < (uint64_t) ilen) ctx->total[1]++;
if (left && ilen >= fill) {
memcpy((void *) (ctx->buffer + left), input, fill);
mbedtls_sha512_process(ctx, ctx->buffer);
input += fill;
ilen -= fill;
left = 0;
}
while (ilen >= 128) {
mbedtls_sha512_process(ctx, input);
input += 128;
ilen -= 128;
}
if (ilen > 0) memcpy((void *) (ctx->buffer + left), input, ilen);
}
static const unsigned char sha512_padding[128] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
/*
* SHA-512 final digest
*/
static void mbedtls_sha512_finish(mbedtls_sha512_context *ctx,
unsigned char output[64]) {
size_t last, padn;
uint64_t high, low;
unsigned char msglen[16];
high = (ctx->total[0] >> 61) | (ctx->total[1] << 3);
low = (ctx->total[0] << 3);
PUT_UINT64_BE(high, msglen, 0);
PUT_UINT64_BE(low, msglen, 8);
last = (size_t) (ctx->total[0] & 0x7F);
padn = (last < 112) ? (112 - last) : (240 - last);
mbedtls_sha512_update(ctx, sha512_padding, padn);
mbedtls_sha512_update(ctx, msglen, 16);
PUT_UINT64_BE(ctx->state[0], output, 0);
PUT_UINT64_BE(ctx->state[1], output, 8);
PUT_UINT64_BE(ctx->state[2], output, 16);
PUT_UINT64_BE(ctx->state[3], output, 24);
PUT_UINT64_BE(ctx->state[4], output, 32);
PUT_UINT64_BE(ctx->state[5], output, 40);
PUT_UINT64_BE(ctx->state[6], output, 48);
PUT_UINT64_BE(ctx->state[7], output, 56);
}
/*
* output = SHA-512( input buffer )
*/
void SHA512_256(const uint8_t *in, size_t n, uint8_t out[SHA512_DIGEST_LENGTH]) {
mbedtls_sha512_context ctx;
mbedtls_sha512_init(&ctx);
mbedtls_sha512_starts(&ctx);
mbedtls_sha512_update(&ctx, in, n);
mbedtls_sha512_finish(&ctx, out);
secure_wipe((uint8_t *) &ctx, sizeof(ctx));
}
void SHA512_256_with_context(const uint8_t *in_ctx, size_t n_ctx,
const uint8_t *in, size_t n, uint8_t out[SHA512_DIGEST_LENGTH]) {
mbedtls_sha512_context ctx;
mbedtls_sha512_init(&ctx);
mbedtls_sha512_starts(&ctx);
mbedtls_sha512_update(&ctx, in_ctx, n_ctx);
mbedtls_sha512_update(&ctx, in, n);
mbedtls_sha512_finish(&ctx, out);
secure_wipe((uint8_t *) &ctx, sizeof(ctx));
}
|
the_stack_data/16616.c
|
///////////////////////////////////////////////////////////
//
// Function Name : Reverse()
// Input : Integer
// Output : Integer
// Description : Accept Number From User And Return Reverse Of That Number Using For-Loop
// Author : Prasad Dangare
// Date : 09 Mar 2021
//
///////////////////////////////////////////////////////////
#include <stdio.h>
int Revere(int iNo)
{
int iDigit = 0, iRev = 0;
if(iNo < 0)
{
iNo =- iNo;
}
/*
while (iNo != 0)
{
iDigit = iNo % 10;
iRev = (iRev * 10) + iDigit;
iNo = iNo / 10;
}
*/
for(; iNo > 0; iNo = iNo / 10)
{
iDigit = iNo % 10;
iRev = (iRev * 10) + iDigit;
}
return iRev;
}
int main()
{
int iValue = 0;
int iRet = 0;
printf("Enter The Number : ");
scanf("%d", &iValue);
iRet = Revere(iValue);
printf("Reverse Of Number is : %d", iRet);
return 0;
}
|
the_stack_data/31150.c
|
#include<stdio.h>
#include<string.h>
#include<stdbool.h>
int magic_string_len(char str[], int len) {
int i = 0;
int j = len-1;
bool flag_a, flag_b;
int magic_len = 0;
while(i<j) {
if(str[i++] == '>' && str[j--] == '<') {
magic_len += 2;
}
while(str[i] != '>' && i<j) {
i++;
}
while(str[j] != '<' && i<j) {
j--;
}
}
return magic_len;
}
void main() {
//char str[] = "<><><<>";
char str[] = "<<>>";
//char str[] = "<<<<><>>><>>><>><>><>>><<<<>><>>>>><<>>>>><><<<<>>";
//char str[] = ">>><<<";
int len = strlen(str);
int res = magic_string_len(str, len);
printf("magic str len is %d", res);
}
|
the_stack_data/516807.c
|
//{{BLOCK(Soldat)
//======================================================================
//
// Soldat, 8x8@4,
// + palette 256 entries, not compressed
// + 1 tiles not compressed
// Total size: 512 + 32 = 544
//
// Time-stamp: 2019-01-09, 22:13:33
// Exported by Cearn's GBA Image Transmogrifier, v0.8.3
// ( http://www.coranac.com/projects/#grit )
//
//======================================================================
const unsigned int SoldatTiles[8] __attribute__((aligned(4)))=
{
0x01000010,0x01100110,0x01111110,0x01F33F10,0x01333310,0x01111110,0x00100100,0x00100100,
};
const unsigned int SoldatPal[128] __attribute__((aligned(4)))=
{
0x00100000,0x02100200,0x40104000,0x63184200,0x001F4210,0x03FF03E0,0x7C1F7C00,0x7FFF7FE0,
0x00070004,0x000F000B,0x00170013,0x001F001B,0x00E00080,0x01E00160,0x02E00260,0x03E00360,
0x00E70084,0x01EF016B,0x02F70273,0x03FF037B,0x1C001000,0x3C002C00,0x5C004C00,0x7C006C00,
0x1C071004,0x3C0F2C0B,0x5C174C13,0x7C1F6C1B,0x1CE01080,0x3DE02D60,0x5EE04E60,0x7FE06F60,
0x0C630842,0x1CE714A5,0x2D6B2529,0x3DEF35AD,0x4E734631,0x5EF756B5,0x6F7B6739,0x7FFF77BD,
0x007F001F,0x017F00FF,0x027F01FF,0x037F02FF,0x03FC03FF,0x03F403F8,0x03EC03F0,0x03E403E8,
0x0FE003E0,0x2FE01FE0,0x4FE03FE0,0x6FE05FE0,0x7F807FE0,0x7E807F00,0x7D807E00,0x7C807D00,
0x7C037C00,0x7C0B7C07,0x7C137C0F,0x7C1B7C17,0x701F7C1F,0x501F601F,0x301F401F,0x101F201F,
0x0000001F,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
0x04210000,0x0C630842,0x14A51084,0x1CE718C6,0x25292108,0x2D6B294A,0x35AD318C,0x3DEF39CE,
0x46314210,0x4E734A52,0x56B55294,0x5EF75AD6,0x67396318,0x6F7B6B5A,0x77BD739C,0x7FFF7BDE,
};
//}}BLOCK(Soldat)
|
the_stack_data/32950112.c
|
/* Copyright (c) 1982, Regents, University of California */
extern int Fixzero[];
int *inewint(n)
{
register int *ip;
int *newint();
if(n < 1024 && n >= -1024) return (Fixzero+n);
ip = newint();
*ip = n;
return(ip);
}
blzero(where,howmuch)
register char *where;
{
register char *p;
for(p = where + howmuch; p > where; ) *--p = 0;
}
|
the_stack_data/54825091.c
|
//pointer access - example
#include<stdio.h>
void main()
{
int x, y;
int *ptr;
x = 10;
ptr = &x;
y = *ptr;
printf("Value of x is %d\n\n",x);
printf("x is stored at addr %u\n", &x);
printf("y is stored at addr %u\n", &y);
printf("value of y is: %d\n",y);
printf("pointer variable ptr contains the addr %u\n", ptr);
printf("pointer variable ptr itself is stored at addr %u\n", &ptr);
*ptr = 25;
printf("\nNow x has been assigned a new value through pointer which is= %d\n",x);
}
|
the_stack_data/29824213.c
|
/* benchmark.c
*
* Copyright (C) 2014 Vaggelis Atlidakis <[email protected]>
*
* Benchmark average time for memset, and malloc a 256 bytes block
*
*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <inttypes.h>
#define BLK_SIZE 256
#define MILLION 1000000
#define REPS 1000*MILLION
static inline void timespec_sub(struct timespec *a, const struct timespec *b)
{
a->tv_sec -= b->tv_sec;
a->tv_nsec -= b->tv_nsec;
if (a->tv_nsec < 0) {
a->tv_nsec += 1000000000;
a->tv_sec -= 1;
}
}
void main(int argc, char** argv)
{
char *p;
struct timespec start, stop;
uint64_t accum;
uint32_t i;
FILE *fp;
fp=fopen("data/benchmark_stats.txt", "a+");
accum = 0;
for (i = 0; i < REPS; i++)
{
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
p=malloc(BLK_SIZE);
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stop);
timespec_sub(&stop, &start);
accum += (((uint64_t)stop.tv_sec)*1000000000 + ((uint64_t)stop.tv_nsec));
free(p);
if ( i != 0 )
if ( i % (MILLION) == 0 )
fprintf(fp, "malloc progress: %.2f %% - cur. avg.: %"PRId64"\n", 100* ((float)i / (float)(REPS) ), accum/(uint64_t)i);
fflush(fp);
}
fprintf(fp, "avg. malloc time:%"PRId64" ns after %d reps\n", accum/(uint64_t)i, REPS);
fflush(fp);
p=malloc(BLK_SIZE);
accum = 0;
for (i = 0; i < REPS; i++)
{
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &start);
memset(p, 0, BLK_SIZE);
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &stop);
timespec_sub(&stop, &start);
accum += (((uint64_t)stop.tv_sec)*1000000000 + ((uint64_t)stop.tv_nsec));
if ( i != 0 )
if ( i % (MILLION) == 0 )
fprintf(fp, "memset progress: %.2f %% - cur. avg.: %"PRId64"\n", 100* ((float)i /(float)(REPS) ), accum/(uint64_t)i);
fflush(fp);
}
fprintf(fp, "avg. memset:%"PRId64" ns after %d reps\n", accum/(uint64_t)i, REPS);
fflush(fp);
free(p);
fclose(fp);
}
|
the_stack_data/57951669.c
|
#include<stdio.h>
#include<malloc.h>
struct node{
int data;
struct node *next;
}*HEAD=NULL;
struct node *createNode(int data){
struct node *newNode;
newNode = (struct node *)malloc(sizeof(struct node));
newNode->data = data;
newNode->next = NULL;
return newNode;
}
void insert(int data){
struct node *temp = HEAD;
struct node *newNode;
newNode = createNode(data);
if(HEAD==NULL){
HEAD = newNode;
}
else
{
while(temp->next!=NULL)
temp = temp->next;
temp->next = newNode;
temp = newNode;
}
}
void makeitcircular(int a,int index){
struct node *temp = HEAD;
struct node *circle;
struct node *indexer;
int i=0;
while(temp->next!=NULL){
if(i==a)
circle = temp;
if(i==index)
indexer = temp;
temp = temp->next;
i++;
}
indexer->next = circle;
}
void print(){
struct node *temp = HEAD;
while(temp!=NULL)
{
printf("%d->",temp->data);
temp = temp->next;
}
}
struct node *detectCircle(){
struct node *fast = HEAD;
struct node *slow = HEAD;
while(fast->next->next!=NULL && slow->next!=NULL){
printf("\n slow - %d",slow->data);
printf("\n fast - %d",fast->data);
fast = fast->next->next;
slow = slow->next;
if(fast==slow){
printf("\n fast -> %d - slow ->%d",fast->data,slow->data);
printf("\n LOOP detected");
break;
}
else
{
}
}
if(fast == NULL || fast->next == NULL)
return NULL;
slow = HEAD;
while(slow!=fast){
printf("\n slow - %d",slow->data);
printf("\n fast - %d",fast->data);
slow = slow->next;
fast = fast->next;
}
printf("\n ans :%d",slow->data);
}
int main(){
insert(1);
insert(2);
insert(3);
insert(4);
insert(5);
insert(6);
insert(7);
insert(8);
insert(9);
insert(10);
insert(11);
insert(12);
insert(13);
insert(14);
print();
//forced to make circular - index,index->next to be updated
makeitcircular(3,12);
//obviously we made circular loop
//print();
detectCircle();
}
|
the_stack_data/3746.c
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
// RUN: -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
// RUN: -emit-llvm -o - %s | FileCheck \
// RUN: --check-prefix=CHECK --check-prefix=CHECK-DIAG \
// RUN: --check-prefix=ITANIUM --check-prefix=ITANIUM-DIAG \
// RUN: %s
// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 \
// RUN: -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -fsanitize-trap=cfi-icall \
// RUN: -emit-llvm -o - %s | FileCheck \
// RUN: --check-prefix=CHECK \
// RUN: --check-prefix=ITANIUM --check-prefix=ITANIUM-TRAP \
// RUN: %s
// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 \
// RUN: -fsanitize=cfi-icall -fsanitize-cfi-cross-dso \
// RUN: -emit-llvm -o - %s | FileCheck \
// RUN: --check-prefix=CHECK --check-prefix=CHECK-DIAG \
// RUN: --check-prefix=MS --check-prefix=MS-DIAG \
// RUN: %s
// RUN: %clang_cc1 -triple x86_64-pc-windows-msvc -O1 \
// RUN: -fsanitize=cfi-icall -fsanitize-cfi-cross-dso -fsanitize-trap=cfi-icall \
// RUN: -emit-llvm -o - %s | FileCheck \
// RUN: --check-prefix=CHECK \
// RUN: --check-prefix=MS --check-prefix=MS-TRAP \
// RUN: %s
// CHECK-DIAG: @[[SRC:.*]] = private unnamed_addr constant {{.*}}cfi-icall-cross-dso.c\00
// CHECK-DIAG: @[[TYPE:.*]] = private unnamed_addr constant { i16, i16, [{{.*}} x i8] } { i16 -1, i16 0, [{{.*}} x i8] c"'void ()'\00"
// CHECK-DIAG: @[[DATA:.*]] = private unnamed_addr global {{.*}}@[[SRC]]{{.*}}@[[TYPE]]
// ITANIUM: call i1 @llvm.type.test(i8* %{{.*}}, metadata !"_ZTSFvE"), !nosanitize
// ITANIUM-DIAG: call void @__cfi_slowpath_diag(i64 6588678392271548388, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}) {{.*}}, !nosanitize
// ITANIUM-TRAP: call void @__cfi_slowpath(i64 6588678392271548388, i8* %{{.*}}) {{.*}}, !nosanitize
// MS: call i1 @llvm.type.test(i8* %{{.*}}, metadata !"?6AX@Z"), !nosanitize
// MS-DIAG: call void @__cfi_slowpath_diag(i64 4195979634929632483, i8* %{{.*}}, {{.*}}@[[DATA]]{{.*}}) {{.*}}, !nosanitize
// MS-TRAP: call void @__cfi_slowpath(i64 4195979634929632483, i8* %{{.*}}) {{.*}}, !nosanitize
void caller(void (*f)()) {
f();
}
// Check that we emit both string and hash based type entries for static void g(),
// and don't emit them for the declaration of h().
// CHECK: define internal void @g({{.*}} !type [[TVOID:![0-9]+]] !type [[TVOID_ID:![0-9]+]]
static void g(void) {}
// CHECK: declare void @h({{[^!]*$}}
void h(void);
typedef void (*Fn)(void);
Fn g1() {
return &g;
}
Fn h1() {
return &h;
}
// CHECK: define void @bar({{.*}} !type [[TNOPROTO:![0-9]+]] !type [[TNOPROTO_ID:![0-9]+]]
// ITANIUM: define available_externally void @foo({{[^!]*$}}
// MS: define linkonce_odr void @foo({{.*}} !type [[TNOPROTO]] !type [[TNOPROTO_ID]]
inline void foo() {}
void bar() { foo(); }
// CHECK: !{i32 4, !"Cross-DSO CFI", i32 1}
// Check that the type entries are correct.
// ITANIUM: [[TVOID]] = !{i64 0, !"_ZTSFvvE"}
// ITANIUM: [[TVOID_ID]] = !{i64 0, i64 9080559750644022485}
// ITANIUM: [[TNOPROTO]] = !{i64 0, !"_ZTSFvE"}
// ITANIUM: [[TNOPROTO_ID]] = !{i64 0, i64 6588678392271548388}
// MS: [[TVOID]] = !{i64 0, !"?6AXXZ"}
// MS: [[TVOID_ID]] = !{i64 0, i64 5113650790573562461}
// MS: [[TNOPROTO]] = !{i64 0, !"?6AX@Z"}
// MS: [[TNOPROTO_ID]] = !{i64 0, i64 4195979634929632483}
|
the_stack_data/54824319.c
|
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
int main() {
FILE *writeableFile = fopen("sulong_test_file", "w");
if (writeableFile == NULL) {
printf("error opening file!\n");
exit(1);
}
const char *text = "hello world!";
fprintf(writeableFile, "write this to the writeableFile: %s\n", text);
if (fclose(writeableFile) == EOF) {
exit(4);
}
FILE *readableFile = fopen("sulong_test_file", "r");
if (readableFile == NULL) {
printf("error opening file!\n");
exit(2);
}
char buff[1000];
fgets(buff, 1000, readableFile);
if (fclose(readableFile) == EOF) {
exit(4);
}
fputs(buff, stdout);
if (remove("sulong_test_file")) {
printf("error removing file!\n");
exit(3);
}
}
|
the_stack_data/192331892.c
|
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define PORT_NUM 3800
#define MAXLEN 256
struct cal_data
{
int left_num;
int right_num;
char op;
int result;
short int error;
};
int main(int argc, char **argv)
{
int sockfd;
socklen_t addrlen;
int cal_result;
int left_num, right_num;
struct sockaddr_in addr, cliaddr;
struct cal_data rdata;
if((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
{
return 1;
}
memset((void *)&addr, 0x00, sizeof(addr));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = htonl(INADDR_ANY);
addr.sin_port = htons(PORT_NUM);
addrlen = sizeof(addr);
if(bind(sockfd, (struct sockaddr *)&addr, addrlen) == -1)
{
return 1;
}
while(1)
{
addrlen = sizeof(cliaddr);
recvfrom(sockfd, (void *)&rdata, sizeof(rdata), 0,
(struct sockaddr *)&cliaddr, &addrlen);
#if DEBUG
char *ptr = (char *) &rdata;
for(int i=0; i< sizeof(rdata); i++)
printf("%02x ", *(ptr+i) & 0xFF);
printf("\n");
printf("Client Info : %s (%d)\n", inet_ntoa(cliaddr.sin_addr), ntohs(cliaddr.sin_port));
printf("%02x %c %02x\n", ntohl(rdata.left_num), rdata.op, ntohl(rdata.right_num));
#endif
left_num = ntohl(rdata.left_num);
right_num = ntohl(rdata.right_num);
switch(rdata.op)
{
case '+':
cal_result = left_num + right_num;
break;
case '-':
cal_result = left_num - right_num;
break;
case '*':
cal_result = left_num * right_num;
break;
case '/':
if(right_num == 0)
{
rdata.error = htons(2);
break;
}
cal_result = left_num / right_num;
break;
}
rdata.result=htonl(cal_result);
#if DEBUG
for(int i=0; i< sizeof(rdata); i++)
printf("%02x ", *(ptr+i) & 0xFF);
printf("\n");
#endif
sendto(sockfd, (void *)&rdata, sizeof(rdata), 0,
(struct sockaddr *)&cliaddr, addrlen);
}
return 1;
}
|
the_stack_data/34512878.c
|
/* Header automatically inserted by PYPS for defining MAX, MIN, MOD and others */
#ifndef MAX0
# define MAX0(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MAX
# define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif
#ifndef MOD
# define MOD(a, b) ((a) % (b))
#endif
#ifndef DBLE
# define DBLE(a) ((double)(a))
#endif
#ifndef INT
# define INT(a) ((int)(a))
#endif
#ifdef WITH_TRIGO
# include <math.h>
# ifndef COS
# define COS(a) (cos(a))
# endif
# ifndef SIN
# define SIN(a) (sin(a))
# endif
#endif
/* End header automatically inserted by PYPS for defining MAX, MIN, MOD and others */
#include <xmmintrin.h>
typedef float a2sf[2] __attribute__ ((aligned (16)));
typedef float a4sf[4] __attribute__ ((aligned (16)));
typedef double a2df[2] __attribute__ ((aligned (16)));
typedef int a4si[4] __attribute__ ((aligned (16)));
typedef __m128 v4sf;
typedef __m128d v2df;
typedef __m128i v4si;
typedef __m128i v8hi;
/* float */
#define SIMD_LOAD_V4SF(vec,arr) vec=_mm_loadu_ps(arr)
#define SIMD_LOADA_V4SF(vec,arr) vec=_mm_load_ps(arr)
#define SIMD_MULPS(vec1,vec2,vec3) vec1=_mm_mul_ps(vec2,vec3)
#define SIMD_DIVPS(vec1,vec2,vec3) vec1=_mm_div_ps(vec2,vec3)
#define SIMD_ADDPS(vec1,vec2,vec3) vec1=_mm_add_ps(vec2,vec3)
#define SIMD_SUBPS(vec1, vec2, vec3) vec1 = _mm_sub_ps(vec2, vec3)
/* umin as in unary minus */
#define SIMD_UMINPS(vec1, vec2) do { __m128 __pips_tmp; __pips_tmp = _mm_setzero_ps(); vec1 = _mm_sub_ps(__pips_tmp, vec2); } while(0)
#define SIMD_STORE_V4SF(vec,arr) _mm_storeu_ps(arr,vec)
#define SIMD_STOREA_V4SF(vec,arr) _mm_store_ps(arr,vec)
#define SIMD_STORE_GENERIC_V4SF(vec,v0,v1,v2,v3) do { float __pips_tmp[4] __attribute__ ((aligned (16))); SIMD_STOREA_V4SF(vec,&__pips_tmp[0]); *(v0)=__pips_tmp[0]; *(v1)=__pips_tmp[1]; *(v2)=__pips_tmp[2]; *(v3)=__pips_tmp[3]; } while (0)
#define SIMD_ZERO_V4SF(vec) vec = _mm_setzero_ps()
#define SIMD_LOAD_GENERIC_V4SF(vec,v0,v1,v2,v3) do { float __pips_v[4] __attribute ((aligned (16))); __pips_v[0]=v0; __pips_v[1]=v1; __pips_v[2]=v2; __pips_v[3]=v3; SIMD_LOADA_V4SF(vec,&__pips_v[0]); } while(0)
/* handle padded value, this is a very bad implementation ... */
#define SIMD_STORE_MASKED_V4SF(vec,arr) do { float __pips_tmp[4] __attribute__ ((aligned (16))); SIMD_STOREA_V4SF(vec,&__pips_tmp[0]); (arr)[0] = __pips_tmp[0]; (arr)[1] = __pips_tmp[1]; (arr)[2] = __pips_tmp[2]; } while(0)
#define SIMD_LOAD_V4SI_TO_V4SF(v, f) do { float __pips_tmp[4]; __pips_tmp[0] = (f)[0]; __pips_tmp[1] = (f)[1]; __pips_tmp[2] = (f)[2]; __pips_tmp[3] = (f)[3]; SIMD_LOAD_V4SF(v, __pips_tmp); } while(0)
/* double */
#define SIMD_LOAD_V2DF(vec,arr) vec=_mm_loadu_pd(arr)
#define SIMD_MULPD(vec1,vec2,vec3) vec1=_mm_mul_pd(vec2,vec3)
#define SIMD_ADDPD(vec1,vec2,vec3) vec1=_mm_add_pd(vec2,vec3)
#define SIMD_UMINPD(vec1, vec2) do { __m128d __pips_tmp; __pips_tmp = _mm_setzero_pd(); vec1 = _mm_sub_pd(__pips_tmp, vec2); } while(0)
#define SIMD_COSPD(vec1, vec2) do { double __pips_tmp[2] __attribute__ ((aligned (16))); SIMD_STORE_V2DF(vec2, __pips_tmp); __pips_tmp[0] = cos(__pips_tmp[0]); __pips_tmp[1] = cos(__pips_tmp[1]); SIMD_LOAD_V2DF(vec2, __pips_tmp); } while(0)
#define SIMD_SINPD(vec1, vec2) do { double __pips_tmp[2] __attribute__ ((aligned (16))); SIMD_STORE_V2DF(vec2, __pips_tmp); __pips_tmp[0] = sin(__pips_tmp[0]); __pips_tmp[1] = sin(__pips_tmp[1]); } while(0)
#define SIMD_STORE_V2DF(vec,arr) _mm_storeu_pd(arr,vec)
#define SIMD_STORE_GENERIC_V2DF(vec, v0, v1) do { double __pips_tmp[2]; SIMD_STORE_V2DF(vec,&__pips_tmp[0]); *(v0)=__pips_tmp[0]; *(v1)=__pips_tmp[1]; } while (0)
#define SIMD_LOAD_GENERIC_V2DF(vec,v0,v1) do { double v[2] = { v0,v1}; SIMD_LOAD_V2DF(vec,&v[0]); } while(0)
/* conversions */
#define SIMD_STORE_V2DF_TO_V2SF(vec,f) do { double __pips_tmp[2]; SIMD_STORE_V2DF(vec, __pips_tmp); (f)[0] = __pips_tmp[0]; (f)[1] = __pips_tmp[1]; } while(0)
#define SIMD_LOAD_V2SF_TO_V2DF(vec,f) SIMD_LOAD_GENERIC_V2DF(vec,(f)[0],(f)[1])
/* char */
#define SIMD_LOAD_V8HI(vec,arr) vec = (__m128i*)(arr)
#define SIMD_STORE_V8HI(vec,arr) *(__m128i *)(&(arr)[0]) = vec
#define SIMD_STORE_V8HI_TO_V8SI(vec,arr) SIMD_STORE_V8HI(vec,arr)
#define SIMD_LOAD_V8SI_TO_V8HI(vec,arr) SIMD_LOAD_V8HI(vec,arr)
/*
* file for dscal_r.c
*/
/* PIPS include guard begin: #include <stdio.h> */
#include <stdio.h>
/* PIPS include guard end: #include <stdio.h> */
/* PIPS include guard begin: #include <stdlib.h> */
#include <stdlib.h>
/* PIPS include guard end: #include <stdlib.h> */
void dscal_r(int n, float da, float dx[n]);
int main(int argc, char *argv[]);
void dscal_r(int n, float da, float dx[n])
{
//PIPS generated variable
int i0, i1;
//SAC generated temporary array
a4sf pdata0 = {da, da, da, da};
//PIPS generated variable
v4sf vec00_0, vec10_0;
SIMD_LOAD_V4SF(vec10_0, &pdata0[0]);
for(i0 = 0; i0 <= 4*(n/4)-1; i0 += 4) {
//PIPS:SAC generated v4sf vector(s)
SIMD_LOAD_V4SF(vec00_0, &dx[i0]);
SIMD_MULPS(vec00_0, vec10_0, vec00_0);
SIMD_STORE_V4SF(vec00_0, &dx[i0]);
}
for(i1 = 4*(n/4); i1 <= n-1; i1 += 1)
dx[i1] = pdata0[0]*dx[i1];
;
}
int main(int argc, char *argv[])
{
int n = argc==1?10:atoi(argv[1]);
float dx[n];
int i;
for(i = 0; i <= n-1; i += 1)
dx[i] = i;
dscal_r(n, 42., dx);
for(i = 0; i <= n-1; i += 1)
printf("%f", dx[i]);
return 0;
}
|
the_stack_data/152078.c
|
#include <stdlib.h>
#include <stdio.h>
typedef struct node {
int data;
struct node* next, *prev;
} node;
typedef struct queue {
int size;
struct node *head, *tail;
} queue;
int dequeue (queue *thisQ) {
if (thisQ == NULL) {
return 0;
}
if (thisQ->size == 0) {
return 0;
}
int retval = thisQ->head->data;
node *temp = thisQ->head;
thisQ->head = thisQ->head->next;
if (thisQ->size > 1)
thisQ->head->prev = NULL;
else
thisQ->tail = NULL;
free(temp);
thisQ->size--;
return retval;
}
|
the_stack_data/122016687.c
|
// RUN: %ucc -o %t %s "$(dirname %s)"/check_align_asm.s
// RUN: %t
// passes on Darwin, fails on Linux - timeout was hiding the crash
extern void check_align() __asm("check_align");
a()
{
int i = 1;
short c[i];
c[0] = 0;
check_align(c, i);
}
b()
{
int i = 3;
char c[i];
c[0] = 0;
c[1] = 0;
c[2] = 0;
check_align(c, i);
}
main()
{
a();
b();
return 0;
}
|
the_stack_data/50137365.c
|
#ifdef CONFIG_IR_RECEIVER
#include <stdint.h>
#include "glue.h"
#include "proj.h"
#include "sig.h"
#include "timer_a1.h"
#include "ir_remote_extra.h"
uint8_t ir_number;
extern uart_descriptor bc;
void ir_remote_init(const uint8_t flag)
{
IR_DIR &= ~IR_PIN;
// activate on a high-to-low transition
IR_IES |= IR_PIN;
// reset IRQ flags
IR_IFG &= ~IR_PIN;
// enable interrupt
IR_IE |= IR_PIN;
if (flag & IR_RST_SM) {
ir_resume();
}
}
uint8_t ir_remote_in(void)
{
return (IR_IN & IR_PIN);
}
void ir_remote_mng(void)
{
char buf[CONV_BASE_10_BUF_SZ];
if (ir_decode(&results)) {
ir_number = -1;
switch (results.value) {
// RC5 codes
case 1: // 1
ir_number = 1;
break;
case 2: // 2
ir_number = 2;
break;
case 3: // 3
ir_number = 3;
break;
case 4: // 4
ir_number = 4;
break;
case 5: // 5
ir_number = 5;
break;
case 6: // 6
ir_number = 6;
break;
case 7: // 7
ir_number = 7;
break;
case 8: // 8
ir_number = 8;
break;
case 9: // 9
ir_number = 9;
break;
case 0: // 0
ir_number = 0;
break;
default:
break;
}
uart_print(&bc, _utoh(&buf[0], results.value));
uart_print(&bc, "\r\n");
ir_resume(); // Receive the next value
}
}
// Port 6 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector=PORT6_VECTOR
__interrupt void port6_isr_handler(void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(PORT6_VECTOR))) port6_isr_handler(void)
#else
#error Compiler not supported!
#endif
{
switch (P6IV) {
case P6IV__P6IFG3:
// disable pin interrupt
IR_IE &= ~IR_PIN;
timer_a1_init();
ir_isr();
//_BIC_SR_IRQ(LPM3_bits);
break;
}
P6IFG = 0;
}
#endif
|
the_stack_data/82685.c
|
/*
*******************************************************************************
* Copyright (c) 2020-2021, STMicroelectronics
* All rights reserved.
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
*******************************************************************************
*/
#if defined(ARDUINO_GENERIC_F042F4PX) || defined(ARDUINO_GENERIC_F042F6PX)
#include "pins_arduino.h"
/**
* @brief System Clock Configuration
* @param None
* @retval None
*/
WEAK void SystemClock_Config(void)
{
/* SystemClock_Config can be generated by STM32CubeMX */
#warning "SystemClock_Config() is empty. Default clock at reset is used."
}
#endif /* ARDUINO_GENERIC_* */
|
the_stack_data/107952574.c
|
void __VERIFIER_assert(int x) { if(!(x)) {ERROR: goto ERROR;}}
extern void __VERIFIER_assume(int);
extern int __VERIFIER_nondet_int(void);
extern unsigned int __VERIFIER_nondet_uint(void);
extern _Bool __VERIFIER_nondet_bool(void);
extern char __VERIFIER_nondet_char(void);
extern unsigned char __VERIFIER_nondet_uchar(void);/*
* generated by CSeq [ 0000 / 0000 ]
*
* 2C9F merger-0.0-2015.07.09
* FB59 parser-0.0-2015.06.26
* AB0B module-0.0-2015.07.16 ]
*
* 2015-08-24 16:09:12
*
* params:
* --unwind 11, --rounds 2, -i reorder_2_false-unreach-call.c, -l out, --backend cpachecker,
*
* modules:
* 36D1 workarounds-0.0 ()
* 5E66 functiontracker-0.0 ()
* AE03 preinstrumenter-0.0 (error-label)
* 8CEB constants-0.0 ()
* 6EDD spinlock-0.0 ()
* 9C8E switchconverter-0.0 ()
* 6A40 dowhileconverter-0.0 ()
* B23B conditionextractor-0.0 ()
* BB48 varnames-0.0 ()
* 698C inliner-0.0 ()
* 1629 unroller-0.0 (unwind)
* 8667 duplicator-0.0 ()
* 72E0 condwaitconverter-0.0 ()
* 454D lazyseq-0.0 (rounds schedule threads deadlock)
* 2B01 instrumenter-0.0 (backend bitwidth header)
*
*/
#include <stdio.h>
#include <stdlib.h>
#define THREADS 22
#define ROUNDS 2
#define STOP_VOID(A) return;
#define STOP_NONVOID(A) return 0;
#define IF(T,A,B) if ((__cs_pc[T] > A) | (A >= __cs_pc_cs[T])) goto B;
#ifndef NULL
#define NULL 0
#endif
unsigned int __cs_active_thread[THREADS + 1] = {1};
unsigned int __cs_pc[THREADS + 1];
unsigned int __cs_pc_cs[THREADS + 1];
unsigned int __cs_thread_index;
unsigned int __cs_thread_lines[] = {91, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2};
void *__cs_safe_malloc(int __cs_size)
{
void *__cs_ptr = malloc(__cs_size);
__VERIFIER_assume(__cs_ptr);
return __cs_ptr;
}
void __cs_init_scalar(void *__cs_var, int __cs_size)
{
if (__cs_size == (sizeof(int)))
*((int *) __cs_var) = __VERIFIER_nondet_int();
else
{
char *__cs_ptr = (char *) __cs_var;
int __cs_j;
}
}
void __CSEQ_message(char *__cs_message)
{
;
}
typedef int __cs_t;
void *__cs_threadargs[THREADS + 1];
int __cs_create(__cs_t *__cs_new_thread_id, void *__cs_attr, void *(*__cs_t)(void *), void *__cs_arg, int __cs_threadID)
{
if (__cs_threadID > THREADS)
return 0;
*__cs_new_thread_id = __cs_threadID;
__cs_active_thread[__cs_threadID] = 1;
__cs_threadargs[__cs_threadID] = __cs_arg;
__CSEQ_message("thread spawned");
return 0;
}
int __cs_join(__cs_t __cs_id, void **__cs_value_ptr)
{
__VERIFIER_assume(__cs_pc[__cs_id] == __cs_thread_lines[__cs_id]);
return 0;
}
int __cs_exit(void *__cs_value_ptr)
{
return 0;
}
typedef int __cs_mutex_t;
int __cs_mutex_init(__cs_mutex_t *__cs_m, int __cs_val)
{
*__cs_m = -1;
return 0;
}
int __cs_mutex_destroy(__cs_mutex_t *__cs_mutex_to_destroy)
{
__VERIFIER_assert((*__cs_mutex_to_destroy) != 0);
__VERIFIER_assert((*__cs_mutex_to_destroy) != (-2));
__VERIFIER_assert((*__cs_mutex_to_destroy) == (-1));
*__cs_mutex_to_destroy = -2;
__CSEQ_message("lock destroyed");
return 0;
}
int __cs_mutex_lock(__cs_mutex_t *__cs_mutex_to_lock)
{
__VERIFIER_assert((*__cs_mutex_to_lock) != 0);
__VERIFIER_assert((*__cs_mutex_to_lock) != (-2));
__VERIFIER_assume((*__cs_mutex_to_lock) == (-1));
*__cs_mutex_to_lock = __cs_thread_index + 1;
__CSEQ_message("lock acquired");
return 0;
}
int __cs_mutex_unlock(__cs_mutex_t *__cs_mutex_to_unlock)
{
__VERIFIER_assert((*__cs_mutex_to_unlock) != 0);
__VERIFIER_assert((*__cs_mutex_to_unlock) != (-2));
__VERIFIER_assert((*__cs_mutex_to_unlock) == (__cs_thread_index + 1));
*__cs_mutex_to_unlock = -1;
__CSEQ_message("lock released");
return 0;
}
typedef int __cs_cond_t;
int __cs_cond_init(__cs_cond_t *__cs_cond_to_init, void *__cs_attr)
{
*__cs_cond_to_init = -1;
return 0;
}
int __cs_cond_wait_1(__cs_cond_t *__cs_cond_to_wait_for, __cs_mutex_t *__cs_m)
{
__VERIFIER_assert((*__cs_cond_to_wait_for) != 0);
__VERIFIER_assert((*__cs_cond_to_wait_for) != (-2));
__cs_mutex_unlock(__cs_m);
}
int __cs_cond_wait_2(__cs_cond_t *__cs_cond_to_wait_for, __cs_mutex_t *__cs_m)
{
__VERIFIER_assume((*__cs_cond_to_wait_for) == 1);
__cs_mutex_lock(__cs_m);
return 0;
}
int __cs_cond_signal(__cs_cond_t *__cs_cond_to_signal)
{
*__cs_cond_to_signal = 1;
__CSEQ_message("conditional variable signal");
return 0;
}
extern void __VERIFIER_error();
static int iSet = 2;
static int iCheck = 2;
static int a = 0;
static int b = 0;
void *setThread_0(void *__cs_param__param);
void *setThread_1(void *__cs_param__param);
void *setThread_2(void *__cs_param__param);
void *setThread_3(void *__cs_param__param);
void *setThread_4(void *__cs_param__param);
void *setThread_5(void *__cs_param__param);
void *setThread_6(void *__cs_param__param);
void *setThread_7(void *__cs_param__param);
void *setThread_8(void *__cs_param__param);
void *setThread_9(void *__cs_param__param);
void *setThread_10(void *__cs_param__param);
void *checkThread_0(void *__cs_param__param);
void *checkThread_1(void *__cs_param__param);
void *checkThread_2(void *__cs_param__param);
void *checkThread_3(void *__cs_param__param);
void *checkThread_4(void *__cs_param__param);
void *checkThread_5(void *__cs_param__param);
void *checkThread_6(void *__cs_param__param);
void *checkThread_7(void *__cs_param__param);
void *checkThread_8(void *__cs_param__param);
void *checkThread_9(void *__cs_param__param);
void *checkThread_10(void *__cs_param__param);
void set();
int check();
int main_thread(void)
{
int __cs_param_main_argc;
char **__cs_param_main_argv;
IF(0,0,tmain_1)
static int __cs_local_main_i;
__cs_init_scalar(&__cs_local_main_i, sizeof(int));
static int __cs_local_main_err;
__cs_init_scalar(&__cs_local_main_err, sizeof(int));
static _Bool __cs_local_main___cs_tmp_if_cond_0;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_0, sizeof(_Bool));
__cs_local_main___cs_tmp_if_cond_0 = __cs_param_main_argc != 1;
if (__cs_local_main___cs_tmp_if_cond_0)
{
static _Bool __cs_local_main___cs_tmp_if_cond_1;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_1, sizeof(_Bool));
__cs_local_main___cs_tmp_if_cond_1 = __cs_param_main_argc != 3;
if (__cs_local_main___cs_tmp_if_cond_1)
{
fprintf(stderr, "./reorder <param1> <param2>\n");
exit(-1);
}
else
{
sscanf(__cs_param_main_argv[1], "%d", &iSet);
sscanf(__cs_param_main_argv[2], "%d", &iCheck);
}
;
}
;
static __cs_t *__cs_local_main_setPool;
__cs_local_main_setPool = (__cs_t *) malloc((sizeof(__cs_t)) * iSet);
__VERIFIER_assume(__cs_local_main_setPool);
static __cs_t *__cs_local_main_checkPool;
__cs_local_main_checkPool = (__cs_t *) malloc((sizeof(__cs_t)) * iCheck);
__VERIFIER_assume(__cs_local_main_checkPool);
__cs_local_main_i = 0;
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_0, 0, 1));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_1: IF(0,1,tmain_2)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_2: IF(0,2,tmain_3)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_1, 0, 2));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_3: IF(0,3,tmain_4)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_4: IF(0,4,tmain_5)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_2, 0, 3));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_5: IF(0,5,tmain_6)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_6: IF(0,6,tmain_7)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_3, 0, 4));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_7: IF(0,7,tmain_8)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_8: IF(0,8,tmain_9)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_4, 0, 5));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_9: IF(0,9,tmain_10)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_10: IF(0,10,tmain_11)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_5, 0, 6));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_11: IF(0,11,tmain_12)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_12: IF(0,12,tmain_13)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_6, 0, 7));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_13: IF(0,13,tmain_14)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_14: IF(0,14,tmain_15)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_7, 0, 8));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_15: IF(0,15,tmain_16)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_16: IF(0,16,tmain_17)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_8, 0, 9));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_17: IF(0,17,tmain_18)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_18: IF(0,18,tmain_19)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_9, 0, 10));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_19: IF(0,19,tmain_20)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_1;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_2;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_2, sizeof(_Bool));
tmain_20: IF(0,20,tmain_21)
__cs_local_main___cs_tmp_if_cond_2 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_setPool[__cs_local_main_i], 0, setThread_10, 0, 11));
if (__cs_local_main___cs_tmp_if_cond_2)
{
fprintf(stderr, "Error [%d] found creating set thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_21: IF(0,21,tmain_22)
__VERIFIER_assume(!(__cs_local_main_i < iSet));
__exit_loop_1:
__VERIFIER_assume(__cs_pc_cs[0] >= 22);
;
;
__cs_local_main_i = 0;
tmain_22: IF(0,22,tmain_23)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_23: IF(0,23,tmain_24)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_0,
0, 12));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_24: IF(0,24,tmain_25)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_25: IF(0,25,tmain_26)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_1,
0, 13));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_26: IF(0,26,tmain_27)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_27: IF(0,27,tmain_28)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_2,
0, 14));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_28: IF(0,28,tmain_29)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_29: IF(0,29,tmain_30)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_3,
0, 15));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_30: IF(0,30,tmain_31)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_31: IF(0,31,tmain_32)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_4,
0, 16));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_32: IF(0,32,tmain_33)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_33: IF(0,33,tmain_34)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_5,
0, 17));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_34: IF(0,34,tmain_35)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_35: IF(0,35,tmain_36)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_6,
0, 18));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_36: IF(0,36,tmain_37)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_37: IF(0,37,tmain_38)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_7,
0, 19));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_38: IF(0,38,tmain_39)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_39: IF(0,39,tmain_40)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_8,
0, 20));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_40: IF(0,40,tmain_41)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_41: IF(0,41,tmain_42)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_9,
0, 21));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_42: IF(0,42,tmain_43)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_2;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_3;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_3, sizeof(_Bool));
tmain_43: IF(0,43,tmain_44)
__cs_local_main___cs_tmp_if_cond_3 = 0 != (__cs_local_main_err = __cs_create(&__cs_local_main_checkPool[__cs_local_main_i], 0, checkThread_10,
0, 22));
if (__cs_local_main___cs_tmp_if_cond_3)
{
fprintf(stderr, "Error [%d] found creating check thread.\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_44: IF(0,44,tmain_45)
__VERIFIER_assume(!(__cs_local_main_i < iCheck));
__exit_loop_2:
__VERIFIER_assume(__cs_pc_cs[0] >= 45);
;
;
__cs_local_main_i = 0;
tmain_45: IF(0,45,tmain_46)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_46: IF(0,46,tmain_47)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_47: IF(0,47,tmain_48)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_48: IF(0,48,tmain_49)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_49: IF(0,49,tmain_50)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_50: IF(0,50,tmain_51)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_51: IF(0,51,tmain_52)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_52: IF(0,52,tmain_53)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_53: IF(0,53,tmain_54)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_54: IF(0,54,tmain_55)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_55: IF(0,55,tmain_56)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_56: IF(0,56,tmain_57)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_57: IF(0,57,tmain_58)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_58: IF(0,58,tmain_59)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_59: IF(0,59,tmain_60)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_60: IF(0,60,tmain_61)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_61: IF(0,61,tmain_62)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_62: IF(0,62,tmain_63)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_63: IF(0,63,tmain_64)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_64: IF(0,64,tmain_65)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_65: IF(0,65,tmain_66)
if (!(__cs_local_main_i < iSet))
{
goto __exit_loop_3;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_4;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_4, sizeof(_Bool));
tmain_66: IF(0,66,tmain_67)
__cs_local_main___cs_tmp_if_cond_4 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_setPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_4)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_67: IF(0,67,tmain_68)
__VERIFIER_assume(!(__cs_local_main_i < iSet));
__exit_loop_3:
__VERIFIER_assume(__cs_pc_cs[0] >= 68);
;
;
__cs_local_main_i = 0;
tmain_68: IF(0,68,tmain_69)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_69: IF(0,69,tmain_70)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_70: IF(0,70,tmain_71)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_71: IF(0,71,tmain_72)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_72: IF(0,72,tmain_73)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_73: IF(0,73,tmain_74)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_74: IF(0,74,tmain_75)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_75: IF(0,75,tmain_76)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_76: IF(0,76,tmain_77)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_77: IF(0,77,tmain_78)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_78: IF(0,78,tmain_79)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_79: IF(0,79,tmain_80)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_80: IF(0,80,tmain_81)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_81: IF(0,81,tmain_82)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_82: IF(0,82,tmain_83)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_83: IF(0,83,tmain_84)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_84: IF(0,84,tmain_85)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_85: IF(0,85,tmain_86)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_86: IF(0,86,tmain_87)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_87: IF(0,87,tmain_88)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_88: IF(0,88,tmain_89)
if (!(__cs_local_main_i < iCheck))
{
goto __exit_loop_4;
;
}
;
{
static _Bool __cs_local_main___cs_tmp_if_cond_5;
__cs_init_scalar(&__cs_local_main___cs_tmp_if_cond_5, sizeof(_Bool));
tmain_89: IF(0,89,tmain_90)
__cs_local_main___cs_tmp_if_cond_5 = 0 != (__cs_local_main_err = __cs_join(__cs_local_main_checkPool[__cs_local_main_i], 0));
if (__cs_local_main___cs_tmp_if_cond_5)
{
fprintf(stderr, "pthread join error: %d\n", __cs_local_main_err);
exit(-1);
}
;
}
;
__cs_local_main_i++;
tmain_90: IF(0,90,tmain_91)
__VERIFIER_assume(!(__cs_local_main_i < iCheck));
__exit_loop_4:
__VERIFIER_assume(__cs_pc_cs[0] >= 91);
;
;
goto __exit_main;
;
__exit_main:
__VERIFIER_assume(__cs_pc_cs[0] >= 91);
;
;
tmain_91:
STOP_NONVOID(91);
}
void *setThread_0(void *__cs_param_setThread_param)
{
IF(1,0,tsetThread_0_1)
a = 1;
tsetThread_0_1: IF(1,1,tsetThread_0_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[1] >= 2);
;
;
tsetThread_0_2:
STOP_NONVOID(2);
}
void *setThread_1(void *__cs_param_setThread_param)
{
IF(2,0,tsetThread_1_1)
a = 1;
tsetThread_1_1: IF(2,1,tsetThread_1_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[2] >= 2);
;
;
tsetThread_1_2:
STOP_NONVOID(2);
}
void *setThread_2(void *__cs_param_setThread_param)
{
IF(3,0,tsetThread_2_1)
a = 1;
tsetThread_2_1: IF(3,1,tsetThread_2_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[3] >= 2);
;
;
tsetThread_2_2:
STOP_NONVOID(2);
}
void *setThread_3(void *__cs_param_setThread_param)
{
IF(4,0,tsetThread_3_1)
a = 1;
tsetThread_3_1: IF(4,1,tsetThread_3_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[4] >= 2);
;
;
tsetThread_3_2:
STOP_NONVOID(2);
}
void *setThread_4(void *__cs_param_setThread_param)
{
IF(5,0,tsetThread_4_1)
a = 1;
tsetThread_4_1: IF(5,1,tsetThread_4_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[5] >= 2);
;
;
tsetThread_4_2:
STOP_NONVOID(2);
}
void *setThread_5(void *__cs_param_setThread_param)
{
IF(6,0,tsetThread_5_1)
a = 1;
tsetThread_5_1: IF(6,1,tsetThread_5_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[6] >= 2);
;
;
tsetThread_5_2:
STOP_NONVOID(2);
}
void *setThread_6(void *__cs_param_setThread_param)
{
IF(7,0,tsetThread_6_1)
a = 1;
tsetThread_6_1: IF(7,1,tsetThread_6_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[7] >= 2);
;
;
tsetThread_6_2:
STOP_NONVOID(2);
}
void *setThread_7(void *__cs_param_setThread_param)
{
IF(8,0,tsetThread_7_1)
a = 1;
tsetThread_7_1: IF(8,1,tsetThread_7_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[8] >= 2);
;
;
tsetThread_7_2:
STOP_NONVOID(2);
}
void *setThread_8(void *__cs_param_setThread_param)
{
IF(9,0,tsetThread_8_1)
a = 1;
tsetThread_8_1: IF(9,1,tsetThread_8_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[9] >= 2);
;
;
tsetThread_8_2:
STOP_NONVOID(2);
}
void *setThread_9(void *__cs_param_setThread_param)
{
IF(10,0,tsetThread_9_1)
a = 1;
tsetThread_9_1: IF(10,1,tsetThread_9_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[10] >= 2);
;
;
tsetThread_9_2:
STOP_NONVOID(2);
}
void *setThread_10(void *__cs_param_setThread_param)
{
IF(11,0,tsetThread_10_1)
a = 1;
tsetThread_10_1: IF(11,1,tsetThread_10_2)
b = -1;
goto __exit_setThread;
;
__exit_setThread:
__VERIFIER_assume(__cs_pc_cs[11] >= 2);
;
;
tsetThread_10_2:
STOP_NONVOID(2);
}
void *checkThread_0(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(12,0,tcheckThread_0_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_0_1: IF(12,1,tcheckThread_0_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[12] >= 2);
;
;
tcheckThread_0_2:
STOP_NONVOID(2);
}
void *checkThread_1(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(13,0,tcheckThread_1_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_1_1: IF(13,1,tcheckThread_1_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[13] >= 2);
;
;
tcheckThread_1_2:
STOP_NONVOID(2);
}
void *checkThread_2(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(14,0,tcheckThread_2_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_2_1: IF(14,1,tcheckThread_2_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[14] >= 2);
;
;
tcheckThread_2_2:
STOP_NONVOID(2);
}
void *checkThread_3(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(15,0,tcheckThread_3_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_3_1: IF(15,1,tcheckThread_3_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[15] >= 2);
;
;
tcheckThread_3_2:
STOP_NONVOID(2);
}
void *checkThread_4(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(16,0,tcheckThread_4_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_4_1: IF(16,1,tcheckThread_4_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[16] >= 2);
;
;
tcheckThread_4_2:
STOP_NONVOID(2);
}
void *checkThread_5(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(17,0,tcheckThread_5_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_5_1: IF(17,1,tcheckThread_5_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[17] >= 2);
;
;
tcheckThread_5_2:
STOP_NONVOID(2);
}
void *checkThread_6(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(18,0,tcheckThread_6_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_6_1: IF(18,1,tcheckThread_6_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[18] >= 2);
;
;
tcheckThread_6_2:
STOP_NONVOID(2);
}
void *checkThread_7(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(19,0,tcheckThread_7_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_7_1: IF(19,1,tcheckThread_7_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[19] >= 2);
;
;
tcheckThread_7_2:
STOP_NONVOID(2);
}
void *checkThread_8(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(20,0,tcheckThread_8_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_8_1: IF(20,1,tcheckThread_8_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[20] >= 2);
;
;
tcheckThread_8_2:
STOP_NONVOID(2);
}
void *checkThread_9(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(21,0,tcheckThread_9_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_9_1: IF(21,1,tcheckThread_9_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[21] >= 2);
;
;
tcheckThread_9_2:
STOP_NONVOID(2);
}
void *checkThread_10(void *__cs_param_checkThread_param)
{
static _Bool __cs_local_checkThread___cs_tmp_if_cond_6;
IF(22,0,tcheckThread_10_1)
__cs_init_scalar(&__cs_local_checkThread___cs_tmp_if_cond_6, sizeof(_Bool));
tcheckThread_10_1: IF(22,1,tcheckThread_10_2)
__cs_local_checkThread___cs_tmp_if_cond_6 = !(((a == 0) && (b == 0)) || ((a == 1) && (b == (-1))));
if (__cs_local_checkThread___cs_tmp_if_cond_6)
{
fprintf(stderr, "Bug found!\n");
__VERIFIER_assert(0);
__VERIFIER_assert(0);
}
;
goto __exit_checkThread;
;
__exit_checkThread:
__VERIFIER_assume(__cs_pc_cs[22] >= 2);
;
;
tcheckThread_10_2:
STOP_NONVOID(2);
}
int main(void)
{
unsigned int __cs_tmp_t0_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t1_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t2_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t3_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t4_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t5_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t6_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t7_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t8_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t9_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t10_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t11_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t12_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t13_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t14_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t15_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t16_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t17_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t18_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t19_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t20_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t21_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t22_r0 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t0_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t1_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t2_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t3_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t4_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t5_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t6_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t7_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t8_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t9_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t10_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t11_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t12_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t13_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t14_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t15_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t16_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t17_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t18_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t19_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t20_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t21_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t22_r1 = __VERIFIER_nondet_uint();
unsigned int __cs_tmp_t0_r2 = __VERIFIER_nondet_uint();
/* round 0 */
__VERIFIER_assume(__cs_tmp_t0_r0 > 0);
__cs_thread_index = 0;
__cs_pc_cs[0] = __cs_pc[0] + __cs_tmp_t0_r0;
__VERIFIER_assume(__cs_pc_cs[0] > 0);
__VERIFIER_assume(__cs_pc_cs[0] <= 91);
main_thread();
__cs_pc[0] = __cs_pc_cs[0];
if (__cs_active_thread[1] == 1)
{
__cs_thread_index = 1;
__cs_pc_cs[1] = __cs_pc[1] + __cs_tmp_t1_r0;
__VERIFIER_assume(__cs_pc_cs[1] <= 2);
setThread_0(__cs_threadargs[1]);
__cs_pc[1] = __cs_pc_cs[1];
}
if (__cs_active_thread[2] == 1)
{
__cs_thread_index = 2;
__cs_pc_cs[2] = __cs_pc[2] + __cs_tmp_t2_r0;
__VERIFIER_assume(__cs_pc_cs[2] <= 2);
setThread_1(__cs_threadargs[2]);
__cs_pc[2] = __cs_pc_cs[2];
}
if (__cs_active_thread[3] == 1)
{
__cs_thread_index = 3;
__cs_pc_cs[3] = __cs_pc[3] + __cs_tmp_t3_r0;
__VERIFIER_assume(__cs_pc_cs[3] <= 2);
setThread_2(__cs_threadargs[3]);
__cs_pc[3] = __cs_pc_cs[3];
}
if (__cs_active_thread[4] == 1)
{
__cs_thread_index = 4;
__cs_pc_cs[4] = __cs_pc[4] + __cs_tmp_t4_r0;
__VERIFIER_assume(__cs_pc_cs[4] <= 2);
setThread_3(__cs_threadargs[4]);
__cs_pc[4] = __cs_pc_cs[4];
}
if (__cs_active_thread[5] == 1)
{
__cs_thread_index = 5;
__cs_pc_cs[5] = __cs_pc[5] + __cs_tmp_t5_r0;
__VERIFIER_assume(__cs_pc_cs[5] <= 2);
setThread_4(__cs_threadargs[5]);
__cs_pc[5] = __cs_pc_cs[5];
}
if (__cs_active_thread[6] == 1)
{
__cs_thread_index = 6;
__cs_pc_cs[6] = __cs_pc[6] + __cs_tmp_t6_r0;
__VERIFIER_assume(__cs_pc_cs[6] <= 2);
setThread_5(__cs_threadargs[6]);
__cs_pc[6] = __cs_pc_cs[6];
}
if (__cs_active_thread[7] == 1)
{
__cs_thread_index = 7;
__cs_pc_cs[7] = __cs_pc[7] + __cs_tmp_t7_r0;
__VERIFIER_assume(__cs_pc_cs[7] <= 2);
setThread_6(__cs_threadargs[7]);
__cs_pc[7] = __cs_pc_cs[7];
}
if (__cs_active_thread[8] == 1)
{
__cs_thread_index = 8;
__cs_pc_cs[8] = __cs_pc[8] + __cs_tmp_t8_r0;
__VERIFIER_assume(__cs_pc_cs[8] <= 2);
setThread_7(__cs_threadargs[8]);
__cs_pc[8] = __cs_pc_cs[8];
}
if (__cs_active_thread[9] == 1)
{
__cs_thread_index = 9;
__cs_pc_cs[9] = __cs_pc[9] + __cs_tmp_t9_r0;
__VERIFIER_assume(__cs_pc_cs[9] <= 2);
setThread_8(__cs_threadargs[9]);
__cs_pc[9] = __cs_pc_cs[9];
}
if (__cs_active_thread[10] == 1)
{
__cs_thread_index = 10;
__cs_pc_cs[10] = __cs_pc[10] + __cs_tmp_t10_r0;
__VERIFIER_assume(__cs_pc_cs[10] <= 2);
setThread_9(__cs_threadargs[10]);
__cs_pc[10] = __cs_pc_cs[10];
}
if (__cs_active_thread[11] == 1)
{
__cs_thread_index = 11;
__cs_pc_cs[11] = __cs_pc[11] + __cs_tmp_t11_r0;
__VERIFIER_assume(__cs_pc_cs[11] <= 2);
setThread_10(__cs_threadargs[11]);
__cs_pc[11] = __cs_pc_cs[11];
}
if (__cs_active_thread[12] == 1)
{
__cs_thread_index = 12;
__cs_pc_cs[12] = __cs_pc[12] + __cs_tmp_t12_r0;
__VERIFIER_assume(__cs_pc_cs[12] <= 2);
checkThread_0(__cs_threadargs[12]);
__cs_pc[12] = __cs_pc_cs[12];
}
if (__cs_active_thread[13] == 1)
{
__cs_thread_index = 13;
__cs_pc_cs[13] = __cs_pc[13] + __cs_tmp_t13_r0;
__VERIFIER_assume(__cs_pc_cs[13] <= 2);
checkThread_1(__cs_threadargs[13]);
__cs_pc[13] = __cs_pc_cs[13];
}
if (__cs_active_thread[14] == 1)
{
__cs_thread_index = 14;
__cs_pc_cs[14] = __cs_pc[14] + __cs_tmp_t14_r0;
__VERIFIER_assume(__cs_pc_cs[14] <= 2);
checkThread_2(__cs_threadargs[14]);
__cs_pc[14] = __cs_pc_cs[14];
}
if (__cs_active_thread[15] == 1)
{
__cs_thread_index = 15;
__cs_pc_cs[15] = __cs_pc[15] + __cs_tmp_t15_r0;
__VERIFIER_assume(__cs_pc_cs[15] <= 2);
checkThread_3(__cs_threadargs[15]);
__cs_pc[15] = __cs_pc_cs[15];
}
if (__cs_active_thread[16] == 1)
{
__cs_thread_index = 16;
__cs_pc_cs[16] = __cs_pc[16] + __cs_tmp_t16_r0;
__VERIFIER_assume(__cs_pc_cs[16] <= 2);
checkThread_4(__cs_threadargs[16]);
__cs_pc[16] = __cs_pc_cs[16];
}
if (__cs_active_thread[17] == 1)
{
__cs_thread_index = 17;
__cs_pc_cs[17] = __cs_pc[17] + __cs_tmp_t17_r0;
__VERIFIER_assume(__cs_pc_cs[17] <= 2);
checkThread_5(__cs_threadargs[17]);
__cs_pc[17] = __cs_pc_cs[17];
}
if (__cs_active_thread[18] == 1)
{
__cs_thread_index = 18;
__cs_pc_cs[18] = __cs_pc[18] + __cs_tmp_t18_r0;
__VERIFIER_assume(__cs_pc_cs[18] <= 2);
checkThread_6(__cs_threadargs[18]);
__cs_pc[18] = __cs_pc_cs[18];
}
if (__cs_active_thread[19] == 1)
{
__cs_thread_index = 19;
__cs_pc_cs[19] = __cs_pc[19] + __cs_tmp_t19_r0;
__VERIFIER_assume(__cs_pc_cs[19] <= 2);
checkThread_7(__cs_threadargs[19]);
__cs_pc[19] = __cs_pc_cs[19];
}
if (__cs_active_thread[20] == 1)
{
__cs_thread_index = 20;
__cs_pc_cs[20] = __cs_pc[20] + __cs_tmp_t20_r0;
__VERIFIER_assume(__cs_pc_cs[20] <= 2);
checkThread_8(__cs_threadargs[20]);
__cs_pc[20] = __cs_pc_cs[20];
}
if (__cs_active_thread[21] == 1)
{
__cs_thread_index = 21;
__cs_pc_cs[21] = __cs_pc[21] + __cs_tmp_t21_r0;
__VERIFIER_assume(__cs_pc_cs[21] <= 2);
checkThread_9(__cs_threadargs[21]);
__cs_pc[21] = __cs_pc_cs[21];
}
if (__cs_active_thread[22] == 1)
{
__cs_thread_index = 22;
__cs_pc_cs[22] = __cs_pc[22] + __cs_tmp_t22_r0;
__VERIFIER_assume(__cs_pc_cs[22] <= 2);
checkThread_10(__cs_threadargs[22]);
__cs_pc[22] = __cs_pc_cs[22];
}
/* round 1 */
if (__cs_active_thread[0] == 1)
{
__cs_thread_index = 0;
__cs_pc_cs[0] = __cs_pc[0] + __cs_tmp_t0_r1;
__VERIFIER_assume(__cs_pc_cs[0] >= __cs_pc[0]);
__VERIFIER_assume(__cs_pc_cs[0] <= 91);
main_thread();
__cs_pc[0] = __cs_pc_cs[0];
}
if (__cs_active_thread[1] == 1)
{
__cs_thread_index = 1;
__cs_pc_cs[1] = __cs_pc[1] + __cs_tmp_t1_r1;
__VERIFIER_assume(__cs_pc_cs[1] >= __cs_pc[1]);
__VERIFIER_assume(__cs_pc_cs[1] <= 2);
setThread_0(__cs_threadargs[__cs_thread_index]);
__cs_pc[1] = __cs_pc_cs[1];
}
if (__cs_active_thread[2] == 1)
{
__cs_thread_index = 2;
__cs_pc_cs[2] = __cs_pc[2] + __cs_tmp_t2_r1;
__VERIFIER_assume(__cs_pc_cs[2] >= __cs_pc[2]);
__VERIFIER_assume(__cs_pc_cs[2] <= 2);
setThread_1(__cs_threadargs[__cs_thread_index]);
__cs_pc[2] = __cs_pc_cs[2];
}
if (__cs_active_thread[3] == 1)
{
__cs_thread_index = 3;
__cs_pc_cs[3] = __cs_pc[3] + __cs_tmp_t3_r1;
__VERIFIER_assume(__cs_pc_cs[3] >= __cs_pc[3]);
__VERIFIER_assume(__cs_pc_cs[3] <= 2);
setThread_2(__cs_threadargs[__cs_thread_index]);
__cs_pc[3] = __cs_pc_cs[3];
}
if (__cs_active_thread[4] == 1)
{
__cs_thread_index = 4;
__cs_pc_cs[4] = __cs_pc[4] + __cs_tmp_t4_r1;
__VERIFIER_assume(__cs_pc_cs[4] >= __cs_pc[4]);
__VERIFIER_assume(__cs_pc_cs[4] <= 2);
setThread_3(__cs_threadargs[__cs_thread_index]);
__cs_pc[4] = __cs_pc_cs[4];
}
if (__cs_active_thread[5] == 1)
{
__cs_thread_index = 5;
__cs_pc_cs[5] = __cs_pc[5] + __cs_tmp_t5_r1;
__VERIFIER_assume(__cs_pc_cs[5] >= __cs_pc[5]);
__VERIFIER_assume(__cs_pc_cs[5] <= 2);
setThread_4(__cs_threadargs[__cs_thread_index]);
__cs_pc[5] = __cs_pc_cs[5];
}
if (__cs_active_thread[6] == 1)
{
__cs_thread_index = 6;
__cs_pc_cs[6] = __cs_pc[6] + __cs_tmp_t6_r1;
__VERIFIER_assume(__cs_pc_cs[6] >= __cs_pc[6]);
__VERIFIER_assume(__cs_pc_cs[6] <= 2);
setThread_5(__cs_threadargs[__cs_thread_index]);
__cs_pc[6] = __cs_pc_cs[6];
}
if (__cs_active_thread[7] == 1)
{
__cs_thread_index = 7;
__cs_pc_cs[7] = __cs_pc[7] + __cs_tmp_t7_r1;
__VERIFIER_assume(__cs_pc_cs[7] >= __cs_pc[7]);
__VERIFIER_assume(__cs_pc_cs[7] <= 2);
setThread_6(__cs_threadargs[__cs_thread_index]);
__cs_pc[7] = __cs_pc_cs[7];
}
if (__cs_active_thread[8] == 1)
{
__cs_thread_index = 8;
__cs_pc_cs[8] = __cs_pc[8] + __cs_tmp_t8_r1;
__VERIFIER_assume(__cs_pc_cs[8] >= __cs_pc[8]);
__VERIFIER_assume(__cs_pc_cs[8] <= 2);
setThread_7(__cs_threadargs[__cs_thread_index]);
__cs_pc[8] = __cs_pc_cs[8];
}
if (__cs_active_thread[9] == 1)
{
__cs_thread_index = 9;
__cs_pc_cs[9] = __cs_pc[9] + __cs_tmp_t9_r1;
__VERIFIER_assume(__cs_pc_cs[9] >= __cs_pc[9]);
__VERIFIER_assume(__cs_pc_cs[9] <= 2);
setThread_8(__cs_threadargs[__cs_thread_index]);
__cs_pc[9] = __cs_pc_cs[9];
}
if (__cs_active_thread[10] == 1)
{
__cs_thread_index = 10;
__cs_pc_cs[10] = __cs_pc[10] + __cs_tmp_t10_r1;
__VERIFIER_assume(__cs_pc_cs[10] >= __cs_pc[10]);
__VERIFIER_assume(__cs_pc_cs[10] <= 2);
setThread_9(__cs_threadargs[__cs_thread_index]);
__cs_pc[10] = __cs_pc_cs[10];
}
if (__cs_active_thread[11] == 1)
{
__cs_thread_index = 11;
__cs_pc_cs[11] = __cs_pc[11] + __cs_tmp_t11_r1;
__VERIFIER_assume(__cs_pc_cs[11] >= __cs_pc[11]);
__VERIFIER_assume(__cs_pc_cs[11] <= 2);
setThread_10(__cs_threadargs[__cs_thread_index]);
__cs_pc[11] = __cs_pc_cs[11];
}
if (__cs_active_thread[12] == 1)
{
__cs_thread_index = 12;
__cs_pc_cs[12] = __cs_pc[12] + __cs_tmp_t12_r1;
__VERIFIER_assume(__cs_pc_cs[12] >= __cs_pc[12]);
__VERIFIER_assume(__cs_pc_cs[12] <= 2);
checkThread_0(__cs_threadargs[__cs_thread_index]);
__cs_pc[12] = __cs_pc_cs[12];
}
if (__cs_active_thread[13] == 1)
{
__cs_thread_index = 13;
__cs_pc_cs[13] = __cs_pc[13] + __cs_tmp_t13_r1;
__VERIFIER_assume(__cs_pc_cs[13] >= __cs_pc[13]);
__VERIFIER_assume(__cs_pc_cs[13] <= 2);
checkThread_1(__cs_threadargs[__cs_thread_index]);
__cs_pc[13] = __cs_pc_cs[13];
}
if (__cs_active_thread[14] == 1)
{
__cs_thread_index = 14;
__cs_pc_cs[14] = __cs_pc[14] + __cs_tmp_t14_r1;
__VERIFIER_assume(__cs_pc_cs[14] >= __cs_pc[14]);
__VERIFIER_assume(__cs_pc_cs[14] <= 2);
checkThread_2(__cs_threadargs[__cs_thread_index]);
__cs_pc[14] = __cs_pc_cs[14];
}
if (__cs_active_thread[15] == 1)
{
__cs_thread_index = 15;
__cs_pc_cs[15] = __cs_pc[15] + __cs_tmp_t15_r1;
__VERIFIER_assume(__cs_pc_cs[15] >= __cs_pc[15]);
__VERIFIER_assume(__cs_pc_cs[15] <= 2);
checkThread_3(__cs_threadargs[__cs_thread_index]);
__cs_pc[15] = __cs_pc_cs[15];
}
if (__cs_active_thread[16] == 1)
{
__cs_thread_index = 16;
__cs_pc_cs[16] = __cs_pc[16] + __cs_tmp_t16_r1;
__VERIFIER_assume(__cs_pc_cs[16] >= __cs_pc[16]);
__VERIFIER_assume(__cs_pc_cs[16] <= 2);
checkThread_4(__cs_threadargs[__cs_thread_index]);
__cs_pc[16] = __cs_pc_cs[16];
}
if (__cs_active_thread[17] == 1)
{
__cs_thread_index = 17;
__cs_pc_cs[17] = __cs_pc[17] + __cs_tmp_t17_r1;
__VERIFIER_assume(__cs_pc_cs[17] >= __cs_pc[17]);
__VERIFIER_assume(__cs_pc_cs[17] <= 2);
checkThread_5(__cs_threadargs[__cs_thread_index]);
__cs_pc[17] = __cs_pc_cs[17];
}
if (__cs_active_thread[18] == 1)
{
__cs_thread_index = 18;
__cs_pc_cs[18] = __cs_pc[18] + __cs_tmp_t18_r1;
__VERIFIER_assume(__cs_pc_cs[18] >= __cs_pc[18]);
__VERIFIER_assume(__cs_pc_cs[18] <= 2);
checkThread_6(__cs_threadargs[__cs_thread_index]);
__cs_pc[18] = __cs_pc_cs[18];
}
if (__cs_active_thread[19] == 1)
{
__cs_thread_index = 19;
__cs_pc_cs[19] = __cs_pc[19] + __cs_tmp_t19_r1;
__VERIFIER_assume(__cs_pc_cs[19] >= __cs_pc[19]);
__VERIFIER_assume(__cs_pc_cs[19] <= 2);
checkThread_7(__cs_threadargs[__cs_thread_index]);
__cs_pc[19] = __cs_pc_cs[19];
}
if (__cs_active_thread[20] == 1)
{
__cs_thread_index = 20;
__cs_pc_cs[20] = __cs_pc[20] + __cs_tmp_t20_r1;
__VERIFIER_assume(__cs_pc_cs[20] >= __cs_pc[20]);
__VERIFIER_assume(__cs_pc_cs[20] <= 2);
checkThread_8(__cs_threadargs[__cs_thread_index]);
__cs_pc[20] = __cs_pc_cs[20];
}
if (__cs_active_thread[21] == 1)
{
__cs_thread_index = 21;
__cs_pc_cs[21] = __cs_pc[21] + __cs_tmp_t21_r1;
__VERIFIER_assume(__cs_pc_cs[21] >= __cs_pc[21]);
__VERIFIER_assume(__cs_pc_cs[21] <= 2);
checkThread_9(__cs_threadargs[__cs_thread_index]);
__cs_pc[21] = __cs_pc_cs[21];
}
if (__cs_active_thread[22] == 1)
{
__cs_thread_index = 22;
__cs_pc_cs[22] = __cs_pc[22] + __cs_tmp_t22_r1;
__VERIFIER_assume(__cs_pc_cs[22] >= __cs_pc[22]);
__VERIFIER_assume(__cs_pc_cs[22] <= 2);
checkThread_10(__cs_threadargs[__cs_thread_index]);
__cs_pc[22] = __cs_pc_cs[22];
}
if (__cs_active_thread[0] == 1)
{
__cs_thread_index = 0;
__cs_pc_cs[0] = __cs_pc[0] + __cs_tmp_t0_r2;
__VERIFIER_assume(__cs_pc_cs[0] >= __cs_pc[0]);
__VERIFIER_assume(__cs_pc_cs[0] <= 91);
main_thread();
}
return 0;
}
|
the_stack_data/938857.c
|
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
int *x = malloc(sizeof(int));
printf("x = %p\n", x);
free(x);
return 0;
}
|
the_stack_data/104827004.c
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <math.h>
//-lm pour compiler
#define Lambda 9
#define Mu 10
#define EPSILON 1e-5
#define MAXEVENT 1000000 //taille max de l'echeancier
#define MAXTEMPS 1000 //cond d'arret
double temps = 0;
long int n = 0; //nb de clients dans la file a l'instant temps
int compteur = 0; //cond d'arret 2
double cumule = 0;
typedef struct Event {
int type; //0 pour arrive 1 pour sortie
double date;
int etat; //0 pour non traité 1 pour non traité
}event;
typedef struct Echeancier {
event Tab[MAXEVENT];
int taille;
}echeancier;
echeancier Ech;
double Exponnentielle(int lbda) {
double r = (double)random()/RAND_MAX; //entre 0 et 1
while(r==0 || r==1) { //tant que x vaut 0 ou 1 on refait un random
r = (double)random()/RAND_MAX;
}
return -log(r)/(lbda*1.0); // - log(u)/lamda, avec U = unif(0,1)
}
void Ajouter_Ech(event e) {
if(Ech.taille < MAXEVENT) {
Ech.Tab[Ech.taille] = e;
Ech.taille++;
printf("Taille = %d\n", Ech.taille);
}
else (printf("echeancier PLEIN"));
}
void Init_Ech(){
event e;
e.type = 0;
e.date = 0;
e.etat = 0;
Ech.taille = 0;
Ajouter_Ech(e);
}
void Arrive_Event(event e) {
printf("execution Arrivé Client\n");
n++;
event e1;
e1.type = 0;
e1.date = e.date + Exponnentielle(Lambda);
e1.etat = 0;
Ajouter_Ech(e1);
if (n == 1) {
event e2;
e2.type = 1;
e2.date = e.date + Exponnentielle(Mu);
e2.etat = 0;
Ajouter_Ech(e2);
}
temps = e.date;
}
void Service_Event(event e) //service = Mu
{
if (n>0) {
n--;
e.type = 1;
e.date = e.date + Exponnentielle(Mu);
e.etat = 0;
Ajouter_Ech(e);
}
temps = e.date;
}
event Extraire() {
int i,imin;
event min;
for (i = 0; i < Ech.taille; i++) {
if(Ech.Tab[i].etat == 0) {
min = Ech.Tab[i];
imin = i;
break;
}
}
for (i = 0; i < Ech.taille; i++) {
if(min.date > Ech.Tab[i].date && Ech.Tab[i].etat == 0) {
min = Ech.Tab[i];
imin = i;
}
}
Ech.Tab[imin].etat = 1;
return min;
}
void affiche_echeancier() {
event e;
printf (" temps %f et N = %ld taille : %d ", temps,n,Ech.taille);
for (int i = 0; i < Ech.taille; i++)
{
e = Ech.Tab[i];
if (e.type == 0) { printf (" arrive client %lf %d",e.date,e.etat);
}
if (e.type == 1) { printf ("FS %lf %d",e.date,e.etat);
}
}
printf("\n \n");
}
int Condition_arret (long double Old, long double New) {
if (fabs(Old-New) < EPSILON && temps > 1000)
{
compteur++;
if (compteur > 1e3) {return 1;}
}
return 0;
}
void Simulateur(FILE *f1) {
long double OldNmoyen;
long double Nmoyen;
Init_Ech();
event e;
//while (Condition_arret(OldNmoyen,Nmoyen) == 0) //temps < temps MAX // arret > 0
while (temps < MAXTEMPS)
{
e = Extraire();
cumule += (e.date-temps)*n;
OldNmoyen = Nmoyen;
Nmoyen = cumule/temps;
if(temps == 0) {
printf ("temps = 0 et N = 0 et Nmoyen = 0 \n");
fprintf(f1,"0 0 \n");
}
else {
printf("temps = %f et N = %ld et Nmoyen = %Lf\n",temps,n,Nmoyen);
fprintf(f1,"%f %Lf \n",temps,Nmoyen);
}
if (e.type == 0) { Arrive_Event(e); }
if (e.type == 1) { Service_Event(e); }
}
}
int main () {
FILE *f1 = fopen("Simulation_MM1.data","w");
srandom(getpid() + time(NULL));
Simulateur (f1);
fclose(f1);
exit(0);
}
|
the_stack_data/45485.c
|
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
#ifdef __hppa__
#define REGISTER "1"
#else
#ifdef __moxie__
#define REGISTER "2"
#else
#define REGISTER "0"
#endif
#endif
void baz(void)
{
register int xyzzy asm(REGISTER) = 1;
asm volatile ("" : : "r"(xyzzy));
}
/* { dg-final { scan-tree-dump-times "asm\[^\\r\\n\]*xyzzy" 1 "optimized" } } */
|
the_stack_data/509800.c
|
#include <stdio.h>
unsigned int setbits(unsigned int x, int p, int n, unsigned int y);
int main()
{
unsigned int i, j, k;
int p, n;
for (i = 0; i < 30000; i += 511)
{
for (j = 0; j < 1000; j += 37)
{
for (p = 0; p < 16; p++)
{
for (n = 1; n <= p + 1; n++)
{
k = setbits(i, p, n, j);
printf("setbits(%u, %d, %d, %u) = %u\n",
i, p, n, j, k);
}
}
}
}
return 0;
}
unsigned int setbits(unsigned int x, int p, int n, unsigned int y)
{
return (x & ((~0 << (p + 1)) | (~(~0 << (p + 1 - n)))))
| ((y & ~(~0 << n)) << (p + 1 - n));
}
|
the_stack_data/122015917.c
|
// Resultの見直しと、interpret_command とコマンド結果の描画の切り分けをしたバージョン
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h> // for error catch
// Structure for canvas
typedef struct {
int width;
int height;
char **canvas;
char pen;
} Canvas;
//Structure for command (each command will get saved)
typedef struct command Command;
struct command {
char *str;
size_t bufsize;
Command *next;
};
// Structure for history (2-D array)
typedef struct {
Command *begin;
size_t bufsize;
} History;
// functions for Canvas type
Canvas *init_canvas(int width, int height, char pen);
void reset_canvas(Canvas *c);
void print_canvas(Canvas *c);
void free_canvas(Canvas *c);
// display functions
void rewind_screen(unsigned int line);
void clear_command(void);
void clear_screen(void);
// enum for interpret_command results
// interpret_command の結果をより詳細に分割
typedef enum res{ EXIT, LINE, UNDO, SAVE, UNKNOWN, ERRNONINT, ERRLACKARGS, NOCOMMAND} Result;
// Result 型に応じて出力するメッセージを返す
char *strresult(Result res);
int max(const int a, const int b);
void draw_line(Canvas *c, const int x0, const int y0, const int x1, const int y1);
Result interpret_command(const char *command, History *his, Canvas *c);
void save_history(const char *filename, History *his);
Command *push_command(History *his, const char *str);
int main(int argc, char **argv)
{
//for history recording
const int bufsize = 1000;
//initialize first history with an empty NULL
History his = (History){.begin = NULL, .bufsize = bufsize};
int width;
int height;
if (argc != 3){
fprintf(stderr,"usage: %s <width> <height>\n",argv[0]);
return EXIT_FAILURE;
}
else{
char *e;
long w = strtol(argv[1],&e,10);
if (*e != '\0'){
fprintf(stderr, "%s: irregular character found %s\n", argv[1],e);
return EXIT_FAILURE;
}
long h = strtol(argv[2],&e,10);
if (*e != '\0'){
fprintf(stderr, "%s: irregular character found %s\n", argv[2],e);
return EXIT_FAILURE;
}
width = (int)w;
height = (int)h;
}
char pen = '*';
char buf[his.bufsize];
Canvas *c = init_canvas(width,height, pen);
printf("\n"); // required especially for windows env
while (1) {
print_canvas(c);
printf("* > ");
if(fgets(buf, bufsize, stdin) == NULL) break;
const Result r = interpret_command(buf, &his,c);
if (r == EXIT) break;
// 返ってきた結果に応じてコマンド結果を表示
clear_command();
printf("%s\n",strresult(r));
// LINEの場合はHistory構造体に入れる
if (r == LINE) {
push_command(&his,buf);
}
rewind_screen(2); // command results
clear_command(); // command itself
rewind_screen(height+2); // rewind the screen to command input
}
clear_screen();
free_canvas(c);
return 0;
}
Canvas *init_canvas(int width,int height, char pen){
Canvas *new = (Canvas *)malloc(sizeof(Canvas));
new->width = width;
new->height = height;
new->canvas = (char **)malloc(width * sizeof(char *));
char *tmp = (char *)malloc(width*height*sizeof(char));
memset(tmp, ' ', width*height*sizeof(char));
for (int i = 0 ; i < width ; i++){
new->canvas[i] = tmp + i * height;
}
new->pen = pen;
return new;
}
void reset_canvas(Canvas *c){
const int width = c->width;
const int height = c->height;
memset(c->canvas[0], ' ', width*height*sizeof(char));
}
void print_canvas(Canvas *c){
const int height = c->height;
const int width = c->width;
char **canvas = c->canvas;
// 上の壁
printf("+");
for (int x = 0 ; x < width ; x++)
printf("-");
printf("+\n");
// 外壁と内側
for (int y = 0 ; y < height ; y++) {
printf("|");
for (int x = 0 ; x < width; x++){
const char c = canvas[x][y];
putchar(c);
}
printf("|\n");
}
// 下の壁
printf("+");
for (int x = 0 ; x < width ; x++)
printf("-");
printf("+\n");
fflush(stdout);
}
void free_canvas(Canvas *c){
free(c->canvas[0]); // for 2-D array free
free(c->canvas);
free(c);
}
void rewind_screen(unsigned int line){
printf("\e[%dA",line);
}
void clear_command(void){
printf("\e[2K");
}
void clear_screen(void){
printf("\e[2J");
}
int max(const int a, const int b){
return (a > b) ? a : b;
}
void draw_line(Canvas *c, const int x0, const int y0, const int x1, const int y1){
const int width = c->width;
const int height = c->height;
char pen = c->pen;
const int n = max(abs(x1 - x0), abs(y1 - y0));
if ( (x0 >= 0) && (x0 < width) && (y0 >= 0) && (y0 < height))
c->canvas[x0][y0] = pen;
for (int i = 1; i <= n; i++) {
const int x = x0 + i * (x1 - x0) / n;
const int y = y0 + i * (y1 - y0) / n;
if ( (x >= 0) && (x< width) && (y >= 0) && (y < height))
c->canvas[x][y] = pen;
}
}
void save_history(const char *filename, History *his){
const char *default_history_file = "history.txt";
if (filename == NULL)
filename = default_history_file;
FILE *fp;
if ((fp = fopen(filename, "w")) == NULL) {
fprintf(stderr, "error: cannot open %s.\n", filename);
return;
}
for (Command *p = his -> begin; p!=NULL; p = p->next) {
fprintf(fp, "%s", p->str);
}
fclose(fp);
}
Result interpret_command(const char *command, History *his, Canvas *c){
char buf[his->bufsize];
strcpy(buf, command);
buf[strlen(buf) - 1] = 0; // remove the newline character at the end
const char *s = strtok(buf, " ");
if (s == NULL) { // 改行だけ入力された場合
return UNKNOWN;
}
// The first token corresponds to command
if (strcmp(s, "line") == 0) {
int p[4] = {0}; // p[0]: x0, p[1]: y0, p[2]: x1, p[3]: x1
char *b[4];
for (int i = 0 ; i < 4; i++){
b[i] = strtok(NULL, " ");
if (b[i] == NULL){
return ERRLACKARGS;
}
}
for (int i = 0 ; i < 4 ; i++){
char *e;
long v = strtol(b[i],&e, 10);
if (*e != '\0'){
return ERRNONINT;
}
p[i] = (int)v;
}
draw_line(c,p[0],p[1],p[2],p[3]);
return LINE;
}
if (strcmp(s, "save") == 0) {
s = strtok(NULL, " ");
save_history(s, his);
return SAVE;
}
if (strcmp(s, "undo") == 0) {
reset_canvas(c);
Command *p = his -> begin;
if (p == NULL){
return NOCOMMAND;
}
else {
Command *q = NULL;
while (p->next != NULL) {
interpret_command(p->str, his, c);
q = p;
p = p -> next;
}
if (q == NULL) {
his ->begin = NULL;
}
else {
q -> next = NULL;
}
free(p->str);
free(p);
return UNDO;
}
}
if (strcmp(s, "quit") == 0) {
return EXIT;
}
return UNKNOWN;
}
Command *push_command(History *his, const char *str) {
Command *c = (Command*)malloc(sizeof(Command));
char *s = (char*)malloc(his -> bufsize);
strcpy(s, str);
*c = (Command){.str = s, .bufsize = his->bufsize, .next = NULL};
Command *p = his -> begin;
if (p == NULL) {
his -> begin = c;
}
else {
while (p -> next != NULL){
p = p->next;
}
p -> next = c;
}
return c;
}
char *strresult(Result res){
switch(res) {
case EXIT:
break;
case SAVE:
return "history saved";
case LINE:
return "1 line drawn";
case UNDO:
return "undo!";
case UNKNOWN:
return "error: unknown command";
case ERRNONINT:
return "Non-int value is included";
case ERRLACKARGS:
return "Too few arguments";
case NOCOMMAND:
return "No command in history";
}
return NULL;
}
|
the_stack_data/145453643.c
|
#include<stdlib.h>
#include<stdint.h>
#include<stdio.h>
void raddoppia(uint32_t* x, size_t n) {
if (x == NULL)
return 0;
for (size_t i = 0; i < n; i++) {
x[i] = x[i] * 2;
}
}
int main(void) {
size_t n = 3;
uint32_t* v = malloc(n * sizeof(uint32_t));
if (v == NULL)
return 0;
v[0] = 12;
v[1] = 59;
v[2] = 83;
raddoppia(v, n);
printf("STAMPO VETTORE\n");
for (size_t i = 0; i < n; i++) {
printf("%d elemento ---> ", i+1);
printf("%d\n", v[i]);
}
free(v);
return 0;
}
|
the_stack_data/242329576.c
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
* Copyright (C) 2013-2014 Kevin Lange
*
* serial console
*
* Runs a dumb console on a serial port or something similar.
*
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
#include <syscall.h>
#include <signal.h>
#include <termios.h>
#include <fcntl.h>
#include <sys/wait.h>
int fd = 0;
int keep_echo = 0;
int dos_lines = 0;
int keep_canon = 0;
struct termios old;
void set_unbuffered() {
tcgetattr(fileno(stdin), &old);
struct termios new = old;
if (!keep_canon) {
new.c_lflag &= (~ICANON);
}
if (!keep_echo) {
new.c_lflag &= (~ECHO);
}
tcsetattr(fileno(stdin), TCSAFLUSH, &new);
}
void set_buffered() {
tcsetattr(fileno(stdin), TCSAFLUSH, &old);
}
int show_usage(int argc, char * argv[]) {
printf(
"Serial client.\n"
"\n"
"usage: %s [-e] [-r] [-c] [device path]\n"
"\n"
" -e \033[3mkeep echo enabled\033[0m\n"
" -c \033[3mkeep canon enabled\033[0m\n"
" -r \033[3mtransform line feeds to \\r\\n\033[0m\n"
" -? \033[3mshow this help text\033[0m\n"
"\n", argv[0]);
return 1;
}
int main(int argc, char ** argv) {
int arg = 1;
char * device;
while (arg < argc) {
if (argv[arg][0] != '-') break;
if (!strcmp(argv[arg], "-e")) {
keep_echo = 1;
} else if (!strcmp(argv[arg], "-r")) {
dos_lines = 1;
} else if (!strcmp(argv[arg], "-c")) {
keep_canon = 1;
} else if (!strcmp(argv[arg], "-?")) {
return show_usage(argc, argv);
} else {
fprintf(stderr, "%s: Unrecognized option: %s\n", argv[0], argv[arg]);
}
arg++;
}
if (arg == argc) {
device = "/dev/ttyS0";
} else {
device = argv[arg];
}
set_unbuffered();
fd = open(device, 0, 0);
int fds[2] = {STDIN_FILENO, fd};
while (1) {
int index = syscall_fswait(2, fds);
if (index == -1) {
fprintf(stderr, "serial-console: fswait: erroneous file descriptor\n");
fprintf(stderr, "serial-console: (did you try to open a file that isn't a serial console?\n");
return 1;
}
if (index == 0) {
char c = fgetc(stdin);
if (c == 0x1D) { /* ^] */
while (1) {
printf("serial-console> ");
set_buffered();
fflush(stdout);
char line[1024];
fgets(line, 1024, stdin);
if (feof(stdin)) {
return 0;
}
int i = strlen(line);
line[i-1] = '\0';
if (!strcmp(line, "quit")) {
return 0;
} else if (!strcmp(line, "continue")) {
set_unbuffered();
fflush(stdout);
break;
}
}
} else {
if (dos_lines && c == '\n') {
char buf[1] = {'\r'};
write(fd, buf, 1);
}
char buf[1] = {c};
write(fd, buf, 1);
}
} else {
char buf[1024];
size_t r = read(fd, buf, 1024);
fwrite(buf, 1, r, stdout);
fflush(stdout);
}
}
close(fd);
set_buffered();
return 0;
}
|
the_stack_data/81915.c
|
/* Tourist Guide */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
typedef char bool;
#define TRUE 1
#define FALSE 0
#define MAXNAME 32
#define MAXCITIES 100
#define MAXV MAXCITIES
#define MAXDEGREE MAXV
typedef struct {
int edges[MAXV][MAXDEGREE];
int degree[MAXV];
int vertices[MAXV];
int part[MAXV];
int nvertices;
} graph;
char city_names[MAXCITIES][MAXNAME];
bool cameras[MAXV];
int total;
int compare(const void *x, const void *y) {
return (strcmp((char *)x, (char *)y));
}
int binary_search(char key[], int first, int last) {
int pos, cmp;
if (first > last)
return (-1);
pos = (first + last) / 2;
cmp = strcmp(city_names[pos], key);
if (!cmp)
return (pos);
else if (cmp > 0)
return (binary_search(key, first, pos-1));
else
return (binary_search(key, pos+1, last));
}
void construct_graph(graph *g) {
int i;
int r;
int pos1, pos2;
char city1[MAXNAME], city2[MAXNAME];
for (i = 0; i < g->nvertices; i++)
g -> degree[i] = 0;
scanf("%d", &r);
getchar();
for (i = 0; i < r; i++) {
scanf("%s %s", city1, city2);
pos1 = binary_search(city1, 0, g->nvertices-1);
pos2 = binary_search(city2, 0, g->nvertices-1);
g -> edges[pos1][g->degree[pos1]] = pos2;
g -> degree[pos1]++;
g -> edges[pos2][g->degree[pos2]] = pos1;
g -> degree[pos2]++;
}
}
void compute_trivial(graph *g) {
int i;
for (i = 0; i < g->nvertices; i++)
if ((g->degree[i] == 1) && (g -> degree[g->edges[i][0]] > 1) && (cameras[g->edges[i][0]] == FALSE)) {
total++;
cameras[g->edges[i][0]] = TRUE;
}
}
void dfs_comp(graph *g, int v, int *pieces, bool discovered[], int comp[]) {
int i;
int y;
discovered[v] = TRUE;
comp[*pieces] = v;
(*pieces)++;
for (i = 0; i < g->degree[v]; i++) {
y = g->edges[v][i];
if (discovered[y] == FALSE)
dfs_comp(g, y, pieces, discovered, comp);
}
}
void connected_components(graph *g) {
int pieces;
int i, j, aux;
bool discovered[MAXV];
int comp[MAXV];
for (i = 0; i < g->nvertices; i++)
discovered[i] = FALSE;
for (i = 0; i < g->nvertices; i++)
if (discovered[i] == FALSE) {
pieces = 0;
dfs_comp(g, i, &pieces, discovered, comp);
for (j = 0; j < pieces; j++) {
g -> vertices[comp[j]] = pieces;
g -> part[comp[j]] = comp[(j+1)%pieces];
}
}
}
void dfs(graph *g, int exclude, int v, bool discovered[], int *connected) {
int i;
int y;
discovered[v] = TRUE;
(*connected)++;
for (i = 0; i < g->degree[v]; i++) {
y = g->edges[v][i];
if ((y != exclude) && (discovered[y] == FALSE))
dfs(g, exclude, y, discovered, connected);
}
}
int main() {
int n;
int i, j, scenario;
int connected;
graph g;
bool discovered[MAXV];
scenario = 1;
while (scanf("%d", &n)) {
getchar();
if (n == 0)
break;
if (scenario > 1)
putchar('\n');
g.nvertices = n;
for (i = 0; i < n; i++)
scanf("%s", city_names[i]);
qsort(city_names, n, sizeof(char)*MAXNAME, compare);
construct_graph(&g);
for (i = 0; i < g.nvertices; i++)
cameras[i] = FALSE;
total = 0;
compute_trivial(&g);
connected_components(&g);
for (i = 0; i < g.nvertices; i++)
if ((cameras[i] == FALSE) && (g.degree[i] > 1)) {
for (j = 0; j < g.nvertices; j++)
discovered[j] = FALSE;
connected = 0;
dfs(&g, i, g.part[i], discovered, &connected);
if (connected < g.vertices[i]-1) {
cameras[i] = TRUE;
total++;
}
}
printf("City map #%d: %d camera(s) found\n", scenario, total);
for (i = 0; i < g.nvertices; i++)
if (cameras[i] == TRUE)
printf("%s\n", city_names[i]);
scenario++;
}
return 0;
}
|
the_stack_data/232956308.c
|
/* hw9_23 */
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[]="Hello, C language";
printf("str[]=%s\n",str);
printf("sizeof(str[])=%d\n",sizeof(str));
system("pause");
return 0;
}
/*
str[]=Hello, C language
sizeof(str[])=18
Press any key to continue . . .
*/
|
the_stack_data/148578031.c
|
#include<stdio.h>
#define __(a) goto a;
#define ___(a) putchar(a);
#define _(a,b) ___(a) __(b);
main()
{ _:__(t)a:_('r',g)b:_('$',p)
c:_('l',f)d:_(' ',s)e:_('a',s)
f:_('o',q)g:_('l',h)h:_('d',n)
i:_('e',w)j:_('e',x)k:_('\n',z)
l:_('H',l)m:_('X',i)n:_('!',k)
o:_('z',q)p:_('q',b)q:_(',',d)
r:_('i',l)s:_('w',v)t:_('H',j)
u:_('a',a)v:_('o',a)w:_(')',k)
x:_('l',c)y:_('\t',g)z:___(0x0)}
|
the_stack_data/328838.c
|
/*
* Simple program feeding raw data into device
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
int i, j;
unsigned char rgb[3];// = {10, 60, 128};
// b g r
//unsigned char rgb[3] = {0, 0, 0};
while (1) {
FILE *file = fopen("sample_image/1.raw", "r");
for (i = 0; i < 176; i++) {
for (j = 0; j < 144; j++) {
memset(rgb, 0, sizeof(rgb));
fscanf(file,"%hhu %hhu %hhu", &rgb[0], &rgb[1], &rgb[2]);
fwrite(rgb, sizeof(rgb), 1, stdout);
}
}
//while (fscanf(file,"%hhu %hhu %hhu", rgb, rgb+1, rgb+2) > 0) {
//printf("%hhu%hhu%hhu\n", rgb[0],rgb[1],rgb[2]);
//fwrite(rgb, sizeof(rgb), 1, stdout);
//}
fclose(file);
}
return 0;
}
|
the_stack_data/488771.c
|
//Classification: #default/n/ML/UUM/dS/A(v,c)/lc/cd
//Written by: Igor Eremeev
//Reviewed by: Sergey Pomelov
//Comment: the simplest case of unused memory
#include <stdlib.h>
#include <stdio.h>
int main(void)
{
int *p, a;
scanf ("%d", &a);
p = (int *)malloc(sizeof(int));
if (p==0) {
return 1;
}
if (a*a+1 < 0) {
(*p) = 12;
printf ("%d", *p);
}
free(p);
return 0;
}
|
the_stack_data/190768332.c
|
// RUN: %clang %s -emit-llvm %O0opt -c -o %t1.bc
// RUN: rm -rf %t.klee-out
// RUN: %klee --output-dir=%t.klee-out --libc=klee --exit-on-error %t1.bc
#include <arpa/inet.h>
#include <assert.h>
int main() {
uint32_t n = 0;
klee_make_symbolic(&n, sizeof(n), "n");
uint32_t h = ntohl(n);
assert(htonl(h) == n);
return 0;
}
|
the_stack_data/628065.c
|
/*
* Copyright (c) 2017, 2018, Oracle and/or its affiliates.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used to
* endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
int main() {
if (!0) {
return 3;
} else {
return 2;
}
}
|
the_stack_data/92324484.c
|
#include <stdio.h>
#include <stdlib.h>
struct node
{
int vertex;
struct node* next;
};
struct node* createNode(int v);
struct Graph
{
int numVertices;
int* visited;
struct node** adjLists; // we need int** to store a two dimensional array. Similary, we need struct node** to store an array of Linked lists
};
struct Graph* createGraph(int);
void addEdge(struct Graph*, int, int);
void printGraph(struct Graph*);
void DFS(struct Graph*, int);
int main()
{
struct Graph* graph = createGraph(4);
addEdge(graph, 0, 1);
addEdge(graph, 0, 2);
addEdge(graph, 1, 2);
addEdge(graph, 2, 3);
printGraph(graph);
DFS(graph, 2);
return 0;
}
void DFS(struct Graph* graph, int vertex) {
struct node* adjList = graph->adjLists[vertex];
struct node* temp = adjList;
graph->visited[vertex] = 1;
printf("Visited %d \n", vertex);
while(temp!=NULL) {
int connectedVertex = temp->vertex;
if(graph->visited[connectedVertex] == 0) {
DFS(graph, connectedVertex);
}
temp = temp->next;
}
}
struct node* createNode(int v)
{
struct node* newNode = malloc(sizeof(struct node));
newNode->vertex = v;
newNode->next = NULL;
return newNode;
}
struct Graph* createGraph(int vertices)
{
struct Graph* graph = malloc(sizeof(struct Graph));
graph->numVertices = vertices;
graph->adjLists = malloc(vertices * sizeof(struct node*));
graph->visited = malloc(vertices * sizeof(int));
int i;
for (i = 0; i < vertices; i++) {
graph->adjLists[i] = NULL;
graph->visited[i] = 0;
}
return graph;
}
void addEdge(struct Graph* graph, int src, int dest)
{
// Add edge from src to dest
struct node* newNode = createNode(dest);
newNode->next = graph->adjLists[src];
graph->adjLists[src] = newNode;
// Add edge from dest to src
newNode = createNode(src);
newNode->next = graph->adjLists[dest];
graph->adjLists[dest] = newNode;
}
void printGraph(struct Graph* graph)
{
int v;
for (v = 0; v < graph->numVertices; v++)
{
struct node* temp = graph->adjLists[v];
printf("\n Adjacency list of vertex %d\n ", v);
while (temp)
{
printf("%d -> ", temp->vertex);
temp = temp->next;
}
printf("\n");
}
}
|
the_stack_data/232957080.c
|
#if 0
#include <stdio.h>
int main()
{
char str[80];
int val=960;
sprintf(str, "/sys/class/gpio/gpio%d/value",val);
printf("\n so %s \n",str);
return 0;
}
#endif
#if 1
#include <stdio.h>
char str[50];
#define CPLD_RESET 960
#define CPLD_CONFIG 961
//#define sysfs(str,export,gpio) sprintf(str, "/sys/class/gpio/gpio%d/%s",gpio,export);
#define sysfs(str,export,gpio) snprintf(str,sizeof(str), "/sys/class/gpio/gpio%d/%s",gpio,export);
int main()
{
sysfs(str,"export",CPLD_RESET);
printf("\n so %s \n",str);
sysfs(str,"export",CPLD_CONFIG);
printf("\n so %s \n",str);
sysfs(str,"direction",CPLD_RESET);
printf("\n so %s \n",str);
sysfs(str,"direction",CPLD_CONFIG);
printf("\n so %s \n",str);
sysfs(str,"value",CPLD_RESET);
printf("\n so %s \n",str);
sysfs(str,"value",CPLD_CONFIG);
printf("\n so %s \n",str);
// printf("\n itoa %s \n",itoa(CPLD_CONFIG));
return 0;
}
#endif
#if 0
#include <stdio.h>
char str[50];
#define STRCAT(a,b) a##b
int val=960;
int main()
{
STRCAT(export,val);
printf("\n so %s \n",str);
}
#endif
|
the_stack_data/100028.c
|
/**
* Author: Jason White
*
* Description:
* Reads joystick/gamepad events and displays them.
*
* Compile:
* gcc joystick.c -o joystick
*
* Run:
* ./joystick [/dev/input/jsX]
*
* See also:
* https://www.kernel.org/doc/Documentation/input/joystick-api.txt
*/
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <linux/joystick.h>
/**
* Reads a joystick event from the joystick device.
*
* Returns 0 on success. Otherwise -1 is returned.
*/
int read_event(int fd, struct js_event *event)
{
ssize_t bytes;
bytes = read(fd, event, sizeof(*event));
if (bytes == sizeof(*event))
return 0;
/* Error, could not read full event. */
return -1;
}
/**
* Returns the number of axes on the controller or 0 if an error occurs.
*/
size_t get_axis_count(int fd)
{
__u8 axes;
if (ioctl(fd, JSIOCGAXES, &axes) == -1)
return 0;
return axes;
}
/**
* Returns the number of buttons on the controller or 0 if an error occurs.
*/
size_t get_button_count(int fd)
{
__u8 buttons;
if (ioctl(fd, JSIOCGBUTTONS, &buttons) == -1)
return 0;
return buttons;
}
/**
* Current state of an axis.
*/
struct axis_state {
short x, y;
};
/**
* Keeps track of the current axis state.
*
* NOTE: This function assumes that axes are numbered starting from 0, and that
* the X axis is an even number, and the Y axis is an odd number. However, this
* is usually a safe assumption.
*
* Returns the axis that the event indicated.
*/
size_t get_axis_state(struct js_event *event, struct axis_state axes[3])
{
size_t axis = event->number / 2;
if (axis < 3)
{
if (event->number % 2 == 0)
axes[axis].x = event->value;
else
axes[axis].y = event->value;
}
return axis;
}
int main(int argc, char *argv[])
{
const char *device;
int js;
struct js_event event;
struct axis_state axes[3] = {0};
size_t axis;
if (argc > 1)
device = argv[1];
else
device = "/dev/input/js0";
js = open(device, O_RDONLY);
if (js == -1)
perror("Could not open joystick");
/* This loop will exit if the controller is unplugged. */
while (read_event(js, &event) == 0)
{
switch (event.type)
{
case JS_EVENT_BUTTON:
printf("Button %u %s\n", event.number, event.value ? "pressed" : "released");
break;
case JS_EVENT_AXIS:
axis = get_axis_state(&event, axes);
if (axis < 3)
printf("Axis %zu at (%6d, %6d)\n", axis, axes[axis].x, axes[axis].y);
break;
default:
/* Ignore init events. */
break;
}
fflush(stdout);
}
close(js);
return 0;
}
|
the_stack_data/82949765.c
|
#include <stdio.h>
int countFloors(int * floors, int maxFloors);
void swap(int * xp, int * yp);
void collapse(int * floors, int maxFloors);
void currentlySelected(int * floors, int topFloor);
int closest(int * up, int onFloor, int * floors, int numOfFloors, int topFloor);
int toggle(int floor, int * floors, int topFloor);
int main() {
int bottemFloor = 1;
int onFloor = bottemFloor;
int topFloor = 80;
int floors[80];
int up = 1;
for(int i = 0; i < topFloor; i++) {
floors[i] = -1;
}
int quit = 0;
while(quit == 0) {
int gotoFloor = 0;
printf("\nYou are on floor %d of %d.\nWhat floors would you like to goto?\n(Enter %d to leave) (Enter -1 to close the doors)\n\0", onFloor, topFloor, onFloor);
currentlySelected(floors, topFloor);
printf("> \0");
if(scanf_s("%d", &gotoFloor) != 1) {
printf("\n\nNon-Ints are not allowed. Get out of my elevator!\n\0");
break;
} else if (gotoFloor == -1) {
// Run Elevator
gotoFloor = closest(&up, onFloor, floors, countFloors(floors, topFloor), topFloor);
if(gotoFloor != -1) {
int add = 1;
if(up == 0) {
add = -1;
}
printf("\n\0");
while(onFloor != gotoFloor) {
onFloor += add;
printf("Now on floor %d.\n\0", onFloor);
}
printf("\nYou have arived at floor %d!\n\0", onFloor);
toggle(onFloor, floors, topFloor);
} else {
printf("\n\nNo floors have been selected!\n\0");
}
} else if(gotoFloor < bottemFloor || gotoFloor > topFloor) {
// Out Of Bounds
printf("\n\nThere is no floor %d in this building!\n\0", gotoFloor);
} else if (gotoFloor == onFloor) {
// Exit Conditions
printf("\n\nYou have gotten off The elevator at floor %d\n\0", onFloor);
quit = 1;
break;
} else {
// Add Number To List
printf("\n\nYou have pressed floor %d.\n\0", gotoFloor);
toggle(gotoFloor, floors, topFloor);
}
}
return 0;
}
int countFloors(int * floors, int maxFloors) {
collapse(floors, maxFloors);
int count = 0;
for (int i = 0; i < maxFloors; i++) {
if(floors[i] != -1) {
count++;
} else {
break;
}
}
return count;
}
void swap(int * xp, int * yp) {
int temp = *xp;
*xp = *yp;
*yp = temp;
}
void collapse(int * floors, int maxFloors) {
for(int i = 0; i < maxFloors-1; i++) {
for(int j = 0; j < maxFloors-i-1; j++) {
if(floors[j] == -1) {
swap(&floors[j], &floors[j+1]);
}
}
}
}
void currentlySelected(int * floors, int topFloor) {
printf("Floors Selected: \0");
for (int i = 0; i < topFloor; i++) {
if(floors[i] != -1) {
printf("%d, \0", floors[i]);
}
}
printf("\n\0");
}
int closest(int * up, int onFloor, int * floors, int numOfFloors, int topFloor) {
if ((*up) == 1) {
int c = topFloor + 1;
for(int i = 0; i < numOfFloors; i++) {
if(floors[i] > onFloor && floors[i] < c) {
c = floors[i];
}
}
if(c == topFloor+1) {
(*up) = 0;
c = -1;
for(int i = 0; i < numOfFloors; i++) {
if(floors[i] < onFloor && floors[i] > c) {
c = floors[i];
}
}
if(c == -1) {
return -1;
} else {
return c;
}
} else {
return c;
}
}
if ((*up) == 0) {
int c = -1;
for(int i = 0; i < numOfFloors; i++) {
if(floors[i] < onFloor && floors[i] > c) {
c = floors[i];
}
}
if(c == -1) {
(*up) = 1;
return closest(up, onFloor, floors, numOfFloors, topFloor);
} else {
return c;
}
}
return -1;
}
int toggle(int floor, int * floors, int topFloor) {
int found = 0;
for (int i = 0; i < topFloor; i++) {
if(floors[i] == floor) {
floors[i] = -1;
found = 1;
collapse(floors, topFloor);
break;
}
}
if(found == 0) {
int y = countFloors(floors, topFloor);
floors[y] = floor;
}
return found;
}
|
the_stack_data/32950059.c
|
#include <stdio.h>
#include <stdlib.h>
struct contacto{
char *Nombre;
char *Telefono;
struct contacto *sig;
struct contacto *ant;
};
void Agregar_Cont(struct contacto *Agenda, char *Nombre, char *Telefono){
struct contacto *NuevoContacto = (struct contacto*) malloc (sizeof (struct contacto));
NuevoContacto->Nombre = Nombre;
NuevoContacto->Telefono = Telefono;
NuevoContacto->sig = NULL;
NuevoContacto->ant = NULL;
struct contacto *AUX1 = Agenda;
struct contacto *AUX2 = NULL;
if (AUX1 == NULL){
Agenda = NuevoContacto;
}
else{
while (AUX1 != NULL){
AUX2 = AUX1;
AUX1 = AUX1->sig;
}
AUX2->sig = NuevoContacto;
NuevoContacto->ant = AUX2;
}
}
struct contacto* Mostar_Ascendente(struct contacto *Agenda){
struct contacto *Aux = Agenda;
while (Aux != NULL){
printf ("%s \n", Aux->Nombre);
printf ("%s \n", Aux->Telefono);
Aux = Aux->sig;
}
return Aux;
}
struct contacto* Mostar_Descendente(struct contacto *Agenda){
struct contacto *Aux1 = Agenda;
struct contacto *Aux2 = NULL;
while (Aux1 != NULL){
Aux2 = Aux1;
Aux1 = Aux1->sig;
}
while (Aux2 != NULL){
printf ("%s \n", Aux2->Nombre);
printf ("%s \n", Aux2->Telefono);
Aux2 = Aux2->ant;
}
return Aux2;
}
void Eliminar_contacto(struct contacto *Agenda, char *NuevoNombre, char *NuevoTelefono){
if (Agenda != NULL){
struct contacto *Aux_borrar = Agenda;
struct contacto *Aux2 = NULL;
while ((Aux_borrar != NULL) && (Aux_borrar->Nombre != NuevoNombre) && (Aux_borrar->Telefono != NuevoTelefono));
Aux2 = Aux_borrar;
Aux_borrar = Aux_borrar->sig;
if (Aux_borrar == NULL){
printf ("No existe el elemento a borrar \n");
}
else if (Aux2 == NULL){
Agenda = Agenda->sig;
free(Aux_borrar);
printf("Elemento borrado \n");
}
else {
Aux2->sig = Aux_borrar->sig;
free(Aux_borrar);
printf("Elemento borrado \n");
}
}
else {
printf ("La Agenda esta vacia \n");
}
}
int main(){
int opc;
struct contacto *Agenda = NULL;
char Nombre[20];
char Telefono[20];
do{
printf("Menu de agenda\n");
printf("Que desea hacer?\n");
printf("1 Mostrar Contactos\n");
printf("2 Agregar Contacto\n");
printf("3 Eliminar Contacto\n");
printf("4 Buscar Contacto\n");
printf("0 Salir del menu\n");
scanf("%i",&opc);
switch(opc){
case 1:
printf("Se entro correctamente a la primera opcion\n");
Mostar_Ascendente(Agenda);
Mostar_Descendente(Agenda);
break;
case 2:
printf("Se entro correctamente a la segunda opcion\n");
fflush(stdin);
printf(" Introdusca un nombre : \n");
gets(Nombre);
fflush(stdin);
printf(" Introdusca un telefono : \n");
gets(Telefono);
fflush(stdin);
Agregar_Cont(Agenda,Nombre,Telefono);
break;
case 3:
printf("Se entro correctamente a la tercera opcion\n");
printf("Se entro correctamente a la primera opcion\n");
printf(" Introdusca un nombre : \n");
gets(Nombre);
printf(" Introdusca un telefono : \n");
gets(Telefono);
Eliminar_contacto(Agenda,Nombre,Telefono);
break;
case 4:
printf("Se entro correctamente a la cuarta opcion\n");
break;
case 0:
printf("Se salio correctamente de la agenda, gracias por visitarnos\n");
break;
default:
printf("Opcion incorrecta, intentelo de nuevo\n");
break;
}
}while(opc != 0);
return 0;
}
|
the_stack_data/757896.c
|
// Utility macro functions
#define decibelCoeficient(g) ((g) > -90.0f ? powf(10.0f, (g) * 0.05f) : 0.0f)
#define clamp(value,min,max) value < min ? min : (value > max ? max : value)
#define allocate(type,count) (type*)calloc(count, sizeof(type))
#define new(type) allocate(type, 1)
#define sign(value) value < 0 ? -1 : (value > 0 ? 1 : 0)
#define max(a,b) a > b ? a : b
#define min(a,b) a < b ? a : b
|
the_stack_data/1088786.c
|
#ifdef HAVE_ETH2
#include <string.h>
#include "eth_plugin_internal.h"
#include "eth_plugin_handler.h"
#include "shared_context.h"
#include "ethUtils.h"
#include "utils.h"
void getEth2PublicKey(uint32_t *bip32Path, uint8_t bip32PathLength, uint8_t *out);
#define WITHDRAWAL_KEY_PATH_1 12381
#define WITHDRAWAL_KEY_PATH_2 3600
#define WITHDRAWAL_KEY_PATH_4 0
#define ETH2_DEPOSIT_PUBKEY_OFFSET 0x80
#define ETH2_WITHDRAWAL_CREDENTIALS_OFFSET 0xE0
#define ETH2_SIGNATURE_OFFSET 0x120
#define ETH2_DEPOSIT_PUBKEY_LENGTH 0x30
#define ETH2_WITHDRAWAL_CREDENTIALS_LENGTH 0x20
#define ETH2_SIGNATURE_LENGTH 0x60
typedef struct eth2_deposit_parameters_t {
uint8_t valid;
} eth2_deposit_parameters_t;
void eth2_plugin_call(int message, void *parameters) {
switch (message) {
case ETH_PLUGIN_INIT_CONTRACT: {
ethPluginInitContract_t *msg = (ethPluginInitContract_t *) parameters;
eth2_deposit_parameters_t *context = (eth2_deposit_parameters_t *) msg->pluginContext;
context->valid = 1;
msg->result = ETH_PLUGIN_RESULT_OK;
} break;
case ETH_PLUGIN_PROVIDE_PARAMETER: {
ethPluginProvideParameter_t *msg = (ethPluginProvideParameter_t *) parameters;
eth2_deposit_parameters_t *context = (eth2_deposit_parameters_t *) msg->pluginContext;
uint32_t index;
PRINTF("eth2 plugin provide parameter %d %.*H\n",
msg->parameterOffset,
32,
msg->parameter);
switch (msg->parameterOffset) {
case 4 + (32 * 0): // pubkey offset
case 4 + (32 * 1): // withdrawal credentials offset
case 4 + (32 * 2): // signature offset
case 4 + (32 * 4): // deposit pubkey length
case 4 + (32 * 7): // withdrawal credentials length
case 4 + (32 * 9): // signature length
{
uint32_t check = 0;
switch (msg->parameterOffset) {
case 4 + (32 * 0):
check = ETH2_DEPOSIT_PUBKEY_OFFSET;
break;
case 4 + (32 * 1):
check = ETH2_WITHDRAWAL_CREDENTIALS_OFFSET;
break;
case 4 + (32 * 2):
check = ETH2_SIGNATURE_OFFSET;
break;
case 4 + (32 * 4):
check = ETH2_DEPOSIT_PUBKEY_LENGTH;
break;
case 4 + (32 * 7):
check = ETH2_WITHDRAWAL_CREDENTIALS_LENGTH;
break;
case 4 + (32 * 9):
check = ETH2_SIGNATURE_LENGTH;
break;
default:
break;
}
index = U4BE(msg->parameter, 32 - 4);
if (index != check) {
PRINTF("eth2 plugin parameter check %d failed, expected %d got %d\n",
msg->parameterOffset,
check,
index);
context->valid = 0;
}
msg->result = ETH_PLUGIN_RESULT_OK;
} break;
case 4 + (32 * 3): // deposit data root
case 4 + (32 * 5): // deposit pubkey
case 4 + (32 * 6):
case 4 + (32 * 10): // signature
case 4 + (32 * 11):
case 4 + (32 * 12):
msg->result = ETH_PLUGIN_RESULT_OK;
break;
case 4 + (32 * 8): // withdrawal credentials
{
uint8_t tmp[48];
uint32_t withdrawalKeyPath[4];
withdrawalKeyPath[0] = WITHDRAWAL_KEY_PATH_1;
withdrawalKeyPath[1] = WITHDRAWAL_KEY_PATH_2;
withdrawalKeyPath[2] = eth2WithdrawalIndex;
withdrawalKeyPath[3] = WITHDRAWAL_KEY_PATH_4;
getEth2PublicKey(withdrawalKeyPath, 4, tmp);
PRINTF("eth2 plugin computed withdrawal public key %.*H\n", 48, tmp);
cx_hash_sha256(tmp, 48, tmp, 32);
tmp[0] = 0;
if (memcmp(tmp, msg->parameter, 32) != 0) {
PRINTF("eth2 plugin invalid withdrawal credentials\n");
PRINTF("Got %.*H\n", 32, msg->parameter);
PRINTF("Expected %.*H\n", 32, tmp);
context->valid = 0;
}
msg->result = ETH_PLUGIN_RESULT_OK;
} break;
default:
PRINTF("Unhandled parameter offset\n");
break;
}
} break;
case ETH_PLUGIN_FINALIZE: {
ethPluginFinalize_t *msg = (ethPluginFinalize_t *) parameters;
eth2_deposit_parameters_t *context = (eth2_deposit_parameters_t *) msg->pluginContext;
PRINTF("eth2 plugin finalize\n");
if (context->valid) {
msg->numScreens = 1;
msg->uiType = ETH_UI_TYPE_GENERIC;
msg->result = ETH_PLUGIN_RESULT_OK;
} else {
msg->result = ETH_PLUGIN_RESULT_FALLBACK;
}
} break;
case ETH_PLUGIN_QUERY_CONTRACT_ID: {
ethQueryContractID_t *msg = (ethQueryContractID_t *) parameters;
strcpy(msg->name, "ETH2");
strcpy(msg->version, "Deposit");
msg->result = ETH_PLUGIN_RESULT_OK;
} break;
case ETH_PLUGIN_QUERY_CONTRACT_UI: {
ethQueryContractUI_t *msg = (ethQueryContractUI_t *) parameters;
// eth2_deposit_parameters_t *context = (eth2_deposit_parameters_t*)msg->pluginContext;
switch (msg->screenIndex) {
case 0: {
uint8_t decimals = WEI_TO_ETHER;
uint8_t *ticker = (uint8_t *) PIC(chainConfig->coinName);
strcpy(msg->title, "Amount");
amountToString(tmpContent.txContent.value.value,
tmpContent.txContent.value.length,
decimals,
(char *) ticker,
msg->msg,
100);
msg->result = ETH_PLUGIN_RESULT_OK;
} break;
default:
break;
}
} break;
default:
PRINTF("Unhandled message %d\n", message);
}
}
#endif
|
the_stack_data/138622.c
|
/*
cpu 386
%include "macros.inc"
extern __CHK
extern __MOVS
extern __STRCAT
extern ___19bd60h
extern ___1d4e8h
extern ___1d83ch
extern ___199fa4h
extern ___61b88h
extern ___1ca00h
extern ___13710h
extern ___3ab5ch_cdecl
extern ___1a1ef8h
extern CONNECTION_TYPE
extern ___199fach
extern ___1a01e0h
extern ___2415ch
extern ___2b5f0h
extern ___61cd0h
extern ___1123ch
extern ___1d688h
extern ___1a1138h__VESA101h_DefaultScreenBufferB
extern ___1a112ch__VESA101_ACTIVESCREEN_PTR
extern ___13248h_cdecl
extern ___185c0bh
extern ___1a1108h
extern ___12e78h_cdecl
extern ___13bd4h_cdecl
extern ___12cb8h__VESA101_PRESENTSCREEN
extern ___631d4h
extern ___63228h
extern kmap
extern ___63244h
extern memset
extern ___2ab50h
extern ___60a84h
extern ___5994ch
extern ___199fa0h
extern ___60b48h
extern ___611c0h
extern ___61278h
extern ___1866b8h
extern ___1caf4h
extern ___623d4h
extern ___59b3ch
extern ___185b58h
section .text
__GDECL(___1e09ch)
push 64h
call near __CHK
push ebx
push ecx
push edx
push esi
push edi
push ebp
sub esp, byte 44h
mov edx, 0c5h
mov edi, esp
mov esi, __dfr_181000h
xor ah, ah
mov [esp+24h], edx
mov [esp+41h], ah
movsd
movsd
movsd
movsb
mov dl, 0dh
lea esi, [esp+40h]
mov edi, esp
mov [esp+40h], dl
call __STRCAT
mov ebx, [___19bd60h]
mov ebp, 0b4h
test ebx, ebx
je short ___1e110h
call near ___1d4e8h
jmp near ___1e4eeh
___1e110h:
call near ___1d83ch
mov eax, [___199fa4h]
push edx
push ecx
push eax
call ___61b88h
add esp, 4
pop ecx
pop edx
test eax, eax
jne short ___1e132h
call near ___1ca00h
add esp, byte 44h
pop ebp
pop edi
pop esi
pop edx
pop ecx
pop ebx
retn
___1e132h:
mov eax, 2
xor edx, edx
push ecx
push edx
push eax
call ___13710h
add esp, 8
pop ecx
xor eax, eax
push edx
push ecx
push eax
call ___3ab5ch_cdecl
add esp, 4
pop ecx
pop edx
test eax, eax
je near ___1e4eeh
mov edx, [___1a1ef8h]
lea eax, [edx*8+0]
sub eax, edx
mov ecx, 4
shl eax, 2
mov esi, 4b00h
sub eax, edx
mov [CONNECTION_TYPE], ecx
mov [___199fach], esi
mov ebx, [eax*4+___1a01e0h+2ch]
push edx
push ecx
push eax
call ___2415ch
pop eax
pop ecx
pop edx
mov edx, [___1a1ef8h]
lea eax, [edx*8+0]
sub eax, edx
shl eax, 2
sub eax, edx
mov [eax*4+___1a01e0h+2ch], ebx
push edx
push ecx
call ___2b5f0h
pop ecx
pop edx
push edx
push ecx
call ___61cd0h
pop ecx
pop edx
test eax, eax
jne short ___1e1b1h
call near ___1123ch
___1e1b1h:
call near ___1d688h
test eax, eax
je near ___1e4e9h
mov ecx, 28f00h
mov esi, [___1a1138h__VESA101h_DefaultScreenBufferB]
mov edi, [___1a112ch__VESA101_ACTIVESCREEN_PTR]
add esi, 10680h
add edi, 10680h
xor edx, edx
call __MOVS
xor eax, eax
mov ebx, 113h
push ecx
push edx
push eax
call ___13710h
add esp, 8
pop ecx
mov eax, 2
xor edx, edx
mov ecx, 41h
push ecx
push edx
push eax
call ___13710h
add esp, 8
pop ecx
push byte 1
mov edx, [esp+28h]
mov eax, ebp
push ecx
push ebx
push edx
push eax
call ___13248h_cdecl
add esp, 14h
mov edx, [esp+24h]
add edx, byte 0dh
lea eax, [edx*4+0]
add eax, edx
shl eax, 7
mov ebx, __dfr_181010h
mov [esp+18h], eax
lea esi, [eax+ebp*1]
mov edx, ___185c0bh
add esi, byte 28h
mov eax, [___1a1108h]
mov ecx, esi
push ecx
push ebx
push edx
push eax
call ___12e78h_cdecl
add esp, 10h
mov edx, [esp+24h]
add edx, byte 1eh
lea eax, [edx*4+0]
add eax, edx
shl eax, 7
mov ebx, __dfr_180ac8h
lea ecx, [eax+ebp*1]
mov edx, ___185c0bh
mov eax, [___1a1108h]
add ecx, byte 28h
push ecx
push ebx
push edx
push eax
call ___12e78h_cdecl
add esp, 10h
mov ebx, [esp+24h]
lea edi, [ebp+0fh]
add ebx, byte 13h
mov eax, edi
mov edx, ebx
push ecx
push edx
push eax
call ___13bd4h_cdecl
add esp, 8
pop ecx
push edx
push ecx
push eax
call ___12cb8h__VESA101_PRESENTSCREEN
pop eax
pop ecx
pop edx
mov eax, esp
push edx
push ecx
push eax
call ___631d4h
add esp, 4
pop ecx
pop edx
push edx
push ecx
push eax
call ___63228h
pop eax
pop ecx
pop edx
mov dh, [kmap+1]
xor ecx, ecx
test dh, dh
jne near ___1e414h
mov eax, [esp+18h]
mov [esp+2ch], edi
mov [esp+28h], esi
mov [esp+34h], esi
mov [esp+30h], ebx
mov [esp+1ch], eax
mov [esp+20h], eax
___1e2c7h:
test ecx, ecx
jne near ___1e414h
mov eax, __dfr_181024h
push edx
push ecx
push eax
call ___63244h
add esp, 4
pop ecx
pop edx
test eax, eax
je near ___1e36fh
xor esi, esi
mov ecx, 0c4h
mov edi, 0d8h
___1e2edh:
mov edx, [esp+20h]
mov eax, [___1a112ch__VESA101_ACTIVESCREEN_PTR]
add eax, edx
add eax, ebp
mov ebx, edi
add eax, byte 28h
mov edx, ecx
add eax, esi
add esi, 280h
push ecx
push ebx
push edx
push eax
call memset
add esp, 0ch
pop ecx
cmp esi, 2800h
jne short ___1e2edh
mov ecx, [esp+34h]
mov ebx, __dfr_18102ch
mov edx, ___185c0bh
mov eax, [___1a1108h]
lea esi, [esp+40h]
push ecx
push ebx
push edx
push eax
call ___12e78h_cdecl
add esp, 10h
push edx
push ecx
push eax
call ___12cb8h__VESA101_PRESENTSCREEN
pop eax
pop ecx
pop edx
mov eax, [__dfr_181044h]
mov edi, esp
mov [esp], eax
call __STRCAT
mov eax, esp
push edx
push ecx
push eax
call ___631d4h
add esp, 4
pop ecx
pop edx
push edx
push ecx
push eax
call ___63228h
pop eax
pop ecx
pop edx
___1e36fh:
mov eax, __dfr_180fb4h
push edx
push ecx
push eax
call ___63244h
add esp, 4
pop ecx
pop edx
test eax, eax
je short ___1e3d4h
xor ecx, ecx
mov edi, 0c4h
mov esi, 0d8h
___1e389h:
mov ebx, [esp+1ch]
mov eax, [___1a112ch__VESA101_ACTIVESCREEN_PTR]
add eax, ebx
add eax, ebp
mov edx, edi
add eax, byte 28h
mov ebx, esi
add eax, ecx
add ecx, 280h
push ecx
push ebx
push edx
push eax
call memset
add esp, 0ch
pop ecx
cmp ecx, 2800h
jne short ___1e389h
mov ecx, [esp+28h]
mov ebx, __dfr_181010h
mov edx, ___185c0bh
mov eax, [___1a1108h]
push ecx
push ebx
push edx
push eax
call ___12e78h_cdecl
add esp, 10h
push edx
push ecx
push eax
call ___12cb8h__VESA101_PRESENTSCREEN
pop eax
pop ecx
pop edx
push edx
push ecx
push eax
call ___63228h
pop eax
pop ecx
pop edx
___1e3d4h:
mov eax, __dfr_180fdch
push edx
push ecx
push eax
call ___63244h
add esp, 4
pop ecx
pop edx
mov ecx, eax
test eax, eax
jne short ___1e3f0h
mov eax, __dfr_180fe4h
push edx
push ecx
push eax
call ___63244h
add esp, 4
pop ecx
pop edx
mov ecx, eax
___1e3f0h:
push edx
push ecx
push eax
call ___2ab50h
pop eax
pop ecx
pop edx
push edx
push ecx
push eax
call ___2ab50h
pop eax
pop ecx
pop edx
mov edx, [esp+30h]
mov eax, [esp+2ch]
push ecx
push edx
push eax
call ___13bd4h_cdecl
add esp, 8
pop ecx
cmp byte [kmap+1], 0
je near ___1e2c7h
___1e414h:
push eax
push ecx
push edx
call ___60a84h
pop edx
pop ecx
pop eax
mov bh, [kmap+1]
xor edi, edi
xor esi, esi
mov [esp+38h], edi
cmp bh, 1
jne short ___1e430h
mov bl, bh
jmp short ___1e432h
___1e430h:
xor bl, bl
___1e432h:
mov edi, [esp+24h]
add ebp, byte 0fh
add edi, byte 13h
___1e43ch:
cmp bl, 1
je short ___1e49ah
cmp dword [esp+38h], 0ffh
je short ___1e49ah
cmp ecx, byte 1
jne short ___1e49ah
push edx
push ecx
call ___5994ch
pop ecx
pop edx
mov dword [esp+3ch], 0ah
mov bl, al
mov edx, esi
mov eax, esi
sar edx, 1fh
idiv dword [esp+3ch]
cmp edx, ecx
jne short ___1e484h
mov eax, [___199fa0h]
mov edx, 2
add eax, byte 6
push ecx
push edx
push eax
call ___60b48h
add esp, 8
pop ecx
mov [esp+38h], eax
___1e484h:
push edx
push ecx
push eax
call ___2ab50h
pop eax
pop ecx
pop edx
push edx
push ecx
push eax
call ___2ab50h
pop eax
pop ecx
pop edx
mov edx, edi
mov eax, ebp
push ecx
push edx
push eax
call ___13bd4h_cdecl
add esp, 8
pop ecx
inc esi
jmp short ___1e43ch
___1e49ah:
cmp bl, 1
je short ___1e4a8h
xor edx, edx
xor eax, eax
push ecx
push edx
push eax
call ___611c0h
add esp, 8
pop ecx
___1e4a8h:
push edx
push ecx
push eax
call ___61278h
pop eax
pop ecx
pop edx
cmp bl, 1
je short ___1e4d0h
mov edi, ___1866b8h+47eh
xor cl, cl
mov esi, __dfr_180fech
mov [___185b58h+18h], cl
push edx
push ecx
call ___1caf4h
pop ecx
pop edx
movsd
movsd
movsd
movsd
movsb
jmp short ___1e4d5h
___1e4d0h:
push edx
push ecx
push eax
call ___623d4h
pop eax
pop ecx
pop edx
___1e4d5h:
push edx
push ecx
call ___5994ch
pop ecx
pop edx
push edx
push ecx
call ___59b3ch
pop ecx
pop edx
add esp, byte 44h
pop ebp
pop edi
pop esi
pop edx
pop ecx
pop ebx
retn
___1e4e9h:
push edx
push ecx
push eax
call ___623d4h
pop eax
pop ecx
pop edx
___1e4eeh:
add esp, byte 44h
pop ebp
pop edi
pop esi
pop edx
pop ecx
pop ebx
retn
section .data
__dfr_180ac8h:
db "Press ESC to abort",0,0
__dfr_180fb4h:
db 4eh,4fh,20h,43h,41h,52h,52h,49h,45h,52h,0,0
__dfr_180fdch:
db 43h,4fh,4eh,4eh,45h,43h,54h,0
__dfr_180fe4h:
db 43h,41h,52h,52h,49h,45h,52h,0
__dfr_180fech:
db 44h,69h,73h,63h,6fh,6eh,6eh,65h,63h,74h,20h,4dh,6fh,64h,65h,6dh,0,0,0,0
__dfr_181000h:
db 41h,54h,45h,31h,58h,31h,56h,31h,53h,30h,3dh,30h,0,0,0,0
__dfr_181010h:
db 57h,61h,69h,74h,69h,6eh,67h,20h,66h,6fh,72h,20h,63h,61h,6ch,6ch,2eh,2eh,2eh,0
__dfr_181024h:
db 52h,49h,4eh,47h,0,0,0,0
__dfr_18102ch:
db 45h,73h,74h,61h,62h,6ch,69h,73h,68h,69h,6eh,67h,20h,63h,6fh,6eh,6eh,65h,63h,74h,69h,6fh,6eh,0
__dfr_181044h:
db 41h,54h,41h,0
*/
|
the_stack_data/125140809.c
|
/*
* Copyright (C) 2017-2019 Alibaba Group Holding Limited
*/
#if AOS_COMP_CLI
#include <string.h>
#include <aos/cli.h>
#include <lwip/netdb.h>
#include "lwip/opt.h"
static void lsfd_command(char *buffer, int32_t buf_len, int32_t argc, char **argv);
struct cli_command lsfd_cmd[] = {
{ "lsfd", "lsfd app", lsfd_command},
};
static void lsfd_help_command(void)
{
LWIP_DEBUGF( SOCKET_ALLOC_DEBUG, ("Usage: lsfd\n"));
LWIP_DEBUGF( SOCKET_ALLOC_DEBUG, ("Eample:\n"));
LWIP_DEBUGF( SOCKET_ALLOC_DEBUG, ("lsfd\n"));
}
static void lsfd_exec_command(void)
{
#if (SOCKET_ALLOC_DEBUG == LWIP_DBG_ON)
extern void print_sock_alloc_info(void);
print_sock_alloc_info();
#endif
}
static void lsfd_command(char *buffer, int32_t buf_len, int32_t argc, char **argv)
{
if (argc == 1) {
lsfd_exec_command();
return;
}
lsfd_help_command();
}
int32_t lsfd_cli_register(void)
{
if (0 == aos_cli_register_commands(lsfd_cmd, 1)) {
return 0;
}
return -1;
}
#endif /* AOS_COMP_CLI */
|
the_stack_data/30393.c
|
// RUN: %clang -fsyntax-only %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
// RUN: %clang -fsyntax-only -fdiagnostics-format=clang %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
// RUN: %clang -fsyntax-only -fdiagnostics-format=clang -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=DEFAULT
//
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc %s 2>&1 | FileCheck %s -check-prefix=MSVC
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fms-compatibility-version=13.00 -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 %s 2>&1 | FileCheck %s -check-prefix=MSVC
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fmsc-version=1300 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fms-compatibility-version=13.00 -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC2010
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -target x86_64-pc-win32 -fshow-column %s 2>&1 | FileCheck %s -check-prefix=MSVC
//
// RUN: %clang -fsyntax-only -fdiagnostics-format=vi %s 2>&1 | FileCheck %s -check-prefix=VI
//
// RUN: %clang -fsyntax-only -fdiagnostics-format=msvc -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=MSVC_ORIG
//
// RUN: %clang -fsyntax-only -fno-show-column %s 2>&1 | FileCheck %s -check-prefix=NO_COLUMN
//
// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback -fmsc-version=1300 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK
// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback -fms-compatibility-version=13.00 %s 2>&1 | FileCheck %s -check-prefix=MSVC2010-FALLBACK
// RUN: not %clang -fsyntax-only -Werror -fdiagnostics-format=msvc-fallback %s 2>&1 | FileCheck %s -check-prefix=MSVC-FALLBACK
#ifdef foo
#endif bad // extension!
// DEFAULT: {{.*}}:36:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
// MSVC2010: {{.*}}(36,7) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
// MSVC: {{.*}}(36,8) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
// VI: {{.*}} +36:8: warning: extra tokens at end of #endif directive [-Wextra-tokens]
// MSVC_ORIG: {{.*}}(36) : warning: extra tokens at end of #endif directive [-Wextra-tokens]
// NO_COLUMN: {{.*}}:36: warning: extra tokens at end of #endif directive [-Wextra-tokens]
// MSVC2010-FALLBACK: {{.*}}(36,7) : error(clang): extra tokens at end of #endif directive
// MSVC-FALLBACK: {{.*}}(36,8) : error(clang): extra tokens at end of #endif directive
int x;
|
the_stack_data/34512933.c
|
// Ogg Vorbis audio decoder - v1.14 - public domain
// http://nothings.org/stb_vorbis/
//
// Original version written by Sean Barrett in 2007.
//
// Originally sponsored by RAD Game Tools. Seeking implementation
// sponsored by Phillip Bennefall, Marc Andersen, Aaron Baker,
// Elias Software, Aras Pranckevicius, and Sean Barrett.
//
// LICENSE
//
// See end of file for license information.
//
// Limitations:
//
// - floor 0 not supported (used in old ogg vorbis files pre-2004)
// - lossless sample-truncation at beginning ignored
// - cannot concatenate multiple vorbis streams
// - sample positions are 32-bit, limiting seekable 192Khz
// files to around 6 hours (Ogg supports 64-bit)
//
// Feature contributors:
// Dougall Johnson (sample-exact seeking)
//
// Bugfix/warning contributors:
// Terje Mathisen Niklas Frykholm Andy Hill
// Casey Muratori John Bolton Gargaj
// Laurent Gomila Marc LeBlanc Ronny Chevalier
// Bernhard Wodo Evan Balster alxprd@github
// Tom Beaumont Ingo Leitgeb Nicolas Guillemot
// Phillip Bennefall Rohit Thiago Goulart
// manxorist@github saga musix github:infatum
// Timur Gagiev
//
// Partial history:
// 1.14 - 2018-02-11 - delete bogus dealloca usage
// 1.13 - 2018-01-29 - fix truncation of last frame (hopefully)
// 1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
// 1.11 - 2017-07-23 - fix MinGW compilation
// 1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory
// 1.09 - 2016-04-04 - back out 'truncation of last frame' fix from previous version
// 1.08 - 2016-04-02 - warnings; setup memory leaks; truncation of last frame
// 1.07 - 2015-01-16 - fixes for crashes on invalid files; warning fixes; const
// 1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
// some crash fixes when out of memory or with corrupt files
// fix some inappropriately signed shifts
// 1.05 - 2015-04-19 - don't define __forceinline if it's redundant
// 1.04 - 2014-08-27 - fix missing const-correct case in API
// 1.03 - 2014-08-07 - warning fixes
// 1.02 - 2014-07-09 - declare qsort comparison as explicitly _cdecl in Windows
// 1.01 - 2014-06-18 - fix stb_vorbis_get_samples_float (interleaved was correct)
// 1.0 - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in >2-channel;
// (API change) report sample rate for decode-full-file funcs
//
// See end of file for full version history.
//////////////////////////////////////////////////////////////////////////////
//
// HEADER BEGINS HERE
//
#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H
#define STB_VORBIS_INCLUDE_STB_VORBIS_H
#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
#define STB_VORBIS_NO_STDIO 1
#endif
#ifndef STB_VORBIS_NO_STDIO
#include <stdio.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
/////////// THREAD SAFETY
// Individual stb_vorbis* handles are not thread-safe; you cannot decode from
// them from multiple threads at the same time. However, you can have multiple
// stb_vorbis* handles and decode from them independently in multiple threads.
/////////// MEMORY ALLOCATION
// normally stb_vorbis uses malloc() to allocate memory at startup,
// and alloca() to allocate temporary memory during a frame on the
// stack. (Memory consumption will depend on the amount of setup
// data in the file and how you set the compile flags for speed
// vs. size. In my test files the maximal-size usage is ~150KB.)
//
// You can modify the wrapper functions in the source (setup_malloc,
// setup_temp_malloc, temp_malloc) to change this behavior, or you
// can use a simpler allocation model: you pass in a buffer from
// which stb_vorbis will allocate _all_ its memory (including the
// temp memory). "open" may fail with a VORBIS_outofmem if you
// do not pass in enough data; there is no way to determine how
// much you do need except to succeed (at which point you can
// query get_info to find the exact amount required. yes I know
// this is lame).
//
// If you pass in a non-NULL buffer of the type below, allocation
// will occur from it as described above. Otherwise just pass NULL
// to use malloc()/alloca()
typedef struct
{
char *alloc_buffer;
int alloc_buffer_length_in_bytes;
} stb_vorbis_alloc;
/////////// FUNCTIONS USEABLE WITH ALL INPUT MODES
typedef struct stb_vorbis stb_vorbis;
typedef struct
{
unsigned int sample_rate;
int channels;
unsigned int setup_memory_required;
unsigned int setup_temp_memory_required;
unsigned int temp_memory_required;
int max_frame_size;
} stb_vorbis_info;
// get general information about the file
extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f);
// get the last error detected (clears it, too)
extern int stb_vorbis_get_error(stb_vorbis *f);
// close an ogg vorbis file and free all memory in use
extern void stb_vorbis_close(stb_vorbis *f);
// this function returns the offset (in samples) from the beginning of the
// file that will be returned by the next decode, if it is known, or -1
// otherwise. after a flush_pushdata() call, this may take a while before
// it becomes valid again.
// NOT WORKING YET after a seek with PULLDATA API
extern int stb_vorbis_get_sample_offset(stb_vorbis *f);
// returns the current seek point within the file, or offset from the beginning
// of the memory buffer. In pushdata mode it returns 0.
extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f);
/////////// PUSHDATA API
#ifndef STB_VORBIS_NO_PUSHDATA_API
// this API allows you to get blocks of data from any source and hand
// them to stb_vorbis. you have to buffer them; stb_vorbis will tell
// you how much it used, and you have to give it the rest next time;
// and stb_vorbis may not have enough data to work with and you will
// need to give it the same data again PLUS more. Note that the Vorbis
// specification does not bound the size of an individual frame.
extern stb_vorbis *stb_vorbis_open_pushdata(
const unsigned char * datablock, int datablock_length_in_bytes,
int *datablock_memory_consumed_in_bytes,
int *error,
const stb_vorbis_alloc *alloc_buffer);
// create a vorbis decoder by passing in the initial data block containing
// the ogg&vorbis headers (you don't need to do parse them, just provide
// the first N bytes of the file--you're told if it's not enough, see below)
// on success, returns an stb_vorbis *, does not set error, returns the amount of
// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes;
// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed
// if returns NULL and *error is VORBIS_need_more_data, then the input block was
// incomplete and you need to pass in a larger block from the start of the file
extern int stb_vorbis_decode_frame_pushdata(
stb_vorbis *f,
const unsigned char *datablock, int datablock_length_in_bytes,
int *channels, // place to write number of float * buffers
float ***output, // place to write float ** array of float * buffers
int *samples // place to write number of output samples
);
// decode a frame of audio sample data if possible from the passed-in data block
//
// return value: number of bytes we used from datablock
//
// possible cases:
// 0 bytes used, 0 samples output (need more data)
// N bytes used, 0 samples output (resynching the stream, keep going)
// N bytes used, M samples output (one frame of data)
// note that after opening a file, you will ALWAYS get one N-bytes,0-sample
// frame, because Vorbis always "discards" the first frame.
//
// Note that on resynch, stb_vorbis will rarely consume all of the buffer,
// instead only datablock_length_in_bytes-3 or less. This is because it wants
// to avoid missing parts of a page header if they cross a datablock boundary,
// without writing state-machiney code to record a partial detection.
//
// The number of channels returned are stored in *channels (which can be
// NULL--it is always the same as the number of channels reported by
// get_info). *output will contain an array of float* buffers, one per
// channel. In other words, (*output)[0][0] contains the first sample from
// the first channel, and (*output)[1][0] contains the first sample from
// the second channel.
extern void stb_vorbis_flush_pushdata(stb_vorbis *f);
// inform stb_vorbis that your next datablock will not be contiguous with
// previous ones (e.g. you've seeked in the data); future attempts to decode
// frames will cause stb_vorbis to resynchronize (as noted above), and
// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it
// will begin decoding the _next_ frame.
//
// if you want to seek using pushdata, you need to seek in your file, then
// call stb_vorbis_flush_pushdata(), then start calling decoding, then once
// decoding is returning you data, call stb_vorbis_get_sample_offset, and
// if you don't like the result, seek your file again and repeat.
#endif
////////// PULLING INPUT API
#ifndef STB_VORBIS_NO_PULLDATA_API
// This API assumes stb_vorbis is allowed to pull data from a source--
// either a block of memory containing the _entire_ vorbis stream, or a
// FILE * that you or it create, or possibly some other reading mechanism
// if you go modify the source to replace the FILE * case with some kind
// of callback to your code. (But if you don't support seeking, you may
// just want to go ahead and use pushdata.)
#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output);
#endif
#if !defined(STB_VORBIS_NO_INTEGER_CONVERSION)
extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output);
#endif
// decode an entire file and output the data interleaved into a malloc()ed
// buffer stored in *output. The return value is the number of samples
// decoded, or -1 if the file could not be opened or was not an ogg vorbis file.
// When you're done with it, just free() the pointer returned in *output.
extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len,
int *error, const stb_vorbis_alloc *alloc_buffer);
// create an ogg vorbis decoder from an ogg vorbis stream in memory (note
// this must be the entire stream!). on failure, returns NULL and sets *error
#ifndef STB_VORBIS_NO_STDIO
extern stb_vorbis * stb_vorbis_open_filename(const char *filename,
int *error, const stb_vorbis_alloc *alloc_buffer);
// create an ogg vorbis decoder from a filename via fopen(). on failure,
// returns NULL and sets *error (possibly to VORBIS_file_open_failure).
extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close,
int *error, const stb_vorbis_alloc *alloc_buffer);
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
// the _current_ seek point (ftell). on failure, returns NULL and sets *error.
// note that stb_vorbis must "own" this stream; if you seek it in between
// calls to stb_vorbis, it will become confused. Morever, if you attempt to
// perform stb_vorbis_seek_*() operations on this file, it will assume it
// owns the _entire_ rest of the file after the start point. Use the next
// function, stb_vorbis_open_file_section(), to limit it.
extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close,
int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len);
// create an ogg vorbis decoder from an open FILE *, looking for a stream at
// the _current_ seek point (ftell); the stream will be of length 'len' bytes.
// on failure, returns NULL and sets *error. note that stb_vorbis must "own"
// this stream; if you seek it in between calls to stb_vorbis, it will become
// confused.
#endif
extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number);
extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number);
// these functions seek in the Vorbis file to (approximately) 'sample_number'.
// after calling seek_frame(), the next call to get_frame_*() will include
// the specified sample. after calling stb_vorbis_seek(), the next call to
// stb_vorbis_get_samples_* will start with the specified sample. If you
// do not need to seek to EXACTLY the target sample when using get_samples_*,
// you can also use seek_frame().
extern int stb_vorbis_seek_start(stb_vorbis *f);
// this function is equivalent to stb_vorbis_seek(f,0)
extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f);
extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f);
// these functions return the total length of the vorbis stream
extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output);
// decode the next frame and return the number of samples. the number of
// channels returned are stored in *channels (which can be NULL--it is always
// the same as the number of channels reported by get_info). *output will
// contain an array of float* buffers, one per channel. These outputs will
// be overwritten on the next call to stb_vorbis_get_frame_*.
//
// You generally should not intermix calls to stb_vorbis_get_frame_*()
// and stb_vorbis_get_samples_*(), since the latter calls the former.
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts);
extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples);
#endif
// decode the next frame and return the number of *samples* per channel.
// Note that for interleaved data, you pass in the number of shorts (the
// size of your array), but the return value is the number of samples per
// channel, not the total number of samples.
//
// The data is coerced to the number of channels you request according to the
// channel coercion rules (see below). You must pass in the size of your
// buffer(s) so that stb_vorbis will not overwrite the end of the buffer.
// The maximum buffer size needed can be gotten from get_info(); however,
// the Vorbis I specification implies an absolute maximum of 4096 samples
// per channel.
// Channel coercion rules:
// Let M be the number of channels requested, and N the number of channels present,
// and Cn be the nth channel; let stereo L be the sum of all L and center channels,
// and stereo R be the sum of all R and center channels (channel assignment from the
// vorbis spec).
// M N output
// 1 k sum(Ck) for all k
// 2 * stereo L, stereo R
// k l k > l, the first l channels, then 0s
// k l k <= l, the first k channels
// Note that this is not _good_ surround etc. mixing at all! It's just so
// you get something useful.
extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats);
extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples);
// gets num_samples samples, not necessarily on a frame boundary--this requires
// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES.
// Returns the number of samples stored per channel; it may be less than requested
// at the end of the file. If there are no more samples in the file, returns 0.
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts);
extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples);
#endif
// gets num_samples samples, not necessarily on a frame boundary--this requires
// buffering so you have to supply the buffers. Applies the coercion rules above
// to produce 'channels' channels. Returns the number of samples stored per channel;
// it may be less than requested at the end of the file. If there are no more
// samples in the file, returns 0.
#endif
//////// ERROR CODES
enum STBVorbisError
{
VORBIS__no_error,
VORBIS_need_more_data=1, // not a real error
VORBIS_invalid_api_mixing, // can't mix API modes
VORBIS_outofmem, // not enough memory
VORBIS_feature_not_supported, // uses floor 0
VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small
VORBIS_file_open_failure, // fopen() failed
VORBIS_seek_without_length, // can't seek in unknown-length file
VORBIS_unexpected_eof=10, // file is truncated?
VORBIS_seek_invalid, // seek past EOF
// decoding errors (corrupt/invalid stream) -- you probably
// don't care about the exact details of these
// vorbis errors:
VORBIS_invalid_setup=20,
VORBIS_invalid_stream,
// ogg errors:
VORBIS_missing_capture_pattern=30,
VORBIS_invalid_stream_structure_version,
VORBIS_continued_packet_flag_invalid,
VORBIS_incorrect_stream_serial_number,
VORBIS_invalid_first_page,
VORBIS_bad_packet_type,
VORBIS_cant_find_last_page,
VORBIS_seek_failed
};
#ifdef __cplusplus
}
#endif
#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H
//
// HEADER ENDS HERE
//
//////////////////////////////////////////////////////////////////////////////
#ifndef STB_VORBIS_HEADER_ONLY
// global configuration settings (e.g. set these in the project/makefile),
// or just set them in this file at the top (although ideally the first few
// should be visible when the header file is compiled too, although it's not
// crucial)
// STB_VORBIS_NO_PUSHDATA_API
// does not compile the code for the various stb_vorbis_*_pushdata()
// functions
// #define STB_VORBIS_NO_PUSHDATA_API
// STB_VORBIS_NO_PULLDATA_API
// does not compile the code for the non-pushdata APIs
// #define STB_VORBIS_NO_PULLDATA_API
// STB_VORBIS_NO_STDIO
// does not compile the code for the APIs that use FILE *s internally
// or externally (implied by STB_VORBIS_NO_PULLDATA_API)
// #define STB_VORBIS_NO_STDIO
// STB_VORBIS_NO_INTEGER_CONVERSION
// does not compile the code for converting audio sample data from
// float to integer (implied by STB_VORBIS_NO_PULLDATA_API)
// #define STB_VORBIS_NO_INTEGER_CONVERSION
// STB_VORBIS_NO_FAST_SCALED_FLOAT
// does not use a fast float-to-int trick to accelerate float-to-int on
// most platforms which requires endianness be defined correctly.
//#define STB_VORBIS_NO_FAST_SCALED_FLOAT
// STB_VORBIS_MAX_CHANNELS [number]
// globally define this to the maximum number of channels you need.
// The spec does not put a restriction on channels except that
// the count is stored in a byte, so 255 is the hard limit.
// Reducing this saves about 16 bytes per value, so using 16 saves
// (255-16)*16 or around 4KB. Plus anything other memory usage
// I forgot to account for. Can probably go as low as 8 (7.1 audio),
// 6 (5.1 audio), or 2 (stereo only).
#ifndef STB_VORBIS_MAX_CHANNELS
#define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone?
#endif
// STB_VORBIS_PUSHDATA_CRC_COUNT [number]
// after a flush_pushdata(), stb_vorbis begins scanning for the
// next valid page, without backtracking. when it finds something
// that looks like a page, it streams through it and verifies its
// CRC32. Should that validation fail, it keeps scanning. But it's
// possible that _while_ streaming through to check the CRC32 of
// one candidate page, it sees another candidate page. This #define
// determines how many "overlapping" candidate pages it can search
// at once. Note that "real" pages are typically ~4KB to ~8KB, whereas
// garbage pages could be as big as 64KB, but probably average ~16KB.
// So don't hose ourselves by scanning an apparent 64KB page and
// missing a ton of real ones in the interim; so minimum of 2
#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT
#define STB_VORBIS_PUSHDATA_CRC_COUNT 4
#endif
// STB_VORBIS_FAST_HUFFMAN_LENGTH [number]
// sets the log size of the huffman-acceleration table. Maximum
// supported value is 24. with larger numbers, more decodings are O(1),
// but the table size is larger so worse cache missing, so you'll have
// to probe (and try multiple ogg vorbis files) to find the sweet spot.
#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH
#define STB_VORBIS_FAST_HUFFMAN_LENGTH 10
#endif
// STB_VORBIS_FAST_BINARY_LENGTH [number]
// sets the log size of the binary-search acceleration table. this
// is used in similar fashion to the fast-huffman size to set initial
// parameters for the binary search
// STB_VORBIS_FAST_HUFFMAN_INT
// The fast huffman tables are much more efficient if they can be
// stored as 16-bit results instead of 32-bit results. This restricts
// the codebooks to having only 65535 possible outcomes, though.
// (At least, accelerated by the huffman table.)
#ifndef STB_VORBIS_FAST_HUFFMAN_INT
#define STB_VORBIS_FAST_HUFFMAN_SHORT
#endif
// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
// If the 'fast huffman' search doesn't succeed, then stb_vorbis falls
// back on binary searching for the correct one. This requires storing
// extra tables with the huffman codes in sorted order. Defining this
// symbol trades off space for speed by forcing a linear search in the
// non-fast case, except for "sparse" codebooks.
// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
// STB_VORBIS_DIVIDES_IN_RESIDUE
// stb_vorbis precomputes the result of the scalar residue decoding
// that would otherwise require a divide per chunk. you can trade off
// space for time by defining this symbol.
// #define STB_VORBIS_DIVIDES_IN_RESIDUE
// STB_VORBIS_DIVIDES_IN_CODEBOOK
// vorbis VQ codebooks can be encoded two ways: with every case explicitly
// stored, or with all elements being chosen from a small range of values,
// and all values possible in all elements. By default, stb_vorbis expands
// this latter kind out to look like the former kind for ease of decoding,
// because otherwise an integer divide-per-vector-element is required to
// unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can
// trade off storage for speed.
//#define STB_VORBIS_DIVIDES_IN_CODEBOOK
#ifdef STB_VORBIS_CODEBOOK_SHORTS
#error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats"
#endif
// STB_VORBIS_DIVIDE_TABLE
// this replaces small integer divides in the floor decode loop with
// table lookups. made less than 1% difference, so disabled by default.
// STB_VORBIS_NO_INLINE_DECODE
// disables the inlining of the scalar codebook fast-huffman decode.
// might save a little codespace; useful for debugging
// #define STB_VORBIS_NO_INLINE_DECODE
// STB_VORBIS_NO_DEFER_FLOOR
// Normally we only decode the floor without synthesizing the actual
// full curve. We can instead synthesize the curve immediately. This
// requires more memory and is very likely slower, so I don't think
// you'd ever want to do it except for debugging.
// #define STB_VORBIS_NO_DEFER_FLOOR
//////////////////////////////////////////////////////////////////////////////
#ifdef STB_VORBIS_NO_PULLDATA_API
#define STB_VORBIS_NO_INTEGER_CONVERSION
#define STB_VORBIS_NO_STDIO
#endif
#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO)
#define STB_VORBIS_NO_STDIO 1
#endif
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
// only need endianness for fast-float-to-int, which we don't
// use for pushdata
#ifndef STB_VORBIS_BIG_ENDIAN
#define STB_VORBIS_ENDIAN 0
#else
#define STB_VORBIS_ENDIAN 1
#endif
#endif
#endif
#ifndef STB_VORBIS_NO_STDIO
#include <stdio.h>
#endif
#ifndef STB_VORBIS_NO_CRT
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
// find definition of alloca if it's not in stdlib.h:
#if defined(_MSC_VER) || defined(__MINGW32__)
#include <malloc.h>
#endif
#if defined(__linux__) || defined(__linux) || defined(__EMSCRIPTEN__)
#include <alloca.h>
#endif
#else // STB_VORBIS_NO_CRT
#define NULL 0
#define malloc(s) 0
#define free(s) ((void) 0)
#define realloc(s) 0
#endif // STB_VORBIS_NO_CRT
#include <limits.h>
#ifdef __MINGW32__
// eff you mingw:
// "fixed":
// http://sourceforge.net/p/mingw-w64/mailman/message/32882927/
// "no that broke the build, reverted, who cares about C":
// http://sourceforge.net/p/mingw-w64/mailman/message/32890381/
#ifdef __forceinline
#undef __forceinline
#endif
#define __forceinline
#define alloca __builtin_alloca
#elif !defined(_MSC_VER)
#if __GNUC__
#define __forceinline inline
#else
#define __forceinline
#endif
#endif
#if STB_VORBIS_MAX_CHANNELS > 256
#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range"
#endif
#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24
#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range"
#endif
#if 0
#include <crtdbg.h>
#define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1])
#else
#define CHECK(f) ((void) 0)
#endif
#define MAX_BLOCKSIZE_LOG 13 // from specification
#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG)
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
typedef signed short int16;
typedef unsigned int uint32;
typedef signed int int32;
#ifndef TRUE
#define TRUE 1
#define FALSE 0
#endif
typedef float codetype;
// @NOTE
//
// Some arrays below are tagged "//varies", which means it's actually
// a variable-sized piece of data, but rather than malloc I assume it's
// small enough it's better to just allocate it all together with the
// main thing
//
// Most of the variables are specified with the smallest size I could pack
// them into. It might give better performance to make them all full-sized
// integers. It should be safe to freely rearrange the structures or change
// the sizes larger--nothing relies on silently truncating etc., nor the
// order of variables.
#define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH)
#define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1)
typedef struct
{
int dimensions, entries;
uint8 *codeword_lengths;
float minimum_value;
float delta_value;
uint8 value_bits;
uint8 lookup_type;
uint8 sequence_p;
uint8 sparse;
uint32 lookup_values;
codetype *multiplicands;
uint32 *codewords;
#ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
#else
int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE];
#endif
uint32 *sorted_codewords;
int *sorted_values;
int sorted_entries;
} Codebook;
typedef struct
{
uint8 order;
uint16 rate;
uint16 bark_map_size;
uint8 amplitude_bits;
uint8 amplitude_offset;
uint8 number_of_books;
uint8 book_list[16]; // varies
} Floor0;
typedef struct
{
uint8 partitions;
uint8 partition_class_list[32]; // varies
uint8 class_dimensions[16]; // varies
uint8 class_subclasses[16]; // varies
uint8 class_masterbooks[16]; // varies
int16 subclass_books[16][8]; // varies
uint16 Xlist[31*8+2]; // varies
uint8 sorted_order[31*8+2];
uint8 neighbors[31*8+2][2];
uint8 floor1_multiplier;
uint8 rangebits;
int values;
} Floor1;
typedef union
{
Floor0 floor0;
Floor1 floor1;
} Floor;
typedef struct
{
uint32 begin, end;
uint32 part_size;
uint8 classifications;
uint8 classbook;
uint8 **classdata;
int16 (*residue_books)[8];
} Residue;
typedef struct
{
uint8 magnitude;
uint8 angle;
uint8 mux;
} MappingChannel;
typedef struct
{
uint16 coupling_steps;
MappingChannel *chan;
uint8 submaps;
uint8 submap_floor[15]; // varies
uint8 submap_residue[15]; // varies
} Mapping;
typedef struct
{
uint8 blockflag;
uint8 mapping;
uint16 windowtype;
uint16 transformtype;
} Mode;
typedef struct
{
uint32 goal_crc; // expected crc if match
int bytes_left; // bytes left in packet
uint32 crc_so_far; // running crc
int bytes_done; // bytes processed in _current_ chunk
uint32 sample_loc; // granule pos encoded in page
} CRCscan;
typedef struct
{
uint32 page_start, page_end;
uint32 last_decoded_sample;
} ProbedPage;
struct stb_vorbis
{
// user-accessible info
unsigned int sample_rate;
int channels;
unsigned int setup_memory_required;
unsigned int temp_memory_required;
unsigned int setup_temp_memory_required;
// input config
#ifndef STB_VORBIS_NO_STDIO
FILE *f;
uint32 f_start;
int close_on_free;
#endif
uint8 *stream;
uint8 *stream_start;
uint8 *stream_end;
uint32 stream_len;
uint8 push_mode;
uint32 first_audio_page_offset;
ProbedPage p_first, p_last;
// memory management
stb_vorbis_alloc alloc;
int setup_offset;
int temp_offset;
// run-time results
int eof;
enum STBVorbisError error;
// user-useful data
// header info
int blocksize[2];
int blocksize_0, blocksize_1;
int codebook_count;
Codebook *codebooks;
int floor_count;
uint16 floor_types[64]; // varies
Floor *floor_config;
int residue_count;
uint16 residue_types[64]; // varies
Residue *residue_config;
int mapping_count;
Mapping *mapping;
int mode_count;
Mode mode_config[64]; // varies
uint32 total_samples;
// decode buffer
float *channel_buffers[STB_VORBIS_MAX_CHANNELS];
float *outputs [STB_VORBIS_MAX_CHANNELS];
float *previous_window[STB_VORBIS_MAX_CHANNELS];
int previous_length;
#ifndef STB_VORBIS_NO_DEFER_FLOOR
int16 *finalY[STB_VORBIS_MAX_CHANNELS];
#else
float *floor_buffers[STB_VORBIS_MAX_CHANNELS];
#endif
uint32 current_loc; // sample location of next frame to decode
int current_loc_valid;
// per-blocksize precomputed data
// twiddle factors
float *A[2],*B[2],*C[2];
float *window[2];
uint16 *bit_reverse[2];
// current page/packet/segment streaming info
uint32 serial; // stream serial number for verification
int last_page;
int segment_count;
uint8 segments[255];
uint8 page_flag;
uint8 bytes_in_seg;
uint8 first_decode;
int next_seg;
int last_seg; // flag that we're on the last segment
int last_seg_which; // what was the segment number of the last seg?
uint32 acc;
int valid_bits;
int packet_bytes;
int end_seg_with_known_loc;
uint32 known_loc_for_packet;
int discard_samples_deferred;
uint32 samples_output;
// push mode scanning
int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching
#ifndef STB_VORBIS_NO_PUSHDATA_API
CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT];
#endif
// sample-access
int channel_buffer_start;
int channel_buffer_end;
};
#if defined(STB_VORBIS_NO_PUSHDATA_API)
#define IS_PUSH_MODE(f) FALSE
#elif defined(STB_VORBIS_NO_PULLDATA_API)
#define IS_PUSH_MODE(f) TRUE
#else
#define IS_PUSH_MODE(f) ((f)->push_mode)
#endif
typedef struct stb_vorbis vorb;
static int error(vorb *f, enum STBVorbisError e)
{
f->error = e;
if (!f->eof && e != VORBIS_need_more_data) {
f->error=e; // breakpoint for debugging
}
return 0;
}
// these functions are used for allocating temporary memory
// while decoding. if you can afford the stack space, use
// alloca(); otherwise, provide a temp buffer and it will
// allocate out of those.
#define array_size_required(count,size) (count*(sizeof(void *)+(size)))
#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size))
#define temp_free(f,p) 0
#define temp_alloc_save(f) ((f)->temp_offset)
#define temp_alloc_restore(f,p) ((f)->temp_offset = (p))
#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size)
// given a sufficiently large block of memory, make an array of pointers to subblocks of it
static void *make_block_array(void *mem, int count, int size)
{
int i;
void ** p = (void **) mem;
char *q = (char *) (p + count);
for (i=0; i < count; ++i) {
p[i] = q;
q += size;
}
return p;
}
static void *setup_malloc(vorb *f, int sz)
{
sz = (sz+3) & ~3;
f->setup_memory_required += sz;
if (f->alloc.alloc_buffer) {
void *p = (char *) f->alloc.alloc_buffer + f->setup_offset;
if (f->setup_offset + sz > f->temp_offset) return NULL;
f->setup_offset += sz;
return p;
}
return sz ? malloc(sz) : NULL;
}
static void setup_free(vorb *f, void *p)
{
if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack
free(p);
}
static void *setup_temp_malloc(vorb *f, int sz)
{
sz = (sz+3) & ~3;
if (f->alloc.alloc_buffer) {
if (f->temp_offset - sz < f->setup_offset) return NULL;
f->temp_offset -= sz;
return (char *) f->alloc.alloc_buffer + f->temp_offset;
}
return malloc(sz);
}
static void setup_temp_free(vorb *f, void *p, int sz)
{
if (f->alloc.alloc_buffer) {
f->temp_offset += (sz+3)&~3;
return;
}
free(p);
}
#define CRC32_POLY 0x04c11db7 // from spec
static uint32 crc_table[256];
static void crc32_init(void)
{
int i,j;
uint32 s;
for(i=0; i < 256; i++) {
for (s=(uint32) i << 24, j=0; j < 8; ++j)
s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0);
crc_table[i] = s;
}
}
static __forceinline uint32 crc32_update(uint32 crc, uint8 byte)
{
return (crc << 8) ^ crc_table[byte ^ (crc >> 24)];
}
// used in setup, and for huffman that doesn't go fast path
static unsigned int bit_reverse(unsigned int n)
{
n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1);
n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2);
n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4);
n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8);
return (n >> 16) | (n << 16);
}
static float square(float x)
{
return x*x;
}
// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3
// as required by the specification. fast(?) implementation from stb.h
// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup
static int ilog(int32 n)
{
static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 };
if (n < 0) return 0; // signed n returns 0
// 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29)
if (n < (1 << 14))
if (n < (1 << 4)) return 0 + log2_4[n ];
else if (n < (1 << 9)) return 5 + log2_4[n >> 5];
else return 10 + log2_4[n >> 10];
else if (n < (1 << 24))
if (n < (1 << 19)) return 15 + log2_4[n >> 15];
else return 20 + log2_4[n >> 20];
else if (n < (1 << 29)) return 25 + log2_4[n >> 25];
else return 30 + log2_4[n >> 30];
}
#ifndef M_PI
#define M_PI 3.14159265358979323846264f // from CRC
#endif
// code length assigned to a value with no huffman encoding
#define NO_CODE 255
/////////////////////// LEAF SETUP FUNCTIONS //////////////////////////
//
// these functions are only called at setup, and only a few times
// per file
static float float32_unpack(uint32 x)
{
// from the specification
uint32 mantissa = x & 0x1fffff;
uint32 sign = x & 0x80000000;
uint32 exp = (x & 0x7fe00000) >> 21;
double res = sign ? -(double)mantissa : (double)mantissa;
return (float) ldexp((float)res, exp-788);
}
// zlib & jpeg huffman tables assume that the output symbols
// can either be arbitrarily arranged, or have monotonically
// increasing frequencies--they rely on the lengths being sorted;
// this makes for a very simple generation algorithm.
// vorbis allows a huffman table with non-sorted lengths. This
// requires a more sophisticated construction, since symbols in
// order do not map to huffman codes "in order".
static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values)
{
if (!c->sparse) {
c->codewords [symbol] = huff_code;
} else {
c->codewords [count] = huff_code;
c->codeword_lengths[count] = len;
values [count] = symbol;
}
}
static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values)
{
int i,k,m=0;
uint32 available[32];
memset(available, 0, sizeof(available));
// find the first entry
for (k=0; k < n; ++k) if (len[k] < NO_CODE) break;
if (k == n) { assert(c->sorted_entries == 0); return TRUE; }
// add to the list
add_entry(c, 0, k, m++, len[k], values);
// add all available leaves
for (i=1; i <= len[k]; ++i)
available[i] = 1U << (32-i);
// note that the above code treats the first case specially,
// but it's really the same as the following code, so they
// could probably be combined (except the initial code is 0,
// and I use 0 in available[] to mean 'empty')
for (i=k+1; i < n; ++i) {
uint32 res;
int z = len[i], y;
if (z == NO_CODE) continue;
// find lowest available leaf (should always be earliest,
// which is what the specification calls for)
// note that this property, and the fact we can never have
// more than one free leaf at a given level, isn't totally
// trivial to prove, but it seems true and the assert never
// fires, so!
while (z > 0 && !available[z]) --z;
if (z == 0) { return FALSE; }
res = available[z];
assert(z >= 0 && z < 32);
available[z] = 0;
add_entry(c, bit_reverse(res), i, m++, len[i], values);
// propogate availability up the tree
if (z != len[i]) {
assert(len[i] >= 0 && len[i] < 32);
for (y=len[i]; y > z; --y) {
assert(available[y] == 0);
available[y] = res + (1 << (32-y));
}
}
}
return TRUE;
}
// accelerated huffman table allows fast O(1) match of all symbols
// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH
static void compute_accelerated_huffman(Codebook *c)
{
int i, len;
for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i)
c->fast_huffman[i] = -1;
len = c->sparse ? c->sorted_entries : c->entries;
#ifdef STB_VORBIS_FAST_HUFFMAN_SHORT
if (len > 32767) len = 32767; // largest possible value we can encode!
#endif
for (i=0; i < len; ++i) {
if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) {
uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i];
// set table entries for all bit combinations in the higher bits
while (z < FAST_HUFFMAN_TABLE_SIZE) {
c->fast_huffman[z] = i;
z += 1 << c->codeword_lengths[i];
}
}
}
}
#ifdef _MSC_VER
#define STBV_CDECL __cdecl
#else
#define STBV_CDECL
#endif
static int STBV_CDECL uint32_compare(const void *p, const void *q)
{
uint32 x = * (uint32 *) p;
uint32 y = * (uint32 *) q;
return x < y ? -1 : x > y;
}
static int include_in_sort(Codebook *c, uint8 len)
{
if (c->sparse) { assert(len != NO_CODE); return TRUE; }
if (len == NO_CODE) return FALSE;
if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE;
return FALSE;
}
// if the fast table above doesn't work, we want to binary
// search them... need to reverse the bits
static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values)
{
int i, len;
// build a list of all the entries
// OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN.
// this is kind of a frivolous optimization--I don't see any performance improvement,
// but it's like 4 extra lines of code, so.
if (!c->sparse) {
int k = 0;
for (i=0; i < c->entries; ++i)
if (include_in_sort(c, lengths[i]))
c->sorted_codewords[k++] = bit_reverse(c->codewords[i]);
assert(k == c->sorted_entries);
} else {
for (i=0; i < c->sorted_entries; ++i)
c->sorted_codewords[i] = bit_reverse(c->codewords[i]);
}
qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare);
c->sorted_codewords[c->sorted_entries] = 0xffffffff;
len = c->sparse ? c->sorted_entries : c->entries;
// now we need to indicate how they correspond; we could either
// #1: sort a different data structure that says who they correspond to
// #2: for each sorted entry, search the original list to find who corresponds
// #3: for each original entry, find the sorted entry
// #1 requires extra storage, #2 is slow, #3 can use binary search!
for (i=0; i < len; ++i) {
int huff_len = c->sparse ? lengths[values[i]] : lengths[i];
if (include_in_sort(c,huff_len)) {
uint32 code = bit_reverse(c->codewords[i]);
int x=0, n=c->sorted_entries;
while (n > 1) {
// invariant: sc[x] <= code < sc[x+n]
int m = x + (n >> 1);
if (c->sorted_codewords[m] <= code) {
x = m;
n -= (n>>1);
} else {
n >>= 1;
}
}
assert(c->sorted_codewords[x] == code);
if (c->sparse) {
c->sorted_values[x] = values[i];
c->codeword_lengths[x] = huff_len;
} else {
c->sorted_values[x] = i;
}
}
}
}
// only run while parsing the header (3 times)
static int vorbis_validate(uint8 *data)
{
static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' };
return memcmp(data, vorbis, 6) == 0;
}
// called from setup only, once per code book
// (formula implied by specification)
static int lookup1_values(int entries, int dim)
{
int r = (int) floor(exp((float) log((float) entries) / dim));
if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning;
++r; // floor() to avoid _ftol() when non-CRT
assert(pow((float) r+1, dim) > entries);
assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above
return r;
}
// called twice per file
static void compute_twiddle_factors(int n, float *A, float *B, float *C)
{
int n4 = n >> 2, n8 = n >> 3;
int k,k2;
for (k=k2=0; k < n4; ++k,k2+=2) {
A[k2 ] = (float) cos(4*k*M_PI/n);
A[k2+1] = (float) -sin(4*k*M_PI/n);
B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f;
B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f;
}
for (k=k2=0; k < n8; ++k,k2+=2) {
C[k2 ] = (float) cos(2*(k2+1)*M_PI/n);
C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
}
}
static void compute_window(int n, float *window)
{
int n2 = n >> 1, i;
for (i=0; i < n2; ++i)
window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI)));
}
static void compute_bitreverse(int n, uint16 *rev)
{
int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
int i, n8 = n >> 3;
for (i=0; i < n8; ++i)
rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2;
}
static int init_blocksize(vorb *f, int b, int n)
{
int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3;
f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2);
f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2);
f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4);
if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem);
compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]);
f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2);
if (!f->window[b]) return error(f, VORBIS_outofmem);
compute_window(n, f->window[b]);
f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8);
if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem);
compute_bitreverse(n, f->bit_reverse[b]);
return TRUE;
}
static void neighbors(uint16 *x, int n, int *plow, int *phigh)
{
int low = -1;
int high = 65536;
int i;
for (i=0; i < n; ++i) {
if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; }
if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; }
}
}
// this has been repurposed so y is now the original index instead of y
typedef struct
{
uint16 x,id;
} stbv__floor_ordering;
static int STBV_CDECL point_compare(const void *p, const void *q)
{
stbv__floor_ordering *a = (stbv__floor_ordering *) p;
stbv__floor_ordering *b = (stbv__floor_ordering *) q;
return a->x < b->x ? -1 : a->x > b->x;
}
//
/////////////////////// END LEAF SETUP FUNCTIONS //////////////////////////
#if defined(STB_VORBIS_NO_STDIO)
#define USE_MEMORY(z) TRUE
#else
#define USE_MEMORY(z) ((z)->stream)
#endif
static uint8 get8(vorb *z)
{
if (USE_MEMORY(z)) {
if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; }
return *z->stream++;
}
#ifndef STB_VORBIS_NO_STDIO
{
int c = fgetc(z->f);
if (c == EOF) { z->eof = TRUE; return 0; }
return c;
}
#endif
}
static uint32 get32(vorb *f)
{
uint32 x;
x = get8(f);
x += get8(f) << 8;
x += get8(f) << 16;
x += (uint32) get8(f) << 24;
return x;
}
static int getn(vorb *z, uint8 *data, int n)
{
if (USE_MEMORY(z)) {
if (z->stream+n > z->stream_end) { z->eof = 1; return 0; }
memcpy(data, z->stream, n);
z->stream += n;
return 1;
}
#ifndef STB_VORBIS_NO_STDIO
if (fread(data, n, 1, z->f) == 1)
return 1;
else {
z->eof = 1;
return 0;
}
#endif
}
static void skip(vorb *z, int n)
{
if (USE_MEMORY(z)) {
z->stream += n;
if (z->stream >= z->stream_end) z->eof = 1;
return;
}
#ifndef STB_VORBIS_NO_STDIO
{
long x = ftell(z->f);
fseek(z->f, x+n, SEEK_SET);
}
#endif
}
static int set_file_offset(stb_vorbis *f, unsigned int loc)
{
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (f->push_mode) return 0;
#endif
f->eof = 0;
if (USE_MEMORY(f)) {
if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) {
f->stream = f->stream_end;
f->eof = 1;
return 0;
} else {
f->stream = f->stream_start + loc;
return 1;
}
}
#ifndef STB_VORBIS_NO_STDIO
if (loc + f->f_start < loc || loc >= 0x80000000) {
loc = 0x7fffffff;
f->eof = 1;
} else {
loc += f->f_start;
}
if (!fseek(f->f, loc, SEEK_SET))
return 1;
f->eof = 1;
fseek(f->f, f->f_start, SEEK_END);
return 0;
#endif
}
static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 };
static int capture_pattern(vorb *f)
{
if (0x4f != get8(f)) return FALSE;
if (0x67 != get8(f)) return FALSE;
if (0x67 != get8(f)) return FALSE;
if (0x53 != get8(f)) return FALSE;
return TRUE;
}
#define PAGEFLAG_continued_packet 1
#define PAGEFLAG_first_page 2
#define PAGEFLAG_last_page 4
static int start_page_no_capturepattern(vorb *f)
{
uint32 loc0,loc1,n;
// stream structure version
if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version);
// header flag
f->page_flag = get8(f);
// absolute granule position
loc0 = get32(f);
loc1 = get32(f);
// @TODO: validate loc0,loc1 as valid positions?
// stream serial number -- vorbis doesn't interleave, so discard
get32(f);
//if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number);
// page sequence number
n = get32(f);
f->last_page = n;
// CRC32
get32(f);
// page_segments
f->segment_count = get8(f);
if (!getn(f, f->segments, f->segment_count))
return error(f, VORBIS_unexpected_eof);
// assume we _don't_ know any the sample position of any segments
f->end_seg_with_known_loc = -2;
if (loc0 != ~0U || loc1 != ~0U) {
int i;
// determine which packet is the last one that will complete
for (i=f->segment_count-1; i >= 0; --i)
if (f->segments[i] < 255)
break;
// 'i' is now the index of the _last_ segment of a packet that ends
if (i >= 0) {
f->end_seg_with_known_loc = i;
f->known_loc_for_packet = loc0;
}
}
if (f->first_decode) {
int i,len;
ProbedPage p;
len = 0;
for (i=0; i < f->segment_count; ++i)
len += f->segments[i];
len += 27 + f->segment_count;
p.page_start = f->first_audio_page_offset;
p.page_end = p.page_start + len;
p.last_decoded_sample = loc0;
f->p_first = p;
}
f->next_seg = 0;
return TRUE;
}
static int start_page(vorb *f)
{
if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern);
return start_page_no_capturepattern(f);
}
static int start_packet(vorb *f)
{
while (f->next_seg == -1) {
if (!start_page(f)) return FALSE;
if (f->page_flag & PAGEFLAG_continued_packet)
return error(f, VORBIS_continued_packet_flag_invalid);
}
f->last_seg = FALSE;
f->valid_bits = 0;
f->packet_bytes = 0;
f->bytes_in_seg = 0;
// f->next_seg is now valid
return TRUE;
}
static int maybe_start_packet(vorb *f)
{
if (f->next_seg == -1) {
int x = get8(f);
if (f->eof) return FALSE; // EOF at page boundary is not an error!
if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern);
if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern);
if (!start_page_no_capturepattern(f)) return FALSE;
if (f->page_flag & PAGEFLAG_continued_packet) {
// set up enough state that we can read this packet if we want,
// e.g. during recovery
f->last_seg = FALSE;
f->bytes_in_seg = 0;
return error(f, VORBIS_continued_packet_flag_invalid);
}
}
return start_packet(f);
}
static int next_segment(vorb *f)
{
int len;
if (f->last_seg) return 0;
if (f->next_seg == -1) {
f->last_seg_which = f->segment_count-1; // in case start_page fails
if (!start_page(f)) { f->last_seg = 1; return 0; }
if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid);
}
len = f->segments[f->next_seg++];
if (len < 255) {
f->last_seg = TRUE;
f->last_seg_which = f->next_seg-1;
}
if (f->next_seg >= f->segment_count)
f->next_seg = -1;
assert(f->bytes_in_seg == 0);
f->bytes_in_seg = len;
return len;
}
#define EOP (-1)
#define INVALID_BITS (-1)
static int get8_packet_raw(vorb *f)
{
if (!f->bytes_in_seg) { // CLANG!
if (f->last_seg) return EOP;
else if (!next_segment(f)) return EOP;
}
assert(f->bytes_in_seg > 0);
--f->bytes_in_seg;
++f->packet_bytes;
return get8(f);
}
static int get8_packet(vorb *f)
{
int x = get8_packet_raw(f);
f->valid_bits = 0;
return x;
}
static void flush_packet(vorb *f)
{
while (get8_packet_raw(f) != EOP);
}
// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important
// as the huffman decoder?
static uint32 get_bits(vorb *f, int n)
{
uint32 z;
if (f->valid_bits < 0) return 0;
if (f->valid_bits < n) {
if (n > 24) {
// the accumulator technique below would not work correctly in this case
z = get_bits(f, 24);
z += get_bits(f, n-24) << 24;
return z;
}
if (f->valid_bits == 0) f->acc = 0;
while (f->valid_bits < n) {
int z = get8_packet_raw(f);
if (z == EOP) {
f->valid_bits = INVALID_BITS;
return 0;
}
f->acc += z << f->valid_bits;
f->valid_bits += 8;
}
}
if (f->valid_bits < 0) return 0;
z = f->acc & ((1 << n)-1);
f->acc >>= n;
f->valid_bits -= n;
return z;
}
// @OPTIMIZE: primary accumulator for huffman
// expand the buffer to as many bits as possible without reading off end of packet
// it might be nice to allow f->valid_bits and f->acc to be stored in registers,
// e.g. cache them locally and decode locally
static __forceinline void prep_huffman(vorb *f)
{
if (f->valid_bits <= 24) {
if (f->valid_bits == 0) f->acc = 0;
do {
int z;
if (f->last_seg && !f->bytes_in_seg) return;
z = get8_packet_raw(f);
if (z == EOP) return;
f->acc += (unsigned) z << f->valid_bits;
f->valid_bits += 8;
} while (f->valid_bits <= 24);
}
}
enum
{
VORBIS_packet_id = 1,
VORBIS_packet_comment = 3,
VORBIS_packet_setup = 5
};
static int codebook_decode_scalar_raw(vorb *f, Codebook *c)
{
int i;
prep_huffman(f);
if (c->codewords == NULL && c->sorted_codewords == NULL)
return -1;
// cases to use binary search: sorted_codewords && !c->codewords
// sorted_codewords && c->entries > 8
if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) {
// binary search
uint32 code = bit_reverse(f->acc);
int x=0, n=c->sorted_entries, len;
while (n > 1) {
// invariant: sc[x] <= code < sc[x+n]
int m = x + (n >> 1);
if (c->sorted_codewords[m] <= code) {
x = m;
n -= (n>>1);
} else {
n >>= 1;
}
}
// x is now the sorted index
if (!c->sparse) x = c->sorted_values[x];
// x is now sorted index if sparse, or symbol otherwise
len = c->codeword_lengths[x];
if (f->valid_bits >= len) {
f->acc >>= len;
f->valid_bits -= len;
return x;
}
f->valid_bits = 0;
return -1;
}
// if small, linear search
assert(!c->sparse);
for (i=0; i < c->entries; ++i) {
if (c->codeword_lengths[i] == NO_CODE) continue;
if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) {
if (f->valid_bits >= c->codeword_lengths[i]) {
f->acc >>= c->codeword_lengths[i];
f->valid_bits -= c->codeword_lengths[i];
return i;
}
f->valid_bits = 0;
return -1;
}
}
error(f, VORBIS_invalid_stream);
f->valid_bits = 0;
return -1;
}
#ifndef STB_VORBIS_NO_INLINE_DECODE
#define DECODE_RAW(var, f,c) \
if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \
prep_huffman(f); \
var = f->acc & FAST_HUFFMAN_TABLE_MASK; \
var = c->fast_huffman[var]; \
if (var >= 0) { \
int n = c->codeword_lengths[var]; \
f->acc >>= n; \
f->valid_bits -= n; \
if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \
} else { \
var = codebook_decode_scalar_raw(f,c); \
}
#else
static int codebook_decode_scalar(vorb *f, Codebook *c)
{
int i;
if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH)
prep_huffman(f);
// fast huffman table lookup
i = f->acc & FAST_HUFFMAN_TABLE_MASK;
i = c->fast_huffman[i];
if (i >= 0) {
f->acc >>= c->codeword_lengths[i];
f->valid_bits -= c->codeword_lengths[i];
if (f->valid_bits < 0) { f->valid_bits = 0; return -1; }
return i;
}
return codebook_decode_scalar_raw(f,c);
}
#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c);
#endif
#define DECODE(var,f,c) \
DECODE_RAW(var,f,c) \
if (c->sparse) var = c->sorted_values[var];
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
#define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c)
#else
#define DECODE_VQ(var,f,c) DECODE(var,f,c)
#endif
// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case
// where we avoid one addition
#define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off])
#define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off])
#define CODEBOOK_ELEMENT_BASE(c) (0)
static int codebook_decode_start(vorb *f, Codebook *c)
{
int z = -1;
// type 0 is only legal in a scalar context
if (c->lookup_type == 0)
error(f, VORBIS_invalid_stream);
else {
DECODE_VQ(z,f,c);
if (c->sparse) assert(z < c->sorted_entries);
if (z < 0) { // check for EOP
if (!f->bytes_in_seg)
if (f->last_seg)
return z;
error(f, VORBIS_invalid_stream);
}
}
return z;
}
static int codebook_decode(vorb *f, Codebook *c, float *output, int len)
{
int i,z = codebook_decode_start(f,c);
if (z < 0) return FALSE;
if (len > c->dimensions) len = c->dimensions;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
float last = CODEBOOK_ELEMENT_BASE(c);
int div = 1;
for (i=0; i < len; ++i) {
int off = (z / div) % c->lookup_values;
float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
output[i] += val;
if (c->sequence_p) last = val + c->minimum_value;
div *= c->lookup_values;
}
return TRUE;
}
#endif
z *= c->dimensions;
if (c->sequence_p) {
float last = CODEBOOK_ELEMENT_BASE(c);
for (i=0; i < len; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
output[i] += val;
last = val + c->minimum_value;
}
} else {
float last = CODEBOOK_ELEMENT_BASE(c);
for (i=0; i < len; ++i) {
output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last;
}
}
return TRUE;
}
static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step)
{
int i,z = codebook_decode_start(f,c);
float last = CODEBOOK_ELEMENT_BASE(c);
if (z < 0) return FALSE;
if (len > c->dimensions) len = c->dimensions;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int div = 1;
for (i=0; i < len; ++i) {
int off = (z / div) % c->lookup_values;
float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
output[i*step] += val;
if (c->sequence_p) last = val;
div *= c->lookup_values;
}
return TRUE;
}
#endif
z *= c->dimensions;
for (i=0; i < len; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
output[i*step] += val;
if (c->sequence_p) last = val;
}
return TRUE;
}
static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode)
{
int c_inter = *c_inter_p;
int p_inter = *p_inter_p;
int i,z, effective = c->dimensions;
// type 0 is only legal in a scalar context
if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream);
while (total_decode > 0) {
float last = CODEBOOK_ELEMENT_BASE(c);
DECODE_VQ(z,f,c);
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
assert(!c->sparse || z < c->sorted_entries);
#endif
if (z < 0) {
if (!f->bytes_in_seg)
if (f->last_seg) return FALSE;
return error(f, VORBIS_invalid_stream);
}
// if this will take us off the end of the buffers, stop short!
// we check by computing the length of the virtual interleaved
// buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter),
// and the length we'll be using (effective)
if (c_inter + p_inter*ch + effective > len * ch) {
effective = len*ch - (p_inter*ch - c_inter);
}
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int div = 1;
for (i=0; i < effective; ++i) {
int off = (z / div) % c->lookup_values;
float val = CODEBOOK_ELEMENT_FAST(c,off) + last;
if (outputs[c_inter])
outputs[c_inter][p_inter] += val;
if (++c_inter == ch) { c_inter = 0; ++p_inter; }
if (c->sequence_p) last = val;
div *= c->lookup_values;
}
} else
#endif
{
z *= c->dimensions;
if (c->sequence_p) {
for (i=0; i < effective; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
if (outputs[c_inter])
outputs[c_inter][p_inter] += val;
if (++c_inter == ch) { c_inter = 0; ++p_inter; }
last = val;
}
} else {
for (i=0; i < effective; ++i) {
float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last;
if (outputs[c_inter])
outputs[c_inter][p_inter] += val;
if (++c_inter == ch) { c_inter = 0; ++p_inter; }
}
}
}
total_decode -= effective;
}
*c_inter_p = c_inter;
*p_inter_p = p_inter;
return TRUE;
}
static int predict_point(int x, int x0, int x1, int y0, int y1)
{
int dy = y1 - y0;
int adx = x1 - x0;
// @OPTIMIZE: force int division to round in the right direction... is this necessary on x86?
int err = abs(dy) * (x - x0);
int off = err / adx;
return dy < 0 ? y0 - off : y0 + off;
}
// the following table is block-copied from the specification
static float inverse_db_table[256] =
{
1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f,
1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f,
1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f,
2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f,
2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f,
3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f,
4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f,
6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f,
7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f,
1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f,
1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f,
1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f,
2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f,
2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f,
3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f,
4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f,
5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f,
7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f,
9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f,
1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f,
1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f,
2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f,
2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f,
3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f,
4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f,
5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f,
7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f,
9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f,
0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f,
0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f,
0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f,
0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f,
0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f,
0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f,
0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f,
0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f,
0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f,
0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f,
0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f,
0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f,
0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f,
0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f,
0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f,
0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f,
0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f,
0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f,
0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f,
0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f,
0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f,
0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f,
0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f,
0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f,
0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f,
0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f,
0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f,
0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f,
0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f,
0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f,
0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f,
0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f,
0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f,
0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f,
0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f,
0.82788260f, 0.88168307f, 0.9389798f, 1.0f
};
// @OPTIMIZE: if you want to replace this bresenham line-drawing routine,
// note that you must produce bit-identical output to decode correctly;
// this specific sequence of operations is specified in the spec (it's
// drawing integer-quantized frequency-space lines that the encoder
// expects to be exactly the same)
// ... also, isn't the whole point of Bresenham's algorithm to NOT
// have to divide in the setup? sigh.
#ifndef STB_VORBIS_NO_DEFER_FLOOR
#define LINE_OP(a,b) a *= b
#else
#define LINE_OP(a,b) a = b
#endif
#ifdef STB_VORBIS_DIVIDE_TABLE
#define DIVTAB_NUMER 32
#define DIVTAB_DENOM 64
int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB
#endif
static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n)
{
int dy = y1 - y0;
int adx = x1 - x0;
int ady = abs(dy);
int base;
int x=x0,y=y0;
int err = 0;
int sy;
#ifdef STB_VORBIS_DIVIDE_TABLE
if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) {
if (dy < 0) {
base = -integer_divide_table[ady][adx];
sy = base-1;
} else {
base = integer_divide_table[ady][adx];
sy = base+1;
}
} else {
base = dy / adx;
if (dy < 0)
sy = base - 1;
else
sy = base+1;
}
#else
base = dy / adx;
if (dy < 0)
sy = base - 1;
else
sy = base+1;
#endif
ady -= abs(base) * adx;
if (x1 > n) x1 = n;
if (x < x1) {
LINE_OP(output[x], inverse_db_table[y]);
for (++x; x < x1; ++x) {
err += ady;
if (err >= adx) {
err -= adx;
y += sy;
} else
y += base;
LINE_OP(output[x], inverse_db_table[y]);
}
}
}
static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype)
{
int k;
if (rtype == 0) {
int step = n / book->dimensions;
for (k=0; k < step; ++k)
if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step))
return FALSE;
} else {
for (k=0; k < n; ) {
if (!codebook_decode(f, book, target+offset, n-k))
return FALSE;
k += book->dimensions;
offset += book->dimensions;
}
}
return TRUE;
}
// n is 1/2 of the blocksize --
// specification: "Correct per-vector decode length is [n]/2"
static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode)
{
int i,j,pass;
Residue *r = f->residue_config + rn;
int rtype = f->residue_types[rn];
int c = r->classbook;
int classwords = f->codebooks[c].dimensions;
unsigned int actual_size = rtype == 2 ? n*2 : n;
unsigned int limit_r_begin = (r->begin < actual_size ? r->begin : actual_size);
unsigned int limit_r_end = (r->end < actual_size ? r->end : actual_size);
int n_read = limit_r_end - limit_r_begin;
int part_read = n_read / r->part_size;
int temp_alloc_point = temp_alloc_save(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata));
#else
int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications));
#endif
CHECK(f);
for (i=0; i < ch; ++i)
if (!do_not_decode[i])
memset(residue_buffers[i], 0, sizeof(float) * n);
if (rtype == 2 && ch != 1) {
for (j=0; j < ch; ++j)
if (!do_not_decode[j])
break;
if (j == ch)
goto done;
for (pass=0; pass < 8; ++pass) {
int pcount = 0, class_set = 0;
if (ch == 2) {
while (pcount < part_read) {
int z = r->begin + pcount*r->part_size;
int c_inter = (z & 1), p_inter = z>>1;
if (pass == 0) {
Codebook *c = f->codebooks+r->classbook;
int q;
DECODE(q,f,c);
if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[0][i+pcount] = q % r->classifications;
q /= r->classifications;
}
#endif
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
int z = r->begin + pcount*r->part_size;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[0][class_set][i];
#else
int c = classifications[0][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
Codebook *book = f->codebooks + b;
#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
#else
// saves 1%
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
#endif
} else {
z += r->part_size;
c_inter = z & 1;
p_inter = z >> 1;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
} else if (ch == 1) {
while (pcount < part_read) {
int z = r->begin + pcount*r->part_size;
int c_inter = 0, p_inter = z;
if (pass == 0) {
Codebook *c = f->codebooks+r->classbook;
int q;
DECODE(q,f,c);
if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[0][i+pcount] = q % r->classifications;
q /= r->classifications;
}
#endif
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
int z = r->begin + pcount*r->part_size;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[0][class_set][i];
#else
int c = classifications[0][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
Codebook *book = f->codebooks + b;
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
} else {
z += r->part_size;
c_inter = 0;
p_inter = z;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
} else {
while (pcount < part_read) {
int z = r->begin + pcount*r->part_size;
int c_inter = z % ch, p_inter = z/ch;
if (pass == 0) {
Codebook *c = f->codebooks+r->classbook;
int q;
DECODE(q,f,c);
if (q == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[0][class_set] = r->classdata[q];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[0][i+pcount] = q % r->classifications;
q /= r->classifications;
}
#endif
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
int z = r->begin + pcount*r->part_size;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[0][class_set][i];
#else
int c = classifications[0][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
Codebook *book = f->codebooks + b;
if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size))
goto done;
} else {
z += r->part_size;
c_inter = z % ch;
p_inter = z / ch;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
}
}
goto done;
}
CHECK(f);
for (pass=0; pass < 8; ++pass) {
int pcount = 0, class_set=0;
while (pcount < part_read) {
if (pass == 0) {
for (j=0; j < ch; ++j) {
if (!do_not_decode[j]) {
Codebook *c = f->codebooks+r->classbook;
int temp;
DECODE(temp,f,c);
if (temp == EOP) goto done;
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
part_classdata[j][class_set] = r->classdata[temp];
#else
for (i=classwords-1; i >= 0; --i) {
classifications[j][i+pcount] = temp % r->classifications;
temp /= r->classifications;
}
#endif
}
}
}
for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) {
for (j=0; j < ch; ++j) {
if (!do_not_decode[j]) {
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
int c = part_classdata[j][class_set][i];
#else
int c = classifications[j][pcount];
#endif
int b = r->residue_books[c][pass];
if (b >= 0) {
float *target = residue_buffers[j];
int offset = r->begin + pcount * r->part_size;
int n = r->part_size;
Codebook *book = f->codebooks + b;
if (!residue_decode(f, book, target, offset, n, rtype))
goto done;
}
}
}
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
++class_set;
#endif
}
}
done:
CHECK(f);
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
temp_free(f,part_classdata);
#else
temp_free(f,classifications);
#endif
temp_alloc_restore(f,temp_alloc_point);
}
#if 0
// slow way for debugging
void inverse_mdct_slow(float *buffer, int n)
{
int i,j;
int n2 = n >> 1;
float *x = (float *) malloc(sizeof(*x) * n2);
memcpy(x, buffer, sizeof(*x) * n2);
for (i=0; i < n; ++i) {
float acc = 0;
for (j=0; j < n2; ++j)
// formula from paper:
//acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
// formula from wikipedia
//acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
// these are equivalent, except the formula from the paper inverts the multiplier!
// however, what actually works is NO MULTIPLIER!?!
//acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5));
acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1));
buffer[i] = acc;
}
free(x);
}
#elif 0
// same as above, but just barely able to run in real time on modern machines
void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
{
float mcos[16384];
int i,j;
int n2 = n >> 1, nmask = (n << 2) -1;
float *x = (float *) malloc(sizeof(*x) * n2);
memcpy(x, buffer, sizeof(*x) * n2);
for (i=0; i < 4*n; ++i)
mcos[i] = (float) cos(M_PI / 2 * i / n);
for (i=0; i < n; ++i) {
float acc = 0;
for (j=0; j < n2; ++j)
acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask];
buffer[i] = acc;
}
free(x);
}
#elif 0
// transform to use a slow dct-iv; this is STILL basically trivial,
// but only requires half as many ops
void dct_iv_slow(float *buffer, int n)
{
float mcos[16384];
float x[2048];
int i,j;
int n2 = n >> 1, nmask = (n << 3) - 1;
memcpy(x, buffer, sizeof(*x) * n);
for (i=0; i < 8*n; ++i)
mcos[i] = (float) cos(M_PI / 4 * i / n);
for (i=0; i < n; ++i) {
float acc = 0;
for (j=0; j < n; ++j)
acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask];
buffer[i] = acc;
}
}
void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype)
{
int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4;
float temp[4096];
memcpy(temp, buffer, n2 * sizeof(float));
dct_iv_slow(temp, n2); // returns -c'-d, a-b'
for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b'
for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d'
for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d
}
#endif
#ifndef LIBVORBIS_MDCT
#define LIBVORBIS_MDCT 0
#endif
#if LIBVORBIS_MDCT
// directly call the vorbis MDCT using an interface documented
// by Jeff Roberts... useful for performance comparison
typedef struct
{
int n;
int log2n;
float *trig;
int *bitrev;
float scale;
} mdct_lookup;
extern void mdct_init(mdct_lookup *lookup, int n);
extern void mdct_clear(mdct_lookup *l);
extern void mdct_backward(mdct_lookup *init, float *in, float *out);
mdct_lookup M1,M2;
void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
{
mdct_lookup *M;
if (M1.n == n) M = &M1;
else if (M2.n == n) M = &M2;
else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; }
else {
if (M2.n) __asm int 3;
mdct_init(&M2, n);
M = &M2;
}
mdct_backward(M, buffer, buffer);
}
#endif
// the following were split out into separate functions while optimizing;
// they could be pushed back up but eh. __forceinline showed no change;
// they're probably already being inlined.
static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A)
{
float *ee0 = e + i_off;
float *ee2 = ee0 + k_off;
int i;
assert((n & 3) == 0);
for (i=(n>>2); i > 0; --i) {
float k00_20, k01_21;
k00_20 = ee0[ 0] - ee2[ 0];
k01_21 = ee0[-1] - ee2[-1];
ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0];
ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1];
ee2[ 0] = k00_20 * A[0] - k01_21 * A[1];
ee2[-1] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
k00_20 = ee0[-2] - ee2[-2];
k01_21 = ee0[-3] - ee2[-3];
ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2];
ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3];
ee2[-2] = k00_20 * A[0] - k01_21 * A[1];
ee2[-3] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
k00_20 = ee0[-4] - ee2[-4];
k01_21 = ee0[-5] - ee2[-5];
ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4];
ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5];
ee2[-4] = k00_20 * A[0] - k01_21 * A[1];
ee2[-5] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
k00_20 = ee0[-6] - ee2[-6];
k01_21 = ee0[-7] - ee2[-7];
ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6];
ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7];
ee2[-6] = k00_20 * A[0] - k01_21 * A[1];
ee2[-7] = k01_21 * A[0] + k00_20 * A[1];
A += 8;
ee0 -= 8;
ee2 -= 8;
}
}
static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1)
{
int i;
float k00_20, k01_21;
float *e0 = e + d0;
float *e2 = e0 + k_off;
for (i=lim >> 2; i > 0; --i) {
k00_20 = e0[-0] - e2[-0];
k01_21 = e0[-1] - e2[-1];
e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0];
e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1];
e2[-0] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-1] = (k01_21)*A[0] + (k00_20) * A[1];
A += k1;
k00_20 = e0[-2] - e2[-2];
k01_21 = e0[-3] - e2[-3];
e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2];
e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3];
e2[-2] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-3] = (k01_21)*A[0] + (k00_20) * A[1];
A += k1;
k00_20 = e0[-4] - e2[-4];
k01_21 = e0[-5] - e2[-5];
e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4];
e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5];
e2[-4] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-5] = (k01_21)*A[0] + (k00_20) * A[1];
A += k1;
k00_20 = e0[-6] - e2[-6];
k01_21 = e0[-7] - e2[-7];
e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6];
e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7];
e2[-6] = (k00_20)*A[0] - (k01_21) * A[1];
e2[-7] = (k01_21)*A[0] + (k00_20) * A[1];
e0 -= 8;
e2 -= 8;
A += k1;
}
}
static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0)
{
int i;
float A0 = A[0];
float A1 = A[0+1];
float A2 = A[0+a_off];
float A3 = A[0+a_off+1];
float A4 = A[0+a_off*2+0];
float A5 = A[0+a_off*2+1];
float A6 = A[0+a_off*3+0];
float A7 = A[0+a_off*3+1];
float k00,k11;
float *ee0 = e +i_off;
float *ee2 = ee0+k_off;
for (i=n; i > 0; --i) {
k00 = ee0[ 0] - ee2[ 0];
k11 = ee0[-1] - ee2[-1];
ee0[ 0] = ee0[ 0] + ee2[ 0];
ee0[-1] = ee0[-1] + ee2[-1];
ee2[ 0] = (k00) * A0 - (k11) * A1;
ee2[-1] = (k11) * A0 + (k00) * A1;
k00 = ee0[-2] - ee2[-2];
k11 = ee0[-3] - ee2[-3];
ee0[-2] = ee0[-2] + ee2[-2];
ee0[-3] = ee0[-3] + ee2[-3];
ee2[-2] = (k00) * A2 - (k11) * A3;
ee2[-3] = (k11) * A2 + (k00) * A3;
k00 = ee0[-4] - ee2[-4];
k11 = ee0[-5] - ee2[-5];
ee0[-4] = ee0[-4] + ee2[-4];
ee0[-5] = ee0[-5] + ee2[-5];
ee2[-4] = (k00) * A4 - (k11) * A5;
ee2[-5] = (k11) * A4 + (k00) * A5;
k00 = ee0[-6] - ee2[-6];
k11 = ee0[-7] - ee2[-7];
ee0[-6] = ee0[-6] + ee2[-6];
ee0[-7] = ee0[-7] + ee2[-7];
ee2[-6] = (k00) * A6 - (k11) * A7;
ee2[-7] = (k11) * A6 + (k00) * A7;
ee0 -= k0;
ee2 -= k0;
}
}
static __forceinline void iter_54(float *z)
{
float k00,k11,k22,k33;
float y0,y1,y2,y3;
k00 = z[ 0] - z[-4];
y0 = z[ 0] + z[-4];
y2 = z[-2] + z[-6];
k22 = z[-2] - z[-6];
z[-0] = y0 + y2; // z0 + z4 + z2 + z6
z[-2] = y0 - y2; // z0 + z4 - z2 - z6
// done with y0,y2
k33 = z[-3] - z[-7];
z[-4] = k00 + k33; // z0 - z4 + z3 - z7
z[-6] = k00 - k33; // z0 - z4 - z3 + z7
// done with k33
k11 = z[-1] - z[-5];
y1 = z[-1] + z[-5];
y3 = z[-3] + z[-7];
z[-1] = y1 + y3; // z1 + z5 + z3 + z7
z[-3] = y1 - y3; // z1 + z5 - z3 - z7
z[-5] = k11 - k22; // z1 - z5 + z2 - z6
z[-7] = k11 + k22; // z1 - z5 - z2 + z6
}
static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n)
{
int a_off = base_n >> 3;
float A2 = A[0+a_off];
float *z = e + i_off;
float *base = z - 16 * n;
while (z > base) {
float k00,k11;
k00 = z[-0] - z[-8];
k11 = z[-1] - z[-9];
z[-0] = z[-0] + z[-8];
z[-1] = z[-1] + z[-9];
z[-8] = k00;
z[-9] = k11 ;
k00 = z[ -2] - z[-10];
k11 = z[ -3] - z[-11];
z[ -2] = z[ -2] + z[-10];
z[ -3] = z[ -3] + z[-11];
z[-10] = (k00+k11) * A2;
z[-11] = (k11-k00) * A2;
k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation
k11 = z[ -5] - z[-13];
z[ -4] = z[ -4] + z[-12];
z[ -5] = z[ -5] + z[-13];
z[-12] = k11;
z[-13] = k00;
k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation
k11 = z[ -7] - z[-15];
z[ -6] = z[ -6] + z[-14];
z[ -7] = z[ -7] + z[-15];
z[-14] = (k00+k11) * A2;
z[-15] = (k00-k11) * A2;
iter_54(z);
iter_54(z-8);
z -= 16;
}
}
static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype)
{
int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
int ld;
// @OPTIMIZE: reduce register pressure by using fewer variables?
int save_point = temp_alloc_save(f);
float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2));
float *u=NULL,*v=NULL;
// twiddle factors
float *A = f->A[blocktype];
// IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
// See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function.
// kernel from paper
// merged:
// copy and reflect spectral data
// step 0
// note that it turns out that the items added together during
// this step are, in fact, being added to themselves (as reflected
// by step 0). inexplicable inefficiency! this became obvious
// once I combined the passes.
// so there's a missing 'times 2' here (for adding X to itself).
// this propogates through linearly to the end, where the numbers
// are 1/2 too small, and need to be compensated for.
{
float *d,*e, *AA, *e_stop;
d = &buf2[n2-2];
AA = A;
e = &buffer[0];
e_stop = &buffer[n2];
while (e != e_stop) {
d[1] = (e[0] * AA[0] - e[2]*AA[1]);
d[0] = (e[0] * AA[1] + e[2]*AA[0]);
d -= 2;
AA += 2;
e += 4;
}
e = &buffer[n2-3];
while (d >= buf2) {
d[1] = (-e[2] * AA[0] - -e[0]*AA[1]);
d[0] = (-e[2] * AA[1] + -e[0]*AA[0]);
d -= 2;
AA += 2;
e -= 4;
}
}
// now we use symbolic names for these, so that we can
// possibly swap their meaning as we change which operations
// are in place
u = buffer;
v = buf2;
// step 2 (paper output is w, now u)
// this could be in place, but the data ends up in the wrong
// place... _somebody_'s got to swap it, so this is nominated
{
float *AA = &A[n2-8];
float *d0,*d1, *e0, *e1;
e0 = &v[n4];
e1 = &v[0];
d0 = &u[n4];
d1 = &u[0];
while (AA >= A) {
float v40_20, v41_21;
v41_21 = e0[1] - e1[1];
v40_20 = e0[0] - e1[0];
d0[1] = e0[1] + e1[1];
d0[0] = e0[0] + e1[0];
d1[1] = v41_21*AA[4] - v40_20*AA[5];
d1[0] = v40_20*AA[4] + v41_21*AA[5];
v41_21 = e0[3] - e1[3];
v40_20 = e0[2] - e1[2];
d0[3] = e0[3] + e1[3];
d0[2] = e0[2] + e1[2];
d1[3] = v41_21*AA[0] - v40_20*AA[1];
d1[2] = v40_20*AA[0] + v41_21*AA[1];
AA -= 8;
d0 += 4;
d1 += 4;
e0 += 4;
e1 += 4;
}
}
// step 3
ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
// optimized step 3:
// the original step3 loop can be nested r inside s or s inside r;
// it's written originally as s inside r, but this is dumb when r
// iterates many times, and s few. So I have two copies of it and
// switch between them halfway.
// this is iteration 0 of step 3
imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A);
imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A);
// this is iteration 1 of step 3
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16);
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16);
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16);
imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16);
l=2;
for (; l < (ld-3)>>1; ++l) {
int k0 = n >> (l+2), k0_2 = k0>>1;
int lim = 1 << (l+1);
int i;
for (i=0; i < lim; ++i)
imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3));
}
for (; l < ld-6; ++l) {
int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1;
int rlim = n >> (l+6), r;
int lim = 1 << (l+1);
int i_off;
float *A0 = A;
i_off = n2-1;
for (r=rlim; r > 0; --r) {
imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0);
A0 += k1*4;
i_off -= 8;
}
}
// iterations with count:
// ld-6,-5,-4 all interleaved together
// the big win comes from getting rid of needless flops
// due to the constants on pass 5 & 4 being all 1 and 0;
// combining them to be simultaneous to improve cache made little difference
imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n);
// output is u
// step 4, 5, and 6
// cannot be in-place because of step 5
{
uint16 *bitrev = f->bit_reverse[blocktype];
// weirdly, I'd have thought reading sequentially and writing
// erratically would have been better than vice-versa, but in
// fact that's not what my testing showed. (That is, with
// j = bitreverse(i), do you read i and write j, or read j and write i.)
float *d0 = &v[n4-4];
float *d1 = &v[n2-4];
while (d0 >= v) {
int k4;
k4 = bitrev[0];
d1[3] = u[k4+0];
d1[2] = u[k4+1];
d0[3] = u[k4+2];
d0[2] = u[k4+3];
k4 = bitrev[1];
d1[1] = u[k4+0];
d1[0] = u[k4+1];
d0[1] = u[k4+2];
d0[0] = u[k4+3];
d0 -= 4;
d1 -= 4;
bitrev += 2;
}
}
// (paper output is u, now v)
// data must be in buf2
assert(v == buf2);
// step 7 (paper output is v, now v)
// this is now in place
{
float *C = f->C[blocktype];
float *d, *e;
d = v;
e = v + n2 - 4;
while (d < e) {
float a02,a11,b0,b1,b2,b3;
a02 = d[0] - e[2];
a11 = d[1] + e[3];
b0 = C[1]*a02 + C[0]*a11;
b1 = C[1]*a11 - C[0]*a02;
b2 = d[0] + e[ 2];
b3 = d[1] - e[ 3];
d[0] = b2 + b0;
d[1] = b3 + b1;
e[2] = b2 - b0;
e[3] = b1 - b3;
a02 = d[2] - e[0];
a11 = d[3] + e[1];
b0 = C[3]*a02 + C[2]*a11;
b1 = C[3]*a11 - C[2]*a02;
b2 = d[2] + e[ 0];
b3 = d[3] - e[ 1];
d[2] = b2 + b0;
d[3] = b3 + b1;
e[0] = b2 - b0;
e[1] = b1 - b3;
C += 4;
d += 4;
e -= 4;
}
}
// data must be in buf2
// step 8+decode (paper output is X, now buffer)
// this generates pairs of data a la 8 and pushes them directly through
// the decode kernel (pushing rather than pulling) to avoid having
// to make another pass later
// this cannot POSSIBLY be in place, so we refer to the buffers directly
{
float *d0,*d1,*d2,*d3;
float *B = f->B[blocktype] + n2 - 8;
float *e = buf2 + n2 - 8;
d0 = &buffer[0];
d1 = &buffer[n2-4];
d2 = &buffer[n2];
d3 = &buffer[n-4];
while (e >= v) {
float p0,p1,p2,p3;
p3 = e[6]*B[7] - e[7]*B[6];
p2 = -e[6]*B[6] - e[7]*B[7];
d0[0] = p3;
d1[3] = - p3;
d2[0] = p2;
d3[3] = p2;
p1 = e[4]*B[5] - e[5]*B[4];
p0 = -e[4]*B[4] - e[5]*B[5];
d0[1] = p1;
d1[2] = - p1;
d2[1] = p0;
d3[2] = p0;
p3 = e[2]*B[3] - e[3]*B[2];
p2 = -e[2]*B[2] - e[3]*B[3];
d0[2] = p3;
d1[1] = - p3;
d2[2] = p2;
d3[1] = p2;
p1 = e[0]*B[1] - e[1]*B[0];
p0 = -e[0]*B[0] - e[1]*B[1];
d0[3] = p1;
d1[0] = - p1;
d2[3] = p0;
d3[0] = p0;
B -= 8;
e -= 8;
d0 += 4;
d2 += 4;
d1 -= 4;
d3 -= 4;
}
}
temp_free(f,buf2);
temp_alloc_restore(f,save_point);
}
#if 0
// this is the original version of the above code, if you want to optimize it from scratch
void inverse_mdct_naive(float *buffer, int n)
{
float s;
float A[1 << 12], B[1 << 12], C[1 << 11];
int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l;
int n3_4 = n - n4, ld;
// how can they claim this only uses N words?!
// oh, because they're only used sparsely, whoops
float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13];
// set up twiddle factors
for (k=k2=0; k < n4; ++k,k2+=2) {
A[k2 ] = (float) cos(4*k*M_PI/n);
A[k2+1] = (float) -sin(4*k*M_PI/n);
B[k2 ] = (float) cos((k2+1)*M_PI/n/2);
B[k2+1] = (float) sin((k2+1)*M_PI/n/2);
}
for (k=k2=0; k < n8; ++k,k2+=2) {
C[k2 ] = (float) cos(2*(k2+1)*M_PI/n);
C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n);
}
// IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio"
// Note there are bugs in that pseudocode, presumably due to them attempting
// to rename the arrays nicely rather than representing the way their actual
// implementation bounces buffers back and forth. As a result, even in the
// "some formulars corrected" version, a direct implementation fails. These
// are noted below as "paper bug".
// copy and reflect spectral data
for (k=0; k < n2; ++k) u[k] = buffer[k];
for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1];
// kernel from paper
// step 1
for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) {
v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1];
v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2];
}
// step 2
for (k=k4=0; k < n8; k+=1, k4+=4) {
w[n2+3+k4] = v[n2+3+k4] + v[k4+3];
w[n2+1+k4] = v[n2+1+k4] + v[k4+1];
w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4];
w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4];
}
// step 3
ld = ilog(n) - 1; // ilog is off-by-one from normal definitions
for (l=0; l < ld-3; ++l) {
int k0 = n >> (l+2), k1 = 1 << (l+3);
int rlim = n >> (l+4), r4, r;
int s2lim = 1 << (l+2), s2;
for (r=r4=0; r < rlim; r4+=4,++r) {
for (s2=0; s2 < s2lim; s2+=2) {
u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4];
u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4];
u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1]
- (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1];
u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1]
+ (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1];
}
}
if (l+1 < ld-3) {
// paper bug: ping-ponging of u&w here is omitted
memcpy(w, u, sizeof(u));
}
}
// step 4
for (i=0; i < n8; ++i) {
int j = bit_reverse(i) >> (32-ld+3);
assert(j < n8);
if (i == j) {
// paper bug: original code probably swapped in place; if copying,
// need to directly copy in this case
int i8 = i << 3;
v[i8+1] = u[i8+1];
v[i8+3] = u[i8+3];
v[i8+5] = u[i8+5];
v[i8+7] = u[i8+7];
} else if (i < j) {
int i8 = i << 3, j8 = j << 3;
v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1];
v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3];
v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5];
v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7];
}
}
// step 5
for (k=0; k < n2; ++k) {
w[k] = v[k*2+1];
}
// step 6
for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) {
u[n-1-k2] = w[k4];
u[n-2-k2] = w[k4+1];
u[n3_4 - 1 - k2] = w[k4+2];
u[n3_4 - 2 - k2] = w[k4+3];
}
// step 7
for (k=k2=0; k < n8; ++k, k2 += 2) {
v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2;
v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2;
}
// step 8
for (k=k2=0; k < n4; ++k,k2 += 2) {
X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1];
X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ];
}
// decode kernel to output
// determined the following value experimentally
// (by first figuring out what made inverse_mdct_slow work); then matching that here
// (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?)
s = 0.5; // theoretically would be n4
// [[[ note! the s value of 0.5 is compensated for by the B[] in the current code,
// so it needs to use the "old" B values to behave correctly, or else
// set s to 1.0 ]]]
for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4];
for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1];
for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4];
}
#endif
static float *get_window(vorb *f, int len)
{
len <<= 1;
if (len == f->blocksize_0) return f->window[0];
if (len == f->blocksize_1) return f->window[1];
assert(0);
return NULL;
}
#ifndef STB_VORBIS_NO_DEFER_FLOOR
typedef int16 YTYPE;
#else
typedef int YTYPE;
#endif
static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag)
{
int n2 = n >> 1;
int s = map->chan[i].mux, floor;
floor = map->submap_floor[s];
if (f->floor_types[floor] == 0) {
return error(f, VORBIS_invalid_stream);
} else {
Floor1 *g = &f->floor_config[floor].floor1;
int j,q;
int lx = 0, ly = finalY[0] * g->floor1_multiplier;
for (q=1; q < g->values; ++q) {
j = g->sorted_order[q];
#ifndef STB_VORBIS_NO_DEFER_FLOOR
if (finalY[j] >= 0)
#else
if (step2_flag[j])
#endif
{
int hy = finalY[j] * g->floor1_multiplier;
int hx = g->Xlist[j];
if (lx != hx)
draw_line(target, lx,ly, hx,hy, n2);
CHECK(f);
lx = hx, ly = hy;
}
}
if (lx < n2) {
// optimization of: draw_line(target, lx,ly, n,ly, n2);
for (j=lx; j < n2; ++j)
LINE_OP(target[j], inverse_db_table[ly]);
CHECK(f);
}
}
return TRUE;
}
// The meaning of "left" and "right"
//
// For a given frame:
// we compute samples from 0..n
// window_center is n/2
// we'll window and mix the samples from left_start to left_end with data from the previous frame
// all of the samples from left_end to right_start can be output without mixing; however,
// this interval is 0-length except when transitioning between short and long frames
// all of the samples from right_start to right_end need to be mixed with the next frame,
// which we don't have, so those get saved in a buffer
// frame N's right_end-right_start, the number of samples to mix with the next frame,
// has to be the same as frame N+1's left_end-left_start (which they are by
// construction)
static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
{
Mode *m;
int i, n, prev, next, window_center;
f->channel_buffer_start = f->channel_buffer_end = 0;
retry:
if (f->eof) return FALSE;
if (!maybe_start_packet(f))
return FALSE;
// check packet type
if (get_bits(f,1) != 0) {
if (IS_PUSH_MODE(f))
return error(f,VORBIS_bad_packet_type);
while (EOP != get8_packet(f));
goto retry;
}
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
i = get_bits(f, ilog(f->mode_count-1));
if (i == EOP) return FALSE;
if (i >= f->mode_count) return FALSE;
*mode = i;
m = f->mode_config + i;
if (m->blockflag) {
n = f->blocksize_1;
prev = get_bits(f,1);
next = get_bits(f,1);
} else {
prev = next = 0;
n = f->blocksize_0;
}
// WINDOWING
window_center = n >> 1;
if (m->blockflag && !prev) {
*p_left_start = (n - f->blocksize_0) >> 2;
*p_left_end = (n + f->blocksize_0) >> 2;
} else {
*p_left_start = 0;
*p_left_end = window_center;
}
if (m->blockflag && !next) {
*p_right_start = (n*3 - f->blocksize_0) >> 2;
*p_right_end = (n*3 + f->blocksize_0) >> 2;
} else {
*p_right_start = window_center;
*p_right_end = n;
}
return TRUE;
}
static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left)
{
Mapping *map;
int i,j,k,n,n2;
int zero_channel[256];
int really_zero_channel[256];
// WINDOWING
n = f->blocksize[m->blockflag];
map = &f->mapping[m->mapping];
// FLOORS
n2 = n >> 1;
CHECK(f);
for (i=0; i < f->channels; ++i) {
int s = map->chan[i].mux, floor;
zero_channel[i] = FALSE;
floor = map->submap_floor[s];
if (f->floor_types[floor] == 0) {
return error(f, VORBIS_invalid_stream);
} else {
Floor1 *g = &f->floor_config[floor].floor1;
if (get_bits(f, 1)) {
short *finalY;
uint8 step2_flag[256];
static int range_list[4] = { 256, 128, 86, 64 };
int range = range_list[g->floor1_multiplier-1];
int offset = 2;
finalY = f->finalY[i];
finalY[0] = get_bits(f, ilog(range)-1);
finalY[1] = get_bits(f, ilog(range)-1);
for (j=0; j < g->partitions; ++j) {
int pclass = g->partition_class_list[j];
int cdim = g->class_dimensions[pclass];
int cbits = g->class_subclasses[pclass];
int csub = (1 << cbits)-1;
int cval = 0;
if (cbits) {
Codebook *c = f->codebooks + g->class_masterbooks[pclass];
DECODE(cval,f,c);
}
for (k=0; k < cdim; ++k) {
int book = g->subclass_books[pclass][cval & csub];
cval = cval >> cbits;
if (book >= 0) {
int temp;
Codebook *c = f->codebooks + book;
DECODE(temp,f,c);
finalY[offset++] = temp;
} else
finalY[offset++] = 0;
}
}
if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec
step2_flag[0] = step2_flag[1] = 1;
for (j=2; j < g->values; ++j) {
int low, high, pred, highroom, lowroom, room, val;
low = g->neighbors[j][0];
high = g->neighbors[j][1];
//neighbors(g->Xlist, j, &low, &high);
pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]);
val = finalY[j];
highroom = range - pred;
lowroom = pred;
if (highroom < lowroom)
room = highroom * 2;
else
room = lowroom * 2;
if (val) {
step2_flag[low] = step2_flag[high] = 1;
step2_flag[j] = 1;
if (val >= room)
if (highroom > lowroom)
finalY[j] = val - lowroom + pred;
else
finalY[j] = pred - val + highroom - 1;
else
if (val & 1)
finalY[j] = pred - ((val+1)>>1);
else
finalY[j] = pred + (val>>1);
} else {
step2_flag[j] = 0;
finalY[j] = pred;
}
}
#ifdef STB_VORBIS_NO_DEFER_FLOOR
do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag);
#else
// defer final floor computation until _after_ residue
for (j=0; j < g->values; ++j) {
if (!step2_flag[j])
finalY[j] = -1;
}
#endif
} else {
error:
zero_channel[i] = TRUE;
}
// So we just defer everything else to later
// at this point we've decoded the floor into buffer
}
}
CHECK(f);
// at this point we've decoded all floors
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
// re-enable coupled channels if necessary
memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels);
for (i=0; i < map->coupling_steps; ++i)
if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) {
zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE;
}
CHECK(f);
// RESIDUE DECODE
for (i=0; i < map->submaps; ++i) {
float *residue_buffers[STB_VORBIS_MAX_CHANNELS];
int r;
uint8 do_not_decode[256];
int ch = 0;
for (j=0; j < f->channels; ++j) {
if (map->chan[j].mux == i) {
if (zero_channel[j]) {
do_not_decode[ch] = TRUE;
residue_buffers[ch] = NULL;
} else {
do_not_decode[ch] = FALSE;
residue_buffers[ch] = f->channel_buffers[j];
}
++ch;
}
}
r = map->submap_residue[i];
decode_residue(f, residue_buffers, ch, n2, r, do_not_decode);
}
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
CHECK(f);
// INVERSE COUPLING
for (i = map->coupling_steps-1; i >= 0; --i) {
int n2 = n >> 1;
float *m = f->channel_buffers[map->chan[i].magnitude];
float *a = f->channel_buffers[map->chan[i].angle ];
for (j=0; j < n2; ++j) {
float a2,m2;
if (m[j] > 0)
if (a[j] > 0)
m2 = m[j], a2 = m[j] - a[j];
else
a2 = m[j], m2 = m[j] + a[j];
else
if (a[j] > 0)
m2 = m[j], a2 = m[j] + a[j];
else
a2 = m[j], m2 = m[j] - a[j];
m[j] = m2;
a[j] = a2;
}
}
CHECK(f);
// finish decoding the floors
#ifndef STB_VORBIS_NO_DEFER_FLOOR
for (i=0; i < f->channels; ++i) {
if (really_zero_channel[i]) {
memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
} else {
do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL);
}
}
#else
for (i=0; i < f->channels; ++i) {
if (really_zero_channel[i]) {
memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2);
} else {
for (j=0; j < n2; ++j)
f->channel_buffers[i][j] *= f->floor_buffers[i][j];
}
}
#endif
// INVERSE MDCT
CHECK(f);
for (i=0; i < f->channels; ++i)
inverse_mdct(f->channel_buffers[i], n, f, m->blockflag);
CHECK(f);
// this shouldn't be necessary, unless we exited on an error
// and want to flush to get to the next packet
flush_packet(f);
if (f->first_decode) {
// assume we start so first non-discarded sample is sample 0
// this isn't to spec, but spec would require us to read ahead
// and decode the size of all current frames--could be done,
// but presumably it's not a commonly used feature
f->current_loc = -n2; // start of first frame is positioned for discard
// we might have to discard samples "from" the next frame too,
// if we're lapping a large block then a small at the start?
f->discard_samples_deferred = n - right_end;
f->current_loc_valid = TRUE;
f->first_decode = FALSE;
} else if (f->discard_samples_deferred) {
if (f->discard_samples_deferred >= right_start - left_start) {
f->discard_samples_deferred -= (right_start - left_start);
left_start = right_start;
*p_left = left_start;
} else {
left_start += f->discard_samples_deferred;
*p_left = left_start;
f->discard_samples_deferred = 0;
}
} else if (f->previous_length == 0 && f->current_loc_valid) {
// we're recovering from a seek... that means we're going to discard
// the samples from this packet even though we know our position from
// the last page header, so we need to update the position based on
// the discarded samples here
// but wait, the code below is going to add this in itself even
// on a discard, so we don't need to do it here...
}
// check if we have ogg information about the sample # for this packet
if (f->last_seg_which == f->end_seg_with_known_loc) {
// if we have a valid current loc, and this is final:
if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) {
uint32 current_end = f->known_loc_for_packet;
// then let's infer the size of the (probably) short final frame
if (current_end < f->current_loc + (right_end-left_start)) {
if (current_end < f->current_loc) {
// negative truncation, that's impossible!
*len = 0;
} else {
*len = current_end - f->current_loc;
}
*len += left_start; // this doesn't seem right, but has no ill effect on my test files
if (*len > right_end) *len = right_end; // this should never happen
f->current_loc += *len;
return TRUE;
}
}
// otherwise, just set our sample loc
// guess that the ogg granule pos refers to the _middle_ of the
// last frame?
// set f->current_loc to the position of left_start
f->current_loc = f->known_loc_for_packet - (n2-left_start);
f->current_loc_valid = TRUE;
}
if (f->current_loc_valid)
f->current_loc += (right_start - left_start);
if (f->alloc.alloc_buffer)
assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset);
*len = right_end; // ignore samples after the window goes to 0
CHECK(f);
return TRUE;
}
static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right)
{
int mode, left_end, right_end;
if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0;
return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left);
}
static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right)
{
int prev,i,j;
// we use right&left (the start of the right- and left-window sin()-regions)
// to determine how much to return, rather than inferring from the rules
// (same result, clearer code); 'left' indicates where our sin() window
// starts, therefore where the previous window's right edge starts, and
// therefore where to start mixing from the previous buffer. 'right'
// indicates where our sin() ending-window starts, therefore that's where
// we start saving, and where our returned-data ends.
// mixin from previous window
if (f->previous_length) {
int i,j, n = f->previous_length;
float *w = get_window(f, n);
for (i=0; i < f->channels; ++i) {
for (j=0; j < n; ++j)
f->channel_buffers[i][left+j] =
f->channel_buffers[i][left+j]*w[ j] +
f->previous_window[i][ j]*w[n-1-j];
}
}
prev = f->previous_length;
// last half of this data becomes previous window
f->previous_length = len - right;
// @OPTIMIZE: could avoid this copy by double-buffering the
// output (flipping previous_window with channel_buffers), but
// then previous_window would have to be 2x as large, and
// channel_buffers couldn't be temp mem (although they're NOT
// currently temp mem, they could be (unless we want to level
// performance by spreading out the computation))
for (i=0; i < f->channels; ++i)
for (j=0; right+j < len; ++j)
f->previous_window[i][j] = f->channel_buffers[i][right+j];
if (!prev)
// there was no previous packet, so this data isn't valid...
// this isn't entirely true, only the would-have-overlapped data
// isn't valid, but this seems to be what the spec requires
return 0;
// truncate a short frame
if (len < right) right = len;
f->samples_output += right-left;
return right - left;
}
static int vorbis_pump_first_frame(stb_vorbis *f)
{
int len, right, left, res;
res = vorbis_decode_packet(f, &len, &left, &right);
if (res)
vorbis_finish_frame(f, len, left, right);
return res;
}
#ifndef STB_VORBIS_NO_PUSHDATA_API
static int is_whole_packet_present(stb_vorbis *f, int end_page)
{
// make sure that we have the packet available before continuing...
// this requires a full ogg parse, but we know we can fetch from f->stream
// instead of coding this out explicitly, we could save the current read state,
// read the next packet with get8() until end-of-packet, check f->eof, then
// reset the state? but that would be slower, esp. since we'd have over 256 bytes
// of state to restore (primarily the page segment table)
int s = f->next_seg, first = TRUE;
uint8 *p = f->stream;
if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag
for (; s < f->segment_count; ++s) {
p += f->segments[s];
if (f->segments[s] < 255) // stop at first short segment
break;
}
// either this continues, or it ends it...
if (end_page)
if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream);
if (s == f->segment_count)
s = -1; // set 'crosses page' flag
if (p > f->stream_end) return error(f, VORBIS_need_more_data);
first = FALSE;
}
for (; s == -1;) {
uint8 *q;
int n;
// check that we have the page header ready
if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data);
// validate the page
if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream);
if (p[4] != 0) return error(f, VORBIS_invalid_stream);
if (first) { // the first segment must NOT have 'continued_packet', later ones MUST
if (f->previous_length)
if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream);
// if no previous length, we're resynching, so we can come in on a continued-packet,
// which we'll just drop
} else {
if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream);
}
n = p[26]; // segment counts
q = p+27; // q points to segment table
p = q + n; // advance past header
// make sure we've read the segment table
if (p > f->stream_end) return error(f, VORBIS_need_more_data);
for (s=0; s < n; ++s) {
p += q[s];
if (q[s] < 255)
break;
}
if (end_page)
if (s < n-1) return error(f, VORBIS_invalid_stream);
if (s == n)
s = -1; // set 'crosses page' flag
if (p > f->stream_end) return error(f, VORBIS_need_more_data);
first = FALSE;
}
return TRUE;
}
#endif // !STB_VORBIS_NO_PUSHDATA_API
static int start_decoder(vorb *f)
{
uint8 header[6], x,y;
int len,i,j,k, max_submaps = 0;
int longest_floorlist=0;
// first page, first packet
if (!start_page(f)) return FALSE;
// validate page flag
if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page);
if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page);
if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page);
// check for expected packet length
if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page);
if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page);
// read packet
// check packet header
if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);
if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page);
// vorbis_version
if (get32(f) != 0) return error(f, VORBIS_invalid_first_page);
f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page);
if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels);
f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page);
get32(f); // bitrate_maximum
get32(f); // bitrate_nominal
get32(f); // bitrate_minimum
x = get8(f);
{
int log0,log1;
log0 = x & 15;
log1 = x >> 4;
f->blocksize_0 = 1 << log0;
f->blocksize_1 = 1 << log1;
if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup);
if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup);
if (log0 > log1) return error(f, VORBIS_invalid_setup);
}
// framing_flag
x = get8(f);
if (!(x & 1)) return error(f, VORBIS_invalid_first_page);
// second packet!
if (!start_page(f)) return FALSE;
if (!start_packet(f)) return FALSE;
do {
len = next_segment(f);
skip(f, len);
f->bytes_in_seg = 0;
} while (len);
// third packet!
if (!start_packet(f)) return FALSE;
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (IS_PUSH_MODE(f)) {
if (!is_whole_packet_present(f, TRUE)) {
// convert error in ogg header to write type
if (f->error == VORBIS_invalid_stream)
f->error = VORBIS_invalid_setup;
return FALSE;
}
}
#endif
crc32_init(); // always init it, to avoid multithread race conditions
if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup);
for (i=0; i < 6; ++i) header[i] = get8_packet(f);
if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup);
// codebooks
f->codebook_count = get_bits(f,8) + 1;
f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count);
if (f->codebooks == NULL) return error(f, VORBIS_outofmem);
memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count);
for (i=0; i < f->codebook_count; ++i) {
uint32 *values;
int ordered, sorted_count;
int total=0;
uint8 *lengths;
Codebook *c = f->codebooks+i;
CHECK(f);
x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup);
x = get_bits(f, 8);
c->dimensions = (get_bits(f, 8)<<8) + x;
x = get_bits(f, 8);
y = get_bits(f, 8);
c->entries = (get_bits(f, 8)<<16) + (y<<8) + x;
ordered = get_bits(f,1);
c->sparse = ordered ? 0 : get_bits(f,1);
if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup);
if (c->sparse)
lengths = (uint8 *) setup_temp_malloc(f, c->entries);
else
lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
if (!lengths) return error(f, VORBIS_outofmem);
if (ordered) {
int current_entry = 0;
int current_length = get_bits(f,5) + 1;
while (current_entry < c->entries) {
int limit = c->entries - current_entry;
int n = get_bits(f, ilog(limit));
if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); }
memset(lengths + current_entry, current_length, n);
current_entry += n;
++current_length;
}
} else {
for (j=0; j < c->entries; ++j) {
int present = c->sparse ? get_bits(f,1) : 1;
if (present) {
lengths[j] = get_bits(f, 5) + 1;
++total;
if (lengths[j] == 32)
return error(f, VORBIS_invalid_setup);
} else {
lengths[j] = NO_CODE;
}
}
}
if (c->sparse && total >= c->entries >> 2) {
// convert sparse items to non-sparse!
if (c->entries > (int) f->setup_temp_memory_required)
f->setup_temp_memory_required = c->entries;
c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries);
if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem);
memcpy(c->codeword_lengths, lengths, c->entries);
setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs!
lengths = c->codeword_lengths;
c->sparse = 0;
}
// compute the size of the sorted tables
if (c->sparse) {
sorted_count = total;
} else {
sorted_count = 0;
#ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH
for (j=0; j < c->entries; ++j)
if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE)
++sorted_count;
#endif
}
c->sorted_entries = sorted_count;
values = NULL;
CHECK(f);
if (!c->sparse) {
c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries);
if (!c->codewords) return error(f, VORBIS_outofmem);
} else {
unsigned int size;
if (c->sorted_entries) {
c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries);
if (!c->codeword_lengths) return error(f, VORBIS_outofmem);
c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries);
if (!c->codewords) return error(f, VORBIS_outofmem);
values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries);
if (!values) return error(f, VORBIS_outofmem);
}
size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries;
if (size > f->setup_temp_memory_required)
f->setup_temp_memory_required = size;
}
if (!compute_codewords(c, lengths, c->entries, values)) {
if (c->sparse) setup_temp_free(f, values, 0);
return error(f, VORBIS_invalid_setup);
}
if (c->sorted_entries) {
// allocate an extra slot for sentinels
c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1));
if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem);
// allocate an extra slot at the front so that c->sorted_values[-1] is defined
// so that we can catch that case without an extra if
c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1));
if (c->sorted_values == NULL) return error(f, VORBIS_outofmem);
++c->sorted_values;
c->sorted_values[-1] = -1;
compute_sorted_huffman(c, lengths, values);
}
if (c->sparse) {
setup_temp_free(f, values, sizeof(*values)*c->sorted_entries);
setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries);
setup_temp_free(f, lengths, c->entries);
c->codewords = NULL;
}
compute_accelerated_huffman(c);
CHECK(f);
c->lookup_type = get_bits(f, 4);
if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup);
if (c->lookup_type > 0) {
uint16 *mults;
c->minimum_value = float32_unpack(get_bits(f, 32));
c->delta_value = float32_unpack(get_bits(f, 32));
c->value_bits = get_bits(f, 4)+1;
c->sequence_p = get_bits(f,1);
if (c->lookup_type == 1) {
c->lookup_values = lookup1_values(c->entries, c->dimensions);
} else {
c->lookup_values = c->entries * c->dimensions;
}
if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup);
mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values);
if (mults == NULL) return error(f, VORBIS_outofmem);
for (j=0; j < (int) c->lookup_values; ++j) {
int q = get_bits(f, c->value_bits);
if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); }
mults[j] = q;
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
if (c->lookup_type == 1) {
int len, sparse = c->sparse;
float last=0;
// pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop
if (sparse) {
if (c->sorted_entries == 0) goto skip;
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions);
} else
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions);
if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
len = sparse ? c->sorted_entries : c->entries;
for (j=0; j < len; ++j) {
unsigned int z = sparse ? c->sorted_values[j] : j;
unsigned int div=1;
for (k=0; k < c->dimensions; ++k) {
int off = (z / div) % c->lookup_values;
float val = mults[off];
val = mults[off]*c->delta_value + c->minimum_value + last;
c->multiplicands[j*c->dimensions + k] = val;
if (c->sequence_p)
last = val;
if (k+1 < c->dimensions) {
if (div > UINT_MAX / (unsigned int) c->lookup_values) {
setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values);
return error(f, VORBIS_invalid_setup);
}
div *= c->lookup_values;
}
}
}
c->lookup_type = 2;
}
else
#endif
{
float last=0;
CHECK(f);
c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values);
if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); }
for (j=0; j < (int) c->lookup_values; ++j) {
float val = mults[j] * c->delta_value + c->minimum_value + last;
c->multiplicands[j] = val;
if (c->sequence_p)
last = val;
}
}
#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK
skip:;
#endif
setup_temp_free(f, mults, sizeof(mults[0])*c->lookup_values);
CHECK(f);
}
CHECK(f);
}
// time domain transfers (notused)
x = get_bits(f, 6) + 1;
for (i=0; i < x; ++i) {
uint32 z = get_bits(f, 16);
if (z != 0) return error(f, VORBIS_invalid_setup);
}
// Floors
f->floor_count = get_bits(f, 6)+1;
f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config));
if (f->floor_config == NULL) return error(f, VORBIS_outofmem);
for (i=0; i < f->floor_count; ++i) {
f->floor_types[i] = get_bits(f, 16);
if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup);
if (f->floor_types[i] == 0) {
Floor0 *g = &f->floor_config[i].floor0;
g->order = get_bits(f,8);
g->rate = get_bits(f,16);
g->bark_map_size = get_bits(f,16);
g->amplitude_bits = get_bits(f,6);
g->amplitude_offset = get_bits(f,8);
g->number_of_books = get_bits(f,4) + 1;
for (j=0; j < g->number_of_books; ++j)
g->book_list[j] = get_bits(f,8);
return error(f, VORBIS_feature_not_supported);
} else {
stbv__floor_ordering p[31*8+2];
Floor1 *g = &f->floor_config[i].floor1;
int max_class = -1;
g->partitions = get_bits(f, 5);
for (j=0; j < g->partitions; ++j) {
g->partition_class_list[j] = get_bits(f, 4);
if (g->partition_class_list[j] > max_class)
max_class = g->partition_class_list[j];
}
for (j=0; j <= max_class; ++j) {
g->class_dimensions[j] = get_bits(f, 3)+1;
g->class_subclasses[j] = get_bits(f, 2);
if (g->class_subclasses[j]) {
g->class_masterbooks[j] = get_bits(f, 8);
if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
for (k=0; k < 1 << g->class_subclasses[j]; ++k) {
g->subclass_books[j][k] = get_bits(f,8)-1;
if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
}
}
g->floor1_multiplier = get_bits(f,2)+1;
g->rangebits = get_bits(f,4);
g->Xlist[0] = 0;
g->Xlist[1] = 1 << g->rangebits;
g->values = 2;
for (j=0; j < g->partitions; ++j) {
int c = g->partition_class_list[j];
for (k=0; k < g->class_dimensions[c]; ++k) {
g->Xlist[g->values] = get_bits(f, g->rangebits);
++g->values;
}
}
// precompute the sorting
for (j=0; j < g->values; ++j) {
p[j].x = g->Xlist[j];
p[j].id = j;
}
qsort(p, g->values, sizeof(p[0]), point_compare);
for (j=0; j < g->values; ++j)
g->sorted_order[j] = (uint8) p[j].id;
// precompute the neighbors
for (j=2; j < g->values; ++j) {
int low,hi;
neighbors(g->Xlist, j, &low,&hi);
g->neighbors[j][0] = low;
g->neighbors[j][1] = hi;
}
if (g->values > longest_floorlist)
longest_floorlist = g->values;
}
}
// Residue
f->residue_count = get_bits(f, 6)+1;
f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0]));
if (f->residue_config == NULL) return error(f, VORBIS_outofmem);
memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0]));
for (i=0; i < f->residue_count; ++i) {
uint8 residue_cascade[64];
Residue *r = f->residue_config+i;
f->residue_types[i] = get_bits(f, 16);
if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup);
r->begin = get_bits(f, 24);
r->end = get_bits(f, 24);
if (r->end < r->begin) return error(f, VORBIS_invalid_setup);
r->part_size = get_bits(f,24)+1;
r->classifications = get_bits(f,6)+1;
r->classbook = get_bits(f,8);
if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup);
for (j=0; j < r->classifications; ++j) {
uint8 high_bits=0;
uint8 low_bits=get_bits(f,3);
if (get_bits(f,1))
high_bits = get_bits(f,5);
residue_cascade[j] = high_bits*8 + low_bits;
}
r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications);
if (r->residue_books == NULL) return error(f, VORBIS_outofmem);
for (j=0; j < r->classifications; ++j) {
for (k=0; k < 8; ++k) {
if (residue_cascade[j] & (1 << k)) {
r->residue_books[j][k] = get_bits(f, 8);
if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup);
} else {
r->residue_books[j][k] = -1;
}
}
}
// precompute the classifications[] array to avoid inner-loop mod/divide
// call it 'classdata' since we already have r->classifications
r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
if (!r->classdata) return error(f, VORBIS_outofmem);
memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries);
for (j=0; j < f->codebooks[r->classbook].entries; ++j) {
int classwords = f->codebooks[r->classbook].dimensions;
int temp = j;
r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords);
if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem);
for (k=classwords-1; k >= 0; --k) {
r->classdata[j][k] = temp % r->classifications;
temp /= r->classifications;
}
}
}
f->mapping_count = get_bits(f,6)+1;
f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping));
if (f->mapping == NULL) return error(f, VORBIS_outofmem);
memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping));
for (i=0; i < f->mapping_count; ++i) {
Mapping *m = f->mapping + i;
int mapping_type = get_bits(f,16);
if (mapping_type != 0) return error(f, VORBIS_invalid_setup);
m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan));
if (m->chan == NULL) return error(f, VORBIS_outofmem);
if (get_bits(f,1))
m->submaps = get_bits(f,4)+1;
else
m->submaps = 1;
if (m->submaps > max_submaps)
max_submaps = m->submaps;
if (get_bits(f,1)) {
m->coupling_steps = get_bits(f,8)+1;
for (k=0; k < m->coupling_steps; ++k) {
m->chan[k].magnitude = get_bits(f, ilog(f->channels-1));
m->chan[k].angle = get_bits(f, ilog(f->channels-1));
if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup);
if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup);
if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup);
}
} else
m->coupling_steps = 0;
// reserved field
if (get_bits(f,2)) return error(f, VORBIS_invalid_setup);
if (m->submaps > 1) {
for (j=0; j < f->channels; ++j) {
m->chan[j].mux = get_bits(f, 4);
if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup);
}
} else
// @SPECIFICATION: this case is missing from the spec
for (j=0; j < f->channels; ++j)
m->chan[j].mux = 0;
for (j=0; j < m->submaps; ++j) {
get_bits(f,8); // discard
m->submap_floor[j] = get_bits(f,8);
m->submap_residue[j] = get_bits(f,8);
if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup);
if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup);
}
}
// Modes
f->mode_count = get_bits(f, 6)+1;
for (i=0; i < f->mode_count; ++i) {
Mode *m = f->mode_config+i;
m->blockflag = get_bits(f,1);
m->windowtype = get_bits(f,16);
m->transformtype = get_bits(f,16);
m->mapping = get_bits(f,8);
if (m->windowtype != 0) return error(f, VORBIS_invalid_setup);
if (m->transformtype != 0) return error(f, VORBIS_invalid_setup);
if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup);
}
flush_packet(f);
f->previous_length = 0;
for (i=0; i < f->channels; ++i) {
f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1);
f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist);
if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem);
memset(f->channel_buffers[i], 0, sizeof(float) * f->blocksize_1);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2);
if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem);
#endif
}
if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE;
if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE;
f->blocksize[0] = f->blocksize_0;
f->blocksize[1] = f->blocksize_1;
#ifdef STB_VORBIS_DIVIDE_TABLE
if (integer_divide_table[1][1]==0)
for (i=0; i < DIVTAB_NUMER; ++i)
for (j=1; j < DIVTAB_DENOM; ++j)
integer_divide_table[i][j] = i / j;
#endif
// compute how much temporary memory is needed
// 1.
{
uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1);
uint32 classify_mem;
int i,max_part_read=0;
for (i=0; i < f->residue_count; ++i) {
Residue *r = f->residue_config + i;
unsigned int actual_size = f->blocksize_1 / 2;
unsigned int limit_r_begin = r->begin < actual_size ? r->begin : actual_size;
unsigned int limit_r_end = r->end < actual_size ? r->end : actual_size;
int n_read = limit_r_end - limit_r_begin;
int part_read = n_read / r->part_size;
if (part_read > max_part_read)
max_part_read = part_read;
}
#ifndef STB_VORBIS_DIVIDES_IN_RESIDUE
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *));
#else
classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *));
#endif
// maximum reasonable partition size is f->blocksize_1
f->temp_memory_required = classify_mem;
if (imdct_mem > f->temp_memory_required)
f->temp_memory_required = imdct_mem;
}
f->first_decode = TRUE;
if (f->alloc.alloc_buffer) {
assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes);
// check if there's enough temp memory so we don't error later
if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset)
return error(f, VORBIS_outofmem);
}
f->first_audio_page_offset = stb_vorbis_get_file_offset(f);
return TRUE;
}
static void vorbis_deinit(stb_vorbis *p)
{
int i,j;
if (p->residue_config) {
for (i=0; i < p->residue_count; ++i) {
Residue *r = p->residue_config+i;
if (r->classdata) {
for (j=0; j < p->codebooks[r->classbook].entries; ++j)
setup_free(p, r->classdata[j]);
setup_free(p, r->classdata);
}
setup_free(p, r->residue_books);
}
}
if (p->codebooks) {
CHECK(p);
for (i=0; i < p->codebook_count; ++i) {
Codebook *c = p->codebooks + i;
setup_free(p, c->codeword_lengths);
setup_free(p, c->multiplicands);
setup_free(p, c->codewords);
setup_free(p, c->sorted_codewords);
// c->sorted_values[-1] is the first entry in the array
setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL);
}
setup_free(p, p->codebooks);
}
setup_free(p, p->floor_config);
setup_free(p, p->residue_config);
if (p->mapping) {
for (i=0; i < p->mapping_count; ++i)
setup_free(p, p->mapping[i].chan);
setup_free(p, p->mapping);
}
CHECK(p);
for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) {
setup_free(p, p->channel_buffers[i]);
setup_free(p, p->previous_window[i]);
#ifdef STB_VORBIS_NO_DEFER_FLOOR
setup_free(p, p->floor_buffers[i]);
#endif
setup_free(p, p->finalY[i]);
}
for (i=0; i < 2; ++i) {
setup_free(p, p->A[i]);
setup_free(p, p->B[i]);
setup_free(p, p->C[i]);
setup_free(p, p->window[i]);
setup_free(p, p->bit_reverse[i]);
}
#ifndef STB_VORBIS_NO_STDIO
if (p->close_on_free) fclose(p->f);
#endif
}
void stb_vorbis_close(stb_vorbis *p)
{
if (p == NULL) return;
vorbis_deinit(p);
setup_free(p,p);
}
static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z)
{
memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start
if (z) {
p->alloc = *z;
p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3;
p->temp_offset = p->alloc.alloc_buffer_length_in_bytes;
}
p->eof = 0;
p->error = VORBIS__no_error;
p->stream = NULL;
p->codebooks = NULL;
p->page_crc_tests = -1;
#ifndef STB_VORBIS_NO_STDIO
p->close_on_free = FALSE;
p->f = NULL;
#endif
}
int stb_vorbis_get_sample_offset(stb_vorbis *f)
{
if (f->current_loc_valid)
return f->current_loc;
else
return -1;
}
stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f)
{
stb_vorbis_info d;
d.channels = f->channels;
d.sample_rate = f->sample_rate;
d.setup_memory_required = f->setup_memory_required;
d.setup_temp_memory_required = f->setup_temp_memory_required;
d.temp_memory_required = f->temp_memory_required;
d.max_frame_size = f->blocksize_1 >> 1;
return d;
}
int stb_vorbis_get_error(stb_vorbis *f)
{
int e = f->error;
f->error = VORBIS__no_error;
return e;
}
static stb_vorbis * vorbis_alloc(stb_vorbis *f)
{
stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p));
return p;
}
#ifndef STB_VORBIS_NO_PUSHDATA_API
void stb_vorbis_flush_pushdata(stb_vorbis *f)
{
f->previous_length = 0;
f->page_crc_tests = 0;
f->discard_samples_deferred = 0;
f->current_loc_valid = FALSE;
f->first_decode = FALSE;
f->samples_output = 0;
f->channel_buffer_start = 0;
f->channel_buffer_end = 0;
}
static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len)
{
int i,n;
for (i=0; i < f->page_crc_tests; ++i)
f->scan[i].bytes_done = 0;
// if we have room for more scans, search for them first, because
// they may cause us to stop early if their header is incomplete
if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) {
if (data_len < 4) return 0;
data_len -= 3; // need to look for 4-byte sequence, so don't miss
// one that straddles a boundary
for (i=0; i < data_len; ++i) {
if (data[i] == 0x4f) {
if (0==memcmp(data+i, ogg_page_header, 4)) {
int j,len;
uint32 crc;
// make sure we have the whole page header
if (i+26 >= data_len || i+27+data[i+26] >= data_len) {
// only read up to this page start, so hopefully we'll
// have the whole page header start next time
data_len = i;
break;
}
// ok, we have it all; compute the length of the page
len = 27 + data[i+26];
for (j=0; j < data[i+26]; ++j)
len += data[i+27+j];
// scan everything up to the embedded crc (which we must 0)
crc = 0;
for (j=0; j < 22; ++j)
crc = crc32_update(crc, data[i+j]);
// now process 4 0-bytes
for ( ; j < 26; ++j)
crc = crc32_update(crc, 0);
// len is the total number of bytes we need to scan
n = f->page_crc_tests++;
f->scan[n].bytes_left = len-j;
f->scan[n].crc_so_far = crc;
f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24);
// if the last frame on a page is continued to the next, then
// we can't recover the sample_loc immediately
if (data[i+27+data[i+26]-1] == 255)
f->scan[n].sample_loc = ~0;
else
f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24);
f->scan[n].bytes_done = i+j;
if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT)
break;
// keep going if we still have room for more
}
}
}
}
for (i=0; i < f->page_crc_tests;) {
uint32 crc;
int j;
int n = f->scan[i].bytes_done;
int m = f->scan[i].bytes_left;
if (m > data_len - n) m = data_len - n;
// m is the bytes to scan in the current chunk
crc = f->scan[i].crc_so_far;
for (j=0; j < m; ++j)
crc = crc32_update(crc, data[n+j]);
f->scan[i].bytes_left -= m;
f->scan[i].crc_so_far = crc;
if (f->scan[i].bytes_left == 0) {
// does it match?
if (f->scan[i].crc_so_far == f->scan[i].goal_crc) {
// Houston, we have page
data_len = n+m; // consumption amount is wherever that scan ended
f->page_crc_tests = -1; // drop out of page scan mode
f->previous_length = 0; // decode-but-don't-output one frame
f->next_seg = -1; // start a new page
f->current_loc = f->scan[i].sample_loc; // set the current sample location
// to the amount we'd have decoded had we decoded this page
f->current_loc_valid = f->current_loc != ~0U;
return data_len;
}
// delete entry
f->scan[i] = f->scan[--f->page_crc_tests];
} else {
++i;
}
}
return data_len;
}
// return value: number of bytes we used
int stb_vorbis_decode_frame_pushdata(
stb_vorbis *f, // the file we're decoding
const uint8 *data, int data_len, // the memory available for decoding
int *channels, // place to write number of float * buffers
float ***output, // place to write float ** array of float * buffers
int *samples // place to write number of output samples
)
{
int i;
int len,right,left;
if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (f->page_crc_tests >= 0) {
*samples = 0;
return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len);
}
f->stream = (uint8 *) data;
f->stream_end = (uint8 *) data + data_len;
f->error = VORBIS__no_error;
// check that we have the entire packet in memory
if (!is_whole_packet_present(f, FALSE)) {
*samples = 0;
return 0;
}
if (!vorbis_decode_packet(f, &len, &left, &right)) {
// save the actual error we encountered
enum STBVorbisError error = f->error;
if (error == VORBIS_bad_packet_type) {
// flush and resynch
f->error = VORBIS__no_error;
while (get8_packet(f) != EOP)
if (f->eof) break;
*samples = 0;
return (int) (f->stream - data);
}
if (error == VORBIS_continued_packet_flag_invalid) {
if (f->previous_length == 0) {
// we may be resynching, in which case it's ok to hit one
// of these; just discard the packet
f->error = VORBIS__no_error;
while (get8_packet(f) != EOP)
if (f->eof) break;
*samples = 0;
return (int) (f->stream - data);
}
}
// if we get an error while parsing, what to do?
// well, it DEFINITELY won't work to continue from where we are!
stb_vorbis_flush_pushdata(f);
// restore the error that actually made us bail
f->error = error;
*samples = 0;
return 1;
}
// success!
len = vorbis_finish_frame(f, len, left, right);
for (i=0; i < f->channels; ++i)
f->outputs[i] = f->channel_buffers[i] + left;
if (channels) *channels = f->channels;
*samples = len;
*output = f->outputs;
return (int) (f->stream - data);
}
stb_vorbis *stb_vorbis_open_pushdata(
const unsigned char *data, int data_len, // the memory available for decoding
int *data_used, // only defined if result is not NULL
int *error, const stb_vorbis_alloc *alloc)
{
stb_vorbis *f, p;
vorbis_init(&p, alloc);
p.stream = (uint8 *) data;
p.stream_end = (uint8 *) data + data_len;
p.push_mode = TRUE;
if (!start_decoder(&p)) {
if (p.eof)
*error = VORBIS_need_more_data;
else
*error = p.error;
return NULL;
}
f = vorbis_alloc(&p);
if (f) {
*f = p;
*data_used = (int) (f->stream - data);
*error = 0;
return f;
} else {
vorbis_deinit(&p);
return NULL;
}
}
#endif // STB_VORBIS_NO_PUSHDATA_API
unsigned int stb_vorbis_get_file_offset(stb_vorbis *f)
{
#ifndef STB_VORBIS_NO_PUSHDATA_API
if (f->push_mode) return 0;
#endif
if (USE_MEMORY(f)) return (unsigned int) (f->stream - f->stream_start);
#ifndef STB_VORBIS_NO_STDIO
return (unsigned int) (ftell(f->f) - f->f_start);
#endif
}
#ifndef STB_VORBIS_NO_PULLDATA_API
//
// DATA-PULLING API
//
static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last)
{
for(;;) {
int n;
if (f->eof) return 0;
n = get8(f);
if (n == 0x4f) { // page header candidate
unsigned int retry_loc = stb_vorbis_get_file_offset(f);
int i;
// check if we're off the end of a file_section stream
if (retry_loc - 25 > f->stream_len)
return 0;
// check the rest of the header
for (i=1; i < 4; ++i)
if (get8(f) != ogg_page_header[i])
break;
if (f->eof) return 0;
if (i == 4) {
uint8 header[27];
uint32 i, crc, goal, len;
for (i=0; i < 4; ++i)
header[i] = ogg_page_header[i];
for (; i < 27; ++i)
header[i] = get8(f);
if (f->eof) return 0;
if (header[4] != 0) goto invalid;
goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24);
for (i=22; i < 26; ++i)
header[i] = 0;
crc = 0;
for (i=0; i < 27; ++i)
crc = crc32_update(crc, header[i]);
len = 0;
for (i=0; i < header[26]; ++i) {
int s = get8(f);
crc = crc32_update(crc, s);
len += s;
}
if (len && f->eof) return 0;
for (i=0; i < len; ++i)
crc = crc32_update(crc, get8(f));
// finished parsing probable page
if (crc == goal) {
// we could now check that it's either got the last
// page flag set, OR it's followed by the capture
// pattern, but I guess TECHNICALLY you could have
// a file with garbage between each ogg page and recover
// from it automatically? So even though that paranoia
// might decrease the chance of an invalid decode by
// another 2^32, not worth it since it would hose those
// invalid-but-useful files?
if (end)
*end = stb_vorbis_get_file_offset(f);
if (last) {
if (header[5] & 0x04)
*last = 1;
else
*last = 0;
}
set_file_offset(f, retry_loc-1);
return 1;
}
}
invalid:
// not a valid page, so rewind and look for next one
set_file_offset(f, retry_loc);
}
}
}
#define SAMPLE_unknown 0xffffffff
// seeking is implemented with a binary search, which narrows down the range to
// 64K, before using a linear search (because finding the synchronization
// pattern can be expensive, and the chance we'd find the end page again is
// relatively high for small ranges)
//
// two initial interpolation-style probes are used at the start of the search
// to try to bound either side of the binary search sensibly, while still
// working in O(log n) time if they fail.
static int get_seek_page_info(stb_vorbis *f, ProbedPage *z)
{
uint8 header[27], lacing[255];
int i,len;
// record where the page starts
z->page_start = stb_vorbis_get_file_offset(f);
// parse the header
getn(f, header, 27);
if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S')
return 0;
getn(f, lacing, header[26]);
// determine the length of the payload
len = 0;
for (i=0; i < header[26]; ++i)
len += lacing[i];
// this implies where the page ends
z->page_end = z->page_start + 27 + header[26] + len;
// read the last-decoded sample out of the data
z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24);
// restore file state to where we were
set_file_offset(f, z->page_start);
return 1;
}
// rarely used function to seek back to the preceeding page while finding the
// start of a packet
static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset)
{
unsigned int previous_safe, end;
// now we want to seek back 64K from the limit
if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset)
previous_safe = limit_offset - 65536;
else
previous_safe = f->first_audio_page_offset;
set_file_offset(f, previous_safe);
while (vorbis_find_page(f, &end, NULL)) {
if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset)
return 1;
set_file_offset(f, end);
}
return 0;
}
// implements the search logic for finding a page and starting decoding. if
// the function succeeds, current_loc_valid will be true and current_loc will
// be less than or equal to the provided sample number (the closer the
// better).
static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number)
{
ProbedPage left, right, mid;
int i, start_seg_with_known_loc, end_pos, page_start;
uint32 delta, stream_length, padding;
double offset, bytes_per_sample;
int probe = 0;
// find the last page and validate the target sample
stream_length = stb_vorbis_stream_length_in_samples(f);
if (stream_length == 0) return error(f, VORBIS_seek_without_length);
if (sample_number > stream_length) return error(f, VORBIS_seek_invalid);
// this is the maximum difference between the window-center (which is the
// actual granule position value), and the right-start (which the spec
// indicates should be the granule position (give or take one)).
padding = ((f->blocksize_1 - f->blocksize_0) >> 2);
if (sample_number < padding)
sample_number = 0;
else
sample_number -= padding;
left = f->p_first;
while (left.last_decoded_sample == ~0U) {
// (untested) the first page does not have a 'last_decoded_sample'
set_file_offset(f, left.page_end);
if (!get_seek_page_info(f, &left)) goto error;
}
right = f->p_last;
assert(right.last_decoded_sample != ~0U);
// starting from the start is handled differently
if (sample_number <= left.last_decoded_sample) {
if (stb_vorbis_seek_start(f))
return 1;
return 0;
}
while (left.page_end != right.page_start) {
assert(left.page_end < right.page_start);
// search range in bytes
delta = right.page_start - left.page_end;
if (delta <= 65536) {
// there's only 64K left to search - handle it linearly
set_file_offset(f, left.page_end);
} else {
if (probe < 2) {
if (probe == 0) {
// first probe (interpolate)
double data_bytes = right.page_end - left.page_start;
bytes_per_sample = data_bytes / right.last_decoded_sample;
offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample);
} else {
// second probe (try to bound the other side)
double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample;
if (error >= 0 && error < 8000) error = 8000;
if (error < 0 && error > -8000) error = -8000;
offset += error * 2;
}
// ensure the offset is valid
if (offset < left.page_end)
offset = left.page_end;
if (offset > right.page_start - 65536)
offset = right.page_start - 65536;
set_file_offset(f, (unsigned int) offset);
} else {
// binary search for large ranges (offset by 32K to ensure
// we don't hit the right page)
set_file_offset(f, left.page_end + (delta / 2) - 32768);
}
if (!vorbis_find_page(f, NULL, NULL)) goto error;
}
for (;;) {
if (!get_seek_page_info(f, &mid)) goto error;
if (mid.last_decoded_sample != ~0U) break;
// (untested) no frames end on this page
set_file_offset(f, mid.page_end);
assert(mid.page_start < right.page_start);
}
// if we've just found the last page again then we're in a tricky file,
// and we're close enough.
if (mid.page_start == right.page_start)
break;
if (sample_number < mid.last_decoded_sample)
right = mid;
else
left = mid;
++probe;
}
// seek back to start of the last packet
page_start = left.page_start;
set_file_offset(f, page_start);
if (!start_page(f)) return error(f, VORBIS_seek_failed);
end_pos = f->end_seg_with_known_loc;
assert(end_pos >= 0);
for (;;) {
for (i = end_pos; i > 0; --i)
if (f->segments[i-1] != 255)
break;
start_seg_with_known_loc = i;
if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet))
break;
// (untested) the final packet begins on an earlier page
if (!go_to_page_before(f, page_start))
goto error;
page_start = stb_vorbis_get_file_offset(f);
if (!start_page(f)) goto error;
end_pos = f->segment_count - 1;
}
// prepare to start decoding
f->current_loc_valid = FALSE;
f->last_seg = FALSE;
f->valid_bits = 0;
f->packet_bytes = 0;
f->bytes_in_seg = 0;
f->previous_length = 0;
f->next_seg = start_seg_with_known_loc;
for (i = 0; i < start_seg_with_known_loc; i++)
skip(f, f->segments[i]);
// start decoding (optimizable - this frame is generally discarded)
if (!vorbis_pump_first_frame(f))
return 0;
if (f->current_loc > sample_number)
return error(f, VORBIS_seek_failed);
return 1;
error:
// try to restore the file to a valid state
stb_vorbis_seek_start(f);
return error(f, VORBIS_seek_failed);
}
// the same as vorbis_decode_initial, but without advancing
static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode)
{
int bits_read, bytes_read;
if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode))
return 0;
// either 1 or 2 bytes were read, figure out which so we can rewind
bits_read = 1 + ilog(f->mode_count-1);
if (f->mode_config[*mode].blockflag)
bits_read += 2;
bytes_read = (bits_read + 7) / 8;
f->bytes_in_seg += bytes_read;
f->packet_bytes -= bytes_read;
skip(f, -bytes_read);
if (f->next_seg == -1)
f->next_seg = f->segment_count - 1;
else
f->next_seg--;
f->valid_bits = 0;
return 1;
}
int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number)
{
uint32 max_frame_samples;
if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
// fast page-level search
if (!seek_to_sample_coarse(f, sample_number))
return 0;
assert(f->current_loc_valid);
assert(f->current_loc <= sample_number);
// linear search for the relevant packet
max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2;
while (f->current_loc < sample_number) {
int left_start, left_end, right_start, right_end, mode, frame_samples;
if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode))
return error(f, VORBIS_seek_failed);
// calculate the number of samples returned by the next frame
frame_samples = right_start - left_start;
if (f->current_loc + frame_samples > sample_number) {
return 1; // the next frame will contain the sample
} else if (f->current_loc + frame_samples + max_frame_samples > sample_number) {
// there's a chance the frame after this could contain the sample
vorbis_pump_first_frame(f);
} else {
// this frame is too early to be relevant
f->current_loc += frame_samples;
f->previous_length = 0;
maybe_start_packet(f);
flush_packet(f);
}
}
// the next frame will start with the sample
assert(f->current_loc == sample_number);
return 1;
}
int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number)
{
if (!stb_vorbis_seek_frame(f, sample_number))
return 0;
if (sample_number != f->current_loc) {
int n;
uint32 frame_start = f->current_loc;
stb_vorbis_get_frame_float(f, &n, NULL);
assert(sample_number > frame_start);
assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end);
f->channel_buffer_start += (sample_number - frame_start);
}
return 1;
}
int stb_vorbis_seek_start(stb_vorbis *f)
{
if (IS_PUSH_MODE(f)) { return error(f, VORBIS_invalid_api_mixing); }
set_file_offset(f, f->first_audio_page_offset);
f->previous_length = 0;
f->first_decode = TRUE;
f->next_seg = -1;
return vorbis_pump_first_frame(f);
}
unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f)
{
unsigned int restore_offset, previous_safe;
unsigned int end, last_page_loc;
if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (!f->total_samples) {
unsigned int last;
uint32 lo,hi;
char header[6];
// first, store the current decode position so we can restore it
restore_offset = stb_vorbis_get_file_offset(f);
// now we want to seek back 64K from the end (the last page must
// be at most a little less than 64K, but let's allow a little slop)
if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset)
previous_safe = f->stream_len - 65536;
else
previous_safe = f->first_audio_page_offset;
set_file_offset(f, previous_safe);
// previous_safe is now our candidate 'earliest known place that seeking
// to will lead to the final page'
if (!vorbis_find_page(f, &end, &last)) {
// if we can't find a page, we're hosed!
f->error = VORBIS_cant_find_last_page;
f->total_samples = 0xffffffff;
goto done;
}
// check if there are more pages
last_page_loc = stb_vorbis_get_file_offset(f);
// stop when the last_page flag is set, not when we reach eof;
// this allows us to stop short of a 'file_section' end without
// explicitly checking the length of the section
while (!last) {
set_file_offset(f, end);
if (!vorbis_find_page(f, &end, &last)) {
// the last page we found didn't have the 'last page' flag
// set. whoops!
break;
}
previous_safe = last_page_loc+1;
last_page_loc = stb_vorbis_get_file_offset(f);
}
set_file_offset(f, last_page_loc);
// parse the header
getn(f, (unsigned char *)header, 6);
// extract the absolute granule position
lo = get32(f);
hi = get32(f);
if (lo == 0xffffffff && hi == 0xffffffff) {
f->error = VORBIS_cant_find_last_page;
f->total_samples = SAMPLE_unknown;
goto done;
}
if (hi)
lo = 0xfffffffe; // saturate
f->total_samples = lo;
f->p_last.page_start = last_page_loc;
f->p_last.page_end = end;
f->p_last.last_decoded_sample = lo;
done:
set_file_offset(f, restore_offset);
}
return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples;
}
float stb_vorbis_stream_length_in_seconds(stb_vorbis *f)
{
return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate;
}
int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output)
{
int len, right,left,i;
if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing);
if (!vorbis_decode_packet(f, &len, &left, &right)) {
f->channel_buffer_start = f->channel_buffer_end = 0;
return 0;
}
len = vorbis_finish_frame(f, len, left, right);
for (i=0; i < f->channels; ++i)
f->outputs[i] = f->channel_buffers[i] + left;
f->channel_buffer_start = left;
f->channel_buffer_end = left+len;
if (channels) *channels = f->channels;
if (output) *output = f->outputs;
return len;
}
#ifndef STB_VORBIS_NO_STDIO
stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length)
{
stb_vorbis *f, p;
vorbis_init(&p, alloc);
p.f = file;
p.f_start = (uint32) ftell(file);
p.stream_len = length;
p.close_on_free = close_on_free;
if (start_decoder(&p)) {
f = vorbis_alloc(&p);
if (f) {
*f = p;
vorbis_pump_first_frame(f);
return f;
}
}
if (error) *error = p.error;
vorbis_deinit(&p);
return NULL;
}
stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc)
{
unsigned int len, start;
start = (unsigned int) ftell(file);
fseek(file, 0, SEEK_END);
len = (unsigned int) (ftell(file) - start);
fseek(file, start, SEEK_SET);
return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len);
}
stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc)
{
FILE *f = fopen(filename, "rb");
if (f)
return stb_vorbis_open_file(f, TRUE, error, alloc);
if (error) *error = VORBIS_file_open_failure;
return NULL;
}
#endif // STB_VORBIS_NO_STDIO
stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc)
{
stb_vorbis *f, p;
if (data == NULL) return NULL;
vorbis_init(&p, alloc);
p.stream = (uint8 *) data;
p.stream_end = (uint8 *) data + len;
p.stream_start = (uint8 *) p.stream;
p.stream_len = len;
p.push_mode = FALSE;
if (start_decoder(&p)) {
f = vorbis_alloc(&p);
if (f) {
*f = p;
vorbis_pump_first_frame(f);
if (error) *error = VORBIS__no_error;
return f;
}
}
if (error) *error = p.error;
vorbis_deinit(&p);
return NULL;
}
#ifndef STB_VORBIS_NO_INTEGER_CONVERSION
#define PLAYBACK_MONO 1
#define PLAYBACK_LEFT 2
#define PLAYBACK_RIGHT 4
#define L (PLAYBACK_LEFT | PLAYBACK_MONO)
#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO)
#define R (PLAYBACK_RIGHT | PLAYBACK_MONO)
static int8 channel_position[7][6] =
{
{ 0 },
{ C },
{ L, R },
{ L, C, R },
{ L, R, L, R },
{ L, C, R, L, R },
{ L, C, R, L, R, C },
};
#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT
typedef union {
float f;
int i;
} float_conv;
typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4];
#define FASTDEF(x) float_conv x
// add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round
#define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT))
#define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22))
#define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s))
#define check_endianness()
#else
#define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s))))
#define check_endianness()
#define FASTDEF(x)
#endif
static void copy_samples(short *dest, float *src, int len)
{
int i;
check_endianness();
for (i=0; i < len; ++i) {
FASTDEF(temp);
int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
dest[i] = v;
}
}
static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len)
{
#define BUFFER_SIZE 32
float buffer[BUFFER_SIZE];
int i,j,o,n = BUFFER_SIZE;
check_endianness();
for (o = 0; o < len; o += BUFFER_SIZE) {
memset(buffer, 0, sizeof(buffer));
if (o + n > len) n = len - o;
for (j=0; j < num_c; ++j) {
if (channel_position[num_c][j] & mask) {
for (i=0; i < n; ++i)
buffer[i] += data[j][d_offset+o+i];
}
}
for (i=0; i < n; ++i) {
FASTDEF(temp);
int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
output[o+i] = v;
}
}
}
static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len)
{
#define BUFFER_SIZE 32
float buffer[BUFFER_SIZE];
int i,j,o,n = BUFFER_SIZE >> 1;
// o is the offset in the source data
check_endianness();
for (o = 0; o < len; o += BUFFER_SIZE >> 1) {
// o2 is the offset in the output data
int o2 = o << 1;
memset(buffer, 0, sizeof(buffer));
if (o + n > len) n = len - o;
for (j=0; j < num_c; ++j) {
int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT);
if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) {
for (i=0; i < n; ++i) {
buffer[i*2+0] += data[j][d_offset+o+i];
buffer[i*2+1] += data[j][d_offset+o+i];
}
} else if (m == PLAYBACK_LEFT) {
for (i=0; i < n; ++i) {
buffer[i*2+0] += data[j][d_offset+o+i];
}
} else if (m == PLAYBACK_RIGHT) {
for (i=0; i < n; ++i) {
buffer[i*2+1] += data[j][d_offset+o+i];
}
}
}
for (i=0; i < (n<<1); ++i) {
FASTDEF(temp);
int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
output[o2+i] = v;
}
}
}
static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples)
{
int i;
if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} };
for (i=0; i < buf_c; ++i)
compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples);
} else {
int limit = buf_c < data_c ? buf_c : data_c;
for (i=0; i < limit; ++i)
copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples);
for ( ; i < buf_c; ++i)
memset(buffer[i]+b_offset, 0, sizeof(short) * samples);
}
}
int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples)
{
float **output;
int len = stb_vorbis_get_frame_float(f, NULL, &output);
if (len > num_samples) len = num_samples;
if (len)
convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len);
return len;
}
static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len)
{
int i;
check_endianness();
if (buf_c != data_c && buf_c <= 2 && data_c <= 6) {
assert(buf_c == 2);
for (i=0; i < buf_c; ++i)
compute_stereo_samples(buffer, data_c, data, d_offset, len);
} else {
int limit = buf_c < data_c ? buf_c : data_c;
int j;
for (j=0; j < len; ++j) {
for (i=0; i < limit; ++i) {
FASTDEF(temp);
float f = data[i][d_offset+j];
int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15);
if ((unsigned int) (v + 32768) > 65535)
v = v < 0 ? -32768 : 32767;
*buffer++ = v;
}
for ( ; i < buf_c; ++i)
*buffer++ = 0;
}
}
}
int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts)
{
float **output;
int len;
if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts);
len = stb_vorbis_get_frame_float(f, NULL, &output);
if (len) {
if (len*num_c > num_shorts) len = num_shorts / num_c;
convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len);
}
return len;
}
int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts)
{
float **outputs;
int len = num_shorts / channels;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < len) {
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= len) k = len - n;
if (k)
convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k);
buffer += k*channels;
n += k;
f->channel_buffer_start += k;
if (n == len) break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
}
return n;
}
int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len)
{
float **outputs;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < len) {
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= len) k = len - n;
if (k)
convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k);
n += k;
f->channel_buffer_start += k;
if (n == len) break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break;
}
return n;
}
#ifndef STB_VORBIS_NO_STDIO
int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output)
{
int data_len, offset, total, limit, error;
short *data;
stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL);
if (v == NULL) return -1;
limit = v->channels * 4096;
*channels = v->channels;
if (sample_rate)
*sample_rate = v->sample_rate;
offset = data_len = 0;
total = limit;
data = (short *) malloc(total * sizeof(*data));
if (data == NULL) {
stb_vorbis_close(v);
return -2;
}
for (;;) {
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
if (n == 0) break;
data_len += n;
offset += n * v->channels;
if (offset + limit > total) {
short *data2;
total *= 2;
data2 = (short *) realloc(data, total * sizeof(*data));
if (data2 == NULL) {
free(data);
stb_vorbis_close(v);
return -2;
}
data = data2;
}
}
*output = data;
stb_vorbis_close(v);
return data_len;
}
#endif // NO_STDIO
int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output)
{
int data_len, offset, total, limit, error;
short *data;
stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL);
if (v == NULL) return -1;
limit = v->channels * 4096;
*channels = v->channels;
if (sample_rate)
*sample_rate = v->sample_rate;
offset = data_len = 0;
total = limit;
data = (short *) malloc(total * sizeof(*data));
if (data == NULL) {
stb_vorbis_close(v);
return -2;
}
for (;;) {
int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset);
if (n == 0) break;
data_len += n;
offset += n * v->channels;
if (offset + limit > total) {
short *data2;
total *= 2;
data2 = (short *) realloc(data, total * sizeof(*data));
if (data2 == NULL) {
free(data);
stb_vorbis_close(v);
return -2;
}
data = data2;
}
}
*output = data;
stb_vorbis_close(v);
return data_len;
}
#endif // STB_VORBIS_NO_INTEGER_CONVERSION
int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats)
{
float **outputs;
int len = num_floats / channels;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < len) {
int i,j;
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= len) k = len - n;
for (j=0; j < k; ++j) {
for (i=0; i < z; ++i)
*buffer++ = f->channel_buffers[i][f->channel_buffer_start+j];
for ( ; i < channels; ++i)
*buffer++ = 0;
}
n += k;
f->channel_buffer_start += k;
if (n == len)
break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
break;
}
return n;
}
int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples)
{
float **outputs;
int n=0;
int z = f->channels;
if (z > channels) z = channels;
while (n < num_samples) {
int i;
int k = f->channel_buffer_end - f->channel_buffer_start;
if (n+k >= num_samples) k = num_samples - n;
if (k) {
for (i=0; i < z; ++i)
memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k);
for ( ; i < channels; ++i)
memset(buffer[i]+n, 0, sizeof(float) * k);
}
n += k;
f->channel_buffer_start += k;
if (n == num_samples)
break;
if (!stb_vorbis_get_frame_float(f, NULL, &outputs))
break;
}
return n;
}
#endif // STB_VORBIS_NO_PULLDATA_API
/* Version history
1.12 - 2017-11-21 - limit residue begin/end to blocksize/2 to avoid large temp allocs in bad/corrupt files
1.11 - 2017-07-23 - fix MinGW compilation
1.10 - 2017-03-03 - more robust seeking; fix negative ilog(); clear error in open_memory
1.09 - 2016-04-04 - back out 'avoid discarding last frame' fix from previous version
1.08 - 2016-04-02 - fixed multiple warnings; fix setup memory leaks;
avoid discarding last frame of audio data
1.07 - 2015-01-16 - fixed some warnings, fix mingw, const-correct API
some more crash fixes when out of memory or with corrupt files
1.06 - 2015-08-31 - full, correct support for seeking API (Dougall Johnson)
some crash fixes when out of memory or with corrupt files
1.05 - 2015-04-19 - don't define __forceinline if it's redundant
1.04 - 2014-08-27 - fix missing const-correct case in API
1.03 - 2014-08-07 - Warning fixes
1.02 - 2014-07-09 - Declare qsort compare function _cdecl on windows
1.01 - 2014-06-18 - fix stb_vorbis_get_samples_float
1.0 - 2014-05-26 - fix memory leaks; fix warnings; fix bugs in multichannel
(API change) report sample rate for decode-full-file funcs
0.99996 - bracket #include <malloc.h> for macintosh compilation by Laurent Gomila
0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem
0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence
0.99993 - remove assert that fired on legal files with empty tables
0.99992 - rewind-to-start
0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo
0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++
0.9998 - add a full-decode function with a memory source
0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition
0.9996 - query length of vorbis stream in samples/seconds
0.9995 - bugfix to another optimization that only happened in certain files
0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors
0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation
0.9992 - performance improvement of IMDCT; now performs close to reference implementation
0.9991 - performance improvement of IMDCT
0.999 - (should have been 0.9990) performance improvement of IMDCT
0.998 - no-CRT support from Casey Muratori
0.997 - bugfixes for bugs found by Terje Mathisen
0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen
0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen
0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen
0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen
0.992 - fixes for MinGW warning
0.991 - turn fast-float-conversion on by default
0.990 - fix push-mode seek recovery if you seek into the headers
0.98b - fix to bad release of 0.98
0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode
0.97 - builds under c++ (typecasting, don't use 'class' keyword)
0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code
0.95 - clamping code for 16-bit functions
0.94 - not publically released
0.93 - fixed all-zero-floor case (was decoding garbage)
0.92 - fixed a memory leak
0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION
0.90 - first public release
*/
#endif // STB_VORBIS_HEADER_ONLY
/*
------------------------------------------------------------------------------
This software is available under 2 licenses -- choose whichever you prefer.
------------------------------------------------------------------------------
ALTERNATIVE A - MIT License
Copyright (c) 2017 Sean Barrett
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
------------------------------------------------------------------------------
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS 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.
------------------------------------------------------------------------------
*/
|
the_stack_data/2585.c
|
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown -w -S -o - -emit-llvm %s | FileCheck %s -check-prefix=NO__ERRNO
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-unknown-gnu -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_GNU
// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-unknown-windows-msvc -w -S -o - -emit-llvm -fmath-errno %s | FileCheck %s --check-prefix=HAS_ERRNO_WIN
// Test attributes and codegen of math builtins.
void foo(double *d, float f, float *fp, long double *l, int *i, const char *c) {
f = __builtin_fmod(f,f); f = __builtin_fmodf(f,f); f = __builtin_fmodl(f,f); f = __builtin_fmodf128(f,f);
// NO__ERRNO: frem double
// NO__ERRNO: frem float
// NO__ERRNO: frem x86_fp80
// NO__ERRNO: frem fp128
// HAS_ERRNO: declare double @fmod(double noundef, double noundef) [[NOT_READNONE:#[0-9]+]]
// HAS_ERRNO: declare float @fmodf(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @fmodl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @fmodf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_atan2(f,f); __builtin_atan2f(f,f) ; __builtin_atan2l(f, f); __builtin_atan2f128(f,f);
// NO__ERRNO: declare double @atan2(double noundef, double noundef) [[READNONE:#[0-9]+]]
// NO__ERRNO: declare float @atan2f(float noundef, float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @atan2f128(fp128 noundef, fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @atan2(double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @atan2f(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atan2l(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @atan2f128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_copysign(f,f); __builtin_copysignf(f,f); __builtin_copysignl(f,f); __builtin_copysignf128(f,f);
// NO__ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// NO__ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.copysign.f128(fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.copysign.f64(double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO: declare float @llvm.copysign.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.copysign.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.copysign.f128(fp128, fp128) [[READNONE_INTRINSIC]]
__builtin_fabs(f); __builtin_fabsf(f); __builtin_fabsl(f); __builtin_fabsf128(f);
// NO__ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.fabs.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.fabs.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.fabs.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.fabs.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_frexp(f,i); __builtin_frexpf(f,i); __builtin_frexpl(f,i); __builtin_frexpf128(f,i);
// NO__ERRNO: declare double @frexp(double noundef, i32* noundef) [[NOT_READNONE:#[0-9]+]]
// NO__ERRNO: declare float @frexpf(float noundef, i32* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @frexpl(x86_fp80 noundef, i32* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare fp128 @frexpf128(fp128 noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare double @frexp(double noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @frexpf(float noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @frexpl(x86_fp80 noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @frexpf128(fp128 noundef, i32* noundef) [[NOT_READNONE]]
__builtin_huge_val(); __builtin_huge_valf(); __builtin_huge_vall(); __builtin_huge_valf128();
// NO__ERRNO-NOT: .huge
// NO__ERRNO-NOT: @huge
// HAS_ERRNO-NOT: .huge
// HAS_ERRNO-NOT: @huge
__builtin_inf(); __builtin_inff(); __builtin_infl(); __builtin_inff128();
// NO__ERRNO-NOT: .inf
// NO__ERRNO-NOT: @inf
// HAS_ERRNO-NOT: .inf
// HAS_ERRNO-NOT: @inf
__builtin_ldexp(f,f); __builtin_ldexpf(f,f); __builtin_ldexpl(f,f); __builtin_ldexpf128(f,f);
// NO__ERRNO: declare double @ldexp(double noundef, i32 noundef) [[READNONE]]
// NO__ERRNO: declare float @ldexpf(float noundef, i32 noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @ldexpl(x86_fp80 noundef, i32 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @ldexpf128(fp128 noundef, i32 noundef) [[READNONE]]
// HAS_ERRNO: declare double @ldexp(double noundef, i32 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @ldexpf(float noundef, i32 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @ldexpl(x86_fp80 noundef, i32 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @ldexpf128(fp128 noundef, i32 noundef) [[NOT_READNONE]]
__builtin_modf(f,d); __builtin_modff(f,fp); __builtin_modfl(f,l); __builtin_modff128(f,l);
// NO__ERRNO: declare double @modf(double noundef, double* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare float @modff(float noundef, float* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @modfl(x86_fp80 noundef, x86_fp80* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare fp128 @modff128(fp128 noundef, fp128* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare double @modf(double noundef, double* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @modff(float noundef, float* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @modfl(x86_fp80 noundef, x86_fp80* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @modff128(fp128 noundef, fp128* noundef) [[NOT_READNONE]]
__builtin_nan(c); __builtin_nanf(c); __builtin_nanl(c); __builtin_nanf128(c);
// NO__ERRNO: declare double @nan(i8* noundef) [[PURE:#[0-9]+]]
// NO__ERRNO: declare float @nanf(i8* noundef) [[PURE]]
// NO__ERRNO: declare x86_fp80 @nanl(i8* noundef) [[PURE]]
// NO__ERRNO: declare fp128 @nanf128(i8* noundef) [[PURE]]
// HAS_ERRNO: declare double @nan(i8* noundef) [[PURE:#[0-9]+]]
// HAS_ERRNO: declare float @nanf(i8* noundef) [[PURE]]
// HAS_ERRNO: declare x86_fp80 @nanl(i8* noundef) [[PURE]]
// HAS_ERRNO: declare fp128 @nanf128(i8* noundef) [[PURE]]
__builtin_nans(c); __builtin_nansf(c); __builtin_nansl(c); __builtin_nansf128(c);
// NO__ERRNO: declare double @nans(i8* noundef) [[PURE]]
// NO__ERRNO: declare float @nansf(i8* noundef) [[PURE]]
// NO__ERRNO: declare x86_fp80 @nansl(i8* noundef) [[PURE]]
// NO__ERRNO: declare fp128 @nansf128(i8* noundef) [[PURE]]
// HAS_ERRNO: declare double @nans(i8* noundef) [[PURE]]
// HAS_ERRNO: declare float @nansf(i8* noundef) [[PURE]]
// HAS_ERRNO: declare x86_fp80 @nansl(i8* noundef) [[PURE]]
// HAS_ERRNO: declare fp128 @nansf128(i8* noundef) [[PURE]]
__builtin_pow(f,f); __builtin_powf(f,f); __builtin_powl(f,f); __builtin_powf128(f,f);
// NO__ERRNO: declare double @llvm.pow.f64(double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.pow.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.pow.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.pow.f128(fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @pow(double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @powf(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @powl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @powf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_powi(f,f); __builtin_powif(f,f); __builtin_powil(f,f);
// NO__ERRNO: declare double @llvm.powi.f64.i32(double, i32) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.powi.f32.i32(float, i32) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.powi.f80.i32(x86_fp80, i32) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.powi.f64.i32(double, i32) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.powi.f32.i32(float, i32) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.powi.f80.i32(x86_fp80, i32) [[READNONE_INTRINSIC]]
/* math */
__builtin_acos(f); __builtin_acosf(f); __builtin_acosl(f); __builtin_acosf128(f);
// NO__ERRNO: declare double @acos(double noundef) [[READNONE]]
// NO__ERRNO: declare float @acosf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @acosl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @acosf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @acos(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @acosf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @acosl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @acosf128(fp128 noundef) [[NOT_READNONE]]
__builtin_acosh(f); __builtin_acoshf(f); __builtin_acoshl(f); __builtin_acoshf128(f);
// NO__ERRNO: declare double @acosh(double noundef) [[READNONE]]
// NO__ERRNO: declare float @acoshf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @acoshl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @acoshf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @acosh(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @acoshf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @acoshl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @acoshf128(fp128 noundef) [[NOT_READNONE]]
__builtin_asin(f); __builtin_asinf(f); __builtin_asinl(f); __builtin_asinf128(f);
// NO__ERRNO: declare double @asin(double noundef) [[READNONE]]
// NO__ERRNO: declare float @asinf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @asinl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @asinf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @asin(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @asinf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @asinl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @asinf128(fp128 noundef) [[NOT_READNONE]]
__builtin_asinh(f); __builtin_asinhf(f); __builtin_asinhl(f); __builtin_asinhf128(f);
// NO__ERRNO: declare double @asinh(double noundef) [[READNONE]]
// NO__ERRNO: declare float @asinhf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @asinhl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @asinhf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @asinh(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @asinhf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @asinhl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @asinhf128(fp128 noundef) [[NOT_READNONE]]
__builtin_atan(f); __builtin_atanf(f); __builtin_atanl(f); __builtin_atanf128(f);
// NO__ERRNO: declare double @atan(double noundef) [[READNONE]]
// NO__ERRNO: declare float @atanf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @atanl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @atanf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @atan(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @atanf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atanl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @atanf128(fp128 noundef) [[NOT_READNONE]]
__builtin_atanh(f); __builtin_atanhf(f); __builtin_atanhl(f); __builtin_atanhf128(f);
// NO__ERRNO: declare double @atanh(double noundef) [[READNONE]]
// NO__ERRNO: declare float @atanhf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @atanhl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @atanhf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @atanh(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @atanhf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @atanhl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @atanhf128(fp128 noundef) [[NOT_READNONE]]
__builtin_cbrt(f); __builtin_cbrtf(f); __builtin_cbrtl(f); __builtin_cbrtf128(f);
// NO__ERRNO: declare double @cbrt(double noundef) [[READNONE]]
// NO__ERRNO: declare float @cbrtf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @cbrtl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @cbrtf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @cbrt(double noundef) [[READNONE:#[0-9]+]]
// HAS_ERRNO: declare float @cbrtf(float noundef) [[READNONE]]
// HAS_ERRNO: declare x86_fp80 @cbrtl(x86_fp80 noundef) [[READNONE]]
// HAS_ERRNO: declare fp128 @cbrtf128(fp128 noundef) [[READNONE]]
__builtin_ceil(f); __builtin_ceilf(f); __builtin_ceill(f); __builtin_ceilf128(f);
// NO__ERRNO: declare double @llvm.ceil.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.ceil.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.ceil.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.ceil.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.ceil.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.ceil.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.ceil.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.ceil.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_cos(f); __builtin_cosf(f); __builtin_cosl(f); __builtin_cosf128(f);
// NO__ERRNO: declare double @llvm.cos.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.cos.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.cos.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.cos.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @cos(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @cosf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @cosl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @cosf128(fp128 noundef) [[NOT_READNONE]]
__builtin_cosh(f); __builtin_coshf(f); __builtin_coshl(f); __builtin_coshf128(f);
// NO__ERRNO: declare double @cosh(double noundef) [[READNONE]]
// NO__ERRNO: declare float @coshf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @coshl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @coshf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @cosh(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @coshf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @coshl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @coshf128(fp128 noundef) [[NOT_READNONE]]
__builtin_erf(f); __builtin_erff(f); __builtin_erfl(f); __builtin_erff128(f);
// NO__ERRNO: declare double @erf(double noundef) [[READNONE]]
// NO__ERRNO: declare float @erff(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @erfl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @erff128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @erf(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @erff(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @erfl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @erff128(fp128 noundef) [[NOT_READNONE]]
__builtin_erfc(f); __builtin_erfcf(f); __builtin_erfcl(f); __builtin_erfcf128(f);
// NO__ERRNO: declare double @erfc(double noundef) [[READNONE]]
// NO__ERRNO: declare float @erfcf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @erfcl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @erfcf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @erfc(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @erfcf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @erfcl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @erfcf128(fp128 noundef) [[NOT_READNONE]]
__builtin_exp(f); __builtin_expf(f); __builtin_expl(f); __builtin_expf128(f);
// NO__ERRNO: declare double @llvm.exp.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.exp.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.exp.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.exp.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @exp(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @expf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @expl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @expf128(fp128 noundef) [[NOT_READNONE]]
__builtin_exp2(f); __builtin_exp2f(f); __builtin_exp2l(f); __builtin_exp2f128(f);
// NO__ERRNO: declare double @llvm.exp2.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.exp2.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.exp2.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.exp2.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @exp2(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @exp2f(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @exp2l(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @exp2f128(fp128 noundef) [[NOT_READNONE]]
__builtin_expm1(f); __builtin_expm1f(f); __builtin_expm1l(f); __builtin_expm1f128(f);
// NO__ERRNO: declare double @expm1(double noundef) [[READNONE]]
// NO__ERRNO: declare float @expm1f(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @expm1l(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @expm1f128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @expm1(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @expm1f(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @expm1l(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @expm1f128(fp128 noundef) [[NOT_READNONE]]
__builtin_fdim(f,f); __builtin_fdimf(f,f); __builtin_fdiml(f,f); __builtin_fdimf128(f,f);
// NO__ERRNO: declare double @fdim(double noundef, double noundef) [[READNONE]]
// NO__ERRNO: declare float @fdimf(float noundef, float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @fdiml(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @fdimf128(fp128 noundef, fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @fdim(double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @fdimf(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @fdiml(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @fdimf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_floor(f); __builtin_floorf(f); __builtin_floorl(f); __builtin_floorf128(f);
// NO__ERRNO: declare double @llvm.floor.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.floor.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.floor.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.floor.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.floor.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.floor.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.floor.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.floor.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_fma(f,f,f); __builtin_fmaf(f,f,f); __builtin_fmal(f,f,f); __builtin_fmaf128(f,f,f);
// NO__ERRNO: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.fma.f128(fp128, fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @fma(double noundef, double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @fmaf(float noundef, float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @fmal(x86_fp80 noundef, x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @fmaf128(fp128 noundef, fp128 noundef, fp128 noundef) [[NOT_READNONE]]
// On GNU or Win, fma never sets errno, so we can convert to the intrinsic.
// HAS_ERRNO_GNU: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO_GNU: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO_GNU: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO_WIN: declare double @llvm.fma.f64(double, double, double) [[READNONE_INTRINSIC:#[0-9]+]]
// HAS_ERRNO_WIN: declare float @llvm.fma.f32(float, float, float) [[READNONE_INTRINSIC]]
// Long double is just double on win, so no f80 use/declaration.
// HAS_ERRNO_WIN-NOT: declare x86_fp80 @llvm.fma.f80(x86_fp80, x86_fp80, x86_fp80)
__builtin_fmax(f,f); __builtin_fmaxf(f,f); __builtin_fmaxl(f,f); __builtin_fmaxf128(f,f);
// NO__ERRNO: declare double @llvm.maxnum.f64(double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.maxnum.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.maxnum.f128(fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.maxnum.f64(double, double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.maxnum.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.maxnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.maxnum.f128(fp128, fp128) [[READNONE_INTRINSIC]]
__builtin_fmin(f,f); __builtin_fminf(f,f); __builtin_fminl(f,f); __builtin_fminf128(f,f);
// NO__ERRNO: declare double @llvm.minnum.f64(double, double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.minnum.f32(float, float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.minnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.minnum.f128(fp128, fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.minnum.f64(double, double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.minnum.f32(float, float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.minnum.f80(x86_fp80, x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.minnum.f128(fp128, fp128) [[READNONE_INTRINSIC]]
__builtin_hypot(f,f); __builtin_hypotf(f,f); __builtin_hypotl(f,f); __builtin_hypotf128(f,f);
// NO__ERRNO: declare double @hypot(double noundef, double noundef) [[READNONE]]
// NO__ERRNO: declare float @hypotf(float noundef, float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @hypotl(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @hypotf128(fp128 noundef, fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @hypot(double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @hypotf(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @hypotl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @hypotf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_ilogb(f); __builtin_ilogbf(f); __builtin_ilogbl(f); __builtin_ilogbf128(f);
// NO__ERRNO: declare i32 @ilogb(double noundef) [[READNONE]]
// NO__ERRNO: declare i32 @ilogbf(float noundef) [[READNONE]]
// NO__ERRNO: declare i32 @ilogbl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare i32 @ilogbf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare i32 @ilogb(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i32 @ilogbf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i32 @ilogbl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i32 @ilogbf128(fp128 noundef) [[NOT_READNONE]]
__builtin_lgamma(f); __builtin_lgammaf(f); __builtin_lgammal(f); __builtin_lgammaf128(f);
// NO__ERRNO: declare double @lgamma(double noundef) [[NOT_READNONE]]
// NO__ERRNO: declare float @lgammaf(float noundef) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @lgammal(x86_fp80 noundef) [[NOT_READNONE]]
// NO__ERRNO: declare fp128 @lgammaf128(fp128 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare double @lgamma(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @lgammaf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @lgammal(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @lgammaf128(fp128 noundef) [[NOT_READNONE]]
__builtin_llrint(f); __builtin_llrintf(f); __builtin_llrintl(f); __builtin_llrintf128(f);
// NO__ERRNO: declare i64 @llvm.llrint.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llrint.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llrint.i64.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @llrint(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llrintf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llrintl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llrintf128(fp128 noundef) [[NOT_READNONE]]
__builtin_llround(f); __builtin_llroundf(f); __builtin_llroundl(f); __builtin_llroundf128(f);
// NO__ERRNO: declare i64 @llvm.llround.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llround.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.llround.i64.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @llround(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llroundf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llroundl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @llroundf128(fp128 noundef) [[NOT_READNONE]]
__builtin_log(f); __builtin_logf(f); __builtin_logl(f); __builtin_logf128(f);
// NO__ERRNO: declare double @llvm.log.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.log.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.log.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.log.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @log(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @logf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @logl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @logf128(fp128 noundef) [[NOT_READNONE]]
__builtin_log10(f); __builtin_log10f(f); __builtin_log10l(f); __builtin_log10f128(f);
// NO__ERRNO: declare double @llvm.log10.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.log10.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.log10.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.log10.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @log10(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @log10f(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @log10l(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @log10f128(fp128 noundef) [[NOT_READNONE]]
__builtin_log1p(f); __builtin_log1pf(f); __builtin_log1pl(f); __builtin_log1pf128(f);
// NO__ERRNO: declare double @log1p(double noundef) [[READNONE]]
// NO__ERRNO: declare float @log1pf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @log1pl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @log1pf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @log1p(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @log1pf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @log1pl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @log1pf128(fp128 noundef) [[NOT_READNONE]]
__builtin_log2(f); __builtin_log2f(f); __builtin_log2l(f); __builtin_log2f128(f);
// NO__ERRNO: declare double @llvm.log2.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.log2.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.log2.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.log2.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @log2(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @log2f(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @log2l(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @log2f128(fp128 noundef) [[NOT_READNONE]]
__builtin_logb(f); __builtin_logbf(f); __builtin_logbl(f); __builtin_logbf128(f);
// NO__ERRNO: declare double @logb(double noundef) [[READNONE]]
// NO__ERRNO: declare float @logbf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @logbl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @logbf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @logb(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @logbf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @logbl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @logbf128(fp128 noundef) [[NOT_READNONE]]
__builtin_lrint(f); __builtin_lrintf(f); __builtin_lrintl(f); __builtin_lrintf128(f);
// NO__ERRNO: declare i64 @llvm.lrint.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lrint.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lrint.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lrint.i64.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @lrint(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lrintf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lrintl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lrintf128(fp128 noundef) [[NOT_READNONE]]
__builtin_lround(f); __builtin_lroundf(f); __builtin_lroundl(f); __builtin_lroundf128(f);
// NO__ERRNO: declare i64 @llvm.lround.i64.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lround.i64.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare i64 @llvm.lround.i64.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare i64 @lround(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lroundf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lroundl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare i64 @lroundf128(fp128 noundef) [[NOT_READNONE]]
__builtin_nearbyint(f); __builtin_nearbyintf(f); __builtin_nearbyintl(f); __builtin_nearbyintf128(f);
// NO__ERRNO: declare double @llvm.nearbyint.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.nearbyint.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.nearbyint.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.nearbyint.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.nearbyint.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.nearbyint.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.nearbyint.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.nearbyint.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_nextafter(f,f); __builtin_nextafterf(f,f); __builtin_nextafterl(f,f); __builtin_nextafterf128(f,f);
// NO__ERRNO: declare double @nextafter(double noundef, double noundef) [[READNONE]]
// NO__ERRNO: declare float @nextafterf(float noundef, float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @nextafterl(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @nextafterf128(fp128 noundef, fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @nextafter(double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @nextafterf(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @nextafterl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @nextafterf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_nexttoward(f,f); __builtin_nexttowardf(f,f);__builtin_nexttowardl(f,f); __builtin_nexttowardf128(f,f);
// NO__ERRNO: declare double @nexttoward(double noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare float @nexttowardf(float noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @nexttowardl(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @nexttowardf128(fp128 noundef, fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @nexttoward(double noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @nexttowardf(float noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @nexttowardl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @nexttowardf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_remainder(f,f); __builtin_remainderf(f,f); __builtin_remainderl(f,f); __builtin_remainderf128(f,f);
// NO__ERRNO: declare double @remainder(double noundef, double noundef) [[READNONE]]
// NO__ERRNO: declare float @remainderf(float noundef, float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @remainderl(x86_fp80 noundef, x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @remainderf128(fp128 noundef, fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @remainder(double noundef, double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @remainderf(float noundef, float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @remainderl(x86_fp80 noundef, x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @remainderf128(fp128 noundef, fp128 noundef) [[NOT_READNONE]]
__builtin_remquo(f,f,i); __builtin_remquof(f,f,i); __builtin_remquol(f,f,i); __builtin_remquof128(f,f,i);
// NO__ERRNO: declare double @remquo(double noundef, double noundef, i32* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare float @remquof(float noundef, float noundef, i32* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare x86_fp80 @remquol(x86_fp80 noundef, x86_fp80 noundef, i32* noundef) [[NOT_READNONE]]
// NO__ERRNO: declare fp128 @remquof128(fp128 noundef, fp128 noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare double @remquo(double noundef, double noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @remquof(float noundef, float noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @remquol(x86_fp80 noundef, x86_fp80 noundef, i32* noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @remquof128(fp128 noundef, fp128 noundef, i32* noundef) [[NOT_READNONE]]
__builtin_rint(f); __builtin_rintf(f); __builtin_rintl(f); __builtin_rintf128(f);
// NO__ERRNO: declare double @llvm.rint.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.rint.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.rint.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.rint.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.rint.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.rint.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.rint.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.rint.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_round(f); __builtin_roundf(f); __builtin_roundl(f); __builtin_roundf128(f);
// NO__ERRNO: declare double @llvm.round.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.round.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.round.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.round.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.round.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.round.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.round.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.round.f128(fp128) [[READNONE_INTRINSIC]]
__builtin_scalbln(f,f); __builtin_scalblnf(f,f); __builtin_scalblnl(f,f); __builtin_scalblnf128(f,f);
// NO__ERRNO: declare double @scalbln(double noundef, i64 noundef) [[READNONE]]
// NO__ERRNO: declare float @scalblnf(float noundef, i64 noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @scalblnl(x86_fp80 noundef, i64 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @scalblnf128(fp128 noundef, i64 noundef) [[READNONE]]
// HAS_ERRNO: declare double @scalbln(double noundef, i64 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @scalblnf(float noundef, i64 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @scalblnl(x86_fp80 noundef, i64 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @scalblnf128(fp128 noundef, i64 noundef) [[NOT_READNONE]]
__builtin_scalbn(f,f); __builtin_scalbnf(f,f); __builtin_scalbnl(f,f); __builtin_scalbnf128(f,f);
// NO__ERRNO: declare double @scalbn(double noundef, i32 noundef) [[READNONE]]
// NO__ERRNO: declare float @scalbnf(float noundef, i32 noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @scalbnl(x86_fp80 noundef, i32 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @scalbnf128(fp128 noundef, i32 noundef) [[READNONE]]
// HAS_ERRNO: declare double @scalbn(double noundef, i32 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @scalbnf(float noundef, i32 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @scalbnl(x86_fp80 noundef, i32 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @scalbnf128(fp128 noundef, i32 noundef) [[NOT_READNONE]]
__builtin_sin(f); __builtin_sinf(f); __builtin_sinl(f); __builtin_sinf128(f);
// NO__ERRNO: declare double @llvm.sin.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.sin.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.sin.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.sin.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @sin(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @sinf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @sinl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @sinf128(fp128 noundef) [[NOT_READNONE]]
__builtin_sinh(f); __builtin_sinhf(f); __builtin_sinhl(f); __builtin_sinhf128(f);
// NO__ERRNO: declare double @sinh(double noundef) [[READNONE]]
// NO__ERRNO: declare float @sinhf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @sinhl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @sinhf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @sinh(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @sinhf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @sinhl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @sinhf128(fp128 noundef) [[NOT_READNONE]]
__builtin_sqrt(f); __builtin_sqrtf(f); __builtin_sqrtl(f); __builtin_sqrtf128(f);
// NO__ERRNO: declare double @llvm.sqrt.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.sqrt.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.sqrt.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.sqrt.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @sqrt(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @sqrtf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @sqrtl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @sqrtf128(fp128 noundef) [[NOT_READNONE]]
__builtin_tan(f); __builtin_tanf(f); __builtin_tanl(f); __builtin_tanf128(f);
// NO__ERRNO: declare double @tan(double noundef) [[READNONE]]
// NO__ERRNO: declare float @tanf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @tanf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @tan(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @tanf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @tanl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @tanf128(fp128 noundef) [[NOT_READNONE]]
__builtin_tanh(f); __builtin_tanhf(f); __builtin_tanhl(f); __builtin_tanhf128(f);
// NO__ERRNO: declare double @tanh(double noundef) [[READNONE]]
// NO__ERRNO: declare float @tanhf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @tanhl(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @tanhf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @tanh(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @tanhf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @tanhl(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @tanhf128(fp128 noundef) [[NOT_READNONE]]
__builtin_tgamma(f); __builtin_tgammaf(f); __builtin_tgammal(f); __builtin_tgammaf128(f);
// NO__ERRNO: declare double @tgamma(double noundef) [[READNONE]]
// NO__ERRNO: declare float @tgammaf(float noundef) [[READNONE]]
// NO__ERRNO: declare x86_fp80 @tgammal(x86_fp80 noundef) [[READNONE]]
// NO__ERRNO: declare fp128 @tgammaf128(fp128 noundef) [[READNONE]]
// HAS_ERRNO: declare double @tgamma(double noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare float @tgammaf(float noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare x86_fp80 @tgammal(x86_fp80 noundef) [[NOT_READNONE]]
// HAS_ERRNO: declare fp128 @tgammaf128(fp128 noundef) [[NOT_READNONE]]
__builtin_trunc(f); __builtin_truncf(f); __builtin_truncl(f); __builtin_truncf128(f);
// NO__ERRNO: declare double @llvm.trunc.f64(double) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare float @llvm.trunc.f32(float) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare x86_fp80 @llvm.trunc.f80(x86_fp80) [[READNONE_INTRINSIC]]
// NO__ERRNO: declare fp128 @llvm.trunc.f128(fp128) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare double @llvm.trunc.f64(double) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare float @llvm.trunc.f32(float) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare x86_fp80 @llvm.trunc.f80(x86_fp80) [[READNONE_INTRINSIC]]
// HAS_ERRNO: declare fp128 @llvm.trunc.f128(fp128) [[READNONE_INTRINSIC]]
};
// NO__ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
// NO__ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} }
// NO__ERRNO: attributes [[PURE]] = { {{.*}}readonly{{.*}} }
// HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} }
// HAS_ERRNO: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// HAS_ERRNO: attributes [[PURE]] = { {{.*}}readonly{{.*}} }
// HAS_ERRNO: attributes [[READNONE]] = { {{.*}}readnone{{.*}} }
// HAS_ERRNO_GNU: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
// HAS_ERRNO_WIN: attributes [[READNONE_INTRINSIC]] = { {{.*}}readnone{{.*}} }
|
the_stack_data/152133.c
|
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
//---------------------------------------------------------------------
// program CG
//---------------------------------------------------------------------
//----------
// Class S:
//----------
//----------
// Class W:
//----------
//----------
// Class A:
//----------
//----------
// Class B:
//----------
//----------
// Class C:
//----------
struct anon_NAS_CG_c_75 {
double real;
double imag;
};
typedef struct anon_NAS_CG_c_75 dcomplex;
//---------------------------------------------------------------------
/*common / main_int_mem /*/
int colidx[567000];
int rowstr[7001];
int iv[7000];
int arow[7000];
int acol[63000];
/*common / main_flt_mem /*/
double aelt[63000];
double a[567000];
double x[7002];
double z[7002];
double p[7002];
double q[7002];
double r[7002];
/*common / partit_size /*/
int naa;
int nzz;
int firstrow;
int lastrow;
int firstcol;
int lastcol;
/*common /urando/*/
double amult;
double tran;
//---------------------------------------------------------------------
int clava_dcg_global[ 27 ] = {0};
void conj_grad(int colidx[], int rowstr[], double x[], double z[], double a[], double p[], double q[], double r[], double *rnorm);
void makea(int n, int nz, double a[], int colidx[], int rowstr[], int firstrow, int lastrow, int firstcol, int lastcol, int arow[], int acol[][9], double aelt[][9], int iv[]);
void sparse(double a[], int colidx[], int rowstr[], int n, int nz, int nozer, int arow[], int acol[][9], double aelt[][9], int firstrow, int lastrow, int nzloc[], double rcond, double shift);
void sprnvc(int n, int nz, int nn1, double v[], int iv[]);
int icnvrt(double x, int ipwr2);
void vecset(int n, double v[], int iv[], int *nzv, int i, double val);
void print_results(char *name, char class, int n1, int n2, int n3, int niter, double t, double mops, char *optype, int verified);
double randlc(double *x, double a);
void vranlc(int n, double *x, double a, double y[]);
double start[64];
double elapsed[64];
double elapsed_time();
void timer_clear(int n);
void timer_start(int n);
void timer_stop(int n);
double timer_read(int n);
void wtime(double *t);
//---------------------------------------------------------------------
void clava_call_graph() {
FILE *log_file_361 = fopen("/home/specs/jbispo/repos/clava-examples/2019-C_Stress_Test/output/NAS_CG.dot", "w+");
if (log_file_361 == NULL)
{
printf("Error opening file /home/specs/jbispo/repos/clava-examples/2019-C_Stress_Test/output/NAS_CG.dot\n");
exit(1);
}
fprintf(log_file_361, "digraph dynamic_call_graph {\n\n");
if(clava_dcg_global[0] != 0) {
fprintf(log_file_361, " main -> timer_clear [label=\"%d\"];\n", clava_dcg_global[0]);
}
if(clava_dcg_global[1] != 0) {
fprintf(log_file_361, " main -> timer_start [label=\"%d\"];\n", clava_dcg_global[1]);
}
if(clava_dcg_global[2] != 0) {
fprintf(log_file_361, " main -> printf [label=\"%d\"];\n", clava_dcg_global[2]);
}
if(clava_dcg_global[3] != 0) {
fprintf(log_file_361, " main -> randlc [label=\"%d\"];\n", clava_dcg_global[3]);
}
if(clava_dcg_global[4] != 0) {
fprintf(log_file_361, " main -> makea [label=\"%d\"];\n", clava_dcg_global[4]);
}
if(clava_dcg_global[5] != 0) {
fprintf(log_file_361, " main -> conj_grad [label=\"%d\"];\n", clava_dcg_global[5]);
}
if(clava_dcg_global[6] != 0) {
fprintf(log_file_361, " main -> sqrt [label=\"%d\"];\n", clava_dcg_global[6]);
}
if(clava_dcg_global[7] != 0) {
fprintf(log_file_361, " main -> timer_stop [label=\"%d\"];\n", clava_dcg_global[7]);
}
if(clava_dcg_global[8] != 0) {
fprintf(log_file_361, " main -> timer_read [label=\"%d\"];\n", clava_dcg_global[8]);
}
if(clava_dcg_global[9] != 0) {
fprintf(log_file_361, " main -> fabs [label=\"%d\"];\n", clava_dcg_global[9]);
}
if(clava_dcg_global[10] != 0) {
fprintf(log_file_361, " main -> print_results [label=\"%d\"];\n", clava_dcg_global[10]);
}
if(clava_dcg_global[11] != 0) {
fprintf(log_file_361, " conj_grad -> sqrt [label=\"%d\"];\n", clava_dcg_global[11]);
}
if(clava_dcg_global[12] != 0) {
fprintf(log_file_361, " makea -> sprnvc [label=\"%d\"];\n", clava_dcg_global[12]);
}
if(clava_dcg_global[13] != 0) {
fprintf(log_file_361, " makea -> vecset [label=\"%d\"];\n", clava_dcg_global[13]);
}
if(clava_dcg_global[14] != 0) {
fprintf(log_file_361, " makea -> sparse [label=\"%d\"];\n", clava_dcg_global[14]);
}
if(clava_dcg_global[15] != 0) {
fprintf(log_file_361, " sparse -> printf [label=\"%d\"];\n", clava_dcg_global[15]);
}
if(clava_dcg_global[16] != 0) {
fprintf(log_file_361, " sparse -> exit [label=\"%d\"];\n", clava_dcg_global[16]);
}
if(clava_dcg_global[17] != 0) {
fprintf(log_file_361, " sparse -> pow [label=\"%d\"];\n", clava_dcg_global[17]);
}
if(clava_dcg_global[18] != 0) {
fprintf(log_file_361, " sprnvc -> randlc [label=\"%d\"];\n", clava_dcg_global[18]);
}
if(clava_dcg_global[19] != 0) {
fprintf(log_file_361, " sprnvc -> icnvrt [label=\"%d\"];\n", clava_dcg_global[19]);
}
if(clava_dcg_global[20] != 0) {
fprintf(log_file_361, " wtime -> gettimeofday [label=\"%d\"];\n", clava_dcg_global[20]);
}
if(clava_dcg_global[21] != 0) {
fprintf(log_file_361, " elapsed_time -> wtime [label=\"%d\"];\n", clava_dcg_global[21]);
}
if(clava_dcg_global[22] != 0) {
fprintf(log_file_361, " timer_start -> elapsed_time [label=\"%d\"];\n", clava_dcg_global[22]);
}
if(clava_dcg_global[23] != 0) {
fprintf(log_file_361, " timer_stop -> elapsed_time [label=\"%d\"];\n", clava_dcg_global[23]);
}
if(clava_dcg_global[24] != 0) {
fprintf(log_file_361, " print_results -> printf [label=\"%d\"];\n", clava_dcg_global[24]);
}
if(clava_dcg_global[25] != 0) {
fprintf(log_file_361, " print_results -> sprintf [label=\"%d\"];\n", clava_dcg_global[25]);
}
if(clava_dcg_global[26] != 0) {
fprintf(log_file_361, " print_results -> pow [label=\"%d\"];\n", clava_dcg_global[26]);
}
fprintf(log_file_361, "}\n");
fclose(log_file_361);
}
int main(int argc, char *argv[]) {
atexit(clava_call_graph);
int i, j, k, it;
double zeta;
double rnorm;
double norm_temp1, norm_temp2;
double t, mflops, tmax;
char Class;
int verified;
double zeta_verify_value, epsilon, err;
char *t_names[3];
for(i = 0; i < 3; i++) {
clava_dcg_global[ 0 ]++;
timer_clear(i);
}
clava_dcg_global[ 1 ]++;
timer_start(0);
firstrow = 0;
lastrow = 7000 - 1;
firstcol = 0;
lastcol = 7000 - 1;
if(7000 == 1400 && 8 == 7 && 15 == 15 && 12.0 == 10) {
Class = 'S';
zeta_verify_value = 8.5971775078648;
}
else if(7000 == 7000 && 8 == 8 && 15 == 15 && 12.0 == 12) {
Class = 'W';
zeta_verify_value = 10.362595087124;
}
else if(7000 == 14000 && 8 == 11 && 15 == 15 && 12.0 == 20) {
Class = 'A';
zeta_verify_value = 17.130235054029;
}
else if(7000 == 75000 && 8 == 13 && 15 == 75 && 12.0 == 60) {
Class = 'B';
zeta_verify_value = 22.712745482631;
}
else if(7000 == 150000 && 8 == 15 && 15 == 75 && 12.0 == 110) {
Class = 'C';
zeta_verify_value = 28.973605592845;
}
else if(7000 == 1500000 && 8 == 21 && 15 == 100 && 12.0 == 500) {
Class = 'D';
zeta_verify_value = 52.514532105794;
}
else if(7000 == 9000000 && 8 == 26 && 15 == 100 && 12.0 == 1500) {
Class = 'E';
zeta_verify_value = 77.522164599383;
}
else {
Class = 'U';
}
clava_dcg_global[ 2 ]++;
printf("\n\n NAS Parallel Benchmarks (NPB3.3-SER-C) - CG Benchmark\n\n");
clava_dcg_global[ 2 ]++;
printf(" Size: %11d\n", 7000);
clava_dcg_global[ 2 ]++;
printf(" Iterations: %5d\n", 15);
clava_dcg_global[ 2 ]++;
printf("\n");
naa = 7000;
nzz = (7000 * (8 + 1) * (8 + 1));
//---------------------------------------------------------------------
// Inialize random number generator
//---------------------------------------------------------------------
tran = 314159265.0;
amult = 1220703125.0;
clava_dcg_global[ 3 ]++;
zeta = randlc(&tran, amult);
//---------------------------------------------------------------------
//
//---------------------------------------------------------------------
clava_dcg_global[ 4 ]++;
makea(naa, nzz, a, colidx, rowstr, firstrow, lastrow, firstcol, lastcol, arow, (int (*)[9]) (void *) acol, (double (*)[9]) (void *) aelt, iv);
//---------------------------------------------------------------------
// Note: as a result of the above call to makea:
// values of j used in indexing rowstr go from 0 --> lastrow-firstrow
// values of colidx which are col indexes go from firstcol --> lastcol
// So:
// Shift the col index vals from actual (firstcol --> lastcol )
// to local, i.e., (0 --> lastcol-firstcol)
//---------------------------------------------------------------------
for(j = 0; j < lastrow - firstrow + 1; j++) {
for(k = rowstr[j]; k < rowstr[j + 1]; k++) {
colidx[k] = colidx[k] - firstcol;
}
}
//---------------------------------------------------------------------
// set starting vector to (1, 1, .... 1)
//---------------------------------------------------------------------
for(i = 0; i < 7000 + 1; i++) {
x[i] = 1.0;
}
for(j = 0; j < lastcol - firstcol + 1; j++) {
q[j] = 0.0;
z[j] = 0.0;
r[j] = 0.0;
p[j] = 0.0;
}
zeta = 0.0;
//---------------------------------------------------------------------
//---->
// Do one iteration untimed to init all code and data page tables
//----> (then reinit, start timing, to niter its)
//---------------------------------------------------------------------
for(it = 1; it <= 1; it++) { // end of do one iteration untimed
//---------------------------------------------------------------------
// The call to the conjugate gradient routine:
//---------------------------------------------------------------------
clava_dcg_global[ 5 ]++;
conj_grad(colidx, rowstr, x, z, a, p, q, r, &rnorm);
//---------------------------------------------------------------------
// zeta = shift + 1/(x.z)
// So, first: (x.z)
// Also, find norm of z
// So, first: (z.z)
//---------------------------------------------------------------------
norm_temp1 = 0.0;
norm_temp2 = 0.0;
for(j = 0; j < lastcol - firstcol + 1; j++) {
norm_temp1 = norm_temp1 + x[j] * z[j];
norm_temp2 = norm_temp2 + z[j] * z[j];
}
clava_dcg_global[ 6 ]++;
norm_temp2 = 1.0 / sqrt(norm_temp2);
//---------------------------------------------------------------------
// Normalize z to obtain x
//---------------------------------------------------------------------
for(j = 0; j < lastcol - firstcol + 1; j++) {
x[j] = norm_temp2 * z[j];
}
}
//---------------------------------------------------------------------
// set starting vector to (1, 1, .... 1)
//---------------------------------------------------------------------
for(i = 0; i < 7000 + 1; i++) {
x[i] = 1.0;
}
zeta = 0.0;
clava_dcg_global[ 7 ]++;
timer_stop(0);
clava_dcg_global[ 2 ]++;
clava_dcg_global[ 8 ]++;
printf(" Initialization time = %15.3f seconds\n", timer_read(0));
clava_dcg_global[ 1 ]++;
timer_start(1);
//---------------------------------------------------------------------
//---->
// Main Iteration for inverse power method
//---->
//---------------------------------------------------------------------
for(it = 1; it <= 15; it++) { // end of main iter inv pow meth
//---------------------------------------------------------------------
// The call to the conjugate gradient routine:
//---------------------------------------------------------------------
clava_dcg_global[ 5 ]++;
conj_grad(colidx, rowstr, x, z, a, p, q, r, &rnorm);
//---------------------------------------------------------------------
// zeta = shift + 1/(x.z)
// So, first: (x.z)
// Also, find norm of z
// So, first: (z.z)
//---------------------------------------------------------------------
norm_temp1 = 0.0;
norm_temp2 = 0.0;
for(j = 0; j < lastcol - firstcol + 1; j++) {
norm_temp1 = norm_temp1 + x[j] * z[j];
norm_temp2 = norm_temp2 + z[j] * z[j];
}
clava_dcg_global[ 6 ]++;
norm_temp2 = 1.0 / sqrt(norm_temp2);
zeta = 12.0 + 1.0 / norm_temp1;
if(it == 1) {
clava_dcg_global[ 2 ]++;
printf("\n iteration ||r|| zeta\n");
}
clava_dcg_global[ 2 ]++;
printf(" %5d %20.14E%20.13f\n", it, rnorm, zeta);
//---------------------------------------------------------------------
// Normalize z to obtain x
//---------------------------------------------------------------------
for(j = 0; j < lastcol - firstcol + 1; j++) {
x[j] = norm_temp2 * z[j];
}
}
clava_dcg_global[ 7 ]++;
timer_stop(1);
//---------------------------------------------------------------------
// End of timed section
//---------------------------------------------------------------------
clava_dcg_global[ 8 ]++;
t = timer_read(1);
clava_dcg_global[ 2 ]++;
printf(" Benchmark completed\n");
epsilon = 1.0e-10;
if(Class != 'U') {
clava_dcg_global[ 9 ]++;
err = fabs(zeta - zeta_verify_value) / zeta_verify_value;
if(err <= epsilon) {
verified = 1;
clava_dcg_global[ 2 ]++;
printf(" VERIFICATION SUCCESSFUL\n");
clava_dcg_global[ 2 ]++;
printf(" Zeta is %20.13E\n", zeta);
clava_dcg_global[ 2 ]++;
printf(" Error is %20.13E\n", err);
}
else {
verified = 0;
clava_dcg_global[ 2 ]++;
printf(" VERIFICATION FAILED\n");
clava_dcg_global[ 2 ]++;
printf(" Zeta %20.13E\n", zeta);
clava_dcg_global[ 2 ]++;
printf(" The correct zeta is %20.13E\n", zeta_verify_value);
}
}
else {
verified = 0;
clava_dcg_global[ 2 ]++;
printf(" Problem size unknown\n");
clava_dcg_global[ 2 ]++;
printf(" NO VERIFICATION PERFORMED\n");
}
if(t != 0.0) {
mflops = (double) (2 * 15 * 7000) * (3.0 + (double) (8 * (8 + 1)) + 25.0 * (5.0 + (double) (8 * (8 + 1))) + 3.0) / t / 1000000.0;
}
else {
mflops = 0.0;
}
clava_dcg_global[ 10 ]++;
print_results("CG", Class, 7000, 0, 0, 15, t, mflops, " floating point", verified);
int exitValue = verified ? 0 : 1;
return exitValue;
}
//---------------------------------------------------------------------
// Floaging point arrays here are named as in NPB1 spec discussion of
// CG algorithm
//---------------------------------------------------------------------
void conj_grad(int colidx[], int rowstr[], double x[], double z[], double a[], double p[], double q[], double r[], double *rnorm) {
int j, k;
int cgit, cgitmax = 25;
double d, sum, rho, rho0, alpha, beta;
rho = 0.0;
//---------------------------------------------------------------------
// Initialize the CG algorithm:
//---------------------------------------------------------------------
for(j = 0; j < naa + 1; j++) {
q[j] = 0.0;
z[j] = 0.0;
r[j] = x[j];
p[j] = r[j];
}
//---------------------------------------------------------------------
// rho = r.r
// Now, obtain the norm of r: First, sum squares of r elements locally...
//---------------------------------------------------------------------
for(j = 0; j < lastcol - firstcol + 1; j++) {
rho = rho + r[j] * r[j];
}
//---------------------------------------------------------------------
//---->
// The conj grad iteration loop
//---->
//---------------------------------------------------------------------
for(cgit = 1; cgit <= cgitmax; cgit++) { // end of do cgit=1,cgitmax
//---------------------------------------------------------------------
// q = A.p
// The partition submatrix-vector multiply: use workspace w
//---------------------------------------------------------------------
//
// NOTE: this version of the multiply is actually (slightly: maybe %5)
// faster on the sp2 on 16 nodes than is the unrolled-by-2 version
// below. On the Cray t3d, the reverse is 1, i.e., the
// unrolled-by-two version is some 10% faster.
// The unrolled-by-8 version below is significantly faster
// on the Cray t3d - overall speed of code is 1.5 times faster.
for(j = 0; j < lastrow - firstrow + 1; j++) {
sum = 0.0;
for(k = rowstr[j]; k < rowstr[j + 1]; k++) {
sum = sum + a[k] * p[colidx[k]];
}
q[j] = sum;
}
/*
for (j = 0; j < lastrow - firstrow + 1; j++) {
int i = rowstr[j];
int iresidue = (rowstr[j+1] - i) % 2;
double sum1 = 0.0;
double sum2 = 0.0;
if (iresidue == 1)
sum1 = sum1 + a[i]*p[colidx[i]];
for (k = i + iresidue; k <= rowstr[j+1] - 2; k += 2) {
sum1 = sum1 + a[k] *p[colidx[k]];
sum2 = sum2 + a[k+1]*p[colidx[k+1]];
}
q[j] = sum1 + sum2;
}
*/
/*
for (j = 0; j < lastrow - firstrow + 1; j++) {
int i = rowstr[j];
int iresidue = (rowstr[j+1] - i) % 8;
double sum = 0.0;
for (k = i; k <= i + iresidue - 1; k++) {
sum = sum + a[k]*p[colidx[k]];
}
for (k = i + iresidue; k <= rowstr[j+1] - 8; k += 8) {
sum = sum + a[k ]*p[colidx[k ]]
+ a[k+1]*p[colidx[k+1]]
+ a[k+2]*p[colidx[k+2]]
+ a[k+3]*p[colidx[k+3]]
+ a[k+4]*p[colidx[k+4]]
+ a[k+5]*p[colidx[k+5]]
+ a[k+6]*p[colidx[k+6]]
+ a[k+7]*p[colidx[k+7]];
}
q[j] = sum;
}
*/
//---------------------------------------------------------------------
// Obtain p.q
//---------------------------------------------------------------------
d = 0.0;
for(j = 0; j < lastcol - firstcol + 1; j++) {
d = d + p[j] * q[j];
}
//---------------------------------------------------------------------
// Obtain alpha = rho / (p.q)
//---------------------------------------------------------------------
alpha = rho / d;
//---------------------------------------------------------------------
// Save a temporary of rho
//---------------------------------------------------------------------
rho0 = rho;
//---------------------------------------------------------------------
// Obtain z = z + alpha*p
// and r = r - alpha*q
//---------------------------------------------------------------------
rho = 0.0;
for(j = 0; j < lastcol - firstcol + 1; j++) {
z[j] = z[j] + alpha * p[j];
r[j] = r[j] - alpha * q[j];
}
//---------------------------------------------------------------------
// rho = r.r
// Now, obtain the norm of r: First, sum squares of r elements locally...
//---------------------------------------------------------------------
for(j = 0; j < lastcol - firstcol + 1; j++) {
rho = rho + r[j] * r[j];
}
//---------------------------------------------------------------------
// Obtain beta:
//---------------------------------------------------------------------
beta = rho / rho0;
//---------------------------------------------------------------------
// p = r + beta*p
//---------------------------------------------------------------------
for(j = 0; j < lastcol - firstcol + 1; j++) {
p[j] = r[j] + beta * p[j];
}
}
//---------------------------------------------------------------------
// Compute residual norm explicitly: ||r|| = ||x - A.z||
// First, form A.z
// The partition submatrix-vector multiply
//---------------------------------------------------------------------
sum = 0.0;
for(j = 0; j < lastrow - firstrow + 1; j++) {
d = 0.0;
for(k = rowstr[j]; k < rowstr[j + 1]; k++) {
d = d + a[k] * z[colidx[k]];
}
r[j] = d;
}
//---------------------------------------------------------------------
// At this point, r contains A.z
//---------------------------------------------------------------------
for(j = 0; j < lastcol - firstcol + 1; j++) {
d = x[j] - r[j];
sum = sum + d * d;
}
clava_dcg_global[ 11 ]++;
*rnorm = sqrt(sum);
}
//---------------------------------------------------------------------
// generate the test problem for benchmark 6
// makea generates a sparse matrix with a
// prescribed sparsity distribution
//
// parameter type usage
//
// input
//
// n i number of cols/rows of matrix
// nz i nonzeros as declared array size
// rcond r*8 condition number
// shift r*8 main diagonal shift
//
// output
//
// a r*8 array for nonzeros
// colidx i col indices
// rowstr i row pointers
//
// workspace
//
// iv, arow, acol i
// aelt r*8
//---------------------------------------------------------------------
void makea(int n, int nz, double a[], int colidx[], int rowstr[], int firstrow, int lastrow, int firstcol, int lastcol, int arow[], int acol[][9], double aelt[][9], int iv[]) {
int iouter, ivelt, nzv, nn1;
int ivc[9];
double vc[9];
//---------------------------------------------------------------------
// nonzer is approximately (int(sqrt(nnza /n)));
//---------------------------------------------------------------------
//---------------------------------------------------------------------
// nn1 is the smallest power of two not less than n
//---------------------------------------------------------------------
nn1 = 1;
do {
nn1 = 2 * nn1;
}
while (nn1 < n);
//---------------------------------------------------------------------
// Generate nonzero positions and save for the use in sparse.
//---------------------------------------------------------------------
for(iouter = 0; iouter < n; iouter++) {
nzv = 8;
clava_dcg_global[ 12 ]++;
sprnvc(n, nzv, nn1, vc, ivc);
clava_dcg_global[ 13 ]++;
vecset(n, vc, ivc, &nzv, iouter + 1, 0.5);
arow[iouter] = nzv;
for(ivelt = 0; ivelt < nzv; ivelt++) {
acol[iouter][ivelt] = ivc[ivelt] - 1;
aelt[iouter][ivelt] = vc[ivelt];
}
}
//---------------------------------------------------------------------
// ... make the sparse matrix from list of elements with duplicates
// (iv is used as workspace)
//---------------------------------------------------------------------
clava_dcg_global[ 14 ]++;
sparse(a, colidx, rowstr, n, nz, 8, arow, acol, aelt, firstrow, lastrow, iv, 1.0e-1, 12.0);
}
//---------------------------------------------------------------------
// rows range from firstrow to lastrow
// the rowstr pointers are defined for nrows = lastrow-firstrow+1 values
//---------------------------------------------------------------------
void sparse(double a[], int colidx[], int rowstr[], int n, int nz, int nozer, int arow[], int acol[][9], double aelt[][9], int firstrow, int lastrow, int nzloc[], double rcond, double shift) {
int nrows;
//---------------------------------------------------
// generate a sparse matrix from a list of
// [col, row, element] tri
//---------------------------------------------------
int i, j, j1, j2, nza, k, kk, nzrow, jcol;
double size, scale, ratio, va;
int cont40;
//---------------------------------------------------------------------
// how many rows of result
//---------------------------------------------------------------------
nrows = lastrow - firstrow + 1;
//---------------------------------------------------------------------
// ...count the number of triples in each row
//---------------------------------------------------------------------
for(j = 0; j < nrows + 1; j++) {
rowstr[j] = 0;
}
for(i = 0; i < n; i++) {
for(nza = 0; nza < arow[i]; nza++) {
j = acol[i][nza] + 1;
rowstr[j] = rowstr[j] + arow[i];
}
}
rowstr[0] = 0;
for(j = 1; j < nrows + 1; j++) {
rowstr[j] = rowstr[j] + rowstr[j - 1];
}
nza = rowstr[nrows] - 1;
//---------------------------------------------------------------------
// ... rowstr(j) now is the location of the first nonzero
// of row j of a
//---------------------------------------------------------------------
if(nza > nz) {
clava_dcg_global[ 15 ]++;
printf("Space for matrix elements exceeded in sparse\n");
clava_dcg_global[ 15 ]++;
printf("nza, nzmax = %d, %d\n", nza, nz);
clava_dcg_global[ 16 ]++;
exit(1);
}
//---------------------------------------------------------------------
// ... preload data pages
//---------------------------------------------------------------------
for(j = 0; j < nrows; j++) {
for(k = rowstr[j]; k < rowstr[j + 1]; k++) {
a[k] = 0.0;
colidx[k] = -1;
}
nzloc[j] = 0;
}
//---------------------------------------------------------------------
// ... generate actual values by summing duplicates
//---------------------------------------------------------------------
size = 1.0;
clava_dcg_global[ 17 ]++;
ratio = pow(rcond, (1.0 / (double) (n)));
for(i = 0; i < n; i++) {
for(nza = 0; nza < arow[i]; nza++) {
j = acol[i][nza];
scale = size * aelt[i][nza];
for(nzrow = 0; nzrow < arow[i]; nzrow++) {
jcol = acol[i][nzrow];
va = aelt[i][nzrow] * scale;
//--------------------------------------------------------------------
// ... add the identity * rcond to the generated matrix to bound
// the smallest eigenvalue from below by rcond
//--------------------------------------------------------------------
if(jcol == j && j == i) {
va = va + rcond - shift;
}
cont40 = 0;
for(k = rowstr[j]; k < rowstr[j + 1]; k++) {
if(colidx[k] > jcol) {
//----------------------------------------------------------------
// ... insert colidx here orderly
//----------------------------------------------------------------
for(kk = rowstr[j + 1] - 2; kk >= k; kk--) {
if(colidx[kk] > -1) {
a[kk + 1] = a[kk];
colidx[kk + 1] = colidx[kk];
}
}
colidx[k] = jcol;
a[k] = 0.0;
cont40 = 1;
break;
}
else if(colidx[k] == -1) {
colidx[k] = jcol;
cont40 = 1;
break;
}
else if(colidx[k] == jcol) {
//--------------------------------------------------------------
// ... mark the duplicated entry
//--------------------------------------------------------------
nzloc[j] = nzloc[j] + 1;
cont40 = 1;
break;
}
}
if(cont40 == 0) {
clava_dcg_global[ 15 ]++;
printf("internal error in sparse: i=%d\n", i);
clava_dcg_global[ 16 ]++;
exit(1);
}
a[k] = a[k] + va;
}
}
size = size * ratio;
}
//---------------------------------------------------------------------
// ... remove empty entries and generate final results
//---------------------------------------------------------------------
for(j = 1; j < nrows; j++) {
nzloc[j] = nzloc[j] + nzloc[j - 1];
}
for(j = 0; j < nrows; j++) {
if(j > 0) {
j1 = rowstr[j] - nzloc[j - 1];
}
else {
j1 = 0;
}
j2 = rowstr[j + 1] - nzloc[j];
nza = rowstr[j];
for(k = j1; k < j2; k++) {
a[k] = a[nza];
colidx[k] = colidx[nza];
nza = nza + 1;
}
}
for(j = 1; j < nrows + 1; j++) {
rowstr[j] = rowstr[j] - nzloc[j - 1];
}
nza = rowstr[nrows] - 1;
}
//---------------------------------------------------------------------
// generate a sparse n-vector (v, iv)
// having nzv nonzeros
//
// mark(i) is set to 1 if position i is nonzero.
// mark is all zero on entry and is reset to all zero before exit
// this corrects a performance bug found by John G. Lewis, caused by
// reinitialization of mark on every one of the n calls to sprnvc
//---------------------------------------------------------------------
void sprnvc(int n, int nz, int nn1, double v[], int iv[]) {
int nzv, ii, i;
double vecelt, vecloc;
nzv = 0;
while(nzv < nz) {
clava_dcg_global[ 18 ]++;
vecelt = randlc(&tran, amult);
//---------------------------------------------------------------------
// generate an integer between 1 and n in a portable manner
//---------------------------------------------------------------------
clava_dcg_global[ 18 ]++;
vecloc = randlc(&tran, amult);
clava_dcg_global[ 19 ]++;
i = icnvrt(vecloc, nn1) + 1;
if(i > n) continue;
//---------------------------------------------------------------------
// was this integer generated already?
//---------------------------------------------------------------------
int was_gen = 0;
for(ii = 0; ii < nzv; ii++) {
if(iv[ii] == i) {
was_gen = 1;
break;
}
}
if(was_gen) continue;
v[nzv] = vecelt;
iv[nzv] = i;
nzv = nzv + 1;
}
}
//---------------------------------------------------------------------
// scale a double precision number x in (0,1) by a power of 2 and chop it
//---------------------------------------------------------------------
int icnvrt(double x, int ipwr2) {
return (int) (ipwr2 * x);
}
//---------------------------------------------------------------------
// set ith element of sparse vector (v, iv) with
// nzv nonzeros to val
//---------------------------------------------------------------------
void vecset(int n, double v[], int iv[], int *nzv, int i, double val) {
int k;
int set;
set = 0;
for(k = 0; k < *nzv; k++) {
if(iv[k] == i) {
v[k] = val;
set = 1;
}
}
if(set == 0) {
v[*nzv] = val;
iv[*nzv] = i;
*nzv = *nzv + 1;
}
}
double randlc(double *x, double a) {
//--------------------------------------------------------------------
//
// This routine returns a uniform pseudorandom double precision number in the
// range (0, 1) by using the linear congruential generator
//
// x_{k+1} = a x_k (mod 2^46)
//
// where 0 < x_k < 2^46 and 0 < a < 2^46. This scheme generates 2^44 numbers
// before repeating. The argument A is the same as 'a' in the above formula,
// and X is the same as x_0. A and X must be odd double precision integers
// in the range (1, 2^46). The returned value RANDLC is normalized to be
// between 0 and 1, i.e. RANDLC = 2^(-46) * x_1. X is updated to contain
// the new seed x_1, so that subsequent calls to RANDLC using the same
// arguments will generate a continuous sequence.
//
// This routine should produce the same results on any computer with at least
// 48 mantissa bits in double precision floating point data. On 64 bit
// systems, double precision should be disabled.
//
// David H. Bailey October 26, 1990
//
//--------------------------------------------------------------------
// r23 = pow(0.5, 23.0);
//// pow(0.5, 23.0) = 1.1920928955078125e-07
// r46 = r23 * r23;
// t23 = pow(2.0, 23.0);
//// pow(2.0, 23.0) = 8.388608e+06
// t46 = t23 * t23;
double const r23 = 1.1920928955078125e-07;
double const r46 = r23 * r23;
double const t23 = 8.388608e+06;
double const t46 = t23 * t23;
double t1, t2, t3, t4, a1, a2, x1, x2, z;
double r;
//--------------------------------------------------------------------
// Break A into two parts such that A = 2^23 * A1 + A2.
//--------------------------------------------------------------------
t1 = r23 * a;
a1 = (int) t1;
a2 = a - t23 * a1;
//--------------------------------------------------------------------
// Break X into two parts such that X = 2^23 * X1 + X2, compute
// Z = A1 * X2 + A2 * X1 (mod 2^23), and then
// X = 2^23 * Z + A2 * X2 (mod 2^46).
//--------------------------------------------------------------------
t1 = r23 * (*x);
x1 = (int) t1;
x2 = *x - t23 * x1;
t1 = a1 * x2 + a2 * x1;
t2 = (int) (r23 * t1);
z = t1 - t23 * t2;
t3 = t23 * z + a2 * x2;
t4 = (int) (r46 * t3);
*x = t3 - t46 * t4;
r = r46 * (*x);
return r;
}
void vranlc(int n, double *x, double a, double y[]) {
//--------------------------------------------------------------------
//
// This routine generates N uniform pseudorandom double precision numbers in
// the range (0, 1) by using the linear congruential generator
//
// x_{k+1} = a x_k (mod 2^46)
//
// where 0 < x_k < 2^46 and 0 < a < 2^46. This scheme generates 2^44 numbers
// before repeating. The argument A is the same as 'a' in the above formula,
// and X is the same as x_0. A and X must be odd double precision integers
// in the range (1, 2^46). The N results are placed in Y and are normalized
// to be between 0 and 1. X is updated to contain the new seed, so that
// subsequent calls to VRANLC using the same arguments will generate a
// continuous sequence. If N is zero, only initialization is performed, and
// the variables X, A and Y are ignored.
//
// This routine is the standard version designed for scalar or RISC systems.
// However, it should produce the same results on any single processor
// computer with at least 48 mantissa bits in double precision floating point
// data. On 64 bit systems, double precision should be disabled.
//
//--------------------------------------------------------------------
// r23 = pow(0.5, 23.0);
//// pow(0.5, 23.0) = 1.1920928955078125e-07
// r46 = r23 * r23;
// t23 = pow(2.0, 23.0);
//// pow(2.0, 23.0) = 8.388608e+06
// t46 = t23 * t23;
double const r23 = 1.1920928955078125e-07;
double const r46 = r23 * r23;
double const t23 = 8.388608e+06;
double const t46 = t23 * t23;
double t1, t2, t3, t4, a1, a2, x1, x2, z;
int i;
//--------------------------------------------------------------------
// Break A into two parts such that A = 2^23 * A1 + A2.
//--------------------------------------------------------------------
t1 = r23 * a;
a1 = (int) t1;
a2 = a - t23 * a1;
//--------------------------------------------------------------------
// Generate N results. This loop is not vectorizable.
//--------------------------------------------------------------------
for(i = 0; i < n; i++) {
//--------------------------------------------------------------------
// Break X into two parts such that X = 2^23 * X1 + X2, compute
// Z = A1 * X2 + A2 * X1 (mod 2^23), and then
// X = 2^23 * Z + A2 * X2 (mod 2^46).
//--------------------------------------------------------------------
t1 = r23 * (*x);
x1 = (int) t1;
x2 = *x - t23 * x1;
t1 = a1 * x2 + a2 * x1;
t2 = (int) (r23 * t1);
z = t1 - t23 * t2;
t3 = t23 * z + a2 * x2;
t4 = (int) (r46 * t3);
*x = t3 - t46 * t4;
y[i] = r46 * (*x);
}
return;
}
void wtime(double *t) {
static int sec = -1;
struct timeval tv;
clava_dcg_global[ 20 ]++;
gettimeofday(&tv, (void *) 0);
if(sec < 0) sec = tv.tv_sec;
*t = (tv.tv_sec - sec) + 1.0e-6 * tv.tv_usec;
}
/*****************************************************************/
/****** E L A P S E D _ T I M E ******/
/*****************************************************************/
double elapsed_time() {
double t;
clava_dcg_global[ 21 ]++;
wtime(&t);
return (t);
}
/*****************************************************************/
/****** T I M E R _ C L E A R ******/
/*****************************************************************/
void timer_clear(int n) {
elapsed[n] = 0.0;
}
/*****************************************************************/
/****** T I M E R _ S T A R T ******/
/*****************************************************************/
void timer_start(int n) {
clava_dcg_global[ 22 ]++;
start[n] = elapsed_time();
}
/*****************************************************************/
/****** T I M E R _ S T O P ******/
/*****************************************************************/
void timer_stop(int n) {
double t, now;
clava_dcg_global[ 23 ]++;
now = elapsed_time();
t = now - start[n];
elapsed[n] += t;
}
/*****************************************************************/
/****** T I M E R _ R E A D ******/
/*****************************************************************/
double timer_read(int n) {
return (elapsed[n]);
}
void print_results(char *name, char class, int n1, int n2, int n3, int niter, double t, double mops, char *optype, int verified) {
char size[16];
int j;
clava_dcg_global[ 24 ]++;
printf("\n\n %s Benchmark Completed.\n", name);
clava_dcg_global[ 24 ]++;
printf(" Class = %12c\n", class);
// If this is not a grid-based problem (EP, FT, CG), then
// we only print n1, which contains some measure of the
// problem size. In that case, n2 and n3 are both zero.
// Otherwise, we print the grid size n1xn2xn3
if((n2 == 0) && (n3 == 0)) {
if((name[0] == 'E') && (name[1] == 'P')) {
clava_dcg_global[ 25 ]++;
clava_dcg_global[ 26 ]++;
sprintf(size, "%15.0lf", pow(2.0, n1));
j = 14;
if(size[j] == '.') {
size[j] = ' ';
j--;
}
size[j + 1] = '\0';
clava_dcg_global[ 24 ]++;
printf(" Size = %15s\n", size);
}
else {
clava_dcg_global[ 24 ]++;
printf(" Size = %12d\n", n1);
}
}
else {
clava_dcg_global[ 24 ]++;
printf(" Size = %4dx%4dx%4d\n", n1, n2, n3);
}
clava_dcg_global[ 24 ]++;
printf(" Iterations = %12d\n", niter);
clava_dcg_global[ 24 ]++;
printf(" Time in seconds = %12.2lf\n", t);
clava_dcg_global[ 24 ]++;
printf(" Mop/s total = %15.2lf\n", mops);
clava_dcg_global[ 24 ]++;
printf(" Operation type = %24s\n", optype);
if(verified) {
clava_dcg_global[ 24 ]++;
printf(" Verification = %12s\n", "SUCCESSFUL");
}
else {
clava_dcg_global[ 24 ]++;
printf(" Verification = %12s\n", "UNSUCCESSFUL");
}
}
|
the_stack_data/193893106.c
|
void toto() {
int count=0;
for(int i=0; i<10000; i++) {
switch (i % 3) {
case 0:
count += 2;
break;
case 1:
count += 1;
break;
case 2:
count += 3;
break;
}
}
}
|
the_stack_data/54824252.c
|
/**
* @file
* @brief
*
* @author Anton Kozlov
* @date 22.07.2015
*/
#include <errno.h>
int errno;
|
the_stack_data/70451225.c
|
#include <stdio.h>
int main()
{
printf("Hello, world!");
printf("\n");
return 0;
}
#ifndef __NO_SYSTEM_INIT
void SystemInit()
{}
#endif
|
the_stack_data/15986.c
|
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3//"
# 1 "<built-in>"
#define __STDC__ 1
#define __STDC_VERSION__ 199901L
#define __STDC_HOSTED__ 1
#define __GNUC__ 10
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#define __VERSION__ "10.2.1 20201103 (release)"
#define __ATOMIC_RELAXED 0
#define __ATOMIC_SEQ_CST 5
#define __ATOMIC_ACQUIRE 2
#define __ATOMIC_RELEASE 3
#define __ATOMIC_ACQ_REL 4
#define __ATOMIC_CONSUME 1
#define __OPTIMIZE_SIZE__ 1
#define __OPTIMIZE__ 1
#define __FINITE_MATH_ONLY__ 0
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_LONG_DOUBLE__ 8
#define __SIZEOF_SIZE_T__ 4
#define __CHAR_BIT__ 8
#define __BIGGEST_ALIGNMENT__ 8
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __ORDER_BIG_ENDIAN__ 4321
#define __ORDER_PDP_ENDIAN__ 3412
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __FLOAT_WORD_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __SIZEOF_POINTER__ 4
#define __SIZE_TYPE__ unsigned int
#define __PTRDIFF_TYPE__ int
#define __WCHAR_TYPE__ unsigned int
#define __WINT_TYPE__ unsigned int
#define __INTMAX_TYPE__ long long int
#define __UINTMAX_TYPE__ long long unsigned int
#define __CHAR16_TYPE__ short unsigned int
#define __CHAR32_TYPE__ long unsigned int
#define __SIG_ATOMIC_TYPE__ int
#define __INT8_TYPE__ signed char
#define __INT16_TYPE__ short int
#define __INT32_TYPE__ long int
#define __INT64_TYPE__ long long int
#define __UINT8_TYPE__ unsigned char
#define __UINT16_TYPE__ short unsigned int
#define __UINT32_TYPE__ long unsigned int
#define __UINT64_TYPE__ long long unsigned int
#define __INT_LEAST8_TYPE__ signed char
#define __INT_LEAST16_TYPE__ short int
#define __INT_LEAST32_TYPE__ long int
#define __INT_LEAST64_TYPE__ long long int
#define __UINT_LEAST8_TYPE__ unsigned char
#define __UINT_LEAST16_TYPE__ short unsigned int
#define __UINT_LEAST32_TYPE__ long unsigned int
#define __UINT_LEAST64_TYPE__ long long unsigned int
#define __INT_FAST8_TYPE__ int
#define __INT_FAST16_TYPE__ int
#define __INT_FAST32_TYPE__ int
#define __INT_FAST64_TYPE__ long long int
#define __UINT_FAST8_TYPE__ unsigned int
#define __UINT_FAST16_TYPE__ unsigned int
#define __UINT_FAST32_TYPE__ unsigned int
#define __UINT_FAST64_TYPE__ long long unsigned int
#define __INTPTR_TYPE__ int
#define __UINTPTR_TYPE__ unsigned int
#define __GXX_ABI_VERSION 1014
#define __SCHAR_MAX__ 0x7f
#define __SHRT_MAX__ 0x7fff
#define __INT_MAX__ 0x7fffffff
#define __LONG_MAX__ 0x7fffffffL
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
#define __WCHAR_MAX__ 0xffffffffU
#define __WCHAR_MIN__ 0U
#define __WINT_MAX__ 0xffffffffU
#define __WINT_MIN__ 0U
#define __PTRDIFF_MAX__ 0x7fffffff
#define __SIZE_MAX__ 0xffffffffU
#define __SCHAR_WIDTH__ 8
#define __SHRT_WIDTH__ 16
#define __INT_WIDTH__ 32
#define __LONG_WIDTH__ 32
#define __LONG_LONG_WIDTH__ 64
#define __WCHAR_WIDTH__ 32
#define __WINT_WIDTH__ 32
#define __PTRDIFF_WIDTH__ 32
#define __SIZE_WIDTH__ 32
#define __INTMAX_MAX__ 0x7fffffffffffffffLL
#define __INTMAX_C(c) c ## LL
#define __UINTMAX_MAX__ 0xffffffffffffffffULL
#define __UINTMAX_C(c) c ## ULL
#define __INTMAX_WIDTH__ 64
#define __SIG_ATOMIC_MAX__ 0x7fffffff
#define __SIG_ATOMIC_MIN__ (-__SIG_ATOMIC_MAX__ - 1)
#define __SIG_ATOMIC_WIDTH__ 32
#define __INT8_MAX__ 0x7f
#define __INT16_MAX__ 0x7fff
#define __INT32_MAX__ 0x7fffffffL
#define __INT64_MAX__ 0x7fffffffffffffffLL
#define __UINT8_MAX__ 0xff
#define __UINT16_MAX__ 0xffff
#define __UINT32_MAX__ 0xffffffffUL
#define __UINT64_MAX__ 0xffffffffffffffffULL
#define __INT_LEAST8_MAX__ 0x7f
#define __INT8_C(c) c
#define __INT_LEAST8_WIDTH__ 8
#define __INT_LEAST16_MAX__ 0x7fff
#define __INT16_C(c) c
#define __INT_LEAST16_WIDTH__ 16
#define __INT_LEAST32_MAX__ 0x7fffffffL
#define __INT32_C(c) c ## L
#define __INT_LEAST32_WIDTH__ 32
#define __INT_LEAST64_MAX__ 0x7fffffffffffffffLL
#define __INT64_C(c) c ## LL
#define __INT_LEAST64_WIDTH__ 64
#define __UINT_LEAST8_MAX__ 0xff
#define __UINT8_C(c) c
#define __UINT_LEAST16_MAX__ 0xffff
#define __UINT16_C(c) c
#define __UINT_LEAST32_MAX__ 0xffffffffUL
#define __UINT32_C(c) c ## UL
#define __UINT_LEAST64_MAX__ 0xffffffffffffffffULL
#define __UINT64_C(c) c ## ULL
#define __INT_FAST8_MAX__ 0x7fffffff
#define __INT_FAST8_WIDTH__ 32
#define __INT_FAST16_MAX__ 0x7fffffff
#define __INT_FAST16_WIDTH__ 32
#define __INT_FAST32_MAX__ 0x7fffffff
#define __INT_FAST32_WIDTH__ 32
#define __INT_FAST64_MAX__ 0x7fffffffffffffffLL
#define __INT_FAST64_WIDTH__ 64
#define __UINT_FAST8_MAX__ 0xffffffffU
#define __UINT_FAST16_MAX__ 0xffffffffU
#define __UINT_FAST32_MAX__ 0xffffffffU
#define __UINT_FAST64_MAX__ 0xffffffffffffffffULL
#define __INTPTR_MAX__ 0x7fffffff
#define __INTPTR_WIDTH__ 32
#define __UINTPTR_MAX__ 0xffffffffU
#define __GCC_IEC_559 0
#define __GCC_IEC_559_COMPLEX 0
#define __FLT_EVAL_METHOD__ 0
#define __FLT_EVAL_METHOD_TS_18661_3__ 0
#define __DEC_EVAL_METHOD__ 2
#define __FLT_RADIX__ 2
#define __FLT_MANT_DIG__ 24
#define __FLT_DIG__ 6
#define __FLT_MIN_EXP__ (-125)
#define __FLT_MIN_10_EXP__ (-37)
#define __FLT_MAX_EXP__ 128
#define __FLT_MAX_10_EXP__ 38
#define __FLT_DECIMAL_DIG__ 9
#define __FLT_MAX__ 3.4028234663852886e+38F
#define __FLT_NORM_MAX__ 3.4028234663852886e+38F
#define __FLT_MIN__ 1.1754943508222875e-38F
#define __FLT_EPSILON__ 1.1920928955078125e-7F
#define __FLT_DENORM_MIN__ 1.4012984643248171e-45F
#define __FLT_HAS_DENORM__ 1
#define __FLT_HAS_INFINITY__ 1
#define __FLT_HAS_QUIET_NAN__ 1
#define __DBL_MANT_DIG__ 53
#define __DBL_DIG__ 15
#define __DBL_MIN_EXP__ (-1021)
#define __DBL_MIN_10_EXP__ (-307)
#define __DBL_MAX_EXP__ 1024
#define __DBL_MAX_10_EXP__ 308
#define __DBL_DECIMAL_DIG__ 17
#define __DBL_MAX__ ((double)1.7976931348623157e+308L)
#define __DBL_NORM_MAX__ ((double)1.7976931348623157e+308L)
#define __DBL_MIN__ ((double)2.2250738585072014e-308L)
#define __DBL_EPSILON__ ((double)2.2204460492503131e-16L)
#define __DBL_DENORM_MIN__ ((double)4.9406564584124654e-324L)
#define __DBL_HAS_DENORM__ 1
#define __DBL_HAS_INFINITY__ 1
#define __DBL_HAS_QUIET_NAN__ 1
#define __LDBL_MANT_DIG__ 53
#define __LDBL_DIG__ 15
#define __LDBL_MIN_EXP__ (-1021)
#define __LDBL_MIN_10_EXP__ (-307)
#define __LDBL_MAX_EXP__ 1024
#define __LDBL_MAX_10_EXP__ 308
#define __DECIMAL_DIG__ 17
#define __LDBL_DECIMAL_DIG__ 17
#define __LDBL_MAX__ 1.7976931348623157e+308L
#define __LDBL_NORM_MAX__ 1.7976931348623157e+308L
#define __LDBL_MIN__ 2.2250738585072014e-308L
#define __LDBL_EPSILON__ 2.2204460492503131e-16L
#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L
#define __LDBL_HAS_DENORM__ 1
#define __LDBL_HAS_INFINITY__ 1
#define __LDBL_HAS_QUIET_NAN__ 1
#define __FLT32_MANT_DIG__ 24
#define __FLT32_DIG__ 6
#define __FLT32_MIN_EXP__ (-125)
#define __FLT32_MIN_10_EXP__ (-37)
#define __FLT32_MAX_EXP__ 128
#define __FLT32_MAX_10_EXP__ 38
#define __FLT32_DECIMAL_DIG__ 9
#define __FLT32_MAX__ 3.4028234663852886e+38F32
#define __FLT32_NORM_MAX__ 3.4028234663852886e+38F32
#define __FLT32_MIN__ 1.1754943508222875e-38F32
#define __FLT32_EPSILON__ 1.1920928955078125e-7F32
#define __FLT32_DENORM_MIN__ 1.4012984643248171e-45F32
#define __FLT32_HAS_DENORM__ 1
#define __FLT32_HAS_INFINITY__ 1
#define __FLT32_HAS_QUIET_NAN__ 1
#define __FLT64_MANT_DIG__ 53
#define __FLT64_DIG__ 15
#define __FLT64_MIN_EXP__ (-1021)
#define __FLT64_MIN_10_EXP__ (-307)
#define __FLT64_MAX_EXP__ 1024
#define __FLT64_MAX_10_EXP__ 308
#define __FLT64_DECIMAL_DIG__ 17
#define __FLT64_MAX__ 1.7976931348623157e+308F64
#define __FLT64_NORM_MAX__ 1.7976931348623157e+308F64
#define __FLT64_MIN__ 2.2250738585072014e-308F64
#define __FLT64_EPSILON__ 2.2204460492503131e-16F64
#define __FLT64_DENORM_MIN__ 4.9406564584124654e-324F64
#define __FLT64_HAS_DENORM__ 1
#define __FLT64_HAS_INFINITY__ 1
#define __FLT64_HAS_QUIET_NAN__ 1
#define __FLT32X_MANT_DIG__ 53
#define __FLT32X_DIG__ 15
#define __FLT32X_MIN_EXP__ (-1021)
#define __FLT32X_MIN_10_EXP__ (-307)
#define __FLT32X_MAX_EXP__ 1024
#define __FLT32X_MAX_10_EXP__ 308
#define __FLT32X_DECIMAL_DIG__ 17
#define __FLT32X_MAX__ 1.7976931348623157e+308F32x
#define __FLT32X_NORM_MAX__ 1.7976931348623157e+308F32x
#define __FLT32X_MIN__ 2.2250738585072014e-308F32x
#define __FLT32X_EPSILON__ 2.2204460492503131e-16F32x
#define __FLT32X_DENORM_MIN__ 4.9406564584124654e-324F32x
#define __FLT32X_HAS_DENORM__ 1
#define __FLT32X_HAS_INFINITY__ 1
#define __FLT32X_HAS_QUIET_NAN__ 1
#define __SFRACT_FBIT__ 7
#define __SFRACT_IBIT__ 0
#define __SFRACT_MIN__ (-0.5HR-0.5HR)
#define __SFRACT_MAX__ 0X7FP-7HR
#define __SFRACT_EPSILON__ 0x1P-7HR
#define __USFRACT_FBIT__ 8
#define __USFRACT_IBIT__ 0
#define __USFRACT_MIN__ 0.0UHR
#define __USFRACT_MAX__ 0XFFP-8UHR
#define __USFRACT_EPSILON__ 0x1P-8UHR
#define __FRACT_FBIT__ 15
#define __FRACT_IBIT__ 0
#define __FRACT_MIN__ (-0.5R-0.5R)
#define __FRACT_MAX__ 0X7FFFP-15R
#define __FRACT_EPSILON__ 0x1P-15R
#define __UFRACT_FBIT__ 16
#define __UFRACT_IBIT__ 0
#define __UFRACT_MIN__ 0.0UR
#define __UFRACT_MAX__ 0XFFFFP-16UR
#define __UFRACT_EPSILON__ 0x1P-16UR
#define __LFRACT_FBIT__ 31
#define __LFRACT_IBIT__ 0
#define __LFRACT_MIN__ (-0.5LR-0.5LR)
#define __LFRACT_MAX__ 0X7FFFFFFFP-31LR
#define __LFRACT_EPSILON__ 0x1P-31LR
#define __ULFRACT_FBIT__ 32
#define __ULFRACT_IBIT__ 0
#define __ULFRACT_MIN__ 0.0ULR
#define __ULFRACT_MAX__ 0XFFFFFFFFP-32ULR
#define __ULFRACT_EPSILON__ 0x1P-32ULR
#define __LLFRACT_FBIT__ 63
#define __LLFRACT_IBIT__ 0
#define __LLFRACT_MIN__ (-0.5LLR-0.5LLR)
#define __LLFRACT_MAX__ 0X7FFFFFFFFFFFFFFFP-63LLR
#define __LLFRACT_EPSILON__ 0x1P-63LLR
#define __ULLFRACT_FBIT__ 64
#define __ULLFRACT_IBIT__ 0
#define __ULLFRACT_MIN__ 0.0ULLR
#define __ULLFRACT_MAX__ 0XFFFFFFFFFFFFFFFFP-64ULLR
#define __ULLFRACT_EPSILON__ 0x1P-64ULLR
#define __SACCUM_FBIT__ 7
#define __SACCUM_IBIT__ 8
#define __SACCUM_MIN__ (-0X1P7HK-0X1P7HK)
#define __SACCUM_MAX__ 0X7FFFP-7HK
#define __SACCUM_EPSILON__ 0x1P-7HK
#define __USACCUM_FBIT__ 8
#define __USACCUM_IBIT__ 8
#define __USACCUM_MIN__ 0.0UHK
#define __USACCUM_MAX__ 0XFFFFP-8UHK
#define __USACCUM_EPSILON__ 0x1P-8UHK
#define __ACCUM_FBIT__ 15
#define __ACCUM_IBIT__ 16
#define __ACCUM_MIN__ (-0X1P15K-0X1P15K)
#define __ACCUM_MAX__ 0X7FFFFFFFP-15K
#define __ACCUM_EPSILON__ 0x1P-15K
#define __UACCUM_FBIT__ 16
#define __UACCUM_IBIT__ 16
#define __UACCUM_MIN__ 0.0UK
#define __UACCUM_MAX__ 0XFFFFFFFFP-16UK
#define __UACCUM_EPSILON__ 0x1P-16UK
#define __LACCUM_FBIT__ 31
#define __LACCUM_IBIT__ 32
#define __LACCUM_MIN__ (-0X1P31LK-0X1P31LK)
#define __LACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LK
#define __LACCUM_EPSILON__ 0x1P-31LK
#define __ULACCUM_FBIT__ 32
#define __ULACCUM_IBIT__ 32
#define __ULACCUM_MIN__ 0.0ULK
#define __ULACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULK
#define __ULACCUM_EPSILON__ 0x1P-32ULK
#define __LLACCUM_FBIT__ 31
#define __LLACCUM_IBIT__ 32
#define __LLACCUM_MIN__ (-0X1P31LLK-0X1P31LLK)
#define __LLACCUM_MAX__ 0X7FFFFFFFFFFFFFFFP-31LLK
#define __LLACCUM_EPSILON__ 0x1P-31LLK
#define __ULLACCUM_FBIT__ 32
#define __ULLACCUM_IBIT__ 32
#define __ULLACCUM_MIN__ 0.0ULLK
#define __ULLACCUM_MAX__ 0XFFFFFFFFFFFFFFFFP-32ULLK
#define __ULLACCUM_EPSILON__ 0x1P-32ULLK
#define __QQ_FBIT__ 7
#define __QQ_IBIT__ 0
#define __HQ_FBIT__ 15
#define __HQ_IBIT__ 0
#define __SQ_FBIT__ 31
#define __SQ_IBIT__ 0
#define __DQ_FBIT__ 63
#define __DQ_IBIT__ 0
#define __TQ_FBIT__ 127
#define __TQ_IBIT__ 0
#define __UQQ_FBIT__ 8
#define __UQQ_IBIT__ 0
#define __UHQ_FBIT__ 16
#define __UHQ_IBIT__ 0
#define __USQ_FBIT__ 32
#define __USQ_IBIT__ 0
#define __UDQ_FBIT__ 64
#define __UDQ_IBIT__ 0
#define __UTQ_FBIT__ 128
#define __UTQ_IBIT__ 0
#define __HA_FBIT__ 7
#define __HA_IBIT__ 8
#define __SA_FBIT__ 15
#define __SA_IBIT__ 16
#define __DA_FBIT__ 31
#define __DA_IBIT__ 32
#define __TA_FBIT__ 63
#define __TA_IBIT__ 64
#define __UHA_FBIT__ 8
#define __UHA_IBIT__ 8
#define __USA_FBIT__ 16
#define __USA_IBIT__ 16
#define __UDA_FBIT__ 32
#define __UDA_IBIT__ 32
#define __UTA_FBIT__ 64
#define __UTA_IBIT__ 64
#define __REGISTER_PREFIX__
#define __USER_LABEL_PREFIX__
#define __GNUC_STDC_INLINE__ 1
#define __STRICT_ANSI__ 1
#define __CHAR_UNSIGNED__ 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
#define __GCC_ATOMIC_BOOL_LOCK_FREE 2
#define __GCC_ATOMIC_CHAR_LOCK_FREE 2
#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2
#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2
#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
#define __GCC_ATOMIC_INT_LOCK_FREE 2
#define __GCC_ATOMIC_LONG_LOCK_FREE 2
#define __GCC_ATOMIC_LLONG_LOCK_FREE 1
#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
#define __GCC_ATOMIC_POINTER_LOCK_FREE 2
#define __HAVE_SPECULATION_SAFE_VALUE 1
#define __GCC_HAVE_DWARF2_CFI_ASM 1
#define __PRAGMA_REDEFINE_EXTNAME 1
#define __SIZEOF_WCHAR_T__ 4
#define __SIZEOF_WINT_T__ 4
#define __SIZEOF_PTRDIFF_T__ 4
#define __ARM_FEATURE_DSP 1
#define __ARM_FEATURE_QBIT 1
#define __ARM_FEATURE_SAT 1
#undef __ARM_FEATURE_CRYPTO
# 1 "<built-in>"
#define __ARM_FEATURE_UNALIGNED 1
#undef __ARM_FEATURE_QRDMX
# 1 "<built-in>"
#undef __ARM_FEATURE_CRC32
# 1 "<built-in>"
#undef __ARM_FEATURE_DOTPROD
# 1 "<built-in>"
#undef __ARM_FEATURE_COMPLEX
# 1 "<built-in>"
#define __ARM_32BIT_STATE 1
#undef __ARM_FEATURE_MVE
# 1 "<built-in>"
#undef __ARM_FEATURE_CMSE
# 1 "<built-in>"
#undef __ARM_FEATURE_LDREX
# 1 "<built-in>"
#define __ARM_FEATURE_LDREX 7
#define __ARM_FEATURE_CLZ 1
#undef __ARM_FEATURE_NUMERIC_MAXMIN
# 1 "<built-in>"
#define __ARM_FEATURE_SIMD32 1
#define __ARM_SIZEOF_MINIMAL_ENUM 1
#define __ARM_SIZEOF_WCHAR_T 4
#undef __ARM_ARCH_PROFILE
# 1 "<built-in>"
#define __ARM_ARCH_PROFILE 77
#define __arm__ 1
#undef __ARM_ARCH
# 1 "<built-in>"
#define __ARM_ARCH 7
#define __APCS_32__ 1
#define __GCC_ASM_FLAG_OUTPUTS__ 1
#define __thumb__ 1
#define __thumb2__ 1
#define __THUMBEL__ 1
#undef __ARM_ARCH_ISA_THUMB
# 1 "<built-in>"
#define __ARM_ARCH_ISA_THUMB 2
#define __ARMEL__ 1
#define __SOFTFP__ 1
#define __VFP_FP__ 1
#undef __ARM_FP
# 1 "<built-in>"
#undef __ARM_FP16_FORMAT_IEEE
# 1 "<built-in>"
#undef __ARM_FP16_FORMAT_ALTERNATIVE
# 1 "<built-in>"
#undef __ARM_FP16_ARGS
# 1 "<built-in>"
#undef __ARM_FEATURE_FP16_SCALAR_ARITHMETIC
# 1 "<built-in>"
#undef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
# 1 "<built-in>"
#undef __ARM_FEATURE_FP16_FML
# 1 "<built-in>"
#define __ARM_FEATURE_FMA 1
#undef __ARM_NEON__
# 1 "<built-in>"
#undef __ARM_NEON
# 1 "<built-in>"
#undef __ARM_NEON_FP
# 1 "<built-in>"
#define __THUMB_INTERWORK__ 1
#define __ARM_ARCH_7EM__ 1
#define __ARM_PCS 1
#define __ARM_EABI__ 1
#undef __FDPIC__
# 1 "<built-in>"
#define __ARM_ARCH_EXT_IDIV__ 1
#define __ARM_FEATURE_IDIV 1
#define __ARM_ASM_SYNTAX_UNIFIED__ 1
#undef __ARM_FEATURE_COPROC
# 1 "<built-in>"
#define __ARM_FEATURE_COPROC 15
#undef __ARM_FEATURE_CDE
# 1 "<built-in>"
#undef __ARM_FEATURE_CDE_COPROC
# 1 "<built-in>"
#undef __ARM_FEATURE_MATMUL_INT8
# 1 "<built-in>"
#undef __ARM_FEATURE_BF16_SCALAR_ARITHMETIC
# 1 "<built-in>"
#undef __ARM_FEATURE_BF16_VECTOR_ARITHMETIC
# 1 "<built-in>"
#undef __ARM_BF16_FORMAT_ALTERNATIVE
# 1 "<built-in>"
#define __GXX_TYPEINFO_EQUALITY_INLINE 0
#define __ELF__ 1
# 1 "<command-line>"
#define __USES_INITFINI__ 1
#define stm32wle5xx 1
#define SUPPORT_LORA 1
#define LORA_IO_SPI_PORT 2
#define SYS_RTC_COUNTER_PORT 2
#define ATCMD_CUST_TABLE_SIZE 64
#define WAN_TYPE 0
#define LORA_STACK_VER 0x040407
#define RAK3372 +RAK5005-O_V1.0 1
#define rak3172 1
#define CORE_CM4 1
#define USE_HAL_DRIVER 1
#define STM32WL55xx 1
#define REGION_AS923 1
#define REGION_AU915 1
#define REGION_CN470 1
#define REGION_CN779 1
#define REGION_EU433 1
#define REGION_EU868 1
#define REGION_KR920 1
#define REGION_IN865 1
#define REGION_US915 1
#define REGION_RU864 1
#define SOFT_SE 1
#define SECURE_ELEMENT_PRE_PROVISIONED 1
#define LORAMAC_CLASSB_ENABLED 1
#define WISBLOCK_BASE_5005_O 1
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
# 31 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 1
# 24 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
#define __RADIO_H__
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdint.h" 1 3 4
# 9 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdint.h" 3 4
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 1 3 4
# 10 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define _STDINT_H
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 1 3 4
#define _MACHINE__DEFAULT_TYPES_H
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 1 3 4
# 22 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 3 4
#define _SYS_FEATURES_H
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_newlib_version.h" 1 3 4
#define _NEWLIB_VERSION_H__ 1
#define _NEWLIB_VERSION "3.3.0"
#define __NEWLIB__ 3
#define __NEWLIB_MINOR__ 3
#define __NEWLIB_PATCHLEVEL__ 0
# 29 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 2 3 4
#define __GNUC_PREREQ(maj,min) ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
#define __GNUC_PREREQ__(ma,mi) __GNUC_PREREQ(ma, mi)
# 249 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 3 4
#define __ATFILE_VISIBLE 0
#define __BSD_VISIBLE 0
#define __GNU_VISIBLE 0
#define __ISO_C_VISIBLE 1999
#define __LARGEFILE_VISIBLE 0
#define __MISC_VISIBLE 0
# 299 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 3 4
#define __POSIX_VISIBLE 0
#define __SVID_VISIBLE 0
# 319 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 3 4
#define __XSI_VISIBLE 0
# 330 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/features.h" 3 4
#define __SSP_FORTIFY_LEVEL 0
# 9 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 2 3 4
#define __EXP(x) __ ##x ##__
# 26 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
#define __have_longlong64 1
#define __have_long32 1
# 41 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef signed char __int8_t;
typedef unsigned char __uint8_t;
#define ___int8_t_defined 1
typedef short int __int16_t;
typedef short unsigned int __uint16_t;
#define ___int16_t_defined 1
# 77 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long int __int32_t;
typedef long unsigned int __uint32_t;
#define ___int32_t_defined 1
# 103 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long long int __int64_t;
typedef long long unsigned int __uint64_t;
#define ___int64_t_defined 1
# 134 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef signed char __int_least8_t;
typedef unsigned char __uint_least8_t;
#define ___int_least8_t_defined 1
# 160 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef short int __int_least16_t;
typedef short unsigned int __uint_least16_t;
#define ___int_least16_t_defined 1
# 182 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long int __int_least32_t;
typedef long unsigned int __uint_least32_t;
#define ___int_least32_t_defined 1
# 200 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
typedef long long int __int_least64_t;
typedef long long unsigned int __uint_least64_t;
#define ___int_least64_t_defined 1
typedef long long int __intmax_t;
typedef long long unsigned int __uintmax_t;
typedef int __intptr_t;
typedef unsigned int __uintptr_t;
# 244 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_default_types.h" 3 4
#undef __EXP
# 13 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 2 3 4
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 1 3 4
# 10 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define _SYS__INTSUP_H
#define __STDINT_EXP(x) __ ##x ##__
# 35 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#undef signed
#undef unsigned
#undef char
#undef short
#undef int
#undef __int20
#undef __int20__
#undef long
#define signed +0
#define unsigned +0
#define char +0
#define short +1
#define __int20 +2
#define __int20__ +2
#define int +2
#define long +4
# 67 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define _INTPTR_EQ_INT
#define _INT32_EQ_LONG
#define __INT8 "hh"
# 93 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __INT16 "h"
# 104 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __INT32 "l"
# 113 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __INT64 "ll"
#define __FAST8
# 129 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __FAST16
#define __FAST32
# 147 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __FAST64 "ll"
#define __LEAST8 "hh"
# 162 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __LEAST16 "h"
# 173 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __LEAST32 "l"
# 182 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#define __LEAST64 "ll"
#undef signed
#undef unsigned
#undef char
#undef short
#undef int
#undef long
# 194 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#undef __int20
# 195 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_intsup.h" 3 4
#undef __int20__
# 14 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 2 3 4
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_stdint.h" 1 3 4
# 10 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_stdint.h" 3 4
#define _SYS__STDINT_H
# 20 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_stdint.h" 3 4
typedef __int8_t int8_t ;
#define _INT8_T_DECLARED
typedef __uint8_t uint8_t ;
#define _UINT8_T_DECLARED
#define __int8_t_defined 1
typedef __int16_t int16_t ;
#define _INT16_T_DECLARED
typedef __uint16_t uint16_t ;
#define _UINT16_T_DECLARED
#define __int16_t_defined 1
typedef __int32_t int32_t ;
#define _INT32_T_DECLARED
typedef __uint32_t uint32_t ;
#define _UINT32_T_DECLARED
#define __int32_t_defined 1
typedef __int64_t int64_t ;
#define _INT64_T_DECLARED
typedef __uint64_t uint64_t ;
#define _UINT64_T_DECLARED
#define __int64_t_defined 1
typedef __intmax_t intmax_t;
#define _INTMAX_T_DECLARED
typedef __uintmax_t uintmax_t;
#define _UINTMAX_T_DECLARED
typedef __intptr_t intptr_t;
#define _INTPTR_T_DECLARED
typedef __uintptr_t uintptr_t;
#define _UINTPTR_T_DECLARED
# 15 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 2 3 4
typedef __int_least8_t int_least8_t;
typedef __uint_least8_t uint_least8_t;
#define __int_least8_t_defined 1
typedef __int_least16_t int_least16_t;
typedef __uint_least16_t uint_least16_t;
#define __int_least16_t_defined 1
typedef __int_least32_t int_least32_t;
typedef __uint_least32_t uint_least32_t;
#define __int_least32_t_defined 1
typedef __int_least64_t int_least64_t;
typedef __uint_least64_t uint_least64_t;
#define __int_least64_t_defined 1
# 51 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
typedef int int_fast8_t;
typedef unsigned int uint_fast8_t;
#define __int_fast8_t_defined 1
typedef int int_fast16_t;
typedef unsigned int uint_fast16_t;
#define __int_fast16_t_defined 1
typedef int int_fast32_t;
typedef unsigned int uint_fast32_t;
#define __int_fast32_t_defined 1
typedef long long int int_fast64_t;
typedef long long unsigned int uint_fast64_t;
#define __int_fast64_t_defined 1
# 128 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INTPTR_MIN (-__INTPTR_MAX__ - 1)
#define INTPTR_MAX (__INTPTR_MAX__)
#define UINTPTR_MAX (__UINTPTR_MAX__)
# 152 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT8_MIN (-__INT8_MAX__ - 1)
#define INT8_MAX (__INT8_MAX__)
#define UINT8_MAX (__UINT8_MAX__)
#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)
#define INT_LEAST8_MAX (__INT_LEAST8_MAX__)
#define UINT_LEAST8_MAX (__UINT_LEAST8_MAX__)
# 174 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT16_MIN (-__INT16_MAX__ - 1)
#define INT16_MAX (__INT16_MAX__)
#define UINT16_MAX (__UINT16_MAX__)
#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1)
#define INT_LEAST16_MAX (__INT_LEAST16_MAX__)
#define UINT_LEAST16_MAX (__UINT_LEAST16_MAX__)
# 196 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT32_MIN (-__INT32_MAX__ - 1)
#define INT32_MAX (__INT32_MAX__)
#define UINT32_MAX (__UINT32_MAX__)
# 212 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1)
#define INT_LEAST32_MAX (__INT_LEAST32_MAX__)
#define UINT_LEAST32_MAX (__UINT_LEAST32_MAX__)
# 230 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT64_MIN (-__INT64_MAX__ - 1)
#define INT64_MAX (__INT64_MAX__)
#define UINT64_MAX (__UINT64_MAX__)
# 246 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1)
#define INT_LEAST64_MAX (__INT_LEAST64_MAX__)
#define UINT_LEAST64_MAX (__UINT_LEAST64_MAX__)
# 262 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1)
#define INT_FAST8_MAX (__INT_FAST8_MAX__)
#define UINT_FAST8_MAX (__UINT_FAST8_MAX__)
# 278 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1)
#define INT_FAST16_MAX (__INT_FAST16_MAX__)
#define UINT_FAST16_MAX (__UINT_FAST16_MAX__)
# 294 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1)
#define INT_FAST32_MAX (__INT_FAST32_MAX__)
#define UINT_FAST32_MAX (__UINT_FAST32_MAX__)
# 310 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1)
#define INT_FAST64_MAX (__INT_FAST64_MAX__)
#define UINT_FAST64_MAX (__UINT_FAST64_MAX__)
# 326 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INTMAX_MAX (__INTMAX_MAX__)
#define INTMAX_MIN (-INTMAX_MAX - 1)
#define UINTMAX_MAX (__UINTMAX_MAX__)
#define SIZE_MAX (__SIZE_MAX__)
#define SIG_ATOMIC_MIN (-__STDINT_EXP(INT_MAX) - 1)
#define SIG_ATOMIC_MAX (__STDINT_EXP(INT_MAX))
#define PTRDIFF_MAX (__PTRDIFF_MAX__)
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
#define WCHAR_MIN (__WCHAR_MIN__)
# 374 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define WCHAR_MAX (__WCHAR_MAX__)
# 384 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define WINT_MAX (__WINT_MAX__)
#define WINT_MIN (__WINT_MIN__)
#define INT8_C(x) __INT8_C(x)
#define UINT8_C(x) __UINT8_C(x)
# 408 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT16_C(x) __INT16_C(x)
#define UINT16_C(x) __UINT16_C(x)
# 420 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT32_C(x) __INT32_C(x)
#define UINT32_C(x) __UINT32_C(x)
# 433 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INT64_C(x) __INT64_C(x)
#define UINT64_C(x) __UINT64_C(x)
# 449 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/stdint.h" 3 4
#define INTMAX_C(x) __INTMAX_C(x)
#define UINTMAX_C(x) __UINTMAX_C(x)
# 10 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdint.h" 2 3 4
#define _GCC_WRAP_STDINT_H
# 32 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 2
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdbool.h" 1 3 4
# 29 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdbool.h" 3 4
#define _STDBOOL_H
#define bool _Bool
#define true 1
#define false 0
# 52 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdbool.h" 3 4
#define __bool_true_false_are_defined 1
# 33 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 2
# 37 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
typedef enum
{
MODEM_FSK = 0,
MODEM_LORA,
}RadioModems_t;
typedef enum
{
RF_IDLE = 0,
RF_RX_RUNNING,
RF_TX_RUNNING,
RF_CAD,
}RadioState_t;
typedef struct
{
void ( *TxDone )( void );
void ( *TxTimeout )( void );
# 77 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
void ( *RxDone )( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );
void ( *RxTimeout )( void );
void ( *RxError )( void );
void ( *FhssChangeChannel )( uint8_t currentChannel );
void ( *CadDone ) (
# 98 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 98 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
channelActivityDetected );
void ( *GnssDone )( void );
void ( *WifiDone )( void );
}RadioEvents_t;
struct Radio_s
{
void ( *Init )( RadioEvents_t *events );
RadioState_t ( *GetStatus )( void );
void ( *SetModem )( RadioModems_t modem );
void ( *SetChannel )( uint32_t freq );
# 152 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
# 152 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 152 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
( *IsChannelFree )( uint32_t freq, uint32_t rxBandwidth, int16_t rssiThresh, uint32_t maxCarrierSenseTime );
# 163 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
uint32_t ( *Random )( void );
# 203 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
void ( *SetRxConfig )( RadioModems_t modem, uint32_t bandwidth,
uint32_t datarate, uint8_t coderate,
uint32_t bandwidthAfc, uint16_t preambleLen,
uint16_t symbTimeout,
# 206 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 206 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
fixLen,
uint8_t payloadLen,
# 208 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 208 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
crcOn,
# 208 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 208 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
freqHopOn, uint8_t hopPeriod,
# 209 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 209 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
iqInverted,
# 209 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 209 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
rxContinuous );
# 245 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
void ( *SetTxConfig )( RadioModems_t modem, int8_t power, uint32_t fdev,
uint32_t bandwidth, uint32_t datarate,
uint8_t coderate, uint16_t preambleLen,
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
fixLen,
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
crcOn,
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
freqHopOn,
uint8_t hopPeriod,
# 249 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 249 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
iqInverted, uint32_t timeout );
# 256 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 256 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
( *CheckRfFrequency )( uint32_t frequency );
# 283 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
uint32_t ( *TimeOnAir )( RadioModems_t modem, uint32_t bandwidth,
uint32_t datarate, uint8_t coderate,
uint16_t preambleLen,
# 285 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 285 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
fixLen, uint8_t payloadLen,
# 286 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 286 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
crcOn );
void ( *Send )( uint8_t *buffer, uint8_t size );
void ( *Sleep )( void );
void ( *Standby )( void );
void ( *Rx )( uint32_t timeout );
void ( *StartCad )( void );
void ( *SetTxContinuousWave )( uint32_t freq, int8_t power, uint16_t time );
int16_t ( *Rssi )( RadioModems_t modem );
void ( *Write )( uint32_t addr, uint8_t data );
uint8_t ( *Read )( uint32_t addr );
void ( *WriteBuffer )( uint32_t addr, uint8_t *buffer, uint8_t size );
void ( *ReadBuffer )( uint32_t addr, uint8_t *buffer, uint8_t size );
void ( *SetMaxPayloadLength )( RadioModems_t modem, uint8_t max );
void ( *SetPublicNetwork )(
# 371 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h" 3 4
_Bool
# 371 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
enable );
uint32_t ( *GetWakeupTime )( void );
void ( *IrqProcess )( void );
# 393 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
void ( *RxBoosted )( uint32_t timeout );
# 402 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/radio/radio.h"
void ( *SetRxDutyCycle ) ( uint32_t rxTime, uint32_t sleepTime );
};
extern const struct Radio_s Radio;
# 32 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 1
# 38 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
#define __REGIONCOMMON_H__
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 1
# 36 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define __LORAMAC_TYPES_H__
# 45 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/timer.h" 1
# 24 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/timer.h"
#define __TIMER_H__
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h" 1
# 44 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
#define UTIL_TIME_SERVER_H__
# 58 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 1 3 4
# 39 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#define _STDDEF_H
#define _STDDEF_H_
#define _ANSI_STDDEF_H
# 131 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#define _PTRDIFF_T
#define _T_PTRDIFF_
#define _T_PTRDIFF
#define __PTRDIFF_T
#define _PTRDIFF_T_
#define _BSD_PTRDIFF_T_
#define ___int_ptrdiff_t_h
#define _GCC_PTRDIFF_T
#define _PTRDIFF_T_DECLARED
# 143 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
typedef int ptrdiff_t;
# 155 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_ptrdiff_t
# 181 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#define __size_t__
#define __SIZE_T__
#define _SIZE_T
#define _SYS_SIZE_T_H
#define _T_SIZE_
#define _T_SIZE
#define __SIZE_T
#define _SIZE_T_
#define _BSD_SIZE_T_
#define _SIZE_T_DEFINED_
#define _SIZE_T_DEFINED
#define _BSD_SIZE_T_DEFINED_
#define _SIZE_T_DECLARED
#define ___int_size_t_h
#define _GCC_SIZE_T
#define _SIZET_
#define __size_t
typedef unsigned int size_t;
# 231 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_size_t
# 260 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#define __wchar_t__
#define __WCHAR_T__
#define _WCHAR_T
#define _T_WCHAR_
#define _T_WCHAR
#define __WCHAR_T
#define _WCHAR_T_
#define _BSD_WCHAR_T_
#define _WCHAR_T_DEFINED_
#define _WCHAR_T_DEFINED
#define _WCHAR_T_H
#define ___int_wchar_t_h
#define __INT_WCHAR_T_H
#define _GCC_WCHAR_T
#define _WCHAR_T_DECLARED
# 287 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef _BSD_WCHAR_T_
# 321 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
typedef unsigned int wchar_t;
# 340 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_wchar_t
# 390 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef NULL
#define NULL ((void *)0)
#undef __need_NULL
#define offsetof(TYPE,MEMBER) __builtin_offsetof (TYPE, MEMBER)
# 59 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_compiler.h" 1
# 26 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_compiler.h"
#define __CMSIS_COMPILER_H
# 54 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_compiler.h"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h" 1
# 26 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __CMSIS_GCC_H
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wconversion"
#pragma GCC diagnostic ignored "-Wunused-parameter"
# 41 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __ASM __asm
#define __INLINE inline
#define __STATIC_INLINE static inline
#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
#define __NO_RETURN __attribute__((__noreturn__))
#define __USED __attribute__((used))
#define __WEAK __attribute__((weak))
#define __PACKED __attribute__((packed, aligned(1)))
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
# 74 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
#pragma GCC diagnostic pop
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
struct __attribute__((packed, aligned(1))) T_UINT16_WRITE { uint16_t v; };
#pragma GCC diagnostic pop
#define __UNALIGNED_UINT16_WRITE(addr,val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
struct __attribute__((packed, aligned(1))) T_UINT16_READ { uint16_t v; };
#pragma GCC diagnostic pop
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
struct __attribute__((packed, aligned(1))) T_UINT32_WRITE { uint32_t v; };
#pragma GCC diagnostic pop
#define __UNALIGNED_UINT32_WRITE(addr,val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpacked"
#pragma GCC diagnostic ignored "-Wattributes"
struct __attribute__((packed, aligned(1))) T_UINT32_READ { uint32_t v; };
#pragma GCC diagnostic pop
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
#define __ALIGNED(x) __attribute__((aligned(x)))
#define __RESTRICT __restrict
#define __COMPILER_BARRIER() __ASM volatile("":::"memory")
# 131 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline __attribute__((__noreturn__)) void __cmsis_start(void)
{
extern void _start(void) __attribute__((__noreturn__));
typedef struct {
uint32_t const* src;
uint32_t* dest;
uint32_t wlen;
} __copy_table_t;
typedef struct {
uint32_t* dest;
uint32_t wlen;
} __zero_table_t;
extern const __copy_table_t __copy_table_start__;
extern const __copy_table_t __copy_table_end__;
extern const __zero_table_t __zero_table_start__;
extern const __zero_table_t __zero_table_end__;
for (__copy_table_t const* pTable = &__copy_table_start__; pTable < &__copy_table_end__; ++pTable) {
for(uint32_t i=0u; i<pTable->wlen; ++i) {
pTable->dest[i] = pTable->src[i];
}
}
for (__zero_table_t const* pTable = &__zero_table_start__; pTable < &__zero_table_end__; ++pTable) {
for(uint32_t i=0u; i<pTable->wlen; ++i) {
pTable->dest[i] = 0u;
}
}
_start();
}
#define __PROGRAM_START __cmsis_start
#define __INITIAL_SP __StackTop
#define __STACK_LIMIT __StackLimit
#define __VECTOR_TABLE __Vectors
#define __VECTOR_TABLE_ATTRIBUTE __attribute((used, section(".vectors")))
# 196 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __enable_irq(void)
{
__asm volatile ("cpsie i" : : : "memory");
}
__attribute__((always_inline)) static inline void __disable_irq(void)
{
__asm volatile ("cpsid i" : : : "memory");
}
__attribute__((always_inline)) static inline uint32_t __get_CONTROL(void)
{
uint32_t result;
__asm volatile ("MRS %0, control" : "=r" (result) );
return(result);
}
# 248 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_CONTROL(uint32_t control)
{
__asm volatile ("MSR control, %0" : : "r" (control) : "memory");
}
# 272 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __get_IPSR(void)
{
uint32_t result;
__asm volatile ("MRS %0, ipsr" : "=r" (result) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __get_APSR(void)
{
uint32_t result;
__asm volatile ("MRS %0, apsr" : "=r" (result) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __get_xPSR(void)
{
uint32_t result;
__asm volatile ("MRS %0, xpsr" : "=r" (result) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __get_PSP(void)
{
uint32_t result;
__asm volatile ("MRS %0, psp" : "=r" (result) );
return(result);
}
# 344 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_PSP(uint32_t topOfProcStack)
{
__asm volatile ("MSR psp, %0" : : "r" (topOfProcStack) : );
}
# 368 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __get_MSP(void)
{
uint32_t result;
__asm volatile ("MRS %0, msp" : "=r" (result) );
return(result);
}
# 398 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_MSP(uint32_t topOfMainStack)
{
__asm volatile ("MSR msp, %0" : : "r" (topOfMainStack) : );
}
# 449 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __get_PRIMASK(void)
{
uint32_t result;
__asm volatile ("MRS %0, primask" : "=r" (result) :: "memory");
return(result);
}
# 479 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_PRIMASK(uint32_t priMask)
{
__asm volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
}
# 506 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __enable_fault_irq(void)
{
__asm volatile ("cpsie f" : : : "memory");
}
__attribute__((always_inline)) static inline void __disable_fault_irq(void)
{
__asm volatile ("cpsid f" : : : "memory");
}
__attribute__((always_inline)) static inline uint32_t __get_BASEPRI(void)
{
uint32_t result;
__asm volatile ("MRS %0, basepri" : "=r" (result) );
return(result);
}
# 558 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_BASEPRI(uint32_t basePri)
{
__asm volatile ("MSR basepri, %0" : : "r" (basePri) : "memory");
}
# 583 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_BASEPRI_MAX(uint32_t basePri)
{
__asm volatile ("MSR basepri_max, %0" : : "r" (basePri) : "memory");
}
__attribute__((always_inline)) static inline uint32_t __get_FAULTMASK(void)
{
uint32_t result;
__asm volatile ("MRS %0, faultmask" : "=r" (result) );
return(result);
}
# 624 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __set_FAULTMASK(uint32_t faultMask)
{
__asm volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
}
# 833 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __get_FPSCR(void)
{
# 849 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
return(0U);
}
__attribute__((always_inline)) static inline void __set_FPSCR(uint32_t fpscr)
{
# 872 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
(void)fpscr;
}
# 894 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __CMSIS_GCC_OUT_REG(r) "=r" (r)
#define __CMSIS_GCC_RW_REG(r) "+r" (r)
#define __CMSIS_GCC_USE_REG(r) "r" (r)
#define __NOP() __ASM volatile ("nop")
#define __WFI() __ASM volatile ("wfi")
#define __WFE() __ASM volatile ("wfe")
#define __SEV() __ASM volatile ("sev")
# 933 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __ISB(void)
{
__asm volatile ("isb 0xF":::"memory");
}
__attribute__((always_inline)) static inline void __DSB(void)
{
__asm volatile ("dsb 0xF":::"memory");
}
__attribute__((always_inline)) static inline void __DMB(void)
{
__asm volatile ("dmb 0xF":::"memory");
}
# 967 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __REV(uint32_t value)
{
return __builtin_bswap32(value);
}
# 986 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __REV16(uint32_t value)
{
uint32_t result;
__asm volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
return result;
}
# 1001 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline int16_t __REVSH(int16_t value)
{
return (int16_t)__builtin_bswap16(value);
}
# 1021 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __ROR(uint32_t op1, uint32_t op2)
{
op2 %= 32U;
if (op2 == 0U)
{
return op1;
}
return (op1 >> op2) | (op1 << (32U - op2));
}
# 1039 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __BKPT(value) __ASM volatile ("bkpt "#value)
# 1048 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __RBIT(uint32_t value)
{
uint32_t result;
__asm volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
# 1068 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
return result;
}
# 1078 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint8_t __CLZ(uint32_t value)
{
# 1089 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
if (value == 0U)
{
return 32U;
}
return __builtin_clz(value);
}
# 1107 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint8_t __LDREXB(volatile uint8_t *addr)
{
uint32_t result;
__asm volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
return ((uint8_t) result);
}
# 1129 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint16_t __LDREXH(volatile uint16_t *addr)
{
uint32_t result;
__asm volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
return ((uint16_t) result);
}
# 1151 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __LDREXW(volatile uint32_t *addr)
{
uint32_t result;
__asm volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
return(result);
}
# 1168 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
{
uint32_t result;
__asm volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
return(result);
}
# 1185 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
{
uint32_t result;
__asm volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" ((uint32_t)value) );
return(result);
}
# 1202 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
{
uint32_t result;
__asm volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
return(result);
}
__attribute__((always_inline)) static inline void __CLREX(void)
{
__asm volatile ("clrex" ::: "memory");
}
# 1236 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __SSAT(ARG1,ARG2) __extension__ ({ int32_t __RES, __ARG1 = (ARG1); __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); __RES; })
# 1252 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __USAT(ARG1,ARG2) __extension__ ({ uint32_t __RES, __ARG1 = (ARG1); __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); __RES; })
# 1268 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __RRX(uint32_t value)
{
uint32_t result;
__asm volatile ("rrx %0, %1" : "=r" (result) : "r" (value) );
return(result);
}
# 1283 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint8_t __LDRBT(volatile uint8_t *ptr)
{
uint32_t result;
__asm volatile ("ldrbt %0, %1" : "=r" (result) : "Q" (*ptr) );
return ((uint8_t) result);
}
# 1305 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint16_t __LDRHT(volatile uint16_t *ptr)
{
uint32_t result;
__asm volatile ("ldrht %0, %1" : "=r" (result) : "Q" (*ptr) );
return ((uint16_t) result);
}
# 1327 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __LDRT(volatile uint32_t *ptr)
{
uint32_t result;
__asm volatile ("ldrt %0, %1" : "=r" (result) : "Q" (*ptr) );
return(result);
}
# 1342 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __STRBT(uint8_t value, volatile uint8_t *ptr)
{
__asm volatile ("strbt %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
}
# 1354 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __STRHT(uint16_t value, volatile uint16_t *ptr)
{
__asm volatile ("strht %1, %0" : "=Q" (*ptr) : "r" ((uint32_t)value) );
}
# 1366 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline void __STRT(uint32_t value, volatile uint32_t *ptr)
{
__asm volatile ("strt %1, %0" : "=Q" (*ptr) : "r" (value) );
}
# 1621 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
__attribute__((always_inline)) static inline uint32_t __SADD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("sadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __QADD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("qadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SHADD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("shadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UADD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UQADD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uqadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UHADD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uhadd8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SSUB8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("ssub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __QSUB8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("qsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SHSUB8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("shsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __USUB8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("usub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UQSUB8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uqsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UHSUB8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uhsub8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SADD16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("sadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __QADD16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("qadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SHADD16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("shadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UADD16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UQADD16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uqadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UHADD16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uhadd16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SSUB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("ssub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __QSUB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("qsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SHSUB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("shsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __USUB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("usub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UQSUB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uqsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UHSUB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uhsub16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SASX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("sasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __QASX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("qasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SHASX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("shasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UASX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UQASX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uqasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UHASX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uhasx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SSAX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("ssax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __QSAX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("qsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SHSAX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("shsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __USAX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("usax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UQSAX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uqsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UHSAX(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uhsax %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __USAD8(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("usad8 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __USADA8(uint32_t op1, uint32_t op2, uint32_t op3)
{
uint32_t result;
__asm volatile ("usada8 %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
return(result);
}
#define __SSAT16(ARG1,ARG2) ({ int32_t __RES, __ARG1 = (ARG1); __ASM ("ssat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); __RES; })
#define __USAT16(ARG1,ARG2) ({ uint32_t __RES, __ARG1 = (ARG1); __ASM ("usat16 %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); __RES; })
__attribute__((always_inline)) static inline uint32_t __UXTB16(uint32_t op1)
{
uint32_t result;
__asm volatile ("uxtb16 %0, %1" : "=r" (result) : "r" (op1));
return(result);
}
__attribute__((always_inline)) static inline uint32_t __UXTAB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("uxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SXTB16(uint32_t op1)
{
uint32_t result;
__asm volatile ("sxtb16 %0, %1" : "=r" (result) : "r" (op1));
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SXTAB16(uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("sxtab16 %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMUAD (uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("smuad %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMUADX (uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("smuadx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMLAD (uint32_t op1, uint32_t op2, uint32_t op3)
{
uint32_t result;
__asm volatile ("smlad %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMLADX (uint32_t op1, uint32_t op2, uint32_t op3)
{
uint32_t result;
__asm volatile ("smladx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
return(result);
}
__attribute__((always_inline)) static inline uint64_t __SMLALD (uint32_t op1, uint32_t op2, uint64_t acc)
{
union llreg_u{
uint32_t w32[2];
uint64_t w64;
} llr;
llr.w64 = acc;
__asm volatile ("smlald %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
return(llr.w64);
}
__attribute__((always_inline)) static inline uint64_t __SMLALDX (uint32_t op1, uint32_t op2, uint64_t acc)
{
union llreg_u{
uint32_t w32[2];
uint64_t w64;
} llr;
llr.w64 = acc;
__asm volatile ("smlaldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
return(llr.w64);
}
__attribute__((always_inline)) static inline uint32_t __SMUSD (uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("smusd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMUSDX (uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("smusdx %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMLSD (uint32_t op1, uint32_t op2, uint32_t op3)
{
uint32_t result;
__asm volatile ("smlsd %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
return(result);
}
__attribute__((always_inline)) static inline uint32_t __SMLSDX (uint32_t op1, uint32_t op2, uint32_t op3)
{
uint32_t result;
__asm volatile ("smlsdx %0, %1, %2, %3" : "=r" (result) : "r" (op1), "r" (op2), "r" (op3) );
return(result);
}
__attribute__((always_inline)) static inline uint64_t __SMLSLD (uint32_t op1, uint32_t op2, uint64_t acc)
{
union llreg_u{
uint32_t w32[2];
uint64_t w64;
} llr;
llr.w64 = acc;
__asm volatile ("smlsld %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
return(llr.w64);
}
__attribute__((always_inline)) static inline uint64_t __SMLSLDX (uint32_t op1, uint32_t op2, uint64_t acc)
{
union llreg_u{
uint32_t w32[2];
uint64_t w64;
} llr;
llr.w64 = acc;
__asm volatile ("smlsldx %0, %1, %2, %3" : "=r" (llr.w32[0]), "=r" (llr.w32[1]): "r" (op1), "r" (op2) , "0" (llr.w32[0]), "1" (llr.w32[1]) );
return(llr.w64);
}
__attribute__((always_inline)) static inline uint32_t __SEL (uint32_t op1, uint32_t op2)
{
uint32_t result;
__asm volatile ("sel %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline int32_t __QADD( int32_t op1, int32_t op2)
{
int32_t result;
__asm volatile ("qadd %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
__attribute__((always_inline)) static inline int32_t __QSUB( int32_t op1, int32_t op2)
{
int32_t result;
__asm volatile ("qsub %0, %1, %2" : "=r" (result) : "r" (op1), "r" (op2) );
return(result);
}
# 2148 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_gcc.h"
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | ((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | ((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
__attribute__((always_inline)) static inline int32_t __SMMLA (int32_t op1, int32_t op2, int32_t op3)
{
int32_t result;
__asm volatile ("smmla %0, %1, %2, %3" : "=r" (result): "r" (op1), "r" (op2), "r" (op3) );
return(result);
}
#pragma GCC diagnostic pop
# 55 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Drivers/CMSIS/Include/cmsis_compiler.h" 2
# 60 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h" 1
# 24 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h"
#define __UTILITIES_CONF_H__
# 34 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_mem.h" 1
# 22 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_mem.h"
#define __STM32_MEM_H__
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h" 1
# 31 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_mem.h" 2
#define UTIL_MEM_PLACE_IN_SECTION(__x__) UTIL_PLACE_IN_SECTION( __x__ )
#define UTIL_MEM_ALIGN ALIGN
# 47 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_mem.h"
void UTIL_MEM_cpy_8( void *dst, const void *src, uint16_t size );
# 56 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_mem.h"
void UTIL_MEM_cpyr_8( void *dst, const void *src, uint16_t size );
# 65 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_mem.h"
void UTIL_MEM_set_8( void *dst, uint8_t value, uint16_t size );
# 35 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_tiny_vsnprintf.h" 1
# 21 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_tiny_vsnprintf.h"
#define __STM32_TINY_VSNPRINTF_H__
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdarg.h" 1 3 4
# 31 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdarg.h" 3 4
#define _STDARG_H
#define _ANSI_STDARG_H_
#undef __need___va_list
#define __GNUC_VA_LIST
# 40 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdarg.h" 3 4
typedef __builtin_va_list __gnuc_va_list;
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#define va_copy(d,s) __builtin_va_copy(d,s)
#define __va_copy(d,s) __builtin_va_copy(d,s)
# 99 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stdarg.h" 3 4
typedef __gnuc_va_list va_list;
#define _VA_LIST_
#define _VA_LIST
#define _VA_LIST_DEFINED
#define _VA_LIST_T_H
#define __va_list__
# 29 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_tiny_vsnprintf.h" 2
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 1 3
#define _STRING_H_
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_ansi.h" 1 3
#define _ANSIDECL_H_
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/newlib.h" 1 3
#define __NEWLIB_H__ 1
# 18 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/newlib.h" 3
#define _WANT_IO_C99_FORMATS 1
#define _WANT_IO_LONG_LONG 1
#define _WANT_REGISTER_FINI 1
# 37 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/newlib.h" 3
#define _REENT_CHECK_VERIFY 1
#define _MB_LEN_MAX 1
# 53 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/newlib.h" 3
#define HAVE_INITFINI_ARRAY 1
#define _ATEXIT_DYNAMIC_ALLOC 1
#define _HAVE_LONG_DOUBLE 1
#define _HAVE_CC_INHIBIT_LOOP_TO_LIBCALL 1
#define _LDBL_EQ_DBL 1
#define _FVWRITE_IN_STREAMIO 1
#define _FSEEK_OPTIMIZATION 1
#define _WIDE_ORIENT 1
#define _UNBUF_STREAM_OPT 1
# 95 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/newlib.h" 3
#define _RETARGETABLE_LOCKING 1
# 11 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_ansi.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/config.h" 1 3
#define __SYS_CONFIG_H__
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/ieeefp.h" 1 3
# 77 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/ieeefp.h" 3
#define __IEEE_LITTLE_ENDIAN
# 473 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/ieeefp.h" 3
#define __OBSOLETE_MATH_DEFAULT 1
#define __OBSOLETE_MATH __OBSOLETE_MATH_DEFAULT
# 5 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/config.h" 2 3
# 224 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/config.h" 3
#define _POINTER_INT long
#undef __RAND_MAX
#define __RAND_MAX 0x7fffffff
# 250 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/config.h" 3
#define __EXPORT
#define __IMPORT
#define _READ_WRITE_RETURN_TYPE int
#define _READ_WRITE_BUFSIZE_TYPE int
# 12 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_ansi.h" 2 3
# 31 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_ansi.h" 3
#define _BEGIN_STD_C
#define _END_STD_C
#define _NOTHROW
#define _LONG_DOUBLE long double
#define _ATTRIBUTE(attrs) __attribute__ (attrs)
# 69 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_ansi.h" 3
#define _ELIDABLE_INLINE static __inline__
#define _NOINLINE __attribute__ ((__noinline__))
#define _NOINLINE_STATIC _NOINLINE static
# 11 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 1 3
# 11 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
#define _SYS_REENT_H_
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/_ansi.h" 1 3
# 14 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 1 3 4
# 15 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 1 3
# 20 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 3
#define _SYS__TYPES_H
#define __need_size_t
#define __need_wint_t
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 1 3 4
# 155 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_ptrdiff_t
# 231 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_size_t
# 340 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_wchar_t
#define _WINT_T
typedef unsigned int wint_t;
#undef __need_wint_t
# 390 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef NULL
#define NULL ((void *)0)
#undef __need_NULL
#define offsetof(TYPE,MEMBER) __builtin_offsetof (TYPE, MEMBER)
# 25 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/_types.h" 1 3
#define _MACHINE__TYPES_H
# 28 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 2 3
typedef long __blkcnt_t;
typedef long __blksize_t;
typedef __uint64_t __fsblkcnt_t;
typedef __uint32_t __fsfilcnt_t;
typedef long _off_t;
typedef int __pid_t;
typedef short __dev_t;
typedef unsigned short __uid_t;
typedef unsigned short __gid_t;
typedef __uint32_t __id_t;
typedef unsigned short __ino_t;
# 90 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 3
typedef __uint32_t __mode_t;
__extension__ typedef long long _off64_t;
typedef _off_t __off_t;
typedef _off64_t __loff_t;
typedef long __key_t;
typedef long _fpos_t;
# 127 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 3
#undef __size_t
typedef unsigned int __size_t;
# 146 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 3
#define unsigned signed
typedef signed int _ssize_t;
#undef unsigned
# 158 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_types.h" 3
typedef _ssize_t __ssize_t;
typedef struct
{
int __count;
union
{
wint_t __wch;
unsigned char __wchb[4];
} __value;
} _mbstate_t;
typedef void *_iconv_t;
#define _CLOCK_T_ unsigned long
typedef unsigned long __clock_t;
#define _TIME_T_ __int_least64_t
typedef __int_least64_t __time_t;
#define _CLOCKID_T_ unsigned long
typedef unsigned long __clockid_t;
#define _TIMER_T_ unsigned long
typedef unsigned long __timer_t;
typedef __uint8_t __sa_family_t;
typedef __uint32_t __socklen_t;
typedef int __nl_item;
typedef unsigned short __nlink_t;
typedef long __suseconds_t;
typedef unsigned long __useconds_t;
typedef __builtin_va_list __va_list;
# 16 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 2 3
#define _NULL 0
#define __Long long
typedef unsigned long __ULong;
# 34 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/lock.h" 1 3
#define __SYS_LOCK_H__
# 33 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/lock.h" 3
struct __lock;
typedef struct __lock * _LOCK_T;
#define _LOCK_RECURSIVE_T _LOCK_T
#define __LOCK_INIT(class,lock) extern struct __lock __lock_ ## lock; class _LOCK_T lock = &__lock_ ## lock
#define __LOCK_INIT_RECURSIVE(class,lock) __LOCK_INIT(class,lock)
extern void __retarget_lock_init(_LOCK_T *lock);
#define __lock_init(lock) __retarget_lock_init(&lock)
extern void __retarget_lock_init_recursive(_LOCK_T *lock);
#define __lock_init_recursive(lock) __retarget_lock_init_recursive(&lock)
extern void __retarget_lock_close(_LOCK_T lock);
#define __lock_close(lock) __retarget_lock_close(lock)
extern void __retarget_lock_close_recursive(_LOCK_T lock);
#define __lock_close_recursive(lock) __retarget_lock_close_recursive(lock)
extern void __retarget_lock_acquire(_LOCK_T lock);
#define __lock_acquire(lock) __retarget_lock_acquire(lock)
extern void __retarget_lock_acquire_recursive(_LOCK_T lock);
#define __lock_acquire_recursive(lock) __retarget_lock_acquire_recursive(lock)
extern int __retarget_lock_try_acquire(_LOCK_T lock);
#define __lock_try_acquire(lock) __retarget_lock_try_acquire(lock)
extern int __retarget_lock_try_acquire_recursive(_LOCK_T lock);
#define __lock_try_acquire_recursive(lock) __retarget_lock_try_acquire_recursive(lock)
extern void __retarget_lock_release(_LOCK_T lock);
#define __lock_release(lock) __retarget_lock_release(lock)
extern void __retarget_lock_release_recursive(_LOCK_T lock);
#define __lock_release_recursive(lock) __retarget_lock_release_recursive(lock)
# 35 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 2 3
typedef _LOCK_T _flock_t;
struct _reent;
struct __locale_t;
struct _Bigint
{
struct _Bigint *_next;
int _k, _maxwds, _sign, _wds;
__ULong _x[1];
};
struct __tm
{
int __tm_sec;
int __tm_min;
int __tm_hour;
int __tm_mday;
int __tm_mon;
int __tm_year;
int __tm_wday;
int __tm_yday;
int __tm_isdst;
};
#define _ATEXIT_SIZE 32
struct _on_exit_args {
void * _fnargs[32];
void * _dso_handle[32];
__ULong _fntypes;
__ULong _is_cxa;
};
# 98 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
struct _atexit {
struct _atexit *_next;
int _ind;
void (*_fns[32])(void);
struct _on_exit_args _on_exit_args;
};
#define _ATEXIT_INIT {_NULL, 0, {_NULL}, {{_NULL}, {_NULL}, 0, 0}}
#define _REENT_INIT_ATEXIT _NULL, _ATEXIT_INIT,
# 122 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
struct __sbuf {
unsigned char *_base;
int _size;
};
# 183 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
#define _REENT_SMALL_CHECK_INIT(ptr)
struct __sFILE {
unsigned char *_p;
int _r;
int _w;
short _flags;
short _file;
struct __sbuf _bf;
int _lbfsize;
void * _cookie;
int (*_read) (struct _reent *, void *,
char *, int);
int (*_write) (struct _reent *, void *,
const char *,
int);
_fpos_t (*_seek) (struct _reent *, void *, _fpos_t, int);
int (*_close) (struct _reent *, void *);
struct __sbuf _ub;
unsigned char *_up;
int _ur;
unsigned char _ubuf[3];
unsigned char _nbuf[1];
struct __sbuf _lb;
int _blksize;
_off_t _offset;
struct _reent *_data;
_flock_t _lock;
_mbstate_t _mbstate;
int _flags2;
};
# 292 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
typedef struct __sFILE __FILE;
struct _glue
{
struct _glue *_next;
int _niobs;
__FILE *_iobs;
};
# 317 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
#define _RAND48_SEED_0 (0x330e)
#define _RAND48_SEED_1 (0xabcd)
#define _RAND48_SEED_2 (0x1234)
#define _RAND48_MULT_0 (0xe66d)
#define _RAND48_MULT_1 (0xdeec)
#define _RAND48_MULT_2 (0x0005)
#define _RAND48_ADD (0x000b)
struct _rand48 {
unsigned short _seed[3];
unsigned short _mult[3];
unsigned short _add;
};
#define _REENT_EMERGENCY_SIZE 25
#define _REENT_ASCTIME_SIZE 26
#define _REENT_SIGNAL_SIZE 24
# 613 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
struct _reent
{
int _errno;
__FILE *_stdin, *_stdout, *_stderr;
int _inc;
char _emergency[25];
int _unspecified_locale_info;
struct __locale_t *_locale;
int __sdidinit;
void (*__cleanup) (struct _reent *);
struct _Bigint *_result;
int _result_k;
struct _Bigint *_p5s;
struct _Bigint **_freelist;
int _cvtlen;
char *_cvtbuf;
union
{
struct
{
unsigned int _unused_rand;
char * _strtok_last;
char _asctime_buf[26];
struct __tm _localtime_buf;
int _gamma_signgam;
__extension__ unsigned long long _rand_next;
struct _rand48 _r48;
_mbstate_t _mblen_state;
_mbstate_t _mbtowc_state;
_mbstate_t _wctomb_state;
char _l64a_buf[8];
char _signal_buf[24];
int _getdate_err;
_mbstate_t _mbrlen_state;
_mbstate_t _mbrtowc_state;
_mbstate_t _mbsrtowcs_state;
_mbstate_t _wcrtomb_state;
_mbstate_t _wcsrtombs_state;
int _h_errno;
} _reent;
struct
{
#define _N_LISTS 30
unsigned char * _nextf[30];
unsigned int _nmalloc[30];
} _unused;
} _new;
struct _atexit *_atexit;
struct _atexit _atexit0;
void (**(_sig_func))(int);
struct _glue __sglue;
__FILE __sf[3];
};
#define _REENT_STDIO_STREAM(var,index) &(var)->__sf[index]
#define _REENT_INIT(var) { 0, _REENT_STDIO_STREAM(&(var), 0), _REENT_STDIO_STREAM(&(var), 1), _REENT_STDIO_STREAM(&(var), 2), 0, "", 0, _NULL, 0, _NULL, _NULL, 0, _NULL, _NULL, 0, _NULL, { { 0, _NULL, "", {0, 0, 0, 0, 0, 0, 0, 0, 0}, 0, 1, { {_RAND48_SEED_0, _RAND48_SEED_1, _RAND48_SEED_2}, {_RAND48_MULT_0, _RAND48_MULT_1, _RAND48_MULT_2}, _RAND48_ADD }, {0, {0}}, {0, {0}}, {0, {0}}, "", "", 0, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}}, {0, {0}} } }, _REENT_INIT_ATEXIT _NULL, {_NULL, 0, _NULL} }
# 751 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
#define _REENT_INIT_PTR_ZEROED(var) { (var)->_stdin = _REENT_STDIO_STREAM(var, 0); (var)->_stdout = _REENT_STDIO_STREAM(var, 1); (var)->_stderr = _REENT_STDIO_STREAM(var, 2); (var)->_new._reent._rand_next = 1; (var)->_new._reent._r48._seed[0] = _RAND48_SEED_0; (var)->_new._reent._r48._seed[1] = _RAND48_SEED_1; (var)->_new._reent._r48._seed[2] = _RAND48_SEED_2; (var)->_new._reent._r48._mult[0] = _RAND48_MULT_0; (var)->_new._reent._r48._mult[1] = _RAND48_MULT_1; (var)->_new._reent._r48._mult[2] = _RAND48_MULT_2; (var)->_new._reent._r48._add = _RAND48_ADD; }
# 765 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
#define _REENT_CHECK_RAND48(ptr)
#define _REENT_CHECK_MP(ptr)
#define _REENT_CHECK_TM(ptr)
#define _REENT_CHECK_ASCTIME_BUF(ptr)
#define _REENT_CHECK_EMERGENCY(ptr)
#define _REENT_CHECK_MISC(ptr)
#define _REENT_CHECK_SIGNAL_BUF(ptr)
#define _REENT_SIGNGAM(ptr) ((ptr)->_new._reent._gamma_signgam)
#define _REENT_RAND_NEXT(ptr) ((ptr)->_new._reent._rand_next)
#define _REENT_RAND48_SEED(ptr) ((ptr)->_new._reent._r48._seed)
#define _REENT_RAND48_MULT(ptr) ((ptr)->_new._reent._r48._mult)
#define _REENT_RAND48_ADD(ptr) ((ptr)->_new._reent._r48._add)
#define _REENT_MP_RESULT(ptr) ((ptr)->_result)
#define _REENT_MP_RESULT_K(ptr) ((ptr)->_result_k)
#define _REENT_MP_P5S(ptr) ((ptr)->_p5s)
#define _REENT_MP_FREELIST(ptr) ((ptr)->_freelist)
#define _REENT_ASCTIME_BUF(ptr) ((ptr)->_new._reent._asctime_buf)
#define _REENT_TM(ptr) (&(ptr)->_new._reent._localtime_buf)
#define _REENT_EMERGENCY(ptr) ((ptr)->_emergency)
#define _REENT_STRTOK_LAST(ptr) ((ptr)->_new._reent._strtok_last)
#define _REENT_MBLEN_STATE(ptr) ((ptr)->_new._reent._mblen_state)
#define _REENT_MBTOWC_STATE(ptr) ((ptr)->_new._reent._mbtowc_state)
#define _REENT_WCTOMB_STATE(ptr) ((ptr)->_new._reent._wctomb_state)
#define _REENT_MBRLEN_STATE(ptr) ((ptr)->_new._reent._mbrlen_state)
#define _REENT_MBRTOWC_STATE(ptr) ((ptr)->_new._reent._mbrtowc_state)
#define _REENT_MBSRTOWCS_STATE(ptr) ((ptr)->_new._reent._mbsrtowcs_state)
#define _REENT_WCRTOMB_STATE(ptr) ((ptr)->_new._reent._wcrtomb_state)
#define _REENT_WCSRTOMBS_STATE(ptr) ((ptr)->_new._reent._wcsrtombs_state)
#define _REENT_L64A_BUF(ptr) ((ptr)->_new._reent._l64a_buf)
#define _REENT_SIGNAL_BUF(ptr) ((ptr)->_new._reent._signal_buf)
#define _REENT_GETDATE_ERR_P(ptr) (&((ptr)->_new._reent._getdate_err))
#define _REENT_INIT_PTR(var) { memset((var), 0, sizeof(*(var))); _REENT_INIT_PTR_ZEROED(var); }
#define _Kmax (sizeof (size_t) << 3)
#define __ATTRIBUTE_IMPURE_PTR__
extern struct _reent *_impure_ptr ;
extern struct _reent *const _global_impure_ptr ;
void _reclaim_reent (struct _reent *);
# 832 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/reent.h" 3
#define _REENT _impure_ptr
#define _GLOBAL_REENT _global_impure_ptr
#define _GLOBAL_ATEXIT (_GLOBAL_REENT->_atexit)
# 12 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 1 3
# 43 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define _SYS_CDEFS_H_
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 1 3 4
# 48 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 2 3
#define __PMT(args) args
#define __DOTS , ...
#define __THROW
#define __ASMNAME(cname) __XSTRING (__USER_LABEL_PREFIX__) cname
#define __ptr_t void *
#define __long_double_t long double
#define __attribute_malloc__
#define __attribute_pure__
#define __attribute_format_strfmon__(a,b)
#define __flexarr [0]
#define __bounded
#define __unbounded
#define __ptrvalue
# 78 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __has_extension __has_feature
#define __has_feature(x) 0
# 94 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __BEGIN_DECLS
#define __END_DECLS
# 107 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __GNUCLIKE_ASM 3
#define __GNUCLIKE_MATH_BUILTIN_CONSTANTS
#define __GNUCLIKE___TYPEOF 1
#define __GNUCLIKE___OFFSETOF 1
#define __GNUCLIKE___SECTION 1
#define __GNUCLIKE_CTOR_SECTION_HANDLING 1
#define __GNUCLIKE_BUILTIN_CONSTANT_P 1
#define __GNUCLIKE_BUILTIN_VARARGS 1
#define __GNUCLIKE_BUILTIN_STDARG 1
#define __GNUCLIKE_BUILTIN_VAALIST 1
#define __GNUC_VA_LIST_COMPATIBILITY 1
#define __compiler_membar() __asm __volatile(" " : : : "memory")
#define __GNUCLIKE_BUILTIN_NEXT_ARG 1
#define __GNUCLIKE_MATH_BUILTIN_RELOPS
#define __GNUCLIKE_BUILTIN_MEMCPY 1
#define __CC_SUPPORTS_INLINE 1
#define __CC_SUPPORTS___INLINE 1
#define __CC_SUPPORTS___INLINE__ 1
#define __CC_SUPPORTS___FUNC__ 1
#define __CC_SUPPORTS_WARNING 1
#define __CC_SUPPORTS_VARADIC_XXX 1
#define __CC_SUPPORTS_DYNAMIC_ARRAY_INIT 1
# 177 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __P(protos) protos
#define __CONCAT1(x,y) x ## y
#define __CONCAT(x,y) __CONCAT1(x,y)
#define __STRING(x) #x
#define __XSTRING(x) __STRING(x)
#define __const const
#define __signed signed
#define __volatile volatile
# 230 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __weak_symbol __attribute__((__weak__))
# 243 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __dead2 __attribute__((__noreturn__))
#define __pure2 __attribute__((__const__))
#define __unused __attribute__((__unused__))
#define __used __attribute__((__used__))
#define __packed __attribute__((__packed__))
#define __aligned(x) __attribute__((__aligned__(x)))
#define __section(x) __attribute__((__section__(x)))
#define __alloc_size(x) __attribute__((__alloc_size__(x)))
#define __alloc_size2(n,x) __attribute__((__alloc_size__(n, x)))
#define __alloc_align(x) __attribute__((__alloc_align__(x)))
# 280 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define _Alignas(x) __aligned(x)
#define _Alignof(x) __alignof(x)
# 296 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define _Atomic(T) struct { T volatile __val; }
#define _Noreturn __dead2
# 331 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define _Thread_local __thread
# 351 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __generic(expr,t,yes,no) __builtin_choose_expr( __builtin_types_compatible_p(__typeof(expr), t), yes, no)
# 366 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __min_size(x) static (x)
#define __malloc_like __attribute__((__malloc__))
#define __pure __attribute__((__pure__))
#define __always_inline __inline__ __attribute__((__always_inline__))
#define __noinline __attribute__ ((__noinline__))
#define __nonnull(x) __attribute__((__nonnull__ x))
#define __nonnull_all __attribute__((__nonnull__))
#define __fastcall __attribute__((__fastcall__))
#define __result_use_check __attribute__((__warn_unused_result__))
#define __returns_twice __attribute__((__returns_twice__))
#define __unreachable() __builtin_unreachable()
# 434 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __restrict restrict
# 467 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __predict_true(exp) __builtin_expect((exp), 1)
#define __predict_false(exp) __builtin_expect((exp), 0)
#define __null_sentinel __attribute__((__sentinel__))
#define __exported __attribute__((__visibility__("default")))
#define __hidden __attribute__((__visibility__("hidden")))
# 489 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __offsetof(type,field) offsetof(type, field)
#define __rangeof(type,start,end) (__offsetof(type, end) - __offsetof(type, start))
# 500 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __containerof(x,s,m) ({ const volatile __typeof(((s *)0)->m) *__x = (x); __DEQUALIFY(s *, (const volatile char *)__x - __offsetof(s, m));})
# 522 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __printflike(fmtarg,firstvararg) __attribute__((__format__ (__printf__, fmtarg, firstvararg)))
#define __scanflike(fmtarg,firstvararg) __attribute__((__format__ (__scanf__, fmtarg, firstvararg)))
#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
#define __strfmonlike(fmtarg,firstvararg) __attribute__((__format__ (__strfmon__, fmtarg, firstvararg)))
#define __strftimelike(fmtarg,firstvararg) __attribute__((__format__ (__strftime__, fmtarg, firstvararg)))
# 539 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __printf0like(fmtarg,firstvararg)
#define __strong_reference(sym,aliassym) extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
#define __weak_reference(sym,alias) __asm__(".weak " #alias); __asm__(".equ " #alias ", " #sym)
#define __warn_references(sym,msg) __asm__(".section .gnu.warning." #sym); __asm__(".asciz \"" msg "\""); __asm__(".previous")
#define __sym_compat(sym,impl,verid) __asm__(".symver " #impl ", " #sym "@" #verid)
#define __sym_default(sym,impl,verid) __asm__(".symver " #impl ", " #sym "@@" #verid)
# 593 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __FBSDID(s) struct __hack
#define __RCSID(s) struct __hack
#define __RCSID_SOURCE(s) struct __hack
#define __SCCSID(s) struct __hack
#define __COPYRIGHT(s) struct __hack
#define __DECONST(type,var) ((type)(__uintptr_t)(const void *)(var))
#define __DEVOLATILE(type,var) ((type)(__uintptr_t)(volatile void *)(var))
#define __DEQUALIFY(type,var) ((type)(__uintptr_t)(const volatile void *)(var))
#define _Nonnull
#define _Nullable
#define _Null_unspecified
#define __NULLABILITY_PRAGMA_PUSH
#define __NULLABILITY_PRAGMA_POP
# 653 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __arg_type_tag(arg_kind,arg_idx,type_tag_idx)
#define __datatype_type_tag(kind,type)
# 672 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/cdefs.h" 3
#define __lock_annotate(x)
#define __lockable __lock_annotate(lockable)
#define __locks_exclusive(...) __lock_annotate(exclusive_lock_function(__VA_ARGS__))
#define __locks_shared(...) __lock_annotate(shared_lock_function(__VA_ARGS__))
#define __trylocks_exclusive(...) __lock_annotate(exclusive_trylock_function(__VA_ARGS__))
#define __trylocks_shared(...) __lock_annotate(shared_trylock_function(__VA_ARGS__))
#define __unlocks(...) __lock_annotate(unlock_function(__VA_ARGS__))
#define __asserts_exclusive(...) __lock_annotate(assert_exclusive_lock(__VA_ARGS__))
#define __asserts_shared(...) __lock_annotate(assert_shared_lock(__VA_ARGS__))
#define __requires_exclusive(...) __lock_annotate(exclusive_locks_required(__VA_ARGS__))
#define __requires_shared(...) __lock_annotate(shared_locks_required(__VA_ARGS__))
#define __requires_unlocked(...) __lock_annotate(locks_excluded(__VA_ARGS__))
#define __no_lock_analysis __lock_annotate(no_thread_safety_analysis)
#define __guarded_by(x) __lock_annotate(guarded_by(x))
#define __pt_guarded_by(x) __lock_annotate(pt_guarded_by(x))
# 13 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 2 3
#define __need_size_t
#define __need_NULL
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 1 3 4
# 155 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_ptrdiff_t
# 231 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_size_t
# 340 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_wchar_t
# 390 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef NULL
#define NULL ((void *)0)
#undef __need_NULL
#define offsetof(TYPE,MEMBER) __builtin_offsetof (TYPE, MEMBER)
# 18 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 2 3
# 27 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 3
void * memchr (const void *, int, size_t);
int memcmp (const void *, const void *, size_t);
void * memcpy (void *restrict, const void *restrict, size_t);
void * memmove (void *, const void *, size_t);
void * memset (void *, int, size_t);
char *strcat (char *restrict, const char *restrict);
char *strchr (const char *, int);
int strcmp (const char *, const char *);
int strcoll (const char *, const char *);
char *strcpy (char *restrict, const char *restrict);
size_t strcspn (const char *, const char *);
char *strerror (int);
size_t strlen (const char *);
char *strncat (char *restrict, const char *restrict, size_t);
int strncmp (const char *, const char *, size_t);
char *strncpy (char *restrict, const char *restrict, size_t);
char *strpbrk (const char *, const char *);
char *strrchr (const char *, int);
size_t strspn (const char *, const char *);
char *strstr (const char *, const char *);
char *strtok (char *restrict, const char *restrict);
size_t strxfrm (char *restrict, const char *restrict, size_t);
# 86 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 3
char *_strdup_r (struct _reent *, const char *);
char *_strndup_r (struct _reent *, const char *, size_t);
# 112 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 3
char * _strerror_r (struct _reent *, int, int, int *);
# 134 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 3
char *strsignal (int __signo);
# 175 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/string.h" 1 3
# 176 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/string.h" 2 3
# 30 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_tiny_vsnprintf.h" 2
# 54 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_tiny_vsnprintf.h"
# 54 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_tiny_vsnprintf.h"
int tiny_vsnprintf_like(char *buf, const int size, const char *fmt, va_list args);
# 37 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h" 2
# 49 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h"
#define VLEVEL_OFF 0
#define VLEVEL_ALWAYS 0
#define VLEVEL_L 1
#define VLEVEL_M 2
#define VLEVEL_H 3
#define TS_OFF 0
#define TS_ON 1
#define T_REG_OFF 0
# 78 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h"
#define UTIL_PLACE_IN_SECTION(__x__) __attribute__((section (__x__)))
#undef ALIGN
#define ALIGN(n) __attribute__((aligned(n)))
#define UTIL_SEQ_INIT_CRITICAL_SECTION() UTILS_INIT_CRITICAL_SECTION()
#define UTIL_SEQ_ENTER_CRITICAL_SECTION() UTILS_ENTER_CRITICAL_SECTION()
#define UTIL_SEQ_EXIT_CRITICAL_SECTION() UTILS_EXIT_CRITICAL_SECTION()
#define UTIL_SEQ_MEMSET8(dest,value,size) UTIL_MEM_set_8( dest, value, size )
#define UTILS_INIT_CRITICAL_SECTION()
#define UTILS_ENTER_CRITICAL_SECTION() uint32_t primask_bit= __get_PRIMASK(); __disable_irq()
#define UTILS_EXIT_CRITICAL_SECTION() __set_PRIMASK(primask_bit)
# 135 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/utilities_conf.h"
#define UTIL_ADV_TRACE_CONDITIONNAL
#define UTIL_ADV_TRACE_UNCHUNK_MODE
#define UTIL_ADV_TRACE_DEBUG(...)
#define UTIL_ADV_TRACE_INIT_CRITICAL_SECTION() UTILS_INIT_CRITICAL_SECTION()
#define UTIL_ADV_TRACE_ENTER_CRITICAL_SECTION() UTILS_ENTER_CRITICAL_SECTION()
#define UTIL_ADV_TRACE_EXIT_CRITICAL_SECTION() UTILS_EXIT_CRITICAL_SECTION()
#define UTIL_ADV_TRACE_TMP_BUF_SIZE (512U)
#define UTIL_ADV_TRACE_TMP_MAX_TIMESTMAP_SIZE (15U)
#define UTIL_ADV_TRACE_FIFO_SIZE (1024U)
#define UTIL_ADV_TRACE_MEMSET8(dest,value,size) UTIL_MEM_set_8((dest),(value),(size))
#define UTIL_ADV_TRACE_VSNPRINTF(...) tiny_vsnprintf_like(__VA_ARGS__)
# 61 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h" 2
# 70 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
typedef enum {
UTIL_TIMER_ONESHOT = 0,
UTIL_TIMER_PERIODIC = 1
} UTIL_TIMER_Mode_t;
typedef enum {
UTIL_TIMER_OK = 0,
UTIL_TIMER_INVALID_PARAM = 1,
UTIL_TIMER_HW_ERROR = 2,
UTIL_TIMER_UNKNOWN_ERROR = 3
} UTIL_TIMER_Status_t;
typedef struct TimerEvent_s
{
uint32_t Timestamp;
uint32_t ReloadValue;
uint8_t IsPending;
uint8_t IsRunning;
uint8_t IsReloadStopped;
UTIL_TIMER_Mode_t Mode;
void ( *Callback )( void *);
void *argument;
struct TimerEvent_s *Next;
} UTIL_TIMER_Object_t;
typedef struct
{
UTIL_TIMER_Status_t (* InitTimer )( void );
UTIL_TIMER_Status_t (* DeInitTimer )( void );
UTIL_TIMER_Status_t (* StartTimerEvt )( uint32_t timeout );
UTIL_TIMER_Status_t (* StopTimerEvt )( void);
uint32_t (* SetTimerContext)( void );
uint32_t (* GetTimerContext)( void );
uint32_t (* GetTimerElapsedTime)( void );
uint32_t (* GetTimerValue)( void );
uint32_t (* GetMinimumTimeout)( void );
uint32_t (* ms2Tick)( uint32_t timeMicroSec );
uint32_t (* Tick2ms)( uint32_t tick );
} UTIL_TIMER_Driver_s;
typedef uint32_t UTIL_TIMER_Time_t;
# 142 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
extern const UTIL_TIMER_Driver_s UTIL_TimerDriver;
# 162 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Status_t UTIL_TIMER_Init(void);
UTIL_TIMER_Status_t UTIL_TIMER_DeInit(void);
# 184 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Status_t UTIL_TIMER_Create( UTIL_TIMER_Object_t *TimerObject, uint32_t PeriodValue, UTIL_TIMER_Mode_t Mode, void ( *Callback )( void *) , void *Argument);
UTIL_TIMER_Status_t UTIL_TIMER_Start( UTIL_TIMER_Object_t *TimerObject );
# 201 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Status_t UTIL_TIMER_StartWithPeriod( UTIL_TIMER_Object_t *TimerObject, uint32_t PeriodValue);
UTIL_TIMER_Status_t UTIL_TIMER_Stop( UTIL_TIMER_Object_t *TimerObject );
# 219 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Status_t UTIL_TIMER_SetPeriod(UTIL_TIMER_Object_t *TimerObject, uint32_t NewPeriodValue);
# 228 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Status_t UTIL_TIMER_SetReloadMode(UTIL_TIMER_Object_t *TimerObject, UTIL_TIMER_Mode_t ReloadMode);
# 237 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Status_t UTIL_TIMER_GetRemainingTime(UTIL_TIMER_Object_t *TimerObject, uint32_t *Time);
uint32_t UTIL_TIMER_IsRunning( UTIL_TIMER_Object_t *TimerObject );
uint32_t UTIL_TIMER_GetFirstRemainingTime(void);
UTIL_TIMER_Time_t UTIL_TIMER_GetCurrentTime(void);
# 269 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
UTIL_TIMER_Time_t UTIL_TIMER_GetElapsedTime(UTIL_TIMER_Time_t past );
# 278 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/timer/stm32_timer.h"
void UTIL_TIMER_IRQ_Handler( void );
# 32 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/timer.h" 2
# 45 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/timer.h"
#define TIMERTIME_T_MAX ( ( uint32_t )~0 )
# 60 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/timer.h"
#define TimerTime_t UTIL_TIMER_Time_t
#define TimerEvent_t UTIL_TIMER_Object_t
#define TimerInit(HANDLE,CB) do { UTIL_TIMER_Create( HANDLE, TIMERTIME_T_MAX, UTIL_TIMER_ONESHOT, CB, NULL); } while(0)
#define TimerSetValue(HANDLE,TIMEOUT) do{ UTIL_TIMER_SetPeriod(HANDLE, TIMEOUT); } while(0)
#define TimerStart(HANDLE) do { UTIL_TIMER_Start(HANDLE); } while(0)
#define TimerStop(HANDLE) do { if (UTIL_TIMER_IsRunning(HANDLE)) { UTIL_TIMER_Stop(HANDLE); } } while(0)
# 100 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/timer.h"
#define TimerGetCurrentTime UTIL_TIMER_GetCurrentTime
#define TimerGetElapsedTime UTIL_TIMER_GetElapsedTime
#define TimerTempCompensation(x,y) (x)
# 46 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/systime.h" 1
# 24 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/systime.h"
#define __SYSTIME_H__
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h" 1
# 46 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
#define __STM32_SYS_TIME_H__
# 59 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 1 3
#define _TIME_H_
#define __need_size_t
#define __need_NULL
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 1 3 4
# 155 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_ptrdiff_t
# 231 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_size_t
# 340 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef __need_wchar_t
# 390 "/opt/gcc-arm-none-eabi-10-2020-q4-major/lib/gcc/arm-none-eabi/10.2.1/include/stddef.h" 3 4
#undef NULL
#define NULL ((void *)0)
#undef __need_NULL
#define offsetof(TYPE,MEMBER) __builtin_offsetof (TYPE, MEMBER)
# 17 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/time.h" 1 3
#define _MACHTIME_H_
#define _CLOCKS_PER_SEC_ 100
# 20 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 2 3
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
#define CLK_TCK CLOCKS_PER_SEC
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 1 3
# 28 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 3
# 28 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 3
typedef __uint8_t u_int8_t;
typedef __uint16_t u_int16_t;
typedef __uint32_t u_int32_t;
typedef __uint64_t u_int64_t;
typedef __intptr_t register_t;
#define __BIT_TYPES_DEFINED__ 1
#define _SYS_TYPES_H
# 97 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 3
typedef __blkcnt_t blkcnt_t;
#define _BLKCNT_T_DECLARED
typedef __blksize_t blksize_t;
#define _BLKSIZE_T_DECLARED
typedef unsigned long clock_t;
#define __clock_t_defined
#define _CLOCK_T_DECLARED
typedef __int_least64_t time_t;
#define __time_t_defined
#define _TIME_T_DECLARED
typedef long daddr_t;
#define __daddr_t_defined
typedef char * caddr_t;
#define __caddr_t_defined
typedef __fsblkcnt_t fsblkcnt_t;
typedef __fsfilcnt_t fsfilcnt_t;
#define _FSBLKCNT_T_DECLARED
typedef __id_t id_t;
#define _ID_T_DECLARED
typedef __ino_t ino_t;
#define _INO_T_DECLARED
# 157 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 3
typedef __off_t off_t;
#define _OFF_T_DECLARED
typedef __dev_t dev_t;
#define _DEV_T_DECLARED
typedef __uid_t uid_t;
#define _UID_T_DECLARED
typedef __gid_t gid_t;
#define _GID_T_DECLARED
typedef __pid_t pid_t;
#define _PID_T_DECLARED
typedef __key_t key_t;
#define _KEY_T_DECLARED
typedef _ssize_t ssize_t;
#define _SSIZE_T_DECLARED
typedef __mode_t mode_t;
#define _MODE_T_DECLARED
typedef __nlink_t nlink_t;
#define _NLINK_T_DECLARED
typedef __clockid_t clockid_t;
#define __clockid_t_defined
#define _CLOCKID_T_DECLARED
typedef __timer_t timer_t;
#define __timer_t_defined
#define _TIMER_T_DECLARED
typedef __useconds_t useconds_t;
#define _USECONDS_T_DECLARED
typedef __suseconds_t suseconds_t;
#define _SUSECONDS_T_DECLARED
typedef __int64_t sbintime_t;
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h" 1 3
# 19 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_pthreadtypes.h" 3
#define _SYS__PTHREADTYPES_H_
# 224 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/machine/types.h" 1 3
# 225 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/types.h" 2 3
#undef __need_inttypes
# 29 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 2 3
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/timespec.h" 1 3
# 35 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/timespec.h" 3
#define _SYS_TIMESPEC_H_
# 1 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_timespec.h" 1 3
# 37 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_timespec.h" 3
#define _SYS__TIMESPEC_H_
# 47 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/_timespec.h" 3
struct timespec {
time_t tv_sec;
long tv_nsec;
};
# 39 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/timespec.h" 2 3
# 58 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/sys/timespec.h" 3
struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
};
# 30 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 2 3
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
clock_t clock (void);
double difftime (time_t _time2, time_t _time1);
time_t mktime (struct tm *_timeptr);
time_t time (time_t *_timer);
char *asctime (const struct tm *_tblock);
char *ctime (const time_t *_time);
struct tm *gmtime (const time_t *_timer);
struct tm *localtime (const time_t *_timer);
size_t strftime (char *restrict _s,
size_t _maxsize, const char *restrict _fmt,
const struct tm *restrict _t);
char *asctime_r (const struct tm *restrict,
char *restrict);
char *ctime_r (const time_t *, char *);
struct tm *gmtime_r (const time_t *restrict,
struct tm *restrict);
struct tm *localtime_r (const time_t *restrict,
struct tm *restrict);
# 103 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 3
void _tzset_r (struct _reent *);
typedef struct __tzrule_struct
{
char ch;
int m;
int n;
int d;
int s;
time_t change;
long offset;
} __tzrule_type;
typedef struct __tzinfo_struct
{
int __tznorth;
int __tzyear;
__tzrule_type __tzrule[2];
} __tzinfo_type;
__tzinfo_type *__gettzinfo (void);
# 240 "/opt/gcc-arm-none-eabi-10-2020-q4-major/arm-none-eabi/include/time.h" 3
#define CLOCK_ENABLED 1
#define CLOCK_DISABLED 0
#define CLOCK_ALLOWED 1
#define CLOCK_DISALLOWED 0
#define TIMER_ABSTIME 4
#define CLOCK_REALTIME ((clockid_t) 1)
# 60 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h" 2
# 70 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
#define TM_DAYS_IN_LEAP_YEAR ( ( uint32_t ) 366U )
#define TM_DAYS_IN_YEAR ( ( uint32_t ) 365U )
#define TM_SECONDS_IN_1DAY ( ( uint32_t )86400U )
#define TM_SECONDS_IN_1HOUR ( ( uint32_t ) 3600U )
#define TM_SECONDS_IN_1MINUTE ( ( uint32_t ) 60U )
#define TM_MINUTES_IN_1HOUR ( ( uint32_t ) 60U )
#define TM_HOURS_IN_1DAY ( ( uint32_t ) 24U )
#define TM_MONTH_JANUARY ( ( uint8_t ) 0U )
#define TM_MONTH_FEBRUARY ( ( uint8_t ) 1U )
#define TM_MONTH_MARCH ( ( uint8_t ) 2U )
#define TM_MONTH_APRIL ( ( uint8_t ) 3U )
#define TM_MONTH_MAY ( ( uint8_t ) 4U )
#define TM_MONTH_JUNE ( ( uint8_t ) 5U )
#define TM_MONTH_JULY ( ( uint8_t ) 6U )
#define TM_MONTH_AUGUST ( ( uint8_t ) 7U )
#define TM_MONTH_SEPTEMBER ( ( uint8_t ) 8U )
#define TM_MONTH_OCTOBER ( ( uint8_t ) 9U )
#define TM_MONTH_NOVEMBER ( ( uint8_t )10U )
#define TM_MONTH_DECEMBER ( ( uint8_t )11U )
#define TM_WEEKDAY_SUNDAY ( ( uint8_t )0U )
#define TM_WEEKDAY_MONDAY ( ( uint8_t )1U )
#define TM_WEEKDAY_TUESDAY ( ( uint8_t )2U )
#define TM_WEEKDAY_WEDNESDAY ( ( uint8_t )3U )
#define TM_WEEKDAY_THURSDAY ( ( uint8_t )4U )
#define TM_WEEKDAY_FRIDAY ( ( uint8_t )5U )
#define TM_WEEKDAY_SATURDAY ( ( uint8_t )6U )
#define UNIX_GPS_EPOCH_OFFSET 315964800
# 122 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
# 122 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
typedef struct SysTime_s
{
uint32_t Seconds;
int16_t SubSeconds;
}SysTime_t;
typedef struct
{
void (*BKUPWrite_Seconds) ( uint32_t Seconds);
uint32_t (*BKUPRead_Seconds) ( void );
void (*BKUPWrite_SubSeconds) ( uint32_t SubSeconds);
uint32_t (*BKUPRead_SubSeconds) ( void );
uint32_t (*GetCalendarTime)( uint16_t* SubSeconds );
} UTIL_SYSTIM_Driver_s;
# 156 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
extern const UTIL_SYSTIM_Driver_s UTIL_SYSTIMDriver;
# 174 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
SysTime_t SysTimeAdd( SysTime_t a, SysTime_t b );
# 184 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
SysTime_t SysTimeSub( SysTime_t a, SysTime_t b );
void SysTimeSet( SysTime_t sysTime );
SysTime_t SysTimeGet( void );
SysTime_t SysTimeGetMcuTime( void );
# 214 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
uint32_t SysTimeToMs( SysTime_t sysTime );
# 223 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
SysTime_t SysTimeFromMs( uint32_t timeMs );
uint32_t SysTimeMkTime( const struct tm* localtime );
# 240 "/home/jenkins/workspace/RUI_Release/rui-v3/external/STM32CubeWL/Utilities/misc/stm32_systime.h"
void SysTimeLocalTime( const uint32_t timestamp, struct tm *localtime );
# 32 "/home/jenkins/workspace/RUI_Release/rui-v3/component/core/board/rak3172/systime.h" 2
# 47 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 2
#define LORAMAC_CRYPTO_UNICAST_KEYS 0
#define LORAMAC_CRYPTO_MULTICAST_KEYS 127
#define LORAMAC_MAX_MC_CTX 4
# 77 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_0 0
# 93 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_1 1
# 109 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_2 2
# 125 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_3 3
# 141 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_4 4
# 157 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_5 5
# 173 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_6 6
# 189 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_7 7
# 205 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_8 8
# 221 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_9 9
# 237 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_10 10
# 253 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_11 11
# 269 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_12 12
# 285 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_13 13
# 301 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_14 14
# 317 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define DR_15 15
# 335 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_0 0
# 351 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_1 1
# 367 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_2 2
# 383 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_3 3
# 399 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_4 4
# 415 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_5 5
# 431 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_6 6
# 447 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_7 7
# 463 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_8 8
# 479 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_9 9
# 495 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_10 10
# 511 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_11 11
# 527 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_12 12
# 543 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_13 13
# 559 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
#define TX_POWER_14 14
#define TX_POWER_15 15
typedef enum DeviceClass_e
{
CLASS_A = 0x00,
CLASS_B = 0x01,
CLASS_C = 0x02,
}DeviceClass_t;
typedef enum eFType
{
FRAME_TYPE_A,
FRAME_TYPE_B,
FRAME_TYPE_C,
FRAME_TYPE_D,
}FType_t;
typedef enum eFCntIdentifier
{
FCNT_UP = 0,
N_FCNT_DOWN,
A_FCNT_DOWN,
FCNT_DOWN,
MC_FCNT_DOWN_0,
MC_FCNT_DOWN_1,
MC_FCNT_DOWN_2,
MC_FCNT_DOWN_3,
}FCntIdentifier_t;
typedef enum eKeyIdentifier
{
APP_KEY = 0,
NWK_KEY,
J_S_INT_KEY,
J_S_ENC_KEY,
F_NWK_S_INT_KEY,
S_NWK_S_INT_KEY,
NWK_S_ENC_KEY,
APP_S_KEY,
MC_ROOT_KEY,
MC_KE_KEY = 127,
MC_KEY_0,
MC_APP_S_KEY_0,
MC_NWK_S_KEY_0,
MC_KEY_1,
MC_APP_S_KEY_1,
MC_NWK_S_KEY_1,
MC_KEY_2,
MC_APP_S_KEY_2,
MC_NWK_S_KEY_2,
MC_KEY_3,
MC_APP_S_KEY_3,
MC_NWK_S_KEY_3,
SLOT_RAND_ZERO_KEY,
NO_KEY,
}KeyIdentifier_t;
typedef enum eAddressIdentifier
{
MULTICAST_0_ADDR = 0,
MULTICAST_1_ADDR = 1,
MULTICAST_2_ADDR = 2,
MULTICAST_3_ADDR = 3,
UNICAST_DEV_ADDR = 4,
}AddressIdentifier_t;
typedef union uMcRxParams
{
struct
{
uint32_t Frequency;
int8_t Datarate;
uint16_t Periodicity;
}ClassB;
struct
{
uint32_t Frequency;
int8_t Datarate;
}ClassC;
}McRxParams_t;
typedef struct sMcChannelParams
{
# 842 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 3 4
_Bool
# 842 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
IsRemotelySetup;
DeviceClass_t Class;
# 850 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 3 4
_Bool
# 850 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
IsEnabled;
AddressIdentifier_t GroupID;
uint32_t Address;
union uMcKeys
{
uint8_t *McKeyE;
struct
{
uint8_t *McAppSKey;
uint8_t *McNwkSKey;
}Session;
}McKeys;
uint32_t FCountMin;
uint32_t FCountMax;
McRxParams_t RxParams;
}McChannelParams_t;
typedef struct sMulticastCtx
{
McChannelParams_t ChannelParams;
uint32_t* DownLinkCounter;
# 920 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
uint8_t PingNb;
uint16_t PingPeriod;
uint16_t PingOffset;
}MulticastCtx_t;
typedef enum eJoinReqIdentifier
{
REJOIN_REQ_0 = 0x00,
REJOIN_REQ_1 = 0x01,
REJOIN_REQ_2 = 0x02,
JOIN_REQ = 0xFF,
}JoinReqIdentifier_t;
typedef enum eLoRaMacMoteCmd
{
MOTE_MAC_LINK_CHECK_REQ = 0x02,
MOTE_MAC_LINK_ADR_ANS = 0x03,
MOTE_MAC_DUTY_CYCLE_ANS = 0x04,
MOTE_MAC_RX_PARAM_SETUP_ANS = 0x05,
MOTE_MAC_DEV_STATUS_ANS = 0x06,
MOTE_MAC_NEW_CHANNEL_ANS = 0x07,
MOTE_MAC_RX_TIMING_SETUP_ANS = 0x08,
MOTE_MAC_TX_PARAM_SETUP_ANS = 0x09,
MOTE_MAC_DL_CHANNEL_ANS = 0x0A,
MOTE_MAC_DEVICE_TIME_REQ = 0x0D,
MOTE_MAC_PING_SLOT_INFO_REQ = 0x10,
MOTE_MAC_PING_SLOT_FREQ_ANS = 0x11,
MOTE_MAC_BEACON_TIMING_REQ = 0x12,
MOTE_MAC_BEACON_FREQ_ANS = 0x13,
}LoRaMacMoteCmd_t;
typedef enum eLoRaMacSrvCmd
{
SRV_MAC_RESET_CONF = 0x01,
SRV_MAC_LINK_CHECK_ANS = 0x02,
SRV_MAC_LINK_ADR_REQ = 0x03,
SRV_MAC_DUTY_CYCLE_REQ = 0x04,
SRV_MAC_RX_PARAM_SETUP_REQ = 0x05,
SRV_MAC_DEV_STATUS_REQ = 0x06,
SRV_MAC_NEW_CHANNEL_REQ = 0x07,
SRV_MAC_RX_TIMING_SETUP_REQ = 0x08,
SRV_MAC_TX_PARAM_SETUP_REQ = 0x09,
SRV_MAC_DL_CHANNEL_REQ = 0x0A,
SRV_MAC_DEVICE_TIME_ANS = 0x0D,
SRV_MAC_PING_SLOT_INFO_ANS = 0x10,
SRV_MAC_PING_SLOT_CHANNEL_REQ = 0x11,
SRV_MAC_BEACON_TIMING_ANS = 0x12,
SRV_MAC_BEACON_FREQ_REQ = 0x13,
}LoRaMacSrvCmd_t;
typedef struct sBand
{
uint16_t DCycle;
int8_t TxMaxPower;
UTIL_TIMER_Time_t LastBandUpdateTime;
UTIL_TIMER_Time_t LastMaxCreditAssignTime;
UTIL_TIMER_Time_t TimeCredits;
UTIL_TIMER_Time_t MaxTimeCredits;
# 1126 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 3 4
_Bool
# 1126 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h"
ReadyForTransmission;
}Band_t;
typedef union uDrRange
{
int8_t Value;
struct sFields
{
int8_t Min : 4;
int8_t Max : 4;
}Fields;
}DrRange_t;
typedef struct sChannelParams
{
uint32_t Frequency;
uint32_t Rx1Frequency;
DrRange_t DrRange;
uint8_t Band;
}ChannelParams_t;
typedef enum eLoRaMacFrameType
{
FRAME_TYPE_JOIN_REQ = 0x00,
FRAME_TYPE_JOIN_ACCEPT = 0x01,
FRAME_TYPE_DATA_UNCONFIRMED_UP = 0x02,
FRAME_TYPE_DATA_UNCONFIRMED_DOWN = 0x03,
FRAME_TYPE_DATA_CONFIRMED_UP = 0x04,
FRAME_TYPE_DATA_CONFIRMED_DOWN = 0x05,
FRAME_TYPE_PROPRIETARY = 0x07,
}LoRaMacFrameType_t;
typedef enum eLoRaMacBatteryLevel
{
BAT_LEVEL_EXT_SRC = 0x00,
BAT_LEVEL_EMPTY = 0x01,
BAT_LEVEL_FULL = 0xFE,
BAT_LEVEL_NO_MEASURE = 0xFF,
}LoRaMacBatteryLevel_t;
# 46 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h" 1
# 38 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define __LORAMAC_HEADER_TYPES_H__
# 48 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_MHDR_FIELD_SIZE 1
#define LORAMAC_JOIN_TYPE_FIELD_SIZE 1
#define LORAMAC_JOIN_EUI_FIELD_SIZE 8
#define LORAMAC_DEV_EUI_FIELD_SIZE 8
#define LORAMAC_DEV_NONCE_FIELD_SIZE 2
#define LORAMAC_JOIN_NONCE_FIELD_SIZE 3
#define LORAMAC_RJCOUNT_0_FIELD_SIZE 2
#define LORAMAC_RJCOUNT_1_FIELD_SIZE 2
#define LORAMAC_NET_ID_FIELD_SIZE 3
#define LORAMAC_DEV_ADDR_FIELD_SIZE 4
#define LORAMAC_DL_SETTINGS_FIELD_SIZE 1
#define LORAMAC_RX_DELAY_FIELD_SIZE 1
#define LORAMAC_CF_LIST_FIELD_SIZE 16
#define LORAMAC_FHDR_DEV_ADDR_FIELD_SIZE LORAMAC_DEV_ADDR_FIELD_SIZE
#define LORAMAC_FHDR_F_CTRL_FIELD_SIZE 1
#define LORAMAC_FHDR_F_CNT_FIELD_SIZE 2
#define LORAMAC_FHDR_F_OPTS_MAX_FIELD_SIZE 15
#define LORAMAC_F_PORT_FIELD_SIZE 1
#define LORAMAC_MAC_PAYLOAD_FIELD_MAX_SIZE 242
#define LORAMAC_MIC_FIELD_SIZE 4
#define LORAMAC_JOIN_REQ_MSG_SIZE ( LORAMAC_MHDR_FIELD_SIZE + LORAMAC_JOIN_EUI_FIELD_SIZE + LORAMAC_DEV_EUI_FIELD_SIZE + LORAMAC_DEV_NONCE_FIELD_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 121 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_RE_JOIN_1_MSG_SIZE ( LORAMAC_MHDR_FIELD_SIZE + LORAMAC_JOIN_TYPE_FIELD_SIZE + LORAMAC_JOIN_EUI_FIELD_SIZE + LORAMAC_DEV_EUI_FIELD_SIZE + LORAMAC_RJCOUNT_1_FIELD_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 131 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_RE_JOIN_0_2_MSG_SIZE ( LORAMAC_MHDR_FIELD_SIZE + LORAMAC_JOIN_TYPE_FIELD_SIZE + LORAMAC_NET_ID_FIELD_SIZE + LORAMAC_DEV_EUI_FIELD_SIZE + LORAMAC_RJCOUNT_0_FIELD_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 141 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_JOIN_ACCEPT_FRAME_MIN_SIZE ( LORAMAC_MHDR_FIELD_SIZE + LORAMAC_JOIN_NONCE_FIELD_SIZE + LORAMAC_NET_ID_FIELD_SIZE + LORAMAC_DEV_ADDR_FIELD_SIZE + LORAMAC_DL_SETTINGS_FIELD_SIZE + LORAMAC_RX_DELAY_FIELD_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 151 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_JOIN_ACCEPT_FRAME_MAX_SIZE ( LORAMAC_MHDR_FIELD_SIZE + LORAMAC_JOIN_NONCE_FIELD_SIZE + LORAMAC_NET_ID_FIELD_SIZE + LORAMAC_DEV_ADDR_FIELD_SIZE + LORAMAC_DL_SETTINGS_FIELD_SIZE + LORAMAC_RX_DELAY_FIELD_SIZE + LORAMAC_CF_LIST_FIELD_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 160 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define JOIN_ACCEPT_MIC_COMPUTATION_OFFSET ( LORAMAC_MHDR_FIELD_SIZE + LORAMAC_JOIN_TYPE_FIELD_SIZE + LORAMAC_JOIN_EUI_FIELD_SIZE + LORAMAC_DEV_NONCE_FIELD_SIZE )
# 173 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_FRAME_PAYLOAD_OVERHEAD_SIZE ( LORAMAC_MHDR_FIELD_SIZE + ( LORAMAC_FHDR_DEV_ADDR_FIELD_SIZE + LORAMAC_FHDR_F_CTRL_FIELD_SIZE + LORAMAC_FHDR_F_CNT_FIELD_SIZE ) + LORAMAC_F_PORT_FIELD_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 182 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
#define LORAMAC_FRAME_PAYLOAD_MIN_SIZE ( LORAMAC_MHDR_FIELD_SIZE + ( LORAMAC_FHDR_DEV_ADDR_FIELD_SIZE + LORAMAC_FHDR_F_CTRL_FIELD_SIZE + LORAMAC_FHDR_F_CNT_FIELD_SIZE ) + LORAMAC_MIC_FIELD_SIZE )
#define LORAMAC_FRAME_PAYLOAD_MAX_SIZE ( LORAMAC_MHDR_FIELD_SIZE + ( LORAMAC_FHDR_DEV_ADDR_FIELD_SIZE + LORAMAC_FHDR_F_CTRL_FIELD_SIZE + LORAMAC_FHDR_F_CNT_FIELD_SIZE ) + LORAMAC_F_PORT_FIELD_SIZE + LORAMAC_MAC_PAYLOAD_FIELD_MAX_SIZE + LORAMAC_MIC_FIELD_SIZE )
# 200 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacHeaderTypes.h"
typedef union uLoRaMacDLSettings
{
uint8_t Value;
struct sDLSettingsBits
{
uint8_t RX2DataRate : 4;
uint8_t RX1DRoffset : 3;
uint8_t OptNeg : 1;
}Bits;
}LoRaMacDLSettings_t;
typedef union uLoRaMacHeader
{
uint8_t Value;
struct sMacHeaderBits
{
uint8_t Major : 2;
uint8_t RFU : 3;
uint8_t MType : 3;
}Bits;
}LoRaMacHeader_t;
typedef union uLoRaMacFrameCtrl
{
uint8_t Value;
struct sCtrlBits
{
uint8_t FOptsLen : 4;
uint8_t FPending : 1;
uint8_t Ack : 1;
uint8_t AdrAckReq : 1;
uint8_t Adr : 1;
}Bits;
}LoRaMacFrameCtrl_t;
typedef struct sLoRaMacFrameHeader
{
uint32_t DevAddr;
LoRaMacFrameCtrl_t FCtrl;
uint16_t FCnt;
uint8_t FOpts[15];
}LoRaMacFrameHeader_t;
# 47 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 1
# 53 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
#define __REGION_H__
# 62 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h" 1
# 24 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
#define __UTILITIES_H__
# 37 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
#define SUCCESS 1
#define FAIL 0
# 52 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
#define MIN(a,b) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
# 63 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
#define MAX(a,b) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
# 72 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
#define POW2(n) ( 1 << n )
typedef union Version_u
{
struct Version_s
{
uint8_t Revision;
uint8_t Patch;
uint8_t Minor;
uint8_t Major;
}Fields;
uint32_t Value;
}Version_t;
void srand1( uint32_t seed );
# 103 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
int32_t randr( int32_t min, int32_t max );
# 114 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size );
# 123 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size );
# 134 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
void memset1( uint8_t *dst, uint8_t value, uint16_t size );
int8_t Nibble2HexChar( uint8_t a );
# 152 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
uint32_t Crc32( uint8_t *buffer, uint16_t length );
uint32_t Crc32Init( void );
# 171 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
uint32_t Crc32Update( uint32_t crcInit, uint8_t *buffer, uint16_t length );
# 180 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
uint32_t Crc32Finalize( uint32_t crc );
#define CRITICAL_SECTION_BEGIN() uint32_t mask; BoardCriticalSectionBegin( &mask )
#define CRITICAL_SECTION_END() BoardCriticalSectionEnd( &mask )
# 203 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/boards/utilities.h"
void BoardCriticalSectionBegin( uint32_t *mask );
void BoardCriticalSectionEnd( uint32_t *mask );
# 63 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 1
# 67 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
#define __LORAMAC_H__
# 79 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacTypes.h" 1
# 80 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionNvm.h" 1
# 34 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionNvm.h"
#define __REGIONNVM_H__
# 45 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionNvm.h"
#define REGION_NVM_MAX_NB_CHANNELS 96
# 59 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionNvm.h"
#define REGION_NVM_MAX_NB_BANDS 6
# 68 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionNvm.h"
#define REGION_NVM_CHANNELS_MASK_SIZE 6
# 77 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionNvm.h"
typedef struct sRegionNvmDataGroup1
{
Band_t Bands[ 6 ];
uint16_t ChannelsMaskRemaining[ 6 ];
uint8_t JoinChannelGroupsCurrentIndex;
uint8_t JoinTrialsCounter;
uint32_t Crc32;
}RegionNvmDataGroup1_t;
typedef struct sRegionNvmDataGroup2
{
ChannelParams_t Channels[ 96 ];
uint16_t ChannelsMask[ 6 ];
uint16_t ChannelsDefaultMask[ 6 ];
uint32_t Crc32;
}RegionNvmDataGroup2_t;
# 82 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacCryptoNvm.h" 1
# 34 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacCryptoNvm.h"
#define __LORAMAC_CRYPTO_NVM_H__
# 49 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacCryptoNvm.h"
typedef struct sFCntList
{
uint32_t FCntUp;
uint32_t NFCntDown;
uint32_t AFCntDown;
uint32_t FCntDown;
uint32_t McFCntDown[4];
}FCntList_t;
typedef struct sLoRaMacCryptoNvmData
{
Version_t LrWanVersion;
uint16_t DevNonce;
uint32_t JoinNonce;
FCntList_t FCntList;
uint32_t LastDownFCnt;
uint32_t Crc32;
}LoRaMacCryptoNvmData_t;
# 83 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/secure-element-nvm.h" 1
# 35 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/secure-element-nvm.h"
#define __SECURE_ELEMENT_NVM_H__
# 48 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/secure-element-nvm.h"
#define SE_KEY_SIZE 16
#define SE_EUI_SIZE 8
#define SE_PIN_SIZE 4
#define NUM_OF_KEYS 23
typedef struct sKey
{
KeyIdentifier_t KeyID;
uint8_t KeyValue[16];
} Key_t;
typedef struct sSecureElementNvCtx
{
uint8_t DevEui[8];
uint8_t JoinEui[8];
uint8_t Pin[4];
Key_t KeyList[23];
uint32_t Crc32;
} SecureElementNvmData_t;
# 84 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacClassBNvm.h" 1
# 34 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacClassBNvm.h"
#define __LORAMACCLASSBNVM_H__
# 47 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMacClassBNvm.h"
typedef struct sLoRaMacClassBPingSlotNvmData
{
struct sPingSlotCtrlNvm
{
uint8_t Assigned : 1;
uint8_t CustomFreq : 1;
}Ctrl;
uint8_t PingNb;
uint16_t PingPeriod;
uint32_t Frequency;
int8_t Datarate;
} LoRaMacClassBPingSlotNvmData_t;
typedef struct sLoRaMacClassBBeaconNvmData
{
struct sBeaconCtrlNvm
{
uint8_t CustomFreq : 1;
}Ctrl;
uint32_t Frequency;
} LoRaMacClassBBeaconNvmData_t;
typedef struct sLoRaMacClassBNvmData
{
LoRaMacClassBPingSlotNvmData_t PingSlotCtx;
LoRaMacClassBBeaconNvmData_t BeaconCtx;
uint32_t Crc32;
} LoRaMacClassBNvmData_t;
# 85 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 2
#define MAX_ACK_RETRIES 8
#define UP_LINK 0
#define DOWN_LINK 1
#define LORA_MAC_MLME_CONFIRM_QUEUE_LEN 5
#define LORAMAC_CRYPTO_MULTICAST_KEYS 127
#define LORA_MAC_COMMAND_MAX_LENGTH 128
#define LORAMAC_NVM_NOTIFY_FLAG_NONE 0x00
#define LORAMAC_NVM_NOTIFY_FLAG_CRYPTO 0x01
#define LORAMAC_NVM_NOTIFY_FLAG_MAC_GROUP1 0x02
#define LORAMAC_NVM_NOTIFY_FLAG_MAC_GROUP2 0x04
#define LORAMAC_NVM_NOTIFY_FLAG_SECURE_ELEMENT 0x08
#define LORAMAC_NVM_NOTIFY_FLAG_REGION_GROUP1 0x10
#define LORAMAC_NVM_NOTIFY_FLAG_REGION_GROUP2 0x20
#define LORAMAC_NVM_NOTIFY_FLAG_CLASS_B 0x40
typedef enum eActivationType
{
ACTIVATION_TYPE_NONE = 0,
ACTIVATION_TYPE_ABP = 1,
ACTIVATION_TYPE_OTAA = 2,
}ActivationType_t;
typedef struct sRxChannelParams
{
uint32_t Frequency;
uint8_t Datarate;
}RxChannelParams_t;
typedef enum eLoRaMacRxSlot
{
RX_SLOT_WIN_1,
RX_SLOT_WIN_2,
RX_SLOT_WIN_CLASS_C,
RX_SLOT_WIN_CLASS_C_MULTICAST,
RX_SLOT_WIN_CLASS_B_PING_SLOT,
RX_SLOT_WIN_CLASS_B_MULTICAST_SLOT,
RX_SLOT_NONE,
}LoRaMacRxSlot_t;
typedef struct sLoRaMacParams
{
uint32_t SystemMaxRxError;
uint8_t MinRxSymbols;
uint32_t MaxRxWindow;
uint32_t ReceiveDelay1;
uint32_t ReceiveDelay2;
uint32_t JoinAcceptDelay1;
uint32_t JoinAcceptDelay2;
uint8_t ChannelsNbTrans;
uint8_t Rx1DrOffset;
RxChannelParams_t Rx2Channel;
RxChannelParams_t RxCChannel;
uint8_t UplinkDwellTime;
uint8_t DownlinkDwellTime;
float MaxEirp;
float AntennaGain;
}LoRaMacParams_t;
typedef union uPingSlotInfo
{
uint8_t Value;
struct sInfoFields
{
uint8_t Periodicity : 3;
uint8_t RFU : 5;
}Fields;
}PingSlotInfo_t;
typedef struct sBeaconInfo
{
SysTime_t Time;
uint32_t Frequency;
uint8_t Datarate;
int16_t Rssi;
int8_t Snr;
struct sGwSpecific
{
uint8_t InfoDesc;
uint8_t Info[6];
}GwSpecific;
}BeaconInfo_t;
typedef enum eLoRaMacEventInfoStatus
{
LORAMAC_EVENT_INFO_STATUS_OK = 0,
LORAMAC_EVENT_INFO_STATUS_ERROR,
LORAMAC_EVENT_INFO_STATUS_TX_TIMEOUT,
LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT,
LORAMAC_EVENT_INFO_STATUS_RX2_TIMEOUT,
LORAMAC_EVENT_INFO_STATUS_RX1_ERROR,
LORAMAC_EVENT_INFO_STATUS_RX2_ERROR,
LORAMAC_EVENT_INFO_STATUS_JOIN_FAIL,
LORAMAC_EVENT_INFO_STATUS_DOWNLINK_REPEATED,
LORAMAC_EVENT_INFO_STATUS_TX_DR_PAYLOAD_SIZE_ERROR,
LORAMAC_EVENT_INFO_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS,
LORAMAC_EVENT_INFO_STATUS_ADDRESS_FAIL,
LORAMAC_EVENT_INFO_STATUS_MIC_FAIL,
LORAMAC_EVENT_INFO_STATUS_MULTICAST_FAIL,
LORAMAC_EVENT_INFO_STATUS_BEACON_LOCKED,
LORAMAC_EVENT_INFO_STATUS_BEACON_LOST,
LORAMAC_EVENT_INFO_STATUS_BEACON_NOT_FOUND,
}LoRaMacEventInfoStatus_t;
typedef union eLoRaMacFlags_t
{
uint8_t Value;
struct sMacFlagBits
{
uint8_t McpsReq : 1;
uint8_t McpsInd : 1;
uint8_t MlmeReq : 1;
uint8_t MlmeInd : 1;
uint8_t MlmeSchedUplinkInd : 1;
uint8_t MacDone : 1;
}Bits;
}LoRaMacFlags_t;
typedef enum eLoRaMacRegion
{
LORAMAC_REGION_AS923,
LORAMAC_REGION_AU915,
LORAMAC_REGION_CN470,
LORAMAC_REGION_CN779,
LORAMAC_REGION_EU433,
LORAMAC_REGION_EU868,
LORAMAC_REGION_KR920,
LORAMAC_REGION_IN865,
LORAMAC_REGION_US915,
LORAMAC_REGION_RU864,
}LoRaMacRegion_t;
typedef struct sLoRaMacNvmDataGroup1
{
uint32_t AdrAckCounter;
UTIL_TIMER_Time_t LastTxDoneTime;
UTIL_TIMER_Time_t AggregatedTimeOff;
uint32_t LastRxMic;
int8_t ChannelsTxPower;
int8_t ChannelsDatarate;
# 569 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 569 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
SrvAckRequested;
uint32_t Crc32;
}LoRaMacNvmDataGroup1_t;
typedef struct sLoRaMacNvmDataGroup2
{
LoRaMacRegion_t Region;
LoRaMacParams_t MacParams;
LoRaMacParams_t MacParamsDefaults;
int8_t ChannelsTxPowerDefault;
int8_t ChannelsDatarateDefault;
uint32_t NetID;
uint32_t DevAddr;
MulticastCtx_t MulticastChannelList[4];
DeviceClass_t DeviceClass;
# 618 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 618 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
PublicNetwork;
# 622 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 622 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
AdrCtrlOn;
uint8_t MaxDCycle;
# 631 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 631 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
DutyCycleOn;
uint16_t AggregatedDCycle;
SysTime_t InitializationTime;
Version_t Version;
ActivationType_t NetworkActivation;
uint32_t Crc32;
}LoRaMacNvmDataGroup2_t;
typedef struct sLoRaMacNvmData
{
LoRaMacCryptoNvmData_t Crypto;
LoRaMacNvmDataGroup1_t MacGroup1;
LoRaMacNvmDataGroup2_t MacGroup2;
SecureElementNvmData_t SecureElement;
RegionNvmDataGroup1_t RegionGroup1;
RegionNvmDataGroup2_t RegionGroup2;
LoRaMacClassBNvmData_t ClassB;
}LoRaMacNvmData_t;
# 720 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
typedef enum eMcps
{
MCPS_UNCONFIRMED,
MCPS_CONFIRMED,
MCPS_MULTICAST,
MCPS_PROPRIETARY,
}Mcps_t;
typedef struct sRequestReturnParam
{
UTIL_TIMER_Time_t DutyCycleWaitTime;
}RequestReturnParam_t;
typedef struct sMcpsReqUnconfirmed
{
uint8_t fPort;
void* fBuffer;
uint16_t fBufferSize;
int8_t Datarate;
}McpsReqUnconfirmed_t;
typedef struct sMcpsReqConfirmed
{
uint8_t fPort;
void* fBuffer;
uint16_t fBufferSize;
int8_t Datarate;
# 823 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
uint8_t NbTrials;
}McpsReqConfirmed_t;
typedef struct sMcpsReqProprietary
{
void* fBuffer;
uint16_t fBufferSize;
int8_t Datarate;
}McpsReqProprietary_t;
typedef struct sMcpsReq
{
Mcps_t Type;
union uMcpsParam
{
McpsReqUnconfirmed_t Unconfirmed;
McpsReqConfirmed_t Confirmed;
McpsReqProprietary_t Proprietary;
}Req;
RequestReturnParam_t ReqReturn;
}McpsReq_t;
typedef struct sMcpsConfirm
{
Mcps_t McpsRequest;
LoRaMacEventInfoStatus_t Status;
uint8_t Datarate;
int8_t TxPower;
# 904 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 904 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
AckReceived;
uint8_t NbRetries;
UTIL_TIMER_Time_t TxTimeOnAir;
uint32_t UpLinkCounter;
uint32_t Channel;
}McpsConfirm_t;
typedef struct sMcpsIndication
{
Mcps_t McpsIndication;
LoRaMacEventInfoStatus_t Status;
uint8_t Multicast;
uint8_t Port;
uint8_t RxDatarate;
uint8_t FramePending;
uint8_t* Buffer;
uint8_t BufferSize;
# 963 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 963 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
RxData;
int16_t Rssi;
int8_t Snr;
LoRaMacRxSlot_t RxSlot;
# 979 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 979 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
AckReceived;
uint32_t DownLinkCounter;
uint32_t DevAddress;
# 991 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 991 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
DeviceTimeAnsReceived;
}McpsIndication_t;
# 1018 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
typedef enum eMlme
{
MLME_UNKNOWN,
MLME_JOIN,
MLME_REJOIN_0,
MLME_REJOIN_1,
MLME_LINK_CHECK,
MLME_TXCW,
MLME_TXCW_1,
MLME_SCHEDULE_UPLINK,
MLME_DERIVE_MC_KE_KEY,
MLME_DERIVE_MC_KEY_PAIR,
MLME_DEVICE_TIME,
MLME_BEACON,
MLME_BEACON_ACQUISITION,
MLME_PING_SLOT_INFO,
MLME_BEACON_TIMING,
MLME_BEACON_LOST,
}Mlme_t;
typedef struct sMlmeReqJoin
{
uint8_t Datarate;
}MlmeReqJoin_t;
typedef struct sMlmeReqTxCw
{
uint16_t Timeout;
uint32_t Frequency;
int8_t Power;
}MlmeReqTxCw_t;
typedef struct sMlmeReqPingSlotInfo
{
PingSlotInfo_t PingSlot;
}MlmeReqPingSlotInfo_t;
typedef struct sMlmeReqDeriveMcKEKey
{
KeyIdentifier_t KeyID;
uint16_t Nonce;
uint8_t* DevEUI;
}MlmeReqDeriveMcKEKey_t;
typedef struct sMlmeReqDeriveMcSessionKeyPair
{
AddressIdentifier_t GroupID;
}MlmeReqDeriveMcSessionKeyPair_t;
typedef struct sMlmeReq
{
Mlme_t Type;
union uMlmeParam
{
MlmeReqJoin_t Join;
MlmeReqTxCw_t TxCw;
MlmeReqPingSlotInfo_t PingSlotInfo;
MlmeReqDeriveMcKEKey_t DeriveMcKEKey;
MlmeReqDeriveMcSessionKeyPair_t DeriveMcSessionKeyPair;
}Req;
RequestReturnParam_t ReqReturn;
}MlmeReq_t;
typedef struct sMlmeConfirm
{
Mlme_t MlmeRequest;
LoRaMacEventInfoStatus_t Status;
UTIL_TIMER_Time_t TxTimeOnAir;
uint8_t DemodMargin;
uint8_t NbGateways;
uint8_t NbRetries;
UTIL_TIMER_Time_t BeaconTimingDelay;
uint8_t BeaconTimingChannel;
}MlmeConfirm_t;
typedef struct sMlmeIndication
{
Mlme_t MlmeIndication;
LoRaMacEventInfoStatus_t Status;
BeaconInfo_t BeaconInfo;
}MlmeIndication_t;
# 1369 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
typedef enum eMib
{
MIB_DEVICE_CLASS,
MIB_NETWORK_ACTIVATION,
MIB_DEV_EUI,
MIB_JOIN_EUI,
MIB_SE_PIN,
MIB_ADR,
MIB_NET_ID,
MIB_DEV_ADDR,
MIB_APP_KEY,
MIB_NWK_KEY,
MIB_J_S_INT_KEY,
MIB_J_S_ENC_KEY,
MIB_F_NWK_S_INT_KEY,
MIB_S_NWK_S_INT_KEY,
MIB_NWK_S_ENC_KEY,
MIB_APP_S_KEY,
MIB_MC_KE_KEY,
MIB_MC_KEY_0,
MIB_MC_APP_S_KEY_0,
MIB_MC_NWK_S_KEY_0,
MIB_MC_KEY_1,
MIB_MC_APP_S_KEY_1,
MIB_MC_NWK_S_KEY_1,
MIB_MC_KEY_2,
MIB_MC_APP_S_KEY_2,
MIB_MC_NWK_S_KEY_2,
MIB_MC_KEY_3,
MIB_MC_APP_S_KEY_3,
MIB_MC_NWK_S_KEY_3,
MIB_PUBLIC_NETWORK,
MIB_CHANNELS,
MIB_RX2_CHANNEL,
MIB_RX2_DEFAULT_CHANNEL,
MIB_RXC_CHANNEL,
MIB_RXC_DEFAULT_CHANNEL,
MIB_CHANNELS_MASK,
MIB_CHANNELS_DEFAULT_MASK,
MIB_CHANNELS_NB_TRANS,
MIB_MAX_RX_WINDOW_DURATION,
MIB_RECEIVE_DELAY_1,
MIB_RECEIVE_DELAY_2,
MIB_JOIN_ACCEPT_DELAY_1,
MIB_JOIN_ACCEPT_DELAY_2,
MIB_CHANNELS_DEFAULT_DATARATE,
MIB_CHANNELS_DATARATE,
MIB_CHANNELS_TX_POWER,
MIB_CHANNELS_DEFAULT_TX_POWER,
MIB_SYSTEM_MAX_RX_ERROR,
MIB_MIN_RX_SYMBOLS,
# 1686 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
MIB_ANTENNA_GAIN,
# 1697 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
MIB_DEFAULT_ANTENNA_GAIN,
MIB_NVM_CTXS,
MIB_ABP_LORAWAN_VERSION,
MIB_LORAWAN_VERSION,
MIB_BEACON_INTERVAL,
MIB_BEACON_RESERVED,
MIB_BEACON_GUARD,
MIB_BEACON_WINDOW,
MIB_BEACON_WINDOW_SLOTS,
MIB_PING_SLOT_WINDOW,
MIB_BEACON_SYMBOL_TO_DEFAULT,
MIB_BEACON_SYMBOL_TO_EXPANSION_MAX,
MIB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX,
MIB_BEACON_SYMBOL_TO_EXPANSION_FACTOR,
MIB_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR,
MIB_MAX_BEACON_LESS_PERIOD,
MIB_PING_SLOT_DATARATE,
}Mib_t;
typedef union uMibParam
{
DeviceClass_t Class;
ActivationType_t NetworkActivation;
uint8_t* DevEui;
uint8_t* JoinEui;
uint8_t* SePin;
# 1810 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 1810 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
AdrEnable;
uint32_t NetID;
uint32_t DevAddr;
uint8_t* AppKey;
uint8_t* NwkKey;
uint8_t* JSIntKey;
uint8_t* JSEncKey;
uint8_t* FNwkSIntKey;
uint8_t* SNwkSIntKey;
uint8_t* NwkSEncKey;
uint8_t* AppSKey;
uint8_t* McKEKey;
uint8_t* McKey0;
uint8_t* McAppSKey0;
uint8_t* McNwkSKey0;
uint8_t* McKey1;
uint8_t* McAppSKey1;
uint8_t* McNwkSKey1;
uint8_t* McKey2;
uint8_t* McAppSKey2;
uint8_t* McNwkSKey2;
uint8_t* McKey3;
uint8_t* McAppSKey3;
uint8_t* McNwkSKey3;
# 1954 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 1954 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
EnablePublicNetwork;
ChannelParams_t* ChannelList;
RxChannelParams_t Rx2Channel;
RxChannelParams_t Rx2DefaultChannel;
RxChannelParams_t RxCChannel;
RxChannelParams_t RxCDefaultChannel;
uint16_t* ChannelsMask;
uint16_t* ChannelsDefaultMask;
uint8_t ChannelsNbTrans;
uint32_t MaxRxWindow;
uint32_t ReceiveDelay1;
uint32_t ReceiveDelay2;
uint32_t JoinAcceptDelay1;
uint32_t JoinAcceptDelay2;
int8_t ChannelsDefaultDatarate;
int8_t ChannelsDatarate;
int8_t ChannelsDefaultTxPower;
int8_t ChannelsTxPower;
McChannelParams_t MulticastChannel;
uint32_t SystemMaxRxError;
uint8_t MinRxSymbols;
float AntennaGain;
float DefaultAntennaGain;
LoRaMacNvmData_t* Contexts;
Version_t AbpLrWanVersion;
struct sLrWanVersion
{
Version_t LoRaWan;
Version_t LoRaWanRegion;
}LrWanVersion;
uint32_t BeaconInterval;
uint32_t BeaconReserved;
uint32_t BeaconGuard;
uint32_t BeaconWindow;
uint32_t BeaconWindowSlots;
uint32_t PingSlotWindow;
uint32_t BeaconSymbolToDefault;
uint32_t BeaconSymbolToExpansionMax;
uint32_t PingSlotSymbolToExpansionMax;
uint32_t BeaconSymbolToExpansionFactor;
uint32_t PingSlotSymbolToExpansionFactor;
uint32_t MaxBeaconLessPeriod;
int8_t PingSlotDatarate;
}MibParam_t;
typedef struct eMibRequestConfirm
{
Mib_t Type;
MibParam_t Param;
}MibRequestConfirm_t;
typedef struct sLoRaMacTxInfo
{
uint8_t MaxPossibleApplicationDataSize;
uint8_t CurrentPossiblePayloadSize;
}LoRaMacTxInfo_t;
typedef enum eLoRaMacStatus
{
LORAMAC_STATUS_OK,
LORAMAC_STATUS_BUSY,
LORAMAC_STATUS_SERVICE_UNKNOWN,
LORAMAC_STATUS_PARAMETER_INVALID,
LORAMAC_STATUS_FREQUENCY_INVALID,
LORAMAC_STATUS_DATARATE_INVALID,
LORAMAC_STATUS_FREQ_AND_DR_INVALID,
LORAMAC_STATUS_NO_NETWORK_JOINED,
LORAMAC_STATUS_LENGTH_ERROR,
LORAMAC_STATUS_REGION_NOT_SUPPORTED,
LORAMAC_STATUS_SKIPPED_APP_DATA,
# 2288 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LORAMAC_STATUS_DUTYCYCLE_RESTRICTED,
LORAMAC_STATUS_NO_CHANNEL_FOUND,
LORAMAC_STATUS_NO_FREE_CHANNEL_FOUND,
LORAMAC_STATUS_BUSY_BEACON_RESERVED_TIME,
LORAMAC_STATUS_BUSY_PING_SLOT_WINDOW_TIME,
LORAMAC_STATUS_BUSY_UPLINK_COLLISION,
LORAMAC_STATUS_CRYPTO_ERROR,
LORAMAC_STATUS_FCNT_HANDLER_ERROR,
LORAMAC_STATUS_MAC_COMMAD_ERROR,
LORAMAC_STATUS_CLASS_B_ERROR,
LORAMAC_STATUS_CONFIRM_QUEUE_ERROR,
LORAMAC_STATUS_MC_GROUP_UNDEFINED,
LORAMAC_STATUS_ERROR
}LoRaMacStatus_t;
typedef struct sLoRaMacPrimitives
{
void ( *MacMcpsConfirm )( McpsConfirm_t* McpsConfirm );
void ( *MacMcpsIndication )( McpsIndication_t* McpsIndication );
void ( *MacMlmeConfirm )( MlmeConfirm_t* MlmeConfirm );
void ( *MacMlmeIndication )( MlmeIndication_t* MlmeIndication );
}LoRaMacPrimitives_t;
typedef struct sLoRaMacCallback
{
# 2384 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
uint8_t ( *GetBatteryLevel )( void );
float ( *GetTemperatureLevel )( void );
void ( *NvmDataChange )( uint16_t notifyFlags );
void ( *MacProcessNotify )( void );
}LoRaMacCallback_t;
static const uint8_t LoRaMacMaxEirpTable[] = { 8, 10, 12, 13, 14, 16, 18, 20, 21, 24, 26, 27, 29, 30, 33, 36 };
# 2435 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacInitialization( LoRaMacPrimitives_t* primitives, LoRaMacCallback_t* callbacks, LoRaMacRegion_t region );
# 2444 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacStart( void );
# 2453 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacStop( void );
# 2460 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h" 3 4
_Bool
# 2460 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacIsBusy( void );
void LoRaMacProcess( void );
# 2494 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacQueryTxPossible( uint8_t size, LoRaMacTxInfo_t* txInfo );
# 2512 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacChannelAdd( uint8_t id, ChannelParams_t params );
# 2526 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacChannelRemove( uint8_t id );
# 2541 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMcChannelSetup( McChannelParams_t *channel );
# 2555 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMcChannelDelete( AddressIdentifier_t groupID );
# 2565 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
uint8_t LoRaMacMcChannelGetGroupId( uint32_t mcAddress );
# 2582 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMcChannelSetupRxParams( AddressIdentifier_t groupID, McRxParams_t *rxParams, uint8_t *status );
# 2610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMibGetRequestConfirm( MibRequestConfirm_t* mibGet );
# 2641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMibSetRequestConfirm( MibRequestConfirm_t* mibSet );
# 2674 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMlmeRequest( MlmeReq_t* mlmeRequest );
# 2708 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t* mcpsRequest );
# 2720 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/LoRaMac.h"
LoRaMacStatus_t LoRaMacDeInitialization( void );
# 64 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 1
# 66 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 2
#define LC(channelIndex) ( uint16_t )( 1 << ( channelIndex - 1 ) )
#define REGION_VERSION 0x00010003
typedef enum ePhyAttribute
{
PHY_FREQUENCY,
PHY_MIN_RX_DR,
PHY_MIN_TX_DR,
PHY_MAX_RX_DR,
PHY_MAX_TX_DR,
PHY_TX_DR,
PHY_DEF_TX_DR,
PHY_RX_DR,
PHY_MAX_TX_POWER,
PHY_TX_POWER,
PHY_DEF_TX_POWER,
PHY_DEF_ADR_ACK_LIMIT,
PHY_DEF_ADR_ACK_DELAY,
PHY_MAX_PAYLOAD,
PHY_DUTY_CYCLE,
PHY_MAX_RX_WINDOW,
PHY_RECEIVE_DELAY1,
PHY_RECEIVE_DELAY2,
PHY_JOIN_ACCEPT_DELAY1,
PHY_JOIN_ACCEPT_DELAY2,
PHY_MAX_FCNT_GAP,
PHY_ACK_TIMEOUT,
PHY_DEF_DR1_OFFSET,
PHY_DEF_RX2_FREQUENCY,
PHY_DEF_RX2_DR,
PHY_CHANNELS_MASK,
PHY_CHANNELS_DEFAULT_MASK,
PHY_MAX_NB_CHANNELS,
PHY_CHANNELS,
PHY_DEF_UPLINK_DWELL_TIME,
PHY_DEF_DOWNLINK_DWELL_TIME,
PHY_DEF_MAX_EIRP,
PHY_DEF_ANTENNA_GAIN,
PHY_NEXT_LOWER_TX_DR,
PHY_BEACON_INTERVAL,
PHY_BEACON_RESERVED,
PHY_BEACON_GUARD,
PHY_BEACON_WINDOW,
PHY_BEACON_WINDOW_SLOTS,
PHY_PING_SLOT_WINDOW,
PHY_BEACON_SYMBOL_TO_DEFAULT,
PHY_BEACON_SYMBOL_TO_EXPANSION_MAX,
PHY_PING_SLOT_SYMBOL_TO_EXPANSION_MAX,
PHY_BEACON_SYMBOL_TO_EXPANSION_FACTOR,
PHY_PING_SLOT_SYMBOL_TO_EXPANSION_FACTOR,
PHY_MAX_BEACON_LESS_PERIOD,
PHY_BEACON_DELAY_BEACON_TIMING_ANS,
PHY_BEACON_CHANNEL_FREQ,
PHY_BEACON_FORMAT,
PHY_BEACON_CHANNEL_DR,
PHY_BEACON_NB_CHANNELS,
PHY_BEACON_CHANNEL_OFFSET,
PHY_PING_SLOT_CHANNEL_FREQ,
PHY_PING_SLOT_CHANNEL_DR,
PHY_PING_SLOT_NB_CHANNELS,
PHY_SF_FROM_DR,
PHY_BW_FROM_DR,
}PhyAttribute_t;
typedef enum eInitType
{
INIT_TYPE_DEFAULTS,
INIT_TYPE_RESET_TO_DEFAULT_CHANNELS,
INIT_TYPE_ACTIVATE_DEFAULT_CHANNELS
}InitType_t;
typedef enum eChannelsMask
{
CHANNELS_MASK,
CHANNELS_DEFAULT_MASK
}ChannelsMask_t;
typedef struct sBeaconFormat
{
uint8_t BeaconSize;
uint8_t Rfu1Size;
uint8_t Rfu2Size;
}BeaconFormat_t;
typedef union uPhyParam
{
uint32_t Value;
float fValue;
uint16_t* ChannelsMask;
ChannelParams_t* Channels;
BeaconFormat_t BeaconFormat;
UTIL_TIMER_Time_t DutyCycleTimePeriod;
}PhyParam_t;
typedef struct sGetPhyParams
{
PhyAttribute_t Attribute;
int8_t Datarate;
uint8_t UplinkDwellTime;
uint8_t DownlinkDwellTime;
uint8_t Channel;
}GetPhyParams_t;
typedef struct sSetBandTxDoneParams
{
uint8_t Channel;
# 458 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 458 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
Joined;
UTIL_TIMER_Time_t LastTxDoneTime;
UTIL_TIMER_Time_t LastTxAirTime;
SysTime_t ElapsedTimeSinceStartUp;
}SetBandTxDoneParams_t;
typedef struct sInitDefaultsParams
{
void* NvmGroup1;
void* NvmGroup2;
InitType_t Type;
}InitDefaultsParams_t;
typedef union uVerifyParams
{
uint32_t Frequency;
int8_t TxPower;
# 508 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 508 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
DutyCycle;
struct sDatarateParams
{
int8_t Datarate;
uint8_t DownlinkDwellTime;
uint8_t UplinkDwellTime;
}DatarateParams;
}VerifyParams_t;
typedef struct sApplyCFListParams
{
uint8_t* Payload;
uint8_t Size;
}ApplyCFListParams_t;
typedef struct sChanMaskSetParams
{
uint16_t* ChannelsMaskIn;
ChannelsMask_t ChannelsMaskType;
}ChanMaskSetParams_t;
typedef struct sRxConfigParams
{
uint8_t Channel;
int8_t Datarate;
uint8_t Bandwidth;
int8_t DrOffset;
uint32_t Frequency;
uint32_t WindowTimeout;
int32_t WindowOffset;
uint8_t DownlinkDwellTime;
# 599 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 599 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RxContinuous;
LoRaMacRxSlot_t RxSlot;
}RxConfigParams_t;
typedef struct sTxConfigParams
{
uint8_t Channel;
int8_t Datarate;
int8_t TxPower;
float MaxEirp;
float AntennaGain;
uint16_t PktLen;
}TxConfigParams_t;
typedef struct sLinkAdrReqParams
{
Version_t Version;
uint8_t* Payload;
uint8_t PayloadSize;
uint8_t UplinkDwellTime;
# 661 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 661 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
AdrEnabled;
int8_t CurrentDatarate;
int8_t CurrentTxPower;
uint8_t CurrentNbRep;
}LinkAdrReqParams_t;
typedef struct sRxParamSetupReqParams
{
int8_t Datarate;
int8_t DrOffset;
uint32_t Frequency;
}RxParamSetupReqParams_t;
typedef struct sNewChannelReqParams
{
ChannelParams_t* NewChannel;
int8_t ChannelId;
}NewChannelReqParams_t;
typedef struct sTxParamSetupReqParams
{
uint8_t UplinkDwellTime;
uint8_t DownlinkDwellTime;
uint8_t MaxEirp;
}TxParamSetupReqParams_t;
typedef struct sDlChannelReqParams
{
uint8_t ChannelId;
uint32_t Rx1Frequency;
}DlChannelReqParams_t;
typedef enum eAlternateDrType
{
ALTERNATE_DR,
ALTERNATE_DR_RESTORE
}AlternateDrType_t;
typedef struct sNextChanParams
{
UTIL_TIMER_Time_t AggrTimeOff;
UTIL_TIMER_Time_t LastAggrTx;
int8_t Datarate;
# 779 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 779 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
Joined;
# 783 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 783 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
DutyCycleEnabled;
SysTime_t ElapsedTimeSinceStartUp;
# 791 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 791 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
LastTxIsJoinRequest;
uint16_t PktLen;
}NextChanParams_t;
typedef struct sChannelAddParams
{
ChannelParams_t* NewChannel;
uint8_t ChannelId;
}ChannelAddParams_t;
typedef struct sChannelRemoveParams
{
uint8_t ChannelId;
}ChannelRemoveParams_t;
typedef struct sContinuousWaveParams
{
uint8_t Channel;
int8_t Datarate;
int8_t TxPower;
float MaxEirp;
float AntennaGain;
uint16_t Timeout;
}ContinuousWaveParams_t;
typedef struct sRxBeaconSetupParams
{
uint16_t SymbolTimeout;
uint32_t RxTime;
uint32_t Frequency;
}RxBeaconSetup_t;
# 884 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 884 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 884 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RegionIsActive( LoRaMacRegion_t region );
# 895 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t* getPhy );
# 904 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
void RegionSetBandTxDone( LoRaMacRegion_t region, SetBandTxDoneParams_t* txDone );
# 913 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
void RegionInitDefaults( LoRaMacRegion_t region, InitDefaultsParams_t* params );
# 926 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 926 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 926 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RegionVerify( LoRaMacRegion_t region, VerifyParams_t* verify, PhyAttribute_t phyAttribute );
# 936 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
void RegionApplyCFList( LoRaMacRegion_t region, ApplyCFListParams_t* applyCFList );
# 947 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 947 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 947 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RegionChanMaskSet( LoRaMacRegion_t region, ChanMaskSetParams_t* chanMaskSet );
# 960 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 960 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 960 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RegionRxConfig( LoRaMacRegion_t region, RxConfigParams_t* rxConfig, int8_t* datarate );
# 1015 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
void RegionComputeRxWindowParameters( LoRaMacRegion_t region, int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams );
# 1030 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 1030 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 1030 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RegionTxConfig( LoRaMacRegion_t region, TxConfigParams_t* txConfig, int8_t* txPower, UTIL_TIMER_Time_t* txTimeOnAir );
# 1049 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
uint8_t RegionLinkAdrReq( LoRaMacRegion_t region, LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed );
# 1060 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
uint8_t RegionRxParamSetupReq( LoRaMacRegion_t region, RxParamSetupReqParams_t* rxParamSetupReq );
# 1071 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
int8_t RegionNewChannelReq( LoRaMacRegion_t region, NewChannelReqParams_t* newChannelReq );
# 1084 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
int8_t RegionTxParamSetupReq( LoRaMacRegion_t region, TxParamSetupReqParams_t* txParamSetupReq );
# 1095 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
int8_t RegionDlChannelReq( LoRaMacRegion_t region, DlChannelReqParams_t* dlChannelReq );
# 1108 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
int8_t RegionAlternateDr( LoRaMacRegion_t region, int8_t currentDr, AlternateDrType_t type );
# 1124 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
LoRaMacStatus_t RegionNextChannel( LoRaMacRegion_t region, NextChanParams_t* nextChanParams, uint8_t* channel, UTIL_TIMER_Time_t* time, UTIL_TIMER_Time_t* aggregatedTimeOff );
# 1135 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
LoRaMacStatus_t RegionChannelAdd( LoRaMacRegion_t region, ChannelAddParams_t* channelAdd );
# 1146 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
# 1146 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h" 3 4
_Bool
# 1146 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
RegionChannelsRemove( LoRaMacRegion_t region, ChannelRemoveParams_t* channelRemove );
# 1155 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
void RegionSetContinuousWave( LoRaMacRegion_t region, ContinuousWaveParams_t* continuousWave );
# 1168 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
uint8_t RegionApplyDrOffset( LoRaMacRegion_t region, uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
# 1177 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/Region.h"
void RegionRxBeaconSetup( LoRaMacRegion_t region, RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr );
Version_t RegionGetVersion( void );
# 48 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 2
#define REGION_COMMON_DEFAULT_RECEIVE_DELAY1 1000
#define REGION_COMMON_DEFAULT_RECEIVE_DELAY2 ( REGION_COMMON_DEFAULT_RECEIVE_DELAY1 + 1000 )
#define REGION_COMMON_DEFAULT_JOIN_ACCEPT_DELAY1 5000
#define REGION_COMMON_DEFAULT_JOIN_ACCEPT_DELAY2 ( REGION_COMMON_DEFAULT_JOIN_ACCEPT_DELAY1 + 1000 )
#define REGION_COMMON_DEFAULT_ADR_ACK_LIMIT 64
#define REGION_COMMON_DEFAULT_ADR_ACK_DELAY 32
#define REGION_COMMON_DEFAULT_MAX_FCNT_GAP 16384
#define REGION_COMMON_DEFAULT_ACK_TIMEOUT 2000
#define REGION_COMMON_DEFAULT_ACK_TIMEOUT_RND 1000
#define REGION_COMMON_DEFAULT_RX1_DR_OFFSET 0
#define REGION_COMMON_DEFAULT_DOWNLINK_DWELL_TIME 0
#define REGION_COMMON_DEFAULT_PING_SLOT_PERIODICITY 7
typedef struct sRegionCommonLinkAdrParams
{
uint8_t NbRep;
int8_t Datarate;
int8_t TxPower;
uint8_t ChMaskCtrl;
uint16_t ChMask;
}RegionCommonLinkAdrParams_t;
typedef struct sRegionCommonLinkAdrReqVerifyParams
{
Version_t Version;
uint8_t Status;
# 152 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 152 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
AdrEnabled;
int8_t Datarate;
int8_t TxPower;
uint8_t NbRep;
int8_t CurrentDatarate;
int8_t CurrentTxPower;
int8_t CurrentNbRep;
uint8_t NbChannels;
uint16_t* ChannelsMask;
int8_t MinDatarate;
int8_t MaxDatarate;
ChannelParams_t* Channels;
int8_t MinTxPower;
int8_t MaxTxPower;
}RegionCommonLinkAdrReqVerifyParams_t;
typedef struct sRegionCommonRxBeaconSetupParams
{
const uint8_t* Datarates;
uint32_t Frequency;
uint8_t BeaconSize;
uint8_t BeaconDatarate;
uint8_t BeaconChannelBW;
uint32_t RxTime;
uint16_t SymbolTimeout;
}RegionCommonRxBeaconSetupParams_t;
typedef struct sRegionCommonCountNbOfEnabledChannelsParams
{
# 244 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 244 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
Joined;
uint8_t Datarate;
uint16_t* ChannelsMask;
ChannelParams_t* Channels;
Band_t* Bands;
uint16_t MaxNbChannels;
uint16_t* JoinChannels;
}RegionCommonCountNbOfEnabledChannelsParams_t;
typedef struct sRegionCommonIdentifyChannelsParam
{
UTIL_TIMER_Time_t AggrTimeOff;
UTIL_TIMER_Time_t LastAggrTx;
# 286 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 286 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
DutyCycleEnabled;
uint8_t MaxBands;
SysTime_t ElapsedTimeSinceStartUp;
# 298 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 298 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
LastTxIsJoinRequest;
UTIL_TIMER_Time_t ExpectedTimeOnAir;
RegionCommonCountNbOfEnabledChannelsParams_t* CountNbOfEnabledChannelsParam;
}RegionCommonIdentifyChannelsParam_t;
typedef struct sRegionCommonSetDutyCycleParams
{
UTIL_TIMER_Time_t DutyCycleTimePeriod;
uint8_t MaxBands;
Band_t* Bands;
}RegionCommonSetDutyCycleParams_t;
typedef struct sRegionCommonGetNextLowerTxDrParams
{
int8_t CurrentDr;
int8_t MaxDr;
int8_t MinDr;
uint8_t NbChannels;
uint16_t* ChannelsMask;
ChannelParams_t* Channels;
}RegionCommonGetNextLowerTxDrParams_t;
# 347 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint8_t RegionCommonValueInRange( int8_t value, int8_t min, int8_t max );
# 367 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
# 367 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 367 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
RegionCommonChanVerifyDr( uint8_t nbChannels, uint16_t* channelsMask, int8_t dr,
int8_t minDr, int8_t maxDr, ChannelParams_t* channels );
# 382 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
# 382 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 382 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
RegionCommonChanDisable( uint16_t* channelsMask, uint8_t id, uint8_t maxChannels );
# 396 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint8_t RegionCommonCountChannels( uint16_t* channelsMask, uint8_t startIdx, uint8_t stopIdx );
# 408 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
void RegionCommonChanMaskCopy( uint16_t* channelsMaskDest, uint16_t* channelsMaskSrc, uint8_t len );
# 422 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
void RegionCommonSetBandTxDone( Band_t* band, UTIL_TIMER_Time_t lastTxAirTime,
# 422 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 422 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
joined, SysTime_t elapsedTimeSinceStartup );
# 444 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
UTIL_TIMER_Time_t RegionCommonUpdateBandTimeOff(
# 444 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 444 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
joined, Band_t* bands,
uint8_t nbBands,
# 445 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 445 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
dutyCycleEnabled,
# 446 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h" 3 4
_Bool
# 446 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
lastTxIsJoinRequest, SysTime_t elapsedTimeSinceStartup,
UTIL_TIMER_Time_t expectedTimeOnAir );
# 461 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint8_t RegionCommonParseLinkAdrReq( uint8_t* payload, RegionCommonLinkAdrParams_t* parseLinkAdr );
# 477 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint8_t RegionCommonLinkAdrReqVerifyParams( RegionCommonLinkAdrReqVerifyParams_t* verifyParams, int8_t* dr, int8_t* txPow, uint8_t* nbRep );
# 488 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint32_t RegionCommonComputeSymbolTimeLoRa( uint8_t phyDr, uint32_t bandwidthInHz );
# 497 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint32_t RegionCommonComputeSymbolTimeFsk( uint8_t phyDrInKbps );
# 515 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
void RegionCommonComputeRxWindowParameters( uint32_t tSymbolInUs, uint8_t minRxSymbols, uint32_t rxErrorInMs, uint32_t wakeUpTimeInMs, uint32_t* windowTimeoutInSymbols, int32_t* windowOffsetInMs );
# 532 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
int8_t RegionCommonComputeTxPower( int8_t txPowerIndex, float maxEirp, float antennaGain );
void RegionCommonRxBeaconSetup( RegionCommonRxBeaconSetupParams_t* rxBeaconSetupParams );
# 554 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
void RegionCommonCountNbOfEnabledChannels( RegionCommonCountNbOfEnabledChannelsParams_t* countNbOfEnabledChannelsParams,
uint8_t* enabledChannels, uint8_t* nbEnabledChannels, uint8_t* nbRestrictedChannels );
# 578 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
LoRaMacStatus_t RegionCommonIdentifyChannels( RegionCommonIdentifyChannelsParam_t* identifyChannelsParam,
UTIL_TIMER_Time_t* aggregatedTimeOff, uint8_t* enabledChannels,
uint8_t* nbEnabledChannels, uint8_t* nbRestrictedChannels,
UTIL_TIMER_Time_t* nextTxDelay );
# 590 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
int8_t RegionCommonGetNextLowerTxDr( RegionCommonGetNextLowerTxDrParams_t *params );
# 601 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
int8_t RegionCommonLimitTxPower( int8_t txPower, int8_t maxBandTxPower );
# 612 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionCommon.h"
uint32_t RegionCommonGetBandwidth( uint32_t drIndex, const uint32_t* bandwidths );
typedef uint32_t (*IsSingleChannel_t)(void);
typedef uint8_t (*AlternateDr_t)(void);
typedef struct SingleChannel_s
{
IsSingleChannel_t IsSingleChannel;
AlternateDr_t AlternateDr;
}SingleChannel_t;
int32_t US915_SingleChannelRegisterCallback(SingleChannel_t* SingleChannel);
int32_t AU915_SingleChannelRegisterCallback(SingleChannel_t* SingleChannel);
# 33 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 2
# 1 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h" 1
# 38 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
#define __REGION_AS923_H__
# 51 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
#define CHANNEL_PLAN_GROUP_AS923_1 1
#define CHANNEL_PLAN_GROUP_AS923_2 2
#define CHANNEL_PLAN_GROUP_AS923_3 3
#define CHANNEL_PLAN_GROUP_AS923_1_JP 4
#define AS923_MAX_NB_CHANNELS 16
#define AS923_NUMB_DEFAULT_CHANNELS 2
#define AS923_NUMB_CHANNELS_CF_LIST 5
#define AS923_TX_MIN_DATARATE DR_0
#define AS923_TX_MAX_DATARATE DR_7
#define AS923_RX_MIN_DATARATE DR_0
#define AS923_RX_MAX_DATARATE DR_7
#define AS923_DEFAULT_DATARATE DR_2
#define AS923_DWELL_LIMIT_DATARATE DR_2
#define AS923_MIN_RX1_DR_OFFSET 0
#define AS923_MAX_RX1_DR_OFFSET 7
#define AS923_MIN_TX_POWER TX_POWER_7
#define AS923_MAX_TX_POWER TX_POWER_0
#define AS923_DEFAULT_TX_POWER TX_POWER_0
#define AS923_DEFAULT_UPLINK_DWELL_TIME 1
#define AS923_DEFAULT_MAX_EIRP 16.0f
#define AS923_DEFAULT_ANTENNA_GAIN 2.15f
#define AS923_DUTY_CYCLE_ENABLED 0
#define AS923_MAX_RX_WINDOW 3000
# 174 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
#define AS923_RX_WND_2_FREQ 923200000
#define AS923_RX_WND_2_DR DR_2
#define AS923_BEACON_CHANNEL_FREQ 923400000
#define AS923_PING_SLOT_CHANNEL_FREQ 923400000
#define AS923_BEACON_SIZE 17
#define AS923_RFU1_SIZE 2
#define AS923_RFU2_SIZE 0
#define AS923_BEACON_CHANNEL_DR DR_3
#define AS923_BEACON_CHANNEL_BW 0
#define AS923_PING_SLOT_CHANNEL_DR DR_3
#define AS923_MAX_NB_BANDS 1
#define AS923_BAND0 { 100, AS923_MAX_TX_POWER, 0, 0, 0, 0, 0 }
#define AS923_LC1 { 923200000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
#define AS923_LC2 { 923400000, 0, { ( ( DR_5 << 4 ) | DR_0 ) }, 0 }
#define AS923_JOIN_CHANNELS ( uint16_t )( LC( 1 ) | LC( 2 ) )
#define AS923_RSSI_FREE_TH -80
#define AS923_CARRIER_SENSE_TIME 5
static const uint8_t DataratesAS923[] = { 12, 11, 10, 9, 8, 7, 7, 50 };
static const uint32_t BandwidthsAS923[] = { 125000, 125000, 125000, 125000, 125000, 125000, 250000, 0 };
static const uint8_t MaxPayloadOfDatarateDwell0AS923[] = { 59, 59, 123, 123, 250, 250, 250, 250 };
static const uint8_t MaxPayloadOfDatarateDwell1AS923[] = { 0, 0, 19, 61, 133, 250, 250, 250 };
static const uint8_t MaxPayloadOfDatarateDwell1DownAS923[] = { 0, 0, 11, 53, 126, 242, 242, 242 };
static const int8_t EffectiveRx1DrOffsetAS923[] = { 0, 1, 2, 3, 4, 5, -1, -2 };
# 302 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
PhyParam_t RegionAS923GetPhyParam( GetPhyParams_t* getPhy );
void RegionAS923SetBandTxDone( SetBandTxDoneParams_t* txDone );
void RegionAS923InitDefaults( InitDefaultsParams_t* params );
# 327 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
# 327 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h" 3 4
_Bool
# 327 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
RegionAS923Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute );
void RegionAS923ApplyCFList( ApplyCFListParams_t* applyCFList );
# 344 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
# 344 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h" 3 4
_Bool
# 344 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
RegionAS923ChanMaskSet( ChanMaskSetParams_t* chanMaskSet );
# 359 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
void RegionAS923ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams );
# 370 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
# 370 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h" 3 4
_Bool
# 370 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
RegionAS923RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate );
# 383 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
# 383 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h" 3 4
_Bool
# 383 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, UTIL_TIMER_Time_t* txTimeOnAir );
# 392 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
uint8_t RegionAS923LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed );
# 401 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq );
# 410 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
int8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq );
# 421 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
int8_t RegionAS923TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq );
# 430 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
int8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq );
# 439 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
int8_t RegionAS923AlternateDr( int8_t currentDr, AlternateDrType_t type );
# 453 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_t* channel, UTIL_TIMER_Time_t* time, UTIL_TIMER_Time_t* aggregatedTimeOff );
# 462 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
LoRaMacStatus_t RegionAS923ChannelAdd( ChannelAddParams_t* channelAdd );
# 471 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
# 471 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h" 3 4
_Bool
# 471 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
RegionAS923ChannelsRemove( ChannelRemoveParams_t* channelRemove );
void RegionAS923SetContinuousWave( ContinuousWaveParams_t* continuousWave );
# 491 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.h"
uint8_t RegionAS923ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset );
void RegionAS923RxBeaconSetup( RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr );
# 34 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 2
#define CHANNELS_MASK_SIZE 1
#define REGION_AS923_DEFAULT_CHANNEL_PLAN CHANNEL_PLAN_GROUP_AS923_1
#define REGION_AS923_FREQ_OFFSET 0
#define AS923_MIN_RF_FREQUENCY 915000000
#define AS923_MAX_RF_FREQUENCY 928000000
# 102 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
static RegionNvmDataGroup1_t* RegionNvmGroup1;
static RegionNvmDataGroup2_t* RegionNvmGroup2;
static
# 106 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 106 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
VerifyRfFreq( uint32_t freq )
{
if( Radio.CheckRfFrequency( freq ) ==
# 109 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 109 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
return
# 111 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 111 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
if( ( freq < 915000000 ) || ( freq > 928000000 ) )
{
return
# 116 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 116 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
return
# 118 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 118 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
static UTIL_TIMER_Time_t GetTimeOnAir( int8_t datarate, uint16_t pktLen )
{
int8_t phyDr = DataratesAS923[datarate];
uint32_t bandwidth = RegionCommonGetBandwidth( datarate, BandwidthsAS923 );
UTIL_TIMER_Time_t timeOnAir = 0;
if( datarate == 7 )
{
timeOnAir = Radio.TimeOnAir( MODEM_FSK, bandwidth, phyDr * 1000, 0, 5,
# 129 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 129 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, pktLen,
# 129 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 129 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
);
}
else
{
timeOnAir = Radio.TimeOnAir( MODEM_LORA, bandwidth, phyDr, 1, 8,
# 133 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 133 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, pktLen,
# 133 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 133 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
);
}
return timeOnAir;
}
PhyParam_t RegionAS923GetPhyParam( GetPhyParams_t* getPhy )
{
PhyParam_t phyParam = { 0 };
switch( getPhy->Attribute )
{
case PHY_MIN_RX_DR:
{
if( getPhy->DownlinkDwellTime == 0 )
{
phyParam.Value = 0;
}
else
{
phyParam.Value = 2;
}
break;
}
case PHY_MIN_TX_DR:
{
if( getPhy->UplinkDwellTime == 0 )
{
phyParam.Value = 0;
}
else
{
phyParam.Value = 2;
}
break;
}
case PHY_DEF_TX_DR:
{
phyParam.Value = 2;
break;
}
case PHY_NEXT_LOWER_TX_DR:
{
RegionCommonGetNextLowerTxDrParams_t nextLowerTxDrParams =
{
.CurrentDr = getPhy->Datarate,
.MaxDr = ( int8_t )7,
.MinDr = ( int8_t )( ( getPhy->UplinkDwellTime == 0 ) ? 0 : 2 ),
.NbChannels = 16,
.ChannelsMask = RegionNvmGroup2->ChannelsMask,
.Channels = RegionNvmGroup2->Channels,
};
phyParam.Value = RegionCommonGetNextLowerTxDr( &nextLowerTxDrParams );
break;
}
case PHY_MAX_TX_POWER:
{
phyParam.Value = 0;
break;
}
case PHY_DEF_TX_POWER:
{
phyParam.Value = 0;
break;
}
case PHY_DEF_ADR_ACK_LIMIT:
{
phyParam.Value = 64;
break;
}
case PHY_DEF_ADR_ACK_DELAY:
{
phyParam.Value = 32;
break;
}
case PHY_MAX_PAYLOAD:
{
if( getPhy->UplinkDwellTime == 0 )
{
phyParam.Value = MaxPayloadOfDatarateDwell0AS923[getPhy->Datarate];
}
else
{
phyParam.Value = MaxPayloadOfDatarateDwell1AS923[getPhy->Datarate];
}
break;
}
case PHY_DUTY_CYCLE:
{
phyParam.Value = 0;
break;
}
case PHY_MAX_RX_WINDOW:
{
phyParam.Value = 3000;
break;
}
case PHY_RECEIVE_DELAY1:
{
phyParam.Value = 1000;
break;
}
case PHY_RECEIVE_DELAY2:
{
phyParam.Value = ( 1000 + 1000 );
break;
}
case PHY_JOIN_ACCEPT_DELAY1:
{
phyParam.Value = 5000;
break;
}
case PHY_JOIN_ACCEPT_DELAY2:
{
phyParam.Value = ( 5000 + 1000 );
break;
}
case PHY_MAX_FCNT_GAP:
{
phyParam.Value = 16384;
break;
}
case PHY_ACK_TIMEOUT:
{
phyParam.Value = ( 2000 + randr( -1000, 1000 ) );
break;
}
case PHY_DEF_DR1_OFFSET:
{
phyParam.Value = 0;
break;
}
case PHY_DEF_RX2_FREQUENCY:
{
phyParam.Value = 923200000 - 0;
break;
}
case PHY_DEF_RX2_DR:
{
phyParam.Value = 2;
break;
}
case PHY_CHANNELS_MASK:
{
phyParam.ChannelsMask = RegionNvmGroup2->ChannelsMask;
break;
}
case PHY_CHANNELS_DEFAULT_MASK:
{
phyParam.ChannelsMask = RegionNvmGroup2->ChannelsDefaultMask;
break;
}
case PHY_MAX_NB_CHANNELS:
{
phyParam.Value = 16;
break;
}
case PHY_CHANNELS:
{
phyParam.Channels = RegionNvmGroup2->Channels;
break;
}
case PHY_DEF_UPLINK_DWELL_TIME:
{
phyParam.Value = 1;
break;
}
case PHY_DEF_DOWNLINK_DWELL_TIME:
{
phyParam.Value = 0;
break;
}
case PHY_DEF_MAX_EIRP:
{
phyParam.fValue = 16.0f;
break;
}
case PHY_DEF_ANTENNA_GAIN:
{
phyParam.fValue = 2.15f;
break;
}
case PHY_BEACON_CHANNEL_FREQ:
{
phyParam.Value = 923400000 - 0;
break;
}
case PHY_BEACON_FORMAT:
{
phyParam.BeaconFormat.BeaconSize = 17;
phyParam.BeaconFormat.Rfu1Size = 2;
phyParam.BeaconFormat.Rfu2Size = 0;
break;
}
case PHY_BEACON_CHANNEL_DR:
{
phyParam.Value = 3;
break;
}
case PHY_PING_SLOT_CHANNEL_FREQ:
{
phyParam.Value = 923400000;
break;
}
case PHY_PING_SLOT_CHANNEL_DR:
{
phyParam.Value = 3;
break;
}
case PHY_SF_FROM_DR:
{
phyParam.Value = DataratesAS923[getPhy->Datarate];
break;
}
case PHY_BW_FROM_DR:
{
phyParam.Value = RegionCommonGetBandwidth( getPhy->Datarate, BandwidthsAS923 );
break;
}
default:
{
break;
}
}
return phyParam;
}
void RegionAS923SetBandTxDone( SetBandTxDoneParams_t* txDone )
{
RegionCommonSetBandTxDone( &RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txDone->Channel].Band],
txDone->LastTxAirTime, txDone->Joined, txDone->ElapsedTimeSinceStartUp );
}
void RegionAS923InitDefaults( InitDefaultsParams_t* params )
{
Band_t bands[1] =
{
{ 100, 0, 0, 0, 0, 0, 0 }
};
switch( params->Type )
{
case INIT_TYPE_DEFAULTS:
{
if( ( params->NvmGroup1 ==
# 377 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
((void *)0)
# 377 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
) || ( params->NvmGroup2 ==
# 377 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
((void *)0)
# 377 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
) )
{
return;
}
RegionNvmGroup1 = (RegionNvmDataGroup1_t*) params->NvmGroup1;
RegionNvmGroup2 = (RegionNvmDataGroup2_t*) params->NvmGroup2;
memcpy1( ( uint8_t* )RegionNvmGroup1->Bands, ( uint8_t* )bands, sizeof( Band_t ) * 1 );
RegionNvmGroup2->Channels[0] = ( ChannelParams_t ) { 923200000, 0, { ( ( 5 << 4 ) | 0 ) }, 0 };
RegionNvmGroup2->Channels[1] = ( ChannelParams_t ) { 923400000, 0, { ( ( 5 << 4 ) | 0 ) }, 0 };
RegionNvmGroup2->Channels[0].Frequency -= 0;
RegionNvmGroup2->Channels[1].Frequency -= 0;
RegionNvmGroup2->ChannelsDefaultMask[0] = ( uint16_t )( 1 << ( 1 - 1 ) ) + ( uint16_t )( 1 << ( 2 - 1 ) );
RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, 1 );
break;
}
case INIT_TYPE_RESET_TO_DEFAULT_CHANNELS:
{
RegionNvmGroup2->Channels[0].Rx1Frequency = 0;
RegionNvmGroup2->Channels[1].Rx1Frequency = 0;
RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, RegionNvmGroup2->ChannelsDefaultMask, 1 );
break;
}
case INIT_TYPE_ACTIVATE_DEFAULT_CHANNELS:
{
RegionNvmGroup2->ChannelsMask[0] |= RegionNvmGroup2->ChannelsDefaultMask[0];
break;
}
default:
{
break;
}
}
}
# 425 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 425 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
RegionAS923Verify( VerifyParams_t* verify, PhyAttribute_t phyAttribute )
{
switch( phyAttribute )
{
case PHY_FREQUENCY:
{
return VerifyRfFreq( verify->Frequency );
}
case PHY_TX_DR:
{
if( verify->DatarateParams.UplinkDwellTime == 0 )
{
return RegionCommonValueInRange( verify->DatarateParams.Datarate, 0, 7 );
}
else
{
return RegionCommonValueInRange( verify->DatarateParams.Datarate, 2, 7 );
}
}
case PHY_DEF_TX_DR:
{
return RegionCommonValueInRange( verify->DatarateParams.Datarate, 0, 5 );
}
case PHY_RX_DR:
{
if( verify->DatarateParams.DownlinkDwellTime == 0 )
{
return RegionCommonValueInRange( verify->DatarateParams.Datarate, 0, 7 );
}
else
{
return RegionCommonValueInRange( verify->DatarateParams.Datarate, 2, 7 );
}
}
case PHY_DEF_TX_POWER:
case PHY_TX_POWER:
{
return RegionCommonValueInRange( verify->TxPower, 0, 7 );
}
case PHY_DUTY_CYCLE:
{
return 0;
}
default:
return
# 470 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 470 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
}
void RegionAS923ApplyCFList( ApplyCFListParams_t* applyCFList )
{
ChannelParams_t newChannel;
ChannelAddParams_t channelAdd;
ChannelRemoveParams_t channelRemove;
newChannel.DrRange.Value = ( 5 << 4 ) | 0;
if( applyCFList->Size != 16 )
{
return;
}
if( applyCFList->Payload[15] != 0 )
{
return;
}
for( uint8_t i = 0, chanIdx = 2; chanIdx < 16; i+=3, chanIdx++ )
{
if( chanIdx < ( 5 + 2 ) )
{
newChannel.Frequency = (uint32_t) applyCFList->Payload[i];
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 1] << 8 );
newChannel.Frequency |= ( (uint32_t) applyCFList->Payload[i + 2] << 16 );
newChannel.Frequency *= 100;
newChannel.Rx1Frequency = 0;
}
else
{
newChannel.Frequency = 0;
newChannel.DrRange.Value = 0;
newChannel.Rx1Frequency = 0;
}
if( newChannel.Frequency != 0 )
{
channelAdd.NewChannel = &newChannel;
channelAdd.ChannelId = chanIdx;
RegionAS923ChannelAdd( &channelAdd );
}
else
{
channelRemove.ChannelId = chanIdx;
RegionAS923ChannelsRemove( &channelRemove );
}
}
}
# 533 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 533 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
RegionAS923ChanMaskSet( ChanMaskSetParams_t* chanMaskSet )
{
switch( chanMaskSet->ChannelsMaskType )
{
case CHANNELS_MASK:
{
RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsMask, chanMaskSet->ChannelsMaskIn, 1 );
break;
}
case CHANNELS_DEFAULT_MASK:
{
RegionCommonChanMaskCopy( RegionNvmGroup2->ChannelsDefaultMask, chanMaskSet->ChannelsMaskIn, 1 );
break;
}
default:
return
# 548 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 548 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
return
# 550 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 550 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
void RegionAS923ComputeRxWindowParameters( int8_t datarate, uint8_t minRxSymbols, uint32_t rxError, RxConfigParams_t *rxConfigParams )
{
uint32_t tSymbolInUs = 0;
rxConfigParams->Datarate = ( ( ( datarate ) < ( 7 ) ) ? ( datarate ) : ( 7 ) );
rxConfigParams->Bandwidth = RegionCommonGetBandwidth( rxConfigParams->Datarate, BandwidthsAS923 );
if( rxConfigParams->Datarate == 7 )
{
tSymbolInUs = RegionCommonComputeSymbolTimeFsk( DataratesAS923[rxConfigParams->Datarate] );
}
else
{
tSymbolInUs = RegionCommonComputeSymbolTimeLoRa( DataratesAS923[rxConfigParams->Datarate], BandwidthsAS923[rxConfigParams->Datarate] );
}
RegionCommonComputeRxWindowParameters( tSymbolInUs, minRxSymbols, rxError, Radio.GetWakeupTime( ), &rxConfigParams->WindowTimeout, &rxConfigParams->WindowOffset );
}
# 573 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 573 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
RegionAS923RxConfig( RxConfigParams_t* rxConfig, int8_t* datarate )
{
RadioModems_t modem;
int8_t dr = rxConfig->Datarate;
int8_t phyDr = 0;
uint32_t frequency = rxConfig->Frequency;
if( Radio.GetStatus( ) != RF_IDLE )
{
return
# 582 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 582 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
if( rxConfig->RxSlot == RX_SLOT_WIN_1 )
{
frequency = RegionNvmGroup2->Channels[rxConfig->Channel].Frequency;
if( RegionNvmGroup2->Channels[rxConfig->Channel].Rx1Frequency != 0 )
{
frequency = RegionNvmGroup2->Channels[rxConfig->Channel].Rx1Frequency;
}
}
phyDr = DataratesAS923[dr];
Radio.SetChannel( frequency );
if( dr == 7 )
{
modem = MODEM_FSK;
Radio.SetRxConfig( modem, 50000, phyDr * 1000, 0, 83333, 5, rxConfig->WindowTimeout,
# 605 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 605 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 0,
# 605 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 605 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 0, 0,
# 605 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 605 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, rxConfig->RxContinuous );
}
else
{
modem = MODEM_LORA;
Radio.SetRxConfig( modem, rxConfig->Bandwidth, phyDr, 1, 0, 8, rxConfig->WindowTimeout,
# 610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 0,
# 610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 0, 0,
# 610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 610 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, rxConfig->RxContinuous );
}
Radio.SetMaxPayloadLength( modem, MaxPayloadOfDatarateDwell0AS923[dr] + ( 1 + ( 4 + 1 + 2 ) + 1 + 4 ) );
*datarate = (uint8_t) dr;
return
# 616 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 616 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
# 619 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 619 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
RegionAS923TxConfig( TxConfigParams_t* txConfig, int8_t* txPower, UTIL_TIMER_Time_t* txTimeOnAir )
{
RadioModems_t modem;
int8_t phyDr = DataratesAS923[txConfig->Datarate];
int8_t txPowerLimited = RegionCommonLimitTxPower( txConfig->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[txConfig->Channel].Band].TxMaxPower );
uint32_t bandwidth = RegionCommonGetBandwidth( txConfig->Datarate, BandwidthsAS923 );
int8_t phyTxPower = 0;
phyTxPower = RegionCommonComputeTxPower( txPowerLimited, txConfig->MaxEirp, txConfig->AntennaGain );
Radio.SetChannel( RegionNvmGroup2->Channels[txConfig->Channel].Frequency );
if( txConfig->Datarate == 7 )
{
modem = MODEM_FSK;
Radio.SetTxConfig( modem, phyTxPower, 25000, bandwidth, phyDr * 1000, 0, 5,
# 636 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 636 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
,
# 636 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 636 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 0, 0,
# 636 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 636 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 4000 );
}
else
{
modem = MODEM_LORA;
Radio.SetTxConfig( modem, phyTxPower, 0, bandwidth, phyDr, 1, 8,
# 641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
,
# 641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 0, 0,
# 641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 641 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
, 4000 );
}
*txTimeOnAir = GetTimeOnAir( txConfig->Datarate, txConfig->PktLen );
Radio.SetMaxPayloadLength( modem, txConfig->PktLen );
*txPower = txPowerLimited;
return
# 651 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 651 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
uint8_t RegionAS923LinkAdrReq( LinkAdrReqParams_t* linkAdrReq, int8_t* drOut, int8_t* txPowOut, uint8_t* nbRepOut, uint8_t* nbBytesParsed )
{
uint8_t status = 0x07;
RegionCommonLinkAdrParams_t linkAdrParams = { 0 };
uint8_t nextIndex = 0;
uint8_t bytesProcessed = 0;
uint16_t chMask = 0;
GetPhyParams_t getPhy;
PhyParam_t phyParam;
RegionCommonLinkAdrReqVerifyParams_t linkAdrVerifyParams;
while( bytesProcessed < linkAdrReq->PayloadSize )
{
nextIndex = RegionCommonParseLinkAdrReq( &( linkAdrReq->Payload[bytesProcessed] ), &linkAdrParams );
if( nextIndex == 0 )
break;
bytesProcessed += nextIndex;
status = 0x07;
chMask = linkAdrParams.ChMask;
if( ( linkAdrParams.ChMaskCtrl == 0 ) && ( chMask == 0 ) )
{
status &= 0xFE;
}
else if( ( ( linkAdrParams.ChMaskCtrl >= 1 ) && ( linkAdrParams.ChMaskCtrl <= 5 )) ||
( linkAdrParams.ChMaskCtrl >= 7 ) )
{
status &= 0xFE;
}
else
{
for( uint8_t i = 0; i < 16; i++ )
{
if( linkAdrParams.ChMaskCtrl == 6 )
{
if( RegionNvmGroup2->Channels[i].Frequency != 0 )
{
chMask |= 1 << i;
}
}
else
{
if( ( ( chMask & ( 1 << i ) ) != 0 ) &&
( RegionNvmGroup2->Channels[i].Frequency == 0 ) )
{
status &= 0xFE;
}
}
}
}
}
getPhy.Attribute = PHY_MIN_TX_DR;
getPhy.UplinkDwellTime = linkAdrReq->UplinkDwellTime;
phyParam = RegionAS923GetPhyParam( &getPhy );
linkAdrVerifyParams.Status = status;
linkAdrVerifyParams.AdrEnabled = linkAdrReq->AdrEnabled;
linkAdrVerifyParams.Datarate = linkAdrParams.Datarate;
linkAdrVerifyParams.TxPower = linkAdrParams.TxPower;
linkAdrVerifyParams.NbRep = linkAdrParams.NbRep;
linkAdrVerifyParams.CurrentDatarate = linkAdrReq->CurrentDatarate;
linkAdrVerifyParams.CurrentTxPower = linkAdrReq->CurrentTxPower;
linkAdrVerifyParams.CurrentNbRep = linkAdrReq->CurrentNbRep;
linkAdrVerifyParams.NbChannels = 16;
linkAdrVerifyParams.ChannelsMask = &chMask;
linkAdrVerifyParams.MinDatarate = ( int8_t )phyParam.Value;
linkAdrVerifyParams.MaxDatarate = 7;
linkAdrVerifyParams.Channels = RegionNvmGroup2->Channels;
linkAdrVerifyParams.MinTxPower = 7;
linkAdrVerifyParams.MaxTxPower = 0;
linkAdrVerifyParams.Version = linkAdrReq->Version;
status = RegionCommonLinkAdrReqVerifyParams( &linkAdrVerifyParams, &linkAdrParams.Datarate, &linkAdrParams.TxPower, &linkAdrParams.NbRep );
if( status == 0x07 )
{
memset1( ( uint8_t* ) RegionNvmGroup2->ChannelsMask, 0, sizeof( RegionNvmGroup2->ChannelsMask ) );
RegionNvmGroup2->ChannelsMask[0] = chMask;
}
*drOut = linkAdrParams.Datarate;
*txPowOut = linkAdrParams.TxPower;
*nbRepOut = linkAdrParams.NbRep;
*nbBytesParsed = bytesProcessed;
return status;
}
uint8_t RegionAS923RxParamSetupReq( RxParamSetupReqParams_t* rxParamSetupReq )
{
uint8_t status = 0x07;
if( VerifyRfFreq( rxParamSetupReq->Frequency ) ==
# 764 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 764 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
status &= 0xFE;
}
if( RegionCommonValueInRange( rxParamSetupReq->Datarate, 0, 7 ) ==
# 770 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 770 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
status &= 0xFD;
}
if( RegionCommonValueInRange( rxParamSetupReq->DrOffset, 0, 7 ) ==
# 776 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 776 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
status &= 0xFB;
}
return status;
}
int8_t RegionAS923NewChannelReq( NewChannelReqParams_t* newChannelReq )
{
uint8_t status = 0x03;
ChannelAddParams_t channelAdd;
ChannelRemoveParams_t channelRemove;
if( newChannelReq->NewChannel->Frequency == 0 )
{
channelRemove.ChannelId = newChannelReq->ChannelId;
if( RegionAS923ChannelsRemove( &channelRemove ) ==
# 795 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 795 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
status &= 0xFC;
}
}
else
{
channelAdd.NewChannel = newChannelReq->NewChannel;
channelAdd.ChannelId = newChannelReq->ChannelId;
switch( RegionAS923ChannelAdd( &channelAdd ) )
{
case LORAMAC_STATUS_OK:
{
break;
}
case LORAMAC_STATUS_FREQUENCY_INVALID:
{
status &= 0xFE;
break;
}
case LORAMAC_STATUS_DATARATE_INVALID:
{
status &= 0xFD;
break;
}
case LORAMAC_STATUS_FREQ_AND_DR_INVALID:
{
status &= 0xFC;
break;
}
default:
{
status &= 0xFC;
break;
}
}
}
return status;
}
int8_t RegionAS923TxParamSetupReq( TxParamSetupReqParams_t* txParamSetupReq )
{
return 0;
}
int8_t RegionAS923DlChannelReq( DlChannelReqParams_t* dlChannelReq )
{
uint8_t status = 0x03;
if( VerifyRfFreq( dlChannelReq->Rx1Frequency ) ==
# 848 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 848 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
status &= 0xFE;
}
if( RegionNvmGroup2->Channels[dlChannelReq->ChannelId].Frequency == 0 )
{
status &= 0xFD;
}
if( status == 0x03 )
{
RegionNvmGroup2->Channels[dlChannelReq->ChannelId].Rx1Frequency = dlChannelReq->Rx1Frequency;
}
return status;
}
int8_t RegionAS923AlternateDr( int8_t currentDr, AlternateDrType_t type )
{
return 2;
}
LoRaMacStatus_t RegionAS923NextChannel( NextChanParams_t* nextChanParams, uint8_t* channel, UTIL_TIMER_Time_t* time, UTIL_TIMER_Time_t* aggregatedTimeOff )
{
uint8_t nbEnabledChannels = 0;
uint8_t nbRestrictedChannels = 0;
uint8_t enabledChannels[16] = { 0 };
RegionCommonIdentifyChannelsParam_t identifyChannelsParam;
RegionCommonCountNbOfEnabledChannelsParams_t countChannelsParams;
LoRaMacStatus_t status = LORAMAC_STATUS_NO_CHANNEL_FOUND;
uint16_t joinChannels = ( uint16_t )( ( uint16_t )( 1 << ( 1 - 1 ) ) | ( uint16_t )( 1 << ( 2 - 1 ) ) );
if( RegionCommonCountChannels( RegionNvmGroup2->ChannelsMask, 0, 1 ) == 0 )
{
RegionNvmGroup2->ChannelsMask[0] |= ( uint16_t )( 1 << ( 1 - 1 ) ) + ( uint16_t )( 1 << ( 2 - 1 ) );
}
countChannelsParams.Joined = nextChanParams->Joined;
countChannelsParams.Datarate = nextChanParams->Datarate;
countChannelsParams.ChannelsMask = RegionNvmGroup2->ChannelsMask;
countChannelsParams.Channels = RegionNvmGroup2->Channels;
countChannelsParams.Bands = RegionNvmGroup1->Bands;
countChannelsParams.MaxNbChannels = 16;
countChannelsParams.JoinChannels = &joinChannels;
identifyChannelsParam.AggrTimeOff = nextChanParams->AggrTimeOff;
identifyChannelsParam.LastAggrTx = nextChanParams->LastAggrTx;
identifyChannelsParam.DutyCycleEnabled = nextChanParams->DutyCycleEnabled;
identifyChannelsParam.MaxBands = 1;
identifyChannelsParam.ElapsedTimeSinceStartUp = nextChanParams->ElapsedTimeSinceStartUp;
identifyChannelsParam.LastTxIsJoinRequest = nextChanParams->LastTxIsJoinRequest;
identifyChannelsParam.ExpectedTimeOnAir = GetTimeOnAir( nextChanParams->Datarate, nextChanParams->PktLen );
identifyChannelsParam.CountNbOfEnabledChannelsParam = &countChannelsParams;
status = RegionCommonIdentifyChannels( &identifyChannelsParam, aggregatedTimeOff, enabledChannels,
&nbEnabledChannels, &nbRestrictedChannels, time );
if( status == LORAMAC_STATUS_OK )
{
# 937 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
*channel = enabledChannels[randr( 0, nbEnabledChannels - 1 )];
}
else if( status == LORAMAC_STATUS_NO_CHANNEL_FOUND )
{
RegionNvmGroup2->ChannelsMask[0] |= ( uint16_t )( 1 << ( 1 - 1 ) ) + ( uint16_t )( 1 << ( 2 - 1 ) );
}
return status;
}
LoRaMacStatus_t RegionAS923ChannelAdd( ChannelAddParams_t* channelAdd )
{
# 950 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 950 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
drInvalid =
# 950 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 950 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
# 951 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 951 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
freqInvalid =
# 951 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 951 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
uint8_t id = channelAdd->ChannelId;
if( id < 2 )
{
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
}
if( id >= 16 )
{
return LORAMAC_STATUS_PARAMETER_INVALID;
}
if( RegionCommonValueInRange( channelAdd->NewChannel->DrRange.Fields.Min, 0, 7 ) ==
# 965 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 965 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
drInvalid =
# 967 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 967 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
if( RegionCommonValueInRange( channelAdd->NewChannel->DrRange.Fields.Max, 0, 7 ) ==
# 969 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 969 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
drInvalid =
# 971 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 971 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
if( channelAdd->NewChannel->DrRange.Fields.Min > channelAdd->NewChannel->DrRange.Fields.Max )
{
drInvalid =
# 975 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 975 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
if( freqInvalid ==
# 979 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 979 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
if( VerifyRfFreq( channelAdd->NewChannel->Frequency ) ==
# 981 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 981 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
freqInvalid =
# 983 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 983 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
}
if( ( drInvalid ==
# 988 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 988 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
) && ( freqInvalid ==
# 988 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 988 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
) )
{
return LORAMAC_STATUS_FREQ_AND_DR_INVALID;
}
if( drInvalid ==
# 992 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 992 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
return LORAMAC_STATUS_DATARATE_INVALID;
}
if( freqInvalid ==
# 996 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
1
# 996 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
)
{
return LORAMAC_STATUS_FREQUENCY_INVALID;
}
memcpy1( ( uint8_t* ) &(RegionNvmGroup2->Channels[id]), ( uint8_t* ) channelAdd->NewChannel, sizeof( RegionNvmGroup2->Channels[id] ) );
RegionNvmGroup2->Channels[id].Band = 0;
RegionNvmGroup2->ChannelsMask[0] |= ( 1 << id );
return LORAMAC_STATUS_OK;
}
# 1007 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
_Bool
# 1007 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
RegionAS923ChannelsRemove( ChannelRemoveParams_t* channelRemove )
{
uint8_t id = channelRemove->ChannelId;
if( id < 2 )
{
return
# 1013 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c" 3 4
0
# 1013 "/home/jenkins/workspace/RUI_Release/rui-v3/external/lora/LoRaMac-node-4.4.7/src/mac/region/RegionAS923.c"
;
}
RegionNvmGroup2->Channels[id] = ( ChannelParams_t ){ 0, 0, { 0 }, 0 };
return RegionCommonChanDisable( RegionNvmGroup2->ChannelsMask, id, 16 );
}
void RegionAS923SetContinuousWave( ContinuousWaveParams_t* continuousWave )
{
int8_t txPowerLimited = RegionCommonLimitTxPower( continuousWave->TxPower, RegionNvmGroup1->Bands[RegionNvmGroup2->Channels[continuousWave->Channel].Band].TxMaxPower );
int8_t phyTxPower = 0;
uint32_t frequency = RegionNvmGroup2->Channels[continuousWave->Channel].Frequency;
phyTxPower = RegionCommonComputeTxPower( txPowerLimited, continuousWave->MaxEirp, continuousWave->AntennaGain );
Radio.SetTxContinuousWave( frequency, phyTxPower, continuousWave->Timeout );
}
uint8_t RegionAS923ApplyDrOffset( uint8_t downlinkDwellTime, int8_t dr, int8_t drOffset )
{
int8_t minDr = 0;
if( downlinkDwellTime == 1 )
{
minDr = 2;
}
return ( ( ( 5 ) < ( ( ( ( minDr ) > ( dr - EffectiveRx1DrOffsetAS923[drOffset] ) ) ? ( minDr ) : ( dr - EffectiveRx1DrOffsetAS923[drOffset] ) ) ) ) ? ( 5 ) : ( ( ( ( minDr ) > ( dr - EffectiveRx1DrOffsetAS923[drOffset] ) ) ? ( minDr ) : ( dr - EffectiveRx1DrOffsetAS923[drOffset] ) ) ) );
}
void RegionAS923RxBeaconSetup( RxBeaconSetup_t* rxBeaconSetup, uint8_t* outDr )
{
RegionCommonRxBeaconSetupParams_t regionCommonRxBeaconSetup;
regionCommonRxBeaconSetup.Datarates = DataratesAS923;
regionCommonRxBeaconSetup.Frequency = rxBeaconSetup->Frequency;
regionCommonRxBeaconSetup.BeaconSize = 17;
regionCommonRxBeaconSetup.BeaconDatarate = 3;
regionCommonRxBeaconSetup.BeaconChannelBW = 0;
regionCommonRxBeaconSetup.RxTime = rxBeaconSetup->RxTime;
regionCommonRxBeaconSetup.SymbolTimeout = rxBeaconSetup->SymbolTimeout;
RegionCommonRxBeaconSetup( ®ionCommonRxBeaconSetup );
*outDr = 3;
}
|
the_stack_data/29824358.c
|
// general protection fault in smc_getsockopt
// https://syzkaller.appspot.com/bug?id=6e5e224656a49e9167742ed797391bad751c812a
// status:fixed
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <endian.h>
#include <stdint.h>
#include <string.h>
#include <sys/syscall.h>
#include <unistd.h>
uint64_t r[1] = {0xffffffffffffffff};
void loop()
{
long res = 0;
res = syscall(__NR_socket, 0x2b, 1, 0);
if (res != -1)
r[0] = res;
syscall(__NR_listen, r[0], 2);
syscall(__NR_shutdown, r[0], 2);
*(uint32_t*)0x20000040 = 0xc;
syscall(__NR_getsockopt, r[0], 0, 8, 0x20000000, 0x20000040);
}
int main()
{
syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0);
loop();
return 0;
}
|
the_stack_data/515797.c
|
/* Liao, 5/14/2009
* A test case extracted from h264ref of the spec cpu 2006.
* */
typedef struct
{
unsigned int Elow;
} EncodingEnvironment;
typedef EncodingEnvironment *EncodingEnvironmentPtr;
#define Elow (eep->Elow)
void arienco_start_encoding(EncodingEnvironmentPtr eep)
{
Elow = 0;
}
|
the_stack_data/57951722.c
|
#include <stdio.h>
#include <stdlib.h>
typedef struct reg {
int conteudo;
struct reg *prox;
} celula;
void imprima (celula *le) {
celula *p;
for (p = le->prox; p != NULL; p = p->prox)
printf ("%d\n", p->conteudo);
}
int main() {
celula *le;
le = malloc (sizeof (celula));
le->prox = NULL;
le->conteudo;
printf ("%d\n", le->conteudo);
imprima(le);
return 0;
}
|
the_stack_data/83446.c
|
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
char name[100][23], phone[100][12];
int idx[100], r[100];
int cmp(const void *a, const void *b) {
int x = *(int *)a, y = *(int *)b;
int res = strcmp(name[x], name[y]);
if (res) return res;
return idx[x] - idx[y];
}
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%s %s", name[i], phone[i]);
bool f = false;
for (int j = 0; j < i; j++) {
if (strcmp(name[i], name[j]) == 0 && strcmp(phone[i], phone[j]) == 0) {
f = true;
break;
}
}
if (f) {
i--;
n--;
continue;
}
for (int j = i - 1; j >= 0; j--) {
if (strcmp(name[i], name[j]) == 0) {
idx[i] = idx[j] + 1;
break;
}
}
}
for (int i = 0; i < n; i++) r[i] = i;
qsort(r, n, sizeof(int), cmp);
for (int i = 0; i < n; i++) {
printf("%s", name[r[i]]);
if (idx[r[i]]) printf("_%d", idx[r[i]]);
printf(" %s\n", phone[r[i]]);
}
}
|
the_stack_data/425260.c
|
#include <stdio.h>
int main(void)
{
int number, day, month, year;
float price;
printf("Enter item number: ");
scanf_s("%d", &number);
printf("Enter unit price: ");
scanf_s("%f", &price);
printf("Enter purchase date (mm/dd/yyyy): ");
scanf_s("%d/%d/%d", &month, &day, &year);
printf("Item\tUnit\tPurchase\n\tPrice\tDate\n%d\t$%.1f\t%d%d%d",
number, price, month, day, year);
return 0;
}
|
the_stack_data/1132026.c
|
/* { dg-do compile } */
/* { dg-options "-O2 -mtune=generic" } */
char a[5];
int
func1 (void)
{
__builtin_memset (a,-1,sizeof (a));
return 0;
}
int a2[5];
int
func2 (void)
{
__builtin_memset (a2,-1,sizeof (a2));
return 0;
}
char a3[5];
int
func3 (void)
{
__builtin_memset (a3,0x8fffffff,sizeof (a3));
return 0;
}
char a4[5];
int
func4 (void)
{
__builtin_memset (a4,0x8fffff00,sizeof (a4));
return 0;
}
int a5[5];
int
func5 (void)
{
__builtin_memset (a5,0x8fffffff,sizeof (a5));
return 0;
}
/* { dg-final { scan-assembler-not "call\[\\t \]*_?memset" } } */
|
the_stack_data/665032.c
|
//Marcus Vinícius Souza Fernandes - 19.1.4046 - BCC201-61P
#include <stdio.h>
#include <stdlib.h>
void tresvalores(int *n1, int *n2, int *n3);
void sorteio(int *nmaleatorio1, int *nmaleatorio2, int *nmaleatorio3);
double valorpremio(int premio, int *n1, int *n2, int *n3, int *nmaleatorio1, int *nmaleatorio2, int *nmaleatorio3);
int main ()
{
int n1, n2, n3, nmaleatorio1, nmaleatorio2, nmaleatorio3, premio;
tresvalores(&n1, &n2, &n3);
sorteio(&nmaleatorio1, &nmaleatorio2, &nmaleatorio3);
valorpremio(premio, &n1, &n2, &n3, &nmaleatorio1, &nmaleatorio2, &nmaleatorio3);
return 0;
}
void tresvalores(int *n1, int *n2, int *n3)
{
printf("Insira 3 números de 0 a 30 por favor: ");
scanf("%d %d %d", n1, n2, n3);
}
void sorteio(int *nmaleatorio1, int *nmaleatorio2, int *nmaleatorio3)
{
*nmaleatorio1 = (rand()%30)+1;
*nmaleatorio2 = (rand()%30)+1;
*nmaleatorio3 = (rand()%30)+1;
}
double valorpremio(int premio, int *n1, int *n2, int *n3, int *nmaleatorio1, int *nmaleatorio2, int *nmaleatorio3)
{
premio=0;
if (nmaleatorio1 == n1 || nmaleatorio1 == n2 || nmaleatorio1 == n3)
{
premio=premio+1;
}
if (nmaleatorio2 == n1 || nmaleatorio2 == n2 || nmaleatorio2 == n3)
{
premio=premio+1;
}
if (nmaleatorio3 == n1 || nmaleatorio3 == n2 || nmaleatorio3 == n3)
{
premio=premio+1;
}
switch (premio) {
case 3:
printf("Seu prêmio é de R$100.000,00\n");
break;
case 2:
printf("Seu prêmio é de R$1.000,00\n");
break;
case 1:
printf("Seu prêmio é de R$1,00\n");
break;
case 0:
printf("Seu prêmio é de R$0,0\n");
break;
}
}
|
the_stack_data/73575895.c
|
/*
From: Matt Donadio <[email protected]>
Simon L. Peyton Jones writes:
> If anyone has a C version, or is better with floats than me, it would
> be delightful to either declare GHC2.04 correct, or fix the bug if there is
> one.
This is the FFT that I generally use. It's basically a direct
translation of the psuedocode from Cormen, Leiserson, and Rivest's
_Introduction_to_Algorithms_ (which is actually a lot better then the
examples I have seen in my DSP books). I also tested it a while ago
against the an IEEE test and saw no problems.
I'll try to take a look at the nofib results when I get home tonight,
but I think I only have ghc-2.03.
Matt Donadio <[email protected]>
Lockheed Martin Management & Data Systems
*/
/*
* $Id: fft.c,v 1.2 2001/05/27 17:37:59 sof Exp $
*
* $Log: fft.c,v $
* Revision 1.2 2001/05/27 17:37:59 sof
* basic mingw headers doesn't define M_PI; make fft.c cope
*
* Revision 1.1 1997/07/27 01:03:52 sof
* For reference, C version of FFT
*
* Revision 1.1 1996/10/24 15:41:00 donadio
* Initial revision
*
*/
static char RCSid[] = "$Id: fft.c,v 1.2 2001/05/27 17:37:59 sof Exp $";
/*
* fft() - a straightforward implementation of a decimation in time
* FFT algorithm. No fancy micro-twiddling of C code. Let
* the compiler do that for you.
*
* input - Pointer to the input vector.
* output - Pointer to where you want the output, ie this is not an
* in-place algorithm.
* n - The number of points in the input vector. Must be a power
* of two.
* dir - Direction : 1 = forward
* -1 = reverse
*
* See Cormen, Leiserson, and Rivest's _Introduction_to_Algorithms_,
* Chapter 32 for more details.
*
* If you need to speed this up, rewrite bit_reverse_copy() and try changing
* the local variables with complex type into two variables with double type
* Some uses of const may help, too. YMMV.
*
* Matt Donadio - [email protected]
*
*/
#include <math.h>
/* It's not there on mingw systems [05/01 - sof] */
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
typedef struct {
double r;
double i;
} complex;
static void bit_reverse_copy(complex *, complex *, int);
void fft(complex * input, complex * output, unsigned int n, int dir)
{
unsigned int s, j, k;
unsigned int lgn;
unsigned int m;
complex Wm, W;
complex t, u;
bit_reverse_copy(input, output, n);
for (lgn = 0; n >> lgn > 1; lgn++);
for (s = 1; s <= lgn; s++) {
m = 1 << s;
Wm.r = cos(2.0 * M_PI / (double) m);
Wm.i = sin(-dir * 2.0 * M_PI / (double) m);
W.r = 1.0;
W.i = 0.0;
for (j = 0; j <= m / 2 - 1; j++) {
for (k = j; k <= n - 1; k += m) {
t.r = W.r * (output + k + m / 2)->r - W.i * (output + k + m / 2)->i;
t.i = W.r * (output + k + m / 2)->i + W.i * (output + k + m / 2)->r;
u.r = (output + k)->r;
u.i = (output + k)->i;
(output + k)->r = u.r + t.r;
(output + k)->i = u.i + t.i;
(output + k + m / 2)->r = u.r - t.r;
(output + k + m / 2)->i = u.i - t.i;
}
t.r = W.r * Wm.r - W.i * Wm.i;
t.i = W.r * Wm.i + W.i * Wm.r;
W.r = t.r;
W.i = t.i;
}
}
if (dir == -1) {
for (j = 0; j < n; j++) {
(output + j)->r /= (double) n;
(output + j)->i /= (double) n;
}
}
}
/*
* this could probably be a lot better...
*/
static void bit_reverse_copy(complex * input, complex * output, int n)
{
unsigned int i, j, k;
int lgn;
for (lgn = 0; n >> lgn > 1; lgn++);
for (i = 0; i < n; i++) {
k = 0;
for (j = 0; j < lgn; j++) {
if ((i & (1 << j)) == (1 << j)) {
k += 1 << (lgn - 1 - j);
}
}
(output + i)->r = (input + k)->r;
(output + i)->i = (input + k)->i;
}
}
|
the_stack_data/62288.c
|
/* $NetBSD: doexec.c,v 1.8 2003/07/26 19:38:48 salo Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the
* NetBSD Project. See http://www.NetBSD.org/ for
* information about NetBSD.
* 4. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD: soc2013/dpl/head/tools/regression/execve/doexec.c 159140 2006-05-31 11:13:10Z maxim $
*/
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
int
main(argc, argv)
int argc;
char *argv[];
{
if (argc != 2) {
fprintf(stderr, "usage: %s <progname>\n", argv[0]);
exit(2);
}
unsetenv("LANG"); /* we compare C error strings */
if (execve(argv[1], &argv[1], NULL) == -1) {
printf("%s\n", strerror(errno));
exit(1);
}
}
|
the_stack_data/1052999.c
|
#include <stdio.h>
#include <stdlib.h>
//#define USE_MATH_DEFINES
#include <math.h>
#ifdef M_PI
#undef M_PI
#endif /*M_PI*/
//#define M_PI 3.14159265358979323846
#define M_PI 3.141592653589793238462643383279502884197169399375105820974944
// --------------------------------------------------------------
// muveletek komplex szamokkal
// komplex szamok reprezentalasahoz struktura
typedef float complex_elem_t;
typedef struct complex_t {
complex_elem_t re, im;
} complex;
// exponencialis alakbol felir egy komplex szamot
// r*e^j*phi
void complex_exp(float r, float phi, struct complex_t *out){
out->re = r * cos(phi);
out->im = r * sin(phi);
}
// ket komplex szam szorzata
void complex_mul(const complex *_a, const complex *_b, complex *out){
float a=_a->re, b=_a->im, c=_b->re, d=_b->im;
out->re = (a*c-b*d);
out->im = (a*d+b*c);
}
// athelyezzuk lokalis valtozokba arra az esetre, ha
// a kimenet valamelyik bemenettel egyezne
void complex_mul_by_c(const complex *_a, const complex_elem_t _b, complex *out){
float a=_a->re, b=_a->im;
out->re = _b*a;
out->im = _b*b;
}
// ket komplex szam osszege
void complex_add(const complex *_a, const complex *_b, complex *out){
float a=_a->re, b=_a->im, c=_b->re, d=_b->im;
out->re = a+c;
out->im = b+d;
}
// ket komplex szam kulonbsege
void complex_sub(const complex *_a, const complex *_b, complex *out){
float a=_a->re, b=_a->im, c=_b->re, d=_b->im;
out->re = a-c;
out->im = b-d;
}
// --------------------------------------------------------------
// Discrete Foutirer Transform
void DFT(const complex *in, const unsigned int len, complex *out){
int n=0, k=0;
struct complex_t dk, op;
float theta = 2*M_PI/(float)len, phi = 0.0;
if (!in) return;
if (!out) return;
for(k=0; k<len; k++){
dk.re = dk.im = 0.0;
for(n=0; n<len; n++){
op.im = op.re = 0.0;
phi = -theta*(float)k*(float)n; //printf("%3.2f; ", phi);
complex_exp(1., phi, &op);
complex_mul(&in[n], &op, &op);
complex_add(&op, &dk, &dk);
}
//complex_mul_by_c(&dk, 1/(float)(len+1), &dk);
out[k] = dk;
}
}
// --------------------------------------------------------------
// Fast Foutirer Transform
// csak 2^n darab mintaval mukodik
// http://www.katjaas.nl/FFTimplement/FFTimplement.html
// ezt kivagtam innen, mert nem kell.
// --------------------------------------------------------------
// cfft
// http://people.sc.fsu.edu/~jburkardt/c_src/fft_serial/fft_serial.c
/*
Author:
Original C version by Wesley Petersen.
This C version by John Burkardt.
*/
// --------------------------------------------------------------
// modositott
void fft_ccopy ( int n, complex *x, complex *y ){ int i; for (i=0; i<n; i++ ) y[i] = x[i]; }
// cfft init
void fft_cffti ( int n, complex *w){
complex_elem_t arg;
complex_elem_t aw;
int i, n2;
n2 = n / 2;
aw = 2.0 * M_PI / ( ( float ) n );
for ( i = 0; i < n2; i++ ){
arg = aw * ((float)i);
complex_exp(1., arg, &w[i]);
}
}
void fft_step ( int n, int mj, complex *a, complex *b, complex *c, complex *d, complex *w, complex_elem_t sgn){
complex amb;
complex wjw;
int j, ja, jb, jc, jd, jw, k, lj, mj2;
mj2 = 2 * mj;
lj = n / mj2;
for ( j = 0; j < lj; j++ ){
jw = j * mj; ja = jw; jb = ja; jc = j * mj2; jd = jc;
wjw = w[jw];
if ( sgn < 0.0 ) wjw.im = -wjw.im;
for ( k = 0; k < mj; k++ ){
complex_add(&a[ja+k], &b[jb+k], &c[jc+k]);
complex_sub(&a[ja+k], &b[jb+k], &amb);
complex_mul(&wjw, &amb, &d[jd+k]);
}
}
return;
}
// cfftv2
void fft_cfft2 ( int n, complex *x, complex *y, complex *w, complex_elem_t sgn ){
int j, m, mj;
int tgle;
m = (int) (log((float)n)/log(1.99));
mj = 1;
tgle = 1;
fft_step( n, mj, &x[0], &x[(n/2)], &y[0], &y[mj], w, sgn );
if ( n == 2 ) return;
for ( j = 0; j < m - 2; j++ ){
mj = mj * 2;
if ( tgle ) {
fft_step( n, mj, &y[0], &y[n/2], &x[0], &x[mj], w, sgn );
tgle = 0;
} else {
fft_step( n, mj, &x[0], &x[n/2], &y[0], &y[mj], w, sgn );
tgle = 1;
}
}
if ( tgle ) {
fft_ccopy ( n, y, x );
}
mj = n / 2;
fft_step(n, mj, &x[0], &x[n/2], &y[0], &y[mj], w, sgn);
return;
}
// --------------------------------------------------------------
// main
//float data[] = {0.f,1.f,2.f,3.f};
#define SIZEOF_ARRAY(x) (sizeof(x)/sizeof(*x))
int sampleTimes [] = {1,2,10};
int samples[] = {16, 32, 64, 128, 256};
int main(){
int datasize, datasizeMax, i = 0, n = 0, t = 0;
complex *src_dts, *Wn, *res_dft, *res_fft;
float theta, omega, samplingTime, aw, af;
//datasize = SIZEOF_ARRAY(data);
datasize = datasizeMax = 1<<8; //2^4
src_dts = (complex*)malloc(datasizeMax*sizeof(*src_dts));
Wn = (complex*)malloc((datasizeMax/2)*sizeof(*Wn));
//res_dft = (complex*)malloc(datasizeMax*sizeof(*res_dft));
res_fft = (complex*)malloc(datasizeMax*sizeof(*res_fft));
/////////////////////////////////////////////////////////
// 1.
datasize = 1<<6; // 2^6
omega = M_PI*.1f;
fft_cffti(datasize, Wn);
for (i=0; i<SIZEOF_ARRAY(sampleTimes); i++){
theta=omega*(float)sampleTimes[i];
for (n=0; n<datasize; n++){
src_dts[n].re = cos(theta*(float)n);
src_dts[n].im = 0.f;
}
fft_cfft2(datasize, src_dts, res_fft, Wn, -1.0f);
printf("N,f,omega,Re{D[N]},Im{D[N]},theta=%3.2f\n", theta);
for(n=0; n<datasize; n++){
//printf("D[%d] = %3.2f %c j*%3.2f \n", n, res_fft[n].re, (res_fft[n].im<0)?'-':'+', (res_fft[n].im<0)?-res_fft[n].im:res_fft[n].im);
af = .5* (float)(1+n) / (float)sampleTimes[i];
aw = 2.*M_PI * af;
printf("%d,%3.2f,%3.2f,%3.2f,%3.2f\n", n, af, aw, res_fft[n].re, res_fft[n].im);
}
}
/////////////////////////////////////////////////////////
// 2.
theta = omega;
for (i=0; i<SIZEOF_ARRAY(samples); i++){
datasize = samples[i];
for (n=0; n<datasize; n++){
src_dts[n].re = cos(theta*(float)n);
src_dts[n].im = 0.f;
}
fft_cffti(datasize, Wn);
fft_cfft2(datasize, src_dts, res_fft, Wn, -1.0f);
printf("N,omega,Re{D[N]},Im{D[N]},samples=%d\n", datasize);
for(n=0; n<datasize; n++){
//printf("D[%d] = %3.2f %c j*%3.2f \n", n, res_fft[n].re, (res_fft[n].im<0)?'-':'+', (res_fft[n].im<0)?-res_fft[n].im:res_fft[n].im);
af = .5* (float)(1+n) / (float)sampleTimes[i];
aw = 2.*M_PI * af;
printf("%d,%3.2f,%3.2f,%3.2f,%3.2f\n", n, af, aw, res_fft[n].re, res_fft[n].im);
}
}
free(Wn);
free(src_dts);
//free(res_dft);
free(res_fft);
return 0;
}
|
the_stack_data/63100.c
|
/* Exercise 1 - Calculations
Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */
#include <stdio.h>
int main() {
int marks1, marks2, total=0 ;
float average ;
printf("Enter marks for the Subject 1 : ");
scanf("%d",&marks1);
printf("Enter marks for the Subject 2 : ");
scanf("%d",&marks2);
total =marks1+marks2;
average=total/2;
printf("Average mark is %.2f",average);
return 0;
}
|
the_stack_data/977418.c
|
#include <stdio.h>
#include <time.h>
char* returnDate(char * buffer){
time_t rawtime;
struct tm * timeinfo;
time (&rawtime);
timeinfo = localtime(&rawtime);
strftime(buffer,80,"%d_%m_%Y", timeinfo);
return buffer;
}
|
the_stack_data/44646.c
|
// PARAM: --enable allfuns --set ana.activated "['base','threadid','threadflag','escape','mutex','mallocWrapper']"
int glob1 = 5;
int glob2 = 7;
int f() {
glob1 = 5;
return 0;
}
int g() {
assert(glob1 == 5);
assert(glob2 == 7);
return 0;
}
|
the_stack_data/161079554.c
|
#include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
int main(int argc, char **argv)
{
DIR *dir_p;
struct dirent *dirent_p;
if ((dir_p = opendir(".")) == NULL)
{
perror("opendir");
exit(-1);
}
while ((dirent_p = readdir(dir_p)) != NULL)
{
printf("%s\n", dirent_p->d_name);
}
closedir(dir_p);
return(0);
}
|
the_stack_data/181393896.c
|
/* Copyright 2018 SiFive, Inc */
/* SPDX-License-Identifier: Apache-2.0 */
int main() {
return 1;
}
|
the_stack_data/50138238.c
|
/**ARGS: source -DFOO1 -UFOO2 */
/**SYSCODE: = 2*/
#define FOO2
|
the_stack_data/15763132.c
|
#include <stdio.h>
#include <string.h>
#define NLEN 30
struct namect {
char fname[NLEN];
char lname[NLEN];
int letters;
};
void getinfo(struct namect *);
void makeinfo(struct namect *);
void showinfo(const struct namect *);
char * s_gets(char *, int);
int main(void)
{
struct namect person;
getinfo(&person);
makeinfo(&person);
showinfo(&person);
return 0;
}
void getinfo(struct namect * pst)
{
printf("Enter your first name: ");
s_gets(pst->fname, NLEN);
printf("Enter your last name: ");
s_gets(pst->lname, NLEN);
}
void makeinfo(struct namect * pst)
{
pst->letters = strlen(pst->fname) +
strlen(pst->lname);
}
void showinfo(const struct namect * pst)
{
printf("%s %s, your name contains %d letters.\n",
pst->fname, pst->lname, pst->letters);
}
char * s_gets(char * st, int n)
{
char *ret_val;
char *find;
ret_val = fgets(st, n, stdin);
if (ret_val)
{
find = strchr(st, '\n');
if (find)
*find = 0;
else
while (getchar() != '\n')
continue;
}
return ret_val;
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.