file
stringlengths 18
26
| data
stringlengths 2
1.05M
|
---|---|
the_stack_data/30225.c | #include <stdio.h>
int main()
{
float vetor[15];
int opcao, cont;
for (cont = 0; cont < 15; cont++)
{
printf("Digite a posicao %d: ", cont + 1);
scanf("%f", &vetor[cont]);
}
printf("\nDigite sua opcao [1 || 2]:");
scanf(" %d", &opcao);
if (opcao == 1)
{
for (cont = 0; cont < 15; cont++)
{
printf("%.1f ", vetor[cont]);
}
}
else if (opcao == 2)
{
for (cont = 15; 0 < cont; cont--)
{
printf("%.2f ", vetor[cont]);
}
}
else
{
printf("Opcao Invalida!");
}
return 0;
} |
the_stack_data/17563.c | #include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <string.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <math.h>
#define DOMAINE AF_INET
#define TYPE SOCK_DGRAM
#define PROTOCOL 0
#define BUFFER_TAILLE 1500
#define ALPHA 1.2 //Facteur arbitraire : timeout = alpha * srtt
#define ALPHASRTT 0.8
#define THRESHOLD 80 //passage de slow start à congestion avoidance
#define INITIAL_WINDOW 1
double what_time_is_it(){
//Return the time in microseconds
struct timespec now;
clock_gettime(CLOCK_REALTIME,&now);
return now.tv_sec*1000000 + 0.001*now.tv_nsec;
}
void delay(int number_of_microseconds)
{
// Storing start time
double start_time = what_time_is_it();
// looping till required time is not acheived
while (what_time_is_it() < start_time + number_of_microseconds)
;
}
int get_numSequence(char* buffer, char* buffer2){
//Récupération num séquence
memcpy(buffer2,buffer+3,6);
int beginWindow = atoi(buffer2);
return beginWindow;
}
int min(int a, int b){
if (a<b) return a;
else return b;
}
float minfloat(float a, float b){
if (a<b) return a;
else return b;
}
int max(int a, int b){
if (a>b) return a;
else return b;
}
int main(int argc, char *argv[])
{
//Arguments :
if (argc != 4)
{
printf("Bad usage : serveur <port_UDP_connexion> <premier_port_UDP_donnees> <nb_ports_données_disponibles>\n");
printf("argv[0] : %s\n",argv[0]);
return 0;
}
int nbPorts = atoi(argv[3]);
//Définition adresse UDP de connexion :
struct sockaddr_in adresseUDP; //Structure contenant addresse serveur
memset((char*)&adresseUDP,0,sizeof(adresseUDP));
adresseUDP.sin_family = DOMAINE;
adresseUDP.sin_port = htons(atoi(argv[1])); //Port du serveur, converti en valeur réseau
adresseUDP.sin_addr.s_addr = htonl(INADDR_ANY);
//Définition socket connexion udp
int socketServUDP;
if( (socketServUDP = socket(DOMAINE,TYPE,PROTOCOL)) == -1)
{
perror("Creation de socket impossible\n");
return -1;
}
printf("Descripteur UDP : %i\n",socketServUDP);
//Lien entre les deux :
bind(socketServUDP,(struct sockaddr*)&adresseUDP,sizeof(adresseUDP));
//Définition adresse UDP de data
struct sockaddr_in adresseUDP_data; //Structure contenant addresse serveur
memset((char*)&adresseUDP_data,0,sizeof(adresseUDP_data));
adresseUDP_data.sin_family = DOMAINE;
adresseUDP_data.sin_addr.s_addr = htonl(INADDR_ANY);
//Initialisation variable adresse client pour socket data
struct sockaddr_in adresse_data; //Structure contenant addresse client
memset((char*)&adresse_data,0,sizeof(adresse_data));
socklen_t taille_data = sizeof(adresse_data); //Taille de l'adresse client
char* ipClient_data;
int portClient_data;
//Ecoute (socket passif)
listen(socketServUDP,1);
//Initialisation variable adresse client pour socket connexion
struct sockaddr_in adresse_arrivee; //Structure contenant addresse client
memset((char*)&adresse_arrivee,0,sizeof(adresse_arrivee));
socklen_t taille_arrivee = sizeof(adresse_arrivee); //Taille de l'adresse client
char* ipClient;
int portClient;
FILE* fichier;
int filedescriptor;
char nomfichier[64];
int taillefichier;
int portIncrement = 0;
int online = 1;
int unreceived;
int problem;
char sendBuffer[BUFFER_TAILLE];
char recvBuffer[BUFFER_TAILLE];
char typeBuffer[7];
char strSequence[7];
int selret;
int portData;
double timer;
long int timeToWait = 2000; //en MICROSECONDES
double TempSRTT;
double srtt = 2000;
int measurement = 0; //valeur du paquet dont on mesure le RTT, 0 sinon aucune mesure en cours
//Définition de la window
//Window = espace entre beginWindow et endWindow
int beginWindow = 0; //Numéro de séquence partagé entre client et serveur
int endWindow = 0; //Numéro de séquence des messages envoyés / à envoyer
int nSent = 0; //Nombre de séquences envoyées dans la Boucle
int nReceived = 0; //Nombre de séquences reçues dans la boucle
//Controle de congestion
int windowSize = INITIAL_WINDOW; //S'incrémente avec slowstart et congestion avoidance
int ssthresh = THRESHOLD; //Valeur de passage de Slown Start à Congestion Avoidance
int nWrongAcks = 0; //Compteur de ACK "inappropriés"
int receivedAck = 0; //Ack reçu
int fastRetransmit = 0; //Booléen, 1 si mode fast retransmit
//Descripteur
fd_set socket_set;
FD_ZERO(&socket_set);
//timeoute
struct timeval timeout;
//La valeur du timeout sera renseignée après calcul du RTT
int id = getpid();
while(online) //Boucle de connexion
{
/*
FD_SET(socketServUDP, &socket_set); //Activation du bit associé à au socket UDP de CONNEXION
selret = select(5,&socket_set,NULL,NULL,NULL);
if (selret<0)
{
perror("Erreur de select");
return -1;
}
isInit = FD_ISSET(socketServUDP,&socket_set); //SI MESSAGE UDP
*/
if(id != 0){
//SERVEUR CONNEXION
delay(100000); //Délai afin de laisser au fils le temps de recevoir un ACK selon le cas de figure
recvfrom(socketServUDP, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_arrivee, &taille_arrivee);
if(strcmp(recvBuffer,"") != 0) printf("Reçu UDP (port serveur) : %s\n",recvBuffer);
//recuperation de l'adresse
ipClient = inet_ntoa(adresse_arrivee.sin_addr);
portClient = ntohs(adresse_arrivee.sin_port);
printf("Adresse = %s\n",ipClient);
printf("Port = %i\n",portClient);
//initialisation de connexion (reception SYN)
if(strcmp(recvBuffer, "SYN") == 0) {
//FORK : La suite doit être gérée par un autre processus
//Calcul valeur port
portIncrement = (portIncrement + 1);
if (portIncrement > nbPorts) portIncrement = 0;
portData = atoi(argv[2]) + portIncrement;
id = fork();
if(id<0)
{
perror("[!] Fork failed");
return -1;
}
printf("id : %i\n",id);
if (id == 0) //PRocessus fils :
{
printf("PortData : %i\n",portData);
//Création du socket data propre au processus fils
//Définition socket UDP de data
int socketServUDP_data;
if( (socketServUDP_data = socket(DOMAINE,TYPE,PROTOCOL)) == -1)
{
perror("Creation de socket impossible\n");
return -1;
}
printf("Descripteur UDP : %i\n",socketServUDP_data);
adresseUDP_data.sin_port = htons(portData); //Port du serveur, converti en valeur réseau
//Lien entre les deux :
bind(socketServUDP_data,(struct sockaddr*)&adresseUDP_data,sizeof(adresseUDP_data));
//Ecoute :
listen(socketServUDP_data,1);
//Envoi du SYNACK
unreceived = 1;
memset(sendBuffer, 0, sizeof(sendBuffer));
sprintf(sendBuffer,"SYN-ACK%i",portData);
while(unreceived){
printf("Send Synack.\n");
sendto(socketServUDP, sendBuffer, BUFFER_TAILLE, 0, (const struct sockaddr *) &adresse_arrivee, taille_arrivee);
//Message envoyé ! On initialise un timer pour estimer le RTT
//timer = clock();
//Attente pour le ACK
FD_SET(socketServUDP, &socket_set); //Activation du bit associé à au socket UDP de CONNEXION
timeout.tv_usec = timeToWait;
selret = select(5,&socket_set,NULL,NULL,&timeout);
if (selret<0)
{
perror("Erreur de select");
return -1;
}
else if ((selret != 0)) {
recvfrom(socketServUDP, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_arrivee, &taille_arrivee);
if(strcmp(recvBuffer,"ACK")==0) unreceived = 0;
}
}
//Ack bel et bien Reçu : on arrête le timer
//RoundTripTime = (double)(clock() - timer)/CLOCKS_PER_SEC;
//printf("RTT : %f\n",RoundTripTime);
//Choix de la valeur du timeout
//timeToWait = round(1000000 * RoundTripTime * ALPHA); //Facteur arbitraire, en microsecondes
//printf("Timeout (microseconds) : %f\n",timeToWait);
//timeout.tv_sec = 0;
//timeout.tv_usec = timeToWait; //Initialisation du timer (à répéter avant chaque select)
//PROCESSUS DE TRANSFERT DE FICHIER : fork
FD_CLR(socketServUDP, &socket_set); //Desactivation du bit associé à au socket UDP de CONNEXION
FD_SET(socketServUDP_data, &socket_set); //Activation du bit associé à au socket UDP de DATA
recvfrom(socketServUDP_data, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_data, &taille_data);
if(strcmp(recvBuffer,"") != 0) printf("Reçu UDP (port data) : %s\n",recvBuffer);
//recuperation de l'adresse
ipClient_data = inet_ntoa(adresse_data.sin_addr);
portClient_data = ntohs(adresse_data.sin_port);
printf("Adresse = %s\n",ipClient_data);
printf("Port = %i\n",portClient_data);
//beginWindow = rand()/10000;
beginWindow = 1;
endWindow = 1;
//verification qu'il ne s'agisse pas d'un ACK perdu
while (strstr(recvBuffer, "ACK") != NULL)
{
//SI ACK PERDU : RECEPTION A NOUVEAU
printf("[-] Lost Ack\n");
FD_CLR(socketServUDP, &socket_set); //Desactivation du bit associé à au socket UDP de CONNEXION
FD_SET(socketServUDP_data, &socket_set); //Activation du bit associé à au socket UDP de DATA
recvfrom(socketServUDP_data, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_data, &taille_data);
if(strcmp(recvBuffer,"") != 0) printf("Reçu UDP (port data) : %s\n",recvBuffer);
//recuperation de l'adresse
ipClient_data = inet_ntoa(adresse_data.sin_addr);
portClient_data = ntohs(adresse_data.sin_port);
printf("Adresse = %s\n",ipClient_data);
printf("Port = %i\n",portClient_data);
}
//récuperation nom de fichier
memcpy(nomfichier,recvBuffer,min(BUFFER_TAILLE,64));
//Ouverture fichier
fichier = fopen(nomfichier, "r");
printf("%s\n",nomfichier);
if (fichier==NULL)
{
printf("[!] File not found !\n");
//On enverra le contenu de "error.txt"
fichier = fopen("error.txt","r");
}
//lecture du fichier en UNE FOIS
//Récupération informations sur le fichier
struct stat carac;
filedescriptor = fileno(fichier);
fstat(filedescriptor, &carac);
taillefichier = carac.st_size;
//attribution espace fichier
printf("Taille du fichier : %i\n",taillefichier);
char* file=(char*)malloc(taillefichier+3); //Allocation d'un tableau comportant le contenu du fichier
if (file==0)
{
printf("Erreur d'allocation.\n");
return(-1);
}
else printf("Allocation réussie.\n");
printf("Taille file : %ld\n",sizeof(file));
fread(file,1,taillefichier,fichier); //lecture du fichier en une seule FOIS
printf("Copie réussie.\n");
fclose(fichier);
//taillefichier converti en nombre de segments à envoyer
int restefichier = taillefichier%(BUFFER_TAILLE - 6);
taillefichier = taillefichier/(BUFFER_TAILLE - 6) + 1;
printf("Nb de segments : %i\n",taillefichier);
//Boucle d'envoi du fichier
int i;
double timeBeginning = what_time_is_it();
windowSize = 1;
timeout.tv_sec = 0;
while(beginWindow <= taillefichier){
printf("\n");
//NewReno Fast Retransmit : on n'envoie QUE le paquet perdu.
if (fastRetransmit == 1){
endWindow = beginWindow;
printf("[!]FAST RETRANSMIT : only one segment.\n");
}
//Congestion Avoidance : on doit incrémenter windowSize à chaque RTT.
//On considère qu'une boucle ~ = un RTT.
else {
endWindow = beginWindow + windowSize;
if (windowSize >= ssthresh) windowSize++;
}
if (endWindow > taillefichier){
endWindow = taillefichier;
windowSize = endWindow - beginWindow + 1;
}
//Boucle de transmission
nSent = 0;
nReceived = 0;
for(int j = beginWindow; j<=endWindow; j++){
nSent++;
i = (BUFFER_TAILLE - 6) * (j-1); //segment de sequence n = début à la position n-1
//Construction du message
sprintf(typeBuffer,"000000"); //Base du numéro de séquence
sprintf(strSequence,"%i",j); //Numéro de séquence en str
char *ptr = typeBuffer + (6-strlen(strSequence)); //Pointeur du début d'écriture pour le numéro de séquence
memcpy(ptr,strSequence,strlen(strSequence)); //Ecriture au ponteur
printf("[0] Sending number %s\n",typeBuffer);
memset(sendBuffer, 0, sizeof(sendBuffer));
memset(recvBuffer, 0, sizeof(recvBuffer));
// sprintf(sendBuffer,"%s%s",typeBuffer,bloc); //formation du message à envoyer
//La ligne précédente utilise sprintf. Cela posera problème si l'on a un caractère \0 .
memcpy(sendBuffer,typeBuffer,6);
if (j == taillefichier) memcpy(sendBuffer+6,file+i,restefichier); //Si moins de BUFFER_TAILLE - 6 à envoyer
else memcpy(sendBuffer+6,file+i,BUFFER_TAILLE-6);
//Envoi du message
if ((!measurement)&&(j==endWindow)){ //On ne mesurera que le dernier paquet envoyé afin d'éviter des valeurs absurdes
timer = what_time_is_it();
measurement = j;
//printf("[i] Début de la mesure pour segment %i\n",j);
}
if (j == taillefichier) sendto(socketServUDP_data, sendBuffer, restefichier + 6, 0, (const struct sockaddr *) &adresse_data, taille_data);
else sendto(socketServUDP_data, sendBuffer, BUFFER_TAILLE, 0, (const struct sockaddr *) &adresse_data, taille_data);
//printf("[o] Sended : \n%s\n\n",sendBuffer);
//printf("%i\n",a);
}
//Boucle de réception
problem = 0;
while((!problem) && (nReceived < nSent) && ((beginWindow<=endWindow)||(fastRetransmit)||(beginWindow == taillefichier))){
FD_SET(socketServUDP_data, &socket_set); //Activation du bit associé à au socket UDP de DATA
timeout.tv_usec = timeToWait; //Initialisation du timer
//printf("timeout usec : %li\n",timeout.tv_usec);
//printf("timeout sec : %li\n",timeout.tv_sec);
selret = select(5,&socket_set,NULL,NULL,&timeout);
if (selret<0)
{
perror("[!] Select Error.\n");
return -1;
}
else if (selret == 0) { //TIMEOUT
//mise à jour du ssthresh
ssthresh = max(windowSize / 2, 2 * INITIAL_WINDOW);
windowSize = INITIAL_WINDOW;
problem = 1;
nWrongAcks = 0;
printf("[-] Timeout.\n");
fastRetransmit = 0;
//Augmentation du srtt avec les timeout
srtt = minfloat(1.1*srtt,30000);
}
else{
nReceived++;
//Vérification nature du message reçu
recvfrom(socketServUDP_data, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_data, &taille_data);
receivedAck = get_numSequence(recvBuffer,typeBuffer);
if(receivedAck == beginWindow -1 ) {
//Erreur : mauvais num sequence
//Si = au wrongack précédent, on ignore simplement
//Si < au beginWindow - 1 : on considère que c'est dû à la gigue / une erreur d'envoi,
//car en théorie un acquittement supérieur a déjà été envoyé.
nWrongAcks++;
if (nWrongAcks==3){
problem = 1;
//mise à jour du ssthresh
ssthresh = max(windowSize / 2, 2 * INITIAL_WINDOW);
windowSize = ssthresh; //FAST Recovery
printf("[-] 3 wrong acks.\n");
//printf("attendu (ou +) : %i\n",beginWindow);
//printf("reçu : %i\n",receivedAck);
//FAST RETRANSMIT MODE :
//On lit tous les messages à recevoir, et on compte tous les duplicated acks.
//NewReno fastRetransmit : on retransmet le paquet manquant et un paquet additionnel pour chaque duplicated ack.
//RFC 5681
timeout.tv_usec = 400; //Initialisation du timer
FD_SET(socketServUDP_data, &socket_set); //Activation du bit associé à au socket UDP de DATA
while(select(5,&socket_set,NULL,NULL,&timeout) != 0){ //Tant qu'il y a des messages à lire :
FD_SET(socketServUDP_data, &socket_set);
recvfrom(socketServUDP_data, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_data, &taille_data);
if (get_numSequence(recvBuffer,typeBuffer) < beginWindow) nWrongAcks++;
timeout.tv_usec = 400; //Initialisation du timer
}
//Incrémentation de windowsize
windowSize += nWrongAcks;
nWrongAcks = 0;
//Passage en mode fast retransmit pour l'émission.
fastRetransmit = 1;
}
else if(fastRetransmit == 1){
//SI erreur alors que fast RETRANSMIT : = TIMEOUT
//mise à jour du ssthresh
ssthresh = max(windowSize / 2, 2 * INITIAL_WINDOW);
windowSize = INITIAL_WINDOW;
problem = 1;
nWrongAcks = 0;
printf("[-] Timeout.\n");
fastRetransmit = 0;
//Augmentation du srtt avec les timeout
srtt = minfloat(1.1*srtt,30000);
timeToWait = (long int)(ALPHA*srtt);
}
}
else{
//message bien reçu et acknowlegded
printf("[+] Ack number %i received.\n",receivedAck);
nWrongAcks = 0;
beginWindow = receivedAck + 1;
//printf("numSequence du client : %i\n",beginWindow);
if ((windowSize<ssthresh)&&(!fastRetransmit)) windowSize++;
fastRetransmit = 0;
if (windowSize == ssthresh) printf("[+] Congestion Avoidance.\n");
if ((measurement < beginWindow)&&(measurement != 0)) { //Paquet mesuré reçu !
TempSRTT = (what_time_is_it() - timer);
srtt = ALPHASRTT*srtt + (1.0-ALPHASRTT)*TempSRTT;
timeToWait = (long int)(ALPHA*srtt);
//printf("[i] Fin de la mesure pour segment %i\n",measurement);
//printf("RTT : %f\n",TempSRTT);
printf("SRTT : %f\n",srtt);
//printf("timeout : %li\n",timeToWait);
measurement = 0;
}
}
}
}
//Fin de la boucle de réception : on a reçu tous les messages utiles // on a eu un problème synonyme de Congestion
//On jette tous les paquets qui arriveront / sont arrivés car il y a de fortes chances qu'ils soient incorrects.
timeout.tv_usec = 500; //Initialisation du timer
FD_SET(socketServUDP_data, &socket_set); //Activation du bit associé à au socket UDP de DATA
while(select(5,&socket_set,NULL,NULL,&timeout) != 0){ //Tant qu'il y a des messages à lire :
FD_SET(socketServUDP_data, &socket_set);
recvfrom(socketServUDP_data, recvBuffer, BUFFER_TAILLE, 0,(struct sockaddr*)&adresse_data, &taille_data);
timeout.tv_usec = 500; //Initialisation du timer
}
}
//Fin du fichier atteint : procédure end
printf("end of file\n");
//printf("timeToWait : %li\n",timeToWait);
printf("Size : %ld Bytes\n",carac.st_size);
double timeTaken = (what_time_is_it()-timeBeginning) / 1000000; //Car temps en microsecondes
printf("Time taken : %f\n",timeTaken);
printf("Rate (according to the program) : %f Bytes/s\n",((double)carac.st_size/timeTaken));
memset(sendBuffer, 0, sizeof(sendBuffer));
sprintf(sendBuffer,"FIN");
sendto(socketServUDP_data, sendBuffer, BUFFER_TAILLE, 0, (const struct sockaddr *) &adresse_data, taille_data);
free(file); // On libère l'espace attribué pour la lecture
close(socketServUDP_data);
online = 0; //Arrêt du serveur (fork)
}
}
}
}
printf("[!]END OF FORK\n");
return 0;
}
|
the_stack_data/138794.c | /*
* Copyright (C) 2018-2020 Alibaba Group Holding Limited
*/
#if defined(CONFIG_RESAMPLER_IPC) && CONFIG_RESAMPLER_IPC
#include "ipc.h"
#include <csi_core.h>
#include "avutil/mem_block.h"
#include "res_icore.h"
#include "icore/res_icore_internal.h"
#include "swresample/resample.h"
#define TAG "res_icore_ap"
#define RES_MB_SIZE_DEFAULT (1*1024)
struct res_icore {
uint32_t irate;
uint32_t orate;
uint8_t bits;
uint8_t channels;
void *r; // resx_t
void *priv; // priv only for ap/cpu0
};
struct res_icore_ap_priv {
mblock_t *in_mb;
mblock_t *out_mb;
};
static struct {
ipc_t *ipc;
int init;
} g_res_icore;
static int _ipc_cmd_send(icore_msg_t *data, int sync)
{
message_t msg;
memset(&msg, 0, sizeof(message_t));
msg.service_id = RES_ICORE_IPC_SERIVCE_ID;
msg.command = IPC_CMD_RES_ICORE;
msg.req_data = data;
msg.req_len = ICORE_MSG_SIZE + data->size;
msg.resp_data = data;
msg.resp_len = ICORE_MSG_SIZE + data->size;
msg.flag |= sync;
ipc_message_send(g_res_icore.ipc, &msg, AOS_WAIT_FOREVER);
return data->ret.code;
}
/**
* @brief new a resampler
* @param [in] irate : input sample rate
* @param [in] orate : output sample rate
* @param [in] channels : 1/2, mono/stereo, support mono now only
* @param [in] bits : 16 only
* @return NULL on error
*/
res_icore_t *res_icore_new(uint32_t irate, uint32_t orate, uint8_t channels, uint8_t bits)
{
int rc;
res_icore_t *hdl = NULL;
struct res_icore_ap_priv *priv = NULL;
mblock_t *in_mb = NULL, *out_mb = NULL;
icore_msg_t *msg_new = NULL;
res_icore_new_t *inp;
CHECK_PARAM(irate && orate && (channels == 1) && bits, NULL);
hdl = aos_zalloc(sizeof(res_icore_t));
CHECK_RET_TAG_WITH_RET(hdl, NULL);
in_mb = mblock_new(RES_MB_SIZE_DEFAULT, 16);
out_mb = mblock_new(RES_MB_SIZE_DEFAULT, 16);
CHECK_RET_TAG_WITH_GOTO(in_mb && out_mb, err);
msg_new = icore_msg_new(ICORE_CMD_RES_NEW, sizeof(res_icore_new_t));
CHECK_RET_TAG_WITH_GOTO(msg_new, err);
priv = aos_zalloc(sizeof(struct res_icore_ap_priv));
CHECK_RET_TAG_WITH_GOTO(priv, err);
inp = icore_get_msg(msg_new, res_icore_new_t);
inp->irate = irate;
inp->orate = orate;
inp->channels = channels;
inp->bits = bits;
rc = _ipc_cmd_send(msg_new, MESSAGE_SYNC);
CHECK_RET_TAG_WITH_GOTO(rc == 0, err);
priv->in_mb = in_mb;
priv->out_mb = out_mb;
hdl->irate = irate;
hdl->orate = orate;
hdl->channels = channels;
hdl->bits = bits;
hdl->r = inp->r;
hdl->priv = priv;
icore_msg_free(msg_new);
return hdl;
err:
mblock_free(in_mb);
mblock_free(out_mb);
icore_msg_free(msg_new);
aos_free(hdl);
aos_free(priv);
return NULL;
}
/**
* @brief get the max out samples number per channel
* @param [in] irate
* @param [in] orate
* @param [in] nb_isamples : number of input samples available in one channel
* @return -1 on error
*/
int res_icore_get_osamples_max(uint32_t irate, uint32_t orate, size_t nb_isamples)
{
return resx_get_osamples_max(irate, orate, nb_isamples);
}
/**
* @brief convert nb_samples from src to dst sample format
* @param [in] hdl
* @param [in] out
* @param [in] nb_osamples : amount of space available for output in samples per channel
* @param [in] in
* @param [in] nb_isamples : number of input samples available in one channel
* @return number of samples output per channel, -1 on error
*/
int res_icore_convert(res_icore_t *hdl, void **out, size_t nb_osamples, const void **in, size_t nb_isamples)
{
int i, rc = -1;
size_t isize, osize;
icore_msg_t *msg;
res_icore_convert_t *inp;
struct res_icore_ap_priv *priv;
CHECK_PARAM(hdl && in && out && nb_isamples && nb_osamples, -1);
for (i = 0; i < hdl->channels; i++) {
if (!(in[i] && out[i])) {
LOGE(TAG, "out/in params is err.");
return -1;
}
}
priv = hdl->priv;
msg = icore_msg_new(ICORE_CMD_RES_CONVERT, sizeof(res_icore_convert_t));
CHECK_RET_TAG_WITH_RET(msg, -1);
isize = nb_isamples * hdl->bits / 8;
rc = mblock_grow(priv->in_mb, ICORE_ALIGN_BUFZ(isize));
CHECK_RET_TAG_WITH_GOTO(rc == 0, err);
osize = nb_osamples * hdl->bits / 8;
rc = mblock_grow(priv->out_mb, ICORE_ALIGN_BUFZ(osize));
CHECK_RET_TAG_WITH_GOTO(rc == 0, err);
inp = icore_get_msg(msg, res_icore_convert_t);
inp->r = hdl->r;
inp->nb_isamples = nb_isamples;
inp->nb_osamples = nb_osamples;
inp->in = priv->in_mb->data;
inp->out = priv->out_mb->data;
memcpy((void*)inp->in, (const void*)in[0], isize);
csi_dcache_clean_invalid_range((uint32_t*)inp->in, isize);
rc = _ipc_cmd_send(msg, MESSAGE_SYNC);
if (rc > 0) {
osize = rc * hdl->bits / 8;
csi_dcache_invalid_range((uint32_t*)inp->out, osize);
memcpy((void*)out[0], (const void*)inp->out, osize);
}
icore_msg_free(msg);
return rc;
err:
icore_msg_free(msg);
return -1;
}
/**
* @brief free the rualizer
* @param [in] hdl
* @return 0/-1
*/
int res_icore_free(res_icore_t *hdl)
{
int rc = -1;
icore_msg_t *msg;
res_icore_free_t *inp;
struct res_icore_ap_priv *priv;
CHECK_PARAM(hdl, -1);
priv = hdl->priv;
msg = icore_msg_new(ICORE_CMD_RES_FREE, sizeof(res_icore_free_t));
CHECK_RET_TAG_WITH_RET(msg, -1);
inp = icore_get_msg(msg, res_icore_free_t);
inp->r = hdl->r;
rc = _ipc_cmd_send(msg, MESSAGE_SYNC);
icore_msg_free(msg);
mblock_free(priv->in_mb);
mblock_free(priv->out_mb);
aos_free(hdl->priv);
aos_free(hdl);
return rc;
}
/**
* @brief init the icore resample
* @return 0/-1
*/
int res_icore_init()
{
if (!g_res_icore.init) {
g_res_icore.ipc = ipc_get(RES_ICORE_CP_IDX);
CHECK_RET_TAG_WITH_RET(g_res_icore.ipc, -1);
ipc_add_service(g_res_icore.ipc, RES_ICORE_IPC_SERIVCE_ID, NULL, NULL);
g_res_icore.init = 1;
}
return g_res_icore.init ? 0 : -1;
}
#endif
|
the_stack_data/1088630.c | #include <stdio.h>
typedef struct node {
int value;
struct node *next;
} node;
int ll_has_cycle(node *head) {
/* your code here */
//create fast and slow pointers and initialize them
struct node * slow = head;
struct node * fast = head;
//run through the nodes and find the point of collision
while(fast && fast->next){ //not NULL
//slow moves 1 step, fast moves 2 steps
fast = fast->next->next;
slow = slow->next;
//check for collision
if(fast == slow){
//advance slow and head one step at a time until they meet
while(slow != head){
slow = slow->next;
head = head->next;
}
//slow and head have now both arrived at the beginning of the cycle
return head;
}
}
return NULL; //we're here because fast hits a Null pointer => no cycle, break out of while loop.
}
void test_ll_has_cycle(void) {
int i;
node nodes[25]; //enough to run our tests
for(i=0; i < sizeof(nodes)/sizeof(node); i++) {
nodes[i].next = 0;
nodes[i].value = 0;
}
nodes[0].next = &nodes[1];
nodes[1].next = &nodes[2];
nodes[2].next = &nodes[3];
printf("Checking first list for cycles. There should be none, ll_has_cycle says it has %s cycle\n", ll_has_cycle(&nodes[0])?"a":"no");
nodes[4].next = &nodes[5];
nodes[5].next = &nodes[6];
nodes[6].next = &nodes[7];
nodes[7].next = &nodes[8];
nodes[8].next = &nodes[9];
nodes[9].next = &nodes[10];
nodes[10].next = &nodes[4];
printf("Checking second list for cycles. There should be a cycle, ll_has_cycle says it has %s cycle\n", ll_has_cycle(&nodes[4])?"a":"no");
nodes[11].next = &nodes[12];
nodes[12].next = &nodes[13];
nodes[13].next = &nodes[14];
nodes[14].next = &nodes[15];
nodes[15].next = &nodes[16];
nodes[16].next = &nodes[17];
nodes[17].next = &nodes[14];
printf("Checking third list for cycles. There should be a cycle, ll_has_cycle says it has %s cycle\n", ll_has_cycle(&nodes[11])?"a":"no");
nodes[18].next = &nodes[18];
printf("Checking fourth list for cycles. There should be a cycle, ll_has_cycle says it has %s cycle\n", ll_has_cycle(&nodes[18])?"a":"no");
nodes[19].next = &nodes[20];
nodes[20].next = &nodes[21];
nodes[21].next = &nodes[22];
nodes[22].next = &nodes[23];
printf("Checking fifth list for cycles. There should be none, ll_has_cycle says it has %s cycle\n", ll_has_cycle(&nodes[19])?"a":"no");
printf("Checking length-zero list for cycles. There should be none, ll_has_cycle says it has %s cycle\n", ll_has_cycle(NULL)?"a":"no");
}
int main(void) {
test_ll_has_cycle();
return 0;
}
|
the_stack_data/757920.c | #include <setjmp.h>
#include <stdio.h>
jmp_buf mainTask, childTask;
void call_with_cushion(void);
void child(void);
int main(void) {
if (!setjmp(mainTask)) {
call_with_cushion(); /* child never returns */ /* yield */
} /* execution resumes after this "}" when child yields */
for (;;) {
printf("Parent\n");
if (!setjmp(mainTask)) {
longjmp(childTask, 1); /* yield - note that this is undefined under C99 */
}
}
}
void call_with_cushion (void) {
char space[1000]; /* Reserve enough space for main to run */
space[999] = 1; /* Do not optimize array out of existence */
child();
}
void child (void) {
for (;;) {
printf("Child loop begin\n");
if (!setjmp(childTask)) longjmp(mainTask, 1); /* yield - invalidates childTask in C99 */
printf("Child loop end\n");
if (!setjmp(childTask)) longjmp(mainTask, 1); /* yield - invalidates childTask in C99 */
}
/* Don't return. Instead we should set a flag to indicate that main()
should stop yielding to us and then longjmp(mainTask, 1) */
}
|
the_stack_data/32951267.c | /**
* File: pi.c
*
* Author:
* ID:
* Date:
*/
int main() {
return 0;
} |
the_stack_data/398080.c | #include <stdio.h>
void merge(int *a, int l, int m, int r);
void mergesort(int *a, int l, int r);
int main(){
int t=1;
int i, j, k, l;
int *n;
scanf("%d", &t);
n = (int *)malloc(t*sizeof(int));
for (i = 0; i < t; i++){
scanf("%d", n+i);
}
mergesort(n, 0, t - 1);
for (i = 0; i < t; i++){
printf("%d\n", *(n+i));
}
free(n);
return 0;
}
void merge(int *a, int l, int m, int r){
int i, j, k;
int len1 = m - l + 1;
int len2 = r - m;
int *a1;
a1 = (int *)malloc(len1*sizeof(int));
int *a2;
a2 = (int *)malloc(len2*sizeof(int));
for (i = 0; i < len1; i++){
*(a1 + i) = *(a+l + i);
}
for (i = 0; i < len2; i++){
*(a2 + i) = *(a+m + 1 + i);
}
i = 0;
j = 0;
k = l;
while (i < len1 && j < len2){
if (*(a1 + i) <= *(a2 + j)){
*(a + k) = *(a1 + i);
i++;
}
else{
*(a + k) = *(a2 + j);
j++;
}
k++;
}
while (i < len1){
*(a + k) = *(a1 + i);
i++;
k++;
}
while (j < len2){
*(a + k) = *(a2 + j);
j++;
k++;
}
free(a1);
free(a2);
}
void mergesort(int *a, int l, int r){
if (l < r){
int m = l + ((r-l) / 2);
mergesort(a, l, m);
mergesort(a, m + 1, r);
merge(a, l, m, r);
}
}
|
the_stack_data/611451.c | // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
// RUN: %clang_cc1 -no-opaque-pointers -triple riscv32 -target-feature +zksh -emit-llvm %s -o - \
// RUN: | FileCheck %s -check-prefix=RV32ZKSH
// RV32ZKSH-LABEL: @sm3p0(
// RV32ZKSH-NEXT: entry:
// RV32ZKSH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZKSH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZKSH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZKSH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sm3p0.i32(i32 [[TMP0]])
// RV32ZKSH-NEXT: ret i32 [[TMP1]]
//
long sm3p0(long rs1)
{
return __builtin_riscv_sm3p0(rs1);
}
// RV32ZKSH-LABEL: @sm3p1(
// RV32ZKSH-NEXT: entry:
// RV32ZKSH-NEXT: [[RS1_ADDR:%.*]] = alloca i32, align 4
// RV32ZKSH-NEXT: store i32 [[RS1:%.*]], i32* [[RS1_ADDR]], align 4
// RV32ZKSH-NEXT: [[TMP0:%.*]] = load i32, i32* [[RS1_ADDR]], align 4
// RV32ZKSH-NEXT: [[TMP1:%.*]] = call i32 @llvm.riscv.sm3p1.i32(i32 [[TMP0]])
// RV32ZKSH-NEXT: ret i32 [[TMP1]]
//
long sm3p1(long rs1) {
return __builtin_riscv_sm3p1(rs1);
}
|
the_stack_data/95450414.c | /* this should never actually get called, it is here so the real version in shd-interposer.c
* can properly intercept it.
*/
int interposer_setShadowIsLoaded(int isLoaded) {
return -1;
}
|
the_stack_data/451603.c | #include <stdlib.h>
int main(void) {
abort();
return 0;
} |
the_stack_data/1146445.c | /* Taxonomy Classification: 0000000000000062000100 */
/*
* WRITE/READ 0 write
* WHICH BOUND 0 upper
* DATA TYPE 0 char
* MEMORY LOCATION 0 stack
* SCOPE 0 same
* CONTAINER 0 no
* POINTER 0 no
* INDEX COMPLEXITY 0 constant
* ADDRESS COMPLEXITY 0 constant
* LENGTH COMPLEXITY 0 N/A
* ADDRESS ALIAS 0 none
* INDEX ALIAS 0 none
* LOCAL CONTROL FLOW 0 none
* SECONDARY CONTROL FLOW 0 none
* LOOP STRUCTURE 6 non-standard while
* LOOP COMPLEXITY 2 one
* ASYNCHRONY 0 no
* TAINT 0 no
* RUNTIME ENV. DEPENDENCE 0 no
* MAGNITUDE 1 1 byte
* CONTINUOUS/DISCRETE 0 discrete
* SIGNEDNESS 0 no
*/
/*
Copyright 2004 M.I.T.
Permission is hereby granted, without written agreement or royalty fee, to use,
copy, modify, and distribute this software and its documentation for any
purpose, provided that the above copyright notice and the following three
paragraphs appear in all copies of this software.
IN NO EVENT SHALL M.I.T. BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE
AND ITS DOCUMENTATION, EVEN IF M.I.T. HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMANGE.
M.I.T. SPECIFICALLY DISCLAIMS ANY WARRANTIES INCLUDING, BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
AND NON-INFRINGEMENT.
THE SOFTWARE IS PROVIDED ON AN "AS-IS" BASIS AND M.I.T. HAS NO OBLIGATION TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*/
int main(int argc, char *argv[])
{
int inc_value;
int loop_counter;
char buf[10];
inc_value = 10 - (10 - 1);
loop_counter = 0;
while((loop_counter += inc_value) && (loop_counter <= 10))
{
/* BAD */
buf[10] = 'A';
}
return 0;
}
|
the_stack_data/58867.c | // RUN: %clang_cc1 -fsyntax-only -verify -Wassign-enum %s
// rdar://11824807
typedef enum CCTestEnum
{
One,
Two=4,
Three
} CCTestEnum;
CCTestEnum test = 50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
CCTestEnum test1 = -50; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
CCTestEnum foo(CCTestEnum r) {
return 20; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
}
enum Test2 { K_zero, K_one };
enum Test2 test2(enum Test2 *t) {
*t = 20; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}}
return 10; // expected-warning {{integer constant not in range of enumerated type 'enum Test2'}}
}
// PR15069
typedef enum
{
a = 0
} T;
void f()
{
T x = a;
x += 1; // expected-warning {{integer constant not in range of enumerated type}}
}
int main() {
CCTestEnum test = 1; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
test = 600; // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
foo(2); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
foo(-1); // expected-warning {{integer constant not in range of enumerated type 'CCTestEnum'}}
foo(4);
foo(Two+1);
}
|
the_stack_data/479153.c | #include "stdio.h"
double aijn(double* a, double* b, int i, int j, int n, int m){
return (n == m) ? a[i*m+j] :
aijn(a, b, i, j, n+1, m) * aijn(a, b, n, n, n+1, m) -
aijn(a, b, i, n, n+1, m) * aijn(a, b, n, j, n+1, m);
}
double bin(double* a, double* b, int i, int n, int m){
return (n == m) ? b[i] :
aijn(a, b, n, n, n+1, m) * bin(a, b, i, n+1, m) -
aijn(a, b, i, n, n+1, m) * bin(a, b, n, n+1, m);
}
void solve_xi(double* a, double* b, double* x, int i, int m){
double d = bin(a, b, i, i+1, m);
for(int j = 0; j < i; ++j)
d-=aijn(a, b, i, j, i+1, m)*x[j];
x[i] = d / aijn(a, b, i, i, i+1, m);
}
void runtime_solve(double* a, double * b, double* x, int m){
for(int k = 0; k < m; ++k)
solve_xi(a, b, x, k, m);
}
int main() {
double sum_x[5] = {0., 0., 0., 0., 0.};
for(int i = 0; i < 1000000; ++i) {
double a[5*5] = {
6.80, -6.05, -0.45, 8.32, -9.67,
-2.11, -3.30, 2.58, 2.71, -5.14,
5.66, 5.36, -2.70, 4.35, -7.26,
5.97, -4.44, 0.27, -7.17, 6.08,
8.23, 1.08, 9.04, 2.14, -6.87
};
double b[5] = {
4.02, 6.19, -8.22, -7.57, -3.03,
};
double x[5];
runtime_solve(a, b, x, sizeof(x) / sizeof(x[0]));
for(int j = 0; j < 5; ++j){
sum_x[j] += x[j];
}
}
printf("%f, %f, %f, %f, %f\n", sum_x[0], sum_x[1], sum_x[2], sum_x[3], sum_x[4]);
}
|
the_stack_data/57871.c | /*
* Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#include <stdio.h>
#include <string.h>
#include <openssl/opensslconf.h>
#include <openssl/crypto.h>
#include <openssl/engine.h>
#include <openssl/evp.h>
#include <openssl/aes.h>
#include <openssl/rand.h>
#include <openssl/err.h>
#include <openssl/modes.h>
#ifndef OPENSSL_NO_HW
# ifndef OPENSSL_NO_HW_PADLOCK
/* Attempt to have a single source for both 0.9.7 and 0.9.8 :-) */
# if (OPENSSL_VERSION_NUMBER >= 0x00908000L)
# ifndef OPENSSL_NO_DYNAMIC_ENGINE
# define DYNAMIC_ENGINE
# endif
# elif (OPENSSL_VERSION_NUMBER >= 0x00907000L)
# ifdef ENGINE_DYNAMIC_SUPPORT
# define DYNAMIC_ENGINE
# endif
# else
# error "Only OpenSSL >= 0.9.7 is supported"
# endif
/*
* VIA PadLock AES is available *ONLY* on some x86 CPUs. Not only that it
* doesn't exist elsewhere, but it even can't be compiled on other platforms!
*/
# undef COMPILE_HW_PADLOCK
# if !defined(I386_ONLY) && defined(PADLOCK_ASM)
# define COMPILE_HW_PADLOCK
# ifdef OPENSSL_NO_DYNAMIC_ENGINE
static ENGINE *ENGINE_padlock(void);
# endif
# endif
# ifdef OPENSSL_NO_DYNAMIC_ENGINE
void engine_load_padlock_int(void);
void engine_load_padlock_int(void)
{
/* On non-x86 CPUs it just returns. */
# ifdef COMPILE_HW_PADLOCK
ENGINE *toadd = ENGINE_padlock();
if (!toadd)
return;
ENGINE_add(toadd);
ENGINE_free(toadd);
ERR_clear_error();
# endif
}
# endif
# ifdef COMPILE_HW_PADLOCK
/* Function for ENGINE detection and control */
static int padlock_available(void);
static int padlock_init(ENGINE *e);
/* RNG Stuff */
static RAND_METHOD padlock_rand;
/* Cipher Stuff */
static int padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher,
const int **nids, int nid);
/* Engine names */
static const char *padlock_id = "padlock";
static char padlock_name[100];
/* Available features */
static int padlock_use_ace = 0; /* Advanced Cryptography Engine */
static int padlock_use_rng = 0; /* Random Number Generator */
/* ===== Engine "management" functions ===== */
/* Prepare the ENGINE structure for registration */
static int padlock_bind_helper(ENGINE *e)
{
/* Check available features */
padlock_available();
/*
* RNG is currently disabled for reasons discussed in commentary just
* before padlock_rand_bytes function.
*/
padlock_use_rng = 0;
/* Generate a nice engine name with available features */
BIO_snprintf(padlock_name, sizeof(padlock_name),
"VIA PadLock (%s, %s)",
padlock_use_rng ? "RNG" : "no-RNG",
padlock_use_ace ? "ACE" : "no-ACE");
/* Register everything or return with an error */
if (!ENGINE_set_id(e, padlock_id) ||
!ENGINE_set_name(e, padlock_name) ||
!ENGINE_set_init_function(e, padlock_init) ||
(padlock_use_ace && !ENGINE_set_ciphers(e, padlock_ciphers)) ||
(padlock_use_rng && !ENGINE_set_RAND(e, &padlock_rand))) {
return 0;
}
/* Everything looks good */
return 1;
}
# ifdef OPENSSL_NO_DYNAMIC_ENGINE
/* Constructor */
static ENGINE *ENGINE_padlock(void)
{
ENGINE *eng = ENGINE_new();
if (eng == NULL) {
return NULL;
}
if (!padlock_bind_helper(eng)) {
ENGINE_free(eng);
return NULL;
}
return eng;
}
# endif
/* Check availability of the engine */
static int padlock_init(ENGINE *e)
{
return (padlock_use_rng || padlock_use_ace);
}
/*
* This stuff is needed if this ENGINE is being compiled into a
* self-contained shared-library.
*/
# ifdef DYNAMIC_ENGINE
static int padlock_bind_fn(ENGINE *e, const char *id)
{
if (id && (strcmp(id, padlock_id) != 0)) {
return 0;
}
if (!padlock_bind_helper(e)) {
return 0;
}
return 1;
}
IMPLEMENT_DYNAMIC_CHECK_FN()
IMPLEMENT_DYNAMIC_BIND_FN(padlock_bind_fn)
# endif /* DYNAMIC_ENGINE */
/* ===== Here comes the "real" engine ===== */
/* Some AES-related constants */
# define AES_BLOCK_SIZE 16
# define AES_KEY_SIZE_128 16
# define AES_KEY_SIZE_192 24
# define AES_KEY_SIZE_256 32
/*
* Here we store the status information relevant to the current context.
*/
/*
* BIG FAT WARNING: Inline assembler in PADLOCK_XCRYPT_ASM() depends on
* the order of items in this structure. Don't blindly modify, reorder,
* etc!
*/
struct padlock_cipher_data {
unsigned char iv[AES_BLOCK_SIZE]; /* Initialization vector */
union {
unsigned int pad[4];
struct {
int rounds:4;
int dgst:1; /* n/a in C3 */
int align:1; /* n/a in C3 */
int ciphr:1; /* n/a in C3 */
unsigned int keygen:1;
int interm:1;
unsigned int encdec:1;
int ksize:2;
} b;
} cword; /* Control word */
AES_KEY ks; /* Encryption key */
};
/* Interface to assembler module */
unsigned int padlock_capability(void);
void padlock_key_bswap(AES_KEY *key);
void padlock_verify_context(struct padlock_cipher_data *ctx);
void padlock_reload_key(void);
void padlock_aes_block(void *out, const void *inp,
struct padlock_cipher_data *ctx);
int padlock_ecb_encrypt(void *out, const void *inp,
struct padlock_cipher_data *ctx, size_t len);
int padlock_cbc_encrypt(void *out, const void *inp,
struct padlock_cipher_data *ctx, size_t len);
int padlock_cfb_encrypt(void *out, const void *inp,
struct padlock_cipher_data *ctx, size_t len);
int padlock_ofb_encrypt(void *out, const void *inp,
struct padlock_cipher_data *ctx, size_t len);
int padlock_ctr32_encrypt(void *out, const void *inp,
struct padlock_cipher_data *ctx, size_t len);
int padlock_xstore(void *out, int edx);
void padlock_sha1_oneshot(void *ctx, const void *inp, size_t len);
void padlock_sha1(void *ctx, const void *inp, size_t len);
void padlock_sha256_oneshot(void *ctx, const void *inp, size_t len);
void padlock_sha256(void *ctx, const void *inp, size_t len);
/*
* Load supported features of the CPU to see if the PadLock is available.
*/
static int padlock_available(void)
{
unsigned int edx = padlock_capability();
/* Fill up some flags */
padlock_use_ace = ((edx & (0x3 << 6)) == (0x3 << 6));
padlock_use_rng = ((edx & (0x3 << 2)) == (0x3 << 2));
return padlock_use_ace + padlock_use_rng;
}
/* ===== AES encryption/decryption ===== */
# if defined(NID_aes_128_cfb128) && ! defined (NID_aes_128_cfb)
# define NID_aes_128_cfb NID_aes_128_cfb128
# endif
# if defined(NID_aes_128_ofb128) && ! defined (NID_aes_128_ofb)
# define NID_aes_128_ofb NID_aes_128_ofb128
# endif
# if defined(NID_aes_192_cfb128) && ! defined (NID_aes_192_cfb)
# define NID_aes_192_cfb NID_aes_192_cfb128
# endif
# if defined(NID_aes_192_ofb128) && ! defined (NID_aes_192_ofb)
# define NID_aes_192_ofb NID_aes_192_ofb128
# endif
# if defined(NID_aes_256_cfb128) && ! defined (NID_aes_256_cfb)
# define NID_aes_256_cfb NID_aes_256_cfb128
# endif
# if defined(NID_aes_256_ofb128) && ! defined (NID_aes_256_ofb)
# define NID_aes_256_ofb NID_aes_256_ofb128
# endif
/* List of supported ciphers. */
static const int padlock_cipher_nids[] = {
NID_aes_128_ecb,
NID_aes_128_cbc,
NID_aes_128_cfb,
NID_aes_128_ofb,
NID_aes_128_ctr,
NID_aes_192_ecb,
NID_aes_192_cbc,
NID_aes_192_cfb,
NID_aes_192_ofb,
NID_aes_192_ctr,
NID_aes_256_ecb,
NID_aes_256_cbc,
NID_aes_256_cfb,
NID_aes_256_ofb,
NID_aes_256_ctr
};
static int padlock_cipher_nids_num = (sizeof(padlock_cipher_nids) /
sizeof(padlock_cipher_nids[0]));
/* Function prototypes ... */
static int padlock_aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc);
# define NEAREST_ALIGNED(ptr) ( (unsigned char *)(ptr) + \
( (0x10 - ((size_t)(ptr) & 0x0F)) & 0x0F ) )
# define ALIGNED_CIPHER_DATA(ctx) ((struct padlock_cipher_data *)\
NEAREST_ALIGNED(EVP_CIPHER_CTX_get_cipher_data(ctx)))
static int
padlock_ecb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
const unsigned char *in_arg, size_t nbytes)
{
return padlock_ecb_encrypt(out_arg, in_arg,
ALIGNED_CIPHER_DATA(ctx), nbytes);
}
static int
padlock_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
const unsigned char *in_arg, size_t nbytes)
{
struct padlock_cipher_data *cdata = ALIGNED_CIPHER_DATA(ctx);
int ret;
memcpy(cdata->iv, EVP_CIPHER_CTX_iv(ctx), AES_BLOCK_SIZE);
if ((ret = padlock_cbc_encrypt(out_arg, in_arg, cdata, nbytes)))
memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), cdata->iv, AES_BLOCK_SIZE);
return ret;
}
static int
padlock_cfb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
const unsigned char *in_arg, size_t nbytes)
{
struct padlock_cipher_data *cdata = ALIGNED_CIPHER_DATA(ctx);
size_t chunk;
if ((chunk = EVP_CIPHER_CTX_num(ctx))) { /* borrow chunk variable */
unsigned char *ivp = EVP_CIPHER_CTX_iv_noconst(ctx);
if (chunk >= AES_BLOCK_SIZE)
return 0; /* bogus value */
if (EVP_CIPHER_CTX_encrypting(ctx))
while (chunk < AES_BLOCK_SIZE && nbytes != 0) {
ivp[chunk] = *(out_arg++) = *(in_arg++) ^ ivp[chunk];
chunk++, nbytes--;
} else
while (chunk < AES_BLOCK_SIZE && nbytes != 0) {
unsigned char c = *(in_arg++);
*(out_arg++) = c ^ ivp[chunk];
ivp[chunk++] = c, nbytes--;
}
EVP_CIPHER_CTX_set_num(ctx, chunk % AES_BLOCK_SIZE);
}
if (nbytes == 0)
return 1;
memcpy(cdata->iv, EVP_CIPHER_CTX_iv(ctx), AES_BLOCK_SIZE);
if ((chunk = nbytes & ~(AES_BLOCK_SIZE - 1))) {
if (!padlock_cfb_encrypt(out_arg, in_arg, cdata, chunk))
return 0;
nbytes -= chunk;
}
if (nbytes) {
unsigned char *ivp = cdata->iv;
out_arg += chunk;
in_arg += chunk;
EVP_CIPHER_CTX_set_num(ctx, nbytes);
if (cdata->cword.b.encdec) {
cdata->cword.b.encdec = 0;
padlock_reload_key();
padlock_aes_block(ivp, ivp, cdata);
cdata->cword.b.encdec = 1;
padlock_reload_key();
while (nbytes) {
unsigned char c = *(in_arg++);
*(out_arg++) = c ^ *ivp;
*(ivp++) = c, nbytes--;
}
} else {
padlock_reload_key();
padlock_aes_block(ivp, ivp, cdata);
padlock_reload_key();
while (nbytes) {
*ivp = *(out_arg++) = *(in_arg++) ^ *ivp;
ivp++, nbytes--;
}
}
}
memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), cdata->iv, AES_BLOCK_SIZE);
return 1;
}
static int
padlock_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
const unsigned char *in_arg, size_t nbytes)
{
struct padlock_cipher_data *cdata = ALIGNED_CIPHER_DATA(ctx);
size_t chunk;
/*
* ctx->num is maintained in byte-oriented modes, such as CFB and OFB...
*/
if ((chunk = EVP_CIPHER_CTX_num(ctx))) { /* borrow chunk variable */
unsigned char *ivp = EVP_CIPHER_CTX_iv_noconst(ctx);
if (chunk >= AES_BLOCK_SIZE)
return 0; /* bogus value */
while (chunk < AES_BLOCK_SIZE && nbytes != 0) {
*(out_arg++) = *(in_arg++) ^ ivp[chunk];
chunk++, nbytes--;
}
EVP_CIPHER_CTX_set_num(ctx, chunk % AES_BLOCK_SIZE);
}
if (nbytes == 0)
return 1;
memcpy(cdata->iv, EVP_CIPHER_CTX_iv(ctx), AES_BLOCK_SIZE);
if ((chunk = nbytes & ~(AES_BLOCK_SIZE - 1))) {
if (!padlock_ofb_encrypt(out_arg, in_arg, cdata, chunk))
return 0;
nbytes -= chunk;
}
if (nbytes) {
unsigned char *ivp = cdata->iv;
out_arg += chunk;
in_arg += chunk;
EVP_CIPHER_CTX_set_num(ctx, nbytes);
padlock_reload_key(); /* empirically found */
padlock_aes_block(ivp, ivp, cdata);
padlock_reload_key(); /* empirically found */
while (nbytes) {
*(out_arg++) = *(in_arg++) ^ *ivp;
ivp++, nbytes--;
}
}
memcpy(EVP_CIPHER_CTX_iv_noconst(ctx), cdata->iv, AES_BLOCK_SIZE);
return 1;
}
static void padlock_ctr32_encrypt_glue(const unsigned char *in,
unsigned char *out, size_t blocks,
struct padlock_cipher_data *ctx,
const unsigned char *ivec)
{
memcpy(ctx->iv, ivec, AES_BLOCK_SIZE);
padlock_ctr32_encrypt(out, in, ctx, AES_BLOCK_SIZE * blocks);
}
static int
padlock_ctr_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out_arg,
const unsigned char *in_arg, size_t nbytes)
{
struct padlock_cipher_data *cdata = ALIGNED_CIPHER_DATA(ctx);
unsigned int num = EVP_CIPHER_CTX_num(ctx);
CRYPTO_ctr128_encrypt_ctr32(in_arg, out_arg, nbytes,
cdata, EVP_CIPHER_CTX_iv_noconst(ctx),
EVP_CIPHER_CTX_buf_noconst(ctx), &num,
(ctr128_f) padlock_ctr32_encrypt_glue);
EVP_CIPHER_CTX_set_num(ctx, (size_t)num);
return 1;
}
# define EVP_CIPHER_block_size_ECB AES_BLOCK_SIZE
# define EVP_CIPHER_block_size_CBC AES_BLOCK_SIZE
# define EVP_CIPHER_block_size_OFB 1
# define EVP_CIPHER_block_size_CFB 1
# define EVP_CIPHER_block_size_CTR 1
/*
* Declaring so many ciphers by hand would be a pain. Instead introduce a bit
* of preprocessor magic :-)
*/
# define DECLARE_AES_EVP(ksize,lmode,umode) \
static EVP_CIPHER *_hidden_aes_##ksize##_##lmode = NULL; \
static const EVP_CIPHER *padlock_aes_##ksize##_##lmode(void) \
{ \
if (_hidden_aes_##ksize##_##lmode == NULL \
&& ((_hidden_aes_##ksize##_##lmode = \
EVP_CIPHER_meth_new(NID_aes_##ksize##_##lmode, \
EVP_CIPHER_block_size_##umode, \
AES_KEY_SIZE_##ksize)) == NULL \
|| !EVP_CIPHER_meth_set_iv_length(_hidden_aes_##ksize##_##lmode, \
AES_BLOCK_SIZE) \
|| !EVP_CIPHER_meth_set_flags(_hidden_aes_##ksize##_##lmode, \
0 | EVP_CIPH_##umode##_MODE) \
|| !EVP_CIPHER_meth_set_init(_hidden_aes_##ksize##_##lmode, \
padlock_aes_init_key) \
|| !EVP_CIPHER_meth_set_do_cipher(_hidden_aes_##ksize##_##lmode, \
padlock_##lmode##_cipher) \
|| !EVP_CIPHER_meth_set_impl_ctx_size(_hidden_aes_##ksize##_##lmode, \
sizeof(struct padlock_cipher_data) + 16) \
|| !EVP_CIPHER_meth_set_set_asn1_params(_hidden_aes_##ksize##_##lmode, \
EVP_CIPHER_set_asn1_iv) \
|| !EVP_CIPHER_meth_set_get_asn1_params(_hidden_aes_##ksize##_##lmode, \
EVP_CIPHER_get_asn1_iv))) { \
EVP_CIPHER_meth_free(_hidden_aes_##ksize##_##lmode); \
_hidden_aes_##ksize##_##lmode = NULL; \
} \
return _hidden_aes_##ksize##_##lmode; \
}
DECLARE_AES_EVP(128, ecb, ECB)
DECLARE_AES_EVP(128, cbc, CBC)
DECLARE_AES_EVP(128, cfb, CFB)
DECLARE_AES_EVP(128, ofb, OFB)
DECLARE_AES_EVP(128, ctr, CTR)
DECLARE_AES_EVP(192, ecb, ECB)
DECLARE_AES_EVP(192, cbc, CBC)
DECLARE_AES_EVP(192, cfb, CFB)
DECLARE_AES_EVP(192, ofb, OFB)
DECLARE_AES_EVP(192, ctr, CTR)
DECLARE_AES_EVP(256, ecb, ECB)
DECLARE_AES_EVP(256, cbc, CBC)
DECLARE_AES_EVP(256, cfb, CFB)
DECLARE_AES_EVP(256, ofb, OFB)
DECLARE_AES_EVP(256, ctr, CTR)
static int
padlock_ciphers(ENGINE *e, const EVP_CIPHER **cipher, const int **nids,
int nid)
{
/* No specific cipher => return a list of supported nids ... */
if (!cipher) {
*nids = padlock_cipher_nids;
return padlock_cipher_nids_num;
}
/* ... or the requested "cipher" otherwise */
switch (nid) {
case NID_aes_128_ecb:
*cipher = padlock_aes_128_ecb();
break;
case NID_aes_128_cbc:
*cipher = padlock_aes_128_cbc();
break;
case NID_aes_128_cfb:
*cipher = padlock_aes_128_cfb();
break;
case NID_aes_128_ofb:
*cipher = padlock_aes_128_ofb();
break;
case NID_aes_128_ctr:
*cipher = padlock_aes_128_ctr();
break;
case NID_aes_192_ecb:
*cipher = padlock_aes_192_ecb();
break;
case NID_aes_192_cbc:
*cipher = padlock_aes_192_cbc();
break;
case NID_aes_192_cfb:
*cipher = padlock_aes_192_cfb();
break;
case NID_aes_192_ofb:
*cipher = padlock_aes_192_ofb();
break;
case NID_aes_192_ctr:
*cipher = padlock_aes_192_ctr();
break;
case NID_aes_256_ecb:
*cipher = padlock_aes_256_ecb();
break;
case NID_aes_256_cbc:
*cipher = padlock_aes_256_cbc();
break;
case NID_aes_256_cfb:
*cipher = padlock_aes_256_cfb();
break;
case NID_aes_256_ofb:
*cipher = padlock_aes_256_ofb();
break;
case NID_aes_256_ctr:
*cipher = padlock_aes_256_ctr();
break;
default:
/* Sorry, we don't support this NID */
*cipher = NULL;
return 0;
}
return 1;
}
/* Prepare the encryption key for PadLock usage */
static int
padlock_aes_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
struct padlock_cipher_data *cdata;
int key_len = EVP_CIPHER_CTX_key_length(ctx) * 8;
unsigned long mode = EVP_CIPHER_CTX_mode(ctx);
if (key == NULL)
return 0; /* ERROR */
cdata = ALIGNED_CIPHER_DATA(ctx);
memset(cdata, 0, sizeof(*cdata));
/* Prepare Control word. */
if (mode == EVP_CIPH_OFB_MODE || mode == EVP_CIPH_CTR_MODE)
cdata->cword.b.encdec = 0;
else
cdata->cword.b.encdec = (EVP_CIPHER_CTX_encrypting(ctx) == 0);
cdata->cword.b.rounds = 10 + (key_len - 128) / 32;
cdata->cword.b.ksize = (key_len - 128) / 64;
switch (key_len) {
case 128:
/*
* PadLock can generate an extended key for AES128 in hardware
*/
memcpy(cdata->ks.rd_key, key, AES_KEY_SIZE_128);
cdata->cword.b.keygen = 0;
break;
case 192:
case 256:
/*
* Generate an extended AES key in software. Needed for AES192/AES256
*/
/*
* Well, the above applies to Stepping 8 CPUs and is listed as
* hardware errata. They most likely will fix it at some point and
* then a check for stepping would be due here.
*/
if ((mode == EVP_CIPH_ECB_MODE || mode == EVP_CIPH_CBC_MODE)
&& !enc)
AES_set_decrypt_key(key, key_len, &cdata->ks);
else
AES_set_encrypt_key(key, key_len, &cdata->ks);
# ifndef AES_ASM
/*
* OpenSSL C functions use byte-swapped extended key.
*/
padlock_key_bswap(&cdata->ks);
# endif
cdata->cword.b.keygen = 1;
break;
default:
/* ERROR */
return 0;
}
/*
* This is done to cover for cases when user reuses the
* context for new key. The catch is that if we don't do
* this, padlock_eas_cipher might proceed with old key...
*/
padlock_reload_key();
return 1;
}
/* ===== Random Number Generator ===== */
/*
* This code is not engaged. The reason is that it does not comply
* with recommendations for VIA RNG usage for secure applications
* (posted at http://www.via.com.tw/en/viac3/c3.jsp) nor does it
* provide meaningful error control...
*/
/*
* Wrapper that provides an interface between the API and the raw PadLock
* RNG
*/
static int padlock_rand_bytes(unsigned char *output, int count)
{
unsigned int eax, buf;
while (count >= 8) {
eax = padlock_xstore(output, 0);
if (!(eax & (1 << 6)))
return 0; /* RNG disabled */
/* this ---vv--- covers DC bias, Raw Bits and String Filter */
if (eax & (0x1F << 10))
return 0;
if ((eax & 0x1F) == 0)
continue; /* no data, retry... */
if ((eax & 0x1F) != 8)
return 0; /* fatal failure... */
output += 8;
count -= 8;
}
while (count > 0) {
eax = padlock_xstore(&buf, 3);
if (!(eax & (1 << 6)))
return 0; /* RNG disabled */
/* this ---vv--- covers DC bias, Raw Bits and String Filter */
if (eax & (0x1F << 10))
return 0;
if ((eax & 0x1F) == 0)
continue; /* no data, retry... */
if ((eax & 0x1F) != 1)
return 0; /* fatal failure... */
*output++ = (unsigned char)buf;
count--;
}
OPENSSL_cleanse(&buf, sizeof(buf));
return 1;
}
/* Dummy but necessary function */
static int padlock_rand_status(void)
{
return 1;
}
/* Prepare structure for registration */
static RAND_METHOD padlock_rand = {
NULL, /* seed */
padlock_rand_bytes, /* bytes */
NULL, /* cleanup */
NULL, /* add */
padlock_rand_bytes, /* pseudorand */
padlock_rand_status, /* rand status */
};
# endif /* COMPILE_HW_PADLOCK */
# endif /* !OPENSSL_NO_HW_PADLOCK */
#endif /* !OPENSSL_NO_HW */
#if defined(OPENSSL_NO_HW) || defined(OPENSSL_NO_HW_PADLOCK) \
|| !defined(COMPILE_HW_PADLOCK)
# ifndef OPENSSL_NO_DYNAMIC_ENGINE
OPENSSL_EXPORT
int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns);
OPENSSL_EXPORT
int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns)
{
return 0;
}
IMPLEMENT_DYNAMIC_CHECK_FN()
# endif
#endif
|
the_stack_data/103265328.c | /* { dg-do compile } */
typedef struct filter_buffer filter_buffer_t;
struct filter_buffer
{
char buf[1];
};
typedef struct sbuf_header sbuf_header_t;
struct sbuf_header
{
char buf[1];
}
const_f (filter_buffer_t *buf)
{
float val;
int i;
for (i = 0; i < 10; i++)
((float*) (&((sbuf_header_t *) (__PTRDIFF_TYPE__)((buf) == (filter_buffer_t *)&(buf)->buf[0]))->buf[0]))[i] = val;
}
|
the_stack_data/639301.c | // taken from - https://www.youtube.com/watch?v=LtXEMwSG5-8
#include<stdio.h>
#include<stdlib.h>
#include<sys/socket.h>
#include<sys/types.h>
#include<netinet/in.h>
#include <unistd.h>
int main(){
char server_message[256] = "you recieved this from server";
//create the server socket
int server_socket;
server_socket = socket(AF_INET,SOCK_STREAM,0);
//define the server address
struct sockaddr_in server_address;
server_address.sin_family = AF_INET;
server_address.sin_port = htons(9002);
server_address.sin_addr.s_addr = INADDR_ANY;
/*
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int bind(int sockfd, const struct sockaddr *addr, socklen_t addrlen);
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.
*/
// bind the socket to the specified id and port.
bind(server_socket,(struct sockaddr*)&server_address,sizeof(server_address));
/*
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
int listen(int sockfd, int backlog);
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.
*/
listen(server_socket,5);
int client_socket;
// after listening accept.
client_socket = accept(server_socket,NULL,NULL);
/*
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
ssize_t send(int sockfd, const void *buf, size_t len, int flags);
ssize_t sendto(int sockfd, const void *buf, size_t len, int flags,
const struct sockaddr *dest_addr, socklen_t addrlen);
ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
RETURN VALUE
On success, these calls return the number of bytes sent. On error, -1
is returned, and errno is set appropriately.
*/
send(client_socket,server_message,sizeof(server_message),0);
//close the socket
close(server_socket);
return 0;
}
|
the_stack_data/40764173.c | #include <stdio.h>
#include <math.h>
int main(){
double i = 24;
printf("%f\n", sqrt(24));
}
|
the_stack_data/36075407.c | #include <stdio.h>
void main()
{
char str[255], *ptr1, *ptr2, temp ;
int n,m;
printf("Enter a string: ");
scanf("%s", str);
ptr1=str;
n=1;
while(*ptr1 !='\0')
{
ptr1++;
n++;
}
ptr1--;
ptr2=str;
m=1;
while(m<=n/2)
{
temp=*ptr1;
*ptr1=*ptr2;
*ptr2=temp;
ptr1--;
ptr2++;;
m++;
}
printf("Reverse string is %s", str);
} |
the_stack_data/98574270.c | /*
This file was generated by the code generator.
Changing the content manually may result in loss of changes.
The code generator recommends using auto generation after changing the seed file.
*/
#define X )*2+1
#define _ )*2
#define s ((((((((0
char DEFBitmap[4096] = {
/*char 0x00
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x01
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ X _ X _ X _ ,
s X _ X _ X _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ X _ X _ X _ ,
s X _ _ X _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x02
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X X X X X _ _ ,
s X X X X X X X _ ,
s X X _ X _ X X _ ,
s X X _ X _ X X _ ,
s X X X X X X X _ ,
s X X X X X X X _ ,
s X X _ X _ X X _ ,
s X X X _ X X X _ ,
s _ X X X X X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x03
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X _ X X _ _ ,
s X X X X X X X _ ,
s X X X X X X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 _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x07
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ X X X X _ _ ,
s _ _ X X X X _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x08
*/
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X _ _ X X X ,
s X X _ _ _ _ X X ,
s X X _ _ _ _ X X ,
s X X X _ _ X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
/*char 0x09
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ X X X X _ _ ,
s _ X X _ _ X X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X X _ _ X X _ ,
s _ _ X X X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x0a
*/
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X _ _ _ _ X X ,
s X _ _ X X _ _ X ,
s X _ X X X X _ X ,
s X _ X X X X _ X ,
s X _ _ X X _ _ X ,
s X X _ _ _ _ X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
/*char 0x0b
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ X _ X _ _ ,
s X _ _ X _ _ X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x0c
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x0d
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ X X _ _ ,
s _ _ _ _ X X X _ ,
s _ _ _ _ X _ X X ,
s _ _ _ _ X _ X X ,
s _ _ _ _ X _ X _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ X X X X _ _ _ ,
s X X X X X _ _ _ ,
s _ X X X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x0e
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X X X X X ,
s _ _ _ X X X X X ,
s _ _ _ X _ _ _ X ,
s _ _ _ X _ _ _ X ,
s _ _ _ X _ _ _ X ,
s _ _ _ X _ _ _ X ,
s _ _ _ X _ _ _ X ,
s _ _ _ X _ _ _ X ,
s _ X X X _ X X X ,
s X X X X X X X X ,
s _ X X _ _ X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x0f
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ X _ X _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ X _ X _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x10
*/
s _ _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X X _ _ _ _ _ _ ,
s X X X _ _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X X _ _ _ ,
s X X X X X X _ _ ,
s X X X X X X X _ ,
s X X X X X X _ _ ,
s X X X X X _ _ _ ,
s X X X X _ _ _ _ ,
s X X X _ _ _ _ _ ,
s X X _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x11
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ X _ ,
s _ _ _ _ _ X X _ ,
s _ _ _ _ X X X _ ,
s _ _ _ X X X X _ ,
s _ _ X X X X X _ ,
s _ X X X X X X _ ,
s X X X X X X X _ ,
s _ X X X X X X _ ,
s _ _ X X X X X _ ,
s _ _ _ X X X X _ ,
s _ _ _ _ X X X _ ,
s _ _ _ _ _ X X _ ,
s _ _ _ _ _ _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x12
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ X _ X _ _ ,
s X _ _ X _ _ X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X _ _ X _ _ X _ ,
s _ X _ X _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x13
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x14
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X X X _ ,
s _ X _ _ X _ X _ ,
s X _ _ _ X _ X _ ,
s X _ _ _ X _ X _ ,
s X _ _ _ X _ X _ ,
s X _ _ _ X _ X _ ,
s _ X _ _ X _ X _ ,
s _ _ X X X _ X _ ,
s _ _ _ _ X _ X _ ,
s _ _ _ _ X _ X _ ,
s _ _ _ _ X _ X _ ,
s _ _ _ _ X _ X _ ,
s _ _ _ _ X _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x15
*/
s _ X X X X X _ _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s _ X X X X X _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x16
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s X X X X X X X _ ,
s X X X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x17
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ X _ X _ _ ,
s X _ _ X _ _ X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X _ _ X _ _ X _ ,
s _ X _ X _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ X X X X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x18
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ X _ X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 ,
/*char 0x22
*/
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x23
*/
s _ _ _ _ _ _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s X X X X X X X _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s X X X X X X X _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x24
*/
s _ _ _ X _ _ _ _ ,
s _ _ X X X _ X _ ,
s _ X _ X _ X X _ ,
s X _ _ X _ _ X _ ,
s X _ _ X _ _ X _ ,
s X _ _ X _ _ _ _ ,
s _ X _ X _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ _ X _ ,
s X _ _ X _ _ X _ ,
s X _ _ X _ _ X _ ,
s X X _ X _ X _ _ ,
s X _ X X X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0x25
*/
s _ X X _ _ _ X _ ,
s X _ _ X _ _ X _ ,
s X _ _ X _ X _ _ ,
s X _ _ X _ X _ _ ,
s _ X X _ X _ _ _ ,
s _ _ _ _ X _ _ _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,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x40
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ X X _ X _ ,
s X _ X _ X _ X _ ,
s X _ X _ X _ X _ ,
s X _ X _ X _ X _ ,
s X _ X _ X _ X _ ,
s X _ X _ X _ X _ ,
s X _ _ X X X _ _ ,
s X _ _ _ _ _ _ _ ,
s _ X _ _ _ X X _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x41
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ X X X X X X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s X X X _ _ X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x42
*/
s _ _ _ _ _ _ _ _ ,
s X X X X _ _ _ _ ,
s _ X _ _ X _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ X _ _ _ ,
s _ X X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s X X X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x43
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ X _ ,
s _ X _ _ _ X X _ ,
s _ X _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x44
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s X X X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x45
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s X X X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x46
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s X X X X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x47
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ X _ ,
s _ X _ _ _ X X _ ,
s _ X _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ X X X X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ X X _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x48
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ _ X X X ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X X X X X X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s X X X _ _ X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x49
*/
s _ _ _ _ _ _ _ _ ,
s _ X X X X X _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _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_ _ _ _ X X ,
s _ X _ _ _ _ X _ ,
s _ X X _ _ X X _ ,
s _ X X _ _ X X _ ,
s _ X X _ _ X X _ ,
s _ X _ X X _ X _ ,
s _ X _ X X _ X _ ,
s _ X _ X X _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s X X X _ _ X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x4e
*/
s _ _ _ _ _ _ _ _ ,
s X X _ _ _ X X X ,
s _ X _ _ _ _ X _ ,
s _ X X _ _ _ X _ ,
s _ X X _ _ _ X _ ,
s _ X _ X _ _ X _ ,
s _ X _ X _ _ X _ ,
s _ X _ X _ _ X _ ,
s _ X _ _ X _ X _ ,
s _ X _ _ X _ X _ ,
s _ X _ _ X _ X _ ,
s _ X _ _ _ X X _ ,
s _ X _ _ _ X X _ ,
s X X X _ _ _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x4f
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x50
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ X X X X _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s X X X X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x51
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ X _ _ X _ ,
s X _ _ _ X _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x52
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X X _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s X X X _ _ X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x53
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ X _ ,
s _ X _ _ _ X X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X X _ _ _ X _ _ ,
s X _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x54
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s X _ _ X _ _ X _ ,
s X _ _ X _ _ X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ X X X X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x55
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ _ X X X ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ _ X _ _ X _ _ ,
s _ _ X X X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x56
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ _ X X X ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x57
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ _ X X X ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ X _ X X _ X _ ,
s _ X _ X X _ X _ ,
s _ X _ X X _ X _ ,
s _ X _ X X _ X _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x58
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ _ X X X ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ X X _ _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ X _ _ _ _ X _ ,
s _ X _ _ _ _ X _ ,
s X X X _ _ X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x59
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ X X X _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ X X X X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x5a
*/
s _ _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ X _ _ _ _ _ _ ,
s _ X _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X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_ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X X X X X X X _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x83
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X X X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x84
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X X X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x85
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X X X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s _ X _ _ _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 _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x90
*/
s _ _ _ _ X X _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X X X X X _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x91
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X _ _ _ _ _ ,
s _ _ _ X X X _ _ ,
s _ _ _ X _ _ X _ ,
s _ X X X _ _ X _ ,
s X _ _ X X X X _ ,
s X _ _ X _ _ _ _ ,
s X _ _ X _ _ _ _ ,
s X _ _ X _ _ X _ ,
s _ X X _ X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x92
*/
s _ _ _ _ X X _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s X X X X X X X _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x93
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ _ _ ,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_ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x9a
*/
s _ _ X _ _ X _ _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x9b
*/
s _ _ _ _ _ _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X X X X _ _ ,
s _ X X _ X _ X _ ,
s X _ X _ X _ _ _ ,
s X _ X _ X _ _ _ ,
s X _ X _ X _ _ _ ,
s X _ X _ X _ _ _ ,
s X _ X _ X _ _ _ ,
s _ X X _ X _ X _ ,
s _ _ X X X X _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ X _ X _ _ _ ,
/*char 0x9c
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ X X _ _ ,
s _ _ _ X _ _ X _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s X X X X X X _ _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ _ X _ _ _ _ _ ,
s _ X X _ _ _ _ _ ,
s X _ X _ _ _ _ _ ,
s X _ X X _ _ X _ ,
s _ X _ _ X X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x9d
*/
s _ _ _ _ _ _ _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ X _ _ _ X _ _ ,
s _ _ X _ X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x9e
*/
s _ _ _ _ _ _ _ _ ,
s X X X _ _ _ _ _ ,
s X _ _ X _ _ _ _ ,
s X _ _ _ X _ _ _ ,
s X _ _ _ X _ _ _ ,
s X _ _ _ X _ _ _ ,
s X _ _ X _ X _ _ ,
s X X X _ _ X _ _ ,
s X _ _ X X X X X ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0x9f
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ X X _ _ ,
s _ _ _ X _ _ X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X _ _ X _ _ _ _ ,
s _ X X _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xa0
*/
s _ _ _ _ X X _ _ ,
s _ _ _ _ X _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X X X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ X X X X _ _ ,
s _ X _ _ _ X _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_ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xa4
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ X _ _ X _ ,
s _ _ X _ X _ X _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s X X X X X _ _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s X _ _ _ _ _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xa5
*/
s _ _ _ X _ _ X _ ,
s _ _ X _ X _ X _ ,
s _ _ X _ _ X _ _ ,
s _ _ _ _ _ _ _ _ ,
s X _ _ _ _ _ X _ ,
s X X _ _ _ _ X _ ,
s X X _ _ _ _ X _ ,
s X _ X _ _ _ X _ ,
s X _ _ X _ _ X _ ,
s X _ _ X _ _ X _ ,
s X _ _ _ X _ X _ ,
s X _ _ _ _ X X _ ,
s X _ _ _ _ X X _ ,
s X _ _ _ _ _ X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xa6
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ X X X X _ _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ _ _ _ X _ _ ,
s _ _ X X X X _ _ ,
s _ X _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s X _ _ _ _ X _ _ ,
s _ X _ _ _ X _ _ ,
s _ _ X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s X X X X X X X _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xa7
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ X X X _ _ _ ,
s _ X _ _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s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
s _ X _ X _ X _ X ,
s X _ X _ X _ X _ ,
/*char 0xb2
*/
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
s _ X X X _ X X X ,
s X X _ X X X _ X ,
/*char 0xb3
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0xb4
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _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X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0xc6
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X X X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X X X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0xc7
*/
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X X X ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
/*char 0xc8
*/
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X X X X X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 _ _ X _ X _ _ ,
/*char 0xcc
*/
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ X X X ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
/*char 0xcd
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s X X X X X X X X ,
s _ _ _ _ _ _ _ _ ,
s X X X X X X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xce
*/
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s X X X X _ X X X ,
s _ _ _ _ _ _ _ _ ,
s X X X X _ X X X ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
/*char 0xcf
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _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 _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0xd6
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X X X X X ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
/*char 0xd7
*/
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s X X X X _ X X X ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
s _ _ _ X _ X _ _ ,
/*char 0xd8
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X X ,
s _ _ _ X _ _ _ _ ,
s X X X X X X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0xd9
*/
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s X X X X _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xda
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ X X X X X ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
s _ _ _ X _ _ _ _ ,
/*char 0xdb
*/
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
/*char 0xdc
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
/*char 0xdd
*/
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
s X X X X _ _ _ _ ,
/*char 0xde
*/
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
s _ _ _ _ X X X X ,
/*char 0xdf
*/
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s X X X X X X X X ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
/*char 0xe0
*/
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _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_ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _ ,
s _ _ _ _ _ _ _ _
};
#undef X
#undef _
#undef s
|
the_stack_data/28262247.c | /*
* Copyright (c) 2018 Renato Montes
* License: Apache License 2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Compile with:
* gcc -ansi -W -Wall -pedantic solver.c -o solver.exe
*
* Run as:
* ./solver.exe 3 < three.csv
* ./solver.exe 4 < four.csv
* ./solver.exe 10 < ten.csv
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* Number of arguments expected in program invocation from command-line. */
static int ARG_NUMBER = 2;
/* Minimum matrix size. */
static int MIN_MATRIX_SIZE = 2;
/* Input buffer for lines in the CSV value source. */
#define BUFFSIZE 1024
/* Length of decimal values in CSV source, including negative sign. */
#define DECIMAL_LENGTH 6
/* Function prototypes. */
int get_size(int argc, char** argv);
struct problem* get_data(int size);
void save_constant(float* constants, int row, char line[BUFFSIZE], size_t position);
float** get_cofactors(float** original, int size);
float get_det(float** original, int size);
void get_minor(float** matrix, float** minor, int size, int i, int j);
float get_det_with_cofactors(float** original, float** cofactors, int size);
void free_matrix(float** matrix, int size);
float* get_answers(float det, float** cofactors, float* constants, int size);
int* get_rounded_answers(float* answers, int size);
void print_answers(int* answers, int size);
/* Problem data entered. */
struct problem {
float** original;
float* constants;
};
/*
* Check command-line arguments for a valid matrix size.
*
* Arguments:
* argc (int): number of arguments at command-line invocation
* argv (char**): string arguments at command-line invocation
*
* Return:
* int: size entered as a command-line argument
*
* Post-condition:
* the returned matrix size is valid
*/
int get_size(int argc, char** argv) {
int size;
if (argc != ARG_NUMBER) {
fprintf(stderr, "Usage: speedy [size] < [datafile]\n");
exit(0);
}
if ((size = atoi(argv[1])) < MIN_MATRIX_SIZE) {
fprintf(stderr, "Error: matrix size must be an integer greater"\
" than or equal to 2\n");
exit(0);
};
return size;
}
/*
* Obtain CSV data from stdin.
*
* Arguments:
* size (const int): size of the square matrix
*
* Return:
* struct problem: data obtained from CSV input
*/
struct problem* get_data(int size) {
int row, column;
char line[BUFFSIZE];
size_t position;
size_t counter;
char linechar;
float linefloat;
char substring[DECIMAL_LENGTH];
struct problem* data = malloc(sizeof(struct problem));
float** matrix = malloc(sizeof(float*) * size);
float* constants = malloc(sizeof(float) * size);
for (row = 0; row < size; row++) {
if (!fgets(line, BUFFSIZE, stdin)) {
fprintf(stderr, "Error: could not read a line\n");
exit(0);
}
matrix[row] = malloc(sizeof(float) * size);
position = 0;
for (column = 0; column < size; column++) {
counter = 0;
while ((linechar = line[position]) != ',') {
substring[counter] = linechar;
counter++;
position++;
}
substring[counter] = '\0';
sscanf(substring, "%f", &linefloat);
matrix[row][column] = linefloat;
position++;
}
counter = 0;
while ((linechar = line[position]) != '\n' && linechar != '\0') {
substring[counter] = linechar;
counter++;
position++;
}
substring[counter] = '\0';
sscanf(substring, "%f", &linefloat);
constants[row] = linefloat;
}
data->original = matrix;
data->constants = constants;
return data;
}
/*
* Calculate cofactor matrix from original matrix.
*
* Arguments:
* original (float**): original matrix
* size (int): size of the square matrix
*
* Return:
* float**: cofactor matrix, including correct positive/negative signs
*/
float** get_cofactors(float** original, int size) {
int row, col;
int sign;
float** cofactors = malloc(sizeof(float*) * size);
float** topminor = malloc(sizeof(float*) * (size - 1));
for (row = 0; row < size; row++) {
cofactors[row] = malloc(sizeof(float) * size);
}
for (row = 0; row < (size - 1); row++) {
topminor[row] = malloc(sizeof(float) * (size - 1));
}
for (row = 0; row < size; row++) {
sign = (row % 2 == 0)? 1 : -1;
for (col = 0; col < size; col++) {
get_minor(original, topminor, size, row, col);
cofactors[row][col] = sign * get_det(topminor, size - 1);
sign = -sign;
}
}
for (row = 0; row < (size - 1); row++) {
free(topminor[row]);
}
free(topminor);
return cofactors;
}
/*
* Calculate determinant of matrix in a recursive manner.
*
* Arguments:
* matrix (float**): the square matrix to obtain the determinant of
* size (int): size of the square matrix
*
* Return:
* float: the determinant of the input matrix
*/
float get_det(float** matrix, int size) {
float det;
int j;
int sign = 1;
float** minor = malloc(sizeof(float*) * (size - 1));
for (j = 0; j < size - 1; j++) {
minor[j] = malloc(sizeof(float) * (size - 1));
}
if (size == 2) {
return matrix[0][0] * matrix[1][1] - matrix[0][1] * matrix[1][0];
}
for (j = 0; j < size; j++)
{
get_minor(matrix, minor, size, 0, j);
det += sign * matrix[0][j] * get_det(minor, size - 1);
sign = -sign;
}
for (j = 0; j < size - 1; j++) {
free(minor[j]);
}
free(minor);
return det;
}
/*
* Obtain minor based on specific element and modify in-place.
*
* Arguments:
* matrix (float**): the matrix to examine
* minor (float**): the matrix to store the minor in
* size (int): the size of the matrix to examine
* i (int): the row of the element of reference to discriminate
* j (int): the column of the element of reference to discriminate
*/
void get_minor(float** matrix,
float** minor,
int size,
int i,
int j) {
int matrixrow;
int matrixcol;
int minorrow = 0;
int minorcol = 0;
for (matrixrow = 0; matrixrow < size; matrixrow++) {
for (matrixcol = 0; matrixcol < size; matrixcol++) {
if (matrixrow != i && matrixcol != j) {
minor[minorrow][minorcol] = matrix[matrixrow][matrixcol];
minorcol++;
if (minorcol == size - 1) {
minorcol = 0;
minorrow++;
}
}
}
}
}
/*
* Get a determinant quickly by making use of a cofactor matrix.
*
* Arguments:
* original (float**): the original matrix
* cofactors (float**): the cofactor matrix
* size (int): the size of the square matrices
*
* Return:
* float: the calculated determinant
*/
float get_det_with_cofactors(float** original,
float** cofactors,
int size) {
int col;
float det = 0.0;
for (col = 0; col < size; col++) {
det += original[0][col] * cofactors[0][col];
}
return det;
}
/*
* Calculate answers to the AX = B system of linear equations
*
* Arguments:
* det (float): the determinant of matrix A
* cofactors (float**): the cofactors of matrix A
* constants (float*): the right-hand constants (B)
* size (int): the size of the square matrix A
*
* Return:
* float*: answers to the linear equations, as floats
*/
float* get_answers(float det,
float** cofactors,
float* constants,
int size) {
int i, j;
float* answers = malloc(sizeof(float) * size);
for (i = 0; i < size; i++) {
answers[i] = 0;
for (j = 0; j < size; j++) {
/* Inverse matrix built on the fly. */
answers[i] += constants[j] * cofactors[j][i];
}
answers[i] = answers[i] / det;
}
return answers;
}
/*
* Round float answers into ints.
*
* Arguments:
* answers (float*): answers obtained as floats
* size (int): number of answers obtained
*
* Return:
* int*: answers obtained, now rounded to be ints
*
* Pre-condition:
* All answers for the input data are intended to be ints. This function
* approximates all received floats to their closest int value.
*/
int* get_rounded_answers(float* answers, int size) {
int i;
float cur;
int* final = malloc(sizeof(int) * size);
for (i = 0; i < size; i++) {
cur = answers[i];
final[i] = (cur < 0.0)? (int)(cur - 0.5) : (int)(cur + 0.5) ;
}
return final;
}
/*
* Print int answers to the command-line.
*
* Arguments:
* answers (int*): answers to the problem data, as ints
* size (int): number of answers to the problem data (number of equations)
*/
void print_answers(int* answers, int size) {
int i;
printf("%d", answers[0]);
for (i = 1; i < size; i++) {
printf(",%d", answers[i]);
}
}
/*
* Free the allocated memory of a matrix.
*
* Arguments:
* matrix (float**): matrix to be freed
* size (int): size of the matrix to be freed
*/
void free_matrix(float** matrix, int size) {
int row;
for (row = 0; row < size; row++) {
free(matrix[row]);
}
free(matrix);
}
/*
* Program entry point.
*
* Arguments:
* argc (int): number of command-line arguments at program invocation
* argv (char**): strings of command-line arguments at program invocation
*
* Return:
* int: program runtime exit code
*/
int main(int argc, char** argv) {
int size;
struct problem data;
float** cofactors;
float det;
float* answers;
/* Read matrix size from command-line argument. */
size = get_size(argc, argv);
/* Read data from input. */
data = *(get_data(size));
/* Obtain cofactor matrix. */
cofactors = get_cofactors(data.original, size);
/* Obtain determinant using the cofactor matrix. */
det = get_det_with_cofactors(data.original, cofactors, size);
/* Calculate answers as floats. */
answers = get_answers(det, cofactors, data.constants, size);
/* Print answers after rounding them to the closest int values. */
print_answers(get_rounded_answers(answers, size), size);
/* Free last matrices allocated in memory. */
free_matrix(data.original, size);
free_matrix(cofactors, size);
return 0;
}
|
the_stack_data/730374.c | #include <stdio.h>
int main()
{
int a,sq,cb;
scanf("%d",&a);
sq=a*a;
cb=a*a*a;
printf("\n %d",sq);
printf("\n %d",cb);
return 0;
}
|
the_stack_data/14201193.c | /* Copyright (C) 2014-2017 Free Software Foundation, Inc.
This file 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, or (at your option) any
later version.
This file 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.
Under Section 7 of GPL version 3, you are granted additional
permissions described in the GCC Runtime Library Exception, version
3.1, as published by the Free Software Foundation.
You should have received a copy of the GNU General Public License and
a copy of the GCC Runtime Library Exception along with this program;
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
int *__exitval_ptr;
extern void __attribute__((noreturn)) exit (int status);
extern int main (int, void **);
/* Always setup soft stacks to allow testing with -msoft-stack but without
-mgomp. 32 is the maximum number of warps in a CTA: the definition here
must match the external declaration emitted by the compiler. */
void *__nvptx_stacks[32] __attribute__((shared,nocommon));
/* Likewise for -muniform-simt. */
unsigned __nvptx_uni[32] __attribute__((shared,nocommon));
void __attribute__((kernel))
__main (int *rval_ptr, int argc, void **argv)
{
__exitval_ptr = rval_ptr;
/* Store something non-zero, so the host knows something went wrong,
if we fail to reach exit properly. */
if (rval_ptr)
*rval_ptr = 255;
static char stack[131072] __attribute__((aligned(8)));
__nvptx_stacks[0] = stack + sizeof stack;
__nvptx_uni[0] = 0;
exit (main (argc, argv));
}
|
the_stack_data/1040426.c | #include<stdio.h>
int main()
{
int i,n,s;
printf("Size : ");
scanf("%d",&n);
int p=0;
int a[n];
for(i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
printf("Enter The value to Search : ");
scanf("%d",&s);
for(i=0; i<n; i++)
{
if(s==a[i])
{
p=i+1;
break;
}
}
if(p==0)
{
printf("Not Found");
}
else
{
printf("The position of %d : %d",s,p);
}
return 0;
}
|
the_stack_data/137782.c | #include <stdio.h>
int main()
{
for(int i = 1; i <= 100; i++) {
if (i % 15 == 0){
printf("FizzBuzz\n");
}
else if (i % 3 == 0){
printf("Fizz\n");
}
else if (i % 5 == 0){
printf("Buzz\n");
}
else {
printf("%d\n", i);
}
}
return 0;
}
|
the_stack_data/18575.c | #include <stdlib.h>
struct _s {
int x;
int a[];
};
int main(void){
struct _s *p = (struct _s*)malloc(sizeof(struct _s) + 5 * sizeof(int));
p->a[2] = 5;
return p->a[2];
}
|
the_stack_data/206392837.c | // possible deadlock in blkdev_put
// https://syzkaller.appspot.com/bug?id=6348c095f6a5ccbb6500
// status:0
// autogenerated by syzkaller (https://github.com/google/syzkaller)
#define _GNU_SOURCE
#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include <linux/futex.h>
#include <linux/loop.h>
static unsigned long long procid;
static void sleep_ms(uint64_t ms)
{
usleep(ms * 1000);
}
static uint64_t current_time_ms(void)
{
struct timespec ts;
if (clock_gettime(CLOCK_MONOTONIC, &ts))
exit(1);
return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}
static void use_temporary_dir(void)
{
char tmpdir_template[] = "./syzkaller.XXXXXX";
char* tmpdir = mkdtemp(tmpdir_template);
if (!tmpdir)
exit(1);
if (chmod(tmpdir, 0777))
exit(1);
if (chdir(tmpdir))
exit(1);
}
static void thread_start(void* (*fn)(void*), void* arg)
{
pthread_t th;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 128 << 10);
int i = 0;
for (; i < 100; i++) {
if (pthread_create(&th, &attr, fn, arg) == 0) {
pthread_attr_destroy(&attr);
return;
}
if (errno == EAGAIN) {
usleep(50);
continue;
}
break;
}
exit(1);
}
typedef struct {
int state;
} event_t;
static void event_init(event_t* ev)
{
ev->state = 0;
}
static void event_reset(event_t* ev)
{
ev->state = 0;
}
static void event_set(event_t* ev)
{
if (ev->state)
exit(1);
__atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE);
syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000);
}
static void event_wait(event_t* ev)
{
while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE))
syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0);
}
static int event_isset(event_t* ev)
{
return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE);
}
static int event_timedwait(event_t* ev, uint64_t timeout)
{
uint64_t start = current_time_ms();
uint64_t now = start;
for (;;) {
uint64_t remain = timeout - (now - start);
struct timespec ts;
ts.tv_sec = remain / 1000;
ts.tv_nsec = (remain % 1000) * 1000 * 1000;
syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts);
if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE))
return 1;
now = current_time_ms();
if (now - start > timeout)
return 0;
}
}
static bool write_file(const char* file, const char* what, ...)
{
char buf[1024];
va_list args;
va_start(args, what);
vsnprintf(buf, sizeof(buf), what, args);
va_end(args);
buf[sizeof(buf) - 1] = 0;
int len = strlen(buf);
int fd = open(file, O_WRONLY | O_CLOEXEC);
if (fd == -1)
return false;
if (write(fd, buf, len) != len) {
int err = errno;
close(fd);
errno = err;
return false;
}
close(fd);
return true;
}
static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2)
{
if (a0 == 0xc || a0 == 0xb) {
char buf[128];
sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1,
(uint8_t)a2);
return open(buf, O_RDWR, 0);
} else {
char buf[1024];
char* hash;
strncpy(buf, (char*)a0, sizeof(buf) - 1);
buf[sizeof(buf) - 1] = 0;
while ((hash = strchr(buf, '#'))) {
*hash = '0' + (char)(a1 % 10);
a1 /= 10;
}
return open(buf, a2, 0);
}
}
struct fs_image_segment {
void* data;
uintptr_t size;
uintptr_t offset;
};
#define IMAGE_MAX_SEGMENTS 4096
#define IMAGE_MAX_SIZE (129 << 20)
#define sys_memfd_create 319
static unsigned long fs_image_segment_check(unsigned long size,
unsigned long nsegs,
struct fs_image_segment* segs)
{
if (nsegs > IMAGE_MAX_SEGMENTS)
nsegs = IMAGE_MAX_SEGMENTS;
for (size_t i = 0; i < nsegs; i++) {
if (segs[i].size > IMAGE_MAX_SIZE)
segs[i].size = IMAGE_MAX_SIZE;
segs[i].offset %= IMAGE_MAX_SIZE;
if (segs[i].offset > IMAGE_MAX_SIZE - segs[i].size)
segs[i].offset = IMAGE_MAX_SIZE - segs[i].size;
if (size < segs[i].offset + segs[i].offset)
size = segs[i].offset + segs[i].offset;
}
if (size > IMAGE_MAX_SIZE)
size = IMAGE_MAX_SIZE;
return size;
}
static int setup_loop_device(long unsigned size, long unsigned nsegs,
struct fs_image_segment* segs,
const char* loopname, int* memfd_p, int* loopfd_p)
{
int err = 0, loopfd = -1;
size = fs_image_segment_check(size, nsegs, segs);
int memfd = syscall(sys_memfd_create, "syzkaller", 0);
if (memfd == -1) {
err = errno;
goto error;
}
if (ftruncate(memfd, size)) {
err = errno;
goto error_close_memfd;
}
for (size_t i = 0; i < nsegs; i++) {
if (pwrite(memfd, segs[i].data, segs[i].size, segs[i].offset) < 0) {
}
}
loopfd = open(loopname, O_RDWR);
if (loopfd == -1) {
err = errno;
goto error_close_memfd;
}
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
if (errno != EBUSY) {
err = errno;
goto error_close_loop;
}
ioctl(loopfd, LOOP_CLR_FD, 0);
usleep(1000);
if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
err = errno;
goto error_close_loop;
}
}
*memfd_p = memfd;
*loopfd_p = loopfd;
return 0;
error_close_loop:
close(loopfd);
error_close_memfd:
close(memfd);
error:
errno = err;
return -1;
}
static long syz_mount_image(volatile long fsarg, volatile long dir,
volatile unsigned long size,
volatile unsigned long nsegs,
volatile long segments, volatile long flags,
volatile long optsarg)
{
struct fs_image_segment* segs = (struct fs_image_segment*)segments;
int res = -1, err = 0, loopfd = -1, memfd = -1, need_loop_device = !!segs;
char* mount_opts = (char*)optsarg;
char* target = (char*)dir;
char* fs = (char*)fsarg;
char* source = NULL;
char loopname[64];
if (need_loop_device) {
memset(loopname, 0, sizeof(loopname));
snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
if (setup_loop_device(size, nsegs, segs, loopname, &memfd, &loopfd) == -1)
return -1;
source = loopname;
}
mkdir(target, 0777);
char opts[256];
memset(opts, 0, sizeof(opts));
if (strlen(mount_opts) > (sizeof(opts) - 32)) {
}
strncpy(opts, mount_opts, sizeof(opts) - 32);
if (strcmp(fs, "iso9660") == 0) {
flags |= MS_RDONLY;
} else if (strncmp(fs, "ext", 3) == 0) {
if (strstr(opts, "errors=panic") || strstr(opts, "errors=remount-ro") == 0)
strcat(opts, ",errors=continue");
} else if (strcmp(fs, "xfs") == 0) {
strcat(opts, ",nouuid");
}
res = mount(source, target, fs, flags, opts);
if (res == -1) {
err = errno;
goto error_clear_loop;
}
res = open(target, O_RDONLY | O_DIRECTORY);
if (res == -1) {
err = errno;
}
error_clear_loop:
if (need_loop_device) {
ioctl(loopfd, LOOP_CLR_FD, 0);
close(loopfd);
close(memfd);
}
errno = err;
return res;
}
#define FS_IOC_SETFLAGS _IOW('f', 2, long)
static void remove_dir(const char* dir)
{
int iter = 0;
DIR* dp = 0;
retry:
while (umount2(dir, MNT_DETACH) == 0) {
}
dp = opendir(dir);
if (dp == NULL) {
if (errno == EMFILE) {
exit(1);
}
exit(1);
}
struct dirent* ep = 0;
while ((ep = readdir(dp))) {
if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0)
continue;
char filename[FILENAME_MAX];
snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name);
while (umount2(filename, MNT_DETACH) == 0) {
}
struct stat st;
if (lstat(filename, &st))
exit(1);
if (S_ISDIR(st.st_mode)) {
remove_dir(filename);
continue;
}
int i;
for (i = 0;; i++) {
if (unlink(filename) == 0)
break;
if (errno == EPERM) {
int fd = open(filename, O_RDONLY);
if (fd != -1) {
long flags = 0;
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) {
}
close(fd);
continue;
}
}
if (errno == EROFS) {
break;
}
if (errno != EBUSY || i > 100)
exit(1);
if (umount2(filename, MNT_DETACH))
exit(1);
}
}
closedir(dp);
for (int i = 0;; i++) {
if (rmdir(dir) == 0)
break;
if (i < 100) {
if (errno == EPERM) {
int fd = open(dir, O_RDONLY);
if (fd != -1) {
long flags = 0;
if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) {
}
close(fd);
continue;
}
}
if (errno == EROFS) {
break;
}
if (errno == EBUSY) {
if (umount2(dir, MNT_DETACH))
exit(1);
continue;
}
if (errno == ENOTEMPTY) {
if (iter < 100) {
iter++;
goto retry;
}
}
}
exit(1);
}
}
static void kill_and_wait(int pid, int* status)
{
kill(-pid, SIGKILL);
kill(pid, SIGKILL);
for (int i = 0; i < 100; i++) {
if (waitpid(-1, status, WNOHANG | __WALL) == pid)
return;
usleep(1000);
}
DIR* dir = opendir("/sys/fs/fuse/connections");
if (dir) {
for (;;) {
struct dirent* ent = readdir(dir);
if (!ent)
break;
if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
continue;
char abort[300];
snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
ent->d_name);
int fd = open(abort, O_WRONLY);
if (fd == -1) {
continue;
}
if (write(fd, abort, 1) < 0) {
}
close(fd);
}
closedir(dir);
} else {
}
while (waitpid(-1, status, __WALL) != pid) {
}
}
static void reset_loop()
{
char buf[64];
snprintf(buf, sizeof(buf), "/dev/loop%llu", procid);
int loopfd = open(buf, O_RDWR);
if (loopfd != -1) {
ioctl(loopfd, LOOP_CLR_FD, 0);
close(loopfd);
}
}
static void setup_test()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
write_file("/proc/self/oom_score_adj", "1000");
}
struct thread_t {
int created, call;
event_t ready, done;
};
static struct thread_t threads[16];
static void execute_call(int call);
static int running;
static void* thr(void* arg)
{
struct thread_t* th = (struct thread_t*)arg;
for (;;) {
event_wait(&th->ready);
event_reset(&th->ready);
execute_call(th->call);
__atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
event_set(&th->done);
}
return 0;
}
static void execute_one(void)
{
int i, call, thread;
for (call = 0; call < 11; call++) {
for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0]));
thread++) {
struct thread_t* th = &threads[thread];
if (!th->created) {
th->created = 1;
event_init(&th->ready);
event_init(&th->done);
event_set(&th->done);
thread_start(thr, th);
}
if (!event_isset(&th->done))
continue;
event_reset(&th->done);
th->call = call;
__atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
event_set(&th->ready);
event_timedwait(&th->done, 45 + (call == 3 ? 50 : 0));
break;
}
}
for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++)
sleep_ms(1);
}
static void execute_one(void);
#define WAIT_FLAGS __WALL
static void loop(void)
{
int iter = 0;
for (;; iter++) {
char cwdbuf[32];
sprintf(cwdbuf, "./%d", iter);
if (mkdir(cwdbuf, 0777))
exit(1);
reset_loop();
int pid = fork();
if (pid < 0)
exit(1);
if (pid == 0) {
if (chdir(cwdbuf))
exit(1);
setup_test();
execute_one();
exit(0);
}
int status = 0;
uint64_t start = current_time_ms();
for (;;) {
if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
break;
sleep_ms(1);
if (current_time_ms() - start < 5 * 1000)
continue;
kill_and_wait(pid, &status);
break;
}
remove_dir(cwdbuf);
}
}
#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif
uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0,
0xffffffffffffffff};
void execute_call(int call)
{
intptr_t res = 0;
switch (call) {
case 0:
memcpy((void*)0x20000000, "/dev/loop#\000", 11);
res = -1;
res = syz_open_dev(0x20000000, 0, 0);
if (res != -1)
r[0] = res;
break;
case 1:
memcpy((void*)0x20000340,
"\020\001\000t\b\000\000\000|\021\000\377\001\000\000\000\000#"
"\000\000\000\000\000\000\306\263\251Y\006{\034!\350$"
"\322T\'\351\351\351n\v\v@\"Y9;\233kr}\215\331glv|\302\025\v`"
"\022\345\202\226\355\005rT\372\030\216\370\205\352\353\343\357^"
"\257\373\307",
83);
syscall(__NR_memfd_create, 0x20000340ul, 0ul);
break;
case 2:
*(uint32_t*)0x20000280 = 0x600;
*(uint16_t*)0x20000288 = 0x17e;
*(uint64_t*)0x20000290 = 0;
*(uint16_t*)0x20000298 = 0;
*(uint32_t*)0x200002a0 = 0;
*(uint32_t*)0x200002a4 = 1;
*(uint32_t*)0x200002a8 = 0x18;
*(uint32_t*)0x200002ac = 0xc;
memcpy((void*)0x200002b0,
"\xb0\x4a\x83\x70\x66\x94\xa7\x51\x54\xc6\x29\xf7\x5b\x71\xa9\x5a"
"\x8f\x3b\x28\x92\x71\xc6\x07\xad\xb2\x2d\x4d\x79\xc3\x01\x00\x7b"
"\x12\x91\xb1\x15\x0d\x4d\x3a\xa2\x0d\x7b\xee\xbc\x68\x9e\x92\x6d"
"\x5e\x29\x06\x79\xd1\x04\x2f\x1b\x38\xe9\xe8\xaf\x69\x4c\x0d\x43",
64);
memcpy((void*)0x200002f0, "\x52\x44\x53\x4b\x0f\x00\x08\x00\x57\x45\x56\x82"
"\x00\x00\xa4\x82\xeb\xf7\x88\x8c\x30\x5b\xee\x6f"
"\xd6\x00\x00\x00\x00\x00\xff\xff",
32);
*(uint64_t*)0x20000310 = 0;
*(uint64_t*)0x20000318 = 0;
*(uint32_t*)0x20000320 = 0;
syscall(__NR_ioctl, r[0], 0x4c02, 0x20000280ul);
break;
case 3:
memcpy((void*)0x20000000, "reiserfs\000", 9);
memcpy((void*)0x20000100, "./file0\000", 8);
*(uint64_t*)0x20000200 = 0x20010000;
memcpy((void*)0x20010000,
"\x00\x40\x00\x00\xec\x1f\x00\x00\x13\x20\x00\x00\x12\x00\x00\x00"
"\x00\x00\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x61\x1c\xad\x49"
"\xe1\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x10\xec\x03"
"\x02\x00\x01\x00\x52\x65\x49\x73\x45\x72\x33\x46\x73\x00\x00\x00"
"\x03\x00\x00\x00\x02\x00\x01\x00\x00\x00\x01\x20\x01\x00\x00\x00"
"\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x01\x00\x1e\x00\x3a\xc1\x65\x5f\x00\x4e\xed\x00",
128);
*(uint64_t*)0x20000208 = 0x80;
*(uint64_t*)0x20000210 = 0x10000;
*(uint64_t*)0x20000218 = 0x20010100;
memcpy(
(void*)0x20010100,
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00",
1056);
*(uint64_t*)0x20000220 = 0x420;
*(uint64_t*)0x20000228 = 0x11000;
*(uint64_t*)0x20000230 = 0x20010600;
*(uint64_t*)0x20000238 = 0;
*(uint64_t*)0x20000240 = 0x11800;
*(uint64_t*)0x20000248 = 0x20010e00;
memcpy((void*)0x20010e00,
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x12\x00\x00\x00"
"\x00\x00\x00\x00\x00\x20\x00\x00\x00\x01\x00\x00\x61\x1c\xad\x49"
"\xe1\x00\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
64);
*(uint64_t*)0x20000250 = 0x40;
*(uint64_t*)0x20000258 = 0x2012000;
*(uint64_t*)0x20000260 = 0x20010f00;
memcpy((void*)0x20010f00,
"\x01\x00\x02\x00\x75\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x20\x00\xe0\x0f\x00\x00"
"\x01\x00\x00\x00\x02\x00\x00\x00\x01\x00\x00\x00\xf4\x01\x00\x00"
"\x02\x00\x23\x00\xbd\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
96);
*(uint64_t*)0x20000268 = 0x60;
*(uint64_t*)0x20000270 = 0x2013000;
*(uint64_t*)0x20000278 = 0x20011000;
memcpy((void*)0x20011000,
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00"
"\x00\x01\x00\x00\x00\x02\x00\x00\x00\x22\x00\x04\x00\x02\x00\x00"
"\x00\x00\x00\x00\x00\x01\x00\x00\x00\x20\x00\x04\x00\x2e\x2e\x2e"
"\xed\x41\x03\x00\x5c\xf9\x53\x5f\x23\x00\x00\x00\x3a\xc1\x65\x5f"
"\x3a\xc1\x65\x5f\x3a\xc1\x65\x5f\x01\x00\x00\x00\xff\xff\xff\xff",
96);
*(uint64_t*)0x20000280 = 0x60;
*(uint64_t*)0x20000288 = 0x2013fa0;
*(uint8_t*)0x20011100 = 0;
syz_mount_image(0x20000000, 0x20000100, 0x4000000, 6, 0x20000200, 0,
0x20011100);
break;
case 4:
res = syscall(__NR_perf_event_open, 0ul, 0, 0ul, -1, 0ul);
if (res != -1)
r[1] = res;
break;
case 5:
res = syscall(__NR_getpid);
if (res != -1)
r[2] = res;
break;
case 6:
*(uint32_t*)0x200002c0 = 0;
syscall(__NR_sched_setscheduler, r[2], 0ul, 0x200002c0ul);
break;
case 7:
res = syscall(__NR_socket, 0x2bul, 1ul, 0);
if (res != -1)
r[3] = res;
break;
case 8:
syscall(__NR_sendmsg, -1, 0ul, 0ul);
break;
case 9:
syscall(__NR_dup2, r[1], r[3]);
break;
case 10:
syz_open_dev(0, 0x7f, 0);
break;
}
}
int main(void)
{
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
for (procid = 0; procid < 6; procid++) {
if (fork() == 0) {
use_temporary_dir();
loop();
}
}
sleep(1000000);
return 0;
}
|
the_stack_data/248579382.c | /*-
* Copyright (c) 2008-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <[email protected]>
*
* SPDX-License-Identifier: BSD-2-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#ifdef VTEST_WITH_VTC_VARNISH
#include "config.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <fnmatch.h>
#include <inttypes.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "vtc.h"
#include "vapi/vsc.h"
#include "vapi/vsl.h"
#include "vapi/vsm.h"
#include "vcli.h"
#include "vjsn.h"
#include "vre.h"
#include "vsub.h"
#include "vtcp.h"
#include "vtim.h"
struct varnish {
unsigned magic;
#define VARNISH_MAGIC 0x208cd8e3
char *name;
struct vtclog *vl;
VTAILQ_ENTRY(varnish) list;
struct vsb *args;
int fds[4];
pid_t pid;
double syntax;
pthread_t tp;
pthread_t tp_vsl;
int expect_exit;
int cli_fd;
int vcl_nbr;
char *workdir;
char *jail;
char *proto;
struct vsm *vsm_vsl;
struct vsm *vsm_vsc;
struct vsc *vsc;
int has_a_arg;
unsigned vsl_tag_count[256];
volatile int vsl_rec;
volatile int vsl_idle;
};
#define NONSENSE "%XJEIFLH|)Xspa8P"
static VTAILQ_HEAD(, varnish) varnishes =
VTAILQ_HEAD_INITIALIZER(varnishes);
/**********************************************************************
* Ask a question over CLI
*/
static enum VCLI_status_e
varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
{
int i;
unsigned retval;
char *r;
if (cmd != NULL) {
vtc_dump(v->vl, 4, "CLI TX", cmd, -1);
i = write(v->cli_fd, cmd, strlen(cmd));
if (i != strlen(cmd) && !vtc_stop)
vtc_fatal(v->vl, "CLI write failed (%s) = %u %s",
cmd, errno, strerror(errno));
i = write(v->cli_fd, "\n", 1);
if (i != 1 && !vtc_stop)
vtc_fatal(v->vl, "CLI write failed (%s) = %u %s",
cmd, errno, strerror(errno));
}
i = VCLI_ReadResult(v->cli_fd, &retval, &r, vtc_maxdur);
if (i != 0 && !vtc_stop)
vtc_fatal(v->vl, "CLI failed (%s) = %d %u %s",
cmd, i, retval, r);
vtc_log(v->vl, 3, "CLI RX %u", retval);
vtc_dump(v->vl, 4, "CLI RX", r, -1);
if (repl != NULL)
*repl = r;
else
free(r);
return ((enum VCLI_status_e)retval);
}
/**********************************************************************
*
*/
static void
wait_stopped(const struct varnish *v)
{
char *r = NULL;
enum VCLI_status_e st;
vtc_log(v->vl, 3, "wait-stopped");
while (1) {
st = varnish_ask_cli(v, "status", &r);
if (st != CLIS_OK)
vtc_fatal(v->vl,
"CLI status command failed: %u %s", st, r);
if (!strcmp(r, "Child in state stopped")) {
free(r);
break;
}
free(r);
r = NULL;
(void)usleep(200000);
}
}
/**********************************************************************
*
*/
static void
wait_running(const struct varnish *v)
{
char *r = NULL;
enum VCLI_status_e st;
while (1) {
vtc_log(v->vl, 3, "wait-running");
st = varnish_ask_cli(v, "status", &r);
if (st != CLIS_OK)
vtc_fatal(v->vl,
"CLI status command failed: %u %s", st, r);
if (!strcmp(r, "Child in state stopped"))
vtc_fatal(v->vl,
"Child stopped before running: %u %s", st, r);
if (!strcmp(r, "Child in state running")) {
free(r);
r = NULL;
st = varnish_ask_cli(v, "debug.listen_address", &r);
if (st != CLIS_OK)
vtc_fatal(v->vl,
"CLI status command failed: %u %s", st, r);
free(r);
break;
}
free(r);
r = NULL;
(void)usleep(200000);
}
}
/**********************************************************************
* Varnishlog gatherer thread
*/
static void
vsl_catchup(const struct varnish *v)
{
int vsl_idle;
vsl_idle = v->vsl_idle;
while (!vtc_error && vsl_idle == v->vsl_idle)
VTIM_sleep(0.1);
}
static void *
varnishlog_thread(void *priv)
{
struct varnish *v;
struct VSL_data *vsl;
struct vsm *vsm;
struct VSL_cursor *c;
enum VSL_tag_e tag;
uint32_t vxid;
unsigned len;
const char *tagname, *data;
int type, i, opt;
struct vsb *vsb = NULL;
CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC);
vsl = VSL_New();
AN(vsl);
vsm = v->vsm_vsl;
c = NULL;
opt = 0;
while (v->fds[1] > 0 || c != NULL) { //lint !e845 bug in flint
if (c == NULL) {
if (vtc_error)
break;
VTIM_sleep(0.1);
(void)VSM_Status(vsm);
c = VSL_CursorVSM(vsl, vsm, opt);
if (c == NULL) {
vtc_log(v->vl, 3, "vsl|%s", VSL_Error(vsl));
VSL_ResetError(vsl);
continue;
}
}
AN(c);
opt = VSL_COPT_TAIL;
while (1) {
i = VSL_Next(c);
if (i != 1)
break;
v->vsl_rec = 1;
tag = VSL_TAG(c->rec.ptr);
vxid = VSL_ID(c->rec.ptr);
if (tag == SLT__Batch)
continue;
tagname = VSL_tags[tag];
len = VSL_LEN(c->rec.ptr);
type = VSL_CLIENT(c->rec.ptr) ?
'c' : VSL_BACKEND(c->rec.ptr) ?
'b' : '-';
data = VSL_CDATA(c->rec.ptr);
v->vsl_tag_count[tag]++;
if (VSL_tagflags[tag] & SLT_F_BINARY) {
if (vsb == NULL)
vsb = VSB_new_auto();
VSB_clear(vsb);
VSB_quote(vsb, data, len, VSB_QUOTE_HEX);
AZ(VSB_finish(vsb));
/* +2 to skip "0x" */
vtc_log(v->vl, 4, "vsl| %10u %-15s %c [%s]",
vxid, tagname, type, VSB_data(vsb) + 2);
} else {
vtc_log(v->vl, 4, "vsl| %10u %-15s %c %.*s",
vxid, tagname, type, (int)len, data);
}
}
if (i == 0) {
/* Nothing to do but wait */
v->vsl_idle++;
if (!(VSM_Status(vsm) & VSM_WRK_RUNNING)) {
/* Abandoned - try reconnect */
VSL_DeleteCursor(c);
c = NULL;
} else {
VTIM_sleep(0.1);
}
} else if (i == -2) {
/* Abandoned - try reconnect */
VSL_DeleteCursor(c);
c = NULL;
} else
break;
}
if (c)
VSL_DeleteCursor(c);
VSL_Delete(vsl);
if (vsb != NULL)
VSB_destroy(&vsb);
return (NULL);
}
/**********************************************************************
* Allocate and initialize a varnish
*/
static struct varnish *
varnish_new(const char *name)
{
struct varnish *v;
struct vsb *vsb;
char buf[1024];
ALLOC_OBJ(v, VARNISH_MAGIC);
AN(v);
REPLACE(v->name, name);
REPLACE(v->jail, "");
v->vl = vtc_logopen(name);
AN(v->vl);
vsb = macro_expandf(v->vl, "${tmpdir}/%s", name);
AN(vsb);
v->workdir = strdup(VSB_data(vsb));
AN(v->workdir);
VSB_destroy(&vsb);
bprintf(buf, "rm -rf %s ; mkdir -p %s", v->workdir, v->workdir);
AZ(system(buf));
v->args = VSB_new_auto();
v->cli_fd = -1;
VTAILQ_INSERT_TAIL(&varnishes, v, list);
return (v);
}
/**********************************************************************
* Delete a varnish instance
*/
static void
varnish_delete(struct varnish *v)
{
CHECK_OBJ_NOTNULL(v, VARNISH_MAGIC);
vtc_logclose(v->vl);
free(v->name);
free(v->jail);
free(v->workdir);
VSB_destroy(&v->args);
if (v->vsc != NULL)
VSC_Destroy(&v->vsc, v->vsm_vsc);
if (v->vsm_vsc != NULL)
VSM_Destroy(&v->vsm_vsc);
if (v->vsm_vsl != NULL)
VSM_Destroy(&v->vsm_vsl);
/*
* We do not delete the workdir, it may contain stuff people
* want (coredumps, shmlog/stats etc), and trying to divine
* "may want" is just too much trouble. Leave it around and
* nuke it at the start of the next test-run.
*/
/* XXX: MEMLEAK (?) */
FREE_OBJ(v);
}
/**********************************************************************
* Varnish listener
*/
static void *
varnish_thread(void *priv)
{
struct varnish *v;
CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC);
return (vtc_record(v->vl, v->fds[0], NULL));
}
/**********************************************************************
* Launch a Varnish
*/
static void
varnish_launch(struct varnish *v)
{
struct vsb *vsb, *vsb1;
int i, nfd;
char abuf[128], pbuf[128];
struct pollfd fd[2];
enum VCLI_status_e u;
const char *err;
char *r = NULL;
/* Create listener socket */
v->cli_fd = VTCP_listen_on("127.0.0.1:0", NULL, 1, &err);
if (err != NULL)
vtc_fatal(v->vl, "Create CLI listen socket failed: %s", err);
assert(v->cli_fd > 0);
VTCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf);
AZ(VSB_finish(v->args));
vtc_log(v->vl, 2, "Launch");
vsb = VSB_new_auto();
AN(vsb);
VSB_cat(vsb, "cd ${pwd} &&");
VSB_printf(vsb, " exec varnishd %s -d -n %s",
v->jail, v->workdir);
VSB_cat(vsb, VSB_data(params_vsb));
if (leave_temp) {
VSB_cat(vsb, " -p debug=+vcl_keep");
VSB_cat(vsb, " -p debug=+vmod_so_keep");
VSB_cat(vsb, " -p debug=+vsm_keep");
}
VSB_cat(vsb, " -l 2m");
VSB_cat(vsb, " -p auto_restart=off");
VSB_cat(vsb, " -p syslog_cli_traffic=off");
VSB_cat(vsb, " -p sigsegv_handler=on");
VSB_cat(vsb, " -p thread_pool_min=10");
VSB_cat(vsb, " -p debug=+vtc_mode");
VSB_cat(vsb, " -p vsl_mask=+Debug");
if (!v->has_a_arg) {
VSB_printf(vsb, " -a '%s'", "127.0.0.1:0");
if (v->proto != NULL)
VSB_printf(vsb, ",%s", v->proto);
}
VSB_printf(vsb, " -M '%s %s'", abuf, pbuf);
VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir);
if (vmod_path != NULL)
VSB_printf(vsb, " -p vmod_path=%s", vmod_path);
VSB_printf(vsb, " %s", VSB_data(v->args));
AZ(VSB_finish(vsb));
vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb));
vsb1 = macro_expand(v->vl, VSB_data(vsb));
AN(vsb1);
VSB_destroy(&vsb);
vsb = vsb1;
vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb));
AZ(pipe(&v->fds[0]));
AZ(pipe(&v->fds[2]));
v->pid = fork();
assert(v->pid >= 0);
if (v->pid == 0) {
AZ(dup2(v->fds[0], 0));
assert(dup2(v->fds[3], 1) == 1);
assert(dup2(1, 2) == 2);
closefd(&v->fds[0]);
closefd(&v->fds[1]);
closefd(&v->fds[2]);
closefd(&v->fds[3]);
VSUB_closefrom(STDERR_FILENO + 1);
AZ(execl("/bin/sh", "/bin/sh", "-c", VSB_data(vsb), (char*)0));
exit(1);
} else {
vtc_log(v->vl, 3, "PID: %ld", (long)v->pid);
macro_def(v->vl, v->name, "pid", "%ld", (long)v->pid);
macro_def(v->vl, v->name, "name", "%s", v->workdir);
}
closefd(&v->fds[0]);
closefd(&v->fds[3]);
v->fds[0] = v->fds[2];
v->fds[2] = v->fds[3] = -1;
VSB_destroy(&vsb);
AZ(pthread_create(&v->tp, NULL, varnish_thread, v));
/* Wait for the varnish to call home */
memset(fd, 0, sizeof fd);
fd[0].fd = v->cli_fd;
fd[0].events = POLLIN;
fd[1].fd = v->fds[1];
fd[1].events = POLLIN;
i = poll(fd, 2, vtc_maxdur * 1000 / 3);
vtc_log(v->vl, 4, "CLIPOLL %d 0x%x 0x%x",
i, fd[0].revents, fd[1].revents);
if (i == 0)
vtc_fatal(v->vl, "FAIL timeout waiting for CLI connection");
if (fd[1].revents & POLLHUP)
vtc_fatal(v->vl, "FAIL debug pipe closed");
if (!(fd[0].revents & POLLIN))
vtc_fatal(v->vl, "FAIL CLI connection wait failure");
nfd = accept(v->cli_fd, NULL, NULL);
if (nfd < 0) {
closefd(&v->cli_fd);
vtc_fatal(v->vl, "FAIL no CLI connection accepted");
}
closefd(&v->cli_fd);
v->cli_fd = nfd;
vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd);
assert(v->cli_fd >= 0);
/* Receive the banner or auth response */
u = varnish_ask_cli(v, NULL, &r);
if (vtc_error)
return;
if (u != CLIS_AUTH)
vtc_fatal(v->vl, "CLI auth demand expected: %u %s", u, r);
bprintf(abuf, "%s/_.secret", v->workdir);
nfd = open(abuf, O_RDONLY);
assert(nfd >= 0);
assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 7);
bstrcpy(abuf, "auth ");
VCLI_AuthResponse(nfd, r, abuf + 5);
closefd(&nfd);
free(r);
r = NULL;
strcat(abuf, "\n");
u = varnish_ask_cli(v, abuf, &r);
if (vtc_error)
return;
if (u != CLIS_OK)
vtc_fatal(v->vl, "CLI auth command failed: %u %s", u, r);
free(r);
v->vsm_vsc = VSM_New();
AN(v->vsm_vsc);
v->vsc = VSC_New();
AN(v->vsc);
assert(VSM_Arg(v->vsm_vsc, 'n', v->workdir) > 0);
AZ(VSM_Attach(v->vsm_vsc, -1));
v->vsm_vsl = VSM_New();
assert(VSM_Arg(v->vsm_vsl, 'n', v->workdir) > 0);
AZ(VSM_Attach(v->vsm_vsl, -1));
AZ(pthread_create(&v->tp_vsl, NULL, varnishlog_thread, v));
}
/**********************************************************************
* Start a Varnish
*/
static void
varnish_start(struct varnish *v)
{
enum VCLI_status_e u;
char *resp = NULL, *h, *p;
if (v->cli_fd < 0)
varnish_launch(v);
if (vtc_error)
return;
vtc_log(v->vl, 2, "Start");
u = varnish_ask_cli(v, "start", &resp);
if (vtc_error)
return;
if (u != CLIS_OK)
vtc_fatal(v->vl, "CLI start command failed: %u %s", u, resp);
wait_running(v);
free(resp);
resp = NULL;
u = varnish_ask_cli(v, "debug.xid 999", &resp);
if (vtc_error)
return;
if (u != CLIS_OK)
vtc_fatal(v->vl, "CLI debug.xid command failed: %u %s",
u, resp);
free(resp);
resp = NULL;
u = varnish_ask_cli(v, "debug.listen_address", &resp);
if (vtc_error)
return;
if (u != CLIS_OK)
vtc_fatal(v->vl,
"CLI debug.listen_address command failed: %u %s", u, resp);
h = resp;
p = strchr(h, '\n');
if (p != NULL)
*p = '\0';
p = strchr(h, ' ');
AN(p);
*p++ = '\0';
vtc_log(v->vl, 2, "Listen on %s %s", h, p);
macro_def(v->vl, v->name, "addr", "%s", h);
macro_def(v->vl, v->name, "port", "%s", p);
macro_def(v->vl, v->name, "sock", "%s %s", h, p);
free(resp);
/* Wait for vsl logging to get underway */
while (v->vsl_rec == 0)
VTIM_sleep(.1);
}
/**********************************************************************
* Stop a Varnish
*/
static void
varnish_stop(struct varnish *v)
{
if (v->cli_fd < 0)
varnish_launch(v);
if (vtc_error)
return;
vtc_log(v->vl, 2, "Stop");
(void)varnish_ask_cli(v, "stop", NULL);
wait_stopped(v);
}
/**********************************************************************
* Cleanup
*/
static void
varnish_cleanup(struct varnish *v)
{
void *p;
/* Close the CLI connection */
closefd(&v->cli_fd);
/* Close the STDIN connection. */
closefd(&v->fds[1]);
/* Wait until STDOUT+STDERR closes */
AZ(pthread_join(v->tp, &p));
closefd(&v->fds[0]);
/* Pick up the VSL thread */
AZ(pthread_join(v->tp_vsl, &p));
vtc_wait4(v->vl, v->pid, v->expect_exit, 0, 0);
v->pid = 0;
}
/**********************************************************************
* Wait for a Varnish
*/
static void
varnish_wait(struct varnish *v)
{
if (v->cli_fd < 0)
return;
vtc_log(v->vl, 2, "Wait");
if (!vtc_error) {
/* Do a backend.list to log if child is still running */
(void)varnish_ask_cli(v, "backend.list", NULL);
}
/* Then stop it */
varnish_stop(v);
if (varnish_ask_cli(v, "panic.clear", NULL) != CLIS_CANT)
vtc_fatal(v->vl, "Unexpected panic");
varnish_cleanup(v);
}
/**********************************************************************
* Ask a CLI JSON question
*/
static void
varnish_cli_json(struct varnish *v, const char *cli)
{
enum VCLI_status_e u;
char *resp = NULL;
const char *errptr;
struct vjsn *vj;
if (v->cli_fd < 0)
varnish_launch(v);
if (vtc_error)
return;
u = varnish_ask_cli(v, cli, &resp);
vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli);
if (u != CLIS_OK)
vtc_fatal(v->vl,
"FAIL CLI response %u expected %u", u, CLIS_OK);
vj = vjsn_parse(resp, &errptr);
if (vj == NULL)
vtc_fatal(v->vl, "FAIL CLI, not good JSON: %s", errptr);
vjsn_delete(&vj);
free(resp);
}
/**********************************************************************
* Ask a CLI question
*/
static void
varnish_cli(struct varnish *v, const char *cli, unsigned exp, const char *re)
{
enum VCLI_status_e u;
vre_t *vre = NULL;
char *resp = NULL;
const char *errptr;
int err;
if (re != NULL) {
vre = VRE_compile(re, 0, &errptr, &err);
if (vre == NULL)
vtc_fatal(v->vl, "Illegal regexp");
}
if (v->cli_fd < 0)
varnish_launch(v);
if (vtc_error) {
if (vre != NULL)
VRE_free(&vre);
return;
}
u = varnish_ask_cli(v, cli, &resp);
vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli);
if (exp != 0 && exp != (unsigned)u)
vtc_fatal(v->vl, "FAIL CLI response %u expected %u", u, exp);
if (vre != NULL) {
err = VRE_exec(vre, resp, strlen(resp), 0, 0, NULL, 0, NULL);
if (err < 1)
vtc_fatal(v->vl, "Expect failed (%d)", err);
VRE_free(&vre);
}
free(resp);
}
/**********************************************************************
* Load a VCL program
*/
static void
varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp)
{
struct vsb *vsb;
enum VCLI_status_e u;
if (v->cli_fd < 0)
varnish_launch(v);
if (vtc_error)
return;
vsb = VSB_new_auto();
AN(vsb);
VSB_printf(vsb, "vcl.inline vcl%d << %s\nvcl %.1f;\n%s\n%s\n",
++v->vcl_nbr, NONSENSE, v->syntax, vcl, NONSENSE);
AZ(VSB_finish(vsb));
u = varnish_ask_cli(v, VSB_data(vsb), resp);
if (u == CLIS_OK) {
VSB_clear(vsb);
VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
AZ(VSB_finish(vsb));
u = varnish_ask_cli(v, VSB_data(vsb), NULL);
}
if (u == CLIS_OK && fail) {
VSB_destroy(&vsb);
vtc_fatal(v->vl, "VCL compilation succeeded expected failure");
} else if (u != CLIS_OK && !fail) {
VSB_destroy(&vsb);
vtc_fatal(v->vl, "VCL compilation failed expected success");
} else if (fail)
vtc_log(v->vl, 2, "VCL compilation failed (as expected)");
VSB_destroy(&vsb);
}
/**********************************************************************
* Load a VCL program prefixed by backend decls for our servers
*/
static void
varnish_vclbackend(struct varnish *v, const char *vcl)
{
struct vsb *vsb, *vsb2;
enum VCLI_status_e u;
if (v->cli_fd < 0)
varnish_launch(v);
if (vtc_error)
return;
vsb = VSB_new_auto();
AN(vsb);
vsb2 = VSB_new_auto();
AN(vsb2);
VSB_printf(vsb2, "vcl %.1f;\n", v->syntax);
cmd_server_gen_vcl(vsb2);
AZ(VSB_finish(vsb2));
VSB_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n%s\n",
++v->vcl_nbr, NONSENSE, VSB_data(vsb2), vcl, NONSENSE);
AZ(VSB_finish(vsb));
u = varnish_ask_cli(v, VSB_data(vsb), NULL);
if (u != CLIS_OK) {
VSB_destroy(&vsb);
VSB_destroy(&vsb2);
vtc_fatal(v->vl, "FAIL VCL does not compile");
}
VSB_clear(vsb);
VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr);
AZ(VSB_finish(vsb));
u = varnish_ask_cli(v, VSB_data(vsb), NULL);
assert(u == CLIS_OK);
VSB_destroy(&vsb);
VSB_destroy(&vsb2);
}
/**********************************************************************
*/
struct dump_priv {
const char *arg;
const struct varnish *v;
};
static int
do_stat_dump_cb(void *priv, const struct VSC_point * const pt)
{
const struct varnish *v;
struct dump_priv *dp;
uint64_t u;
if (pt == NULL)
return (0);
dp = priv;
v = dp->v;
if (strcmp(pt->ctype, "uint64_t"))
return (0);
u = *pt->ptr;
if (strcmp(dp->arg, "*")) {
if (fnmatch(dp->arg, pt->name, 0))
return (0);
}
vtc_log(v->vl, 4, "VSC %s %ju", pt->name, (uintmax_t)u);
return (0);
}
static void
varnish_vsc(const struct varnish *v, const char *arg)
{
struct dump_priv dp;
memset(&dp, 0, sizeof dp);
dp.v = v;
dp.arg = arg;
(void)VSM_Status(v->vsm_vsc);
(void)VSC_Iter(v->vsc, v->vsm_vsc, do_stat_dump_cb, &dp);
}
/**********************************************************************
* Check statistics
*/
struct stat_priv {
char target_pattern[256];
uintmax_t val;
const struct varnish *v;
};
static int
do_expect_cb(void *priv, const struct VSC_point * const pt)
{
struct stat_priv *sp = priv;
if (pt == NULL)
return (0);
if (fnmatch(sp->target_pattern, pt->name, 0))
return (0);
AZ(strcmp(pt->ctype, "uint64_t"));
AN(pt->ptr);
sp->val = *pt->ptr;
return (1);
}
/**********************************************************************
*/
static void
varnish_expect(const struct varnish *v, char * const *av)
{
uint64_t ref;
int good;
char *r;
char *p;
int i, not = 0;
struct stat_priv sp;
r = av[0];
if (r[0] == '!') {
not = 1;
r++;
AZ(av[1]);
} else {
AN(av[1]);
AN(av[2]);
}
p = strrchr(r, '.');
if (p == NULL) {
bprintf(sp.target_pattern, "MAIN.%s", r);
} else {
bprintf(sp.target_pattern, "%s", r);
}
sp.val = 0;
sp.v = v;
ref = 0;
good = 0;
for (i = 0; i < 50; i++, (void)usleep(100000)) {
(void)VSM_Status(v->vsm_vsc);
good = VSC_Iter(v->vsc, v->vsm_vsc, do_expect_cb, &sp);
if (!good) {
good = -2;
continue;
}
if (not)
vtc_fatal(v->vl, "Found (not expected): %s", av[0]+1);
good = 0;
ref = strtoumax(av[2], &p, 0);
if (ref == UINTMAX_MAX || *p)
vtc_fatal(v->vl, "Syntax error in number (%s)", av[2]);
if (!strcmp(av[1], "==")) { if (sp.val == ref) good = 1; }
else if (!strcmp(av[1], "!=")) { if (sp.val != ref) good = 1; }
else if (!strcmp(av[1], ">")) { if (sp.val > ref) good = 1; }
else if (!strcmp(av[1], "<")) { if (sp.val < ref) good = 1; }
else if (!strcmp(av[1], ">=")) { if (sp.val >= ref) good = 1; }
else if (!strcmp(av[1], "<=")) { if (sp.val <= ref) good = 1; }
else
vtc_fatal(v->vl, "comparison %s unknown", av[1]);
if (good)
break;
}
if (good == -1) {
vtc_fatal(v->vl, "VSM error: %s", VSM_Error(v->vsm_vsc));
}
if (good == -2) {
if (not) {
vtc_log(v->vl, 2, "not found (as expected): %s",
av[0] + 1);
return;
}
vtc_fatal(v->vl, "stats field %s unknown", av[0]);
}
if (good == 1) {
vtc_log(v->vl, 2, "as expected: %s (%ju) %s %s",
av[0], sp.val, av[1], av[2]);
} else {
vtc_fatal(v->vl, "Not true: %s (%ju) %s %s (%ju)",
av[0], (uintmax_t)sp.val, av[1], av[2], (uintmax_t)ref);
}
}
/* SECTION: varnish varnish
*
* Define and interact with varnish instances.
*
* To define a Varnish server, you'll use this syntax::
*
* varnish vNAME [-arg STRING] [-vcl STRING] [-vcl+backend STRING]
* [-errvcl STRING STRING] [-jail STRING] [-proto PROXY]
*
* The first ``varnish vNAME`` invocation will start the varnishd master
* process in the background, waiting for the ``-start`` switch to actually
* start the child.
*
* Types used in the description below:
*
* PATTERN
* is a 'glob' style pattern (ie: fnmatch(3)) as used in shell filename
* expansion.
*
* Arguments:
*
* vNAME
* Identify the Varnish server with a string, it must starts with 'v'.
*
* \-arg STRING
* Pass an argument to varnishd, for example "-h simple_list".
*
* \-vcl STRING
* Specify the VCL to load on this Varnish instance. You'll probably
* want to use multi-lines strings for this ({...}).
*
* \-vcl+backend STRING
* Do the exact same thing as -vcl, but adds the definition block of
* known backends (ie. already defined).
*
* \-errvcl STRING1 STRING2
* Load STRING2 as VCL, expecting it to fail, and Varnish to send an
* error string matching STRING2
*
* \-jail STRING
* Look at ``man varnishd`` (-j) for more information.
*
* \-proto PROXY
* Have Varnish use the proxy protocol. Note that PROXY here is the
* actual string.
*
* You can decide to start the Varnish instance and/or wait for several events::
*
* varnish vNAME [-start] [-wait] [-wait-running] [-wait-stopped]
*
* \-start
* Start the child process.
*
* \-stop
* Stop the child process.
*
* \-syntax
* Set the VCL syntax level for this command (default: 4.1)
*
* \-wait
* Wait for that instance to terminate.
*
* \-wait-running
* Wait for the Varnish child process to be started.
*
* \-wait-stopped
* Wait for the Varnish child process to stop.
*
* \-cleanup
* Once Varnish is stopped, clean everything after it. This is only used
* in very few tests and you should never need it.
*
* Once Varnish is started, you can talk to it (as you would through
* ``varnishadm``) with these additional switches::
*
* varnish vNAME [-cli STRING] [-cliok STRING] [-clierr STRING]
* [-clijson STRING] [-expect STRING OP NUMBER]
*
* \-cli STRING|-cliok STRING|-clierr STATUS STRING|-cliexpect REGEXP STRING
* All four of these will send STRING to the CLI, the only difference
* is what they expect the result to be. -cli doesn't expect
* anything, -cliok expects 200, -clierr expects STATUS, and
* -cliexpect expects the REGEXP to match the returned response.
*
* \-clijson STRING
* Send STRING to the CLI, expect success (CLIS_OK/200) and check
* that the response is parsable JSON.
*
* \-expect PATTERN OP NUMBER
* Look into the VSM and make sure the first VSC counter identified by
* PATTERN has a correct value. OP can be ==, >, >=, <, <=. For
* example::
*
* varnish v1 -expect SM?.s1.g_space > 1000000
* \-expectexit NUMBER
* Expect varnishd to exit(3) with this value
*
* \-vsc PATTERN
* Dump VSC counters matching PATTERN.
*
* \-vsl_catchup
* Wait until the logging thread has idled to make sure that all
* the generated log is flushed
*/
void
cmd_varnish(CMD_ARGS)
{
struct varnish *v, *v2;
(void)priv;
(void)cmd;
if (av == NULL) {
/* Reset and free */
VTAILQ_FOREACH_SAFE(v, &varnishes, list, v2) {
if (v->cli_fd >= 0)
varnish_wait(v);
VTAILQ_REMOVE(&varnishes, v, list);
varnish_delete(v);
}
return;
}
AZ(strcmp(av[0], "varnish"));
av++;
VTC_CHECK_NAME(vl, av[0], "Varnish", 'v');
VTAILQ_FOREACH(v, &varnishes, list)
if (!strcmp(v->name, av[0]))
break;
if (v == NULL)
v = varnish_new(av[0]);
av++;
v->syntax = 4.1;
for (; *av != NULL; av++) {
if (vtc_error)
break;
if (!strcmp(*av, "-arg")) {
AN(av[1]);
AZ(v->pid);
VSB_cat(v->args, " ");
VSB_cat(v->args, av[1]);
if (av[1][0] == '-' && av[1][1] == 'a')
v->has_a_arg = 1;
av++;
continue;
}
if (!strcmp(*av, "-cleanup")) {
AZ(av[1]);
varnish_cleanup(v);
continue;
}
if (!strcmp(*av, "-cli")) {
AN(av[1]);
varnish_cli(v, av[1], 0, NULL);
av++;
continue;
}
if (!strcmp(*av, "-clierr")) {
AN(av[1]);
AN(av[2]);
varnish_cli(v, av[2], atoi(av[1]), NULL);
av += 2;
continue;
}
if (!strcmp(*av, "-cliexpect")) {
AN(av[1]);
AN(av[2]);
varnish_cli(v, av[2], 0, av[1]);
av += 2;
continue;
}
if (!strcmp(*av, "-clijson")) {
AN(av[1]);
varnish_cli_json(v, av[1]);
av++;
continue;
}
if (!strcmp(*av, "-cliok")) {
AN(av[1]);
varnish_cli(v, av[1], (unsigned)CLIS_OK, NULL);
av++;
continue;
}
if (!strcmp(*av, "-errvcl")) {
char *r = NULL;
AN(av[1]);
AN(av[2]);
varnish_vcl(v, av[2], 1, &r);
if (strstr(r, av[1]) == NULL)
vtc_fatal(v->vl,
"Did not find expected string: (\"%s\")",
av[1]);
else
vtc_log(v->vl, 3,
"Found expected string: (\"%s\")",
av[1]);
free(r);
av += 2;
continue;
}
if (!strcmp(*av, "-expect")) {
av++;
varnish_expect(v, av);
av += 2;
continue;
}
if (!strcmp(*av, "-expectexit")) {
v->expect_exit = strtoul(av[1], NULL, 0);
av++;
continue;
}
if (!strcmp(*av, "-jail")) {
AN(av[1]);
AZ(v->pid);
REPLACE(v->jail, av[1]);
av++;
continue;
}
if (!strcmp(*av, "-proto")) {
AN(av[1]);
AZ(v->pid);
REPLACE(v->proto, av[1]);
av++;
continue;
}
if (!strcmp(*av, "-start")) {
varnish_start(v);
continue;
}
if (!strcmp(*av, "-stop")) {
varnish_stop(v);
continue;
}
if (!strcmp(*av, "-syntax")) {
AN(av[1]);
v->syntax = strtod(av[1], NULL);
av++;
continue;
}
if (!strcmp(*av, "-vcl")) {
AN(av[1]);
varnish_vcl(v, av[1], 0, NULL);
av++;
continue;
}
if (!strcmp(*av, "-vcl+backend")) {
AN(av[1]);
varnish_vclbackend(v, av[1]);
av++;
continue;
}
if (!strcmp(*av, "-vsc")) {
AN(av[1]);
varnish_vsc(v, av[1]);
av++;
continue;
}
if (!strcmp(*av, "-wait-stopped")) {
wait_stopped(v);
continue;
}
if (!strcmp(*av, "-wait-running")) {
wait_running(v);
continue;
}
if (!strcmp(*av, "-wait")) {
varnish_wait(v);
continue;
}
if (!strcmp(*av, "-vsl_catchup")) {
vsl_catchup(v);
continue;
}
vtc_fatal(v->vl, "Unknown varnish argument: %s", *av);
}
}
#endif /* VTEST_WITH_VTC_VARNISH */
|
the_stack_data/441759.c | // An iterative C program to print all numbers from 1
// to N without semicoolon
#include<stdio.h>
#define N 10
int main(int num, char *argv[])
{
while (num <= N && printf("%d ", num) && num++)
{
}
}
|
the_stack_data/148577191.c | /* ************************************************
SECOND= Cumulative CPU time for job in seconds. MKS unit is seconds.
Clock resolution should be less than 2% of Kernel 11 run-time.
ONLY CPU time should be measured, NO system or I/O time included.
In VM systems, page-fault time must be avoided (Direction 8).
SECOND accuracy may be tested by calling: CALIBR test.
Defing CLOCK_FUNCTION and/or BSD_TIMER on the compile line will
often produce a working timer routine. If not, you will need to
write your own. In addition, you should consider modifying
the timer routine if your system has a higher
resolution clock. The run time for the loops is shorter
when using a high resolution clock.
Timing routines with resolutions of order 1/60 second are typical on
PCs and workstations, and require the use
of multiple-pass loops around each kernel to make the run time
at least 50 times the tick-period of the timing routine.
Function SECOVT measures the overhead time for a call to SECOND.
An independent calibration of the running time may be wise.
Compare the Total Job Cpu Time printout at end of the LFK output file
with the job Cpu time charged by your operating system, if available.
The output written during the run provides a chance to check the
timing with a stopwatch.
USE THE HIGHEST RESOLUTION CPU-TIMER FUNCTION AVAILABLE
***********************************************************************
*/
#ifdef TIMEOFDAY
#define CLOCK_FUNCTION time_of_day
#define TICKS_PER_SEC 1
extern double time_of_day(void);
#endif
#ifdef _WIN32
#include <time.h>
#include <windows.h>
extern double get_time(void);
#define CLOCK_FUNCTION get_time
#define TICKS_PER_SEC 1
/* Defining USE_FANCY_CLOCK builds a version with a timer that is very
accurate on single processor Windows 95/98/NT computers, but it
gives incorrect answers on multi-processor NT systems. */
#define USE_FANCY_CLOCK
#endif
#ifdef ANSI_TIMER
#define CLOCK_FUNCTION clock
#endif
extern double second(double oldsec);
#ifndef CLOCK_FUNCTION
#ifdef BSD_TIMER
/* This will work on our Suns -- other BSD machines may differ?
sys/time.h includes time.h on Sun */
#include <sys/time.h>
#include <sys/resource.h>
double second(double oldsec)
{
double cpu, sys;
struct rusage cpuTime;
getrusage(RUSAGE_SELF, &cpuTime);
cpu= cpuTime.ru_utime.tv_sec + 1.0e-6*cpuTime.ru_utime.tv_usec;
sys= cpuTime.ru_stime.tv_sec + 1.0e-6*cpuTime.ru_stime.tv_usec;
return cpu+sys-oldsec;
}
#else /* Not BSD_TIMER */
/* Assume POSIX 1003.1-1990 standard timing interface.
However-- CLK_TCK is noted as "obsolescent" there... */
#include <time.h>
#include <sys/times.h>
/* Try to handle modest deviations from POSIX standard (e.g.- Sun). */
#ifndef CLK_TCK
#include <unistd.h>
#ifndef CLK_TCK
#define CLK_TCK sysconf(_SC_CLK_TCK)
#endif
#endif
double second(double oldsec)
{
static double ticksPerSecond= 0.0;
struct tms cpuTime;
long wallTicks= times(&cpuTime);
double cpu, sys;
if (ticksPerSecond==0.0) ticksPerSecond= CLK_TCK;
cpu= cpuTime.tms_utime/(double)ticksPerSecond;
sys= cpuTime.tms_stime/(double)ticksPerSecond;
return cpu+sys-oldsec;
}
#endif /* end of non BSD_TIMER branch */
#else /* Branch where CLOCK_FUNCTION is defined */
/* Define CLOCK_FUNCTION then modify the following version to suit
your architecture. See sysdep.h for other suggestions.
*/
#include <time.h>
double second(double oldsec)
{
return ((double)CLOCK_FUNCTION()) / ((double)TICKS_PER_SEC) - oldsec;
}
#endif
#ifdef MAC_CLOCK
double get_time(void)
{
/* WARNING: Mac doesn't distinguish between system and user time
(so count all time as user time) and it is totally wrong
if MultiFinder makes a switch while the program is being timed.
*/
double tim;
UnsignedWide microTickCount;
Microseconds(µTickCount);
tim= 1.0e-6*microTickCount.lo+1.0e-6*1024.0*1024.0*4096.0*microTickCount.hi;
return tim;
}
#endif /* MAC_CLOCK */
#ifdef _WIN32
/* WARNING: Use low resolution timer on a multi-processor Intel computer. */
double get_time(void)
{
/* WARNING: PC doesn't distinguish between system and user time
(so count all time as user time).
*/
#ifdef USE_FANCY_CLOCK
unsigned _int64 time64, ticksPerSecond;
QueryPerformanceCounter( (LARGE_INTEGER *)&time64);
QueryPerformanceFrequency( (LARGE_INTEGER *)&ticksPerSecond);
return ((double)(_int64)time64)/(_int64)ticksPerSecond;
#else
return (double)clock()/CLOCKS_PER_SEC;
#endif
}
#endif /* _WIN32 */
#ifdef TIMEOFDAY
#include <sys/time.h>
double time_of_day(void)
{
/* gettimeofday is a Posix timer that returns a "microsecond clock".
*/
double tim;
int err;
struct timeval time;
void *zone= 0;
err= gettimeofday(&time, zone);
tim= 1.0e-6*time.tv_usec+time.tv_sec;
return tim;
}
#endif /* TIMEOFDAY */
|
the_stack_data/151705338.c | // RUN: %clang_cc1 -no-opaque-pointers -fsanitize=implicit-unsigned-integer-truncation -fsanitize-recover=implicit-unsigned-integer-truncation -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_implicit_conversion" --check-prefixes=CHECK
// CHECK-DAG: @[[LINE_100_UNSIGNED_TRUNCATION:.*]] = {{.*}}, i32 100, i32 10 }, {{.*}}, {{.*}}, i8 1 }
// CHECK-DAG: @[[LINE_200_UNSIGNED_TRUNCATION:.*]] = {{.*}}, i32 200, i32 10 }, {{.*}}, {{.*}}, i8 1 }
// CHECK-LABEL: @ignorelist_0_convert_unsigned_int_to_unsigned_char
__attribute__((no_sanitize("undefined"))) unsigned char ignorelist_0_convert_unsigned_int_to_unsigned_char(unsigned int x) {
// We are not in "undefined" group, so that doesn't work.
// CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_100_UNSIGNED_TRUNCATION]] to i8*)
#line 100
return x;
}
// CHECK-LABEL: @ignorelist_1_convert_unsigned_int_to_unsigned_char
__attribute__((no_sanitize("integer"))) unsigned char ignorelist_1_convert_unsigned_int_to_unsigned_char(unsigned int x) {
return x;
}
// CHECK-LABEL: @ignorelist_2_convert_unsigned_int_to_unsigned_char
__attribute__((no_sanitize("implicit-conversion"))) unsigned char ignorelist_2_convert_unsigned_int_to_unsigned_char(unsigned int x) {
return x;
}
// CHECK-LABEL: @ignorelist_3_convert_unsigned_int_to_unsigned_char
__attribute__((no_sanitize("implicit-integer-truncation"))) unsigned char ignorelist_3_convert_unsigned_int_to_unsigned_char(unsigned int x) {
return x;
}
// CHECK-LABEL: @ignorelist_4_convert_unsigned_int_to_unsigned_char
__attribute__((no_sanitize("implicit-unsigned-integer-truncation"))) unsigned char ignorelist_4_convert_unsigned_int_to_unsigned_char(unsigned int x) {
return x;
}
// CHECK-LABEL: @ignorelist_5_convert_unsigned_int_to_unsigned_char
__attribute__((no_sanitize("implicit-signed-integer-truncation"))) unsigned char ignorelist_5_convert_unsigned_int_to_unsigned_char(unsigned int x) {
// This is an unsigned truncation, not signed-one.
// CHECK: call void @__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, {{{.*}}}*, i8 }* @[[LINE_200_UNSIGNED_TRUNCATION]] to i8*)
#line 200
return x;
}
|
the_stack_data/129546.c | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
//#include <linux/types.h>
//#include <linux/ipc.h>
//#include <linux/sem.h>
//----------------------------------------------------------------------------*/
/* 전처리기 선언
//----------------------------------------------------------------------------*/
#ifndef true
#define true (1)
#endif
#ifndef false
#define false (0)
#endif
#define SEVERITY_SUCCESS (0)
#define SEVERITY_ERROR (1)
#define THREAD_COUNT_MAX (2)
//----------------------------------------------------------------------------*/
union semun
{
int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */
unsigned short *array; /* array for GETALL & SETALL */
struct seminfo *__buf; /* buffer for IPC_INFO */
void *__pad;
};
//----------------------------------------------------------------------------*/
/* 전역 변수 / 함수 선언
//----------------------------------------------------------------------------*/
int SemaphoreID = 0;
void* ThreadFunction(void* Data);
//----------------------------------------------------------------------------*/
/* 엔트리 포인트
//----------------------------------------------------------------------------*/
int main(int argc, char** argv)
{
SemaphoreID = semget((key_t)3477,
1,
IPC_CREAT | 0666);
if(-1 == SemaphoreID)
{
return SEVERITY_ERROR;
}
union semun SemaphoreUnion;
SemaphoreUnion.val = 1;
int ResultSemaphoreControl = semctl(SemaphoreID,
0,
SETVAL,
SemaphoreUnion);
if(-1 == ResultSemaphoreControl)
{
return SEVERITY_ERROR;
}
pthread_t ThreadID[THREAD_COUNT_MAX] = { 0 };
int ThreadCount = 0;
for(int Index = 0; Index < THREAD_COUNT_MAX; ++Index)
{
int Result = pthread_create(&ThreadID[Index],
NULL,
ThreadFunction,
(void*)&ThreadCount);
printf("Create thread result : %d\n", Result);
usleep(5000);
}
while(true)
{
printf("Main Thread : %d\n", ThreadCount);
sleep(2);
}
for(int Index = 0; Index < THREAD_COUNT_MAX; ++Index)
{
pthread_join(ThreadID[Index], NULL);
}
return SEVERITY_SUCCESS;
}
//----------------------------------------------------------------------------*/
/* 스레드 별로 실행할 예제 함수
//----------------------------------------------------------------------------*/
void* ThreadFunction(void* Data)
{
struct sembuf SemaphoreOpen =
{
0,
-1,
SEM_UNDO
};
struct sembuf SemaphoreClose =
{
0,
1,
SEM_UNDO
};
int* Count = (int*)Data;
pthread_t ThreadID = pthread_self();
int Temp = 0;
while(true)
{
// 임계영역 설정
int Result = semop(SemaphoreID,
&SemaphoreOpen,
1);
if(-1 == Result)
{
return NULL;
}
// 임계영역 내 수행
Temp = *Count;
++Temp;
sleep(1);
(*Count) = Temp;
printf("Thread ID : %lu %d\n", ThreadID, *Count);
// 임계영역 해제
semop(SemaphoreID,
&SemaphoreClose,
1);
}
}
|
the_stack_data/190767292.c | /* This testcase is part of GDB, the GNU debugger.
Copyright 2009-2015 Free Software Foundation, Inc.
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/>. */
/* Architecture tests for intel i386 platform. */
void
sse_test (void)
{
char buf0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15};
char buf1[] = {16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31};
char buf2[] = {32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47};
asm ("movupd %0, %%xmm0":"=m"(buf0));
asm ("movupd %0, %%xmm1":"=m"(buf1));
asm ("movupd %0, %%xmm2":"=m"(buf2));
asm ("addpd %xmm0, %xmm1");
asm ("addps %xmm1, %xmm2");
asm ("addsd %xmm2, %xmm1");
asm ("addss %xmm1, %xmm0");
asm ("addsubpd %xmm0, %xmm2");
asm ("addsubps %xmm0, %xmm1");
asm ("andpd %xmm1, %xmm2");
asm ("andps %xmm2, %xmm1");
asm ("cmppd $3, %xmm0, %xmm1");
asm ("cmpps $4, %xmm1, %xmm2");
asm ("cmpsd $5, %xmm2, %xmm1");
asm ("cmpss $6, %xmm1, %xmm0");
asm ("comisd %xmm0, %xmm2");
asm ("comiss %xmm0, %xmm1");
asm ("cvtdq2pd %xmm1, %xmm2");
asm ("cvtdq2ps %xmm2, %xmm1");
asm ("cvtpd2dq %xmm1, %xmm0");
asm ("cvtpd2ps %xmm0, %xmm1");
asm ("divpd %xmm1, %xmm2");
asm ("divps %xmm2, %xmm1");
asm ("divsd %xmm1, %xmm0");
asm ("divss %xmm0, %xmm2");
asm ("mulpd %xmm0, %xmm1");
asm ("mulps %xmm1, %xmm2");
asm ("mulsd %xmm2, %xmm1");
asm ("mulss %xmm1, %xmm0");
asm ("orpd %xmm2, %xmm0");
asm ("orps %xmm0, %xmm1");
asm ("packsswb %xmm0, %xmm2");
asm ("packssdw %xmm0, %xmm1");
asm ("ucomisd %xmm1, %xmm2");
asm ("ucomiss %xmm2, %xmm1");
asm ("unpckhpd %xmm1, %xmm0");
asm ("unpckhps %xmm2, %xmm0");
asm ("xorpd %xmm0, %xmm1");
asm ("xorps %xmm1, %xmm2");
} /* end sse_test */
void
ssse3_test (void)
{
char buf0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15};
char buf1[] = {16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31};
char buf2[] = {32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47};
asm ("movupd %0, %%xmm0":"=m"(buf0));
asm ("movupd %0, %%xmm1":"=m"(buf1));
asm ("movupd %0, %%xmm2":"=m"(buf2));
asm ("pabsb %xmm1, %xmm2");
asm ("pabsw %xmm2, %xmm1");
asm ("pabsd %xmm1, %xmm0");
} /* end ssse3_test */
void
sse4_test (void)
{
char buf0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8,
9, 10, 11, 12, 13, 14, 15};
char buf1[] = {16, 17, 18, 19, 20, 21, 22, 23,
24, 25, 26, 27, 28, 29, 30, 31};
char buf2[] = {32, 33, 34, 35, 36, 37, 38, 39,
40, 41, 42, 43, 44, 45, 46, 47};
asm ("movupd %0, %%xmm0":"=m"(buf0));
asm ("movupd %0, %%xmm1":"=m"(buf1));
asm ("movupd %0, %%xmm2":"=m"(buf2));
asm ("blendpd $1, %xmm1, %xmm0");
asm ("blendps $2, %xmm2, %xmm0");
asm ("blendvpd %xmm0, %xmm1, %xmm2");
asm ("blendvps %xmm0, %xmm2, %xmm1");
} /* end sse4_test */
int
main ()
{
sse_test ();
ssse3_test ();
sse4_test ();
return 0; /* end of main */
}
|
the_stack_data/234518519.c | //
// Created by forgot on 2019-08-04.
//
/*1083 是否存在相等的差 (20 point(s))*/
/*给定 N 张卡片,正面分别写上 1、2、……、N,然后全部翻面,洗牌,在背面分别写上 1、2、……、N。将每张牌的正反两面数字相减(大减小),
* 得到 N 个非负差值,其中是否存在相等的差?
输入格式:
输入第一行给出一个正整数 N(2 ≤ N ≤ 10 000),随后一行给出 1 到 N 的一个洗牌后的排列,第 i 个数表示正面写了 i 的那张卡片背面的数字。
输出格式:
按照“差值 重复次数”的格式从大到小输出重复的差值及其重复的次数,每行输出一个结果。
输入样例:
8
3 5 8 6 2 1 4 7
输出样例:
5 2
3 3
2 2*/
#include <stdio.h>
//int main() {
// int N;
// scanf("%d", &N);
// int diffValueCount[10001] = {0};
//
// for (int i = 0; i < N; i++) {
// int front;
// int back = i + 1;
// scanf("%d", &front);
// int diffValue = front > back ? front - back : back - front;
// diffValueCount[diffValue]++;
// }
//
// for (int j = 10000; j >= 0; j--) {
//// 注意,大于1才算差值重复,才输出
// if (diffValueCount[j] >1) {
// printf("%d %d\n", j, diffValueCount[j]);
// }
// }
//
// return 0;
//} |
the_stack_data/182952810.c | // ==============================================================
// Vivado(TM) HLS - High-Level Synthesis from C, C++ and SystemC v2020.2 (64-bit)
// Copyright 1986-2020 Xilinx, Inc. All Rights Reserved.
// ==============================================================
#ifndef __linux__
#include "xstatus.h"
#include "xparameters.h"
#include "xisppipeline_accel.h"
extern XIsppipeline_accel_Config XIsppipeline_accel_ConfigTable[];
XIsppipeline_accel_Config *XIsppipeline_accel_LookupConfig(u16 DeviceId) {
XIsppipeline_accel_Config *ConfigPtr = NULL;
int Index;
for (Index = 0; Index < XPAR_XISPPIPELINE_ACCEL_NUM_INSTANCES; Index++) {
if (XIsppipeline_accel_ConfigTable[Index].DeviceId == DeviceId) {
ConfigPtr = &XIsppipeline_accel_ConfigTable[Index];
break;
}
}
return ConfigPtr;
}
int XIsppipeline_accel_Initialize(XIsppipeline_accel *InstancePtr, u16 DeviceId) {
XIsppipeline_accel_Config *ConfigPtr;
Xil_AssertNonvoid(InstancePtr != NULL);
ConfigPtr = XIsppipeline_accel_LookupConfig(DeviceId);
if (ConfigPtr == NULL) {
InstancePtr->IsReady = 0;
return (XST_DEVICE_NOT_FOUND);
}
return XIsppipeline_accel_CfgInitialize(InstancePtr, ConfigPtr);
}
#endif
|
the_stack_data/50139006.c | #include <stdio.h>
#include <pthread.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <strings.h>
void *read_func(void *arg)
{
char buf[128];
bzero(buf, sizeof(buf));
FILE *fp = fopen("./read.txt", "w+");
if(fp == NULL)
{
printf("fopen fail\n");
pthread_exit((void *)1);
}
while(1)
{
scanf("%s", buf);
fwrite(buf, sizeof(char), strlen(buf), fp);
fflush(fp);
if(!strncasecmp(buf, "quit", 4))
break;
//sleep(1);
bzero(buf, sizeof(buf));
}
printf("read_func exit\n");
pthread_exit((void *)0);
}
void *write_func(void *arg)
{
char buf[128];
bzero(buf, sizeof(buf));
FILE * fp1 = fopen("./read.txt", "r+");
if(fp1 == NULL)
{
printf("fopen fail\n");
pthread_exit((void *)1);
}
FILE *fp2 = fopen("./log.txt", "w+");
if(fp2 == NULL)
{
printf("fopen fail\n");
pthread_exit((void *)1);
}
while(1)
{
fread(buf, sizeof(char), sizeof(buf), fp1);
if(strlen(buf))
{
fwrite(buf, sizeof(char), strlen(buf), fp2);
fflush(fp2);
if(!strncasecmp(buf, "quit", 4))
{
break;
}
bzero(buf, sizeof(buf));
}
sleep(1);
//printf("buf = %s\n", buf);
}
printf("write_func exit\n");
pthread_exit((void *)0);
}
int main()
{
//memset(buf, 0, sizeof(buf));
pthread_t p_wrtie, p_read;
int retw = pthread_create(&p_wrtie, NULL, (void *)write_func, NULL);
if(retw != 0)
{
perror("pthread create");
return -1;
}
int retr = pthread_create(&p_read, NULL, (void *)read_func, NULL);
if(retr != 0)
{
perror("pthread create");
return -1;
}
void *ret_w_val, *ret_r_val;
pthread_join(p_wrtie, (void **)&ret_w_val);
pthread_join(p_read, (void **)&ret_r_val);
printf("main exit...\n");
return 0;
} |
the_stack_data/11075663.c | //===-- memmove.c ---------------------------------------------------------===//
//
// The KLEE Symbolic Virtual Machine
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include <stdlib.h>
void *memmove(void *dst, const void *src, size_t count) {
char *a = dst;
const char *b = src;
if (src == dst)
return dst;
if (src>dst) {
while (count--) *a++ = *b++;
} else {
a+=count-1;
b+=count-1;
while (count--) *a-- = *b--;
}
return dst;
}
|
the_stack_data/225142561.c | #include <ncurses.h>
int main(void)
{
int x;
char hamlet[5][46] = { "And by opposing end them?",
"Or to take arms against a sea of troubles,",
"The slings and arrows of outrageous fortune,",
"Whether 'tis nobler in the mind to suffer",
"To be, or not to be: that is the question:" };
initscr();
for(x=0;x<5;x++)
{
move(0,0);
insertln();
addstr(hamlet[x]);
refresh();
getch();
}
endwin();
return 0;
}
|
the_stack_data/15763084.c | /*
* Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the Apache License 2.0 (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
* in the file LICENSE in the source distribution or at
* https://www.openssl.org/source/license.html
*/
#if defined(_WIN32)
# include <windows.h>
#endif
#include <openssl/crypto.h>
#if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) && defined(OPENSSL_SYS_WINDOWS)
CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
{
CRYPTO_RWLOCK *lock;
if ((lock = OPENSSL_zalloc(sizeof(CRITICAL_SECTION))) == NULL) {
/* Don't set error, to avoid recursion blowup. */
return NULL;
}
# if !defined(_WIN32_WCE)
/* 0x400 is the spin count value suggested in the documentation */
if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) {
OPENSSL_free(lock);
return NULL;
}
# else
InitializeCriticalSection(lock);
# endif
return lock;
}
int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock)
{
EnterCriticalSection(lock);
return 1;
}
int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock)
{
EnterCriticalSection(lock);
return 1;
}
int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock)
{
LeaveCriticalSection(lock);
return 1;
}
void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock)
{
if (lock == NULL)
return;
DeleteCriticalSection(lock);
OPENSSL_free(lock);
return;
}
# define ONCE_UNINITED 0
# define ONCE_ININIT 1
# define ONCE_DONE 2
/*
* We don't use InitOnceExecuteOnce because that isn't available in WinXP which
* we still have to support.
*/
int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void))
{
LONG volatile *lock = (LONG *)once;
LONG result;
if (*lock == ONCE_DONE)
return 1;
do {
result = InterlockedCompareExchange(lock, ONCE_ININIT, ONCE_UNINITED);
if (result == ONCE_UNINITED) {
init();
*lock = ONCE_DONE;
return 1;
}
} while (result == ONCE_ININIT);
return (*lock == ONCE_DONE);
}
int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *))
{
*key = TlsAlloc();
if (*key == TLS_OUT_OF_INDEXES)
return 0;
return 1;
}
void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key)
{
DWORD last_error;
void *ret;
/*
* TlsGetValue clears the last error even on success, so that callers may
* distinguish it successfully returning NULL or failing. It is documented
* to never fail if the argument is a valid index from TlsAlloc, so we do
* not need to handle this.
*
* However, this error-mangling behavior interferes with the caller's use of
* GetLastError. In particular SSL_get_error queries the error queue to
* determine whether the caller should look at the OS's errors. To avoid
* destroying state, save and restore the Windows error.
*
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms686812(v=vs.85).aspx
*/
last_error = GetLastError();
ret = TlsGetValue(*key);
SetLastError(last_error);
return ret;
}
int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val)
{
if (TlsSetValue(*key, val) == 0)
return 0;
return 1;
}
int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key)
{
if (TlsFree(*key) == 0)
return 0;
return 1;
}
CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void)
{
return GetCurrentThreadId();
}
int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b)
{
return (a == b);
}
int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock)
{
*ret = (int)InterlockedExchangeAdd((long volatile *)val, (long)amount) + amount;
<<<<<<< HEAD
return 1;
}
int CRYPTO_atomic_or(uint64_t *val, uint64_t op, uint64_t *ret,
CRYPTO_RWLOCK *lock)
{
*ret = (uint64_t)InterlockedOr64((LONG64 volatile *)val, (LONG64)op) | op;
return 1;
}
int CRYPTO_atomic_load(uint64_t *val, uint64_t *ret, CRYPTO_RWLOCK *lock)
{
*ret = (uint64_t)InterlockedOr64((LONG64 volatile *)val, 0);
=======
>>>>>>> 6e3ba20dc49ccbf12ff4c27a4d8b84dcbeb71654
return 1;
}
int openssl_init_fork_handlers(void)
{
return 0;
}
int openssl_get_fork_id(void)
{
return 0;
}
#endif
|
the_stack_data/442982.c | void foo ()
{
int x1, x2, x3;
bar (&x2 - &x1, &x3 - &x2);
}
|
the_stack_data/143257.c | //*****************************************************************************
// strchr.c : string function
// 2002/02/04 by Gaku : this is rough sketch
//*****************************************************************************
#include <stddef.h>
//=============================================================================
// search D for C
//=============================================================================
char* GO_strchr (char *d, int c)
{
while (c != *d) {
if ('\0' == *d++)
return NULL;
}
return d;
}
|
the_stack_data/181393920.c | /* public domain rewrite of strerror(3) */
extern int sys_nerr;
extern char *sys_errlist[];
static char msg[50];
char *
strerror(int error)
{
if (error <= sys_nerr && error > 0) {
return sys_errlist[error];
}
sprintf(msg, "Unknown error (%d)", error);
return msg;
}
|
the_stack_data/45448936.c | /* prime finder, version 1.02
completed november 12 2007
version history
1.00: initial code
1.01: ignore numbers divisible by 2
1.01 appeared to crash, probably due
to some sort of overflow.
changed ints to long
*/
#include <stdio.h>
long number;
int result;
int main(void) {
//printf("hello\n");
printf("2\n"); // 2 is a prime, so it MUST be printed
result = 0;
for (number = 3; number < 10^6; number += 2) {
result = prime(number);
if (result == 1)
printf("%d\n", number);
}
return(0);
}
int prime(long prime) {
int i = 1;
int holder = 0;
int divisor = 1;
for (i; i < prime - 1; i++) {
divisor = (prime - i);
holder = prime % divisor;
if (holder == 0)
return(0);
}
return(1);
}
|
the_stack_data/134959.c | // general protection fault in skb_clone
// https://syzkaller.appspot.com/bug?id=0ddc4855f89da87f59777350563a486d8ef039d9
// status:fixed
// autogenerated by syzkaller (http://github.com/google/syzkaller)
#ifndef __NR_bpf
#define __NR_bpf 321
#endif
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/if_tun.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <net/if_arp.h>
#include <pthread.h>
#include <sched.h>
#include <setjmp.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <unistd.h>
const int kFailStatus = 67;
const int kRetryStatus = 69;
__attribute__((noreturn)) static void doexit(int status)
{
volatile unsigned i;
syscall(__NR_exit_group, status);
for (i = 0;; i++) {
}
}
__attribute__((noreturn)) static void fail(const char* msg, ...)
{
int e = errno;
fflush(stdout);
va_list args;
va_start(args, msg);
vfprintf(stderr, msg, args);
va_end(args);
fprintf(stderr, " (errno %d)\n", e);
doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus);
}
#define BITMASK_LEN(type, bf_len) (type)((1ull << (bf_len)) - 1)
#define BITMASK_LEN_OFF(type, bf_off, bf_len) \
(type)(BITMASK_LEN(type, (bf_len)) << (bf_off))
#define STORE_BY_BITMASK(type, addr, val, bf_off, bf_len) \
if ((bf_off) == 0 && (bf_len) == 0) { \
*(type*)(addr) = (type)(val); \
} else { \
type new_val = *(type*)(addr); \
new_val &= ~BITMASK_LEN_OFF(type, (bf_off), (bf_len)); \
new_val |= ((type)(val)&BITMASK_LEN(type, (bf_len))) << (bf_off); \
*(type*)(addr) = new_val; \
}
static __thread int skip_segv;
static __thread jmp_buf segv_env;
static void segv_handler(int sig, siginfo_t* info, void* uctx)
{
uintptr_t addr = (uintptr_t)info->si_addr;
const uintptr_t prog_start = 1 << 20;
const uintptr_t prog_end = 100 << 20;
if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) &&
(addr < prog_start || addr > prog_end)) {
_longjmp(segv_env, 1);
}
doexit(sig);
for (;;) {
}
}
static void install_segv_handler()
{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = SIG_IGN;
syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8);
syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8);
memset(&sa, 0, sizeof(sa));
sa.sa_sigaction = segv_handler;
sa.sa_flags = SA_NODEFER | SA_SIGINFO;
sigaction(SIGSEGV, &sa, NULL);
sigaction(SIGBUS, &sa, NULL);
}
#define NONFAILING(...) \
{ \
__atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \
if (_setjmp(segv_env) == 0) { \
__VA_ARGS__; \
} \
__atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \
}
static void use_temporary_dir()
{
char tmpdir_template[] = "./syzkaller.XXXXXX";
char* tmpdir = mkdtemp(tmpdir_template);
if (!tmpdir)
fail("failed to mkdtemp");
if (chmod(tmpdir, 0777))
fail("failed to chmod");
if (chdir(tmpdir))
fail("failed to chdir");
}
static void vsnprintf_check(char* str, size_t size, const char* format,
va_list args)
{
int rv;
rv = vsnprintf(str, size, format, args);
if (rv < 0)
fail("tun: snprintf failed");
if ((size_t)rv >= size)
fail("tun: string '%s...' doesn't fit into buffer", str);
}
static void snprintf_check(char* str, size_t size, const char* format,
...)
{
va_list args;
va_start(args, format);
vsnprintf_check(str, size, format, args);
va_end(args);
}
#define COMMAND_MAX_LEN 128
static void execute_command(const char* format, ...)
{
va_list args;
char command[COMMAND_MAX_LEN];
int rv;
va_start(args, format);
vsnprintf_check(command, sizeof(command), format, args);
rv = system(command);
if (rv != 0)
fail("tun: command \"%s\" failed with code %d", &command[0], rv);
va_end(args);
}
static int tunfd = -1;
#define SYZ_TUN_MAX_PACKET_SIZE 1000
#define MAX_PIDS 32
#define ADDR_MAX_LEN 32
#define LOCAL_MAC "aa:aa:aa:aa:aa:%02hx"
#define REMOTE_MAC "bb:bb:bb:bb:bb:%02hx"
#define LOCAL_IPV4 "172.20.%d.170"
#define REMOTE_IPV4 "172.20.%d.187"
#define LOCAL_IPV6 "fe80::%02hxaa"
#define REMOTE_IPV6 "fe80::%02hxbb"
static void initialize_tun(uint64_t pid)
{
if (pid >= MAX_PIDS)
fail("tun: no more than %d executors", MAX_PIDS);
int id = pid;
tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK);
if (tunfd == -1)
fail("tun: can't open /dev/net/tun");
char iface[IFNAMSIZ];
snprintf_check(iface, sizeof(iface), "syz%d", id);
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, iface, IFNAMSIZ);
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0)
fail("tun: ioctl(TUNSETIFF) failed");
char local_mac[ADDR_MAX_LEN];
snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC, id);
char remote_mac[ADDR_MAX_LEN];
snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC, id);
char local_ipv4[ADDR_MAX_LEN];
snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, id);
char remote_ipv4[ADDR_MAX_LEN];
snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, id);
char local_ipv6[ADDR_MAX_LEN];
snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, id);
char remote_ipv6[ADDR_MAX_LEN];
snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, id);
execute_command("sysctl -w net.ipv6.conf.%s.accept_dad=0", iface);
execute_command("sysctl -w net.ipv6.conf.%s.router_solicitations=0",
iface);
execute_command("ip link set dev %s address %s", iface, local_mac);
execute_command("ip addr add %s/24 dev %s", local_ipv4, iface);
execute_command("ip -6 addr add %s/120 dev %s", local_ipv6, iface);
execute_command("ip neigh add %s lladdr %s dev %s nud permanent",
remote_ipv4, remote_mac, iface);
execute_command("ip -6 neigh add %s lladdr %s dev %s nud permanent",
remote_ipv6, remote_mac, iface);
execute_command("ip link set dev %s up", iface);
}
static void setup_tun(uint64_t pid, bool enable_tun)
{
if (enable_tun)
initialize_tun(pid);
}
struct csum_inet {
uint32_t acc;
};
static void csum_inet_init(struct csum_inet* csum)
{
csum->acc = 0;
}
static void csum_inet_update(struct csum_inet* csum,
const uint8_t* data, size_t length)
{
if (length == 0)
return;
size_t i;
for (i = 0; i < length - 1; i += 2)
csum->acc += *(uint16_t*)&data[i];
if (length & 1)
csum->acc += (uint16_t)data[length - 1];
while (csum->acc > 0xffff)
csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16);
}
static uint16_t csum_inet_digest(struct csum_inet* csum)
{
return ~csum->acc;
}
static uintptr_t syz_emit_ethernet(uintptr_t a0, uintptr_t a1)
{
if (tunfd < 0)
return (uintptr_t)-1;
int64_t length = a0;
char* data = (char*)a1;
return write(tunfd, data, length);
}
static void loop();
static void sandbox_common()
{
prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
setpgrp();
setsid();
struct rlimit rlim;
rlim.rlim_cur = rlim.rlim_max = 128 << 20;
setrlimit(RLIMIT_AS, &rlim);
rlim.rlim_cur = rlim.rlim_max = 8 << 20;
setrlimit(RLIMIT_MEMLOCK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_FSIZE, &rlim);
rlim.rlim_cur = rlim.rlim_max = 1 << 20;
setrlimit(RLIMIT_STACK, &rlim);
rlim.rlim_cur = rlim.rlim_max = 0;
setrlimit(RLIMIT_CORE, &rlim);
unshare(CLONE_NEWNS);
unshare(CLONE_NEWIPC);
unshare(CLONE_IO);
}
static int do_sandbox_none(int executor_pid, bool enable_tun)
{
int pid = fork();
if (pid)
return pid;
sandbox_common();
setup_tun(executor_pid, enable_tun);
loop();
doexit(1);
}
static void test();
void loop()
{
while (1) {
test();
}
}
long r[72];
void* thr(void* arg)
{
switch ((long)arg) {
case 0:
r[0] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul,
0xfffffffffffffffful, 0x0ul);
break;
case 1:
NONFAILING(*(uint32_t*)0x20001fd0 = (uint32_t)0x0);
NONFAILING(*(uint32_t*)0x20001fd4 = (uint32_t)0x1);
NONFAILING(*(uint64_t*)0x20001fd8 = (uint64_t)0x20000000);
NONFAILING(*(uint64_t*)0x20001fe0 = (uint64_t)0x20fdbfef);
NONFAILING(*(uint32_t*)0x20001fe8 = (uint32_t)0x0);
NONFAILING(*(uint32_t*)0x20001fec = (uint32_t)0x0);
NONFAILING(*(uint64_t*)0x20001ff0 = (uint64_t)0x20b92fd0);
NONFAILING(*(uint32_t*)0x20001ff8 = (uint32_t)0x0);
NONFAILING(*(uint8_t*)0x20000000 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20000001 = (uint8_t)0x0);
NONFAILING(*(uint16_t*)0x20000002 = (uint16_t)0xfffffffffffff802);
NONFAILING(*(uint32_t*)0x20000004 = (uint32_t)0xffffffffffffffff);
NONFAILING(memcpy((void*)0x20fdbfef, "\x00", 1));
r[14] = syscall(__NR_bpf, 0x5ul, 0x20001fd0ul, 0x30ul);
break;
case 2:
r[15] = syscall(__NR_socket, 0x11ul, 0x802ul, 0x300ul);
break;
case 3:
r[16] = syscall(__NR_setsockopt, r[15], 0x107ul, 0x12ul,
0x20000000ul, 0x4ul);
break;
case 4:
NONFAILING(*(uint32_t*)0x20f87000 = (uint32_t)0x0);
r[18] = syscall(__NR_setsockopt, r[15], 0x1ul, 0x8ul, 0x20f87000ul,
0x4ul);
break;
case 5:
NONFAILING(
memcpy((void*)0x20ee9000, "\xef\xad\x07\x00\x00\xa7", 6));
NONFAILING(*(uint8_t*)0x20ee9006 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20ee9007 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20ee9008 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20ee9009 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20ee900a = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20ee900b = (uint8_t)0x0);
NONFAILING(*(uint16_t*)0x20ee900c = (uint16_t)0x0);
NONFAILING(*(uint16_t*)0x20ee900e = (uint16_t)0x300);
NONFAILING(*(uint8_t*)0x20ee9010 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x20ee9011 = (uint8_t)0x0);
NONFAILING(memcpy((void*)0x20ee9012, "\x1b", 1));
r[31] = syz_emit_ethernet(0x13ul, 0x20ee9000ul);
break;
case 6:
NONFAILING(*(uint8_t*)0x201b8000 = (uint8_t)0xaa);
NONFAILING(*(uint8_t*)0x201b8001 = (uint8_t)0xaa);
NONFAILING(*(uint8_t*)0x201b8002 = (uint8_t)0xaa);
NONFAILING(*(uint8_t*)0x201b8003 = (uint8_t)0xaa);
NONFAILING(*(uint8_t*)0x201b8004 = (uint8_t)0xaa);
NONFAILING(*(uint8_t*)0x201b8005 = (uint8_t)0x0);
NONFAILING(
memcpy((void*)0x201b8006, "\xde\x7a\x5d\xb3\x46\x9d", 6));
NONFAILING(*(uint16_t*)0x201b800c = (uint16_t)0x0);
NONFAILING(STORE_BY_BITMASK(uint8_t, 0x201b800e, 0x2, 0, 4));
NONFAILING(STORE_BY_BITMASK(uint8_t, 0x201b800e, 0x6, 4, 4));
NONFAILING(memcpy((void*)0x201b800f, "\xb8\x20\x04", 3));
NONFAILING(*(uint16_t*)0x201b8012 = (uint16_t)0x2f00);
NONFAILING(*(uint8_t*)0x201b8014 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8015 = (uint8_t)0x401);
NONFAILING(*(uint8_t*)0x201b8016 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8017 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8018 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8019 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b801a = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b801b = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b801c = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b801d = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b801e = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b801f = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8020 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8021 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8022 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8023 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8024 = (uint8_t)0x0);
NONFAILING(*(uint8_t*)0x201b8025 = (uint8_t)0x0);
NONFAILING(*(uint64_t*)0x201b8026 = (uint64_t)0x0);
NONFAILING(*(uint64_t*)0x201b802e = (uint64_t)0x100000000000000);
NONFAILING(*(uint8_t*)0x201b8036 = (uint8_t)0x80);
NONFAILING(*(uint8_t*)0x201b8037 = (uint8_t)0x0);
NONFAILING(*(uint16_t*)0x201b8038 = (uint16_t)0x0);
NONFAILING(*(uint16_t*)0x201b803a = (uint16_t)0xc1e6);
NONFAILING(*(uint16_t*)0x201b803c = (uint16_t)0x900);
NONFAILING(
memcpy((void*)0x201b803e,
"\x68\x82\xf1\xcb\x00\x9c\x0b\x91\x21\xfb\x2c\x61\x53"
"\xd0\x5b\x4b\x85\x33\x4c\x8b\xfc\xc7\x43\x45\x13\x3d"
"\xd3\x8a\x7c\x2a\x15\xab\xbc\x30\xf3\x02\x9c\x08\x41",
39));
struct csum_inet csum_70;
csum_inet_init(&csum_70);
NONFAILING(
csum_inet_update(&csum_70, (const uint8_t*)0x201b8016, 16));
NONFAILING(
csum_inet_update(&csum_70, (const uint8_t*)0x201b8026, 16));
uint32_t csum_70_chunk_2 = 0x2f000000;
csum_inet_update(&csum_70, (const uint8_t*)&csum_70_chunk_2, 4);
uint32_t csum_70_chunk_3 = 0x3a000000;
csum_inet_update(&csum_70, (const uint8_t*)&csum_70_chunk_3, 4);
NONFAILING(
csum_inet_update(&csum_70, (const uint8_t*)0x201b8036, 47));
NONFAILING(*(uint16_t*)0x201b8038 = csum_inet_digest(&csum_70));
r[71] = syz_emit_ethernet(0x65ul, 0x201b8000ul);
break;
}
return 0;
}
void test()
{
long i;
pthread_t th[14];
memset(r, -1, sizeof(r));
srand(getpid());
for (i = 0; i < 7; i++) {
pthread_create(&th[i], 0, thr, (void*)i);
usleep(rand() % 10000);
}
for (i = 0; i < 7; i++) {
pthread_create(&th[7 + i], 0, thr, (void*)i);
if (rand() % 2)
usleep(rand() % 10000);
}
usleep(rand() % 100000);
}
int main()
{
int i;
for (i = 0; i < 8; i++) {
if (fork() == 0) {
install_segv_handler();
use_temporary_dir();
int pid = do_sandbox_none(i, true);
int status = 0;
while (waitpid(pid, &status, __WALL) != pid) {
}
return 0;
}
}
sleep(1000000);
return 0;
}
|
the_stack_data/55522.c | /*
* TCP/IP or UDP/IP networking functions
* modified for LWIP support on ESP32
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* Additions Copyright (C) 2015 Angus Gratton
* 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)
*/
#if defined(CONFIG_SAL) || defined(CONFIG_TCPIP)
#if !defined(MBEDTLS_CONFIG_FILE)
#include "mbedtls/config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#if !defined(MBEDTLS_NET_C)
#if defined(MBEDTLS_NET_C_ALT)
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#include <stdlib.h>
#define mbedtls_calloc calloc
#define mbedtls_free free
#define mbedtls_time time
#define mbedtls_time_t time_t
#endif
#include "mbedtls/net_sockets.h"
#include <string.h>
#include <sys/types.h>
#include <sys/select.h>
#include <unistd.h>
#include <lwip/netdb.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <stdint.h>
/*
* Prepare for using the sockets interface
*/
static int net_prepare( void )
{
return ( 0 );
}
/*
* Initialize a context
*/
void mbedtls_net_init( mbedtls_net_context *ctx )
{
ctx->fd = -1;
}
/*
* Initiate a TCP connection with host:port and the given protocol
*/
int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto )
{
int ret;
struct addrinfo hints, *addr_list, *cur;
/* Do name resolution with both IPv6 and IPv4 */
memset( &hints, 0, sizeof( hints ) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = proto == MBEDTLS_NET_PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM;
hints.ai_protocol = proto == MBEDTLS_NET_PROTO_UDP ? IPPROTO_UDP : IPPROTO_TCP;
if( getaddrinfo( host, port, &hints, &addr_list ) != 0 )
return( MBEDTLS_ERR_NET_UNKNOWN_HOST );
/* Try the sockaddrs until a connection succeeds */
ret = MBEDTLS_ERR_NET_UNKNOWN_HOST;
for( cur = addr_list; cur != NULL; cur = cur->ai_next )
{
ctx->fd = (int) socket( cur->ai_family, cur->ai_socktype,
cur->ai_protocol );
if( ctx->fd < 0 )
{
ret = MBEDTLS_ERR_NET_SOCKET_FAILED;
continue;
}
#if 1
{
//FIXME: patch for connect may be block
int rc, flags, fd = ctx->fd;
flags = fcntl(fd, F_GETFL, 0);
rc = fcntl(fd, F_SETFL, O_NONBLOCK);
rc = connect( ctx->fd, cur->ai_addr, cur->ai_addrlen );
if (rc == 0) {
fcntl(fd, F_SETFL, flags);
ret = 0;
break;
}
if (errno == EISCONN) {
fcntl(fd, F_SETFL, flags);
ret = 0;
break;
} else if ((errno == EAGAIN) || (errno == EINPROGRESS)) {
fd_set fds;
struct timeval tv;
tv.tv_sec = 3;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(fd, &fds);
rc = select(fd + 1, NULL, &fds, NULL, &tv);
if (rc >= 1 && FD_ISSET(fd, &fds)) {
fcntl(fd, F_SETFL, flags);
ret = 0;
break;
}
}
}
#else
if( connect( ctx->fd, cur->ai_addr, cur->ai_addrlen ) == 0 )
{
ret = 0;
break;
}
#endif
close( ctx->fd );
ret = MBEDTLS_ERR_NET_CONNECT_FAILED;
}
freeaddrinfo( addr_list );
return( ret );
}
/*
* Create a listening socket on bind_ip:port
*/
int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto )
{
int ret;
struct addrinfo hints, *addr_list, *cur;
struct sockaddr_in *serv_addr = NULL;
#if SO_REUSE
int n = 1;
#endif
if ( ( ret = net_prepare() ) != 0 ) {
return ( ret );
}
/* Bind to IPv6 and/or IPv4, but only in the desired protocol */
memset( &hints, 0, sizeof( hints ) );
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = proto == MBEDTLS_NET_PROTO_UDP ? SOCK_DGRAM : SOCK_STREAM;
hints.ai_protocol = proto == MBEDTLS_NET_PROTO_UDP ? IPPROTO_UDP : IPPROTO_TCP;
if ( getaddrinfo( bind_ip, port, &hints, &addr_list ) != 0 ) {
return ( MBEDTLS_ERR_NET_UNKNOWN_HOST );
}
/* Try the sockaddrs until a binding succeeds */
ret = MBEDTLS_ERR_NET_UNKNOWN_HOST;
for ( cur = addr_list; cur != NULL; cur = cur->ai_next ) {
int fd = socket( cur->ai_family, cur->ai_socktype, cur->ai_protocol );
if ( fd < 0 ) {
ret = MBEDTLS_ERR_NET_SOCKET_FAILED;
continue;
}
/*SO_REUSEADDR option dafault is disable in source code(lwip)*/
#if SO_REUSE
if ( setsockopt( fd, SOL_SOCKET, SO_REUSEADDR,
(const char *) &n, sizeof( n ) ) != 0 ) {
close( fd );
ret = MBEDTLS_ERR_NET_SOCKET_FAILED;
continue;
}
#endif
/*bind interface dafault don't process the addr is 0xffffffff for TCP Protocol*/
serv_addr = (struct sockaddr_in *)cur->ai_addr;
serv_addr->sin_addr.s_addr = htonl(INADDR_ANY); /* Any incoming interface */
if ( bind( fd, (struct sockaddr *)serv_addr, cur->ai_addrlen ) != 0 ) {
close( fd );
ret = MBEDTLS_ERR_NET_BIND_FAILED;
continue;
}
/* Listen only makes sense for TCP */
if ( proto == MBEDTLS_NET_PROTO_TCP ) {
if ( listen( fd, MBEDTLS_NET_LISTEN_BACKLOG ) != 0 ) {
close( fd );
ret = MBEDTLS_ERR_NET_LISTEN_FAILED;
continue;
}
}
/* I we ever get there, it's a success */
ctx->fd = fd;
ret = 0;
break;
}
freeaddrinfo( addr_list );
return ( ret );
}
/*
* Check if the requested operation would be blocking on a non-blocking socket
* and thus 'failed' with a negative return value.
*
* Note: on a blocking socket this function always returns 0!
*/
static int net_would_block( const mbedtls_net_context *ctx )
{
int error = errno;
/*
* Never return 'WOULD BLOCK' on a non-blocking socket
*/
if ( ( fcntl( ctx->fd, F_GETFL, 0) & O_NONBLOCK ) != O_NONBLOCK ) {
errno = error;
return ( 0 );
}
switch ( errno = error ) {
#if defined EAGAIN
case EAGAIN:
#endif
#if defined EWOULDBLOCK && EWOULDBLOCK != EAGAIN
case EWOULDBLOCK:
#endif
return ( 1 );
}
return ( 0 );
}
/*
* Accept a connection from a remote client
*/
int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
mbedtls_net_context *client_ctx,
void *client_ip, size_t buf_size, size_t *ip_len )
{
int ret;
int type;
struct sockaddr_in client_addr;
socklen_t n = (socklen_t) sizeof( client_addr );
socklen_t type_len = (socklen_t) sizeof( type );
/* Is this a TCP or UDP socket? */
if ( getsockopt( bind_ctx->fd, SOL_SOCKET, SO_TYPE,
(void *) &type, (socklen_t *) &type_len ) != 0 ||
( type != SOCK_STREAM && type != SOCK_DGRAM ) ) {
return ( MBEDTLS_ERR_NET_ACCEPT_FAILED );
}
if ( type == SOCK_STREAM ) {
/* TCP: actual accept() */
ret = client_ctx->fd = (int) accept( bind_ctx->fd,
(struct sockaddr *) &client_addr, &n );
} else {
/* UDP: wait for a message, but keep it in the queue */
char buf[1] = { 0 };
ret = recvfrom( bind_ctx->fd, buf, sizeof( buf ), MSG_PEEK,
(struct sockaddr *) &client_addr, &n );
}
if ( ret < 0 ) {
if ( net_would_block( bind_ctx ) != 0 ) {
return ( MBEDTLS_ERR_SSL_WANT_READ );
}
return ( MBEDTLS_ERR_NET_ACCEPT_FAILED );
}
/* UDP: hijack the listening socket to communicate with the client,
* then bind a new socket to accept new connections */
if ( type != SOCK_STREAM ) {
struct sockaddr_in local_addr;
int one = 1;
if ( connect( bind_ctx->fd, (struct sockaddr *) &client_addr, n ) != 0 ) {
return ( MBEDTLS_ERR_NET_ACCEPT_FAILED );
}
client_ctx->fd = bind_ctx->fd;
bind_ctx->fd = -1; /* In case we exit early */
n = sizeof( struct sockaddr_in );
if ( getsockname( client_ctx->fd,
(struct sockaddr *) &local_addr, &n ) != 0 ||
( bind_ctx->fd = (int) socket( AF_INET,
SOCK_DGRAM, IPPROTO_UDP ) ) < 0 ||
setsockopt( bind_ctx->fd, SOL_SOCKET, SO_REUSEADDR,
(const char *) &one, sizeof( one ) ) != 0 ) {
return ( MBEDTLS_ERR_NET_SOCKET_FAILED );
}
if ( bind( bind_ctx->fd, (struct sockaddr *) &local_addr, n ) != 0 ) {
return ( MBEDTLS_ERR_NET_BIND_FAILED );
}
}
if ( client_ip != NULL ) {
struct sockaddr_in *addr4 = (struct sockaddr_in *) &client_addr;
*ip_len = sizeof( addr4->sin_addr.s_addr );
if ( buf_size < *ip_len ) {
return ( MBEDTLS_ERR_NET_BUFFER_TOO_SMALL );
}
memcpy( client_ip, &addr4->sin_addr.s_addr, *ip_len );
}
return ( 0 );
}
/*
* Set the socket blocking or non-blocking
*/
int mbedtls_net_set_block( mbedtls_net_context *ctx )
{
return ( fcntl( ctx->fd, F_SETFL, fcntl( ctx->fd, F_GETFL, 0 ) & ~O_NONBLOCK ) );
}
int mbedtls_net_set_nonblock( mbedtls_net_context *ctx )
{
return ( fcntl( ctx->fd, F_SETFL, fcntl( ctx->fd, F_GETFL, 0 ) | O_NONBLOCK ) );
}
/*
* Portable usleep helper
*/
void mbedtls_net_usleep( unsigned long usec )
{
struct timeval tv;
tv.tv_sec = usec / 1000000;
tv.tv_usec = usec % 1000000;
select( 0, NULL, NULL, NULL, &tv );
}
/*
* Read at most 'len' characters
*/
int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len )
{
int ret;
int fd = ((mbedtls_net_context *) ctx)->fd;
if( fd < 0 )
return( MBEDTLS_ERR_NET_INVALID_CONTEXT );
ret = (int) recv( fd, buf, len, 0);
// DBG("@@ret:%d, errno:%d", ret, errno);
if( ret < 0 )
{
// if( errno == EAGAIN )
// return( MBEDTLS_ERR_SSL_WANT_READ );
if( errno == EPIPE || errno == ECONNRESET )
return( MBEDTLS_ERR_NET_CONN_RESET );
if( errno == EINTR )
return( MBEDTLS_ERR_SSL_WANT_READ );
return( MBEDTLS_ERR_NET_RECV_FAILED );
}
return( ret );
}
/*
* Read at most 'len' characters, blocking for at most 'timeout' ms
*/
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
uint32_t timeout )
{
int ret;
struct timeval tv;
fd_set read_fds;
int fd = ((mbedtls_net_context *) ctx)->fd;
if( fd < 0 )
return( MBEDTLS_ERR_NET_INVALID_CONTEXT );
FD_ZERO( &read_fds );
FD_SET( fd, &read_fds );
tv.tv_sec = timeout / 1000;
tv.tv_usec = ( timeout % 1000 ) * 1000;
/* no wait if timeout == 0 */
ret = select( fd + 1, &read_fds, NULL, NULL, &tv );
// printf("%s, %d, select ret:%d\n", __func__, __LINE__, ret);
/* Zero fds ready means we timed out */
if( ret == 0 )
return( MBEDTLS_ERR_SSL_TIMEOUT );
if( ret < 0 )
{
if( errno == EINTR )
return( MBEDTLS_ERR_SSL_WANT_READ );
return( MBEDTLS_ERR_NET_RECV_FAILED );
}
/* This call will not block */
return( mbedtls_net_recv( ctx, buf, len ) );
}
/*
* Write at most 'len' characters
*/
int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len )
{
int ret;
int fd = ((mbedtls_net_context *) ctx)->fd;
ret = (int) send( fd, buf, len, 0);
if( ret < 0 )
{
if( errno == EPIPE || errno == ECONNRESET )
return( MBEDTLS_ERR_NET_CONN_RESET );
if( errno == EINTR )
return( MBEDTLS_ERR_SSL_WANT_WRITE );
return( MBEDTLS_ERR_NET_SEND_FAILED );
}
return( ret );
}
/*
* Gracefully close the connection
*/
void mbedtls_net_free( mbedtls_net_context *ctx )
{
if ( ctx->fd == -1 ) {
return;
}
shutdown( ctx->fd, 2 );
close( ctx->fd );
ctx->fd = -1;
}
#endif /* MBEDTLS_NET_C_ALT */
#endif /* MBEDTLS_NET_C */
#endif
|
the_stack_data/218893070.c | #define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <limits.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <fcntl.h>
#include <linux/unistd.h>
#include <linux/kcmp.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
static long sys_kcmp(int pid1, int pid2, int type, int fd1, int fd2)
{
return syscall(__NR_kcmp, pid1, pid2, type, fd1, fd2);
}
int main(int argc, char **argv)
{
const char kpath[] = "kcmp-test-file";
int pid1, pid2;
int fd1, fd2;
int status;
fd1 = open(kpath, O_RDWR | O_CREAT | O_TRUNC, 0644);
pid1 = getpid();
if (fd1 < 0) {
perror("Can't create file");
exit(1);
}
pid2 = fork();
if (pid2 < 0) {
perror("fork failed");
exit(1);
}
if (!pid2) {
int pid2 = getpid();
int ret;
fd2 = open(kpath, O_RDWR, 0644);
if (fd2 < 0) {
perror("Can't open file");
exit(1);
}
/* An example of output and arguments */
printf("pid1: %6d pid2: %6d FD: %2ld FILES: %2ld VM: %2ld "
"FS: %2ld SIGHAND: %2ld IO: %2ld SYSVSEM: %2ld "
"INV: %2ld\n",
pid1, pid2,
sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd2),
sys_kcmp(pid1, pid2, KCMP_FILES, 0, 0),
sys_kcmp(pid1, pid2, KCMP_VM, 0, 0),
sys_kcmp(pid1, pid2, KCMP_FS, 0, 0),
sys_kcmp(pid1, pid2, KCMP_SIGHAND, 0, 0),
sys_kcmp(pid1, pid2, KCMP_IO, 0, 0),
sys_kcmp(pid1, pid2, KCMP_SYSVSEM, 0, 0),
/* This one should fail */
sys_kcmp(pid1, pid2, KCMP_TYPES + 1, 0, 0));
/* This one should return same fd */
ret = sys_kcmp(pid1, pid2, KCMP_FILE, fd1, fd1);
if (ret) {
printf("FAIL: 0 expected but %d returned\n", ret);
ret = -1;
} else
printf("PASS: 0 returned as expected\n");
/* Compare with self */
ret = sys_kcmp(pid1, pid1, KCMP_VM, 0, 0);
if (ret) {
printf("FAIL: 0 expected but %li returned\n", ret);
ret = -1;
} else
printf("PASS: 0 returned as expected\n");
exit(ret);
}
waitpid(pid2, &status, P_ALL);
return 0;
}
|
the_stack_data/72264.c | int foo(int a, int b) {
int x = 0;
int y = 100; // range of y is [100..100]
int z = 100; // range of z is [100..100]
if (a) {
x = 0;
} else {
x = 10;
}
// range of x is [0..10]
y = x + 1; //range of y is [1..11]
z = x * y; // range of z is [0..110]
y = 5*x; // range of y is [0 .. 50]
if (z > y) {
//range of z is [1..110]
z = z - 80; //range of z is [-79..30]
}
// range of z is [0..50]if the branch is not taken
return z; //range of z is[-79..50]
}
/// Expected output
/// [-79..50]
|
the_stack_data/12637212.c | #include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <complex.h>
#ifdef complex
#undef complex
#endif
#ifdef I
#undef I
#endif
#if defined(_WIN64)
typedef long long BLASLONG;
typedef unsigned long long BLASULONG;
#else
typedef long BLASLONG;
typedef unsigned long BLASULONG;
#endif
#ifdef LAPACK_ILP64
typedef BLASLONG blasint;
#if defined(_WIN64)
#define blasabs(x) llabs(x)
#else
#define blasabs(x) labs(x)
#endif
#else
typedef int blasint;
#define blasabs(x) abs(x)
#endif
typedef blasint integer;
typedef unsigned int uinteger;
typedef char *address;
typedef short int shortint;
typedef float real;
typedef double doublereal;
typedef struct { real r, i; } complex;
typedef struct { doublereal r, i; } doublecomplex;
#ifdef _MSC_VER
static inline _Fcomplex Cf(complex *z) {_Fcomplex zz={z->r , z->i}; return zz;}
static inline _Dcomplex Cd(doublecomplex *z) {_Dcomplex zz={z->r , z->i};return zz;}
static inline _Fcomplex * _pCf(complex *z) {return (_Fcomplex*)z;}
static inline _Dcomplex * _pCd(doublecomplex *z) {return (_Dcomplex*)z;}
#else
static inline _Complex float Cf(complex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex double Cd(doublecomplex *z) {return z->r + z->i*_Complex_I;}
static inline _Complex float * _pCf(complex *z) {return (_Complex float*)z;}
static inline _Complex double * _pCd(doublecomplex *z) {return (_Complex double*)z;}
#endif
#define pCf(z) (*_pCf(z))
#define pCd(z) (*_pCd(z))
typedef int logical;
typedef short int shortlogical;
typedef char logical1;
typedef char integer1;
#define TRUE_ (1)
#define FALSE_ (0)
/* Extern is for use with -E */
#ifndef Extern
#define Extern extern
#endif
/* I/O stuff */
typedef int flag;
typedef int ftnlen;
typedef int ftnint;
/*external read, write*/
typedef struct
{ flag cierr;
ftnint ciunit;
flag ciend;
char *cifmt;
ftnint cirec;
} cilist;
/*internal read, write*/
typedef struct
{ flag icierr;
char *iciunit;
flag iciend;
char *icifmt;
ftnint icirlen;
ftnint icirnum;
} icilist;
/*open*/
typedef struct
{ flag oerr;
ftnint ounit;
char *ofnm;
ftnlen ofnmlen;
char *osta;
char *oacc;
char *ofm;
ftnint orl;
char *oblnk;
} olist;
/*close*/
typedef struct
{ flag cerr;
ftnint cunit;
char *csta;
} cllist;
/*rewind, backspace, endfile*/
typedef struct
{ flag aerr;
ftnint aunit;
} alist;
/* inquire */
typedef struct
{ flag inerr;
ftnint inunit;
char *infile;
ftnlen infilen;
ftnint *inex; /*parameters in standard's order*/
ftnint *inopen;
ftnint *innum;
ftnint *innamed;
char *inname;
ftnlen innamlen;
char *inacc;
ftnlen inacclen;
char *inseq;
ftnlen inseqlen;
char *indir;
ftnlen indirlen;
char *infmt;
ftnlen infmtlen;
char *inform;
ftnint informlen;
char *inunf;
ftnlen inunflen;
ftnint *inrecl;
ftnint *innrec;
char *inblank;
ftnlen inblanklen;
} inlist;
#define VOID void
union Multitype { /* for multiple entry points */
integer1 g;
shortint h;
integer i;
/* longint j; */
real r;
doublereal d;
complex c;
doublecomplex z;
};
typedef union Multitype Multitype;
struct Vardesc { /* for Namelist */
char *name;
char *addr;
ftnlen *dims;
int type;
};
typedef struct Vardesc Vardesc;
struct Namelist {
char *name;
Vardesc **vars;
int nvars;
};
typedef struct Namelist Namelist;
#define abs(x) ((x) >= 0 ? (x) : -(x))
#define dabs(x) (fabs(x))
#define f2cmin(a,b) ((a) <= (b) ? (a) : (b))
#define f2cmax(a,b) ((a) >= (b) ? (a) : (b))
#define dmin(a,b) (f2cmin(a,b))
#define dmax(a,b) (f2cmax(a,b))
#define bit_test(a,b) ((a) >> (b) & 1)
#define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
#define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
#define abort_() { sig_die("Fortran abort routine called", 1); }
#define c_abs(z) (cabsf(Cf(z)))
#define c_cos(R,Z) { pCf(R)=ccos(Cf(Z)); }
#ifdef _MSC_VER
#define c_div(c, a, b) {Cf(c)._Val[0] = (Cf(a)._Val[0]/Cf(b)._Val[0]); Cf(c)._Val[1]=(Cf(a)._Val[1]/Cf(b)._Val[1]);}
#define z_div(c, a, b) {Cd(c)._Val[0] = (Cd(a)._Val[0]/Cd(b)._Val[0]); Cd(c)._Val[1]=(Cd(a)._Val[1]/Cd(b)._Val[1]);}
#else
#define c_div(c, a, b) {pCf(c) = Cf(a)/Cf(b);}
#define z_div(c, a, b) {pCd(c) = Cd(a)/Cd(b);}
#endif
#define c_exp(R, Z) {pCf(R) = cexpf(Cf(Z));}
#define c_log(R, Z) {pCf(R) = clogf(Cf(Z));}
#define c_sin(R, Z) {pCf(R) = csinf(Cf(Z));}
//#define c_sqrt(R, Z) {*(R) = csqrtf(Cf(Z));}
#define c_sqrt(R, Z) {pCf(R) = csqrtf(Cf(Z));}
#define d_abs(x) (fabs(*(x)))
#define d_acos(x) (acos(*(x)))
#define d_asin(x) (asin(*(x)))
#define d_atan(x) (atan(*(x)))
#define d_atn2(x, y) (atan2(*(x),*(y)))
#define d_cnjg(R, Z) { pCd(R) = conj(Cd(Z)); }
#define r_cnjg(R, Z) { pCf(R) = conjf(Cf(Z)); }
#define d_cos(x) (cos(*(x)))
#define d_cosh(x) (cosh(*(x)))
#define d_dim(__a, __b) ( *(__a) > *(__b) ? *(__a) - *(__b) : 0.0 )
#define d_exp(x) (exp(*(x)))
#define d_imag(z) (cimag(Cd(z)))
#define r_imag(z) (cimagf(Cf(z)))
#define d_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define r_int(__x) (*(__x)>0 ? floor(*(__x)) : -floor(- *(__x)))
#define d_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define r_lg10(x) ( 0.43429448190325182765 * log(*(x)) )
#define d_log(x) (log(*(x)))
#define d_mod(x, y) (fmod(*(x), *(y)))
#define u_nint(__x) ((__x)>=0 ? floor((__x) + .5) : -floor(.5 - (__x)))
#define d_nint(x) u_nint(*(x))
#define u_sign(__a,__b) ((__b) >= 0 ? ((__a) >= 0 ? (__a) : -(__a)) : -((__a) >= 0 ? (__a) : -(__a)))
#define d_sign(a,b) u_sign(*(a),*(b))
#define r_sign(a,b) u_sign(*(a),*(b))
#define d_sin(x) (sin(*(x)))
#define d_sinh(x) (sinh(*(x)))
#define d_sqrt(x) (sqrt(*(x)))
#define d_tan(x) (tan(*(x)))
#define d_tanh(x) (tanh(*(x)))
#define i_abs(x) abs(*(x))
#define i_dnnt(x) ((integer)u_nint(*(x)))
#define i_len(s, n) (n)
#define i_nint(x) ((integer)u_nint(*(x)))
#define i_sign(a,b) ((integer)u_sign((integer)*(a),(integer)*(b)))
#define pow_dd(ap, bp) ( pow(*(ap), *(bp)))
#define pow_si(B,E) spow_ui(*(B),*(E))
#define pow_ri(B,E) spow_ui(*(B),*(E))
#define pow_di(B,E) dpow_ui(*(B),*(E))
#define pow_zi(p, a, b) {pCd(p) = zpow_ui(Cd(a), *(b));}
#define pow_ci(p, a, b) {pCf(p) = cpow_ui(Cf(a), *(b));}
#define pow_zz(R,A,B) {pCd(R) = cpow(Cd(A),*(B));}
#define s_cat(lpp, rpp, rnp, np, llp) { ftnlen i, nc, ll; char *f__rp, *lp; ll = (llp); lp = (lpp); for(i=0; i < (int)*(np); ++i) { nc = ll; if((rnp)[i] < nc) nc = (rnp)[i]; ll -= nc; f__rp = (rpp)[i]; while(--nc >= 0) *lp++ = *(f__rp)++; } while(--ll >= 0) *lp++ = ' '; }
#define s_cmp(a,b,c,d) ((integer)strncmp((a),(b),f2cmin((c),(d))))
#define s_copy(A,B,C,D) { int __i,__m; for (__i=0, __m=f2cmin((C),(D)); __i<__m && (B)[__i] != 0; ++__i) (A)[__i] = (B)[__i]; }
#define sig_die(s, kill) { exit(1); }
#define s_stop(s, n) {exit(0);}
static char junk[] = "\n@(#)LIBF77 VERSION 19990503\n";
#define z_abs(z) (cabs(Cd(z)))
#define z_exp(R, Z) {pCd(R) = cexp(Cd(Z));}
#define z_sqrt(R, Z) {pCd(R) = csqrt(Cd(Z));}
#define myexit_() break;
#define mycycle() continue;
#define myceiling(w) {ceil(w)}
#define myhuge(w) {HUGE_VAL}
//#define mymaxloc_(w,s,e,n) {if (sizeof(*(w)) == sizeof(double)) dmaxloc_((w),*(s),*(e),n); else dmaxloc_((w),*(s),*(e),n);}
#define mymaxloc(w,s,e,n) {dmaxloc_(w,*(s),*(e),n)}
/* procedure parameter types for -A and -C++ */
#define F2C_proc_par_types 1
#ifdef __cplusplus
typedef logical (*L_fp)(...);
#else
typedef logical (*L_fp)();
#endif
static float spow_ui(float x, integer n) {
float pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static double dpow_ui(double x, integer n) {
double pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
#ifdef _MSC_VER
static _Fcomplex cpow_ui(complex x, integer n) {
complex pow={1.0,0.0}; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x.r = 1/x.r, x.i=1/x.i;
for(u = n; ; ) {
if(u & 01) pow.r *= x.r, pow.i *= x.i;
if(u >>= 1) x.r *= x.r, x.i *= x.i;
else break;
}
}
_Fcomplex p={pow.r, pow.i};
return p;
}
#else
static _Complex float cpow_ui(_Complex float x, integer n) {
_Complex float pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
#endif
#ifdef _MSC_VER
static _Dcomplex zpow_ui(_Dcomplex x, integer n) {
_Dcomplex pow={1.0,0.0}; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x._Val[0] = 1/x._Val[0], x._Val[1] =1/x._Val[1];
for(u = n; ; ) {
if(u & 01) pow._Val[0] *= x._Val[0], pow._Val[1] *= x._Val[1];
if(u >>= 1) x._Val[0] *= x._Val[0], x._Val[1] *= x._Val[1];
else break;
}
}
_Dcomplex p = {pow._Val[0], pow._Val[1]};
return p;
}
#else
static _Complex double zpow_ui(_Complex double x, integer n) {
_Complex double pow=1.0; unsigned long int u;
if(n != 0) {
if(n < 0) n = -n, x = 1/x;
for(u = n; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
#endif
static integer pow_ii(integer x, integer n) {
integer pow; unsigned long int u;
if (n <= 0) {
if (n == 0 || x == 1) pow = 1;
else if (x != -1) pow = x == 0 ? 1/x : 0;
else n = -n;
}
if ((n > 0) || !(n == 0 || x == 1 || x != -1)) {
u = n;
for(pow = 1; ; ) {
if(u & 01) pow *= x;
if(u >>= 1) x *= x;
else break;
}
}
return pow;
}
static integer dmaxloc_(double *w, integer s, integer e, integer *n)
{
double m; integer i, mi;
for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
if (w[i-1]>m) mi=i ,m=w[i-1];
return mi-s+1;
}
static integer smaxloc_(float *w, integer s, integer e, integer *n)
{
float m; integer i, mi;
for(m=w[s-1], mi=s, i=s+1; i<=e; i++)
if (w[i-1]>m) mi=i ,m=w[i-1];
return mi-s+1;
}
static inline void cdotc_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Fcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conjf(Cf(&x[i]))._Val[0] * Cf(&y[i])._Val[0];
zdotc._Val[1] += conjf(Cf(&x[i]))._Val[1] * Cf(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conjf(Cf(&x[i*incx]))._Val[0] * Cf(&y[i*incy])._Val[0];
zdotc._Val[1] += conjf(Cf(&x[i*incx]))._Val[1] * Cf(&y[i*incy])._Val[1];
}
}
pCf(z) = zdotc;
}
#else
_Complex float zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conjf(Cf(&x[i])) * Cf(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conjf(Cf(&x[i*incx])) * Cf(&y[i*incy]);
}
}
pCf(z) = zdotc;
}
#endif
static inline void zdotc_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Dcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conj(Cd(&x[i]))._Val[0] * Cd(&y[i])._Val[0];
zdotc._Val[1] += conj(Cd(&x[i]))._Val[1] * Cd(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += conj(Cd(&x[i*incx]))._Val[0] * Cd(&y[i*incy])._Val[0];
zdotc._Val[1] += conj(Cd(&x[i*incx]))._Val[1] * Cd(&y[i*incy])._Val[1];
}
}
pCd(z) = zdotc;
}
#else
_Complex double zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conj(Cd(&x[i])) * Cd(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += conj(Cd(&x[i*incx])) * Cd(&y[i*incy]);
}
}
pCd(z) = zdotc;
}
#endif
static inline void cdotu_(complex *z, integer *n_, complex *x, integer *incx_, complex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Fcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cf(&x[i])._Val[0] * Cf(&y[i])._Val[0];
zdotc._Val[1] += Cf(&x[i])._Val[1] * Cf(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cf(&x[i*incx])._Val[0] * Cf(&y[i*incy])._Val[0];
zdotc._Val[1] += Cf(&x[i*incx])._Val[1] * Cf(&y[i*incy])._Val[1];
}
}
pCf(z) = zdotc;
}
#else
_Complex float zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cf(&x[i]) * Cf(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cf(&x[i*incx]) * Cf(&y[i*incy]);
}
}
pCf(z) = zdotc;
}
#endif
static inline void zdotu_(doublecomplex *z, integer *n_, doublecomplex *x, integer *incx_, doublecomplex *y, integer *incy_) {
integer n = *n_, incx = *incx_, incy = *incy_, i;
#ifdef _MSC_VER
_Dcomplex zdotc = {0.0, 0.0};
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cd(&x[i])._Val[0] * Cd(&y[i])._Val[0];
zdotc._Val[1] += Cd(&x[i])._Val[1] * Cd(&y[i])._Val[1];
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc._Val[0] += Cd(&x[i*incx])._Val[0] * Cd(&y[i*incy])._Val[0];
zdotc._Val[1] += Cd(&x[i*incx])._Val[1] * Cd(&y[i*incy])._Val[1];
}
}
pCd(z) = zdotc;
}
#else
_Complex double zdotc = 0.0;
if (incx == 1 && incy == 1) {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cd(&x[i]) * Cd(&y[i]);
}
} else {
for (i=0;i<n;i++) { /* zdotc = zdotc + dconjg(x(i))* y(i) */
zdotc += Cd(&x[i*incx]) * Cd(&y[i*incy]);
}
}
pCd(z) = zdotc;
}
#endif
/* -- translated by f2c (version 20000121).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
/* Table of constant values */
static integer c__1 = 1;
static doublereal c_b9 = -1.;
/* > \brief \b ZPBSTF */
/* =========== DOCUMENTATION =========== */
/* Online html documentation available at */
/* http://www.netlib.org/lapack/explore-html/ */
/* > \htmlonly */
/* > Download ZPBSTF + dependencies */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/zpbstf.
f"> */
/* > [TGZ]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/zpbstf.
f"> */
/* > [ZIP]</a> */
/* > <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/zpbstf.
f"> */
/* > [TXT]</a> */
/* > \endhtmlonly */
/* Definition: */
/* =========== */
/* SUBROUTINE ZPBSTF( UPLO, N, KD, AB, LDAB, INFO ) */
/* CHARACTER UPLO */
/* INTEGER INFO, KD, LDAB, N */
/* COMPLEX*16 AB( LDAB, * ) */
/* > \par Purpose: */
/* ============= */
/* > */
/* > \verbatim */
/* > */
/* > ZPBSTF computes a split Cholesky factorization of a complex */
/* > Hermitian positive definite band matrix A. */
/* > */
/* > This routine is designed to be used in conjunction with ZHBGST. */
/* > */
/* > The factorization has the form A = S**H*S where S is a band matrix */
/* > of the same bandwidth as A and the following structure: */
/* > */
/* > S = ( U ) */
/* > ( M L ) */
/* > */
/* > where U is upper triangular of order m = (n+kd)/2, and L is lower */
/* > triangular of order n-m. */
/* > \endverbatim */
/* Arguments: */
/* ========== */
/* > \param[in] UPLO */
/* > \verbatim */
/* > UPLO is CHARACTER*1 */
/* > = 'U': Upper triangle of A is stored; */
/* > = 'L': Lower triangle of A is stored. */
/* > \endverbatim */
/* > */
/* > \param[in] N */
/* > \verbatim */
/* > N is INTEGER */
/* > The order of the matrix A. N >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in] KD */
/* > \verbatim */
/* > KD is INTEGER */
/* > The number of superdiagonals of the matrix A if UPLO = 'U', */
/* > or the number of subdiagonals if UPLO = 'L'. KD >= 0. */
/* > \endverbatim */
/* > */
/* > \param[in,out] AB */
/* > \verbatim */
/* > AB is COMPLEX*16 array, dimension (LDAB,N) */
/* > On entry, the upper or lower triangle of the Hermitian band */
/* > matrix A, stored in the first kd+1 rows of the array. The */
/* > j-th column of A is stored in the j-th column of the array AB */
/* > as follows: */
/* > if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for f2cmax(1,j-kd)<=i<=j; */
/* > if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=f2cmin(n,j+kd). */
/* > */
/* > On exit, if INFO = 0, the factor S from the split Cholesky */
/* > factorization A = S**H*S. See Further Details. */
/* > \endverbatim */
/* > */
/* > \param[in] LDAB */
/* > \verbatim */
/* > LDAB is INTEGER */
/* > The leading dimension of the array AB. LDAB >= KD+1. */
/* > \endverbatim */
/* > */
/* > \param[out] INFO */
/* > \verbatim */
/* > INFO is INTEGER */
/* > = 0: successful exit */
/* > < 0: if INFO = -i, the i-th argument had an illegal value */
/* > > 0: if INFO = i, the factorization could not be completed, */
/* > because the updated element a(i,i) was negative; the */
/* > matrix A is not positive definite. */
/* > \endverbatim */
/* Authors: */
/* ======== */
/* > \author Univ. of Tennessee */
/* > \author Univ. of California Berkeley */
/* > \author Univ. of Colorado Denver */
/* > \author NAG Ltd. */
/* > \date December 2016 */
/* > \ingroup complex16OTHERcomputational */
/* > \par Further Details: */
/* ===================== */
/* > */
/* > \verbatim */
/* > */
/* > The band storage scheme is illustrated by the following example, when */
/* > N = 7, KD = 2: */
/* > */
/* > S = ( s11 s12 s13 ) */
/* > ( s22 s23 s24 ) */
/* > ( s33 s34 ) */
/* > ( s44 ) */
/* > ( s53 s54 s55 ) */
/* > ( s64 s65 s66 ) */
/* > ( s75 s76 s77 ) */
/* > */
/* > If UPLO = 'U', the array AB holds: */
/* > */
/* > on entry: on exit: */
/* > */
/* > * * a13 a24 a35 a46 a57 * * s13 s24 s53**H s64**H s75**H */
/* > * a12 a23 a34 a45 a56 a67 * s12 s23 s34 s54**H s65**H s76**H */
/* > a11 a22 a33 a44 a55 a66 a77 s11 s22 s33 s44 s55 s66 s77 */
/* > */
/* > If UPLO = 'L', the array AB holds: */
/* > */
/* > on entry: on exit: */
/* > */
/* > a11 a22 a33 a44 a55 a66 a77 s11 s22 s33 s44 s55 s66 s77 */
/* > a21 a32 a43 a54 a65 a76 * s12**H s23**H s34**H s54 s65 s76 * */
/* > a31 a42 a53 a64 a64 * * s13**H s24**H s53 s64 s75 * * */
/* > */
/* > Array elements marked * are not used by the routine; s12**H denotes */
/* > conjg(s12); the diagonal elements of S are real. */
/* > \endverbatim */
/* > */
/* ===================================================================== */
/* Subroutine */ int zpbstf_(char *uplo, integer *n, integer *kd,
doublecomplex *ab, integer *ldab, integer *info)
{
/* System generated locals */
integer ab_dim1, ab_offset, i__1, i__2, i__3;
doublereal d__1;
/* Local variables */
extern /* Subroutine */ int zher_(char *, integer *, doublereal *,
doublecomplex *, integer *, doublecomplex *, integer *);
integer j, m;
extern logical lsame_(char *, char *);
logical upper;
integer km;
extern /* Subroutine */ int xerbla_(char *, integer *, ftnlen), zdscal_(
integer *, doublereal *, doublecomplex *, integer *), zlacgv_(
integer *, doublecomplex *, integer *);
doublereal ajj;
integer kld;
/* -- LAPACK computational routine (version 3.7.0) -- */
/* -- LAPACK is a software package provided by Univ. of Tennessee, -- */
/* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..-- */
/* December 2016 */
/* ===================================================================== */
/* Test the input parameters. */
/* Parameter adjustments */
ab_dim1 = *ldab;
ab_offset = 1 + ab_dim1 * 1;
ab -= ab_offset;
/* Function Body */
*info = 0;
upper = lsame_(uplo, "U");
if (! upper && ! lsame_(uplo, "L")) {
*info = -1;
} else if (*n < 0) {
*info = -2;
} else if (*kd < 0) {
*info = -3;
} else if (*ldab < *kd + 1) {
*info = -5;
}
if (*info != 0) {
i__1 = -(*info);
xerbla_("ZPBSTF", &i__1, (ftnlen)6);
return 0;
}
/* Quick return if possible */
if (*n == 0) {
return 0;
}
/* Computing MAX */
i__1 = 1, i__2 = *ldab - 1;
kld = f2cmax(i__1,i__2);
/* Set the splitting point m. */
m = (*n + *kd) / 2;
if (upper) {
/* Factorize A(m+1:n,m+1:n) as L**H*L, and update A(1:m,1:m). */
i__1 = m + 1;
for (j = *n; j >= i__1; --j) {
/* Compute s(j,j) and test for non-positive-definiteness. */
i__2 = *kd + 1 + j * ab_dim1;
ajj = ab[i__2].r;
if (ajj <= 0.) {
i__2 = *kd + 1 + j * ab_dim1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
goto L50;
}
ajj = sqrt(ajj);
i__2 = *kd + 1 + j * ab_dim1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
/* Computing MIN */
i__2 = j - 1;
km = f2cmin(i__2,*kd);
/* Compute elements j-km:j-1 of the j-th column and update the */
/* the leading submatrix within the band. */
d__1 = 1. / ajj;
zdscal_(&km, &d__1, &ab[*kd + 1 - km + j * ab_dim1], &c__1);
zher_("Upper", &km, &c_b9, &ab[*kd + 1 - km + j * ab_dim1], &c__1,
&ab[*kd + 1 + (j - km) * ab_dim1], &kld);
/* L10: */
}
/* Factorize the updated submatrix A(1:m,1:m) as U**H*U. */
i__1 = m;
for (j = 1; j <= i__1; ++j) {
/* Compute s(j,j) and test for non-positive-definiteness. */
i__2 = *kd + 1 + j * ab_dim1;
ajj = ab[i__2].r;
if (ajj <= 0.) {
i__2 = *kd + 1 + j * ab_dim1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
goto L50;
}
ajj = sqrt(ajj);
i__2 = *kd + 1 + j * ab_dim1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
/* Computing MIN */
i__2 = *kd, i__3 = m - j;
km = f2cmin(i__2,i__3);
/* Compute elements j+1:j+km of the j-th row and update the */
/* trailing submatrix within the band. */
if (km > 0) {
d__1 = 1. / ajj;
zdscal_(&km, &d__1, &ab[*kd + (j + 1) * ab_dim1], &kld);
zlacgv_(&km, &ab[*kd + (j + 1) * ab_dim1], &kld);
zher_("Upper", &km, &c_b9, &ab[*kd + (j + 1) * ab_dim1], &kld,
&ab[*kd + 1 + (j + 1) * ab_dim1], &kld);
zlacgv_(&km, &ab[*kd + (j + 1) * ab_dim1], &kld);
}
/* L20: */
}
} else {
/* Factorize A(m+1:n,m+1:n) as L**H*L, and update A(1:m,1:m). */
i__1 = m + 1;
for (j = *n; j >= i__1; --j) {
/* Compute s(j,j) and test for non-positive-definiteness. */
i__2 = j * ab_dim1 + 1;
ajj = ab[i__2].r;
if (ajj <= 0.) {
i__2 = j * ab_dim1 + 1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
goto L50;
}
ajj = sqrt(ajj);
i__2 = j * ab_dim1 + 1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
/* Computing MIN */
i__2 = j - 1;
km = f2cmin(i__2,*kd);
/* Compute elements j-km:j-1 of the j-th row and update the */
/* trailing submatrix within the band. */
d__1 = 1. / ajj;
zdscal_(&km, &d__1, &ab[km + 1 + (j - km) * ab_dim1], &kld);
zlacgv_(&km, &ab[km + 1 + (j - km) * ab_dim1], &kld);
zher_("Lower", &km, &c_b9, &ab[km + 1 + (j - km) * ab_dim1], &kld,
&ab[(j - km) * ab_dim1 + 1], &kld);
zlacgv_(&km, &ab[km + 1 + (j - km) * ab_dim1], &kld);
/* L30: */
}
/* Factorize the updated submatrix A(1:m,1:m) as U**H*U. */
i__1 = m;
for (j = 1; j <= i__1; ++j) {
/* Compute s(j,j) and test for non-positive-definiteness. */
i__2 = j * ab_dim1 + 1;
ajj = ab[i__2].r;
if (ajj <= 0.) {
i__2 = j * ab_dim1 + 1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
goto L50;
}
ajj = sqrt(ajj);
i__2 = j * ab_dim1 + 1;
ab[i__2].r = ajj, ab[i__2].i = 0.;
/* Computing MIN */
i__2 = *kd, i__3 = m - j;
km = f2cmin(i__2,i__3);
/* Compute elements j+1:j+km of the j-th column and update the */
/* trailing submatrix within the band. */
if (km > 0) {
d__1 = 1. / ajj;
zdscal_(&km, &d__1, &ab[j * ab_dim1 + 2], &c__1);
zher_("Lower", &km, &c_b9, &ab[j * ab_dim1 + 2], &c__1, &ab[(
j + 1) * ab_dim1 + 1], &kld);
}
/* L40: */
}
}
return 0;
L50:
*info = j;
return 0;
/* End of ZPBSTF */
} /* zpbstf_ */
|
the_stack_data/92722.c | /*
* Copyright 2019 by Texas Instruments Incorporated.
*
*/
/*****************************************************************************/
/* BOOT_CORTEX_M.C v##### - Initialize the ARM C runtime environment */
/* Copyright (c) 2017@%%%% Texas Instruments Incorporated */
/*****************************************************************************/
#include <stdint.h>
#ifdef __TI_RTS_BUILD
/*---------------------------------------------------------------------------*/
/* __TI_default_c_int00 indicates that the default TI entry routine is being */
/* used. The linker makes assumptions about what exit does when this symbol */
/* is seen. This symbols should NOT be defined if a customized exit routine */
/* is used. */
/*---------------------------------------------------------------------------*/
__asm("__TI_default_c_int00 .set 1");
#endif
/*----------------------------------------------------------------------------*/
/* Define the user mode stack. The size will be determined by the linker. */
/*----------------------------------------------------------------------------*/
__attribute__((section(".stack")))
int __stack;
/*----------------------------------------------------------------------------*/
/* Linker defined symbol that will point to the end of the user mode stack. */
/* The linker will enforce 8-byte alignment. */
/*----------------------------------------------------------------------------*/
extern int __STACK_END;
/*----------------------------------------------------------------------------*/
/* Function declarations. */
/*----------------------------------------------------------------------------*/
__attribute__((weak)) extern void __mpu_init(void);
extern int _system_pre_init(void);
extern void __TI_auto_init(void);
extern void _args_main(void);
extern void exit(int);
extern int main();
__attribute__((noreturn))
extern void xdc_runtime_System_exit__E(int);
/*----------------------------------------------------------------------------*/
/* Default boot routine for Cortex-M */
/*----------------------------------------------------------------------------*/
static __inline __attribute__((always_inline, noreturn))
void _c_int00_template(int NEEDS_ARGS, int NEEDS_INIT)
{
// Initialize the stack pointer
register char* stack_ptr = (char*)&__STACK_END;
__asm volatile ("MSR msp, %0" : : "r" (stack_ptr) : );
// Initialize the FPU if building for floating point
#ifdef __ARM_FP
volatile uint32_t* cpacr = (volatile uint32_t*)0xE000ED88;
*cpacr |= (0xf0 << 16);
#endif
__mpu_init();
if (_system_pre_init())
{
if (NEEDS_INIT)
__TI_auto_init();
}
if (NEEDS_ARGS) {
_args_main();
xdc_runtime_System_exit__E(0);
}
else {
xdc_runtime_System_exit__E(main());
}
}
/******************************************************************************/
/* Specializations */
/******************************************************************************/
__attribute__((section(".text:_c_int00"), used, noreturn))
void _c_int00(void)
{
_c_int00_template(1, 1);
}
__attribute__((section(".text:_c_int00_noargs"), used, noreturn))
void _c_int00_noargs(void)
{
_c_int00_template(0, 1);
}
__attribute__((section(".text:_c_int00_noinit"), used, noreturn))
void _c_int00_noinit(void)
{
_c_int00_template(1, 0);
}
__attribute__((section(".text:_c_int00_noinit_noargs"), used, noreturn))
void _c_int00_noinit_noargs(void)
{
_c_int00_template(0, 0);
}
/*
* @(#) ti.targets.arm.rtsarm; 1, 0, 0,0; 8-9-2019 17:26:43; /db/ztree/library/trees/xdctargets/xdctargets-v00/src/ xlibrary
*/
|
the_stack_data/4194.c | /* perching-panda.c
*
* Copyright 2021 Goutham Krishna K V
*
* 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 X CONSORTIUM BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
* Except as contained in this notice, the name(s) of the above copyright
* holders shall not be used in advertising or otherwise to promote the sale,
* use or other dealings in this Software without prior written
* authorization.
*/
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
struct hashcell_node {
int content;
struct hashcell_node *next;
};
struct hashcell_node *hashcell_node_create(int content,
struct hashcell_node *next)
{
struct hashcell_node *newnode =
(struct hashcell_node*)malloc(sizeof(struct hashcell_node));
newnode->content = content;
newnode->next = next;
return newnode;
}
struct hashcell_node *hashcell_node_destroy(struct hashcell_node *node)
{
if (node != NULL) {
struct hashcell_node *next_node = node->next;
free(node);
return next_node;
}
return NULL;
}
struct hashcell {
struct hashcell_node *top;
size_t length;
};
struct hashcell *hashcell_create() {
struct hashcell *newcell =
(struct hashcell*)malloc(sizeof(struct hashcell));
newcell->top = NULL;
newcell->length = 0;
return newcell;
}
void hashcell_destroy(struct hashcell *cell)
{
if (cell != NULL)
{
struct hashcell_node *topval = cell->top;
while (topval != NULL && cell->length > 0)
{
topval = hashcell_node_destroy (topval);
}
free(cell);
}
}
bool hashcell_insert(struct hashcell *cell, int ele)
{
if (cell != NULL)
{
cell->top = hashcell_node_create (ele, cell->top);
cell->length++;
return true;
}
return false;
}
void hashcell_print(struct hashcell *cell)
{
if (cell != NULL)
{
struct hashcell_node *current = cell->top;
while (current != NULL)
{
printf("%d ", current->content);
current = current->next;
}
printf("\n");
}
}
struct hashset {
struct hashcell *elements;
size_t length;
};
struct hashset *hashset_create(size_t length) {
struct hashset *newset =
(struct hashset*)malloc (sizeof(struct hashset));
newset->elements = (struct hashcell*)malloc(sizeof(struct hashcell) * length);
newset->length = length;
return newset;
}
void hashset_destroy(struct hashset* set)
{
if (set != NULL)
{
if (set->elements != NULL)
{
for(size_t i = 0; i < set->length; i++)
{
hashcell_destroy (&set->elements[i]);
}
free(set->elements);
}
free(set);
}
}
void hashset_insert(struct hashset *set, int ele)
{
size_t hashset_ins = (size_t)ele % set->length;
hashcell_insert(&set->elements[hashset_ins], ele);
}
void hashset_print(struct hashset *set)
{
if (set != NULL)
{
for(size_t i = 0; i < set->length; i++)
{
printf("%zu: ", i);
hashcell_print (&set->elements[i]);
}
}
}
int
main (
// int argc,
// char *argv[]
)
{
int arr[] = {1,2,67,3,5,734,6,4,23,324,245,2357};
struct hashset *set = hashset_create (21);
for(size_t i = 0; i < 12; i++)
{
hashset_insert (set, arr[i]);
}
hashset_print(set);
return (0);
}
|
the_stack_data/35959.c |
#if defined(MPT_BUILD_WINESUPPORT_WRAPPER)
#include "NativeConfig.h"
#include <windows.h>
#include <stdint.h>
#include "Native.h"
#include "NativeUtils.h"
#include "NativeSoundDevice.h"
#ifdef _MSC_VER
#pragma warning(disable:4098) /* 'void' function returning a value */
#endif
#define WINE_THREAD
#ifdef __cplusplus
extern "C" {
#endif
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_Init(void) {
return OpenMPT_Init();
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_Fini(void) {
return OpenMPT_Fini();
}
OPENMPT_WINESUPPORT_WRAPPER_API void * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_Alloc( size_t size ) {
return OpenMPT_Alloc( size );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_Free( void * mem ) {
return OpenMPT_Free( mem );
}
OPENMPT_WINESUPPORT_WRAPPER_API size_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_String_Length( const char * str ) {
return OpenMPT_String_Length( str );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_String_Duplicate( const char * src ) {
return OpenMPT_String_Duplicate( src );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_String_Free( char * str ) {
return OpenMPT_String_Free( str );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_EnumerateDevices() {
return OpenMPT_SoundDevice_EnumerateDevices();
}
typedef struct OpenMPT_Wine_Wrapper_SoundDevice_IMessageReceiver {
void * inst;
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundDeviceMessageFunc)( void * inst, uintptr_t level, const char * message );
} OpenMPT_Wine_Wrapper_SoundDevice_IMessageReceiver;
typedef struct OpenMPT_Wine_Wrapper_SoundDevice_ISource {
void * inst;
// main thread
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceGetReferenceClockNowNanosecondsFunc)( void * inst, uint64_t * result );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourcePreStartCallbackFunc)( void * inst );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourcePostStopCallbackFunc)( void * inst );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceIsLockedByCurrentThreadFunc)( void * inst, uintptr_t * result );
// audio thread
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceLockFunc)( void * inst );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceLockedGetReferenceClockNowNanosecondsFunc)( void * inst, uint64_t * result );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceLockedReadPrepareFunc)( void * inst, const OpenMPT_SoundDevice_TimeInfo * timeInfo );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceLockedReadFunc)( void * inst, const OpenMPT_SoundDevice_BufferFormat * bufferFormat, uintptr_t numFrames, void * buffer, const void * inputBuffer );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceLockedReadDoneFunc)( void * inst, const OpenMPT_SoundDevice_TimeInfo * timeInfo );
void (OPENMPT_WINESUPPORT_WRAPPER_CALL * SoundSourceUnlockFunc)( void * inst );
} OpenMPT_Wine_Wrapper_SoundDevice_ISource;
#ifdef WINE_THREAD
typedef enum OpenMPT_Wine_Wrapper_AudioThreadCommand {
AudioThreadCommandInvalid = -1
, AudioThreadCommandExit = 0
, AudioThreadCommandLock = 1
, AudioThreadCommandClock = 2
, AudioThreadCommandReadPrepare = 3
, AudioThreadCommandRead = 4
, AudioThreadCommandReadDone = 5
, AudioThreadCommandUnlock = 6
} OpenMPT_Wine_Wrapper_AudioThreadCommand;
#endif
typedef struct OpenMPT_Wine_Wrapper_SoundDevice {
OpenMPT_SoundDevice * impl;
OpenMPT_SoundDevice_IMessageReceiver native_receiver;
OpenMPT_SoundDevice_ISource native_source;
OpenMPT_Wine_Wrapper_SoundDevice_IMessageReceiver wine_receiver;
OpenMPT_Wine_Wrapper_SoundDevice_ISource wine_source;
#ifdef WINE_THREAD
HANDLE audiothread_startup_done;
OpenMPT_Semaphore * audiothread_sem_request;
OpenMPT_Semaphore * audiothread_sem_done;
OpenMPT_Wine_Wrapper_AudioThreadCommand audiothread_command;
const OpenMPT_SoundDevice_TimeInfo * audiothread_command_timeInfo;
const OpenMPT_SoundDevice_BufferFormat * audiothread_command_bufferFormat;
const OpenMPT_SoundDevice_BufferAttributes * audiothread_command_bufferAttributes;
uintptr_t audiothread_command_numFrames;
void * audiothread_command_buffer;
const void * audiothread_command_inputBuffer;
uint64_t * audiothread_command_result;
HANDLE audiothread;
OpenMPT_PriorityBooster * priority_booster;
#endif
} OpenMPT_Wine_Wrapper_SoundDevice;
static void OPENMPT_WINESUPPORT_CALL SoundDeviceMessageFunc( void * inst, uintptr_t level, const char * message ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
return sd->wine_receiver.SoundDeviceMessageFunc( sd->wine_receiver.inst, level, message );
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceGetReferenceClockNowNanosecondsFunc( void * inst, uint64_t * result ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
return sd->wine_source.SoundSourceGetReferenceClockNowNanosecondsFunc( sd->wine_source.inst, result );
}
static void OPENMPT_WINESUPPORT_CALL SoundSourcePreStartCallbackFunc( void * inst ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
return sd->wine_source.SoundSourcePreStartCallbackFunc( sd->wine_source.inst );
}
static void OPENMPT_WINESUPPORT_CALL SoundSourcePostStopCallbackFunc( void * inst ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
return sd->wine_source.SoundSourcePostStopCallbackFunc( sd->wine_source.inst );
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceIsLockedByCurrentThreadFunc( void * inst, uintptr_t * result ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
return sd->wine_source.SoundSourceIsLockedByCurrentThreadFunc( sd->wine_source.inst, result );
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceLockFunc( void * inst ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
#ifdef WINE_THREAD
sd->audiothread_command = AudioThreadCommandLock;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
#else
return sd->wine_source.SoundSourceLockFunc( sd->wine_source.inst );
#endif
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceLockedGetReferenceClockNowNanosecondsFunc( void * inst, uint64_t * result ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
#ifdef WINE_THREAD
sd->audiothread_command = AudioThreadCommandClock;
sd->audiothread_command_result = result;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
#else
return sd->wine_source.SoundSourceLockedGetReferenceClockNowNanosecondsFunc( sd->wine_source.inst, result );
#endif
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceLockedReadPrepareFunc( void * inst, const OpenMPT_SoundDevice_TimeInfo * timeInfo ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
#ifdef WINE_THREAD
sd->audiothread_command = AudioThreadCommandReadPrepare;
sd->audiothread_command_timeInfo = timeInfo;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
#else
return sd->wine_source.SoundSourceLockedReadPrepareFunc( sd->wine_source.inst, timeInfo );
#endif
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceLockedReadFunc( void * inst, const OpenMPT_SoundDevice_BufferFormat * bufferFormat, uintptr_t numFrames, void * buffer, const void * inputBuffer ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
#ifdef WINE_THREAD
sd->audiothread_command = AudioThreadCommandRead;
sd->audiothread_command_bufferFormat = bufferFormat;
sd->audiothread_command_numFrames = numFrames;
sd->audiothread_command_buffer = buffer;
sd->audiothread_command_inputBuffer = inputBuffer;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
#else
return sd->wine_source.SoundSourceLockedReadFunc( sd->wine_source.inst, bufferFormat, bufferAttributes, numFrames, buffer, inputBuffer );
#endif
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceLockedReadDoneFunc( void * inst, const OpenMPT_SoundDevice_TimeInfo * timeInfo ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
#ifdef WINE_THREAD
sd->audiothread_command = AudioThreadCommandReadDone;
sd->audiothread_command_timeInfo = timeInfo;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
#else
return sd->wine_source.SoundSourceLockedReadDoneFunc( sd->wine_source.inst, timeInfo );
#endif
}
static void OPENMPT_WINESUPPORT_CALL SoundSourceUnlockFunc( void * inst ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)inst;
if ( !sd ) {
return;
}
#ifdef WINE_THREAD
sd->audiothread_command = AudioThreadCommandUnlock;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
#else
return sd->wine_source.SoundSourceUnlockFunc( sd->wine_source.inst );
#endif
}
#ifdef WINE_THREAD
static DWORD WINAPI AudioThread( LPVOID userdata ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)userdata;
sd->priority_booster = OpenMPT_PriorityBooster_Construct_From_SoundDevice( sd->impl );
SetEvent( sd->audiothread_startup_done );
{
int exit = 0;
while(!exit)
{
OpenMPT_Semaphore_Wait( sd->audiothread_sem_request );
switch ( sd->audiothread_command ) {
case AudioThreadCommandExit:
exit = 1;
break;
case AudioThreadCommandLock:
if(sd->wine_source.SoundSourceLockFunc)
sd->wine_source.SoundSourceLockFunc( sd->wine_source.inst );
break;
case AudioThreadCommandClock:
if(sd->wine_source.SoundSourceLockedGetReferenceClockNowNanosecondsFunc)
sd->wine_source.SoundSourceLockedGetReferenceClockNowNanosecondsFunc( sd->wine_source.inst, sd->audiothread_command_result );
break;
case AudioThreadCommandReadPrepare:
if(sd->wine_source.SoundSourceLockedReadPrepareFunc)
sd->wine_source.SoundSourceLockedReadPrepareFunc
( sd->wine_source.inst
, sd->audiothread_command_timeInfo
);
break;
case AudioThreadCommandRead:
if(sd->wine_source.SoundSourceLockedReadFunc)
sd->wine_source.SoundSourceLockedReadFunc
( sd->wine_source.inst
, sd->audiothread_command_bufferFormat
, sd->audiothread_command_numFrames
, sd->audiothread_command_buffer
, sd->audiothread_command_inputBuffer
);
break;
case AudioThreadCommandReadDone:
if(sd->wine_source.SoundSourceLockedReadDoneFunc)
sd->wine_source.SoundSourceLockedReadDoneFunc
( sd->wine_source.inst
, sd->audiothread_command_timeInfo
);
break;
case AudioThreadCommandUnlock:
if(sd->wine_source.SoundSourceUnlockFunc)
sd->wine_source.SoundSourceUnlockFunc( sd->wine_source.inst );
break;
default:
break;
}
OpenMPT_Semaphore_Post( sd->audiothread_sem_done );
}
}
OpenMPT_PriorityBooster_Destruct(sd->priority_booster);
sd->priority_booster = NULL;
return 0;
}
#endif
OPENMPT_WINESUPPORT_WRAPPER_API OpenMPT_Wine_Wrapper_SoundDevice * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Construct( const char * info ) {
OpenMPT_Wine_Wrapper_SoundDevice * sd = (OpenMPT_Wine_Wrapper_SoundDevice*)OpenMPT_Wine_Wrapper_Alloc( sizeof( OpenMPT_Wine_Wrapper_SoundDevice ) );
sd->impl = OpenMPT_SoundDevice_Construct( info );
return sd;
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Destruct( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
OpenMPT_SoundDevice_Destruct( sd->impl );
sd->impl = NULL;
OpenMPT_Wine_Wrapper_Free( sd );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_SetMessageReceiver( OpenMPT_Wine_Wrapper_SoundDevice * sd, const OpenMPT_Wine_Wrapper_SoundDevice_IMessageReceiver * receiver ) {
OpenMPT_SoundDevice_SetMessageReceiver( sd->impl, NULL );
ZeroMemory( &( sd->wine_receiver ), sizeof( sd->wine_receiver ) );
if(receiver)
{
sd->wine_receiver = *receiver;
}
sd->native_receiver.inst = sd;
sd->native_receiver.SoundDeviceMessageFunc = &SoundDeviceMessageFunc;
OpenMPT_SoundDevice_SetMessageReceiver( sd->impl, &sd->native_receiver );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_SetSource( OpenMPT_Wine_Wrapper_SoundDevice * sd, const OpenMPT_Wine_Wrapper_SoundDevice_ISource * source ) {
OpenMPT_SoundDevice_SetSource( sd->impl, NULL );
ZeroMemory( &( sd->wine_source ), sizeof( sd->wine_source ) );
if(source)
{
sd->wine_source = *source;
}
sd->native_source.inst = sd;
sd->native_source.SoundSourceGetReferenceClockNowNanosecondsFunc = &SoundSourceGetReferenceClockNowNanosecondsFunc;
sd->native_source.SoundSourcePreStartCallbackFunc = &SoundSourcePreStartCallbackFunc;
sd->native_source.SoundSourcePostStopCallbackFunc = &SoundSourcePostStopCallbackFunc;
sd->native_source.SoundSourceIsLockedByCurrentThreadFunc = &SoundSourceIsLockedByCurrentThreadFunc;
sd->native_source.SoundSourceLockFunc = &SoundSourceLockFunc;
sd->native_source.SoundSourceLockedGetReferenceClockNowNanosecondsFunc = &SoundSourceLockedGetReferenceClockNowNanosecondsFunc;
sd->native_source.SoundSourceLockedReadPrepareFunc = &SoundSourceLockedReadPrepareFunc;
sd->native_source.SoundSourceLockedReadFunc = &SoundSourceLockedReadFunc;
sd->native_source.SoundSourceLockedReadDoneFunc = &SoundSourceLockedReadDoneFunc;
sd->native_source.SoundSourceUnlockFunc = &SoundSourceUnlockFunc;
OpenMPT_SoundDevice_SetSource( sd->impl, &sd->native_source );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetDeviceInfo( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_GetDeviceInfo( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetDeviceCaps( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_GetDeviceCaps( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetDeviceDynamicCaps( OpenMPT_Wine_Wrapper_SoundDevice * sd, const char * baseSampleRates ) {
return OpenMPT_SoundDevice_GetDeviceDynamicCaps( sd->impl, baseSampleRates );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Init( OpenMPT_Wine_Wrapper_SoundDevice * sd, const char * appInfo ) {
return OpenMPT_SoundDevice_Init( sd->impl, appInfo );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Open( OpenMPT_Wine_Wrapper_SoundDevice * sd, const char * settings ) {
uintptr_t result = 0;
result = OpenMPT_SoundDevice_Open( sd->impl, settings );
#ifdef WINE_THREAD
if ( result ) {
DWORD threadId = 0;
sd->audiothread_startup_done = CreateEvent( NULL, FALSE, FALSE, NULL );
sd->audiothread_sem_request = OpenMPT_Semaphore_Construct();
sd->audiothread_sem_done = OpenMPT_Semaphore_Construct();
sd->audiothread_command = AudioThreadCommandInvalid;
sd->audiothread = CreateThread( NULL, 0, &AudioThread, sd, 0, &threadId );
WaitForSingleObject( sd->audiothread_startup_done, INFINITE );
}
#endif
return result;
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Close( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
uintptr_t result = 0;
#ifdef WINE_THREAD
if ( OpenMPT_SoundDevice_IsOpen( sd->impl ) ) {
sd->audiothread_command = AudioThreadCommandExit;
OpenMPT_Semaphore_Post( sd->audiothread_sem_request );
OpenMPT_Semaphore_Wait( sd->audiothread_sem_done );
sd->audiothread_command = AudioThreadCommandInvalid;
WaitForSingleObject( sd->audiothread, INFINITE );
CloseHandle( sd->audiothread );
sd->audiothread = NULL;
OpenMPT_Semaphore_Destruct( sd->audiothread_sem_done );
sd->audiothread_sem_done = NULL;
OpenMPT_Semaphore_Destruct( sd->audiothread_sem_request );
sd->audiothread_sem_request = NULL;
CloseHandle( sd->audiothread_startup_done );
sd->audiothread_startup_done = NULL;
}
#endif
result = OpenMPT_SoundDevice_Close( sd->impl );
return result;
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Start( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_Start( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_Stop( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_Stop( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetRequestFlags( const OpenMPT_Wine_Wrapper_SoundDevice * sd, uint32_t * result) {
return OpenMPT_SoundDevice_GetRequestFlags( sd->impl, result );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_IsInited( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_IsInited( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_IsOpen( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_IsOpen( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_IsAvailable( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_IsAvailable( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_IsPlaying( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_IsPlaying( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_IsPlayingSilence( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_IsPlayingSilence( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_StopAndAvoidPlayingSilence( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_StopAndAvoidPlayingSilence( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_EndPlayingSilence( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_EndPlayingSilence( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_OnIdle( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_OnIdle( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetSettings( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_GetSettings( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetActualSampleFormat( const OpenMPT_Wine_Wrapper_SoundDevice * sd, int32_t * result ) {
return OpenMPT_SoundDevice_GetActualSampleFormat( sd->impl, result );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetEffectiveBufferAttributes( const OpenMPT_Wine_Wrapper_SoundDevice * sd, OpenMPT_SoundDevice_BufferAttributes * result ) {
return OpenMPT_SoundDevice_GetEffectiveBufferAttributes( sd->impl, result );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetTimeInfo( const OpenMPT_Wine_Wrapper_SoundDevice * sd, OpenMPT_SoundDevice_TimeInfo * result ) {
return OpenMPT_SoundDevice_GetTimeInfo( sd->impl, result );
}
OPENMPT_WINESUPPORT_WRAPPER_API void OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetStreamPosition( const OpenMPT_Wine_Wrapper_SoundDevice * sd, OpenMPT_SoundDevice_StreamPosition * result ) {
return OpenMPT_SoundDevice_GetStreamPosition( sd->impl, result );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_DebugIsFragileDevice( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_DebugIsFragileDevice( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_DebugInRealtimeCallback( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_DebugInRealtimeCallback( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API char * OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_GetStatistics( const OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_GetStatistics( sd->impl );
}
OPENMPT_WINESUPPORT_WRAPPER_API uintptr_t OPENMPT_WINESUPPORT_WRAPPER_CALL OpenMPT_Wine_Wrapper_SoundDevice_OpenDriverSettings( OpenMPT_Wine_Wrapper_SoundDevice * sd ) {
return OpenMPT_SoundDevice_OpenDriverSettings( sd->impl );
}
#ifdef __cplusplus
} // extern "C"
#endif
#endif // MPT_BUILD_WINESUPPORT_WRAPPER
|
the_stack_data/333036.c | #include<stdio.h>
int len(char[20]);
int com(char[20],char[20]);
void rev(char[20],char[20]);
void pal(char[20]);
void concat(char[20],char[20]);
void copy(char[20],char[20]);
void substr(char[20],char[20]);
int i,j;
void main()
{char a[20],b[20],c[20],d[20];
int n,flag1,l1,l2;
do{
printf("\n\nenter 1 for calculate length\nenter 2 for comparing strings\nenter 3 for reversing a string\nenter 4 for checking for pallendrone\nenter 5 for concatinate two strings\nenter 6 for copy a string\nenter 7 for count substring\n");
scanf("%d",&n);
switch(n)
{ case 1: printf("\nenter a string\t");
scanf("%s",&a);
printf("\nenter a 2nd string\t");
scanf("%s",&b);
l1=len(a);
printf("\n%d is size of string\n\n",l1);
l2=len(b);
printf("%d is size of 2nd string\n\n",l2);
break;
case 2: flag1= com(a,b);
if(flag1==1)
printf("\nstrings are not equal\n");
else
printf("\nstrings are equal\n");
break;
case 3: rev(a,c);
printf("\nreverse of 1st string:\t%s",c);
rev(b,d);
printf("\nreverse of 2nd string:\t%s",d);
break;
case 4: pal(a);
pal(b);
break;
case 5: concat(a,b);
break;
case 6: printf("enter a string:\t");
scanf("%s",&a);
copy(a,c);
break;
case 7: printf("enter 1st string:\t");
scanf("%s",&a);
printf("enter 2nd string:\t");
scanf("%s",&b);
substr(a,b);
break;
default: printf("enter a valid option");
}
}while(n!=0);
}
int len(char a1[20])
{int l=0;
for(i=0;a1[i]!='\0';i++)
{a1[i];
++l;
}
return l;
}
int com(char a1[20],char b1[20])
{int flag=0;
for(i=0;a1[i]!='\0';i++)
{
if(a1[i]!=b1[i])
{flag=1;
break;}
}
return (flag); }
void rev(char a2[20],char b2[20])
{int l;
l= len(a2);
int i=l-1;
int a=0;
for(i;i>=0;i--)
{b2[a]=a2[i];
a++;
}
b2[a]='\0';
}
void pal(char a3[20])
{ int flag2;
char b3[20];
rev(a3,b3);
flag2= com(a3,b3);
if(flag2!=1)
printf("\n%s is pallendrone\n",a3);
else
printf("\n%s is not pallendrone\n",a3);
}
void concat(char a4[20],char b4[20])
{
i=len(a4);
j=0;
for(i;b4[j]!='\0';j++)
{
a4[i]=b4[j];
i++;
}
a4[i]='\0';
printf("both strings are added:\t%s",a4);
}
void copy(char a5[20],char b5[20])
{
for(i=0;a5[i]!='\0';i++)
{
b5[i]=a5[i];
}
b5[i]='\0';
printf("\n1st string:\t%s\ncopied string:\t%s",a5,b5);
}
void substr(char a6[20],char b6[20])
{
int count=0;
i=0;
j=0;
while(a6[i]!='\0')
{
if(a6[i]==b6[j])
{
i++;
j++;
if(b6[j]=='\0')
{
count++;
j=0;
}
}
else
{i++;
j=0;
}
}
if(count>0)
{printf("%s is a sub string of %s\n and it comes %d times in %s ",b6,a6,count,b6);
}
else
printf("\n%s not a substring of %s\n",b6,a6);
}
/* OUTPUT
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
1
enter a string sac
enter a 2nd string hin
3 is size of string
3 is size of 2nd string
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
2
strings are not equal
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
3
reverse of 1st string: cas
reverse of 2nd string: nih
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
4
sac is not pallendrone
hin is not pallendrone
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
5
both strings are added: sachin
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
6
enter a string: sachinn
1st string: sachinn
copied string: sachinn
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
7
enter 1st string: banana
enter 2nd string: a
a is a sub string of banana
and it comes 3 times in a
enter 1 for calculate length
enter 2 for comparing strings
enter 3 for reversing a string
enter 4 for checking for pallendrone
enter 5 for concatinate two strings
enter 6 for copy a string
enter 7 for count substring
*/
|
the_stack_data/72012348.c | /* global.c */
#include <stdio.h>
void critic(int * p);
int main(void)
{
int units = 0;
printf("How many pounds to a firkin of butter?\n");
scanf("%d", &units);
while (units != 56)
critic(&units);
printf("You must have looked it up!\n");
return 0;
}
void critic(int * p)
{
printf("No luck, my friend. Try again.\n");
scanf("%d", p);
} |
the_stack_data/154522.c | /* <MIT License>
Copyright (c) 2013 Marek Majkowski <[email protected]>
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.
</MIT License>
Original location:
https://github.com/majek/csiphash/
Solution inspired by code from:
Samuel Neves (supercop/crypto_auth/siphash24/little)
djb (supercop/crypto_auth/siphash24/little2)
Jean-Philippe Aumasson (https://131002.net/siphash/siphash24.c)
*/
#include <stdint.h>
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define _le64toh(x) ((uint64_t)(x))
#elif defined(_WIN32)
/* Windows is always little endian, unless you're on xbox360
http://msdn.microsoft.com/en-us/library/b0084kay(v=vs.80).aspx */
#define _le64toh(x) ((uint64_t)(x))
#elif defined(__APPLE__)
#include <libkern/OSByteOrder.h>
#define _le64toh(x) OSSwapLittleToHostInt64(x)
#else
/* See: http://sourceforge.net/p/predef/wiki/Endianness/ */
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <sys/endian.h>
#else
#include <endian.h>
#endif
#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
__BYTE_ORDER == __LITTLE_ENDIAN
#define _le64toh(x) ((uint64_t)(x))
#else
#define _le64toh(x) le64toh(x)
#endif
#endif
#define ROTATE(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
#define HALF_ROUND(a, b, c, d, s, t) \
a += b; \
c += d; \
b = ROTATE(b, s) ^ a; \
d = ROTATE(d, t) ^ c; \
a = ROTATE(a, 32);
#define DOUBLE_ROUND(v0, v1, v2, v3) \
HALF_ROUND(v0, v1, v2, v3, 13, 16); \
HALF_ROUND(v2, v1, v0, v3, 17, 21); \
HALF_ROUND(v0, v1, v2, v3, 13, 16); \
HALF_ROUND(v2, v1, v0, v3, 17, 21);
#define ROUND(v0, v1, v2, v3) \
HALF_ROUND(v0, v1, v2, v3, 13, 16); \
HALF_ROUND(v2, v1, v0, v3, 17, 21);
uint64_t siphash24(const void *src, unsigned long src_sz, const char key[16])
{
const uint64_t *_key = (uint64_t *)key;
uint64_t k0 = _le64toh(_key[0]);
uint64_t k1 = _le64toh(_key[1]);
uint64_t b = (uint64_t)src_sz << 56;
const uint64_t *in = (uint64_t *)src;
uint64_t v0 = k0 ^ 0x736f6d6570736575ULL;
uint64_t v1 = k1 ^ 0x646f72616e646f6dULL;
uint64_t v2 = k0 ^ 0x6c7967656e657261ULL;
uint64_t v3 = k1 ^ 0x7465646279746573ULL;
while (src_sz >= 8) {
uint64_t mi = _le64toh(*in);
in += 1;
src_sz -= 8;
v3 ^= mi;
DOUBLE_ROUND(v0, v1, v2, v3);
v0 ^= mi;
}
uint64_t t = 0;
uint8_t *pt = (uint8_t *)&t;
uint8_t *m = (uint8_t *)in;
switch (src_sz) {
case 7:
pt[6] = m[6];
/* fallthrough */
case 6:
pt[5] = m[5];
/* fallthrough */
case 5:
pt[4] = m[4];
/* fallthrough */
case 4:
*((uint32_t *)&pt[0]) = *((uint32_t *)&m[0]);
break;
case 3:
pt[2] = m[2];
/* fallthrough */
case 2:
pt[1] = m[1];
/* fallthrough */
case 1:
pt[0] = m[0];
}
b |= _le64toh(t);
v3 ^= b;
DOUBLE_ROUND(v0, v1, v2, v3);
v0 ^= b;
v2 ^= 0xff;
DOUBLE_ROUND(v0, v1, v2, v3);
DOUBLE_ROUND(v0, v1, v2, v3);
return (v0 ^ v1) ^ (v2 ^ v3);
}
uint32_t hsiphash(const void *src, unsigned long src_sz, const char key[16])
{
const uint64_t *_key = (uint64_t *)key;
uint64_t k0 = _le64toh(_key[0]);
uint64_t k1 = _le64toh(_key[1]);
uint64_t b = (uint64_t)src_sz << 56;
const uint64_t *in = (uint64_t *)src;
uint64_t v0 = k0 ^ 0x736f6d6570736575ULL;
uint64_t v1 = k1 ^ 0x646f72616e646f6dULL;
uint64_t v2 = k0 ^ 0x6c7967656e657261ULL;
uint64_t v3 = k1 ^ 0x7465646279746573ULL;
while (src_sz >= 8) {
uint64_t mi = _le64toh(*in);
in += 1;
src_sz -= 8;
v3 ^= mi;
ROUND(v0, v1, v2, v3);
v0 ^= mi;
}
uint64_t t = 0;
uint8_t *pt = (uint8_t *)&t;
uint8_t *m = (uint8_t *)in;
switch (src_sz) {
case 7:
pt[6] = m[6];
/* fallthrough */
case 6:
pt[5] = m[5];
/* fallthrough */
case 5:
pt[4] = m[4];
/* fallthrough */
case 4:
*((uint32_t *)&pt[0]) = *((uint32_t *)&m[0]);
break;
case 3:
pt[2] = m[2];
/* fallthrough */
case 2:
pt[1] = m[1];
/* fallthrough */
case 1:
pt[0] = m[0];
}
b |= _le64toh(t);
v3 ^= b;
ROUND(v0, v1, v2, v3);
v0 ^= b;
v2 ^= 0xff;
ROUND(v0, v1, v2, v3);
ROUND(v0, v1, v2, v3);
return (v0 ^ v1) ^ (v2 ^ v3);
}
/* Hardcode key to allow compiler to inline it. */
static const char siphash_key[16] = {0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf};
uint32_t hsiphash_static(const void *src, unsigned long src_sz)
{
return hsiphash(src, src_sz, siphash_key);
}
|
the_stack_data/68886797.c | /*
* Copyright © 2011, 2013 Guillem Jover
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED ``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.
*/
#include <sys/cdefs.h>
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#ifdef HAVE_FOPENCOOKIE
struct funopen_cookie {
void *orig_cookie;
int (*readfn)(void *cookie, char *buf, int size);
int (*writefn)(void *cookie, const char *buf, int size);
off_t (*seekfn)(void *cookie, off_t offset, int whence);
int (*closefn)(void *cookie);
};
static ssize_t
funopen_read(void *cookie, char *buf, size_t size)
{
struct funopen_cookie *cookiewrap = cookie;
if (cookiewrap->readfn == NULL) {
errno = EBADF;
return -1;
}
return cookiewrap->readfn(cookiewrap->orig_cookie, buf, size);
}
static ssize_t
funopen_write(void *cookie, const char *buf, size_t size)
{
struct funopen_cookie *cookiewrap = cookie;
if (cookiewrap->writefn == NULL)
return EOF;
return cookiewrap->writefn(cookiewrap->orig_cookie, buf, size);
}
static int
funopen_seek(void *cookie, off64_t *offset, int whence)
{
struct funopen_cookie *cookiewrap = cookie;
off_t soff = *offset;
if (cookiewrap->seekfn == NULL) {
errno = ESPIPE;
return -1;
}
soff = cookiewrap->seekfn(cookiewrap->orig_cookie, soff, whence);
*offset = soff;
return *offset;
}
static int
funopen_close(void *cookie)
{
struct funopen_cookie *cookiewrap = cookie;
int rc;
if (cookiewrap->closefn == NULL)
return 0;
rc = cookiewrap->closefn(cookiewrap->orig_cookie);
free(cookiewrap);
return rc;
}
FILE *
funopen(const void *cookie,
int (*readfn)(void *cookie, char *buf, int size),
int (*writefn)(void *cookie, const char *buf, int size),
off_t (*seekfn)(void *cookie, off_t offset, int whence),
int (*closefn)(void *cookie))
{
struct funopen_cookie *cookiewrap;
cookie_io_functions_t funcswrap = {
.read = funopen_read,
.write = funopen_write,
.seek = funopen_seek,
.close = funopen_close,
};
const char *mode;
if (readfn) {
if (writefn == NULL)
mode = "r";
else
mode = "r+";
} else if (writefn) {
mode = "w";
} else {
errno = EINVAL;
return NULL;
}
cookiewrap = malloc(sizeof(*cookiewrap));
if (cookiewrap == NULL)
return NULL;
cookiewrap->orig_cookie = (void *)cookie;
cookiewrap->readfn = readfn;
cookiewrap->writefn = writefn;
cookiewrap->seekfn = seekfn;
cookiewrap->closefn = closefn;
return fopencookie(cookiewrap, mode, funcswrap);
}
#else
//#error "Function funopen() needs to be ported."
#endif
|
the_stack_data/867130.c | /* From C11 Sec. 6.7.9.25:
*
* EXAMPLE 2 The declaration
*
* int x[] = { 1, 3, 5 };
*
* defines and initializes x as a one-dimensional array object that
* has three * elements, as no size was specified and there are three
* initializers.
*/
int x[] = { 1, 3, 5 };
|
the_stack_data/43888432.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* only_a.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: exam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/21 09:12:36 by exam #+# #+# */
/* Updated: 2017/11/21 09:12:39 by exam ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
int main(void)
{
write(1, "a", 1);
return (0);
}
|
the_stack_data/404137.c | // code: 1
int main() { return 12.0 != 12.1; } |
the_stack_data/85057.c | #ifndef __TYPES__
#define __TYPES__
#ifndef NULL
#define NULL ((void*)0)
#endif
#ifndef true
#define true 1
#endif
#ifndef false
#define false 0
#endif
#ifndef test
#define test
#endif
#define endof(var) \
((Void*)&var + sizeof(var))
#define typedef_MaybeType(Type) \
typedef struct { \
Boolean hasValue; \
Type value; \
} Maybe##Type;
typedef void Void;
typedef void Any;
typedef char Char;
typedef char Boolean;
typedef unsigned char Byte;
typedef int Int;
typedef long Long;
typedef unsigned long ULong;
#endif
|
the_stack_data/663423.c | /*
const __disp_vga_t disp_vga_h1024_v768 =
{
//u32 pixel_clk;
65000000,
//u16 x_res;
1024,
//u16 y_res;
768,
//u16 hor_total_time;
1344,
//u16 hor_front_porch;
24,
//u16 hor_sync_time;
136,
//u16 hor_back_porch;
160,
//u16 ver_total_time;
806,
//u16 ver_front_porch;
3,
//u16 ver_sync_time;
6,
//u16 ver_back_porch;
9,
//bool hor_sync_polarity;
0,
//bool ver_sync_polarity;
0,
};
*/
|
the_stack_data/64699.c | /*
* Copyright (C) 2010 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#define _GNU_SOURCE 1
#include <sched.h>
extern int __getcpu(unsigned *cpu, unsigned *node, void* unused);
int sched_getcpu(void)
{
unsigned cpu;
if (__getcpu(&cpu, NULL, NULL) < 0)
return 0;
return (int)cpu;
}
|
the_stack_data/65511.c | /**
* main.c
*/
#define GPIO_CLOCK_GATING *((unsigned volatile int *) 0x400FE608U)
#define GPIODATA_DIR *((unsigned volatile int *) 0x40025400U)
#define GPIODATA_DEN *((unsigned volatile int *) 0x4002551CU)
#define GPIODATA_DATA *((unsigned volatile int *) 0x400253FCU)
#define LED_RED (1U << 1)
#define LED_BLUE (1U << 2)
#define LED_GREEN (1U << 3)
int main(void)
{
GPIO_CLOCK_GATING = 0x20U;
GPIODATA_DIR = LED_RED | LED_BLUE | LED_GREEN;
GPIODATA_DEN = LED_RED | LED_BLUE | LED_GREEN;
int counter = 0;
while (1) {
++counter;
if (counter < 1e5) {
GPIODATA_DATA = LED_RED; // Red lights up
}
if (counter >= 1e5 && counter < 2e5) {
GPIODATA_DATA |= LED_BLUE; // Blue and Red light up
}
if (counter >= 2e5 && counter < 3e5) {
GPIODATA_DATA |= LED_GREEN; // All light up
}
if (counter >= 3e5 && counter < 4e5) {
GPIODATA_DATA &= ~LED_RED; // Red turns off
}
if (counter >= 4e5 && counter < 5e5) {
GPIODATA_DATA &= ~LED_GREEN; // Green turns off
}
if (counter >= 5e5 && counter < 6e5) {
GPIODATA_DATA &= ~LED_BLUE; // Blue turns off
}
if (counter >= 6e5) {
counter = 0;
}
}
return 0;
}
|
the_stack_data/42257.c | /* bignum.c
Implementation of large integer arithmetic: addition, subtraction,
multiplication, and division.
begun: February 7, 2002
by: Steven Skiena
*/
/*
Copyright 2003 by Steven S. Skiena; all rights reserved.
Permission is granted for use in non-commerical applications
provided this copyright notice remains intact and unchanged.
This program appears in my book:
"Programming Challenges: The Programming Contest Training Manual"
by Steven Skiena and Miguel Revilla, Springer-Verlag, New York 2003.
See our website www.programming-challenges.com for additional information.
This book can be ordered from Amazon.com at
http://www.amazon.com/exec/obidos/ASIN/0387001638/thealgorithmrepo/
*/
#include <stdio.h>
#define MAXDIGITS 100 /* maximum length bignum */
#define PLUS 1 /* positive sign bit */
#define MINUS -1 /* negative sign bit */
typedef struct {
char digits[MAXDIGITS]; /* represent the number */
int signbit; /* 1 if positive, -1 if negative */
int lastdigit; /* index of high-order digit */
} bignum;
print_bignum(bignum *n)
{
int i;
if (n->signbit == MINUS) printf("- ");
for (i=n->lastdigit; i>=0; i--)
printf("%c",'0'+ n->digits[i]);
printf("\n");
}
int_to_bignum(int s, bignum *n)
{
int i; /* counter */
int t; /* int to work with */
if (s >= 0) n->signbit = PLUS;
else n->signbit = MINUS;
for (i=0; i<MAXDIGITS; i++) n->digits[i] = (char) 0;
n->lastdigit = -1;
t = abs(s);
while (t > 0) {
n->lastdigit ++;
n->digits[ n->lastdigit ] = (t % 10);
t = t / 10;
}
if (s == 0) n->lastdigit = 0;
}
initialize_bignum(bignum *n)
{
int_to_bignum(0,n);
}
int max(int a, int b)
{
if (a > b) return(a); else return(b);
}
/* c = a +-/* b; */
add_bignum(bignum *a, bignum *b, bignum *c)
{
int carry; /* carry digit */
int i; /* counter */
initialize_bignum(c);
if (a->signbit == b->signbit) c->signbit = a->signbit;
else {
if (a->signbit == MINUS) {
a->signbit = PLUS;
subtract_bignum(b,a,c);
a->signbit = MINUS;
} else {
b->signbit = PLUS;
subtract_bignum(a,b,c);
b->signbit = MINUS;
}
return;
}
c->lastdigit = max(a->lastdigit,b->lastdigit)+1;
carry = 0;
for (i=0; i<=(c->lastdigit); i++) {
c->digits[i] = (char) (carry+a->digits[i]+b->digits[i]) % 10;
carry = (carry + a->digits[i] + b->digits[i]) / 10;
}
zero_justify(c);
}
subtract_bignum(bignum *a, bignum *b, bignum *c)
{
int borrow; /* has anything been borrowed? */
int v; /* placeholder digit */
int i; /* counter */
initialize_bignum(c);
if ((a->signbit == MINUS) || (b->signbit == MINUS)) {
b->signbit = -1 * b->signbit;
add_bignum(a,b,c);
b->signbit = -1 * b->signbit;
return;
}
if (compare_bignum(a,b) == PLUS) {
subtract_bignum(b,a,c);
c->signbit = MINUS;
return;
}
c->lastdigit = max(a->lastdigit,b->lastdigit);
borrow = 0;
for (i=0; i<=(c->lastdigit); i++) {
v = (a->digits[i] - borrow - b->digits[i]);
if (a->digits[i] > 0)
borrow = 0;
if (v < 0) {
v = v + 10;
borrow = 1;
}
c->digits[i] = (char) v % 10;
}
zero_justify(c);
}
compare_bignum(bignum *a, bignum *b)
{
int i; /* counter */
if ((a->signbit == MINUS) && (b->signbit == PLUS)) return(PLUS);
if ((a->signbit == PLUS) && (b->signbit == MINUS)) return(MINUS);
if (b->lastdigit > a->lastdigit) return (PLUS * a->signbit);
if (a->lastdigit > b->lastdigit) return (MINUS * a->signbit);
for (i = a->lastdigit; i>=0; i--) {
if (a->digits[i] > b->digits[i]) return(MINUS * a->signbit);
if (b->digits[i] > a->digits[i]) return(PLUS * a->signbit);
}
return(0);
}
zero_justify(bignum *n)
{
while ((n->lastdigit > 0) && (n->digits[ n->lastdigit ] == 0))
n->lastdigit --;
if ((n->lastdigit == 0) && (n->digits[0] == 0))
n->signbit = PLUS; /* hack to avoid -0 */
}
digit_shift(bignum *n, int d) /* multiply n by 10^d */
{
int i; /* counter */
if ((n->lastdigit == 0) && (n->digits[0] == 0)) return;
for (i=n->lastdigit; i>=0; i--)
n->digits[i+d] = n->digits[i];
for (i=0; i<d; i++) n->digits[i] = 0;
n->lastdigit = n->lastdigit + d;
}
multiply_bignum(bignum *a, bignum *b, bignum *c)
{
bignum row; /* represent shifted row */
bignum tmp; /* placeholder bignum */
int i,j; /* counters */
initialize_bignum(c);
row = *a;
for (i=0; i<=b->lastdigit; i++) {
for (j=1; j<=b->digits[i]; j++) {
add_bignum(c,&row,&tmp);
*c = tmp;
}
digit_shift(&row,1);
}
c->signbit = a->signbit * b->signbit;
zero_justify(c);
}
divide_bignum(bignum *a, bignum *b, bignum *c)
{
bignum row; /* represent shifted row */
bignum tmp; /* placeholder bignum */
int asign, bsign; /* temporary signs */
int i,j; /* counters */
initialize_bignum(c);
c->signbit = a->signbit * b->signbit;
asign = a->signbit;
bsign = b->signbit;
a->signbit = PLUS;
b->signbit = PLUS;
initialize_bignum(&row);
initialize_bignum(&tmp);
c->lastdigit = a->lastdigit;
for (i=a->lastdigit; i>=0; i--) {
digit_shift(&row,1);
row.digits[0] = a->digits[i];
c->digits[i] = 0;
while (compare_bignum(&row,b) != PLUS) {
c->digits[i] ++;
subtract_bignum(&row,b,&tmp);
row = tmp;
}
}
zero_justify(c);
a->signbit = asign;
b->signbit = bsign;
}
/*
main()
{
int a,b;
bignum n1,n2,n3,zero;
while (scanf("%d %d\n",&a,&b) != EOF) {
printf("a = %d b = %d\n",a,b);
int_to_bignum(a,&n1);
int_to_bignum(b,&n2);
add_bignum(&n1,&n2,&n3);
printf("addition -- ");
print_bignum(&n3);
printf("compare_bignum a ? b = %d\n",compare_bignum(&n1, &n2));
subtract_bignum(&n1,&n2,&n3);
printf("subtraction -- ");
print_bignum(&n3);
multiply_bignum(&n1,&n2,&n3);
printf("multiplication -- ");
print_bignum(&n3);
int_to_bignum(0,&zero);
if (compare_bignum(&zero, &n2) == 0)
printf("division -- NaN \n");
else {
divide_bignum(&n1,&n2,&n3);
printf("division -- ");
print_bignum(&n3);
}
printf("--------------------------\n");
}
}
*/ |
the_stack_data/48574831.c |
int main() {
int x;
x = 65;
putchar(x);
if (0) {
int y;
y = 66;
putchar(y);
} else {
int y, z;
y = 67;
z = 68;
putchar(y);
putchar(z);
}
putchar(x);
putchar(10);
return 0;
}
|
the_stack_data/28546.c | #include <stdio.h>
int main(){
int i, j, n, k;
scanf("%d", &n);
for(i = n; i > 0; i--){
for(k = 0; k < i; k++)
printf(" ");
for(j = 0; j <= 2*(n-i); j++){
printf("*");
}
printf("\n");
}
for(i = 1; i < n; i++){
for(k = -1; k < i; k++)
printf(" ");
for(j = 0; j < 2*(n-i)-1; j++){
printf("*");
}
printf("\n");
}
return 0;
} |
the_stack_data/76699549.c | /*This is mechanically generated code*/
#include <stdlib.h>
typedef struct { int x, y; } xy;
typedef unsigned char byte;
int fast12_corner_score(const byte* p, const int pixel[], int bstart)
{
int bmin = bstart;
int bmax = 255;
int b = (bmax + bmin)/2;
/*Compute the score using binary search*/
for(;;)
{
int cb = *p + b;
int c_b= *p - b;
if( p[pixel[0]] > cb)
if( p[pixel[1]] > cb)
if( p[pixel[2]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
goto is_a_corner;
else
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[4]] < c_b)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[8]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[3]] < c_b)
if( p[pixel[15]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[2]] < c_b)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[3]] < c_b)
goto is_a_corner;
else
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[3]] < c_b)
goto is_a_corner;
else
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[1]] < c_b)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[2]] < c_b)
goto is_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[4]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[2]] < c_b)
goto is_a_corner;
else
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[0]] < c_b)
if( p[pixel[1]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[2]] > cb)
goto is_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[1]] < c_b)
if( p[pixel[2]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[3]] > cb)
goto is_a_corner;
else
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[2]] < c_b)
if( p[pixel[3]] > cb)
if( p[pixel[15]] < c_b)
if( p[pixel[7]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[3]] < c_b)
if( p[pixel[4]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
goto is_a_corner;
else
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[7]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[6]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[3]] > cb)
goto is_a_corner;
else
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[5]] > cb)
if( p[pixel[4]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[13]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[2]] > cb)
goto is_a_corner;
else
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[2]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[4]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[4]] > cb)
if( p[pixel[5]] > cb)
if( p[pixel[6]] > cb)
if( p[pixel[7]] > cb)
if( p[pixel[8]] > cb)
if( p[pixel[9]] > cb)
if( p[pixel[10]] > cb)
if( p[pixel[11]] > cb)
if( p[pixel[12]] > cb)
if( p[pixel[3]] > cb)
if( p[pixel[2]] > cb)
if( p[pixel[1]] > cb)
goto is_a_corner;
else
if( p[pixel[13]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] > cb)
if( p[pixel[14]] > cb)
if( p[pixel[15]] > cb)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else if( p[pixel[4]] < c_b)
if( p[pixel[5]] < c_b)
if( p[pixel[6]] < c_b)
if( p[pixel[7]] < c_b)
if( p[pixel[8]] < c_b)
if( p[pixel[9]] < c_b)
if( p[pixel[10]] < c_b)
if( p[pixel[11]] < c_b)
if( p[pixel[12]] < c_b)
if( p[pixel[3]] < c_b)
if( p[pixel[2]] < c_b)
if( p[pixel[1]] < c_b)
goto is_a_corner;
else
if( p[pixel[13]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
if( p[pixel[13]] < c_b)
if( p[pixel[14]] < c_b)
if( p[pixel[15]] < c_b)
goto is_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
else
goto is_not_a_corner;
is_a_corner:
bmin=b;
goto end_if;
is_not_a_corner:
bmax=b;
goto end_if;
end_if:
if(bmin == bmax - 1 || bmin == bmax)
return bmin;
b = (bmin + bmax) / 2;
}
}
static void make_offsets(int pixel[], int row_stride)
{
pixel[0] = 0 + row_stride * 3;
pixel[1] = 1 + row_stride * 3;
pixel[2] = 2 + row_stride * 2;
pixel[3] = 3 + row_stride * 1;
pixel[4] = 3 + row_stride * 0;
pixel[5] = 3 + row_stride * -1;
pixel[6] = 2 + row_stride * -2;
pixel[7] = 1 + row_stride * -3;
pixel[8] = 0 + row_stride * -3;
pixel[9] = -1 + row_stride * -3;
pixel[10] = -2 + row_stride * -2;
pixel[11] = -3 + row_stride * -1;
pixel[12] = -3 + row_stride * 0;
pixel[13] = -3 + row_stride * 1;
pixel[14] = -2 + row_stride * 2;
pixel[15] = -1 + row_stride * 3;
}
int* fast12_score(const byte* i, int stride, xy* corners, int num_corners, int b)
{
int* scores = (int*)malloc(sizeof(int)* num_corners);
int n;
int pixel[16];
make_offsets(pixel, stride);
for(n=0; n < num_corners; n++)
scores[n] = fast12_corner_score(i + corners[n].y*stride + corners[n].x, pixel, b);
return scores;
}
xy* fast12_detect(const byte* im, int xsize, int ysize, int stride, int b, int* ret_num_corners)
{
int num_corners=0;
xy* ret_corners;
int rsize=512;
int pixel[16];
int x, y;
ret_corners = (xy*)malloc(sizeof(xy)*rsize);
make_offsets(pixel, stride);
for(y=3; y < ysize - 3; y++)
for(x=3; x < xsize - 3; x++)
{
const byte* p = im + y*stride + x;
int cb = *p + b;
int c_b= *p - b;
if(p[pixel[0]] > cb)
if(p[pixel[1]] > cb)
if(p[pixel[2]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
{}
else
if(p[pixel[15]] > cb)
{}
else
continue;
else
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[4]] < c_b)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[8]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[3]] < c_b)
if(p[pixel[15]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[2]] < c_b)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[3]] < c_b)
{}
else
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[3]] < c_b)
{}
else
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[1]] < c_b)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[2]] < c_b)
{}
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[4]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[2]] < c_b)
{}
else
if(p[pixel[14]] < c_b)
{}
else
continue;
else
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[0]] < c_b)
if(p[pixel[1]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[2]] > cb)
{}
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[1]] < c_b)
if(p[pixel[2]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[3]] > cb)
{}
else
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[2]] < c_b)
if(p[pixel[3]] > cb)
if(p[pixel[15]] < c_b)
if(p[pixel[7]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[3]] < c_b)
if(p[pixel[4]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
{}
else
if(p[pixel[15]] < c_b)
{}
else
continue;
else
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[7]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[6]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[3]] > cb)
{}
else
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[5]] > cb)
if(p[pixel[4]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[13]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[2]] > cb)
{}
else
if(p[pixel[14]] > cb)
{}
else
continue;
else
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[2]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[4]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
if(p[pixel[4]] > cb)
if(p[pixel[5]] > cb)
if(p[pixel[6]] > cb)
if(p[pixel[7]] > cb)
if(p[pixel[8]] > cb)
if(p[pixel[9]] > cb)
if(p[pixel[10]] > cb)
if(p[pixel[11]] > cb)
if(p[pixel[12]] > cb)
if(p[pixel[3]] > cb)
if(p[pixel[2]] > cb)
if(p[pixel[1]] > cb)
{}
else
if(p[pixel[13]] > cb)
{}
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] > cb)
if(p[pixel[14]] > cb)
if(p[pixel[15]] > cb)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else if(p[pixel[4]] < c_b)
if(p[pixel[5]] < c_b)
if(p[pixel[6]] < c_b)
if(p[pixel[7]] < c_b)
if(p[pixel[8]] < c_b)
if(p[pixel[9]] < c_b)
if(p[pixel[10]] < c_b)
if(p[pixel[11]] < c_b)
if(p[pixel[12]] < c_b)
if(p[pixel[3]] < c_b)
if(p[pixel[2]] < c_b)
if(p[pixel[1]] < c_b)
{}
else
if(p[pixel[13]] < c_b)
{}
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
{}
else
continue;
else
continue;
else
if(p[pixel[13]] < c_b)
if(p[pixel[14]] < c_b)
if(p[pixel[15]] < c_b)
{}
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
else
continue;
if(num_corners == rsize)
{
rsize*=2;
ret_corners = (xy*)realloc(ret_corners, sizeof(xy)*rsize);
}
ret_corners[num_corners].x = x;
ret_corners[num_corners].y = y;
num_corners++;
}
*ret_num_corners = num_corners;
return ret_corners;
}
|
the_stack_data/1199126.c |
// this source derived from CHILL AST originally from file 'jacobi1.c' as parsed by frontend compiler rose
|
the_stack_data/32949504.c | /*
* Copyright (c) 2016, University of Oregon
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the University of Glasgow 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.
*/
/*
* reads file specified as an argument (or stdin if not specified),
* removes occurrences of \r
* converts occurrences of \n to \r
*/
#include <stdio.h>
int main(int argc, char *argv[]) {
int c;
FILE *fd;
if (argc > 2) {
fprintf(stderr, "usage: %s [file]\n", argv[0]);
return -1;
}
if (argc == 1)
fd = stdin;
else if (! (fd = fopen(argv[1], "r"))) {
fprintf(stderr, "%s: unable to open file %s\n", argv[0], argv[1]);
return -2;
}
while ((c = fgetc(fd)) != EOF)
if (c == '\r')
continue;
else if (c == '\n')
fputc('\r', stdout);
else
fputc(c, stdout);
return 0;
}
|
the_stack_data/82950238.c | #include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#define DEBUG 0
#if DEBUG == 1
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...)
#endif
// Problem description
// ===================
//
// Given an array of possibly million 64bit numbers (integers in our case) and
// another number N, find a pair in the array, which sums up to N.
typedef struct {
int a, b;
} idx2;
long* read_input();
void heap_sort(long *ary, int ary_len);
idx2 find_target_sum(long target, long *ary, int ary_len);
void heapify(long *ary, int ary_len);
void heap_sift_down(long *ary, int ary_len, int index);
int is_lt(long a, long b);
int is_gt(long a, long b);
void swap(long *ary, int i, int j);
int main(int argc, char **argv) {
long *input;
input = read_input();
if (input != NULL) {
int ary_len = input[0] - 1;
long target = input[1];
long *ary = input + 2;
printf("Input %d integers\n", ary_len);
printf("Target sum to find: %ld\n", target);
heap_sort(ary, ary_len);
idx2 indexes = find_target_sum(target, ary, ary_len);
if (indexes.a >= 0) {
long a = ary[indexes.a], b = ary[indexes.b];
printf("Found pair of values %ld and %ld.\n", a, b);
} else {
printf("No such pair, which sums up to %ld was found.\n", target);
}
} else {
printf("Nothing at input, algorithm not run.\n");
return 1;
}
return 0;
}
#define INITIAL_SIZE 1024
long* read_input() {
int alloc = INITIAL_SIZE, len = 1;
long elem, *elems = (long*) malloc(sizeof(long)*alloc);
while (!feof(stdin)) {
int symbols_read = fscanf(stdin, "%ld", &elem);
if (symbols_read < 1)
continue;
if (len >= alloc) {
alloc *= 2;
elems = (long*) realloc(elems, sizeof(long)*alloc);
if (elems == NULL) {
fprintf(stderr, "Not enough memory\n");
break;
}
}
elems[len++] = elem;
}
elems[0] = len - 1;
return elems;
}
// Heap Sort works in two steps, first it builds a Heap. A Heap is a data
// structure physicaly based on an array, but represents a binary tree, where
// each child is smaller (or bigger) than it's parent - this is the Heap
// invariant.
// The zero element in the array is the root. You can figure out the child
// indexes a & b from parents index i by the following way:
// a = i*2 + 1
// b = i*2 + 2
// The efficient way of building a heap in O(N) is implemented by the heapify()
// operation. It tries to push down, say sift down, each of the array elements,
// until all elements satisfy the Heap invariant.
//
// In the second step, Heap Sort just swap the first (maximum) element with the
// last element in the array to get the maximum element into sorted position.
// Next decreases the heap length to keep the sorted tail from moving and sifts
// down the element in the first position, to keep the Heap invariant. This is
// repeated until all elements are placed into sorted position from back to the
// from of the array.
//
// Time O(NlogN) and additional memory O(1) - that's better than Quick Sort.
void heap_sort(long *ary, int ary_len) {
int heap_size = ary_len;
heapify(ary, heap_size);
while (heap_size > 0) {
debug("heap_sort().while heap_size:%d\n", heap_size);
swap(ary, 0, --heap_size);
heap_sift_down(ary, heap_size, 0);
}
}
idx2 find_target_sum(long target, long *ary, int ary_len) {
idx2 ret = { .a = -1, .b = -1 };
for (int a = 0, b = ary_len - 1; a < b; ) {
long sum = ary[a] + ary[b];
if (sum == target) {
ret.a = a;
ret.b = b;
break;
} else if (sum > target) {
b--;
} else {
a++;
}
}
return ret;
}
void heapify(long *ary, int ary_len) {
// TODO: Skip the lower level, we can not sift down those guys
for (int i = ary_len - 1; i >= 0; i--) {
debug("heapify().for\n");
heap_sift_down(ary, ary_len, i);
}
}
void heap_sift_down(long *ary, int heap_len, int index) {
int i = index;
while (i < heap_len) {
int a = i*2 + 1, b = i*2 + 2;
debug("heap_sift_down().while i:%d a:%d b:%d\n", i, a, b);
// NOTE: I use is_lt() instead of proper cmp() function - it does the job
if (a < heap_len && is_lt(ary[i], ary[a])) {
if (b < heap_len && is_lt(ary[a], ary[b])) {
swap(ary, i, b);
i = b;
} else {
swap(ary, i, a);
i = a;
}
} else if (b < heap_len && is_lt(ary[i], ary[b])) {
swap(ary, i, b);
i = b;
} else {
// No more childs exist, or they satisfy the heap invariant
break;
}
}
}
inline int is_lt(long a, long b) {
return a < b;
}
inline int is_gt(long a, long b) {
return a > b;
}
void swap(long *ary, int i, int j) {
debug("swap(%d, %d)\n", i, j);
long tmp = ary[i];
ary[i] = ary[j];
ary[j] = tmp;
}
// This returns the maximum/root and moves children up to keep the Heap
// invariant. not really needed here... Hoops!
// TODO yin: Move to dedicated Heap source
long heap_extract_max(long *ary, int heap_len) {
int ret;
if (heap_len > 0) {
ret = ary[0];
int i = 0;
while (i < heap_len) {
int a = i*2 + 1, b = i*2 + 2;
// NOTE: I use is_gt() instead of proper cmp() function - it does the job
if (a < heap_len && is_gt(ary[a], ary[b])) {
swap(ary, i, a);
i = a;
} else if (b < heap_len && (i == 0 || is_gt(ary[i], ary[b]))) {
swap(ary, i, b);
i = b;
} else {
// No more childs exist, or they satisfy the heap invariant
break;
}
}
} // NOTE: What to do in an empty heap??? Go crazy?
return ret;
}
|
the_stack_data/184518743.c | /**
* C helper file for testing whether `lib.rs` actually compiles
*/
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <net/if.h>
#include <linux/if_tun.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/select.h>
#include <fcntl.h>
extern int client_tx(int len);
typedef uint32_t seL4_Word;
extern void *client_buf(seL4_Word client_id);
char packet_bytes[] = { 2, 0, 0, 0, 1, 1, 82, 84, 0, 0, 0, 0, 8, 0, 69, 0, 0,
31, 0, 0, 64, 0, 64, 17, 47, 120, 192, 168, 69, 3, 192, 168, 69, 2, 175,
211, 27, 57, 0, 11, 190, 19, 97, 97, 10 };
/**
* Main program
*/
int main()
{
int len = 0;
char* buf = (char*)client_buf(1);
for (int i = 0; i <= sizeof(packet_bytes); i++) {
buf[i] = packet_bytes[i];
len = i;
}
int returnval = client_tx(len);
printf("client_tx transmitted %u bytes with return value %i\n", len,
returnval);
returnval = client_tx(len);
printf("client_tx transmitted %u bytes with return value %i\n", len,
returnval);
}
|
the_stack_data/48576562.c | #include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[]){
if(argc < 2){
printf("Brak 1 argumentu(nazwa zmienej)!\n");
return 1;
}
char* value = getenv(argv[1]);
if(value == NULL){
printf("Brak ustawionej zmienej %s\n", argv[1]);
}
else{
printf("Zmiena %s ustawiona na wartosc %s\n",argv[1],value);
}
return 0;
}
|
the_stack_data/106439.c | #include<stdio.h>
#include<stdlib.h>
#include<signal.h>
#include<unistd.h>
#include<pthread.h>
#include<semaphore.h>
#define MAX_THREADS 5
void * reader(void *arg);
void * writer(void * arg);
sem_t mutex;
sem_t writeblock;
int data = 0;
int rcount = 0;
int main(int argc, char * argv[])
{
int i, b;
pthread_t rtid[MAX_THREADS];
pthread_t wtid[MAX_THREADS];
sem_init(&mutex, 0, 1);
sem_init(&writeblock, 0, 1);
// while(1)
// {
for (int i = 0; i < MAX_THREADS; i++)
{
pthread_create(&rtid[i], NULL, reader, (void *) i);
pthread_create(&wtid[i], NULL, writer, (void *) i);
}
for (int i = 0; i < MAX_THREADS; i++)
{
pthread_join(rtid[i], NULL);
pthread_join(wtid[i], NULL);
}
// }
return 0;
}
void * reader(void * arg)
{
int id = (int) arg;
sem_wait(&mutex);
rcount += 1;
if(rcount == 1)
sem_wait(&writeblock);
sem_post(&mutex);
printf("Data read by the reader %d is %d\n", id, data);
sleep(1);
sem_wait(&mutex);
rcount -= 1;
if(rcount == 0)
sem_post(&writeblock);
sem_post(&mutex);
}
void * writer(void * arg)
{
/*get write unlock and then do the change data for showing*/
int id = (int) arg;
sem_wait(&writeblock);
data++;
printf("Data write by the writer %d is %d\n", id, data);
sleep(1);
sem_post(&writeblock);
} |
the_stack_data/31388434.c | /*************************************************************************\
* Copyright (C) Michael Kerrisk, 2020. *
* *
* This program is free software. You may use, modify, and redistribute it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation, either version 3 or (at your option) any *
* later version. This program is distributed without any warranty. See *
* the file COPYING.gpl-v3 for details. *
\*************************************************************************/
/* Listing 6-6 */
/* setjmp_vars.c
Compiling this program with and without optimization yields different
results, since the optimizer reorganizes code and variables in a manner
that does not take account of the dynamic flow of control established by
a long jump.
Try looking at the assembler source (.s) for the unoptimized (cc -S)
and optimized (cc -O -S) versions of this program to see the cause
of these differences.
*/
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
static jmp_buf env;
static void
doJump(int nvar, int rvar, int vvar)
{
printf("Inside doJump(): nvar=%d rvar=%d vvar=%d\n", nvar, rvar, vvar);
longjmp(env, 1);
}
int
main(int argc, char *argv[])
{
int nvar;
register int rvar; /* Allocated in register if possible */
volatile int vvar; /* See text */
nvar = 111;
rvar = 222;
vvar = 333;
if (setjmp(env) == 0) { /* Code executed after setjmp() */
nvar = 777;
rvar = 888;
vvar = 999;
doJump(nvar, rvar, vvar);
} else { /* Code executed after longjmp() */
printf("After longjmp(): nvar=%d rvar=%d vvar=%d\n", nvar, rvar, vvar);
}
exit(EXIT_SUCCESS);
}
|
the_stack_data/90766661.c | // RUN: %clang -### -S -fwrapv -fno-wrapv -fwrapv %s 2>&1 | FileCheck -check-prefix=CHECK1 %s
// CHECK1: -fwrapv
//
// RUN: %clang -### -S -fstrict-overflow -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK2 %s
// CHECK2: -fwrapv
//
// RUN: %clang -### -S -fwrapv -fstrict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK3 %s
// CHECK3: -fwrapv
//
// RUN: %clang -### -S -fno-wrapv -fno-strict-overflow %s 2>&1 | FileCheck -check-prefix=CHECK4 %s
// CHECK4-NOT: -fwrapv
|
the_stack_data/14199549.c | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/epoll.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
// WireGuard ---> W2U --> udp2raw
int main(int argc, char* argv[])
{
int ret, flags;
int listener, sender, ep;
int PORT_WG=51820, PORT_ENDP=29000, PORT_UR_BEGIN=29100, PORT_UR_SIZE=10;
while((ret = getopt(argc, argv, "hf:l:t:s:")) != -1)
{
switch(ret)
{
case 'f':
PORT_WG=atoi(optarg);
break;
case 'l':
PORT_ENDP=atoi(optarg);
break;
case 't':
PORT_UR_BEGIN=atoi(optarg);
break;
case 's':
PORT_UR_SIZE=atoi(optarg);
break;
case 'h':
default:
fprintf(stderr, "Usage: %s -f WGPort -l ListenPort -t TargetPort -s TargetRange\n", argv[0]);
exit(1);
}
}
fprintf(stderr, "listening on %d, receiving from %d and sending to [%d,%d)\n", PORT_ENDP, PORT_WG, PORT_UR_BEGIN, PORT_UR_BEGIN+PORT_UR_SIZE);
listener = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in saddr;
memset(&saddr, 0, sizeof(saddr));
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = INADDR_ANY;
saddr.sin_port = htons(PORT_ENDP);
ret = bind(listener, (const struct sockaddr*)&saddr, sizeof(saddr));
if (ret < 0) {
perror("bind");
exit(1);
}
sender = socket(AF_INET, SOCK_DGRAM, 0);
// Set to non-blocking
flags = fcntl(listener, F_GETFL, 0);
if (flags < 0)
{
perror("fcntl");
exit(1);
}
flags |= O_NONBLOCK;
fcntl(listener, F_SETFL, flags);
flags = fcntl(sender, F_GETFL, 0);
if (flags < 0)
{
perror("fcntl");
exit(1);
}
flags |= O_NONBLOCK;
fcntl(sender, F_SETFL, flags);
ep = epoll_create(1024);
struct epoll_event ev1;
ev1.events = EPOLLIN | EPOLLET;
ev1.data.fd = listener;
struct epoll_event ev2;
ev2.events = EPOLLIN | EPOLLET;
ev2.data.fd = sender;
epoll_ctl(ep, EPOLL_CTL_ADD, listener, &ev1);
epoll_ctl(ep, EPOLL_CTL_ADD, sender, &ev2);
struct epoll_event events[1024];
struct sockaddr_in* addrTargets = (struct sockaddr_in*)malloc(sizeof(struct sockaddr_in) * PORT_UR_SIZE);
memset(addrTargets, 0, sizeof(struct sockaddr_in) * PORT_UR_SIZE);
for(int i=0; i<PORT_UR_SIZE; i++) {
addrTargets[i].sin_family = AF_INET;
inet_pton(AF_INET, "127.0.0.1", &addrTargets[i].sin_addr);
addrTargets[i].sin_port = htons(PORT_UR_BEGIN + i);
}
struct sockaddr_in addrWg;
memset(&addrWg, 0, sizeof(addrWg));
addrWg.sin_family = AF_INET;
inet_pton(AF_INET, "127.0.0.1", &addrWg.sin_addr);
addrWg.sin_port = htons(PORT_WG);
int rrOffset = 0;
char buffer[4096];
while(1)
{
int nfds = epoll_wait(ep, events, sizeof(events), -1);
if (nfds < 0) {
perror("epoll_wait");
break;
}
for (int i=0;i<nfds; i++)
{
if (events[i].data.fd == listener)
{
int nsize;
while((nsize = recvfrom(listener, buffer, sizeof(buffer), 0, NULL, NULL)) > 0) {
sendto(sender, buffer, nsize, 0, (const struct sockaddr*)(addrTargets + rrOffset), sizeof(struct sockaddr_in));
if (++rrOffset >= PORT_UR_SIZE) {
rrOffset = 0;
}
}
if (nsize < 0 && errno != EAGAIN) {
perror("recvfrom: ");
}
}
else if (events[i].data.fd == sender)
{
int nsize;
while((nsize = recvfrom(sender, buffer, sizeof(buffer), 0, NULL, NULL)) > 0) {
sendto(listener, buffer, nsize, 0, (const struct sockaddr*)&addrWg, sizeof(struct sockaddr_in));
}
if (nsize < 0 && errno != EAGAIN) {
perror("recvfrom: ");
}
}
}
}
}
|
the_stack_data/67842.c | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sort_params.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: odursun <42istanbul.com.tr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/06 16:06:11 by odursun #+# #+# */
/* Updated: 2021/11/06 16:06:12 by odursun ### ########.tr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_putstr(char *str)
{
int i;
i = 0;
while (str[i])
i++;
write(1, str, i);
}
int ft_strcmp(char *s1, char *s2)
{
while (*s1 && (*s1 == *s2))
{
s1++;
s2++;
}
return (*s1 - *s2);
}
void ft_swap(char **x, char **y)
{
char *temp;
temp = *x;
*x = *y;
*y = temp;
}
void ft_sort_ascii(char *tab[], int size)
{
int i;
int j;
i = 0;
while (i < size)
{
j = 0;
while (j < size - i - 1)
{
if (ft_strcmp(tab[j], tab[j + 1]) > 0)
ft_swap(&tab[j], &tab[j + 1]);
j++;
}
i++;
}
}
int main(int argc, char *argv[])
{
int i;
if (argc > 1)
{
ft_sort_ascii(argv + 1, argc - 1);
i = 1;
while (argv[i])
{
ft_putstr(argv[i++]);
write(1, "\n", 1);
}
}
return (0);
}
|
the_stack_data/173579095.c | /* altnames.c --可移植整数类型名 */
#include <stdio.h>
#include <inttypes.h>
int main(void)
{
int32_t me32;
me32 = 45933945;
printf("First, assume int32_t is int: ");
printf("me32 = %d\n", me32);
printf("Next, let's not take any assumptions.\n");
printf("Instead, use a \"macro\" from inttypes.h: ");
printf("me32 = %" PRId32 "\n", me32);
return 0;
} |
the_stack_data/168892942.c | // Tests use-after-return detection and reporting.
// RUN: %clang_hwasan -g %s -o %t && not %run %t 2>&1 | FileCheck %s
// RUN: %clang_hwasan -g %s -o %t && not %env_hwasan_opts=symbolize=0 %run %t 2>&1 | FileCheck %s --check-prefix=NOSYM
// REQUIRES: stable-runtime
// Stack histories currently are not recorded on x86.
// XFAIL: x86_64
void USE(void *x) { // pretend_to_do_something(void *x)
__asm__ __volatile__("" : : "r" (x) : "memory");
}
__attribute__((noinline))
char *buggy() {
char zzz[0x1000];
char *volatile p = zzz;
return p;
}
__attribute__((noinline)) void Unrelated1() { int A[2]; USE(&A[0]); }
__attribute__((noinline)) void Unrelated2() { int BB[3]; USE(&BB[0]); }
__attribute__((noinline)) void Unrelated3() { int CCC[4]; USE(&CCC[0]); }
int main() {
char *p = buggy();
Unrelated1();
Unrelated2();
Unrelated3();
return *p;
// CHECK: READ of size 1 at
// CHECK: #0 {{.*}} in main{{.*}}stack-uar.c:[[@LINE-2]]
// CHECK: is located in stack of thread
// CHECK: Potentially referenced stack objects:
// CHECK-NEXT: zzz in buggy {{.*}}stack-uar.c:[[@LINE-19]]
// CHECK-NEXT: Memory tags around the buggy address
// NOSYM: Previously allocated frames:
// NOSYM-NEXT: record_addr:0x{{.*}} record:0x{{.*}} ({{.*}}/stack-uar.c.tmp+0x{{.*}}){{$}}
// NOSYM-NEXT: record_addr:0x{{.*}} record:0x{{.*}} ({{.*}}/stack-uar.c.tmp+0x{{.*}}){{$}}
// NOSYM-NEXT: record_addr:0x{{.*}} record:0x{{.*}} ({{.*}}/stack-uar.c.tmp+0x{{.*}}){{$}}
// NOSYM-NEXT: record_addr:0x{{.*}} record:0x{{.*}} ({{.*}}/stack-uar.c.tmp+0x{{.*}}){{$}}
// NOSYM-NEXT: Memory tags around the buggy address
// CHECK: SUMMARY: HWAddressSanitizer: tag-mismatch {{.*}} in main
}
|
the_stack_data/923112.c | /*!
* \brief A demo about recursion.
*/
#include <stdio.h>
#define NUM 8
#define DG_NUM (NUM * 2) - 1
static char Queen[NUM][NUM];
static char colflag[NUM];
static char diagonal[DG_NUM];
static char rdiagonal[DG_NUM];
static int status_num = 0;
void output()
{
int col = 0;
int row = 0;
printf("Status %d: \n", ++status_num);
for(col = 0; col < NUM; col++)
{
for(row = 0; row < NUM; row++)
{
printf("%c ", Queen[col][row]);
}
printf("\n");
}
}
void dispose(int line)
{
int col = 0;
for(col = 0; col < NUM; col++)
{
// esurience
if(colflag[col] == 0 &&
diagonal[line + NUM - col - 1] == 0 &&
rdiagonal[line + col] == 0)
{
Queen[line][col] = '@';
colflag[col] = 1;
diagonal[line + NUM - col - 1] = 1;
rdiagonal[line + col] = 1;
if(line < NUM - 1)
{
// recursion
dispose(line + 1);
}
else
{
output();
}
// back track.
Queen[line][col] = '*';
colflag[col] = 0;
diagonal[line + NUM - col - 1] = 0;
rdiagonal[line + col] = 0;
}
}
}
int main(int argc, char *argv[])
{
int col = 0;
int line = 0;
// Initialize
for(col = 0; col < NUM; col++)
{
colflag[col] = 0;
for(line = 0; line < NUM; line++)
{
Queen[col][line] = '*';
}
}
for(line = 0; line < DG_NUM; line++)
{
diagonal[line] = rdiagonal[line] = 0;
}
//
dispose(0);
return 0;
}
|
the_stack_data/97012747.c | /* creates a var named example, and a var p that stores the address of example, then displays available info */
#include <stdio.h>
int main(){
long example = 100;
long *p = NULL;
p = &example;
printf("example = '%ld' | p = '%ld' | *p = '%ld'\n", example, p, *p);
return 0;
}
|
the_stack_data/598259.c | /* hello2.c
* purpose show how to curses functions with a loop
* outline initialize, draw stuff, wrap up
*/
#include <stdio.h>
#include <curses.h>
int main()
{
int i;
initscr();
clear();
for (i = 0; i < LINES; i++) {
move(i, i + i);
if (i % 2 == 1)
standout();
addstr("Hello, world");
if (i % 2 == 1)
standend();
refresh();
getch();
endwin();
return 0;
}
} |
the_stack_data/140764608.c | /* Write a program to "fold" long input lines into two or more shorter lines
after the last non-blank character that occurs before the n-th column of input.
Make sure your program does somthing intelligent with very long lines, and
if there are no banks or tabs before the specified column. */
#include <stdio.h>
#define COLUMN 5
int main(void)
{
int c, i, j, k;
char line[COLUMN+1];
i = 0;
while ((c = getchar()) != EOF)
if (c == '\n') // if line new print string and reset counter
{
line[i] = c;
line[i+1] = '\0';
printf("%s", line);
i = 0; // reset counter
}
else if (i <= COLUMN-1) // if characters have not pass the column limit
{
line[i] = c; // add the last read char to the string
++i;
}
else
{
k = 0;
for (j = i-1; (line[j] == ' ') && (j >= 0); --j) // go to the last non blank char
++k ;
line[j+1] = '\0';
printf("%s", line); // add NULL to the end and print string
for (i = 0; i < k; ++i) // add spaces back and the last char
line[i] = ' ';
line[i] = c; // add char to the next string
++i;
}
line[i] = '\0'; // print the last chars
printf("%s\n", line);
return 0;
}
|
the_stack_data/119575.c | //
// EmptyFile.c
// RayComposer1.6
//
// Created by Michael on 04/08/2017.
// Copyright © 2017 Michael Prokofyev. All rights reserved.
//
#include <stdio.h>
|
the_stack_data/36782.c | /***************************************************************
Copyright © ALIENTEK Co., Ltd. 1998-2029. All rights reserved.
文件名 : keyApp.c
作者 : 正点原子Linux团队
版本 : V1.0
描述 : 以非阻塞方式读取按键状态
其他 : 无
使用方法 : ./keyApp /dev/key
论坛 : www.openedv.com
日志 : 初版V1.0 2021/01/19 正点原子Linux团队创建
***************************************************************/
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <poll.h>
/*
* @description : main主程序
* @param – argc : argv数组元素个数
* @param – argv : 具体参数
* @return : 0 成功;其他 失败
*/
int main(int argc, char *argv[])
{
fd_set readfds;
int key_val;
int fd;
int ret;
/* 判断传参个数是否正确 */
if(2 != argc) {
printf("Usage:\n"
"\t./keyApp /dev/key\n"
);
return -1;
}
/* 打开设备 */
fd = open(argv[1], O_RDONLY | O_NONBLOCK);
if(0 > fd) {
printf("ERROR: %s file open failed!\n", argv[1]);
return -1;
}
FD_ZERO(&readfds);
FD_SET(fd, &readfds);
/* 循环轮训读取按键数据 */
for ( ; ; ) {
ret = select(fd + 1, &readfds, NULL, NULL, NULL);
switch (ret) {
case 0: // 超时
/* 用户自定义超时处理 */
break;
case -1: // 错误
/* 用户自定义错误处理 */
break;
default:
if(FD_ISSET(fd, &readfds)) {
read(fd, &key_val, sizeof(int));
if (0 == key_val)
printf("Key Press\n");
else if (1 == key_val)
printf("Key Release\n");
}
break;
}
}
/* 关闭设备 */
close(fd);
return 0;
} |
the_stack_data/62638933.c | /**
******************************************************************************
* @file stm32u5xx_ll_dma.c
* @author MCD Application Team
* @brief DMA LL module driver.
******************************************************************************
* @attention
*
* Copyright (c) 2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
@verbatim
==============================================================================
##### LL DMA driver acronyms #####
==============================================================================
[..] Acronyms table :
=========================================
|| Acronym || ||
=========================================
|| SRC || Source ||
|| DEST || Destination ||
|| ADDR || Address ||
|| ADDRS || Addresses ||
|| INC || Increment / Incremented ||
|| DEC || Decrement / Decremented ||
|| BLK || Block ||
|| RPT || Repeat / Repeated ||
|| TRIG || Trigger ||
=========================================
@endverbatim
******************************************************************************
*/
#if defined (USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/
#include "stm32u5xx_ll_dma.h"
#include "stm32u5xx_ll_bus.h"
#ifdef USE_FULL_ASSERT
#include "stm32_assert.h"
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
/** @addtogroup STM32U5xx_LL_Driver
* @{
*/
#if (defined (GPDMA1) || defined (LPDMA1))
/** @addtogroup DMA_LL
* @{
*/
/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup DMA_LL_Private_Macros
* @{
*/
#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, Channel) ((((INSTANCE) == GPDMA1) && \
(((Channel) == LL_DMA_CHANNEL_0) || \
((Channel) == LL_DMA_CHANNEL_1) || \
((Channel) == LL_DMA_CHANNEL_2) || \
((Channel) == LL_DMA_CHANNEL_3) || \
((Channel) == LL_DMA_CHANNEL_4) || \
((Channel) == LL_DMA_CHANNEL_5) || \
((Channel) == LL_DMA_CHANNEL_6) || \
((Channel) == LL_DMA_CHANNEL_7) || \
((Channel) == LL_DMA_CHANNEL_8) || \
((Channel) == LL_DMA_CHANNEL_9) || \
((Channel) == LL_DMA_CHANNEL_10) || \
((Channel) == LL_DMA_CHANNEL_11) || \
((Channel) == LL_DMA_CHANNEL_12) || \
((Channel) == LL_DMA_CHANNEL_13) || \
((Channel) == LL_DMA_CHANNEL_14) || \
((Channel) == LL_DMA_CHANNEL_15) || \
((Channel) == LL_DMA_CHANNEL_ALL))) || \
(((INSTANCE) == LPDMA1) && \
(((Channel) == LL_DMA_CHANNEL_0) || \
((Channel) == LL_DMA_CHANNEL_1) || \
((Channel) == LL_DMA_CHANNEL_2) || \
((Channel) == LL_DMA_CHANNEL_3) || \
((Channel) == LL_DMA_CHANNEL_ALL))))
#define IS_LL_GPDMA_CHANNEL_INSTANCE(INSTANCE, Channel) (((INSTANCE) == GPDMA1) && \
(((Channel) == LL_DMA_CHANNEL_0) || \
((Channel) == LL_DMA_CHANNEL_1) || \
((Channel) == LL_DMA_CHANNEL_2) || \
((Channel) == LL_DMA_CHANNEL_3) || \
((Channel) == LL_DMA_CHANNEL_4) || \
((Channel) == LL_DMA_CHANNEL_5) || \
((Channel) == LL_DMA_CHANNEL_6) || \
((Channel) == LL_DMA_CHANNEL_7) || \
((Channel) == LL_DMA_CHANNEL_8) || \
((Channel) == LL_DMA_CHANNEL_9) || \
((Channel) == LL_DMA_CHANNEL_10) || \
((Channel) == LL_DMA_CHANNEL_11) || \
((Channel) == LL_DMA_CHANNEL_12) || \
((Channel) == LL_DMA_CHANNEL_13) || \
((Channel) == LL_DMA_CHANNEL_14) || \
((Channel) == LL_DMA_CHANNEL_15)))
#define IS_LL_DMA_2D_CHANNEL_INSTANCE(INSTANCE, Channel) (((INSTANCE) == GPDMA1) && \
(((Channel) == LL_DMA_CHANNEL_12) || \
((Channel) == LL_DMA_CHANNEL_13) || \
((Channel) == LL_DMA_CHANNEL_14) || \
((Channel) == LL_DMA_CHANNEL_15)))
#define IS_LL_DMA_DIRECTION(__VALUE__) (((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_MEMORY) || \
((__VALUE__) == LL_DMA_DIRECTION_PERIPH_TO_MEMORY) || \
((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_PERIPH))
#define IS_LL_DMA_DATA_ALIGNMENT(__VALUE__) (((__VALUE__) == LL_DMA_DATA_ALIGN_ZEROPADD) || \
((__VALUE__) == LL_DMA_DATA_ALIGN_SIGNEXTPADD) || \
((__VALUE__) == LL_DMA_DATA_PACK_UNPACK))
#define IS_LL_DMA_BURST_LENGTH(__VALUE__) (((__VALUE__) > 0U) && ((__VALUE__) <= 64U))
#define IS_LL_DMA_SRC_DATA_WIDTH(__VALUE__) (((__VALUE__) == LL_DMA_SRC_DATAWIDTH_BYTE) || \
((__VALUE__) == LL_DMA_SRC_DATAWIDTH_HALFWORD) || \
((__VALUE__) == LL_DMA_SRC_DATAWIDTH_WORD))
#define IS_LL_DMA_DEST_DATA_WIDTH(__VALUE__) (((__VALUE__) == LL_DMA_DEST_DATAWIDTH_BYTE) || \
((__VALUE__) == LL_DMA_DEST_DATAWIDTH_HALFWORD) || \
((__VALUE__) == LL_DMA_DEST_DATAWIDTH_WORD))
#define IS_LL_DMA_SRC_INCREMENT_MODE(__VALUE__) (((__VALUE__) == LL_DMA_SRC_FIXED) || \
((__VALUE__) == LL_DMA_SRC_INCREMENT))
#define IS_LL_DMA_DEST_INCREMENT_MODE(__VALUE__) (((__VALUE__) == LL_DMA_DEST_FIXED) || \
((__VALUE__) == LL_DMA_DEST_INCREMENT))
#define IS_LL_DMA_PRIORITY(__VALUE__) (((__VALUE__) == LL_DMA_LOW_PRIORITY_LOW_WEIGHT) || \
((__VALUE__) == LL_DMA_LOW_PRIORITY_MID_WEIGHT) || \
((__VALUE__) == LL_DMA_LOW_PRIORITY_HIGH_WEIGHT) || \
((__VALUE__) == LL_DMA_HIGH_PRIORITY))
#define IS_LL_DMA_BLK_DATALENGTH(__VALUE__) ((__VALUE__) <= 0xFFFFU)
#define IS_LL_DMA_BLK_REPEATCOUNT(__VALUE__) ((__VALUE__) <= 0x0EFFU)
#define IS_LL_DMA_TRIGGER_MODE(__VALUE__) (((__VALUE__) == LL_DMA_TRIGM_BLK_TRANSFER) || \
((__VALUE__) == LL_DMA_TRIGM_RPT_BLK_TRANSFER) || \
((__VALUE__) == LL_DMA_TRIGM_LLI_LINK_TRANSFER) || \
((__VALUE__) == LL_DMA_TRIGM_SINGLBURST_TRANSFER ))
#define IS_LL_DMA_TRIGGER_POLARITY(__VALUE__) (((__VALUE__) == LL_DMA_TRIG_POLARITY_MASKED) || \
((__VALUE__) == LL_DMA_TRIG_POLARITY_RISING) || \
((__VALUE__) == LL_DMA_TRIG_POLARITY_FALLING))
#define IS_LL_DMA_BLKHW_REQUEST(__VALUE__) (((__VALUE__) == LL_DMA_HWREQUEST_SINGLEBURST) || \
((__VALUE__) == LL_DMA_HWREQUEST_BLK))
#define IS_LL_DMA_TRIGGER_SELECTION(__VALUE__) ((__VALUE__) <= LL_GPDMA1_TRIGGER_TIM15_TRGO)
#define IS_LL_DMA_REQUEST_SELECTION(__VALUE__) ((__VALUE__) <= LL_GPDMA1_REQUEST_LPTIM3_UE)
#define IS_LL_DMA_TRANSFER_EVENT_MODE(__VALUE__) (((__VALUE__) == LL_DMA_TCEM_BLK_TRANSFER) || \
((__VALUE__) == LL_DMA_TCEM_RPT_BLK_TRANSFER) || \
((__VALUE__) == LL_DMA_TCEM_EACH_LLITEM_TRANSFER) || \
((__VALUE__) == LL_DMA_TCEM_LAST_LLITEM_TRANSFER))
#define IS_LL_DMA_DEST_HALFWORD_EXCHANGE(__VALUE__) (((__VALUE__) == LL_DMA_DEST_HALFWORD_PRESERVE) || \
((__VALUE__) == LL_DMA_DEST_HALFWORD_EXCHANGE))
#define IS_LL_DMA_DEST_BYTE_EXCHANGE(__VALUE__) (((__VALUE__) == LL_DMA_DEST_BYTE_PRESERVE) || \
((__VALUE__) == LL_DMA_DEST_BYTE_EXCHANGE))
#define IS_LL_DMA_SRC_BYTE_EXCHANGE(__VALUE__) (((__VALUE__) == LL_DMA_SRC_BYTE_PRESERVE) || \
((__VALUE__) == LL_DMA_SRC_BYTE_EXCHANGE))
#define IS_LL_DMA_LINK_ALLOCATED_PORT(__VALUE__) (((__VALUE__) == LL_DMA_LINK_ALLOCATED_PORT0) || \
((__VALUE__) == LL_DMA_LINK_ALLOCATED_PORT1))
#define IS_LL_DMA_SRC_ALLOCATED_PORT(__VALUE__) (((__VALUE__) == LL_DMA_SRC_ALLOCATED_PORT0) || \
((__VALUE__) == LL_DMA_SRC_ALLOCATED_PORT1))
#define IS_LL_DMA_DEST_ALLOCATED_PORT(__VALUE__) (((__VALUE__) == LL_DMA_DEST_ALLOCATED_PORT0) || \
((__VALUE__) == LL_DMA_DEST_ALLOCATED_PORT1))
#define IS_LL_DMA_LINK_STEP_MODE(__VALUE__) (((__VALUE__) == LL_DMA_LSM_FULL_EXECUTION) || \
((__VALUE__) == LL_DMA_LSM_1LINK_EXECUTION))
#define IS_LL_DMA_BURST_SRC_ADDR_UPDATE(__VALUE__) (((__VALUE__) == LL_DMA_BURST_SRC_ADDR_INCREMENT) || \
((__VALUE__) == LL_DMA_BURST_SRC_ADDR_DECREMENT))
#define IS_LL_DMA_BURST_DEST_ADDR_UPDATE(__VALUE__) (((__VALUE__) == LL_DMA_BURST_DEST_ADDR_INCREMENT) || \
((__VALUE__) == LL_DMA_BURST_DEST_ADDR_DECREMENT))
#define IS_LL_DMA_BURST_ADDR_UPDATE_VALUE(__VALUE__) ((__VALUE__) <= 0x1FFFU)
#define IS_LL_DMA_BLKRPT_SRC_ADDR_UPDATE(__VALUE__) (((__VALUE__) == LL_DMA_BLKRPT_SRC_ADDR_INCREMENT) || \
((__VALUE__) == LL_DMA_BLKRPT_SRC_ADDR_DECREMENT))
#define IS_LL_DMA_BLKRPT_DEST_ADDR_UPDATE(__VALUE__) (((__VALUE__) == LL_DMA_BLKRPT_DEST_ADDR_INCREMENT) || \
((__VALUE__) == LL_DMA_BLKRPT_DEST_ADDR_DECREMENT))
#define IS_LL_DMA_BLKRPT_ADDR_UPDATE_VALUE(__VALUE__) ((__VALUE__) <= 0xFFFFU)
#define IS_LL_DMA_LINK_BASEADDR(__VALUE__) (((__VALUE__) & 0xFFFFU) == 0U)
#define IS_LL_DMA_LINK_ADDR_OFFSET(__VALUE__) (((__VALUE__) & 0x03U) == 0U)
#define IS_LL_DMA_LINK_UPDATE_REGISTERS(__VALUE__) ((((__VALUE__) & 0x01FE0000U) == 0U) && ((__VALUE__) != 0U))
#define IS_LL_DMA_LINK_NODETYPE(__VALUE__) (((__VALUE__) == LL_DMA_GPDMA_2D_NODE) || \
((__VALUE__) == LL_DMA_GPDMA_LINEAR_NODE) || \
((__VALUE__) == LL_DMA_LPDMA_LINEAR_NODE))
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
#define IS_LL_DMA_CHANNEL_SRC_SEC(__VALUE__) (((__VALUE__) == LL_DMA_CHANNEL_SRC_NSEC) || \
((__VALUE__) == LL_DMA_CHANNEL_SRC_SEC))
#define IS_LL_DMA_CHANNEL_DEST_SEC(__VALUE__) (((__VALUE__) == LL_DMA_CHANNEL_DEST_NSEC) || \
((__VALUE__) == LL_DMA_CHANNEL_DEST_SEC))
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
/**
* @}
*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup DMA_LL_Exported_Functions
* @{
*/
/** @addtogroup DMA_LL_EF_Init
* @{
*/
/**
* @brief De-initialize the DMA registers to their default reset values.
* @note This API is used for all available DMA channels.
* @note To convert DMAx_Channely Instance to DMAx Instance and Channely, use
* helper macros :
* @arg @ref LL_DMA_GET_INSTANCE
* @arg @ref LL_DMA_GET_CHANNEL
* @param DMAx DMAx Instance
* @param Channel This parameter can be one of the following values:
* @arg @ref LL_DMA_CHANNEL_0
* @arg @ref LL_DMA_CHANNEL_1
* @arg @ref LL_DMA_CHANNEL_2
* @arg @ref LL_DMA_CHANNEL_3
* @arg @ref LL_DMA_CHANNEL_4
* @arg @ref LL_DMA_CHANNEL_5
* @arg @ref LL_DMA_CHANNEL_6
* @arg @ref LL_DMA_CHANNEL_7
* @arg @ref LL_DMA_CHANNEL_8
* @arg @ref LL_DMA_CHANNEL_9
* @arg @ref LL_DMA_CHANNEL_10
* @arg @ref LL_DMA_CHANNEL_11
* @arg @ref LL_DMA_CHANNEL_12
* @arg @ref LL_DMA_CHANNEL_13
* @arg @ref LL_DMA_CHANNEL_14
* @arg @ref LL_DMA_CHANNEL_15
* @retval An ErrorStatus enumeration value:
* - SUCCESS : DMA registers are de-initialized.
* - ERROR : DMA registers are not de-initialized.
*/
uint32_t LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel)
{
DMA_Channel_TypeDef *tmp;
ErrorStatus status = SUCCESS;
/* Check the DMA Instance DMAx and Channel parameters */
assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
if (Channel == LL_DMA_CHANNEL_ALL)
{
if (DMAx == GPDMA1)
{
/* Force reset of DMA clock */
LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_GPDMA1);
/* Release reset of DMA clock */
LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_GPDMA1);
}
else
{
/* Force reset of DMA clock */
LL_AHB3_GRP1_ForceReset(LL_AHB3_GRP1_PERIPH_LPDMA1);
/* Release reset of DMA clock */
LL_AHB3_GRP1_ReleaseReset(LL_AHB3_GRP1_PERIPH_LPDMA1);
}
}
else
{
/* Get the DMA Channel Instance */
tmp = (DMA_Channel_TypeDef *)(LL_DMA_GET_CHANNEL_INSTANCE(DMAx, Channel));
/* Suspend DMA channel */
LL_DMA_SuspendChannel(DMAx, Channel);
/* Disable the selected Channel */
LL_DMA_ResetChannel(DMAx, Channel);
/* Reset DMAx_Channely control register */
LL_DMA_WriteReg(tmp, CLBAR, 0U);
/* Reset DMAx_Channely control register */
LL_DMA_WriteReg(tmp, CCR, 0U);
/* Reset DMAx_Channely Configuration register */
LL_DMA_WriteReg(tmp, CTR1, 0U);
/* Reset DMAx_Channely transfer register 2 */
LL_DMA_WriteReg(tmp, CTR2, 0U);
/* Reset DMAx_Channely block number of data register */
LL_DMA_WriteReg(tmp, CBR1, 0U);
/* Reset DMAx_Channely source address register */
LL_DMA_WriteReg(tmp, CSAR, 0U);
/* Reset DMAx_Channely destination address register */
LL_DMA_WriteReg(tmp, CDAR, 0U);
/* Check DMA channel */
if (IS_LL_DMA_2D_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
/* Reset DMAx_Channely transfer register 3 */
LL_DMA_WriteReg(tmp, CTR3, 0U);
/* Reset DMAx_Channely Block register 2 */
LL_DMA_WriteReg(tmp, CBR2, 0U);
}
/* Reset DMAx_Channely Linked list address register */
LL_DMA_WriteReg(tmp, CLLR, 0U);
/* Reset DMAx_Channely pending flags */
LL_DMA_WriteReg(tmp, CFCR, 0x00003F00U);
/* Reset DMAx_Channely attribute */
LL_DMA_DisableChannelPrivilege(DMAx, Channel);
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
LL_DMA_DisableChannelSecure(DMAx, Channel);
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
}
return (uint32_t)status;
}
/**
* @brief Initialize the DMA registers according to the specified parameters
* in DMA_InitStruct.
* @note This API is used for all available DMA channels.
* @note A software request transfer can be done once programming the direction
* field in memory to memory value.
* @note To convert DMAx_Channely Instance to DMAx Instance and Channely, use
* helper macros :
* @arg @ref LL_DMA_GET_INSTANCE
* @arg @ref LL_DMA_GET_CHANNEL
* @param DMAx DMAx Instance
* @param Channel This parameter can be one of the following values:
* @arg @ref LL_DMA_CHANNEL_0
* @arg @ref LL_DMA_CHANNEL_1
* @arg @ref LL_DMA_CHANNEL_2
* @arg @ref LL_DMA_CHANNEL_3
* @arg @ref LL_DMA_CHANNEL_4
* @arg @ref LL_DMA_CHANNEL_5
* @arg @ref LL_DMA_CHANNEL_6
* @arg @ref LL_DMA_CHANNEL_7
* @arg @ref LL_DMA_CHANNEL_8
* @arg @ref LL_DMA_CHANNEL_9
* @arg @ref LL_DMA_CHANNEL_10
* @arg @ref LL_DMA_CHANNEL_11
* @arg @ref LL_DMA_CHANNEL_12
* @arg @ref LL_DMA_CHANNEL_13
* @arg @ref LL_DMA_CHANNEL_14
* @arg @ref LL_DMA_CHANNEL_15
* @param DMA_InitStruct pointer to a @ref LL_DMA_InitTypeDef structure.
* @retval An ErrorStatus enumeration value:
* - SUCCESS : DMA registers are initialized.
* - ERROR : Not applicable.
*/
uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct)
{
/* Check the DMA Instance DMAx and Channel parameters*/
assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
/* Check the DMA parameters from DMA_InitStruct */
assert_param(IS_LL_DMA_DIRECTION(DMA_InitStruct->Direction));
/* Check direction */
if (DMA_InitStruct->Direction != LL_DMA_DIRECTION_MEMORY_TO_MEMORY)
{
assert_param(IS_LL_DMA_REQUEST_SELECTION(DMA_InitStruct->Request));
}
assert_param(IS_LL_DMA_DATA_ALIGNMENT(DMA_InitStruct->DataAlignment));
assert_param(IS_LL_DMA_SRC_DATA_WIDTH(DMA_InitStruct->SrcDataWidth));
assert_param(IS_LL_DMA_DEST_DATA_WIDTH(DMA_InitStruct->DestDataWidth));
assert_param(IS_LL_DMA_SRC_INCREMENT_MODE(DMA_InitStruct->SrcIncMode));
assert_param(IS_LL_DMA_DEST_INCREMENT_MODE(DMA_InitStruct->DestIncMode));
assert_param(IS_LL_DMA_PRIORITY(DMA_InitStruct->Priority));
assert_param(IS_LL_DMA_BLK_DATALENGTH(DMA_InitStruct->BlkDataLength));
assert_param(IS_LL_DMA_TRIGGER_POLARITY(DMA_InitStruct->TriggerPolarity));
assert_param(IS_LL_DMA_BLKHW_REQUEST(DMA_InitStruct->BlkHWRequest));
assert_param(IS_LL_DMA_TRANSFER_EVENT_MODE(DMA_InitStruct->TransferEventMode));
assert_param(IS_LL_DMA_LINK_STEP_MODE(DMA_InitStruct->LinkStepMode));
assert_param(IS_LL_DMA_LINK_BASEADDR(DMA_InitStruct->LinkedListBaseAddr));
assert_param(IS_LL_DMA_LINK_ADDR_OFFSET(DMA_InitStruct->LinkedListAddrOffset));
/* Check DMA instance */
if (IS_LL_GPDMA_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
assert_param(IS_LL_DMA_BURST_LENGTH(DMA_InitStruct->SrcBurstLength));
assert_param(IS_LL_DMA_BURST_LENGTH(DMA_InitStruct->DestBurstLength));
assert_param(IS_LL_DMA_DEST_HALFWORD_EXCHANGE(DMA_InitStruct->DestHWordExchange));
assert_param(IS_LL_DMA_DEST_BYTE_EXCHANGE(DMA_InitStruct->DestByteExchange));
assert_param(IS_LL_DMA_SRC_BYTE_EXCHANGE(DMA_InitStruct->SrcByteExchange));
assert_param(IS_LL_DMA_LINK_ALLOCATED_PORT(DMA_InitStruct->LinkAllocatedPort));
assert_param(IS_LL_DMA_SRC_ALLOCATED_PORT(DMA_InitStruct->SrcAllocatedPort));
assert_param(IS_LL_DMA_DEST_ALLOCATED_PORT(DMA_InitStruct->DestAllocatedPort));
}
/* Check trigger polarity */
if (DMA_InitStruct->TriggerPolarity != LL_DMA_TRIG_POLARITY_MASKED)
{
assert_param(IS_LL_DMA_TRIGGER_MODE(DMA_InitStruct->TriggerMode));
assert_param(IS_LL_DMA_TRIGGER_SELECTION(DMA_InitStruct->TriggerSelection));
}
/* Check DMA channel */
if (IS_LL_DMA_2D_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
assert_param(IS_LL_DMA_BLK_REPEATCOUNT(DMA_InitStruct->BlkRptCount));
assert_param(IS_LL_DMA_BURST_SRC_ADDR_UPDATE(DMA_InitStruct->SrcAddrUpdateMode));
assert_param(IS_LL_DMA_BURST_DEST_ADDR_UPDATE(DMA_InitStruct->DestAddrUpdateMode));
assert_param(IS_LL_DMA_BURST_ADDR_UPDATE_VALUE(DMA_InitStruct->SrcAddrOffset));
assert_param(IS_LL_DMA_BURST_ADDR_UPDATE_VALUE(DMA_InitStruct->DestAddrOffset));
assert_param(IS_LL_DMA_BLKRPT_SRC_ADDR_UPDATE(DMA_InitStruct->BlkRptSrcAddrUpdateMode));
assert_param(IS_LL_DMA_BLKRPT_DEST_ADDR_UPDATE(DMA_InitStruct->BlkRptDestAddrUpdateMode));
assert_param(IS_LL_DMA_BLKRPT_ADDR_UPDATE_VALUE(DMA_InitStruct->BlkRptSrcAddrOffset));
assert_param(IS_LL_DMA_BLKRPT_ADDR_UPDATE_VALUE(DMA_InitStruct->BlkRptDestAddrOffset));
}
/*-------------------------- DMAx CLBAR Configuration ------------------------
* Configure the Transfer linked list address with parameter :
* - LinkedListBaseAdd: DMA_CLBAR_LBA[31:16] bits
*/
LL_DMA_SetLinkedListBaseAddr(DMAx, Channel, DMA_InitStruct->LinkedListBaseAddr);
/*-------------------------- DMAx CCR Configuration --------------------------
* Configure the control parameter :
* - LinkAllocatedPort: DMA_CCR_LAP bit
* LinkAllocatedPort field is not supported by LPDMA channels.
* - LinkStepMode: DMA_CCR_LSM bit
* - Priority: DMA_CCR_PRIO [23:22] bits
*/
LL_DMA_ConfigControl(DMAx, Channel, DMA_InitStruct->Priority | \
DMA_InitStruct->LinkAllocatedPort | \
DMA_InitStruct->LinkStepMode);
/*-------------------------- DMAx CTR1 Configuration -------------------------
* Configure the Data transfer parameter :
* - DestAllocatedPort: DMA_CTR1_DAP bit
* DestAllocatedPort field is not supported by LPDMA channels.
* - DestHWordExchange: DMA_CTR1_DHX bit
* DestHWordExchange field is not supported by LPDMA channels.
* - DestByteExchange: DMA_CTR1_DBX bit
* DestByteExchange field is not supported by LPDMA channels.
* - DestIncMode: DMA_CTR1_DINC bit
* - DestDataWidth: DMA_CTR1_DDW_LOG2 [17:16] bits
* - SrcAllocatedPort: DMA_CTR1_SAP bit
* SrcAllocatedPort field is not supported by LPDMA channels.
* - SrcByteExchange: DMA_CTR1_SBX bit
* SrcByteExchange field is not supported by LPDMA channels.
* - DataAlignment: DMA_CTR1_PAM [12:11] bits
* DataAlignment field is reduced to one bit by LPDMA channels.
* - SrcIncMode: DMA_CTR1_SINC bit
* - SrcDataWidth: DMA_CTR1_SDW_LOG2 [1:0] bits
* - SrcBurstLength: DMA_CTR1_SBL_1 [9:4] bits
* SrcBurstLength field is not supported by LPDMA channels.
* - DestBurstLength: DMA_CTR1_DBL_1 [25:20] bits
* DestBurstLength field is not supported by LPDMA channels.
*/
LL_DMA_ConfigTransfer(DMAx, Channel, DMA_InitStruct->DestAllocatedPort | \
DMA_InitStruct->DestHWordExchange | \
DMA_InitStruct->DestByteExchange | \
DMA_InitStruct->DestIncMode | \
DMA_InitStruct->DestDataWidth | \
DMA_InitStruct->SrcAllocatedPort | \
DMA_InitStruct->SrcByteExchange | \
DMA_InitStruct->DataAlignment | \
DMA_InitStruct->SrcIncMode | \
DMA_InitStruct->SrcDataWidth);
/* Check DMA instance */
if (IS_LL_GPDMA_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
LL_DMA_ConfigBurstLength(DMAx, Channel, DMA_InitStruct->SrcBurstLength,
DMA_InitStruct->DestBurstLength);
}
/*-------------------------- DMAx CTR2 Configuration -------------------------
* Configure the channel transfer parameter :
* - TransferEventMode: DMA_CTR2_TCEM [31:30] bits
* - TriggerPolarity: DMA_CTR2_TRIGPOL [25:24] bits
* - TriggerMode: DMA_CTR2_TRIGM [15:14] bits
* - BlkHWRequest: DMA_CTR2_BREQ bit
* - Direction: DMA_CTR2_DREQ bit
* - Direction: DMA_CTR2_SWREQ bit
* Direction field is reduced to one bit for LPDMA channels (SWREQ).
* - TriggerSelection: DMA_CTR2_TRIGSEL [21:16] bits
* TriggerSelection field is reduced to 5 bits for LPDMA channels.
* - Request: DMA_CTR2_REQSEL [6:0] bits
* Request field is reduced to 5 bits for LPDMA channels.
*/
LL_DMA_ConfigChannelTransfer(DMAx, Channel, DMA_InitStruct->TransferEventMode | \
DMA_InitStruct->TriggerPolarity | \
DMA_InitStruct->BlkHWRequest | \
DMA_InitStruct->Direction);
/* Check direction */
if (DMA_InitStruct->Direction != LL_DMA_DIRECTION_MEMORY_TO_MEMORY)
{
LL_DMA_SetPeriphRequest(DMAx, Channel, DMA_InitStruct->Request);
}
/* Check trigger polarity */
if (DMA_InitStruct->TriggerPolarity != LL_DMA_TRIG_POLARITY_MASKED)
{
LL_DMA_SetHWTrigger(DMAx, Channel, DMA_InitStruct->TriggerSelection);
LL_DMA_SetTriggerMode(DMAx, Channel, DMA_InitStruct->TriggerMode);
}
/*-------------------------- DMAx CBR1 Configuration -------------------------
* Configure the Transfer Block counters and update mode with parameter :
* - BlkDataLength: DMA_CBR1_BNDT[15:0] bits
* - BlkRptCount: DMA_CBR1_BRC[26:16] bits
* BlkRptCount field is supported only by 2D addressing channels.
* - BlkRptSrcAddrUpdateMode: DMA_CBR1_BRSDEC bit
* BlkRptSrcAddrUpdateMode field is supported only by 2D addressing channels.
* - BlkRptDestAddrUpdateMode: DMA_CBR1_BRDDEC bit
* BlkRptDestAddrUpdateMode field is supported only by 2D addressing channels.
* - SrcAddrUpdateMode: DMA_CBR1_SDEC bit
* SrcAddrUpdateMode field is supported only by 2D addressing channels.
* - DestAddrUpdateMode: DMA_CBR1_DDEC bit
* DestAddrUpdateMode field is supported only by 2D addressing channels.
*/
LL_DMA_SetBlkDataLength(DMAx, Channel, DMA_InitStruct->BlkDataLength);
/* Check DMA channel */
if (IS_LL_DMA_2D_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
LL_DMA_SetBlkRptCount(DMAx, Channel, DMA_InitStruct->BlkRptCount);
LL_DMA_ConfigBlkRptAddrUpdate(DMAx, Channel, DMA_InitStruct->BlkRptSrcAddrUpdateMode | \
DMA_InitStruct->BlkRptDestAddrUpdateMode | \
DMA_InitStruct->SrcAddrUpdateMode | \
DMA_InitStruct->DestAddrUpdateMode);
}
/*-------------------------- DMAx CSAR and CDAR Configuration ----------------
* Configure the Transfer source address with parameter :
* - SrcAddress: DMA_CSAR_SA[31:0] bits
* - DestAddress: DMA_CDAR_DA[31:0] bits
*/
LL_DMA_ConfigAddresses(DMAx, Channel, DMA_InitStruct->SrcAddress, DMA_InitStruct->DestAddress);
/* Check DMA channel */
if (IS_LL_DMA_2D_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
/*------------------------ DMAx CTR3 Configuration -------------------------
* Configure the Transfer Block counters and update mode with parameter :
* - SrcAddrOffset: DMA_CTR3_SAO[28:16] bits
* SrcAddrOffset field is supported only by 2D addressing channels.
* - DestAddrOffset: DMA_CTR3_DAO[12:0] bits
* DestAddrOffset field is supported only by 2D addressing channels.
*/
LL_DMA_ConfigAddrUpdateValue(DMAx, Channel, DMA_InitStruct->SrcAddrOffset, DMA_InitStruct->DestAddrOffset);
/*------------------------ DMAx CBR2 Configuration -----------------------
* Configure the Transfer Block counters and update mode with parameter :
* - BlkRptSrcAddrOffset: DMA_CBR2_BRSAO[15:0] bits
* BlkRptSrcAddrOffset field is supported only by 2D addressing channels.
* - BlkRptDestAddrOffset: DMA_CBR2_BRDAO[31:16] bits
* BlkRptDestAddrOffset field is supported only by 2D addressing channels.
*/
LL_DMA_ConfigBlkRptAddrUpdateValue(DMAx, Channel, DMA_InitStruct->BlkRptSrcAddrOffset,
DMA_InitStruct->BlkRptDestAddrOffset);
}
/*-------------------------- DMAx CLLR Configuration -------------------------
* Configure the Transfer linked list address with parameter :
* - DestAddrOffset: DMA_CLLR_LA[15:2] bits
*/
LL_DMA_SetLinkedListAddrOffset(DMAx, Channel, DMA_InitStruct->LinkedListAddrOffset);
return (uint32_t)SUCCESS;
}
/**
* @brief Set each @ref LL_DMA_InitTypeDef field to default value.
* @param DMA_InitStruct Pointer to a @ref LL_DMA_InitTypeDef structure.
* @retval None.
*/
void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct)
{
/* Set DMA_InitStruct fields to default values */
DMA_InitStruct->SrcAddress = 0x00000000U;
DMA_InitStruct->DestAddress = 0x00000000U;
DMA_InitStruct->Direction = LL_DMA_DIRECTION_MEMORY_TO_MEMORY;
DMA_InitStruct->BlkHWRequest = LL_DMA_HWREQUEST_SINGLEBURST;
DMA_InitStruct->DataAlignment = LL_DMA_DATA_ALIGN_ZEROPADD;
DMA_InitStruct->SrcBurstLength = 1U;
DMA_InitStruct->DestBurstLength = 1U;
DMA_InitStruct->SrcDataWidth = LL_DMA_SRC_DATAWIDTH_BYTE;
DMA_InitStruct->DestDataWidth = LL_DMA_DEST_DATAWIDTH_BYTE;
DMA_InitStruct->SrcIncMode = LL_DMA_SRC_FIXED;
DMA_InitStruct->DestIncMode = LL_DMA_DEST_FIXED;
DMA_InitStruct->Priority = LL_DMA_LOW_PRIORITY_LOW_WEIGHT;
DMA_InitStruct->BlkDataLength = 0x00000000U;
DMA_InitStruct->BlkRptCount = 0x00000000U;
DMA_InitStruct->TriggerMode = LL_DMA_TRIGM_BLK_TRANSFER;
DMA_InitStruct->TriggerPolarity = LL_DMA_TRIG_POLARITY_MASKED;
DMA_InitStruct->TriggerSelection = 0x00000000U;
DMA_InitStruct->Request = 0x00000000U;
DMA_InitStruct->TransferEventMode = LL_DMA_TCEM_BLK_TRANSFER;
DMA_InitStruct->DestHWordExchange = LL_DMA_DEST_HALFWORD_PRESERVE;
DMA_InitStruct->DestByteExchange = LL_DMA_DEST_BYTE_PRESERVE;
DMA_InitStruct->SrcByteExchange = LL_DMA_SRC_BYTE_PRESERVE;
DMA_InitStruct->SrcAllocatedPort = LL_DMA_SRC_ALLOCATED_PORT0;
DMA_InitStruct->DestAllocatedPort = LL_DMA_DEST_ALLOCATED_PORT0;
DMA_InitStruct->LinkAllocatedPort = LL_DMA_LINK_ALLOCATED_PORT0;
DMA_InitStruct->LinkStepMode = LL_DMA_LSM_FULL_EXECUTION;
DMA_InitStruct->SrcAddrUpdateMode = LL_DMA_BURST_SRC_ADDR_INCREMENT;
DMA_InitStruct->DestAddrUpdateMode = LL_DMA_BURST_DEST_ADDR_INCREMENT;
DMA_InitStruct->SrcAddrOffset = 0x00000000U;
DMA_InitStruct->DestAddrOffset = 0x00000000U;
DMA_InitStruct->BlkRptSrcAddrUpdateMode = LL_DMA_BLKRPT_SRC_ADDR_INCREMENT;
DMA_InitStruct->BlkRptDestAddrUpdateMode = LL_DMA_BLKRPT_DEST_ADDR_INCREMENT;
DMA_InitStruct->BlkRptSrcAddrOffset = 0x00000000U;
DMA_InitStruct->BlkRptDestAddrOffset = 0x00000000U;
DMA_InitStruct->LinkedListBaseAddr = 0x00000000U;
DMA_InitStruct->LinkedListAddrOffset = 0x00000000U;
};
/**
* @brief Set each @ref LL_DMA_InitLinkedListTypeDef field to default value.
* @param DMA_InitLinkedListStruct Pointer to
* a @ref LL_DMA_InitLinkedListTypeDef structure.
* @retval None.
*/
void LL_DMA_ListStructInit(LL_DMA_InitLinkedListTypeDef *DMA_InitLinkedListStruct)
{
/* Set LL_DMA_InitLinkedListTypeDef fields to default values */
DMA_InitLinkedListStruct->Priority = LL_DMA_LOW_PRIORITY_LOW_WEIGHT;
DMA_InitLinkedListStruct->LinkStepMode = LL_DMA_LSM_FULL_EXECUTION;
DMA_InitLinkedListStruct->TransferEventMode = LL_DMA_TCEM_LAST_LLITEM_TRANSFER;
DMA_InitLinkedListStruct->LinkAllocatedPort = LL_DMA_LINK_ALLOCATED_PORT0;
};
/**
* @brief De-initialize the DMA linked list.
* @note This API is used for all available DMA channels.
* @note To convert DMAx_Channely Instance to DMAx Instance and Channely, use
* helper macros :
* @arg @ref LL_DMA_GET_INSTANCE
* @arg @ref LL_DMA_GET_CHANNEL
* @param DMAx DMAx Instance
* @param Channel This parameter can be one of the following values:
* @arg @ref LL_DMA_CHANNEL_0
* @arg @ref LL_DMA_CHANNEL_1
* @arg @ref LL_DMA_CHANNEL_2
* @arg @ref LL_DMA_CHANNEL_3
* @arg @ref LL_DMA_CHANNEL_4
* @arg @ref LL_DMA_CHANNEL_5
* @arg @ref LL_DMA_CHANNEL_6
* @arg @ref LL_DMA_CHANNEL_7
* @arg @ref LL_DMA_CHANNEL_8
* @arg @ref LL_DMA_CHANNEL_9
* @arg @ref LL_DMA_CHANNEL_10
* @arg @ref LL_DMA_CHANNEL_11
* @arg @ref LL_DMA_CHANNEL_12
* @arg @ref LL_DMA_CHANNEL_13
* @arg @ref LL_DMA_CHANNEL_14
* @arg @ref LL_DMA_CHANNEL_15
* @retval An ErrorStatus enumeration value:
* - SUCCESS : DMA registers are de-initialized.
* - ERROR : DMA registers are not de-initialized.
*/
uint32_t LL_DMA_List_DeInit(DMA_TypeDef *DMAx, uint32_t Channel)
{
return LL_DMA_DeInit(DMAx, Channel);
}
/**
* @brief Initialize the DMA linked list according to the specified parameters
* in LL_DMA_InitLinkedListTypeDef.
* @note This API is used for all available DMA channels.
* @note To convert DMAx_Channely Instance to DMAx Instance and Channely, use
* helper macros :
* @arg @ref LL_DMA_GET_INSTANCE
* @arg @ref LL_DMA_GET_CHANNEL
* @param DMAx DMAx Instance
* @param Channel This parameter can be one of the following values:
* @arg @ref LL_DMA_CHANNEL_0
* @arg @ref LL_DMA_CHANNEL_1
* @arg @ref LL_DMA_CHANNEL_2
* @arg @ref LL_DMA_CHANNEL_3
* @arg @ref LL_DMA_CHANNEL_4
* @arg @ref LL_DMA_CHANNEL_5
* @arg @ref LL_DMA_CHANNEL_6
* @arg @ref LL_DMA_CHANNEL_7
* @arg @ref LL_DMA_CHANNEL_8
* @arg @ref LL_DMA_CHANNEL_9
* @arg @ref LL_DMA_CHANNEL_10
* @arg @ref LL_DMA_CHANNEL_11
* @arg @ref LL_DMA_CHANNEL_12
* @arg @ref LL_DMA_CHANNEL_13
* @arg @ref LL_DMA_CHANNEL_14
* @arg @ref LL_DMA_CHANNEL_15
* @param DMA_InitLinkedListStruct pointer to
* a @ref LL_DMA_InitLinkedListTypeDef structure.
* @retval An ErrorStatus enumeration value:
* - SUCCESS : DMA registers are initialized.
* - ERROR : Not applicable.
*/
uint32_t LL_DMA_List_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitLinkedListTypeDef *DMA_InitLinkedListStruct)
{
/* Check the DMA Instance DMAx and Channel parameters*/
assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
/* Check the DMA parameters from DMA_InitLinkedListStruct */
assert_param(IS_LL_DMA_PRIORITY(DMA_InitLinkedListStruct->Priority));
assert_param(IS_LL_DMA_LINK_STEP_MODE(DMA_InitLinkedListStruct->LinkStepMode));
assert_param(IS_LL_DMA_TRANSFER_EVENT_MODE(DMA_InitLinkedListStruct->TransferEventMode));
/* Check DMA instance */
if (IS_LL_GPDMA_CHANNEL_INSTANCE(DMAx, Channel) != 0U)
{
assert_param(IS_LL_DMA_LINK_ALLOCATED_PORT(DMA_InitLinkedListStruct->LinkAllocatedPort));
}
/*-------------------------- DMAx CCR Configuration --------------------------
* Configure the control parameter :
* - LinkAllocatedPort: DMA_CCR_LAP bit
* LinkAllocatedPort field is supported only by GPDMA channels.
* - LinkStepMode: DMA_CCR_LSM bit
* - Priority: DMA_CCR_PRIO [23:22] bits
*/
LL_DMA_ConfigControl(DMAx, Channel, DMA_InitLinkedListStruct->Priority | \
DMA_InitLinkedListStruct->LinkAllocatedPort | \
DMA_InitLinkedListStruct->LinkStepMode);
/*-------------------------- DMAx CTR2 Configuration -------------------------
* Configure the channel transfer parameter :
* - TransferEventMode: DMA_CTR2_TCEM [31:30] bits
*/
LL_DMA_SetTransferEventMode(DMAx, Channel, DMA_InitLinkedListStruct->TransferEventMode);
return (uint32_t)SUCCESS;
}
/**
* @brief Set each @ref LL_DMA_InitNodeTypeDef field to default value.
* @param DMA_InitNodeStruct Pointer to a @ref LL_DMA_InitNodeTypeDef
* structure.
* @retval None.
*/
void LL_DMA_NodeStructInit(LL_DMA_InitNodeTypeDef *DMA_InitNodeStruct)
{
/* Set DMA_InitNodeStruct fields to default values */
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
DMA_InitNodeStruct->DestSecure = LL_DMA_CHANNEL_DEST_NSEC;
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
DMA_InitNodeStruct->DestAllocatedPort = LL_DMA_DEST_ALLOCATED_PORT0;
DMA_InitNodeStruct->DestHWordExchange = LL_DMA_DEST_HALFWORD_PRESERVE;
DMA_InitNodeStruct->DestByteExchange = LL_DMA_DEST_BYTE_PRESERVE;
DMA_InitNodeStruct->DestBurstLength = 1U;
DMA_InitNodeStruct->DestIncMode = LL_DMA_DEST_FIXED;
DMA_InitNodeStruct->DestDataWidth = LL_DMA_DEST_DATAWIDTH_BYTE;
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
DMA_InitNodeStruct->SrcSecure = LL_DMA_CHANNEL_SRC_NSEC;
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
DMA_InitNodeStruct->SrcAllocatedPort = LL_DMA_SRC_ALLOCATED_PORT0;
DMA_InitNodeStruct->SrcByteExchange = LL_DMA_SRC_BYTE_PRESERVE;
DMA_InitNodeStruct->DataAlignment = LL_DMA_DATA_ALIGN_ZEROPADD;
DMA_InitNodeStruct->SrcBurstLength = 1U;
DMA_InitNodeStruct->SrcIncMode = LL_DMA_SRC_FIXED;
DMA_InitNodeStruct->SrcDataWidth = LL_DMA_SRC_DATAWIDTH_BYTE;
DMA_InitNodeStruct->TransferEventMode = LL_DMA_TCEM_BLK_TRANSFER;
DMA_InitNodeStruct->TriggerPolarity = LL_DMA_TRIG_POLARITY_MASKED;
DMA_InitNodeStruct->TriggerSelection = 0x00000000U;
DMA_InitNodeStruct->TriggerMode = LL_DMA_TRIGM_BLK_TRANSFER;
DMA_InitNodeStruct->BlkHWRequest = LL_DMA_HWREQUEST_SINGLEBURST;
DMA_InitNodeStruct->Direction = LL_DMA_DIRECTION_MEMORY_TO_MEMORY;
DMA_InitNodeStruct->Request = 0x00000000U;
DMA_InitNodeStruct->BlkRptDestAddrUpdateMode = LL_DMA_BLKRPT_DEST_ADDR_INCREMENT;
DMA_InitNodeStruct->BlkRptSrcAddrUpdateMode = LL_DMA_BLKRPT_SRC_ADDR_INCREMENT;
DMA_InitNodeStruct->DestAddrUpdateMode = LL_DMA_BURST_DEST_ADDR_INCREMENT;
DMA_InitNodeStruct->SrcAddrUpdateMode = LL_DMA_BURST_SRC_ADDR_INCREMENT;
DMA_InitNodeStruct->BlkRptCount = 0x00000000U;
DMA_InitNodeStruct->BlkDataLength = 0x00000000U;
DMA_InitNodeStruct->SrcAddress = 0x00000000U;
DMA_InitNodeStruct->DestAddress = 0x00000000U;
DMA_InitNodeStruct->DestAddrOffset = 0x00000000U;
DMA_InitNodeStruct->SrcAddrOffset = 0x00000000U;
DMA_InitNodeStruct->BlkRptDestAddrOffset = 0x00000000U;
DMA_InitNodeStruct->BlkRptSrcAddrOffset = 0x00000000U;
DMA_InitNodeStruct->UpdateRegisters = (LL_DMA_UPDATE_CTR1 | LL_DMA_UPDATE_CTR2 | \
LL_DMA_UPDATE_CBR1 | LL_DMA_UPDATE_CSAR | \
LL_DMA_UPDATE_CDAR | LL_DMA_UPDATE_CTR3 | \
LL_DMA_UPDATE_CBR2 | LL_DMA_UPDATE_CLLR);
DMA_InitNodeStruct->NodeType = LL_DMA_GPDMA_LINEAR_NODE;
};
/**
* @brief Initializes DMA linked list node according to the specified
* parameters in the DMA_InitNodeStruct.
* @param DMA_InitNodeStruct Pointer to a LL_DMA_InitNodeTypeDef structure
* that contains linked list node
* registers configurations.
* @param pNode Pointer to linked list node to fill according to
* LL_DMA_LinkNodeTypeDef parameters.
* @retval None
*/
uint32_t LL_DMA_CreateLinkNode(LL_DMA_InitNodeTypeDef *DMA_InitNodeStruct, LL_DMA_LinkNodeTypeDef *pNode)
{
uint32_t reg_counter = 0U;
/* Check the DMA Node type */
assert_param(IS_LL_DMA_LINK_NODETYPE(DMA_InitNodeStruct->NodeType));
/* Check the DMA parameters from DMA_InitNodeStruct */
assert_param(IS_LL_DMA_DIRECTION(DMA_InitNodeStruct->Direction));
/* Check direction */
if (DMA_InitNodeStruct->Direction != LL_DMA_DIRECTION_MEMORY_TO_MEMORY)
{
assert_param(IS_LL_DMA_REQUEST_SELECTION(DMA_InitNodeStruct->Request));
}
assert_param(IS_LL_DMA_DATA_ALIGNMENT(DMA_InitNodeStruct->DataAlignment));
assert_param(IS_LL_DMA_SRC_DATA_WIDTH(DMA_InitNodeStruct->SrcDataWidth));
assert_param(IS_LL_DMA_DEST_DATA_WIDTH(DMA_InitNodeStruct->DestDataWidth));
assert_param(IS_LL_DMA_SRC_INCREMENT_MODE(DMA_InitNodeStruct->SrcIncMode));
assert_param(IS_LL_DMA_DEST_INCREMENT_MODE(DMA_InitNodeStruct->DestIncMode));
assert_param(IS_LL_DMA_BLK_DATALENGTH(DMA_InitNodeStruct->BlkDataLength));
assert_param(IS_LL_DMA_TRIGGER_POLARITY(DMA_InitNodeStruct->TriggerPolarity));
assert_param(IS_LL_DMA_BLKHW_REQUEST(DMA_InitNodeStruct->BlkHWRequest));
assert_param(IS_LL_DMA_TRANSFER_EVENT_MODE(DMA_InitNodeStruct->TransferEventMode));
assert_param(IS_LL_DMA_LINK_UPDATE_REGISTERS(DMA_InitNodeStruct->UpdateRegisters));
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
assert_param(IS_LL_DMA_CHANNEL_SRC_SEC(DMA_InitNodeStruct->SrcSecure));
assert_param(IS_LL_DMA_CHANNEL_DEST_SEC(DMA_InitNodeStruct->DestSecure));
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
/* Check trigger polarity */
if (DMA_InitNodeStruct->TriggerPolarity != LL_DMA_TRIG_POLARITY_MASKED)
{
assert_param(IS_LL_DMA_TRIGGER_MODE(DMA_InitNodeStruct->TriggerMode));
assert_param(IS_LL_DMA_TRIGGER_SELECTION(DMA_InitNodeStruct->TriggerSelection));
}
/* Check node type */
if (DMA_InitNodeStruct->NodeType == LL_DMA_GPDMA_LINEAR_NODE)
{
assert_param(IS_LL_DMA_BURST_LENGTH(DMA_InitNodeStruct->SrcBurstLength));
assert_param(IS_LL_DMA_BURST_LENGTH(DMA_InitNodeStruct->DestBurstLength));
assert_param(IS_LL_DMA_DEST_HALFWORD_EXCHANGE(DMA_InitNodeStruct->DestHWordExchange));
assert_param(IS_LL_DMA_DEST_BYTE_EXCHANGE(DMA_InitNodeStruct->DestByteExchange));
assert_param(IS_LL_DMA_SRC_BYTE_EXCHANGE(DMA_InitNodeStruct->SrcByteExchange));
assert_param(IS_LL_DMA_SRC_ALLOCATED_PORT(DMA_InitNodeStruct->SrcAllocatedPort));
assert_param(IS_LL_DMA_DEST_ALLOCATED_PORT(DMA_InitNodeStruct->DestAllocatedPort));
}
/* Check DMA channel */
if (DMA_InitNodeStruct->NodeType == LL_DMA_GPDMA_2D_NODE)
{
assert_param(IS_LL_DMA_BLK_REPEATCOUNT(DMA_InitNodeStruct->BlkRptCount));
assert_param(IS_LL_DMA_BURST_SRC_ADDR_UPDATE(DMA_InitNodeStruct->SrcAddrUpdateMode));
assert_param(IS_LL_DMA_BURST_DEST_ADDR_UPDATE(DMA_InitNodeStruct->DestAddrUpdateMode));
assert_param(IS_LL_DMA_BURST_ADDR_UPDATE_VALUE(DMA_InitNodeStruct->SrcAddrOffset));
assert_param(IS_LL_DMA_BURST_ADDR_UPDATE_VALUE(DMA_InitNodeStruct->DestAddrOffset));
assert_param(IS_LL_DMA_BLKRPT_SRC_ADDR_UPDATE(DMA_InitNodeStruct->BlkRptSrcAddrUpdateMode));
assert_param(IS_LL_DMA_BLKRPT_DEST_ADDR_UPDATE(DMA_InitNodeStruct->BlkRptDestAddrUpdateMode));
assert_param(IS_LL_DMA_BLKRPT_ADDR_UPDATE_VALUE(DMA_InitNodeStruct->BlkRptSrcAddrOffset));
assert_param(IS_LL_DMA_BLKRPT_ADDR_UPDATE_VALUE(DMA_InitNodeStruct->BlkRptDestAddrOffset));
}
/* Check if CTR1 register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CTR1) == LL_DMA_UPDATE_CTR1)
{
/*-------------------------- DMAx CTR1 Configuration -----------------------
* Configure the Data transfer parameter :
* - DestAllocatedPort: DMA_CTR1_DAP bit
* DestAllocatedPort field is not supported by LPDMA channels.
* - DestHWordExchange: DMA_CTR1_DHX bit
* DestHWordExchange field is not supported by LPDMA channels.
* - DestByteExchange: DMA_CTR1_DBX bit
* DestByteExchange field is not supported by LPDMA channels.
* - DestIncMode: DMA_CTR1_DINC bit
* - DestDataWidth: DMA_CTR1_DDW_LOG2 [17:16] bits
* - SrcAllocatedPort: DMA_CTR1_SAP bit
* SrcAllocatedPort field is not supported by LPDMA channels.
* - SrcByteExchange: DMA_CTR1_SBX bit
* SrcByteExchange field is not supported by LPDMA channels.
* - DataAlignment: DMA_CTR1_PAM [12:11] bits
* DataAlignment field is reduced to one bit for LPDMA channels.
* - SrcIncMode: DMA_CTR1_SINC bit
* - SrcDataWidth: DMA_CTR1_SDW_LOG2 [1:0] bits
* - SrcBurstLength: DMA_CTR1_SBL_1 [9:4] bits
* SrcBurstLength field is not supported by LPDMA channels.
* - DestBurstLength: DMA_CTR1_DBL_1 [25:20] bits
* DestBurstLength field is not supported by LPDMA channels.
*/
pNode->LinkRegisters[reg_counter] = (DMA_InitNodeStruct->DestIncMode | \
DMA_InitNodeStruct->DestDataWidth | \
DMA_InitNodeStruct->DataAlignment | \
DMA_InitNodeStruct->SrcIncMode | \
DMA_InitNodeStruct->SrcDataWidth);
#if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U)
pNode->LinkRegisters[reg_counter] |= (DMA_InitNodeStruct->DestSecure | \
DMA_InitNodeStruct->SrcSecure);
#endif /* defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) */
/* Update CTR1 register fields for not LPDMA channels */
if (DMA_InitNodeStruct->NodeType != LL_DMA_LPDMA_LINEAR_NODE)
{
pNode->LinkRegisters[reg_counter] |= (DMA_InitNodeStruct->DestAllocatedPort | \
DMA_InitNodeStruct->DestHWordExchange | \
DMA_InitNodeStruct->DestByteExchange | \
((DMA_InitNodeStruct->DestBurstLength - 1U) << DMA_CTR1_DBL_1_Pos) | \
DMA_InitNodeStruct->SrcAllocatedPort | \
DMA_InitNodeStruct->SrcByteExchange | \
((DMA_InitNodeStruct->SrcBurstLength - 1U) << DMA_CTR1_SBL_1_Pos));
}
/* Increment counter for the next register */
reg_counter++;
}
/* Check if CTR2 register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CTR2) == LL_DMA_UPDATE_CTR2)
{
/*-------------------------- DMAx CTR2 Configuration -----------------------
* Configure the channel transfer parameter :
* - TransferEventMode: DMA_CTR2_TCEM [31:30] bits
* - TriggerPolarity: DMA_CTR2_TRIGPOL [25:24] bits
* - TriggerMode: DMA_CTR2_TRIGM [15:14] bits
* - BlkHWRequest: DMA_CTR2_BREQ bit
* - Direction: DMA_CTR2_DREQ bit
* - Direction: DMA_CTR2_SWREQ bit
* Direction field is reduced to one bit for LPDMA channels (SWREQ).
* - TriggerSelection: DMA_CTR2_TRIGSEL [21:16] bits
* DataAlignment field is reduced to 5 bits for LPDMA channels.
* - Request: DMA_CTR2_REQSEL [6:0] bits
* DataAlignment field is reduced to 5 bits for LPDMA channels.
*/
pNode->LinkRegisters[reg_counter] = (DMA_InitNodeStruct->TransferEventMode | \
DMA_InitNodeStruct->TriggerPolarity | \
DMA_InitNodeStruct->BlkHWRequest | \
DMA_InitNodeStruct->Direction);
/* Check direction */
if (DMA_InitNodeStruct->Direction != LL_DMA_DIRECTION_MEMORY_TO_MEMORY)
{
pNode->LinkRegisters[reg_counter] |= DMA_InitNodeStruct->Request & DMA_CTR2_REQSEL;
}
/* Check trigger polarity */
if (DMA_InitNodeStruct->TriggerPolarity != LL_DMA_TRIG_POLARITY_MASKED)
{
pNode->LinkRegisters[reg_counter] |= (((DMA_InitNodeStruct->TriggerSelection << DMA_CTR2_TRIGSEL_Pos) & \
DMA_CTR2_TRIGSEL) | DMA_InitNodeStruct->TriggerMode);
}
/* Update CTR2 register fields for LPDMA */
if (DMA_InitNodeStruct->NodeType == LL_DMA_LPDMA_LINEAR_NODE)
{
pNode->LinkRegisters[reg_counter] &= (~(1UL << 21U) & ~(3UL << 5U));
}
/* Increment counter for the next register */
reg_counter++;
}
/* Check if CBR1 register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CBR1) == LL_DMA_UPDATE_CBR1)
{
/*-------------------------- DMAx CBR1 Configuration -----------------------
* Configure the Transfer Block counters and update mode with parameter :
* - BlkDataLength: DMA_CBR1_BNDT[15:0] bits
* - BlkRptCount: DMA_CBR1_BRC[26:16] bits
* BlkRptCount field is supported only by 2D addressing channels.
* - BlkRptSrcAddrUpdateMode: DMA_CBR1_BRSDEC bit
* BlkRptSrcAddrUpdateMode field is supported only by 2D addressing channels.
* - BlkRptDestAddrUpdateMode: DMA_CBR1_BRDDEC bit
* BlkRptDestAddrUpdateMode field is supported only by 2D addressing channels.
* - SrcAddrUpdateMode: DMA_CBR1_SDEC bit
* SrcAddrUpdateMode field is supported only by 2D addressing channels.
* - DestAddrUpdateMode: DMA_CBR1_DDEC bit
* DestAddrUpdateMode field is supported only by 2D addressing channels.
*/
pNode->LinkRegisters[reg_counter] = DMA_InitNodeStruct->BlkDataLength;
/* Update CBR1 register fields for 2D addressing channels */
if (DMA_InitNodeStruct->NodeType == LL_DMA_GPDMA_2D_NODE)
{
pNode->LinkRegisters[reg_counter] |= (DMA_InitNodeStruct->BlkRptDestAddrUpdateMode | \
DMA_InitNodeStruct->BlkRptSrcAddrUpdateMode | \
DMA_InitNodeStruct->DestAddrUpdateMode | \
DMA_InitNodeStruct->SrcAddrUpdateMode | \
((DMA_InitNodeStruct->BlkRptCount << DMA_CBR1_BRC_Pos) & DMA_CBR1_BRC));
}
/* Increment counter for the next register */
reg_counter++;
}
/* Check if CSAR register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CSAR) == LL_DMA_UPDATE_CSAR)
{
/*-------------------------- DMAx CSAR Configuration -----------------------
* Configure the Transfer Block counters and update mode with parameter :
* - SrcAddress: DMA_CSAR_SA[31:0] bits
*/
pNode->LinkRegisters[reg_counter] = DMA_InitNodeStruct->SrcAddress;
/* Increment counter for the next register */
reg_counter++;
}
/* Check if CDAR register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CDAR) == LL_DMA_UPDATE_CDAR)
{
/*-------------------------- DMAx CDAR Configuration -----------------------
* Configure the Transfer Block counters and update mode with parameter :
* - DestAddress: DMA_CDAR_DA[31:0] bits
*/
pNode->LinkRegisters[reg_counter] = DMA_InitNodeStruct->DestAddress;
/* Increment counter for the next register */
reg_counter++;
}
/* Update CTR3 register fields for 2D addressing channels */
if (DMA_InitNodeStruct->NodeType == LL_DMA_GPDMA_2D_NODE)
{
/* Check if CTR3 register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CTR3) == LL_DMA_UPDATE_CTR3)
{
/*-------------------------- DMAx CTR3 Configuration ---------------------
* Configure the Block counters and update mode with parameter :
* - DestAddressOffset: DMA_CTR3_DAO[12:0] bits
* DestAddressOffset field is supported only by 2D addressing channels.
* - SrcAddressOffset: DMA_CTR3_SAO[12:0] bits
* SrcAddressOffset field is supported only by 2D addressing channels.
*/
pNode->LinkRegisters[reg_counter] = (DMA_InitNodeStruct->SrcAddrOffset | \
((DMA_InitNodeStruct->DestAddrOffset << DMA_CTR3_DAO_Pos) & DMA_CTR3_DAO));
/* Increment counter for the next register */
reg_counter++;
}
}
/* Update CBR2 register fields for 2D addressing channels */
if (DMA_InitNodeStruct->NodeType == LL_DMA_GPDMA_2D_NODE)
{
/* Check if CBR2 register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CBR2) == LL_DMA_UPDATE_CBR2)
{
/*-------------------------- DMAx CBR2 Configuration ---------------------
* Configure the Block counters and update mode with parameter :
* - BlkRptDestAddrOffset: DMA_CBR2_BRDAO[31:16] bits
* BlkRptDestAddrOffset field is supported only by 2D addressing channels.
* - BlkRptSrcAddrOffset: DMA_CBR2_BRSAO[15:0] bits
* BlkRptSrcAddrOffset field is supported only by 2D addressing channels.
*/
pNode->LinkRegisters[reg_counter] = (DMA_InitNodeStruct->BlkRptSrcAddrOffset | \
((DMA_InitNodeStruct->BlkRptDestAddrOffset << DMA_CBR2_BRDAO_Pos) & \
DMA_CBR2_BRDAO));
/* Increment counter for the next register */
reg_counter++;
}
}
/* Check if CLLR register update is enabled */
if ((DMA_InitNodeStruct->UpdateRegisters & LL_DMA_UPDATE_CLLR) == LL_DMA_UPDATE_CLLR)
{
/*-------------------------- DMAx CLLR Configuration -----------------------
* Configure the Transfer Block counters and update mode with parameter :
* - UpdateRegisters DMA_CLLR_UT1 bit
* - UpdateRegisters DMA_CLLR_UT2 bit
* - UpdateRegisters DMA_CLLR_UB1 bit
* - UpdateRegisters DMA_CLLR_USA bit
* - UpdateRegisters DMA_CLLR_UDA bit
* - UpdateRegisters DMA_CLLR_UT3 bit
* DMA_CLLR_UT3 bit is discarded for linear addressing channels.
* - UpdateRegisters DMA_CLLR_UB2 bit
* DMA_CLLR_UB2 bit is discarded for linear addressing channels.
* - UpdateRegisters DMA_CLLR_ULL bit
*/
pNode->LinkRegisters[reg_counter] = ((DMA_InitNodeStruct->UpdateRegisters & (DMA_CLLR_UT1 | DMA_CLLR_UT2 | \
DMA_CLLR_UB1 | DMA_CLLR_USA | \
DMA_CLLR_UDA | DMA_CLLR_ULL)));
/* Update CLLR register fields for 2D addressing channels */
if (DMA_InitNodeStruct->NodeType == LL_DMA_GPDMA_2D_NODE)
{
pNode->LinkRegisters[reg_counter] |= (DMA_InitNodeStruct->UpdateRegisters & (DMA_CLLR_UT3 | DMA_CLLR_UB2));
}
}
return (uint32_t)SUCCESS;
}
/**
* @brief Connect Linked list Nodes.
* @param pPrevLinkNode Pointer to previous linked list node to be connected to new Linked list node.
* @param PrevNodeCLLRIdx Offset of Previous Node CLLR register.
* This parameter can be a value of @ref DMA_LL_EC_CLLR_OFFSET.
* @param pNewLinkNode Pointer to new Linked list.
* @param NewNodeCLLRIdx Offset of New Node CLLR register.
* This parameter can be a value of @ref DMA_LL_EC_CLLR_OFFSET.
* @retval None
*/
void LL_DMA_ConnectLinkNode(LL_DMA_LinkNodeTypeDef *pPrevLinkNode, uint32_t PrevNodeCLLRIdx,
LL_DMA_LinkNodeTypeDef *pNewLinkNode, uint32_t NewNodeCLLRIdx)
{
pPrevLinkNode->LinkRegisters[PrevNodeCLLRIdx] = (((uint32_t)pNewLinkNode & DMA_CLLR_LA) | \
(pNewLinkNode->LinkRegisters[NewNodeCLLRIdx] & (DMA_CLLR_UT1 | \
DMA_CLLR_UT2 | DMA_CLLR_UB1 | DMA_CLLR_USA | DMA_CLLR_UDA | \
DMA_CLLR_UT3 | DMA_CLLR_UB2 | DMA_CLLR_ULL)));
}
/**
* @brief Disconnect the next linked list node.
* @param pLinkNode Pointer to linked list node to be disconnected from the next one.
* @param LinkNodeCLLRIdx Offset of Link Node CLLR register.
* @retval None.
*/
void LL_DMA_DisconnectNextLinkNode(LL_DMA_LinkNodeTypeDef *pLinkNode, uint32_t LinkNodeCLLRIdx)
{
pLinkNode->LinkRegisters[LinkNodeCLLRIdx] = 0;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* (defined (GPDMA1) || defined (LPDMA1)) */
/**
* @}
*/
#endif /* defined (USE_FULL_LL_DRIVER) */
|
the_stack_data/536993.c | #include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#define MAX_DATA 512
#define MAX_ROWS 100
struct Address{
int id;
int set;
char name[MAX_DATA];
char email[MAX_DATA];
};
struct Database{
struct Address rows[MAX_ROWS];
};
struct Connection{
FILE *file;
struct Database* db;
};
void die(const char* message)
{
if (errno) {
perror(message);
} else {
printf("ERROR %s\n", message);
}
exit(1);
}
void Address_print(struct Address *addr)
{
printf("%d %s %s \n", addr->id,
addr->name,
addr->email);
}
void Database_load(struct Connection* conn)
{
int rc = fread(conn->db, sizeof(struct Database), 1, conn->file);
if (rc !=1) die("Failed to load database.");
}
struct Connection* Database_open(const char *filename, char mode)
{
struct Connection *conn = malloc(sizeof(struct Connection));
if (!conn) die("Memory error");
if (mode == 'c') {
conn->file = fopen(filename, "w");
} else {
conn->file = fopen(filename, "r+");
if (conn->file) {
Database_load(conn);
}
}
if (!conn->file) die("Failed to open file");
return conn;
}
void Database_close(struct Connection *conn)
{
if (conn) {
if (conn->file) fclose(conn->file);
if (conn->db) free(conn->db);
free(conn);
}
}
void Database_write(struct Connection *conn)
{
rewind(conn->file);
int rc = fwrite(conn->db, sizeof(struct Database), 1, conn->file);
if (rc != 1) die("failed to write database");
rc = fflush(conn->file);
if (rc == -1) die("Cannot flush database");
}
void Database_create(struct Connection* conn)
{
int i = 0;
for (i = 0;i < MAX_ROWS; i++)
{
struct Address addr = {.id = i, .set = 0};
conn->db->rows[i] = addr;
}
}
void Database_set(struct Connection *conn, int id, const char *name, const char *email)
{
struct Address *addr = &conn->db->rows[id];
if (addr->set) die("already set, delete it first");
addr->set = 1;
char *res = strncpy(addr->name, name, MAX_DATA);
if (!res) die("name copy failed");
res = strncpy(addr->email, email, MAX_DATA);
if (!res) die("email copy failed");
}
void Database_get(struct Connection *conn, int id)
{
struct Address *addr = &conn->db->rows[id];
if (addr->set)
{
Address_print(addr);
} else {
die("ID not set");
}
}
|
the_stack_data/140765580.c | #include <stdio.h>
unsigned char sumCode[] = {
0x55, // push %ebp
0x89, 0xe5, // mov %esp,%ebp
0x83, 0xec, 0x10, // sub $0x10,%esp
0xc7, 0x45, 0xfc, 0x00, 0x00, 0x00, 0x00, // movl $0x0,-0x4(%ebp)
0xc7, 0x45, 0xf8, 0x00, 0x00, 0x00, 0x00, // movl $0x0,-0x8(%ebp)
0xeb, 0x0a, // jmp 20 <_sum+0x20>
0x8b, 0x45, 0xf8, // mov -0x8(%ebp),%eax
0x01, 0x45, 0xfc, // add %eax,-0x4(%ebp)
0x83, 0x45, 0xf8, 0x01, // addl $0x1,-0x8(%ebp)
0x8b, 0x45, 0xf8, // mov -0x8(%ebp),%eax
0x3b, 0x45, 0x08, // cmp 0x8(%ebp),%eax
0x7e, 0xee, // jle 16 <_sum+0x16>
0x8b, 0x45, 0xfc, // mov -0x4(%ebp),%eax
0xc9, // leave
0xc3, // ret
0x90, // nop
0x90, // nop
0x90 // nop
};
unsigned char addCode[] = {
0x55, // push %ebp
0x89, 0xe5, // mov %esp,%ebp
0x8b, 0x55, 0x08, // mov 0x8(%ebp),%edx
0x8b, 0x45, 0x0c, // mov 0xc(%ebp),%eax
0x01, 0xd0, // add %edx,%eax
0x5d, // pop %ebp
0xc3, // ret
0x90, // nop
0x90, // nop
0x90 // nop
};
unsigned char fibCode[] = {
0x55, // push %ebp
0x89, 0xe5, // mov %esp,%ebp
0x53, // push %ebx
0x83, 0xec, 0x14, // sub $0x14,%esp
0x83, 0x7d, 0x08, 0x01, // cmpl $0x1,0x8(%ebp)
0x7f, 0x07, // jg 14 <_fib+0x14>
0xb8, 0x01, 0x00, 0x00, 0x00, // mov $0x1,%eax
0xeb, 0x20, // jmp 34 <_fib+0x34>
0x8b, 0x45, 0x08, // mov 0x8(%ebp),%eax
0x83, 0xe8, 0x01, // sub $0x1,%eax
0x89, 0x04, 0x24, // mov %eax,(%esp)
0xe8, 0xde, 0xff, 0xff, 0xff, // call 0 <_fib>
0x89, 0xc3, // mov %eax,%ebx
0x8b, 0x45, 0x08, // mov 0x8(%ebp),%eax
0x83, 0xe8, 0x02, // sub $0x2,%eax
0x89, 0x04, 0x24, // mov %eax,(%esp)
0xe8, 0xce, 0xff, 0xff, 0xff, // call 0 <_fib>
0x01, 0xd8, // add %ebx,%eax
0x83, 0xc4, 0x14, // add $0x14,%esp
0x5b, // pop %ebx
0x5d, // pop %ebp
0xc3, // ret
0x90, // nop
0x90, // nop
};
int (*add)(int a, int b);
int (*sum)(int n);
int (*fib)(int n);
// 習題: 請用這種方式算 power(a, b)
int main() {
add = (int (*)(int, int)) addCode;
printf("add(5, 8)=%d\n", add(5, 8));
sum = (int (*)(int)) sumCode;
printf("sum(10)=%d\n", sum(10));
fib = (int (*)(int)) fibCode;
printf("fib(10)=%d\n", fib(10));
}
|
the_stack_data/371077.c | /* liam beckman */
/* 18 may 2018 */
/* cs344: progream 3 */
/* https://www.w3resource.com/c-programming-exercises/string/c-string-exercise-31.php */
/* https://github.com/angrave/SystemProgramming/wiki/Forking,-Part-2:-Fork,-Exec,-Wait */
/* https://stackoverflow.com/questions/2595503/determine-pid-of-terminated-process */
/* https://stackoverflow.com/questions/190229/where-is-the-itoa-function-in-linux */
/* https://www.geeksforgeeks.org/strtok-strtok_r-functions-c-examples/ */
/* https://www.poetryfoundation.org/poems/51021/the-sea-shell */
/* define sigaction structs */
#define _XOPEN_SOURCE
/* getline */
#define _GNU_SOURCE
/* file writing and reading */
#include <fcntl.h>
/* signals */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
/* waitpid() */
#include <sys/wait.h>
/* process id's */
#include <unistd.h>
#include <string.h>
/* Your shell must support command lines with a maximum length of 2048 characters, and a maximum of 512 arguments. */
#define MAX_ARG 512
#define MAX_CHAR 2048
/* function prototypes */
void path(char **args, int argCount);
void execute(char** args, int argCount, int pidShell);
void input(char* infile);
void output(char* outfile);
char* dollarToPid(char* args, int pidShell);
void catchSIGTSTP(int signo);
void catchSIGCHLD(int signo);
int getFgOnly();
void setFgOnly(int newValue);
int getBgStatus();
void setBgStatus(int newValue);
int getWrite();
void setWrite(char* newString);
/* global variables */
/* all commands will be in foreground */
int fgOnly = 0;
/* command will run in background */
int bgStatus = 0;
/* status of background processes before prompt */
char writeBuffer[MAX_CHAR];
/* status of background processes before prompt */
char statusBuffer[MAX_CHAR];
int main(int argc, char* argv[])
{
/* SIGTSTP: ctrl z */
struct sigaction SIGTSTP_action = {0};
SIGTSTP_action.sa_handler = catchSIGTSTP;
sigfillset(&SIGTSTP_action.sa_mask);
SIGTSTP_action.sa_flags = 0;
sigaction(SIGTSTP, &SIGTSTP_action, NULL);
/* ignore SIGINT */
struct sigaction ignore_action = {0};
ignore_action.sa_handler = SIG_IGN;
sigaction(SIGINT, &ignore_action, NULL);
int numCharsEntered = -5;
size_t bufferSize = 0;
char* lineEntered = NULL;
memset(writeBuffer, '\0', sizeof(writeBuffer));
while (1)
{
/* if there are messages in the global write buffer */
/* output status of background process */
printf("%s", writeBuffer);
fflush(stdout);
/* reset writeBuffer */
writeBuffer[0] = '\0';
while (1)
{
if (getWrite() == 0)
{
/* prompt symbol */
printf(":");
fflush(stdout);
}
numCharsEntered = getline(&lineEntered, &bufferSize, stdin);
if (numCharsEntered == -1)
{
clearerr(stdin);
}
else
{
break;
}
}
/* Your shell must support command lines with a maximum length of 2048 characters, and a maximum of 512 arguments. */
char inputString[MAX_ARG][MAX_CHAR];
int m;
for (m = 0; m < MAX_ARG; m++)
{
memset(inputString[m], '\0', strlen(inputString[m]));
}
int j = 0;
int count = 0;
char *args[MAX_ARG];
/* remove new line from end of input */
lineEntered[strcspn(lineEntered, "\n")] = '\0';
/* break input into individual words in inputString array */
int i;
for (i = 0; i <= (strlen(lineEntered)); i++)
{
if (lineEntered[i] == ' ' || lineEntered[i] == '\0')
{
inputString[count][j] = '\0';
args[count] = inputString[count];
/*printf("args[count]: %s\n", args[count]); */
count += 1;
j = 0;
}
else
{
inputString[count][j] = lineEntered[i];
j += 1;
}
}
/* exit command () */
if (strcmp(inputString[0], "exit") == 0)
{
/* kill all ongoing child processes */
pid_t pid;
int childExitStatus;
while ((pid = waitpid(-1, &childExitStatus, WNOHANG)) != -1)
{
kill(pid, SIGINT);
}
/* exit program */
exit(0);
}
/* cd command (change directory, defaults to user's home directory with no arguments) */
char *directory;
if (strcmp(inputString[0], "cd") == 0)
{
/* if no directory was specified */
if (inputString[1][0] == '\0')
{
/* change to the user's home directory */
directory = getenv("HOME");
}
/* else a directory was specified */
else
{
/* so change to that directory */
directory = inputString[1];
/* replace $$ with pid of current process */
if (strstr(directory, "$$") != 0)
{
/* get the pid of the shell */
int pidShell = getpid();
directory = dollarToPid(directory, pidShell);
}
char prefix[3];
memset(prefix, '\0', strlen(prefix));
strcpy(prefix, "./");
strcat(prefix, directory);
}
if (chdir(directory) != 0)
{
perror("chdir error");
}
}
/* status command () */
else if (strcmp(inputString[0], "status") == 0)
{
/* exit status of last foreground command */
printf(statusBuffer);
}
/* ignore comment lines or blank lines */
else if (strcmp(inputString[0], "#") == 0 ||
strcmp(inputString[0], "\0") == 0)
{
continue;
}
/* command not built in, parse user's path */
else
{
path(args, count);
}
/* free lineEntered pointer */
free(lineEntered);
lineEntered = NULL;
}
}
/* stdout redirection ">" */
void output(char* outfile)
{
/* open output file for writing */
/*printf("outfile: %s\n", outfile); */
int targetFD = open(outfile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
if (targetFD == -1)
{
perror("open() error");
exit(1);
}
/* redirect stdout to the output file */
int result = dup2(targetFD, 1);
if (result == -1)
{
perror("dup2 error");
exit(1);
}
close(targetFD);
}
/* stdin redirection "<" */
void input(char* infile)
{
/* open input file for reading */
int targetFD = open(infile, O_RDONLY);
/* close on exec */
fcntl(targetFD, F_SETFD, FD_CLOEXEC);
if (targetFD == -1)
{
perror("open() error");
exit(1);
}
/* redirect stdin to the input file */
int result = dup2(targetFD, 0);
if (result == -1)
{
perror("dup2 error");
exit(1);
}
close(targetFD);
}
void execute(char** args, int argCount, int pidShell)
{
char *myargs[argCount + 1];
memset(myargs, '\0', sizeof(myargs));
int execArgs = 0;
int redirected = 0;
/* default SIGINT action */
struct sigaction SIGINT_action = {0};
SIGINT_action.sa_handler = SIG_DFL;
sigaction(SIGINT, &SIGINT_action, NULL);
/*printf("execute argCount: %d\n", argCount); */
int k;
for (k = 0; k < argCount; k++)
{
/*printf("args[%d]: %s\n", k, args[k]); */
if (strcmp(args[k], ">") == 0)
{
output(args[k + 1]);
redirected = 1;
}
else if (strcmp(args[k], "<") == 0)
{
input(args[k + 1]);
redirected = 1;
}
/* don't try to exec with ampersand */
else if (strcmp(args[k], "&") == 0)
{
continue;
}
else if (!redirected)
{
/* replace $$ with pid of current process */
if (strstr(args[k], "$$") != 0)
{
args[k] = dollarToPid(args[k], pidShell);
}
/* add arguments to array that will be passed to execvp(). */
/*printf("adding %s to myargs\n", args[k]); */
myargs[execArgs] = args[k];
execArgs += 1;
}
}
myargs[argCount] = NULL;
/* If a command fails because the shell could not find the command to run, then the shell will print an error message and set the exit status to 1. */
if (execvp(*myargs, myargs) != 0)
{
perror("exec() error");
exit(2);
}
}
/* change "$$" to pid of shell */
char* dollarToPid(char* args, int pidShell)
{
/* all characters before $$ */
char* prefix = strchr(args, '$');
/* all characters following $$ */
char* token = strtok(prefix, "$");
char* suffix = (char *) malloc((sizeof(token)+ 1) * sizeof(char));
/* if there are characters following $$, */
/* make a copy in the suffix variable */
if (token != NULL)
{
strcpy(suffix, token);
}
/* change $$ to pid of shell */
/* sprintf is standard, could also use */
/* itoa(getpid()) here */
sprintf(prefix, "%d", pidShell);
/* if there were characters following $$ in the original */
/* string, append them to the final pid string */
if (suffix != NULL)
{
strcat(prefix, suffix);
}
/*printf("$$ :: %s\n", prefix); */
/* TODO maybe not necessary */
free(suffix);
return args;
}
void path(char **args, int argCount)
{
pid_t spawnPid = -5;
int pidShell = getpid();
/* set to background if last character is & */
if (strcmp(args[argCount - 1], "&") == 0 && getFgOnly() == 0)
{
/*setFgOnly(0); */
/*printf("setting to bg\n"); */
setBgStatus(1);
}
/* otherwise make sure process runs in foreground */
else
{
/*printf("setting to fg\n"); */
setBgStatus(0);
}
/* register signal handler if command is in background */
/* and register before child can complete */
if (getBgStatus() == 1)
{
struct sigaction SIGCHLD_action = {0};
SIGCHLD_action.sa_handler = catchSIGCHLD;
sigfillset(&SIGCHLD_action.sa_mask);
SIGCHLD_action.sa_flags = 0;
sigaction(SIGCHLD, &SIGCHLD_action, NULL);
}
/* fork child process */
spawnPid = fork();
switch (spawnPid)
{
/* error in forking child process */
case -1:
perror("fork() error\n");
exit(1);
break;
/* child process */
case 0:
execute(args, argCount, pidShell);
break;
/* parent process */
default:
{
int childExitStatus;
/* if the process is running in the foreground */
if (getBgStatus() == 0)
{
/* block until the process is done */
if (waitpid(spawnPid, &childExitStatus, 0) > 0)
{
/* processes exited */
if (WIFEXITED(childExitStatus) != 0)
{
int exitStatus = WEXITSTATUS(childExitStatus);
/* write exit status to status buffer (for "status" command) */
sprintf(statusBuffer, "exit value %d\n", exitStatus);
}
/* process terminated by signal */
else if (WIFSIGNALED(childExitStatus) != 0)
{
int termSignal = WTERMSIG(childExitStatus);
if (termSignal == 123)
{
/*termSignal = 2; */
}
/* write signal to status buffer (for "status" command) */
sprintf(statusBuffer, "terminated by signal %d\n", termSignal);
sprintf(writeBuffer, "terminated by signal %d\n", termSignal);
/*char message[512]; */
/*sprintf(message, "terminated by signal %d\n", termSignal); */
/*write(STDOUT_FILENO, message, 36); */
/*fflush(stdout); */
}
}
}
/* if the process is running in the background */
if (getBgStatus() == 1)
{
sprintf(writeBuffer, "background pid is %d\n", spawnPid);
/* do not block, just run in background */
waitpid(-1, &childExitStatus, WNOHANG);
}
break;
}
}
}
/* For our purposes, note that the printf() family of functions is NOT re-entrant. In your signal handlers, when outputting text, you must use other output functions! */
void catchSIGTSTP(int signo)
{
if (getFgOnly() == 0)
{
/*char *message = "Entering foreground-only mode (& is now ignored)\n"; */
/*write(STDOUT_FILENO, message, 81); */
char *message = "\nEntering foreground-only mode (& is now ignored)\n";
write(STDOUT_FILENO, message, 51);
fflush(stdout);
setFgOnly(1);
}
else
{
/*char *message = "Exiting foreground-only mode\n"; */
/*write(STDOUT_FILENO, message, 38); */
char *message = "\nExiting foreground-only mode\n";
write(STDOUT_FILENO, message, 31);
fflush(stdout);
setFgOnly(0);
}
}
void catchSIGCHLD(int signo)
{
/*printf("SIGCHLD recieved :: bgStatus -> %d\n", bgStatus); */
pid_t spawnPid;
int childExitStatus;
spawnPid = waitpid(-1, &childExitStatus, WNOHANG);
/*if the pid is not from a background process, output info */
if (spawnPid > 0)
{
sprintf(writeBuffer, "background pid %d is done: ", spawnPid);
if (WIFEXITED(childExitStatus) != 0)
{
int exitStatus = WEXITSTATUS(childExitStatus);
sprintf(writeBuffer + strlen(writeBuffer), "exit value %d\n", exitStatus);
}
else if (WIFSIGNALED(childExitStatus) != 0)
{
int termSignal = WTERMSIG(childExitStatus);
sprintf(writeBuffer + strlen(writeBuffer), "terminated by signal %d\n", termSignal);
}
}
/*setWrite(writeBuffer); */
}
int getWrite()
{
/* if writeBuffer is empty, return 0 */
if(writeBuffer[0] == '\0')
{
return 0;
}
/* else if writeBuffer has contents, return 1 */
return 1;
}
void setWrite(char* newString)
{
strcat(writeBuffer, newString);
}
int getFgOnly()
{
return fgOnly;
}
void setFgOnly(int newValue)
{
fgOnly = newValue;
}
int getBgStatus()
{
return bgStatus;
}
void setBgStatus(int newValue)
{
bgStatus = newValue;
}
/*
~ * ~ * ~ * ~ * ~ * ~ * ~ * ~
The Sea Shell
By Marin Sorescu
Translated by Michael Hamburger
~ * ~ * ~ * ~ * ~ * ~ * ~ * ~
I have hidden inside a sea shell
but forgotten in which.
Now daily I dive,
filtering the sea through my fingers,
to find myself.
Sometimes I think
a giant fish has swallowed me.
Looking for it everywhere I want to make sure
it will get me completely.
The sea-bed attracts me, and
I'm repelled by millions
of sea shells that all look alike.
Help, I am one of them.
If only I knew, which.
How often I've gone straight up
to one of them, saying: That’s me.
Only, when I prised it open
it was empty.
~ * ~ * ~ * ~ * ~ * ~ * ~ * ~
*/
|
the_stack_data/77918.c | // PARAM: --set ana.activated "['base','escape','uninit']"
int* some_function(int * x){
return x; //NOWARN
}
int main(){
int z;
int* zp;
zp = some_function(&z); //NOWARN
return z; //WARN
}
|
the_stack_data/62637925.c | #include <stdio.h>
int main() {
int cod1, cod2, num1, num2;
double val1, val2;
scanf("%i %i %lf\n", &cod1, &num1, &val1);
scanf("%i %i %lf\n", &cod2, &num2, &val2);
printf("VALOR A PAGAR: R$ %.2f\n", (num1*val1 + num2*val2));
return 0;
}
|
the_stack_data/39794.c | /*
* Copyright 2008 Google Inc.
*
* 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.
*/
// A calculator example used to demonstrate the cmockery testing library.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <assert.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// If this is being built for a unit test.
#if UNIT_TESTING
/* Redirect printf to a function in the test application so it's possible to
* test the standard output. */
#ifdef printf
#undef printf
#endif // printf
#define printf example_test_printf
extern void print_message(const char *format, ...);
/* Redirect fprintf to a function in the test application so it's possible to
* test error messages. */
#ifdef fprintf
#undef fprintf
#endif // fprintf
#define fprintf example_test_fprintf
extern int example_test_fprintf(FILE * const file, const char *format, ...);
// Redirect assert to mock_assert() so assertions can be caught by cmockery.
#ifdef assert
#undef assert
#endif // assert
#define assert(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
void mock_assert(const int result, const char* expression, const char *file,
const int line);
/* Redirect calloc and free to test_calloc() and test_free() so cmockery can
* check for memory leaks. */
#ifdef calloc
#undef calloc
#endif // calloc
#define calloc(num, size) _test_calloc(num, size, __FILE__, __LINE__)
#ifdef free
#undef free
#endif // free
#define free(ptr) _test_free(ptr, __FILE__, __LINE__)
void* _test_calloc(const size_t number_of_elements, const size_t size,
const char* file, const int line);
void _test_free(void* const ptr, const char* file, const int line);
/* main is defined in the unit test so redefine name of the the main function
* here. */
#define main example_main
/* All functions in this object need to be exposed to the test application,
* so redefine static to nothing. */
#define static
#endif // UNIT_TESTING
// A binary arithmetic integer operation (add, subtract etc.)
typedef int (*BinaryOperator)(int a, int b);
// Structure which maps operator strings to functions.
typedef struct OperatorFunction {
const char* operator;
BinaryOperator function;
} OperatorFunction;
static int add(int a, int b);
static int subtract(int a, int b);
static int multiply(int a, int b);
static int divide(int a, int b);
// Associate operator strings to functions.
static OperatorFunction operator_function_map[] = {
{"+", add},
{"-", subtract},
{"*", multiply},
{"/", divide},
};
static int add(int a, int b) {
return a + b;
}
static int subtract(int a, int b) {
return a - b;
}
static int multiply(int a, int b) {
return a * b;
}
static int divide(int a, int b) {
assert(b); // Check for divide by zero.
return a / b;
}
/* Searches the specified array of operator_functions for the function
* associated with the specified operator_string. This function returns the
* function associated with operator_string if successful, NULL otherwise.
*/
static BinaryOperator find_operator_function_by_string(
const size_t number_of_operator_functions,
const OperatorFunction * const operator_functions,
const char* const operator_string) {
size_t i;
assert(!number_of_operator_functions || operator_functions);
assert(operator_string);
for (i = 0; i < number_of_operator_functions; i++) {
const OperatorFunction *const operator_function =
&operator_functions[i];
if (strcmp(operator_function->operator, operator_string) == 0) {
return operator_function->function;
}
}
return NULL;
}
/* Perform a series of binary arithmetic integer operations with no operator
* precedence.
*
* The input expression is specified by arguments which is an array of
* containing number_of_arguments strings. Operators invoked by the expression
* are specified by the array operator_functions containing
* number_of_operator_functions, OperatorFunction structures. The value of
* each binary operation is stored in a pointer returned to intermediate_values
* which is allocated by malloc().
*
* If successful, this function returns the integer result of the operations.
* If an error occurs while performing the operation error_occurred is set to
* 1, the operation is aborted and 0 is returned.
*/
static int perform_operation(
int number_of_arguments, char *arguments[],
const size_t number_of_operator_functions,
const OperatorFunction * const operator_functions,
int * const number_of_intermediate_values,
int ** const intermediate_values, int * const error_occurred) {
char *end_of_integer;
int value;
unsigned int i;
assert(!number_of_arguments || arguments);
assert(!number_of_operator_functions || operator_functions);
assert(error_occurred);
assert(number_of_intermediate_values);
assert(intermediate_values);
*error_occurred = 0;
*number_of_intermediate_values = 0;
*intermediate_values = NULL;
if (!number_of_arguments)
return 0;
// Parse the first value.
value = (int)strtol(arguments[0], &end_of_integer, 10);
if (end_of_integer == arguments[0]) {
// If an error occurred while parsing the integer.
fprintf(stderr, "Unable to parse integer from argument %s\n",
arguments[0]);
*error_occurred = 1;
return 0;
}
// Allocate an array for the output values.
*intermediate_values = calloc(((number_of_arguments - 1) / 2),
sizeof(**intermediate_values));
i = 1;
while (i < number_of_arguments) {
int other_value;
const char* const operator_string = arguments[i];
const BinaryOperator function = find_operator_function_by_string(
number_of_operator_functions, operator_functions, operator_string);
int * const intermediate_value =
&((*intermediate_values)[*number_of_intermediate_values]);
(*number_of_intermediate_values) ++;
if (!function) {
fprintf(stderr, "Unknown operator %s, argument %d\n",
operator_string, i);
*error_occurred = 1;
break;
}
i ++;
if (i == number_of_arguments) {
fprintf(stderr, "Binary operator %s missing argument\n",
operator_string);
*error_occurred = 1;
break;
}
other_value = (int)strtol(arguments[i], &end_of_integer, 10);
if (end_of_integer == arguments[i]) {
// If an error occurred while parsing the integer.
fprintf(stderr, "Unable to parse integer %s of argument %d\n",
arguments[i], i);
*error_occurred = 1;
break;
}
i ++;
// Perform the operation and store the intermediate value.
*intermediate_value = function(value, other_value);
value = *intermediate_value;
}
if (*error_occurred) {
free(*intermediate_values);
*intermediate_values = NULL;
*number_of_intermediate_values = 0;
return 0;
}
return value;
}
int main(int argc, char *argv[]) {
int return_value;
int number_of_intermediate_values;
int *intermediate_values;
// Peform the operation.
const int result = perform_operation(
argc - 1, &argv[1],
sizeof(operator_function_map) / sizeof(operator_function_map[0]),
operator_function_map, &number_of_intermediate_values,
&intermediate_values, &return_value);
// If no errors occurred display the result.
if (!return_value && argc > 1) {
unsigned int i;
unsigned int intermediate_value_index = 0;
printf("%s\n", argv[1]);
for (i = 2; i < argc; i += 2) {
assert(intermediate_value_index < number_of_intermediate_values);
printf(" %s %s = %d\n", argv[i], argv[i + 1],
intermediate_values[intermediate_value_index++]);
}
printf("= %d\n", result);
}
if (intermediate_values) {
free(intermediate_values);
}
return return_value;
}
|
the_stack_data/116563.c | // RUN: %clang_cc1 -verify -fsyntax-only %s
// RUN: %clang_cc1 -emit-llvm -o %t %s
#include <stddef.h>
// Declare malloc here explicitly so we don't depend on system headers.
void * malloc(size_t) __attribute((malloc));
int no_vars __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
void returns_void (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
int returns_int (void) __attribute((malloc)); // expected-warning {{functions returning a pointer type}}
int * returns_intptr(void) __attribute((malloc)); // no-warning
typedef int * iptr;
iptr returns_iptr (void) __attribute((malloc)); // no-warning
__attribute((malloc)) void *(*f)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
__attribute((malloc)) int (*g)(); // expected-warning{{'malloc' attribute only applies to functions returning a pointer type}}
__attribute((malloc))
void * xalloc(unsigned n) { return malloc(n); } // no-warning
// RUN: grep 'define noalias .* @xalloc(' %t
#define malloc_like __attribute((__malloc__))
void * xalloc2(unsigned) malloc_like;
void * xalloc2(unsigned n) { return malloc(n); }
// RUN: grep 'define noalias .* @xalloc2(' %t
|
the_stack_data/131225.c | // PARAM: --sets solver td3 --enable ana.int.interval --enable exp.partition-arrays.enabled --set ana.activated "['base','threadid','threadflag','expRelation','mallocWrapper']"
// This checks that partitioned arrays and fast_global_inits are no longer incompatible
int global_array[50];
int global_array_multi[50][2][2];
int main(void) {
for(int i =0; i < 50; i++) {
assert(global_array[i] == 0);
assert(global_array_multi[i][1][1] == 0);
}
}
|
the_stack_data/150143136.c | /* $OpenBSD: n_carg.c,v 1.1 2008/10/07 22:25:53 martynas Exp $ */
/*
* Copyright (c) 2008 Martynas Venckus <[email protected]>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <complex.h>
#include <math.h>
double
carg(double complex z)
{
return atan2 (__imag__ z, __real__ z);
}
|
the_stack_data/212643131.c | #include <stdio.h>
#include <stdlib.h>
/*
*/
int main (void)
{
int People[5][10],i,j,indicei,indicej,Maior,Soma,Qto;
float Media;
char Continuar;
do
{
system("cls");
Maior=0;
indicei=0;
indicej=0;
Qto=0;
Soma=0;
for(i=0;i<5;i++)
{
for(j=0;j<10;j++)
{
People[i][j] = rand();
printf("%8d",People[i][j]);
if(People[i][j] > Maior)
{
Maior = People[i][j];
indicei= i+1;
indicej= j+1;
}
Qto++;
Soma+=People[i][j];
}
}
if(Qto > 0)
{
Media=(float)Soma/Qto;
printf("\nMedia das Populacoes: %.2f",Media);
}
printf("\n");
printf("\nMaior Populacao: %d",Maior);
printf("\n\n________________________________________________________________________________\n\n");
printf("\n Executar Novamente (S/s para Sim): ");
fflush(stdin);
scanf("%c",&Continuar);
}while(Continuar == 's' || Continuar == 'S');
}
|
the_stack_data/391531.c | /* { dg-do compile } */
/* { dg-options "-Os -fdump-tree-optimized -fno-partial-inlining" } */
/* When optimizing for size, t should be inlined when it expands to one call only. */
extern int q(int);
int t(int a)
{
if (a > 12)
{
q(a+5);
q(a+5);
}
else
q(a+10);
}
int
main()
{
t(5);
t(20);
}
/* { dg-final { scan-tree-dump-times "q \\(15\\)" 1 "optimized" } } */
/* { dg-final { scan-tree-dump-times "t \\(20\\)" 1 "optimized" } } */
|
the_stack_data/23574016.c | #include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <math.h>
/* User defined constants. */
/* Number of stars in star pattern. */
/* Must be at least 3. Recommended number is 4. */
#define num_stars_in_pattern 4
/* Minimum star brightness (in magnitude) for inclusion in catalog. */
/* Note that lower magnitude values are brighter. */
#define min_magnitude 6.2
/* Maximum Field of View for catalog in radians. */
/* Also the maximum angle between any two stars in a tetrahedron. */
/* Typically equal to the angle subtended by the imager's diagonal. */
/* Must be less than pi, but should be much less to prevent invalidation */
/* of small angle approximation and to minimize non-linearity of FOV error. */
/* .247 radians is about 14.1 degrees or the diagonal of a 10 degree FOV */
#define max_fov .247
/* Maximum star coordinate centroiding error as fraction of maximum FOV. */
/* .001 is .1% of the max FOV or 1.414 pixels in a 1000x1000 image. */
// 1 / (1024*sqrt(2)) < .00069054
#define max_centroid_error .00069054
/* Maximum error in imager FOV estimate as fraction of true imager FOV. */
/* max_fov*(1+max_fov_error) must be less than pi, but should be much less. */
/* .01 for a 10 degree FOV imager covers estimates from 9.9 to 10.1 degrees. */
#define max_fov_error 0.01
/* Minimum angle between stars in catalog in radians. */
/* Optionally used to remove double stars, set to 0 otherwise. */
/* .001 is about 5.7 pixels distance with 1000 pixels over a 10 degree FOV. */
#define min_star_separation .004
/* Ratio of bin size to error range, where bins are the discretization of */
/* Pattern data values to allow them to be hashed and where the error range covers */
/* a range of twice the data value's maximum error. When a data value's error range */
/* overlaps two bins, it's replicated into both. By linearity of expectation, */
/* the expected number of replicas of a given Pattern is: */
/* (1+1/bin_size_ratio)^num_dims, where num_dims is the number of data values */
/* stored in Patterns. The expected ratio of Patterns with matching bins to */
/* Patterns with matching values is: (1 + bin_size_ratio)^num_dims. */
/* The bin_size_ratio represents a tradeoff between catalog size and */
/* runtime, as more replicas means a larger catalog and more mismatching results */
/* means more time spent checking for a match. In most cases, Patterns with */
/* matching values are rare, so a larger bin_size_ratio is better. Must be */
/* greater than 1.0 without changes to Pattern struct, recommended value of 2.0. */
#define bin_size_ratio 3.0
/* Ratio specifying how much of the catalog is occupied by Patterns rather than */
/* empty space. Values below .5 create unnecessarily large catalog sizes, while */
/* values above .7 cause longer lookup times due to increased collision frequency. */
#define catalog_density .6
/* Size of catalog cache in number of patterns. Generating the catalog in cached */
/* pieces reduces disk I/O and greatly speeds up catalog generation. */
#define max_cat_cache_size 100000000
/* Maximum distance matching pattern can be from original offset in catalog. */
/* Measured in number of patterns. Determines overlap between cached catalog */
/* pieces during catalog generation and the number of extra catalog positions */
/* needed at the end of the catalog due to the catalog hash table being non-cyclic. */
#define max_probe_depth 50000
/* Number of entries in the Hipparchos catalog. */
#define STARN 9110
/* Mathematical constant pi's approximate value. */
#define PI 3.1415926
/* The current calendar year. */
#define current_year 2017
/* The following values are not user defined constants and should therefore not be changed. */
/* Maximum scaling of image caused by FOV error. */
float max_scale_factor = fmax(tan(max_fov*(1+max_fov_error)/2.0)/tan(max_fov/2.0),
1-tan(max_fov*(1-max_fov_error)/2.0)/tan(max_fov/2.0));
/* Largest edge error is proportional to the largest edge ratio by the image scale. */
/* For example, doubling the largest edge length doubles the scaling error. */
#define le_error_slope (max_scale_factor-1)
/* Largest edge error has a constant factor determined by the centroiding error. */
/* This value is the worst case of maximum FOV and centroid error. It corresponds to */
/* The FOV taking on its minimum value and both centroids having maximal error inwards. */
#define le_error_offset (2*max_centroid_error/(2-max_scale_factor))
/* Largest possible largest_edge_length given the maximum FOV. */
#define max_le_length (2*sin(max_fov*(1+max_fov_error)/2.0))
/* Feature struct */
/* Data format of what's stored in a given feature of a catalog Pattern. */
/* A coordinate system is constructed by centering the largest edge along the x axis, */
/* where edges are straight lines between stars in the pattern. */
/* The x and y coordinates of every star are divided by the length of the largest edge. */
/* This places two stars at the (x,y) coordinates (-.5,0) and (.5,0) and the remaining */
/* stars in one of two places due to a 180 degree rotational ambiguity. */
/* Each Feature encodes each of the remaining stars' bins, coordinates, and id. */
typedef struct Feature
{
/* Implicitly encoded doubles are used to store the coordinates. */
/* This cuts down on disc usage by instead using integers with an */
/* implicit division factor, as all coordinates are between -1 and 1. */
int x : 15;
/* Bins are identifying values for the Pattern's catalog position. */
/* They discretize Pattern data values, allowing them to be hashed. */
/* A bin offset is the offset of this Pattern's bin from the */
/* lowest bin the Pattern can occupy. With a bin_size_ratio */
/* greater than 1.0, bin offsets can be stored in a single bit. */
unsigned int x_bin_offset : 1;
int y : 15;
unsigned int y_bin_offset : 1;
/* ID of the Feature's star. Unsigned 15 bit integers support 32768 unique stars. */
unsigned int star_id : 15;
/* Extra, unused bit. */
unsigned int pad : 1;
} Feature;
/* Pattern struct */
/* Data format of what's stored in a given catalog position for a given star pattern. */
/* The rotation that results in the largest x bin (y bin as tie-breaker) */
/* is chosen to deal with the pattern's 180 degree rotational ambiguity. */
/* The largest edge length is also stored to allow for sanity-checking of FOV/image scale. */
typedef struct Pattern
{
/* Features are stored in order of increasing x bin, with increasing y bin */
/* as a tie breaker. Two Features cannot contain the same bin pair, as this */
/* would cause ambiguities while matching image stars to catalog stars. */
Feature features[num_stars_in_pattern-2];
/* Length of the largest edge in the star pattern. Used to recompute the FOV as well as */
/* sanity check matches. Also stored as an implicitly encoded double between 0 and 1, */
/* as edge lengths must be between 0 and max_le_length, the maximum largest edge length. */
uint16_t largest_edge;
/* As the largest edge length is always greater than zero, it is also used as */
/* a boolean to indicate whether the hash table slot contains a star pattern. */
/* Note that this is therefore not explicitly set during catalog creation. */
#define has_pattern largest_edge
unsigned int le_bin_offset : 1;
unsigned int fixed_star_id_1 : 15;
unsigned int fixed_star_id_2 : 15;
/* Boolean value indicating whether this catalog position contains the last */
/* matching pattern in the catalog. This avoids having to probe to the next slot. */
unsigned int is_last : 1;
} Pattern;
/* Star struct */
/* Data format of what's stored in the stars array for a given star. */
typedef struct Star
{
/* Unit vector x,y,z coordinates pointing to the star from the center of the celestial sphere. */
double vec[3];
/* Star magnitude */
double mag;
/* Star id, also known as the Hipparchos number */
unsigned int star_id;
} Star;
/* Euclidean difference evaluator for a pair of 3D vectors. */
/* Output is the vector from the end of i to the end of j. */
static void diff(double v1[3],
double v2[3],
double output[3]){
output[0] = v1[0]-v2[0];
output[1] = v1[1]-v2[1];
output[2] = v1[2]-v2[2];
}
/* BSC_Entry struct */
/* Data format of what's stored in a single star entry of the BSC5. */
/* The BSC5 is Yale's Bright Star Catalog 5, containing 9110 stars. */
typedef struct BSC_Entry
{
/* Catalog number of star. */
float XNO;
/* B1950 Right Ascension (radians) */
double SRA0;
/* B1950 Declination (radians) */
double SDEC0;
/* Spectral type (2 characters) */
short IS;
/* V Magnitude * 100 */
short MAG;
/* R.A. proper motion (radians per year) */
float XRPM;
/* Dec. proper motion (radians per year) */
float XDPM;
} BSC_Entry;
/* Vector magnitude evaluator for a 3D vector. */
static double mag(double v[3]){
return sqrt(v[0]*v[0]+v[1]*v[1]+v[2]*v[2]);
}
/* Normalize a 3D vector by dividing by its magnitude. */
static void normalize(double v[3]){
double v_magnitude = mag(v);
v[0] /= v_magnitude;
v[1] /= v_magnitude;
v[2] /= v_magnitude;
}
/* Euclidean distance evaluator for a pair of 3D vectors. */
static double dist(double v1[3],
double v2[3]){
double diff_vector[3];
diff(v1,v2,diff_vector);
return mag(diff_vector);
}
/* Dot product evaluator for a pair of 3D vectors. */
static double dot_prod(double v1[3],
double v2[3]){
return v1[0]*v2[0]+
v1[1]*v2[1]+
v1[2]*v2[2];
}
/* Cross product magnitude evaluator for a pair of 3D vectors. */
static void cross_prod(double v1[3],
double v2[3],
double output[3]){
output[0] = v1[1]*v2[2]-v1[2]*v2[1];
output[1] = v1[2]*v2[0]-v1[0]*v2[2];
output[2] = v1[0]*v2[1]-v1[1]*v2[0];
}
/* Calculate the exponent base for logarithmic binning. */
/* Also bounds check error values. */
static double get_base(double error_slope,
double error_offset){
/* If the fixed error is non-positive, return error and exit. */
if(error_offset <= 0){
printf("\nNon-positive error value detected: increase error values.\n");
exit(EXIT_FAILURE);
}
/* Calculate and return base of logarithmic binning function. */
double base = (1+error_slope)/fmax(1-error_slope, 0);
return base;
}
/* Logarithmically bin doubles that have error linear in their value. Binning function */
/* is designed to ensure each value's error range overlaps at most two bins. */
static int log_bin(double input,
double error_slope,
double error_offset){
/* If either of the error values is infinite, all values share the 0 bin. */
if(!isfinite(error_slope) || !isfinite(error_offset)){
return 0;
}
/* Calculate base of logarithmic binning function. */
double base = get_base(error_slope, error_offset);
int bin;
/* Slopes much smaller than the offset result in linear binning. */
if(base <= 1+error_offset*bin_size_ratio/10.){
bin = input/(2*(error_slope+error_offset)*bin_size_ratio);
}
/* Otherwise, calculate logarithmic bin. */
/* Slopes greater than or equal to one result in all values sharing the 0 bin. */
else{
bin = (log(input*error_slope/error_offset+1)/log(base))/bin_size_ratio;
}
return bin;
}
/* Retrieve minimum possible pre-binned value from a logarithmically binned value. */
static double log_unbin(int bin,
double error_slope,
double error_offset){
/* If either of the error values is infinite, 0 is the minimum value. */
if(!isfinite(error_slope) || !isfinite(error_offset)){
return 0;
}
/* Calculate base of logarithmic binning function. */
double base = get_base(error_slope, error_offset);
double min_input;
/* Slopes much smaller than the offset result in linear binning. */
if(base <= 1+error_offset*bin_size_ratio/10.){
min_input = bin*2*(error_slope+error_offset)*bin_size_ratio;
}
/* Otherwise, calculate minimum possible logarithmic pre-binned value. */
else{
min_input = (pow(base, bin*bin_size_ratio)-1)*error_offset/error_slope;
}
return min_input;
}
/* Evenly bin largest edge length values using the fact that the maximum error is linear */
/* with respect to length. Logarithmic functions satisfy this bin size constraint. */
static int bin_largest_edge(unsigned int largest_edge,
int error_ratio){
/* Convert largest edge length back to double between 0 and 1 from implicitly divided double. */
/* Resulting value is a ratio of max_le_length, the maximum largest edge length. */
double le_ratio = largest_edge/((1<<16)-1.0);
/* Adjust error in le_ratio based on error_ratio between -1 and 1. */
/* An error_ratio of -1 will give the lower bin, +1 will give the upper bin. */
le_ratio += error_ratio*(le_ratio*le_error_slope+le_error_offset);
/* Find and return largest edge bin using logarithmic binning function. */
return log_bin(le_ratio, le_error_slope, le_error_offset);
}
/* Transform largest edge bin into a largest edge ratio. */
/* Returns the minimum largest edge ratio within the bin. */
static double unbin_largest_edge(unsigned int bin){
/* Invert logarithmic binning function to retrieve minimum largest edge ratio. */
double min_le_ratio = log_unbin(bin, le_error_slope, le_error_offset);
return min_le_ratio;
}
/* Evenly bin coordinate using the largest edge bin to find the image scale. */
static int bin_y(int y,
unsigned int le_bin,
int error_ratio){
/* Calculate the minimum size the largest edge ratio could have, given its bin. */
double min_le_ratio = unbin_largest_edge(le_bin);
/* Coordinate error is affected by both the largest edge error and the FOV error. */
double error_constant = le_error_offset/(2-max_scale_factor);
/* Coordinate error has a component proportional to the coordinate value. */
/* This value is the worst case of maximum FOV and centroid error. It corresponds */
/* to the FOV taking on its minimum value, both the largest edge centroids having */
/* maximal error in the same direction, and the coordinate centroid having maximal */
/* error in the opposite direction of the centroiding errors of the largest edge. */
double error_slope = error_constant/fmax(min_le_ratio-error_constant, 0);
/* Coordinate error also has a constant factor determined by the centroiding error. */
double error_offset = error_slope;
/* Convert coordinate back to double between -1 and 1 from implicitly divided double. */
/* Resulting value is a ratio of image_scale. */
double y_ratio = y/((1<<14)-1.0);
/* Adjust error in coordinate based on error_ratio between -1 and 1. */
/* An error_ratio of -1 will give the lower bin, +1 will give the upper bin. */
/* The error is inversely scaled by min_le_ratio, as the coordinate is a ratio */
/* of the largest edge length, while the error is a ratio of max_le_length. */
y_ratio += error_ratio*copysign(fabs(y_ratio)*error_slope+error_offset, y_ratio);
/* Maintain symmetry of coordinate in bins by mirroring the bins across the y axis. */
int bin = log_bin(fabs(y_ratio), error_slope, error_offset);
if(y_ratio < 0){
bin = ~bin;
}
return bin;
}
/* Transform y coordinate bin into a y coordinate ratio absolute value. */
/* Returns the maximum y coordinate ratio absolute value within the bin. */
static double unbin_y(int bin,
unsigned int le_bin){
/* Calculate the minimum size the largest edge ratio could have, given its bin. */
double min_le_ratio = unbin_largest_edge(le_bin);
/* Coordinate error is affected by both the largest edge error and the FOV error. */
double error_constant = le_error_offset/(2-max_scale_factor);
/* Coordinate error has a constant factor determined by the centroiding error. */
/* This value is the worst case of maximum FOV and centroid error. It corresponds */
/* to the FOV taking on its minimum value, both the largest edge centroids having */
/* maximal error in the same direction, and the coordinate centroid having maximal */
/* error in the opposite direction of the centroiding errors of the largest edge. */
double error_slope = error_constant/fmax(min_le_ratio-error_constant, 0);
/* Coordinate error also has a constant factor determined by the centroiding error. */
double error_offset = error_slope;
/* Invert logarithmic binning function to retrieve maximum y coordinate ratio. */
/* Returns the absolute value of the y coordinate ratio, not the actual value. */
double max_y_ratio = log_unbin(bin>=0?bin+1:(~bin)+1, error_slope, error_offset);
return max_y_ratio;
}
/* Evenly bin x coordinate using the y and largest edge bins. */
static int bin_x(int x,
unsigned int le_bin,
int y_bin,
int error_ratio){
/* Calculate the minimum size the largest edge ratio could have, given its bin. */
double min_le_ratio = unbin_largest_edge(le_bin);
/* Calculate the maximum size the y coordinate ratio could have, given its bin. */
double max_y_ratio = unbin_y(y_bin, le_bin);
/* Coordinate error is affected by both the largest edge error and the FOV error. */
double error_constant = le_error_offset/(2-max_scale_factor);
/* Coordinate error has a component proportional to the coordinate value. */
/* This value is the worst case of maximum FOV and centroid error. It corresponds */
/* to the FOV taking on its minimum value, both the largest edge centroids having */
/* maximal error in the same direction, and the coordinate centroid having maximal */
/* error in the opposite direction of the centroiding errors of the largest edge. */
double error_slope = error_constant/fmax(min_le_ratio-error_constant, 0);
/* Coordinate error also has a constant factor determined by the centroiding error. */
double error_offset = error_slope*(1+2*sqrt((1.0/4)+max_y_ratio*max_y_ratio))/2;
/* Convert coordinate back to double between -1 and 1 from implicitly divided double. */
/* Resulting value is a ratio of image_scale. */
double x_ratio = x/((1<<14)-1.0);
/* Adjust error in coordinate based on error_ratio between -1 and 1. */
/* An error_ratio of -1 will give the lower bin, +1 will give the upper bin. */
/* The error is inversely scaled by min_le_ratio, as the coordinate is a ratio */
/* of the largest edge length, while the error is a ratio of max_le_length. */
x_ratio += error_ratio*copysign(fabs(x_ratio)*error_slope+error_offset, x_ratio);
/* Maintain symmetry of coordinate in bins by mirroring the bins across the y axis. */
int bin = log_bin(fabs(x_ratio), error_slope, error_offset);
if(x_ratio < 0){
bin = ~bin;
}
return bin;
}
/* Constant chosen for optimal avalanching. It is the closest prime to 2^64 divided */
/* by the golden ratio. This is a modified Knuth multiplicative hash, as it uses the */
/* closest prime instead. A prime is chosen to prevent an unfortunate catalog size */
/* (i.e. a factor of 2^64 / phi) from effectively canceling out this step. Note again */
/* that the result is automatically taken modulo 2^64 as it is stored as a uint64_t. */
static uint64_t hash_int(uint64_t old_hash, uint64_t key){
key = key*11400714819323198549ULL;
/* XOR with higher order bits to properly mix in the old hash. */
return old_hash^(old_hash >> 13)^key;
}
/* Hash function that takes a Pattern as input and produces a deterministically */
/* random catalog position as output based on its bins. Note that this */
/* hash function was chosen for simplicity/speed. Other functions may have */
/* somewhat better (e.g. more even) distributions of hashed values. */
static uint64_t hash_pattern(Pattern pattern_instance,
uint64_t catalog_size_in_patterns){
/* Initialize hash value to the largest edge bin. */
unsigned int le_bin = bin_largest_edge(pattern_instance.largest_edge,
2*pattern_instance.le_bin_offset-1);
uint64_t hash = hash_int(0, le_bin);
/* Each feature is hashed one at a time through modular multiplication. */
for(int i=0;i<num_stars_in_pattern-2;i++){
/* The bins are used to update the hash by multiplying it. The hash is stored */
/* with an unsigned 64 bit value, so the result is automatically taken modulo 2^64. */
int y_bin = bin_y(pattern_instance.features[i].y, le_bin,
2*pattern_instance.features[i].y_bin_offset-1);
hash = hash_int(hash, y_bin+(1<<31));
hash = hash_int(hash, bin_x(pattern_instance.features[i].x, le_bin, y_bin,
2*pattern_instance.features[i].x_bin_offset-1)+(1<<31));
}
/* Hash value is taken modulo the catalog size to convert it to a location in the catalog. */
/* Due to hash collisions, the pattern may not be stored in this exact location, but nearby. */
return hash%catalog_size_in_patterns;
}
/* Verifies bin pairs are the same for the new and */
/* stored Patterns, in case a collision occurred. */
static int hash_same(Pattern new_pattern,
Pattern cat_pattern){
/* Check whether the Patterns share the same largest edge bins. */
unsigned int new_le_bin = bin_largest_edge(new_pattern.largest_edge,
2*new_pattern.le_bin_offset-1);
unsigned int cat_le_bin = bin_largest_edge(cat_pattern.largest_edge,
2*cat_pattern.le_bin_offset-1);
if(new_le_bin != cat_le_bin){
/* Largest edge bins don't match, so it must be a collision. */
return 0;
}
/* Iterate over both Patterns' Features, checking whether their bins match. */
for(int i=0;i<num_stars_in_pattern-2;i++){
Feature new_feature = new_pattern.features[i];
Feature cat_feature = cat_pattern.features[i];
int new_y_bin = bin_y(new_feature.y, new_le_bin, 2*new_feature.y_bin_offset-1);
int cat_y_bin = bin_y(cat_feature.y, cat_le_bin, 2*cat_feature.y_bin_offset-1);
int new_x_bin = bin_x(new_feature.x, new_le_bin, new_y_bin, 2*new_feature.x_bin_offset-1);
int cat_x_bin = bin_x(cat_feature.x, cat_le_bin, cat_y_bin, 2*cat_feature.x_bin_offset-1);
if((new_y_bin != cat_y_bin) || (new_x_bin != cat_x_bin)){
/* Coordinate bins don't match, so it must be a collision. */
return 0;
}
}
/* All bins matched, so it must not be a match and not a collision. */
return 1;
}
/* Quadratically probes the Pattern cache with bounds checking. */
static int increment_offset(uint64_t *cache_offset,
int *probe_step){
*cache_offset += *probe_step;
static int deepest_probe = 0;
/* Keep track of catalog's deepest probe depth. */
if(((*probe_step)*(*probe_step+1))/2 > deepest_probe){
deepest_probe = ((*probe_step)*(*probe_step+1))/2;
}
/* If cache_offset goes out of bounds, terminate program with failure code. */
/* The problem can be fixed by increasing the max_probe_depth, lowering the */
/* catalog_density, or otherwise lowering the collision frequency. */
if(((*probe_step)*(*probe_step+1))/2 > max_probe_depth){
printf("\nMaximum probe depth exceeded: increase max_probe_depth.\n");
exit(EXIT_FAILURE);
}
*probe_step += 1;
return deepest_probe;
}
/* Inserts a Pattern instance into the catalog cache based on its bins. */
/* Also sorts the Pattern's Features before inserting it into the catalog. */
/* If the pattern would be placed outside of cache range, returns without doing anything. */
static void insert_pattern(int just_count,
uint64_t *num_patterns,
Pattern pattern_catalog_cache[],
uint64_t *catalog_size_in_patterns,
int *cache_index,
Pattern new_pattern){
/* If set to "just count," increment the counter of valid Patterns and return. */
if(just_count){
(*num_patterns)++;
return;
}
/* Offset of the beginning of the Pattern's probing sequence in the pattern catalog. */
uint64_t offset = hash_pattern(new_pattern, *catalog_size_in_patterns);
/* If the Pattern's initial offset isn't in the cached section */
/* of memory, return without doing anything. */
if(offset/max_cat_cache_size != *cache_index){
return;
}
/* Spacing between Patterns in the same probing sequence. Grows linearly, */
/* resulting in quadratic probing. (i.e. 0,1,3,6,10,15...) */
int probe_step = 1;
/* The new pattern will always be the last match in the probing sequence so far. */
new_pattern.is_last = 1;
/* Get offset in catalog cache. */
uint64_t cache_offset = offset%max_cat_cache_size;
/* If there is already a Pattern instance at this catalog position and either its */
/* bin pairs don't match with the new Pattern or it isn't the last matching catalog */
/* Pattern, continue on to the next catalog position given by quadratic probing. */
while(pattern_catalog_cache[cache_offset].has_pattern &&
(!hash_same(new_pattern, pattern_catalog_cache[cache_offset]) ||
!pattern_catalog_cache[cache_offset].is_last)){
/* Advance to the next catalog location given by quadratic probing. */
increment_offset(&cache_offset, &probe_step);
}
/* If there is a Pattern instance already occupying this catalog position, */
/* it must be the last matching Pattern, so set it to not be the last one */
/* and place the new Pattern in the next unoccupied catalog position given by */
/* quadratic probing as the new last matching Pattern. If there is no Pattern */
/* instance already occupying this catalog position, just add the new Pattern */
/* as there must be no matching Patterns already in the catalog. */
if(pattern_catalog_cache[cache_offset].has_pattern){
pattern_catalog_cache[cache_offset].is_last = 0;
while(pattern_catalog_cache[cache_offset].has_pattern){
/* Advance to the next catalog location given by quadratic probing. */
increment_offset(&cache_offset, &probe_step);
}
}
pattern_catalog_cache[cache_offset] = new_pattern;
}
/* Duplicates the Pattern across the catalog given ambiguities in its x,y coordinate bins. */
/* Called by disambiguate_rotation, and calls insert_pattern. */
static void disambiguate_feature_order(int just_count,
uint64_t *num_patterns,
Pattern pattern_catalog_cache[],
uint64_t *catalog_size_in_patterns,
int *cache_index,
Pattern new_pattern,
int feature_index){
/* If all of the ambiguously ordered Features have been disambiguated, insert the Pattern. */
if(feature_index >= num_stars_in_pattern-3){
insert_pattern(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern);
}
/* Otherwise, search for and disambiguate ambiguously ordered Features. */
else{
/* Helper function for permuting Features. Produces all permutations */
/* of Features with index >= from_index and <= to_index. */
void permute_features(int from_index, int to_index){
/* If from_index is equal to to_index, recurse down starting from the next index. */
if(from_index == to_index){
disambiguate_feature_order(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern,
to_index + 1);
}
/* Otherwise, there must be ambiguous Features, which need to be permuted. */
else{
/* Helper function for swapping two Features. */
void swap_features(int index_1, int index_2){
Feature feature_swap = new_pattern.features[index_1];
new_pattern.features[index_1] = new_pattern.features[index_2];
new_pattern.features[index_2] = feature_swap;
}
/* Permute ambiguous Features using recursion and swapping. */
for(int j=from_index;j<=to_index;j++){
swap_features(from_index, j);
permute_features(from_index+1, to_index);
swap_features(from_index, j);
}
}
}
/* Compute largest edge bin for use in calculating Features' x, y coordinate bins. */
unsigned int le_bin = bin_largest_edge(new_pattern.largest_edge,
2*new_pattern.le_bin_offset-1);
/* Find the index of the last Feature with bins that match the feature_index Feature. */
int bin_y_1 = bin_y(new_pattern.features[feature_index].y, le_bin,
2*(new_pattern.features[feature_index].y_bin_offset)-1);
int bin_x_1 = bin_x(new_pattern.features[feature_index].x, le_bin, bin_y_1,
2*(new_pattern.features[feature_index].x_bin_offset)-1);
int i;
for(i=feature_index+1;i<num_stars_in_pattern-2;i++){
int bin_y_2 = bin_y(new_pattern.features[i].y, le_bin,
2*(new_pattern.features[i].y_bin_offset)-1);
int bin_x_2 = bin_x(new_pattern.features[i].x, le_bin, bin_y_2,
2*(new_pattern.features[i].x_bin_offset)-1);
if(bin_x_1 != bin_x_2 ||
bin_y_1 != bin_y_2){
break;
}
}
/* Insert all permutations of the ambiguous Features into the catalog and recurse. */
permute_features(feature_index, i-1);
}
}
/* Duplicates the Pattern across the catalog given ambiguities in its 180 degree */
/* rotation. Called by disambiguate_bins, and calls disambiguate_feature_order. */
static void disambiguate_rotation(int just_count,
uint64_t *num_patterns,
Pattern pattern_catalog_cache[],
uint64_t *catalog_size_in_patterns,
int *cache_index,
Pattern new_pattern){
/* Dummy variable used for iteration. */
int i;
/* Variable encoding which 180 degree rotation will be inserted into the catalog. */
/* A negative value means the current rotation will be inserted. */
/* A positive value means the opposite rotation will be inserted. */
/* A value of zero means both rotations will be inserted into the catalog. */
int pattern_rotation;
/* Compute largest edge bin for use in sorting Features based on x and y bins. */
unsigned int le_bin = bin_largest_edge(new_pattern.largest_edge,
2*new_pattern.le_bin_offset-1);
/* Helper function for sorting Features. Sorts by x bin, then by y bin. */
/* Returns a positive number if the first Feature has larger bin values, */
/* returns a negative number if the second Feature has larger bin values, */
/* and raises an error if both Features have the same bin values. */
int compare_bins(const void *p, const void *q) {
/* Compare the Features' x bins first, then their y bins. */
int p_y_bin = bin_y(((Feature*)p)->y, le_bin, 2*(((Feature*)p)->y_bin_offset)-1);
int q_y_bin = bin_y(((Feature*)q)->y, le_bin, 2*(((Feature*)q)->y_bin_offset)-1);
int p_x_bin = bin_x(((Feature*)p)->x, le_bin, p_y_bin, 2*(((Feature*)p)->x_bin_offset)-1);
int q_x_bin = bin_x(((Feature*)q)->x, le_bin, q_y_bin, 2*(((Feature*)q)->x_bin_offset)-1);
/* If the x bins have different values, the y bins don't need to be computed. */
if(p_x_bin != q_x_bin){
return p_x_bin-q_x_bin;
}
return p_y_bin-q_y_bin;
}
/* Sort Pattern's Features based on coordinate bins to give a unique ordering. */
qsort(new_pattern.features, num_stars_in_pattern-2, sizeof(Feature), compare_bins);
/* Create a copy of the first Feature of the Pattern. */
Feature first_feature = new_pattern.features[0];
/* Rotate the copy by 180 degrees by taking complements of its coordinates. */
first_feature.x = -first_feature.x;
first_feature.y = -first_feature.y;
/* Compare with the last Feature's bins to determine which has the largest */
/* x bin (with y bin as a tie breaker). This will determine the */
/* 180 degree rotation of the Pattern's coordinate system. The orientation */
/* which gives the larger Feature a positive x bin value is chosen. */
/* Put another way, the Feature furthest from the y-axis is placed on the right. */
/* In the case that the first and last Features' bins are ambiguous after */
/* rotating the first Feature by 180 degrees, both orientations are inserted. */
pattern_rotation = compare_bins((void*)&first_feature,
(void*)&(new_pattern.features[num_stars_in_pattern-3]));
/* If the current rotation is correct, insert the Pattern as-is. */
if(pattern_rotation <= 0){
disambiguate_feature_order(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern,
0);
}
/* If the current rotation is incorrect, rotate the Pattern by 180 degrees by taking */
/* the complement of its Features' bin offsets and coordinates, reversing the order */
/* of its Features, and swapping its fixed stars before inserting it into the catalog. */
if(pattern_rotation >= 0){
for(i=0;i<num_stars_in_pattern-2;i++){
/* Take the complement of each Feature's bin offsets and coordinates. */
new_pattern.features[i].x = -new_pattern.features[i].x;
new_pattern.features[i].y = -new_pattern.features[i].y;
}
/* Reverse the order of the Pattern's Features by swapping across the middle. */
for(i=0;i<(num_stars_in_pattern-2)/2;i++){
Feature feature_swap = new_pattern.features[i];
new_pattern.features[i] = new_pattern.features[num_stars_in_pattern-3-i];
new_pattern.features[num_stars_in_pattern-3-i] = feature_swap;
}
/* Swap the order of the Pattern's fixed star ids. */
unsigned int fixed_star_id_swap = new_pattern.fixed_star_id_1;
new_pattern.fixed_star_id_1 = new_pattern.fixed_star_id_2;
new_pattern.fixed_star_id_2 = fixed_star_id_swap;
/* Insert the 180 degree rotated Pattern into the catalog. */
disambiguate_feature_order(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern,
0);
}
}
/* Calculate the difference between the maximum and minimum bins. */
/* Also verify minimum and maximum bins are adjacent. Invalid bins should never */
/* occur during normal operation. They could be caused by invalid settings, */
/* doubleing point arithmetic errors, or another unforeseen bug. */
static int bin_diff(int min_bin,
int max_bin){
int diff = abs(max_bin - min_bin);
/* If the maximum bin isn't within one of the minimum bin, */
/* the bins are invalid, so return an error and exit. */
if(diff > 1){
printf("\nCoordinate overlaps 3 or more bins: raise bin_size_ratio.\n");
exit(EXIT_FAILURE);
}
return diff;
}
/* Recursive function that iterates over the Features in the given Pattern and */
/* duplicates the Pattern across the catalog given ambiguities in bin placement. */
/* Called by disambiguate_largest_edge, and calls disambiguate_rotation. */
static void disambiguate_bins(int just_count,
uint64_t *num_patterns,
Pattern pattern_catalog_cache[],
uint64_t *catalog_size_in_patterns,
int *cache_index,
Pattern new_pattern,
int feature_index){
/* Before the Pattern can have its Features' bins disambiguated, it must first */
/* have its fixed stars' largest edge bin disambiguated. */
if(feature_index < 0){
/* Iterate over all possible largest edge bin ambiguities. */
int min_le_bin = bin_largest_edge(new_pattern.largest_edge, -1);
int max_le_bin = bin_largest_edge(new_pattern.largest_edge, 1);
for(int le_bin_offset=0;
le_bin_offset<=bin_diff(min_le_bin, max_le_bin);
le_bin_offset++){
/* Set the Pattern's largest edge bin offset value. */
new_pattern.le_bin_offset = le_bin_offset;
/* Recursively calls itself to disambiguate the next bin. */
disambiguate_bins(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern,
feature_index+1);
}
}
/* If the Pattern hasn't had all of its coordinate bins disambiguated, */
/* recurse down to select a bin for the next Feature in the Pattern. */
else if(feature_index < num_stars_in_pattern-2){
/* Compute largest edge bin for use in creating x and y coordinate bins. */
unsigned int le_bin = bin_largest_edge(new_pattern.largest_edge,
2*new_pattern.le_bin_offset-1);
/* Iterate over all possible bin ambiguities in the x and y coordinate bins. */
int min_y_bin = bin_y(new_pattern.features[feature_index].y, le_bin, -1);
int max_y_bin = bin_y(new_pattern.features[feature_index].y, le_bin, 1);
for(int y_bin_offset=0;
y_bin_offset<=bin_diff(min_y_bin, max_y_bin);
y_bin_offset++){
/* Set the Feature's y bin offset. */
new_pattern.features[feature_index].y_bin_offset = y_bin_offset;
int y_bin = bin_y(new_pattern.features[feature_index].y, le_bin, 2*y_bin_offset-1);
int min_x_bin = bin_x(new_pattern.features[feature_index].x, le_bin, y_bin, -1);
int max_x_bin = bin_x(new_pattern.features[feature_index].x, le_bin, y_bin, 1);
for(int x_bin_offset=0;
x_bin_offset<=bin_diff(min_x_bin, max_x_bin);
x_bin_offset++){
/* Set the Feature's x bin offset. */
new_pattern.features[feature_index].x_bin_offset = x_bin_offset;
/* Recursively calls itself to disambiguate the next Feature. */
disambiguate_bins(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern,
feature_index+1);
}
}
}
/* Once the Pattern has had its largest edge bin and coordinate bins disambiguated, */
/* pass the Pattern on to disambiguate_rotation for insertion into the catalog. */
else{
/* Disambiguate the Pattern's 180 degree rotation, sort the Pattern's features, */
/* and insert the fully disambiguated Pattern into the catalog. */
disambiguate_rotation(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern);
}
}
/* Duplicates the Pattern across the catalog given ambiguities in the largest edge. */
/* Called by iterate_patterns, and calls disambiguate_bins. */
static void disambiguate_largest_edge(Star stars[],
int star_indices[num_stars_in_pattern],
int just_count,
uint64_t *num_patterns,
Pattern pattern_catalog_cache[],
uint64_t *catalog_size_in_patterns,
int *cache_index){
/* Dummy variables used for iteration. */
int i,j,k;
/* Pattern instance to be inserted into catalog. */
Pattern new_pattern;
/* Iterate over all pairs of stars in the pattern to */
/* find the length of the largest edge. */
double largest_edge_length = 0.0;
for(i=0;i<num_stars_in_pattern;i++){
for(j=i+1;j<num_stars_in_pattern;j++){
/* Track the largest edge so far by comparing once with each edge. */
largest_edge_length = fmax(largest_edge_length,
dist(stars[star_indices[i]].vec,
stars[star_indices[j]].vec));
}
}
/* Disambiguate largest edge length by considering all choices of star */
/* pairs within the pattern that are within error range of the largest edge. */
for(i=0;i<num_stars_in_pattern;i++){
for(j=i+1;j<num_stars_in_pattern;j++){
/* Test ambiguity of each edge length with the largest edge. */
double edge_length = dist(stars[star_indices[i]].vec,stars[star_indices[j]].vec);
/* The error in each of the two stars sharing the edge may contribute up to */
/* le_error_offset to the length of the edge. An edge is therefore considered */
/* ambiguous if its length is within 2*le_error_offset of the largest edge. */
if(edge_length >= largest_edge_length-2*le_error_offset){
/* Set the pattern's fixed star ids to those of the ambiguous edge. */
/* Their order may be swapped later to resolve the 180 degree ambiguity. */
new_pattern.fixed_star_id_1 = stars[star_indices[i]].star_id;
new_pattern.fixed_star_id_2 = stars[star_indices[j]].star_id;
/* Set the Pattern's largest edge length with the ambiguous edge, as it */
/* will be used to determine the coordinates of the remaining stars. */
/* Implicitly encodes the range from 0 up to the sine of the maximum */
/* camera FOV as a 16 bit unsigned integer to keep the catalog compact. */
new_pattern.largest_edge = (edge_length/max_le_length)*((1<<16)-1);
/* Calculate vector along x axis of Pattern's coordinate system. */
/* The vector points from Pattern star i to Pattern star j. */
double x_axis_vector[3];
diff(stars[star_indices[j]].vec,stars[star_indices[i]].vec,x_axis_vector);
/* Calculate vector along y axis of Pattern's coordinate system. */
double y_axis_vector[3];
cross_prod(stars[star_indices[j]].vec,stars[star_indices[i]].vec,y_axis_vector);
/* Normalize axis vectors to unit length by dividing by their magnitudes. */
normalize(x_axis_vector);
normalize(y_axis_vector);
/* Use the remaining stars to initialize the Pattern's Features. */
int feature_index = 0;
for(k=0;k<num_stars_in_pattern;k++){
/* Skip the fixed star ids, as they don't have their own Features. */
if(k != i && k != j){
/* Set the Feature's star id to match its corresponding star. */
new_pattern.features[feature_index].star_id = stars[star_indices[k]].star_id;
/* Calculate the normalized x and y coordinates using vector projection. */
double x = dot_prod(x_axis_vector, stars[star_indices[k]].vec)/edge_length;
double y = dot_prod(y_axis_vector, stars[star_indices[k]].vec)/edge_length;
/* Set Feature's coordinates by converting to implicitly divided integers. */
new_pattern.features[feature_index].x = x*((1<<14)-1);
new_pattern.features[feature_index].y = y*((1<<14)-1);
/* Disallow 0, as rotational ambiguity correction would fail. */
if(new_pattern.features[feature_index].x == 0){
new_pattern.features[feature_index].x = 1;
}
if(new_pattern.features[feature_index].y == 0){
new_pattern.features[feature_index].y = 1;
}
feature_index++;
}
}
/* Disambiguate bins and 180 degree rotation before insertion into catalog. */
disambiguate_bins(just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
new_pattern,
-1);
}
}
}
}
/* Recursive function that iterates over all Patterns with largest edges */
/* smaller than the maximum Field of View. If set to "just count," each */
/* valid Pattern is only used to increment a counter of valid Patterns. */
/* Otherwise, the function uses the Patterns to populate the catalog. */
/* just_count is a boolean that tells the function only to count */
/* the number of patterns and not to add them to the catalog. */
static void iterate_patterns(Star stars[],
int num_stars,
int just_count,
uint64_t *num_patterns,
Pattern pattern_catalog_cache[],
uint64_t *catalog_size_in_patterns,
int *cache_index,
int star_indices_index){
/* Array of star ids for a given Pattern. Being static avoids needing */
/* to pass the array between recursive calls of the function. */
static int star_indices[num_stars_in_pattern];
/* For the given Pattern star, iterate over its possible star ids, */
/* starting with the star id one greater than the Pattern star before */
/* it in the list or 0 if it's the first Pattern star. */
for(star_indices[star_indices_index]=star_indices_index>0?star_indices[star_indices_index-1]+1:0;
star_indices[star_indices_index]<num_stars;
star_indices[star_indices_index]++){
/* If the first Pattern star is being changed, update the progress percentage. */
if(star_indices_index == 0){
/* Progress is measured as the percentage of star ids the first Pattern star */
/* has covered. Since Patterns are produced in sorted order by star id, later */
/* star ids have fewer Patterns to iterate over, progress speeds up as it goes. */
printf("\r%.2f%%", 100.0*star_indices[0]/(num_stars-1));
}
/* Check whether the selected star id is within the maximum Field of View of */
/* the previously selected stars in the Pattern. If any of the previously */
/* selected stars are "out of range" of the newly selected star id, the */
/* Pattern will be too big to fit within the Field of View, so skip over */
/* the newly selected star completely and go to the next one. */
int within_range = 1;
for(int i=0;i<star_indices_index;i++){
if(dist(stars[star_indices[i]].vec,
stars[star_indices[star_indices_index]].vec) > max_le_length){
within_range = 0;
break;
}
}
if(within_range){
/* If the Pattern is valid but hasn't had all of its star ids selected, */
/* recurse down to select a star id for the next star in the Pattern. */
if(star_indices_index < num_stars_in_pattern-1){
iterate_patterns(stars,
num_stars,
just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index,
star_indices_index+1);
}
/* If the Pattern is valid and has all of its star ids selected, call the */
/* disambiguation functions to insert the Pattern into the catalog, duplicating */
/* the Pattern based on its possible ambiguities. The possible ambiguities */
/* are in the largest edge length, bin placement, and 180 degree rotation. */
else{
disambiguate_largest_edge(stars,
star_indices,
just_count,
num_patterns,
pattern_catalog_cache,
catalog_size_in_patterns,
cache_index);
}
}
}
}
/* Helper function that calls the iterate_patterns function in order */
/* to count the number of Patterns that will appear in the catalog. */
static uint64_t count_patterns(Star stars[],
int num_stars){
/* Initialize Pattern counter to zero. */
uint64_t num_patterns = 0;
/* The 1 tells iterate_patterns it should only count patterns */
/* without adding them to the catalog. */
/* The NULLs are stand-ins for pointers to the catalog size, */
/* the unused catalog cache, and cache_index. */
/* The 0 tells iterate_patterns it needs to select the first star. */
iterate_patterns(stars,
num_stars,
1,
&num_patterns,
NULL,
NULL,
NULL,
0);
return num_patterns;
}
/* Populate pattern catalog file with patterns in pieces. The pieces are */
/* kept in memory in the catalog cache until they're completed. Then they're */
/* written to the catalog file before the next piece is made. The pieces */
/* are created in order from the beginning of the catalog to the end. */
static void populate_catalog(FILE *pattern_catalog_file,
uint64_t catalog_size_in_patterns,
Star stars[],
int num_stars){
/* Allocate memory for catalog cache. */
/* By generating the catalog in pieces, it can be constructed in memory, */
/* which speeds up the process significantly even for large catalogs. */
Pattern *pattern_catalog_cache = calloc(max_cat_cache_size+max_probe_depth, sizeof(Pattern));
/* Initialize catalog cache to its maximum value. It is only */
/* changed when generating the last piece of the catalog. */
uint64_t cat_cache_size = max_cat_cache_size;
/* Generate the catalog one piece at a time. Cache_index tracks */
/* which piece of the catalog is currently being generated. */
int cache_index;
/* Calculate number of cached pieces that will be needed to build entire catalog. */
int num_catalog_pieces = catalog_size_in_patterns/max_cat_cache_size+1;
/* Iterate over the pieces. The last piece is truncated at the end of the catalog. */
for (cache_index=0;cache_index<num_catalog_pieces;cache_index++) {
printf("Generating catalog piece %d of %d...\n", cache_index+1, num_catalog_pieces);
/* When generating the last piece of the catalog, resize the cache. */
if (cache_index == num_catalog_pieces - 1){
cat_cache_size = catalog_size_in_patterns%max_cat_cache_size;
}
/* Copy the overlapping max_probe_depth catalog locations from the previous cache. */
/* This maintains the catalog's continuity despite generating it in pieces. */
memcpy(pattern_catalog_cache,
pattern_catalog_cache+max_cat_cache_size,
max_probe_depth*sizeof(Pattern));
/* Initialize this piece of the catalog by setting the rest to all zeros. */
memset(pattern_catalog_cache+max_probe_depth,
0,
max_cat_cache_size*sizeof(Pattern));
/* Populate catalog cache by iterating over all patterns, inserting only those which */
/* have initial offsets which place them within the cached section of the catalog. */
/* The NULL is a stand-in for the unused pointer to the Pattern counter. */
iterate_patterns(stars,
num_stars,
0,
NULL,
pattern_catalog_cache,
&catalog_size_in_patterns,
&cache_index,
0);
/* Write cached piece of the catalog to disk. */
printf("\nWriting piece to disk...\n");
fseeko64(pattern_catalog_file,
max_cat_cache_size*cache_index*sizeof(Pattern),
SEEK_SET);
fwrite(pattern_catalog_cache,
sizeof(Pattern),
cat_cache_size+max_probe_depth,
pattern_catalog_file);
}
}
int main(int argc, char *argv[]) {
/* Hipparchos catalog, pattern catalog, and star vectors file pointers. */
FILE *bsc_file,*pattern_catalog_file,*stars_file,*hip_numbers_file;
/* BSC5 cache */
BSC_Entry bsc_cache[STARN];
/* Allocate array of normalized star vectors, magnitudes, and star ids */
/* in x,y,z,mag,id format. Double stars have been removed from this array. */
Star *stars_temp = malloc(STARN*sizeof(Star));
Star *stars = malloc(STARN*sizeof(Star));
/* Number of vectors/stars in stars array. */
int num_stars_temp = 0;
int num_stars = 0;
/* Right ascension, Declination of star after correction to the current year. */
double ra, dec;
/* Number of Patterns in output catalog. Stars in these Patterns are non-double stars */
/* satisfying both the minimum brightness contraint and the max_fov constraint. */
uint64_t num_patterns = 0;
/* Size of pattern catalog in Patterns. */
uint64_t catalog_size_in_patterns;
/* Size of pattern catalog in bytes. */
uint64_t catalog_size_in_bytes;
/* Open BSC5 file for reading. */
bsc_file = fopen("BSC5","rb");
if(!bsc_file){
printf("Unable to open BSC5 file!");
return 1;
}
/* Offset read position in file by 28 bytes to ignore header data. */
fseeko64(bsc_file, 28, SEEK_SET);
/* Read BSC5 into cache. */
for(int i=0;i<STARN;i++){
fread(&bsc_cache[i].XNO, 4, 1, bsc_file);
fread(&bsc_cache[i].SRA0, 8, 1, bsc_file);
fread(&bsc_cache[i].SDEC0, 8, 1, bsc_file);
fread(&bsc_cache[i].IS, 2, 1, bsc_file);
fread(&bsc_cache[i].MAG, 2, 1, bsc_file);
fread(&bsc_cache[i].XRPM, 4, 1, bsc_file);
fread(&bsc_cache[i].XDPM, 4, 1, bsc_file);
}
/* Close BSC5 file. */
fclose(bsc_file);
/* Read BSC5 catalog and create temporary array of normalized vectors pointing */
/* at each star. Also filter out stars dimmer than the minimum magnitude. */
for(int i=0;i<STARN;i++){
/* If the star is at least as bright as the minimum magnitude, add its vector to the array. */
if(bsc_cache[i].MAG/100.0 <= min_magnitude){
/* Correct right ascension by adding proper motion times the number of years since 1950. */
double ra = bsc_cache[i].SRA0+bsc_cache[i].XRPM*(current_year-1950);
/* Correct declination by adding proper motion times the number of years since 1950 */
double dec = bsc_cache[i].SDEC0+bsc_cache[i].XDPM*(current_year-1950);
if(ra == 0.0 && dec == 0.0){
continue;
}
double magnitude = bsc_cache[i].MAG/100.0;
/* x component (forward) */
stars_temp[num_stars_temp].vec[0] = cos(ra)*cos(dec);
/* y component (left) */
stars_temp[num_stars_temp].vec[1] = sin(ra)*cos(dec);
/* z component (up) */
stars_temp[num_stars_temp].vec[2] = sin(dec);
num_stars_temp += 1;
}
}
/* Filter double stars out of star vectors array. */
for(int i=0;i<num_stars_temp;i++){
int is_double_star = 0;
for(int j=0;j<num_stars_temp;j++){
if (j == i) {
continue;
}
/* If the star vector is too close to any other star vector, */
/* don't add it to the vector array. */
if(dot_prod(stars_temp[i].vec,stars_temp[j].vec) > cos(min_star_separation)){
is_double_star = 1;
break;
}
}
/* If it isn't too close to any other star vector, add it to the vector array. */
if(!is_double_star) {
stars[num_stars] = stars_temp[i];
stars[num_stars].star_id = num_stars;
num_stars += 1;
}
}
/* Close Hipparchos catalog file. */
fclose(bsc_file);
/* Print the number of non-double stars at least as bright as the minimum magnitude. */
printf("%d non-double stars at least magnitude %.2f found\n", num_stars, min_magnitude);
/* Open stars file for writing. */
stars_file = fopen("stars", "wb+");
if(!stars_file){
printf("Unable to open stars file!");
return 1;
}
/* Generate stars file, which stores star vectors, magnitudes, and star ids. */
printf("Inserting the %d stars into stars file...\n", num_stars);
/* Write array of stars to the stars file. */
fwrite(stars, sizeof(Star), num_stars, stars_file);
/* Close stars file. */
fclose(stars_file);
/* Count number of Patterns that will be inserted into catalog. */
/* The number of Patterns is needed prior to catalog generation */
/* to set the catalog size based on the user specified density. */
printf("Counting the number of Patterns the catalog will contain...\n");
num_patterns = count_patterns(stars, num_stars);
printf("\n%llu patterns counted\n", num_patterns);
catalog_size_in_patterns = num_patterns*(1.0/catalog_density);
catalog_size_in_bytes = catalog_size_in_patterns * sizeof(Pattern);
printf("Generating catalog of size %llu patterns and %llu bytes...\n",
catalog_size_in_patterns,
catalog_size_in_bytes);
/* Open pattern catalog file for writing. */
pattern_catalog_file = fopen("pattern_catalog", "wb+");
if(!pattern_catalog_file){
printf("Unable to open pattern catalog file!");
return 1;
}
/* Populate pattern catalog file with patterns. */
populate_catalog(pattern_catalog_file,
catalog_size_in_patterns,
stars,
num_stars);
/* Retrieve deepest probe depth reached while generating catalog. */
uint64_t cache_offset = 0;
int probe_step = 0;
printf("Deepest probe depth: %d\n", increment_offset(&cache_offset, &probe_step));
printf("Catalog generation complete!");
return 0;
};
|
the_stack_data/25136642.c | #include <stdio.h>
int main() {
int c;
printf("Enter a value : ");
c = getchar();
printf("\n You entered: ");
putchar(c);
printf("\n");
return 0;
} |
the_stack_data/68854.c | struct FOO {
int bar;
};
int main() {
struct FOO foo;
foo.bar = 10;
foo.bar--;
return 0;
}
|
the_stack_data/178266775.c | void mx_swap_char(char *s1, char *s2) {
char swap;
if (!s1 || !s2) {
return;
}
swap = *s1;
*s1 = *s2;
*s2 = swap;
}
|
the_stack_data/31387422.c | /**
******************************************************************************
* @file stm32l5xx_ll_opamp.c
* @author MCD Application Team
* @brief OPAMP LL module driver
******************************************************************************
* @attention
*
* <h2><center>© Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
#if defined(USE_FULL_LL_DRIVER)
/* Includes ------------------------------------------------------------------*/
#include "stm32l5xx_ll_opamp.h"
#ifdef USE_FULL_ASSERT
#include "stm32_assert.h"
#else
#define assert_param(expr) ((void)0U)
#endif
/** @addtogroup STM32L5xx_LL_Driver
* @{
*/
#if defined (OPAMP1) || defined (OPAMP2)
/** @addtogroup OPAMP_LL OPAMP
* @{
*/
/* Private types -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private constants ---------------------------------------------------------*/
/* Private macros ------------------------------------------------------------*/
/** @addtogroup OPAMP_LL_Private_Macros
* @{
*/
/* Check of parameters for configuration of OPAMP hierarchical scope: */
/* OPAMP instance. */
#define IS_LL_OPAMP_POWER_MODE(__POWER_MODE__) \
( ((__POWER_MODE__) == LL_OPAMP_POWERMODE_NORMAL) \
|| ((__POWER_MODE__) == LL_OPAMP_POWERMODE_LOWPOWER))
#define IS_LL_OPAMP_FUNCTIONAL_MODE(__FUNCTIONAL_MODE__) \
( ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_STANDALONE) \
|| ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_FOLLOWER) \
|| ((__FUNCTIONAL_MODE__) == LL_OPAMP_MODE_PGA) \
)
/* Note: Comparator non-inverting inputs parameters are the same on all */
/* OPAMP instances. */
/* However, comparator instance kept as macro parameter for */
/* compatibility with other STM32 families. */
#define IS_LL_OPAMP_INPUT_NONINVERTING(__OPAMPX__, __INPUT_NONINVERTING__) \
( ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINVERT_IO0) \
|| ((__INPUT_NONINVERTING__) == LL_OPAMP_INPUT_NONINV_DAC1_CH1) \
)
/* Note: Comparator non-inverting inputs parameters are the same on all */
/* OPAMP instances. */
/* However, comparator instance kept as macro parameter for */
/* compatibility with other STM32 families. */
#define IS_LL_OPAMP_INPUT_INVERTING(__OPAMPX__, __INPUT_INVERTING__) \
( ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO0) \
|| ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_IO1) \
|| ((__INPUT_INVERTING__) == LL_OPAMP_INPUT_INVERT_CONNECT_NO) \
)
/**
* @}
*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @addtogroup OPAMP_LL_Exported_Functions
* @{
*/
/** @addtogroup OPAMP_LL_EF_Init
* @{
*/
/**
* @brief De-initialize registers of the selected OPAMP instance
* to their default reset values.
* @param OPAMPx OPAMP instance
* @retval An ErrorStatus enumeration value:
* - SUCCESS: OPAMP registers are de-initialized
* - ERROR: OPAMP registers are not de-initialized
*/
ErrorStatus LL_OPAMP_DeInit(OPAMP_TypeDef* OPAMPx)
{
ErrorStatus status = SUCCESS;
/* Check the parameters */
assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx));
LL_OPAMP_WriteReg(OPAMPx, CSR, 0x00000000U);
return status;
}
/**
* @brief Initialize some features of OPAMP instance.
* @note This function reset bit of calibration mode to ensure
* to be in functional mode, in order to have OPAMP parameters
* (inputs selection, ...) set with the corresponding OPAMP mode
* to be effective.
* @note This function configures features of the selected OPAMP instance.
* Some features are also available at scope OPAMP common instance
* (common to several OPAMP instances).
* Refer to functions having argument "OPAMPxy_COMMON" as parameter.
* @param OPAMPx OPAMP instance
* @param OPAMP_InitStruct Pointer to a @ref LL_OPAMP_InitTypeDef structure
* @retval An ErrorStatus enumeration value:
* - SUCCESS: OPAMP registers are initialized
* - ERROR: OPAMP registers are not initialized
*/
ErrorStatus LL_OPAMP_Init(OPAMP_TypeDef *OPAMPx, LL_OPAMP_InitTypeDef *OPAMP_InitStruct)
{
/* Check the parameters */
assert_param(IS_OPAMP_ALL_INSTANCE(OPAMPx));
assert_param(IS_LL_OPAMP_POWER_MODE(OPAMP_InitStruct->PowerMode));
assert_param(IS_LL_OPAMP_FUNCTIONAL_MODE(OPAMP_InitStruct->FunctionalMode));
assert_param(IS_LL_OPAMP_INPUT_NONINVERTING(OPAMPx, OPAMP_InitStruct->InputNonInverting));
/* Note: OPAMP inverting input can be used with OPAMP in mode standalone */
/* or PGA with external capacitors for filtering circuit. */
/* Otherwise (OPAMP in mode follower), OPAMP inverting input is */
/* not used (not connected to GPIO pin). */
if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER)
{
assert_param(IS_LL_OPAMP_INPUT_INVERTING(OPAMPx, OPAMP_InitStruct->InputInverting));
}
/* Configuration of OPAMP instance : */
/* - PowerMode */
/* - Functional mode */
/* - Input non-inverting */
/* - Input inverting */
/* Note: Bit OPAMP_CSR_CALON reset to ensure to be in functional mode. */
if(OPAMP_InitStruct->FunctionalMode != LL_OPAMP_MODE_FOLLOWER)
{
MODIFY_REG(OPAMPx->CSR,
OPAMP_CSR_OPALPM
| OPAMP_CSR_OPAMODE
| OPAMP_CSR_CALON
| OPAMP_CSR_VMSEL
| OPAMP_CSR_VPSEL
,
(OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK)
| OPAMP_InitStruct->FunctionalMode
| OPAMP_InitStruct->InputNonInverting
| OPAMP_InitStruct->InputInverting
);
}
else
{
MODIFY_REG(OPAMPx->CSR,
OPAMP_CSR_OPALPM
| OPAMP_CSR_OPAMODE
| OPAMP_CSR_CALON
| OPAMP_CSR_VMSEL
| OPAMP_CSR_VPSEL
,
(OPAMP_InitStruct->PowerMode & OPAMP_POWERMODE_CSR_BIT_MASK)
| LL_OPAMP_MODE_FOLLOWER
| OPAMP_InitStruct->InputNonInverting
| LL_OPAMP_INPUT_INVERT_CONNECT_NO
);
}
return SUCCESS;
}
/**
* @brief Set each @ref LL_OPAMP_InitTypeDef field to default value.
* @param OPAMP_InitStruct pointer to a @ref LL_OPAMP_InitTypeDef structure
* whose fields will be set to default values.
* @retval None
*/
void LL_OPAMP_StructInit(LL_OPAMP_InitTypeDef *OPAMP_InitStruct)
{
/* Set OPAMP_InitStruct fields to default values */
OPAMP_InitStruct->PowerMode = LL_OPAMP_POWERMODE_NORMAL;
OPAMP_InitStruct->FunctionalMode = LL_OPAMP_MODE_FOLLOWER;
OPAMP_InitStruct->InputNonInverting = LL_OPAMP_INPUT_NONINVERT_IO0;
/* Note: Parameter discarded if OPAMP in functional mode follower, */
/* set anyway to its default value. */
OPAMP_InitStruct->InputInverting = LL_OPAMP_INPUT_INVERT_CONNECT_NO;
}
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#endif /* OPAMP1 || OPAMP2 */
/**
* @}
*/
#endif /* USE_FULL_LL_DRIVER */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.