file
stringlengths
18
26
data
stringlengths
2
1.05M
the_stack_data/165769116.c
#include<stdio.h>/*あらかじめ用意されているC言語の入出力関係の機能(ライブラリ)を「使いますよ」という宣言をしています。*/ int main(void)/*C言語のプログラムでは「int main(void)」から実行が始まります*/ {/*「main(void){」で始まり「}」で終わります*/ printf("%d×%d=%2d\n",5,1,5*1);/*C言語が用意している画面に文字列を表示する命令(関数)です。「"」で囲まれた文字列が画面に表示されます。詳細は後に学習します。最後の「|n");」は半角文字でなけれはなりません*//*「=」の後に半角スペース2文字分あけて「5」が表示されます*/ printf("%d×%d=%2d\n",5,2,5*2); printf("%d×%d=%2d\n",5,3,5*3); printf("%d×%d=%2d\n",5,4,5*4); printf("%d×%d=%2d\n",5,5,5*5); printf("%d×%d=%2d\n",5,6,5*6); printf("%d×%d=%2d\n",5,7,5*7); printf("%d×%d=%2d\n",5,8,5*8); printf("%d×%d=%2d\n",5,9,5*9); return 0;/*プログラムを終了する命令です*/ }/*「main(void){」で始まり「}」で終わります*/
the_stack_data/117329421.c
#if defined (STM8Lxx) #include "stm8l15x_comp.c" #endif
the_stack_data/67324528.c
#ifdef OPTION_TTF #include "r/texture.h" #include "r/ro_single.h" #include "r/ro_ttftext.h" struct RoTtfTextGlobals_s ro_ttftext; rTexture ro_ttftext_create_texture(TTF_Font *font, vec4 color, const char *text, int *opt_out_w, int *opt_out_h) { // SDL_ttf seems to render in BGRA format, so we just swap r and b SDL_Surface *img = TTF_RenderText_Blended(font, text, (SDL_Color) {color.v2 * 255, color.v1 * 255, color.v0 * 255, color.v3 * 255}); rTexture tex = r_texture_new_sdl_surface(1, 1, img); r_texture_filter_linear(tex); if (opt_out_w) *opt_out_w = img->w; if (opt_out_h) *opt_out_h = img->h; SDL_FreeSurface(img); return tex; } // // private // // from u/pose static float u_pose_get_w(mat4 p) { return sqrtf(powf(p.m00, 2) + powf(p.m01, 2)); } static float u_pose_get_h(mat4 p) { return sqrtf(powf(p.m10, 2) + powf(p.m11, 2)); } static void u_pose_set_w(mat4 *p, float w) { float f = w / u_pose_get_w(*p); p->m00 *= f; p->m01 *= f; } static void u_pose_set_h(mat4 *p, float h) { float f = h / u_pose_get_h(*p); p->m10 *= f; p->m11 *= f; } static void u_pose_set_size(mat4 *p, float w, float h) { u_pose_set_w(p, w); u_pose_set_h(p, h); } // end of u/pose copy // // public // RoTtfText ro_ttftext_new(vec4 color, const char *text) { RoTtfText self; self.font = ro_ttftext.default_font; int w, h; self.ro = ro_single_new(ro_ttftext_create_texture(self.font, color, text, &w, &h)); self.ratio = (float) w / h; return self; } void ro_ttftext_kill(RoTtfText *self) { ro_single_kill(&self->ro); } void ro_ttftext_render(const RoTtfText *self, const mat4 *camera_mat) { ro_single_render(&self->ro, camera_mat); } void ro_ttftext_set_size(RoTtfText *self, float h) { u_pose_set_size(&self->ro.rect.pose, h * self->ratio, h); } void ro_ttftext_set_text(RoTtfText *self, vec4 color, const char *text) { int w, h; ro_single_set_texture(&self->ro, ro_ttftext_create_texture(self->font, color, text, &w, &h)); self->ratio = (float) w / h; ro_ttftext_set_size(self, u_pose_get_h(self->ro.rect.pose)); } #else //OPTION_TTF typedef int avoid_iso_c_empty_translation_unit_warning_; #endif
the_stack_data/145144.c
/* * Author: Moisés Fernández Zárate A01197049 * Date created: 01/03/2020 * * Mission0.c * In this mission we simulate a system that manages agents. */ #include <stdio.h> #include <string.h> #include <stdbool.h> #include <stdlib.h> /* * struct Node * Structure created to manage each intelligence active and mission, * which are simulated with the next structure ListNodes. */ typedef struct Node { struct Node *next; char input[70]; } Node; /* * struct ListNodes * Structure created to manage the intelligence actives and missions * of each agent, which uses the structure Node for each intelligence * active and mission. */ typedef struct ListNodes { Node *head; Node *tail; } ListNodes; /* * struct Agent * Structure created to manage each agent's profile in the system. */ typedef struct Agent { char name[70]; char lastName[70]; int age; ListNodes intelligenceActives; ListNodes missions; struct Agent *next; } Agent; /* * struct ListAgents * Structure created to manage all the agents in the system. */ typedef struct ListAgents { Agent *head; Agent *tail; } ListAgents; /* * function menu() * This function displays the menu of the system. * Parameters: none. * Return value: none. */ void menu(); /* * function createEntry() * This function creates an agent's profile to store it in the system. * Parameters: none. * Return value: none. */ void createEntry(); /* * function addIntelligenceActive(agent, intelligenceActive, counter) * Parameters: * agent: an agent where the intelligence active will be stored. * intelligenceActive: the intelligence active that will be stored in the agent's profile. * counter: this counter is used to know how to add an intelligence active to the list * of the agent, depending on if it's the first or another one after that. * Return value: none. */ void addIntelligenceActive(Agent *agent, char intelligenceActive[70], int counter); /* * function addMission(agent, mission, counter) * Parameters: * agent: an agent where the mission will be stored. * mission: the mission that will be stored in the agent's profile. * counter: this counter is used to know how to add a mission to the list of the * agent, depending on if it's the first or another one after that. * Return value: none. */ void addMission(Agent *agent, char mission[70], int counter); /* * function deleteEntry() * This function deletes an agent's profile of the system. * Parameters: none. * Return value: none. */ void deleteEntry(); /* * function showAgentProfile(agent) * This function displays the profile of an agent that is received as a parameter. * Parameters: * agent: the agent whose profile will be displayed. * Return value: none. */ void showAgentProfile(Agent *agent); /* * function showAgents() * This function displays the profiles of all the agents that are registered. * Parameters: none. * Return value: none. */ void showAgents(); /* * function validateMission(mission) * This function checks if the mission received is correct. * Parameters: * mission: the mission that will be checked. * Return value: a boolean to know if the mission received is correct. */ bool validateMission(char *mission); /* * function validateIntelligenceActive(intelligenceActive) * This function checks if the intelligence active received is correct. * Parameters: * intelligenceActive: the intelligence active that will be checked. * Return value: a boolean to know if the intelligence active received is correct. */ bool validateIntelligenceActive(char *intelligenceActive); // Global variable to manage the list of agents that are registered. ListAgents agents; // The main function. int main(void) { menu(); return 0; } void menu() { int option; while (true) { printf("----------------------MENU----------------------\n"); printf("Select one of the following options (1, 2, 3 or 4):\n"); printf("1) Create a new entry\n"); printf("2) Delete an entry\n"); printf("3) Show all agents' profiles\n"); printf("4) Exit\n"); scanf("%d", &option); switch(option) { case 1: createEntry(); break; case 2: deleteEntry(); break; case 3: showAgents(); break; case 4: exit(0); break; default: printf("That is not a valid option.\n"); menu(); break; } } } bool validateIntelligenceActive(char *intelligenceActive) { if (strlen(intelligenceActive) < 13) { return false; } for (int i = 0; i < 4; i++) { if (intelligenceActive[i] < 'A' || (intelligenceActive[i] > 'Z' && intelligenceActive[i] < 'a') || intelligenceActive[i] > 'z') { return false; } } for (int i = 4; i < strlen(intelligenceActive); i++) { if (intelligenceActive[i] < '0' || intelligenceActive[i] > '9') { return false; } } return true; } bool validateMission(char *mission) { if (strlen(mission) < 12) { return false; } for (int i = 0; i < 3; i++) { if (mission[i] < 'A' || (mission[i] > 'Z' && mission[i] < 'a') || mission[i] > 'z') { return false; } } for (int i = 3; i < strlen(mission); i++) { if (mission[i] < '0' || mission[i] > '9') { return false; } } return true; } void addIntelligenceActive(Agent *agent, char intelligenceActive[70], int counter) { Node *newIntelligenceActive = 0; newIntelligenceActive = (Node*) malloc(sizeof(Node)); strcpy(newIntelligenceActive->input, intelligenceActive); newIntelligenceActive->next = 0; if (counter == 0) { agent->intelligenceActives.head = newIntelligenceActive; agent->intelligenceActives.tail = agent->intelligenceActives.head; } else { agent->intelligenceActives.tail->next = newIntelligenceActive; agent->intelligenceActives.tail = newIntelligenceActive; } } void addMission(Agent *agent, char mission[70], int counter) { Node *newMission = 0; newMission = (Node*) malloc(sizeof(Node)); strcpy(newMission->input, mission); newMission->next = 0; if (counter == 0) { agent->missions.head = newMission; agent->missions.tail = agent->missions.head; } else { agent->missions.tail->next = newMission; agent->missions.tail = newMission; } } void createEntry() { Agent *agent; agent = (struct Agent*) malloc(sizeof(struct Agent)); agent->intelligenceActives.head = 0; agent->intelligenceActives.tail = 0; agent->missions.head = 0; agent->missions.tail = 0; printf("Enter the first name of the agent: "); scanf("%s", agent->name); printf("Enter the last name of the agent: "); scanf("%s", agent->lastName); printf("Enter the age of the agent: "); scanf("%d", &agent->age); // Adding intelligence actives to an agent. int numberIntelligenceActives = 0; char intelligenceActive[70]; printf("Enter the number of intelligence actives: "); scanf("%d", &numberIntelligenceActives); for (int i = 0; i < numberIntelligenceActives; i++) { printf("Enter the intelligence active #%d: ", i + 1); scanf("%s", intelligenceActive); while (!validateIntelligenceActive(intelligenceActive)) { printf("The intelligence active is invalid. Please enter it again (4 letters followed by 9 digits): "); scanf("%s", intelligenceActive); } addIntelligenceActive(agent, intelligenceActive, i); } // Adding missions to an agent. int numberMissions = 0; char mission[70]; printf("Enter the number of missions: "); scanf("%d", &numberMissions); for (int i = 0; i < numberMissions; i++) { printf("Enter mission #%d: ", i+1); scanf("%s", mission); while (!validateMission(mission)) { printf("The mission is invalid. Please enter it again (3 letters followed by 9 digits): "); scanf("%s", mission); } addMission(agent, mission, i); } if (agents.head == 0) { agents.head = agent; agents.tail = agent; } else { agents.tail->next = agent; agents.tail = agent; } agents.tail->next = 0; printf("The agent profile was registered with success.\n"); } void deleteEntry() { Agent *curr = agents.head; Agent *prev = agents.head; char name[70]; char lastName[70]; int numberAgent = 1; printf("To delete an agent, please enter the following information...\n"); printf("Agent's first name: "); scanf("%s", name); printf("Agent's last name: "); scanf("%s", lastName); printf("Looking for the agent %s %s...\n", name, lastName); if (curr == 0) { printf("Error: The agent %s %s was not found.\n", name, lastName); return; } if (!strcmp(curr->name, name) && !strcmp(curr->lastName, lastName)) { agents.head = agents.head->next; curr->next = 0; free(curr); curr = agents.head; prev = agents.head; printf("The agent %s %s was deleted succesfully.\n", name, lastName); return; } else { curr = curr->next; } while (curr != 0) { if (!strcmp(curr->name, name) && !strcmp(curr->lastName, lastName)) { prev->next = curr->next; curr->next = NULL; free(curr); curr = prev->next; printf("The agent %s %s was deleted succesfully.\n", name, lastName); return; } else { prev = prev->next; curr = curr->next; } } printf("Error: The agent %s %s was not found.\n", name, lastName); } void showAgentProfile(Agent *agent) { printf("----------------------AGENT PROFILE----------------------\n"); printf("Agent's name: %s\n", agent->name); printf("Agent's last name: %s\n", agent->lastName); printf("Agent's age: %d\n", agent->age); printf("--------AGENT'S INTELLIGENCE ACTIVES--------\n"); Node *curr = agent->intelligenceActives.head; while (curr != 0) { printf("%s\n", curr->input); curr = curr->next; } printf("--------AGENT'S MISSIONS--------\n"); curr = agent->missions.head; while (curr != 0) { printf("%s\n", curr->input); curr = curr->next; } } void showAgents() { Agent *curr = agents.head; while (curr != 0) { showAgentProfile(curr); curr = curr->next; } }
the_stack_data/1059679.c
#include <stdio.h> #include <stdlib.h> typedef struct celula { int dado; struct celula *prox; } celula; /*celula *inicializa(){ celula *novo = malloc(sizeof(celula)); novo -> prox = NULL; } void insere(celula *le, int i){ celula *nova = malloc(sizeof(celula)); nova -> dado = i; nova -> prox = le -> prox; le -> prox = nova; }*/ void imprime (celula *le) { for(celula *p = le -> prox; p != NULL; p = p->prox){ printf("%d -> ", p->dado); } printf("NULL\n"); } void imprime_rec (celula *le) { if (le->prox == NULL){ printf ("NULL\n"); return ; } else { printf("%d -> ", le->prox->dado); return imprime_rec (le->prox); } } /*int main() { celula *le; le = inicializa (); for(int i = 0; i <= 5; i++) insere(le, i); imprime(le); imprime_rec (le); return 0; }*/
the_stack_data/86075164.c
int main() { int a = 5; int b = 2; int c = 6; a /= b + 2 - c; return a; }
the_stack_data/108113.c
#include <stdio.h> #include <signal.h> #include <unistd.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> int main(void) { pid_t pid; int i, n, status; for (i = 1; i <= 3; i++) { pid = fork(); if (pid == 0) { printf("CHILD no. %d (PID=%d) working ... \n", i, getpid()); sleep(i * 7); // child working ... printf("CHILD no. %d (PID=%d) exiting ... \n", i, getpid()); exit(0); } } for (i = 1; i <= 4; i++) { printf("PARENT: working hard (task no. %d) ...\n", i); n = 20; while ((n = sleep(n)) != 0); printf("PARENT: end of task no. %d\n", i); printf("PARENT: waiting for child no. %d ...\n", i); while ((pid = waitpid(-1, &status, WNOHANG)) > 0) printf("PARENT: child with PID=%d terminated with exit code %d\n", pid, WEXITSTATUS(status)); } exit(0); }
the_stack_data/607618.c
#include <arpa/inet.h> #include <errno.h> #include <event2/event.h> #include <netinet/in.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <unistd.h> #include <ctype.h> #define READ_BUFF_SIZE 16 #define WRITE_BUFF_SIZE 3 typedef struct connection_ctx_t { struct connection_ctx_t* next; struct connection_ctx_t* prev; evutil_socket_t fd; struct event_base* base; struct event* read_event; struct event* write_event; uint8_t read_buff[READ_BUFF_SIZE]; uint64_t write_buff[WRITE_BUFF_SIZE]; ssize_t read_buff_used; ssize_t write_buff_used; } connection_ctx_t; typedef struct sub_sequence{ uint8_t flag; uint16_t step; uint64_t part; } sub_sequence; sub_sequence sequence[3]; struct event* gen_and_write_seq_event = NULL; size_t count_clients; // error output void error(const char* msg) { fprintf(stderr, "%s, errno = %d\n", msg, errno); exit(1); } void error_no_exit(const char* msg) { fprintf(stderr, "%s, errno = %d\n", msg, errno); } // called manually void on_close(connection_ctx_t* ctx){ printf("[%p] on_close called, fd = %d\n", ctx, ctx->fd); // remove ctx from the lined list ctx->prev->next = ctx->next; ctx->next->prev = ctx->prev; if(ctx->read_event){ event_del(ctx->read_event); event_free(ctx->read_event); } if(ctx->write_event){ event_del(ctx->write_event); event_free(ctx->write_event); } close(ctx->fd); free(ctx); } // checks if the string is a natural number uint8_t is_str_digit(const char* str){ const char* digit = str; while(*digit){ if(!isdigit(*digit)){ printf("The string is not a number!\n"); return 0; } digit++; } return 1; } // void check_sub_sequence(sub_sequence* sequence){ char* token = strtok(NULL, " "); if(token && (strlen(token)<=4) && is_str_digit(token)){ char* end; sequence->part = strtoul(token, &end, 10); token = strtok(NULL, " "); if(token && (strlen(token)<=4) && is_str_digit(token)){ sequence->step = strtoul(token, &end, 10); sequence->flag = 1; } else printf("Incorrect step input of the subsequence (must match the mask yyyy)!\n"); } else printf("Incorrect input of the initial value of the sub-sequence (must match the mask xxxx)!\n"); } void generator_sequence(evutil_socket_t fd, short flags, void* arg){ if((((connection_ctx_t*)arg)->next == arg) || (!sequence[0].flag && !sequence[1].flag && !sequence[2].flag)){ printf("No connected clients or all three sequences are ignored!\n"); if(event_del(gen_and_write_seq_event) < 0) error("event_del() failed"); event_free(gen_and_write_seq_event); gen_and_write_seq_event = NULL; return; } connection_ctx_t* ctx = ((connection_ctx_t*)arg)->next; if(!ctx->write_buff_used){ size_t i, j=0; for(i=0; i<WRITE_BUFF_SIZE; ++i) { if(sequence[i].flag){ if((ctx->write_buff[j] + sequence[i].step) > UINT64_MAX) ctx->write_buff[j] = sequence[i].part; else ctx->write_buff[j] += sequence[i].step; j++; } } ctx->write_buff_used = sizeof(ctx->write_buff[0])*j; } if(event_add(ctx->write_event, NULL) < 0) error("event_add(peer->write_event, ...) failed"); count_clients++; if(ctx->read_event) event_del(ctx->read_event); connection_ctx_t* peer = ctx->next; while(peer != ctx){ if(peer->write_event == NULL) { // list head, skipping peer = peer->next; continue; } // printf("[%p] sending a message to %p...\n", ctx, peer); size_t i; for(i=0; i<WRITE_BUFF_SIZE; ++i) peer->write_buff[i] = ctx->write_buff[i]; peer->write_buff_used = ctx->write_buff_used; // add writing event (it's not a problem to call it multiple times) if(event_add(peer->write_event, NULL) < 0) error("event_add(peer->write_event, ...) failed"); count_clients++; if(peer->read_event){ event_del(peer->read_event); } peer = peer->next; } if(event_del(gen_and_write_seq_event) < 0) error("event_del() failed"); } // command check input by user void check_command(char* str, connection_ctx_t* ctx){ char* token = strtok(str, " "); if(!token){ printf("Incorrect input of a subsequence!\n"); return; } if(!strcmp(token, "seq1")){ check_sub_sequence(&sequence[0]); } else if(!strcmp(token, "seq2")){ check_sub_sequence(&sequence[1]); } else if(!strcmp(token, "seq3")){ check_sub_sequence(&sequence[2]); } else if(!strcmp(token, "export")){ token = strtok(NULL, " "); if(!strcmp(token, "seq")){ if(sequence[0].flag && sequence[1].flag && sequence[2].flag){ size_t i,j=0; for(i=0; i<WRITE_BUFF_SIZE; ++i){ if(sequence[i].part && sequence[i].step) ctx->write_buff[j++] = sequence[i].part; else sequence[i].flag = 0; } ctx->write_buff_used = sizeof(ctx->write_buff[0])*j; gen_and_write_seq_event = event_new(ctx->base, -1, EV_PERSIST, generator_sequence, (void*)ctx->prev); if(!gen_and_write_seq_event) error("event_new(... EV_WRITE ...) failed"); if(event_add(gen_and_write_seq_event, NULL) < 0) error("event_add(gen_and_write_seq_event, ...) failed"); event_active(gen_and_write_seq_event, EV_PERSIST, 0); } } } else printf("Incorrect input of a subsequence!\n"); } void on_read(evutil_socket_t fd, short flags, void* arg){ connection_ctx_t* ctx = arg; printf("[%p] on_read called, fd = %d\n", ctx, fd); ssize_t bytes; for(;;) { bytes = read(fd, ctx->read_buff + ctx->read_buff_used, READ_BUFF_SIZE - ctx->read_buff_used); if(bytes == 0) { printf("[%p] client disconnected!\n", ctx); on_close(ctx); return; } if(bytes < 0) { if(errno == EINTR) continue; printf("[%p] read() failed, errno = %d, closing connection.\n", ctx, errno); on_close(ctx); return; } break; // read() succeeded } ssize_t check = ctx->read_buff_used; ssize_t check_end = ctx->read_buff_used + bytes; ctx->read_buff_used = check_end; while(check < check_end){ if(ctx->read_buff[check] != '\n'){ check++; continue; } int length = (int)check; ctx->read_buff[length] = '\0'; if((length > 0) && (ctx->read_buff[length - 1] == '\r')){ ctx->read_buff[length - 1] = '\0'; length--; } check_command((char*)(ctx->read_buff), ctx); // shift read_buff (optimize!) memmove(ctx->read_buff, ctx->read_buff + check, check_end - check - 1); ctx->read_buff_used -= check + 1; check_end -= check; check = 0; } if(ctx->read_buff_used == READ_BUFF_SIZE) { printf("[%p] client sent a very long string, closing connection.\n", ctx); on_close(ctx); } } void on_write(evutil_socket_t fd, short flags, void* arg){ connection_ctx_t* ctx = arg; // printf("[%p] on_write called, fd = %d\n", ctx, fd); ssize_t bytes; for(;;) { bytes = write(fd, ctx->write_buff, ctx->write_buff_used); if(bytes <= 0) { if(errno == EINTR) continue; printf("[%p] write() failed, errno = %d, closing connection.\n", ctx, errno); on_close(ctx); count_clients--; if(!count_clients) event_active(gen_and_write_seq_event, EV_PERSIST, 0); return; } break; // write() succeeded } // shift the write_buffer (optimize!) memmove(ctx->write_buff, ctx->write_buff + bytes, ctx->write_buff_used - bytes); ctx->write_buff_used -= bytes; // if there is nothing to send call event_del if(ctx->write_buff_used == 0) { // printf("[%p] write_buff is empty, calling event_del(write_event)\n", ctx); if(event_del(ctx->write_event) < 0) error("event_del() failed"); } count_clients--; if(!count_clients) //if the current sequence is passed to all existing clients, generate a new one. event_active(gen_and_write_seq_event, EV_PERSIST, 0); } void on_accept(evutil_socket_t listen_sock, short flags, void* arg){ connection_ctx_t* head_ctx = (connection_ctx_t*)arg; evutil_socket_t fd = accept(listen_sock, 0, 0); if(fd < 0){ if(head_ctx->next == head_ctx) error("accept() failed"); else{ error_no_exit("accept() failed"); return; } } // make in nonblocking if(evutil_make_socket_nonblocking(fd) < 0){ if(head_ctx->next == head_ctx) error("evutil_make_socket_nonblocking() failed"); else{ error_no_exit("evutil_make_socket_nonblocking() failed"); close(fd); return; } } connection_ctx_t* ctx = (connection_ctx_t*)malloc(sizeof(connection_ctx_t)); if(!ctx){ if(head_ctx->next == head_ctx) error("malloc() failed"); else{ error_no_exit("malloc() failed"); close(fd); return; } } // add ctx to the linked list ctx->prev = head_ctx; ctx->next = head_ctx->next; head_ctx->next->prev = ctx; head_ctx->next = ctx; ctx->base = head_ctx->base; ctx->read_event = NULL; ctx->write_event = NULL; ctx->read_buff_used = 0; ctx->write_buff_used = 0; printf("[%p] New connection! fd = %d\n", ctx, fd); ctx->fd = fd; ctx->write_event = event_new(ctx->base, fd, EV_WRITE | EV_PERSIST, on_write, (void*)ctx); if(!ctx->write_event){ if(head_ctx->next == head_ctx) error("event_new(... EV_WRITE ...) failed"); else{ error_no_exit("event_new(... EV_WRITE ...) failed"); on_close(ctx); return; } } if(event_priority_set(ctx->write_event, 1) < 0){ if(head_ctx->next == head_ctx) error("event_priority_set() failed"); else{ error_no_exit("event_priority_set() failed"); on_close(ctx); return; } } if(!gen_and_write_seq_event){ ctx->read_event = event_new(ctx->base, fd, EV_READ | EV_PERSIST, on_read, (void*)ctx); if(!ctx->read_event){ if(head_ctx->next == head_ctx) error("event_new(... EV_READ ...) failed"); else{ error_no_exit("event_new(... EV_READ ...) failed"); on_close(ctx); return; } } if(event_priority_set(ctx->read_event, 1) < 0){ if(head_ctx->next == head_ctx) error("event_priority_set() failed"); else{ error_no_exit("event_priority_set() failed"); on_close(ctx); return; } } if(event_add(ctx->read_event, NULL) < 0){ if(head_ctx->next == head_ctx) error("event_add(read_event, ...) failed"); else{ error_no_exit("event_add(read_event, ...) failed"); on_close(ctx); return; } } } } void run(char* host, int port){ // allocate memory for a connection ctx (used as linked list head) connection_ctx_t* head_ctx = (connection_ctx_t*)malloc(sizeof(connection_ctx_t)); if(!head_ctx) error("malloc() failed"); head_ctx->next = head_ctx; head_ctx->prev = head_ctx; head_ctx->write_event = NULL; head_ctx->read_buff_used = 0; head_ctx->write_buff_used = 0; // create a socket head_ctx->fd = socket(AF_INET, SOCK_STREAM, 0); if(head_ctx->fd < 0) error("socket() failed"); // make it nonblocking if(evutil_make_socket_nonblocking(head_ctx->fd) < 0) error("evutil_make_socket_nonblocking() failed"); // bind and listen struct sockaddr_in sin; sin.sin_family = AF_INET; sin.sin_port = htons(port); sin.sin_addr.s_addr = inet_addr(host); if(bind(head_ctx->fd, (struct sockaddr*)&sin, sizeof(sin)) < 0) error("bind() failed"); if(listen(head_ctx->fd, 1000) < 0) error("listen() failed"); // create an event base struct event_base* base = event_base_new(); if(!base) error("event_base_new() failed"); if(event_base_priority_init(base, 2) < 0) error("event_base_priority_init() failed"); // create a new event struct event* accept_event = event_new(base, head_ctx->fd, EV_READ | EV_PERSIST, on_accept, (void*)head_ctx); if(!accept_event) error("event_new() failed"); head_ctx->base = base; head_ctx->read_event = accept_event; if(event_priority_set(accept_event, 0) < 0) error("event_priority_set() failed"); // schedule the execution of accept_event if(event_add(accept_event, NULL) < 0) error("event_add() failed"); // run the event dispatching loop if(event_base_dispatch(base) < 0) error("event_base_dispatch() failed"); // free allocated resources on_close(head_ctx); event_free(accept_event); event_base_free(base); } /* * If client will close a connection send() will just return -1 * instead of killing a process with SIGPIPE. */ void ignore_sigpipe(){ /* sigset_t msk; if(sigemptyset(&msk) < 0) error("sigemptyset() failed"); if(sigaddset(&msk, SIGPIPE) < 0) error("sigaddset() failed"); */ sigset_t mask; sigset_t orig_mask; sigemptyset(&mask); sigaddset(&mask, SIGPIPE); if (sigprocmask(SIG_BLOCK, &mask, &orig_mask) < 0) { perror ("sigprocmask"); return; } // if(pthread_sigmask(SIG_BLOCK, &msk, nullptr) != 0) // error("pthread_sigmask() failed"); } int main(int argc, char** argv){ if(argc < 3) { printf("Usage: %s <host> <port>\n", argv[0]); exit(1); } char* host = argv[1]; int port = atoi(argv[2]); printf("Starting server on %s:%d\n", host, port); ignore_sigpipe(); run(host, port); if(gen_and_write_seq_event) event_free(gen_and_write_seq_event); return 0; }
the_stack_data/248581713.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): PRABAKARAN B. S., MRAZEK V., VASICEK Z., SEKANINA L., SHAFIQUE M. ApproxFPGAs: Embracing ASIC-based Approximate Arithmetic Components for FPGA-Based Systems. DAC 2020. ***/ // MAE% = 2.27 % // MAE = 1491 // WCE% = 9.32 % // WCE = 6109 // WCRE% = 366.41 % // EP% = 99.20 % // MRE% = 28.93 % // MSE = 35240.883e2 // FPGA_POWER = 0.33 // FPGA_DELAY = 7.7 // FPGA_LUT = 10 #include <stdint.h> #include <stdlib.h> uint64_t mul8u_17BE(const uint64_t B,const uint64_t A) { uint64_t O, dout_16, dout_153, dout_155, dout_163, dout_200, dout_207, dout_208, dout_236, dout_237, dout_241, dout_244, dout_251, dout_252, dout_253, dout_277, dout_281, dout_282, dout_283, dout_284, dout_285, dout_286, dout_287, dout_288, dout_289, dout_290, dout_295, dout_296, dout_297, dout_298, dout_321, dout_322, dout_323, dout_324, dout_325, dout_326, dout_327, dout_328, dout_329, dout_330, dout_331, dout_332, dout_333, dout_334, dout_335; int avg=0; dout_16=((B >> 7)&1)&((A >> 5)&1); dout_153=((A >> 6)&1)&((B >> 5)&1); dout_155=dout_16|dout_153; dout_163=((B >> 7)&1)&((A >> 4)&1); dout_200=dout_155|dout_163; dout_207=((B >> 3)&1)&((A >> 5)&1); dout_208=((B >> 7)&1)&((A >> 5)&1); dout_236=dout_163|((A >> 5)&1); dout_237=((A >> 4)&1)&((B >> 6)&1); dout_241=dout_200^dout_208; dout_244=dout_241|dout_237; dout_251=((B >> 5)&1)&((A >> 6)&1); dout_252=((B >> 6)&1)&((A >> 6)&1); dout_253=((B >> 7)&1)&((A >> 6)&1); dout_277=dout_236&dout_251; dout_281=dout_244^dout_252; dout_282=dout_244&dout_252; dout_283=dout_281&dout_277; dout_284=dout_281^dout_277; dout_285=dout_282|dout_283; dout_286=dout_208^dout_253; dout_287=((A >> 5)&1)&dout_253; dout_288=((B >> 7)&1)&dout_285; dout_289=dout_286^dout_285; dout_290=dout_287|dout_288; dout_295=((B >> 4)&1)&((A >> 7)&1); dout_296=((B >> 5)&1)&((A >> 7)&1); dout_297=((B >> 6)&1)&((A >> 7)&1); dout_298=((B >> 7)&1)&((A >> 7)&1); dout_321=dout_284^dout_296; dout_322=dout_284&dout_296; dout_323=dout_321&dout_295; dout_324=dout_321^dout_295; dout_325=dout_322|dout_323; dout_326=dout_289^dout_297; dout_327=dout_289&dout_297; dout_328=dout_326&dout_325; dout_329=dout_326^dout_325; dout_330=dout_327|dout_328; dout_331=dout_290^dout_298; dout_332=dout_290&((A >> 7)&1); dout_333=((B >> 7)&1)&dout_330; dout_334=dout_331^dout_330; dout_335=dout_332|dout_333; O = 0; O |= (dout_331&1) << 0; O |= (0&1) << 1; O |= (dout_329&1) << 2; O |= (dout_237&1) << 3; O |= (0&1) << 4; O |= (dout_237&1) << 5; O |= (0&1) << 6; O |= (dout_237&1) << 7; O |= (0&1) << 8; O |= (dout_237&1) << 9; O |= (dout_207&1) << 10; O |= (0&1) << 11; O |= (dout_324&1) << 12; O |= (dout_329&1) << 13; O |= (dout_334&1) << 14; O |= (dout_335&1) << 15; return O; }
the_stack_data/153268264.c
// Property: G(a => F r) #define NT_SUCCESS(s) s>0 #define STATUS_SUCCESS 1 #define STATUS_UNSUCCESSFUL 0 #define STATUS_TIMEOUT (-1) #define LARGE_INTEGER int #define NTSTATUS int #define UCHAR int #define PCHAR int #define BOOLEAN int #define ULONG int #define NULL 0 #define FALSE 0 #define TRUE 1 inline void ExAcquireFastMutex() {} inline void ExReleaseFastMutex() {} inline int nondet() { int x; return x; } #define GetStatus nondet #define IoInvalidateDeviceRelations nondet #define KeWaitForSingleObject nondet #define P4ReadRawIeee1284DeviceId nondet #define HTPnpFindDeviceIdKeys nondet #define HtFreePort nondet #define HtRegGetDword nondet #define HtTryAllocatePort nondet #define SetFlags nondet int WarmPollPeriod; int status; int polling; int PowerStateIsAC; inline void init() { WarmPollPeriod = nondet(); status = nondet(); polling = nondet(); PowerStateIsAC = nondet(); } inline int body() { if( NT_SUCCESS( status ) ) { ExAcquireFastMutex(); SetFlags(); ExReleaseFastMutex(); WarmPollPeriod = HtRegGetDword(); if( WarmPollPeriod < 5 ) { WarmPollPeriod = 5; } else { if( WarmPollPeriod > 20 ) { WarmPollPeriod = 20; } } { if (nondet()) { // We've got it. Now get a pointer to it. polling = 1; if(nondet()) { //--------------------------------------------- { LARGE_INTEGER timeOut1; NTSTATUS status; UCHAR deviceStatus; PCHAR devId; BOOLEAN requestRescan; const ULONG pollingFailureThreshold = 10; //pick an arbitrary but reasonable number do { if( PowerStateIsAC ) { } else { } status = KeWaitForSingleObject(); if( nondet() ) { break; } if( !PowerStateIsAC ) { if(nondet()) polling = 0; goto loc_continue; } if( STATUS_TIMEOUT == status ) { if( nondet() ) { // try to acquire port if( HtTryAllocatePort() ) { requestRescan = FALSE; // check for something connected deviceStatus = GetStatus(); if( nondet()) { } else { // we might have something connected // try a device ID to confirm devId = P4ReadRawIeee1284DeviceId(); if( devId ) { PCHAR mfg, mdl, cls, des, aid, cid; // RawIeee1284 string includes 2 bytes of length data at beginning HTPnpFindDeviceIdKeys(); if( mfg && mdl ) { requestRescan = TRUE; } } else { } if( requestRescan ) { } else { if(nondet() ) { } } } HtFreePort( ); if( requestRescan ) { IoInvalidateDeviceRelations(); } } else { } } else { } } loc_continue: { int ddd; ddd = ddd; } } while( TRUE ); } //--------------------------------------------- polling = 0; } else { polling = 0; // error } } else { } } } // Failsafe polling = 1; while (1) { HTPnpFindDeviceIdKeys(); } } int main() { init(); body(); }
the_stack_data/61074868.c
#include<stdio.h> #include<math.h> int main(void){ int base,exp; scanf("%d%d",&base,&exp); int res = pow(base,exp); printf("\n%d",res); return 0; }
the_stack_data/31387296.c
// RUN: %clang_cc1 -fms-extensions -triple i686-pc-windows-msvc -Wcast-calling-convention -DMSVC -Wno-pointer-bool-conversion -verify -x c %s // RUN: %clang_cc1 -fms-extensions -triple i686-pc-windows-msvc -Wcast-calling-convention -DMSVC -Wno-pointer-bool-conversion -verify -x c++ %s // RUN: %clang_cc1 -fms-extensions -triple i686-pc-windows-msvc -Wcast-calling-convention -DMSVC -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s --check-prefix=MSFIXIT // RUN: %clang_cc1 -triple i686-pc-windows-gnu -Wcast-calling-convention -fdiagnostics-parseable-fixits %s 2>&1 | FileCheck %s --check-prefix=GNUFIXIT // expected-note@+1 {{consider defining 'mismatched_before_winapi' with the 'stdcall' calling convention}} void mismatched_before_winapi(int x) {} #ifdef MSVC #define WINAPI __stdcall #else #define WINAPI __attribute__((stdcall)) #endif // expected-note@+1 3 {{consider defining 'mismatched' with the 'stdcall' calling convention}} void mismatched(int x) {} // expected-note@+1 {{consider defining 'mismatched_declaration' with the 'stdcall' calling convention}} void mismatched_declaration(int x); // expected-note@+1 {{consider defining 'suggest_fix_first_redecl' with the 'stdcall' calling convention}} void suggest_fix_first_redecl(int x); void suggest_fix_first_redecl(int x); typedef void (WINAPI *callback_t)(int); void take_callback(callback_t callback); void WINAPI mismatched_stdcall(int x) {} void take_opaque_fn(void (*callback)(int)); int main() { // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} take_callback((callback_t)mismatched); // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} callback_t callback = (callback_t)mismatched; // warns (void)callback; // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} callback = (callback_t)&mismatched; // warns // No warning, just to show we don't drill through other kinds of unary operators. callback = (callback_t)!mismatched; // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} callback = (callback_t)&mismatched_before_winapi; // warns // Probably a bug, but we don't warn. void (*callback2)(int) = mismatched; take_callback((callback_t)callback2); // Another way to suppress the warning. take_callback((callback_t)(void*)mismatched); // Warn on declarations as well as definitions. // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} take_callback((callback_t)mismatched_declaration); // expected-warning@+1 {{cast between incompatible calling conventions 'cdecl' and 'stdcall'}} take_callback((callback_t)suggest_fix_first_redecl); // Don't warn, because we're casting from stdcall to cdecl. Usually that means // the programmer is rinsing the function pointer through some kind of opaque // API. take_opaque_fn((void (*)(int))mismatched_stdcall); } // MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI " // MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI " // MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI " // MSFIXIT: fix-it:"{{.*}}callingconv-cast.c":{7:6-7:6}:"__stdcall " // GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI " // GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI " // GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{16:6-16:6}:"WINAPI " // GNUFIXIT: fix-it:"{{.*}}callingconv-cast.c":{7:6-7:6}:"__attribute__((stdcall)) "
the_stack_data/40762260.c
/************************************************************************* > File Name: ls.c > Author:AnSwEr > Mail: > Created Time: Tue 26 Apr 2016 02:44:08 PM CST ************************************************************************/ #include<stdio.h> #include<sys/types.h> #include<dirent.h> void list(char *dir) { DIR *dir_ptr; struct dirent *direntp; dir_ptr = opendir(dir); if(dir_ptr == NULL) fprintf(stderr,"Error:open %s failed!\n",dir); else { while((direntp = readdir(dir_ptr)) != NULL) printf("%s\n",direntp->d_name); closedir(dir_ptr); } } int main(int argc,char *argv[]) { if(argc > 10) { fprintf(stderr,"Error:your argc=%d out of limit(10)\n",argc); return; } if(argc == 1) // just ls { list("."); return 0; } while(--argc) // list all *argvs { printf("%s:\n",*++argv); list(*argv); printf("\n"); } return 0; }
the_stack_data/130719.c
int main() { int I; #pragma sapfor analysis dependency(<I,4>) explicitaccess(<I,4>) for (I = 0; I < 10; ++I); return 0; }
the_stack_data/7949655.c
// Find shortest unique prefix to represent each word. // start time 21:47 // need time 44 minutes // end time is 23:04 // real time is 1:20, 80 minutes. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct Node Node; struct Node { char c; int users; Node **childs; int size; int capability; }; Node *getNode(char c) { Node *node = malloc(sizeof(Node)); node->c = c; node->users = 1; node->childs = malloc(sizeof(void *) * 8); node->size = 0; node->capability = 8; return node; } void releaseNode(Node *node) { if (node) { for(int i = 0; i < node->size; i++) { releaseNode(node->childs[i]); } node->c = 0; node->users = 0; node->size = 0; free(node->childs); node->capability = 0; free(node); } } Node *getNullRoot() { return getNode(0); } Node *nodeRealloc(Node *node) { if (node->size + 1 >= node->capability) { node->capability *= 2; node->childs = realloc(node->childs, node->capability * sizeof(void *)); } return node; } Node *insertChar(Node* node, char c) { for(int i = 0; i < node->size; i++) { if (node->childs[i]->c == c) { node->childs[i]->users++; // printf("%c child is in\n", c); return node->childs[i]; } } Node *newnode = getNode(c); nodeRealloc(node); node->childs[node->size++] = newnode; // printf("%c get new child\n", c); return newnode; } void insertString(Node *node, const char *s) { Node *cnode = node; while(*s) { cnode = insertChar(cnode, *s); // printf("%c %d ", *s, cnode->size); s += 1; } } Node *findOnlyone(Node *node, int num) { for (int i = 0; i < node->size; i++) { if (node->childs[i]->users == num) return node->childs[i]; } return NULL; } void transfer(Node *node) { printf("%c %d %d\n", node->c, node->size, node->users); for(int i = 0; i < node->size; i++) { transfer(node->childs[i]); } } int find_shortest_unique_prefix(const char *strings[], int num, char **prefix) { Node *node = getNullRoot(); int max_len = 1; for (int i = 0; i < num; i++) { const char *s = strings[i]; if (max_len < strlen(s)) { max_len = strlen(s); } insertString(node, s); printf("%d:[%s]\n", i, s); } char *cp = malloc(max_len); memset(cp, 0, max_len); int index = 0; Node *n = findOnlyone(node, num); // transfer(node); while(n) { cp[index++] = n->c; n = findOnlyone(n, num); } printf("unique prefix:"); printf("[%s]\n", cp); releaseNode(node); free(cp); } int main() { const char *strings[] = {"hello", "he", "hell", NULL}; find_shortest_unique_prefix(strings, 3, NULL); const char *strings2[] = {"hello", "he", "hell", "world", NULL}; find_shortest_unique_prefix(strings2, 4, NULL); const char *strings3[] = {"hello", "he", "hell", "heaaa", NULL}; find_shortest_unique_prefix(strings3, 4, NULL); }
the_stack_data/150143782.c
/* Code Written By Om Chetwani Date of Submission:16/02/2021 */ #include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <stdlib.h> #include <signal.h> void menu(void); int main(int argc, char *argv[]) { int n; do { menu(); scanf("%d", &n); switch (n) { case 1:; //fork pid_t pid; pid =fork(); if (pid>0) printf("\nParent Created with pid: %d",getpid()); else printf("\nChild Created with pid: %d",getpid()); break; case 2:; //exec printf("PID of this code = %d\n", getpid()); char *args[] = {"Hello", "C", "Programming", NULL}; execv("./t2", args); break; case 3://exit exit(0); break; case 4://wait if (fork()== 0) printf("Hello from Child \n"); else { printf("Hello from parent\n"); wait(NULL); printf("Child has terminated\n"); } break; case 5:;// kill pid_t p=fork(); pid_t id=getpid(); if (p>0) { printf("process started with pid:%d\n",id); } kill(id,SIGKILL); break; } } while (n != 6); } void menu() { printf("\n\n-----------------------------------------"); printf("\n Demonstration of Different System Calls"); printf("\n-----------------------------------------\n"); printf("\n1) Fork"); printf("\n2) exec"); printf("\n3) exit"); printf("\n4) wait"); printf("\n5) kill"); printf("\n6) Exit"); printf("\nEnter your choice :"); }
the_stack_data/212643785.c
# 1 "kernel/rhino/core/k_mm_blk.c" # 1 "/home/stone/Documents/Ali_IOT//" # 1 "<built-in>" # 1 "<command-line>" # 1 "kernel/rhino/core/k_mm_blk.c" # 1 "./kernel/rhino/core/include/k_api.h" 1 # 12 "./kernel/rhino/core/include/k_api.h" # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4 # 149 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4 # 149 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4 typedef int ptrdiff_t; # 216 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4 typedef unsigned int size_t; # 328 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4 typedef unsigned int wchar_t; # 426 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4 typedef struct { long long __max_align_ll __attribute__((__aligned__(__alignof__(long long)))); long double __max_align_ld __attribute__((__aligned__(__alignof__(long double)))); } max_align_t; # 13 "./kernel/rhino/core/include/k_api.h" 2 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdint.h" 1 3 4 # 9 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdint.h" 3 4 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 1 3 4 # 12 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 1 3 4 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/features.h" 1 3 4 # 28 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/features.h" 3 4 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_newlib_version.h" 1 3 4 # 29 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/features.h" 2 3 4 # 9 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 2 3 4 # 27 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef signed char __int8_t; typedef unsigned char __uint8_t; # 41 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef short int __int16_t; typedef short unsigned int __uint16_t; # 63 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef long int __int32_t; typedef long unsigned int __uint32_t; # 89 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef long long int __int64_t; typedef long long unsigned int __uint64_t; # 120 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef signed char __int_least8_t; typedef unsigned char __uint_least8_t; # 146 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef short int __int_least16_t; typedef short unsigned int __uint_least16_t; # 168 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef long int __int_least32_t; typedef long unsigned int __uint_least32_t; # 186 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef long long int __int_least64_t; typedef long long unsigned int __uint_least64_t; # 200 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_default_types.h" 3 4 typedef int __intptr_t; typedef unsigned int __uintptr_t; # 13 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 2 3 4 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_intsup.h" 1 3 4 # 49 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_intsup.h" 3 4 # 201 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_intsup.h" 3 4 # 14 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 2 3 4 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_stdint.h" 1 3 4 # 20 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_stdint.h" 3 4 typedef __int8_t int8_t ; typedef __uint8_t uint8_t ; typedef __int16_t int16_t ; typedef __uint16_t uint16_t ; typedef __int32_t int32_t ; typedef __uint32_t uint32_t ; typedef __int64_t int64_t ; typedef __uint64_t uint64_t ; typedef __intptr_t intptr_t; typedef __uintptr_t uintptr_t; # 15 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 2 3 4 typedef __int_least8_t int_least8_t; typedef __uint_least8_t uint_least8_t; typedef __int_least16_t int_least16_t; typedef __uint_least16_t uint_least16_t; typedef __int_least32_t int_least32_t; typedef __uint_least32_t uint_least32_t; typedef __int_least64_t int_least64_t; typedef __uint_least64_t uint_least64_t; # 51 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 typedef int int_fast8_t; typedef unsigned int uint_fast8_t; # 61 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 typedef int int_fast16_t; typedef unsigned int uint_fast16_t; # 71 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 typedef int int_fast32_t; typedef unsigned int uint_fast32_t; # 81 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 typedef long long int int_fast64_t; typedef long long unsigned int uint_fast64_t; # 130 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 typedef long long int intmax_t; # 139 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/stdint.h" 3 4 typedef long long unsigned int uintmax_t; # 10 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stdint.h" 2 3 4 # 14 "./kernel/rhino/core/include/k_api.h" 2 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 1 3 # 10 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 1 3 # 15 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/newlib.h" 1 3 # 16 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/config.h" 1 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/ieeefp.h" 1 3 # 5 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/config.h" 2 3 # 17 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 2 3 # 11 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 1 3 # 13 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/_ansi.h" 1 3 # 14 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4 # 15 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 1 3 # 24 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/machine/_types.h" 1 3 # 25 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/lock.h" 1 3 typedef int _LOCK_T; typedef int _LOCK_RECURSIVE_T; # 26 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 2 3 typedef long __blkcnt_t; typedef long __blksize_t; typedef __uint64_t __fsblkcnt_t; typedef __uint32_t __fsfilcnt_t; typedef long _off_t; typedef int __pid_t; typedef short __dev_t; typedef unsigned short __uid_t; typedef unsigned short __gid_t; typedef __uint32_t __id_t; typedef unsigned short __ino_t; # 88 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3 typedef __uint32_t __mode_t; __extension__ typedef long long _off64_t; typedef _off_t __off_t; typedef _off64_t __loff_t; typedef long __key_t; typedef long _fpos_t; # 129 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3 typedef unsigned int __size_t; # 145 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3 typedef signed int _ssize_t; # 156 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 3 typedef _ssize_t __ssize_t; # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4 # 357 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 3 4 typedef unsigned int wint_t; # 160 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_types.h" 2 3 typedef struct { int __count; union { wint_t __wch; unsigned char __wchb[4]; } __value; } _mbstate_t; typedef _LOCK_RECURSIVE_T _flock_t; typedef void *_iconv_t; typedef unsigned long __clock_t; typedef long __time_t; typedef unsigned long __clockid_t; typedef unsigned long __timer_t; typedef __uint8_t __sa_family_t; typedef __uint32_t __socklen_t; typedef unsigned short __nlink_t; typedef long __suseconds_t; typedef unsigned long __useconds_t; typedef char * __va_list; # 16 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 2 3 typedef unsigned long __ULong; # 38 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 struct _reent; struct __locale_t; struct _Bigint { struct _Bigint *_next; int _k, _maxwds, _sign, _wds; __ULong _x[1]; }; struct __tm { int __tm_sec; int __tm_min; int __tm_hour; int __tm_mday; int __tm_mon; int __tm_year; int __tm_wday; int __tm_yday; int __tm_isdst; }; struct _on_exit_args { void * _fnargs[32]; void * _dso_handle[32]; __ULong _fntypes; __ULong _is_cxa; }; # 93 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 struct _atexit { struct _atexit *_next; int _ind; void (*_fns[32])(void); struct _on_exit_args _on_exit_args; }; # 117 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 struct __sbuf { unsigned char *_base; int _size; }; # 181 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 struct __sFILE { unsigned char *_p; int _r; int _w; short _flags; short _file; struct __sbuf _bf; int _lbfsize; void * _cookie; int (* _read) (struct _reent *, void *, char *, int) ; int (* _write) (struct _reent *, void *, const char *, int) ; _fpos_t (* _seek) (struct _reent *, void *, _fpos_t, int); int (* _close) (struct _reent *, void *); struct __sbuf _ub; unsigned char *_up; int _ur; unsigned char _ubuf[3]; unsigned char _nbuf[1]; struct __sbuf _lb; int _blksize; _off_t _offset; struct _reent *_data; _flock_t _lock; _mbstate_t _mbstate; int _flags2; }; # 287 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 typedef struct __sFILE __FILE; struct _glue { struct _glue *_next; int _niobs; __FILE *_iobs; }; # 319 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 struct _rand48 { unsigned short _seed[3]; unsigned short _mult[3]; unsigned short _add; }; # 569 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 struct _reent { int _errno; __FILE *_stdin, *_stdout, *_stderr; int _inc; char _emergency[25]; int _unspecified_locale_info; struct __locale_t *_locale; int __sdidinit; void (* __cleanup) (struct _reent *); struct _Bigint *_result; int _result_k; struct _Bigint *_p5s; struct _Bigint **_freelist; int _cvtlen; char *_cvtbuf; union { struct { unsigned int _unused_rand; char * _strtok_last; char _asctime_buf[26]; struct __tm _localtime_buf; int _gamma_signgam; __extension__ unsigned long long _rand_next; struct _rand48 _r48; _mbstate_t _mblen_state; _mbstate_t _mbtowc_state; _mbstate_t _wctomb_state; char _l64a_buf[8]; char _signal_buf[24]; int _getdate_err; _mbstate_t _mbrlen_state; _mbstate_t _mbrtowc_state; _mbstate_t _mbsrtowcs_state; _mbstate_t _wcrtomb_state; _mbstate_t _wcsrtombs_state; int _h_errno; } _reent; struct { unsigned char * _nextf[30]; unsigned int _nmalloc[30]; } _unused; } _new; struct _atexit *_atexit; struct _atexit _atexit0; void (**(_sig_func))(int); struct _glue __sglue; __FILE __sf[3]; }; # 766 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/reent.h" 3 extern struct _reent *_impure_ptr ; extern struct _reent *const _global_impure_ptr ; void _reclaim_reent (struct _reent *); # 12 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 1 3 # 45 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4 # 46 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/cdefs.h" 2 3 # 13 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/lib/gcc/arm-none-eabi/5.4.1/include/stddef.h" 1 3 4 # 18 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_locale.h" 1 3 # 9 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/_locale.h" 3 struct __locale_t; typedef struct __locale_t *locale_t; # 21 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3 void * memchr (const void *, int, size_t); int memcmp (const void *, const void *, size_t); void * memcpy (void * restrict, const void * restrict, size_t); void * memmove (void *, const void *, size_t); void * memset (void *, int, size_t); char *strcat (char *restrict, const char *restrict); char *strchr (const char *, int); int strcmp (const char *, const char *); int strcoll (const char *, const char *); char *strcpy (char *restrict, const char *restrict); size_t strcspn (const char *, const char *); char *strerror (int); size_t strlen (const char *); char *strncat (char *restrict, const char *restrict, size_t); int strncmp (const char *, const char *, size_t); char *strncpy (char *restrict, const char *restrict, size_t); char *strpbrk (const char *, const char *); char *strrchr (const char *, int); size_t strspn (const char *, const char *); char *strstr (const char *, const char *); char *strtok (char *restrict, const char *restrict); size_t strxfrm (char *restrict, const char *restrict, size_t); int strcoll_l (const char *, const char *, locale_t); char *strerror_l (int, locale_t); size_t strxfrm_l (char *restrict, const char *restrict, size_t, locale_t); char *strtok_r (char *restrict, const char *restrict, char **restrict); int bcmp (const void *, const void *, size_t); void bcopy (const void *, void *, size_t); void bzero (void *, size_t); void explicit_bzero (void *, size_t); int timingsafe_bcmp (const void *, const void *, size_t); int timingsafe_memcmp (const void *, const void *, size_t); int ffs (int); char *index (const char *, int); void * memccpy (void * restrict, const void * restrict, int, size_t); # 86 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3 char *rindex (const char *, int); char *stpcpy (char *restrict, const char *restrict); char *stpncpy (char *restrict, const char *restrict, size_t); int strcasecmp (const char *, const char *); char *strdup (const char *); char *_strdup_r (struct _reent *, const char *); char *strndup (const char *, size_t); char *_strndup_r (struct _reent *, const char *, size_t); # 121 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3 int strerror_r (int, char *, size_t) __asm__ ("" "__xpg_strerror_r") ; char * _strerror_r (struct _reent *, int, int, int *); size_t strlcat (char *, const char *, size_t); size_t strlcpy (char *, const char *, size_t); int strncasecmp (const char *, const char *, size_t); size_t strnlen (const char *, size_t); char *strsep (char **, const char *); char *strlwr (char *); char *strupr (char *); char *strsignal (int __signo); # 192 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 3 # 1 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/sys/string.h" 1 3 # 193 "/home/stone/Documents/Ali_IOT/build/compiler/gcc-arm-none-eabi/Linux64/arm-none-eabi/include/string.h" 2 3 # 15 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./board/mk3060/./k_config.h" 1 # 16 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_default_config.h" 1 # 17 "./kernel/rhino/core/include/k_api.h" 2 # 1 "././platform/arch/arm/armv5/./gcc/k_types.h" 1 # 14 "././platform/arch/arm/armv5/./gcc/k_types.h" # 14 "././platform/arch/arm/armv5/./gcc/k_types.h" typedef char name_t; typedef uint32_t sem_count_t; typedef uint32_t cpu_stack_t; typedef uint32_t hr_timer_t; typedef uint32_t lr_timer_t; typedef uint32_t mutex_nested_t; typedef uint8_t suspend_nested_t; typedef uint64_t ctx_switch_t; typedef uint32_t cpu_cpsr_t; # 18 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_err.h" 1 typedef enum { RHINO_SUCCESS = 0u, RHINO_SYS_FATAL_ERR, RHINO_SYS_SP_ERR, RHINO_RUNNING, RHINO_STOPPED, RHINO_INV_PARAM, RHINO_NULL_PTR, RHINO_INV_ALIGN, RHINO_KOBJ_TYPE_ERR, RHINO_KOBJ_DEL_ERR, RHINO_KOBJ_DOCKER_EXIST, RHINO_KOBJ_BLK, RHINO_KOBJ_SET_FULL, RHINO_NOTIFY_FUNC_EXIST, RHINO_MM_POOL_SIZE_ERR = 100u, RHINO_MM_ALLOC_SIZE_ERR, RHINO_MM_FREE_ADDR_ERR, RHINO_MM_CORRUPT_ERR, RHINO_DYN_MEM_PROC_ERR, RHINO_NO_MEM, RHINO_RINGBUF_FULL, RHINO_RINGBUF_EMPTY, RHINO_SCHED_DISABLE = 200u, RHINO_SCHED_ALREADY_ENABLED, RHINO_SCHED_LOCK_COUNT_OVF, RHINO_INV_SCHED_WAY, RHINO_TASK_INV_STACK_SIZE = 300u, RHINO_TASK_NOT_SUSPENDED, RHINO_TASK_DEL_NOT_ALLOWED, RHINO_TASK_SUSPEND_NOT_ALLOWED, RHINO_SUSPENDED_COUNT_OVF, RHINO_BEYOND_MAX_PRI, RHINO_PRI_CHG_NOT_ALLOWED, RHINO_INV_TASK_STATE, RHINO_IDLE_TASK_EXIST, RHINO_NO_PEND_WAIT = 400u, RHINO_BLK_ABORT, RHINO_BLK_TIMEOUT, RHINO_BLK_DEL, RHINO_BLK_INV_STATE, RHINO_BLK_POOL_SIZE_ERR, RHINO_TIMER_STATE_INV = 500u, RHINO_NO_THIS_EVENT_OPT = 600u, RHINO_BUF_QUEUE_INV_SIZE = 700u, RHINO_BUF_QUEUE_SIZE_ZERO, RHINO_BUF_QUEUE_FULL, RHINO_BUF_QUEUE_MSG_SIZE_OVERFLOW, RHINO_QUEUE_FULL, RHINO_QUEUE_NOT_FULL, RHINO_SEM_OVF = 800u, RHINO_SEM_TASK_WAITING, RHINO_MUTEX_NOT_RELEASED_BY_OWNER = 900u, RHINO_MUTEX_OWNER_NESTED, RHINO_MUTEX_NESTED_OVF, RHINO_NOT_CALLED_BY_INTRPT = 1000u, RHINO_TRY_AGAIN, RHINO_WORKQUEUE_EXIST = 1100u, RHINO_WORKQUEUE_NOT_EXIST, RHINO_WORKQUEUE_WORK_EXIST, RHINO_WORKQUEUE_BUSY, RHINO_WORKQUEUE_WORK_RUNNING, RHINO_TASK_STACK_OVF = 1200u, RHINO_INTRPT_STACK_OVF } kstat_t; typedef void (*krhino_err_proc_t)(kstat_t err); extern krhino_err_proc_t g_err_proc; # 19 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_critical.h" 1 # 20 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_spin_lock.h" 1 typedef struct { cpu_cpsr_t cpsr; } kspinlock_t; # 21 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_sys.h" 1 # 18 "./kernel/rhino/core/include/k_sys.h" typedef uint64_t sys_time_t; typedef int64_t sys_time_i_t; typedef uint64_t idle_count_t; typedef uint64_t tick_t; typedef int64_t tick_i_t; # 36 "./kernel/rhino/core/include/k_sys.h" kstat_t krhino_init(void); kstat_t krhino_start(void); kstat_t krhino_intrpt_enter(void); void krhino_intrpt_exit(void); void krhino_intrpt_stack_ovf_check(void); tick_t krhino_next_sleep_ticks_get(void); size_t krhino_global_space_get(void); uint32_t krhino_version_get(void); # 22 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_bitmap.h" 1 # 33 "./kernel/rhino/core/include/k_bitmap.h" static inline void krhino_bitmap_set(uint32_t *bitmap, int32_t nr) { bitmap[((nr) >> 5U)] |= (1UL << (32U - 1U - ((nr) & 0X0000001F))); } static inline void krhino_bitmap_clear(uint32_t *bitmap, int32_t nr) { bitmap[((nr) >> 5U)] &= ~(1UL << (32U - 1U - ((nr) & 0X0000001F))); } static inline uint8_t krhino_clz32(uint32_t x) { uint8_t n = 0; if (x == 0) { return 32; } if ((x & 0XFFFF0000) == 0) { x <<= 16; n += 16; } if ((x & 0XFF000000) == 0) { x <<= 8; n += 8; } if ((x & 0XF0000000) == 0) { x <<= 4; n += 4; } if ((x & 0XC0000000) == 0) { x <<= 2; n += 2; } if ((x & 0X80000000) == 0) { n += 1; } return n; } static inline uint8_t krhino_ctz32(uint32_t x) { uint8_t n = 0; if (x == 0) { return 32; } if ((x & 0X0000FFFF) == 0) { x >>= 16; n += 16; } if ((x & 0X000000FF) == 0) { x >>= 8; n += 8; } if ((x & 0X0000000F) == 0) { x >>= 4; n += 4; } if ((x & 0X00000003) == 0) { x >>= 2; n += 2; } if ((x & 0X00000001) == 0) { n += 1; } return n; } static inline int32_t krhino_find_first_bit(uint32_t *bitmap) { int32_t nr = 0; uint32_t tmp = 0; while (*bitmap == 0UL) { nr += 32U; bitmap++; } tmp = *bitmap; if (!(tmp & 0XFFFF0000)) { tmp <<= 16; nr += 16; } if (!(tmp & 0XFF000000)) { tmp <<= 8; nr += 8; } if (!(tmp & 0XF0000000)) { tmp <<= 4; nr += 4; } if (!(tmp & 0XC0000000)) { tmp <<= 2; nr += 2; } if (!(tmp & 0X80000000)) { nr += 1; } return nr; } # 23 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_list.h" 1 typedef struct klist_s { struct klist_s *next; struct klist_s *prev; } klist_t; static inline void klist_init(klist_t *list_head) { list_head->next = list_head; list_head->prev = list_head; } static inline uint8_t is_klist_empty(klist_t *list) { return (list->next == list); } static inline void klist_insert(klist_t *head, klist_t *element) { element->prev = head->prev; element->next = head; head->prev->next = element; head->prev = element; } static inline void klist_add(klist_t *head, klist_t *element) { element->prev = head; element->next = head->next; head->next->prev = element; head->next = element; } static inline void klist_rm(klist_t *element) { element->prev->next = element->next; element->next->prev = element->prev; } static inline void klist_rm_init(klist_t *element) { element->prev->next = element->next; element->next->prev = element->prev; element->next = element->prev = element; } # 24 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_obj.h" 1 typedef enum { BLK_POLICY_PRI = 0u, BLK_POLICY_FIFO } blk_policy_t; typedef enum { BLK_FINISH = 0, BLK_ABORT, BLK_TIMEOUT, BLK_DEL, BLK_INVALID } blk_state_t; typedef enum { RHINO_OBJ_TYPE_NONE = 0, RHINO_SEM_OBJ_TYPE, RHINO_MUTEX_OBJ_TYPE, RHINO_QUEUE_OBJ_TYPE, RHINO_BUF_QUEUE_OBJ_TYPE, RHINO_TIMER_OBJ_TYPE, RHINO_EVENT_OBJ_TYPE, RHINO_MM_OBJ_TYPE } kobj_type_t; typedef struct blk_obj { klist_t blk_list; const name_t *name; blk_policy_t blk_policy; kobj_type_t obj_type; } blk_obj_t; typedef struct { klist_t task_head; klist_t mutex_head; klist_t mblkpool_head; klist_t sem_head; klist_t queue_head; klist_t event_head; klist_t buf_queue_head; } kobj_list_t; # 25 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_sched.h" 1 # 13 "./kernel/rhino/core/include/k_sched.h" typedef struct { klist_t *cur_list_item[62]; uint32_t task_bit_map[((62 + 31) / 32)]; uint8_t highest_pri; } runqueue_t; kstat_t krhino_sched_disable(void); kstat_t krhino_sched_enable(void); # 26 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_task.h" 1 typedef enum { K_SEED, K_RDY, K_PEND, K_SUSPENDED, K_PEND_SUSPENDED, K_SLEEP, K_SLEEP_SUSPENDED, K_DELETED, } task_stat_t; typedef struct { void *task_stack; const name_t *task_name; void *user_info[2]; cpu_stack_t *task_stack_base; uint32_t stack_size; klist_t task_list; suspend_nested_t suspend_count; struct mutex_s *mutex_list; klist_t task_stats_item; klist_t tick_list; tick_t tick_match; tick_t tick_remain; klist_t *tick_head; void *msg; size_t bq_msg_size; task_stat_t task_state; blk_state_t blk_state; blk_obj_t *blk_obj; struct sem_s *task_sem_obj; # 86 "./kernel/rhino/core/include/k_task.h" uint32_t time_slice; uint32_t time_total; uint32_t pend_flags; void *pend_info; uint8_t pend_option; uint8_t sched_policy; uint8_t cpu_num; uint8_t prio; uint8_t b_prio; uint8_t mm_alloc_flag; } ktask_t; typedef void (*task_entry_t)(void *arg); # 129 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_create(ktask_t *task, const name_t *name, void *arg, uint8_t prio, tick_t ticks, cpu_stack_t *stack_buf, size_t stack_size, task_entry_t entry, uint8_t autorun); # 157 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_dyn_create(ktask_t **task, const name_t *name, void *arg, uint8_t pri, tick_t ticks, size_t stack, task_entry_t entry, uint8_t autorun); # 175 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_del(ktask_t *task); kstat_t krhino_task_dyn_del(ktask_t *task); # 192 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_sleep(tick_t dly); kstat_t krhino_task_yield(void); ktask_t *krhino_cur_task_get(void); kstat_t krhino_task_suspend(ktask_t *task); kstat_t krhino_task_resume(ktask_t *task); # 228 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_stack_min_free(ktask_t *task, size_t *free); # 237 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_stack_cur_free(ktask_t *task, size_t *free); # 246 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_pri_change(ktask_t *task, uint8_t pri, uint8_t *old_pri); kstat_t krhino_task_wait_abort(ktask_t *task); # 264 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_time_slice_set(ktask_t *task, size_t slice); kstat_t krhino_sched_policy_set(ktask_t *task, uint8_t policy); kstat_t krhino_sched_policy_get(ktask_t *task, uint8_t *policy); # 290 "./kernel/rhino/core/include/k_task.h" kstat_t krhino_task_info_set(ktask_t *task, size_t idx, void *info); kstat_t krhino_task_info_get(ktask_t *task, size_t idx, void **info); void krhino_task_deathbed(void); # 27 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_ringbuf.h" 1 # 33 "./kernel/rhino/core/include/k_ringbuf.h" typedef struct { uint8_t *buf; uint8_t *end; uint8_t *head; uint8_t *tail; size_t freesize; size_t type; size_t blk_size; } k_ringbuf_t; # 28 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_queue.h" 1 # 11 "./kernel/rhino/core/include/k_queue.h" typedef struct { void **queue_start; size_t size; size_t cur_num; size_t peak_num; } msg_q_t; typedef struct { msg_q_t msg_q; klist_t *pend_entry; } msg_info_t; typedef struct queue_s { blk_obj_t blk_obj; k_ringbuf_t ringbuf; msg_q_t msg_q; klist_t queue_item; uint8_t mm_alloc_flag; } kqueue_t; # 41 "./kernel/rhino/core/include/k_queue.h" kstat_t krhino_queue_create(kqueue_t *queue, const name_t *name, void **start, size_t msg_num); kstat_t krhino_queue_del(kqueue_t *queue); # 59 "./kernel/rhino/core/include/k_queue.h" kstat_t krhino_queue_dyn_create(kqueue_t **queue, const name_t *name, size_t msg_num); kstat_t krhino_queue_dyn_del(kqueue_t *queue); # 76 "./kernel/rhino/core/include/k_queue.h" kstat_t krhino_queue_back_send(kqueue_t *queue, void *msg); kstat_t krhino_queue_all_send(kqueue_t *queue, void *msg); # 93 "./kernel/rhino/core/include/k_queue.h" kstat_t krhino_queue_recv(kqueue_t *queue, tick_t ticks, void **msg); kstat_t krhino_queue_is_full(kqueue_t *queue); kstat_t krhino_queue_flush(kqueue_t *queue); kstat_t krhino_queue_info_get(kqueue_t *queue, msg_info_t *info); # 29 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_buf_queue.h" 1 typedef struct { blk_obj_t blk_obj; void *buf; k_ringbuf_t ringbuf; size_t max_msg_size; size_t cur_num; size_t peak_num; size_t min_free_buf_size; klist_t buf_queue_item; uint8_t mm_alloc_flag; } kbuf_queue_t; typedef struct { size_t buf_size; size_t max_msg_size; size_t cur_num; size_t peak_num; size_t free_buf_size; size_t min_free_buf_size; } kbuf_queue_info_t; # 40 "./kernel/rhino/core/include/k_buf_queue.h" kstat_t krhino_buf_queue_create(kbuf_queue_t *queue, const name_t *name, void *buf, size_t size, size_t max_msg); # 53 "./kernel/rhino/core/include/k_buf_queue.h" kstat_t krhino_fix_buf_queue_create(kbuf_queue_t *queue, const name_t *name, void *buf, size_t msg_size, size_t msg_num); kstat_t krhino_buf_queue_del(kbuf_queue_t *queue); # 72 "./kernel/rhino/core/include/k_buf_queue.h" kstat_t krhino_buf_queue_dyn_create(kbuf_queue_t **queue, const name_t *name, size_t size, size_t max_msg); kstat_t krhino_buf_queue_dyn_del(kbuf_queue_t *queue); # 90 "./kernel/rhino/core/include/k_buf_queue.h" kstat_t krhino_buf_queue_send(kbuf_queue_t *queue, void *msg, size_t size); # 101 "./kernel/rhino/core/include/k_buf_queue.h" kstat_t krhino_buf_queue_recv(kbuf_queue_t *queue, tick_t ticks, void *msg, size_t *size); kstat_t krhino_buf_queue_flush(kbuf_queue_t *queue); # 118 "./kernel/rhino/core/include/k_buf_queue.h" kstat_t krhino_buf_queue_info_get(kbuf_queue_t *queue, kbuf_queue_info_t *info); # 30 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_sem.h" 1 # 11 "./kernel/rhino/core/include/k_sem.h" typedef struct sem_s { blk_obj_t blk_obj; sem_count_t count; sem_count_t peak_count; klist_t sem_item; uint8_t mm_alloc_flag; } ksem_t; # 28 "./kernel/rhino/core/include/k_sem.h" kstat_t krhino_sem_create(ksem_t *sem, const name_t *name, sem_count_t count); kstat_t krhino_sem_del(ksem_t *sem); # 45 "./kernel/rhino/core/include/k_sem.h" kstat_t krhino_sem_dyn_create(ksem_t **sem, const name_t *name, sem_count_t count); kstat_t krhino_sem_dyn_del(ksem_t *sem); kstat_t krhino_sem_give(ksem_t *sem); kstat_t krhino_sem_give_all(ksem_t *sem); kstat_t krhino_sem_take(ksem_t *sem, tick_t ticks); kstat_t krhino_sem_count_set(ksem_t *sem, sem_count_t count); kstat_t krhino_sem_count_get(ksem_t *sem, sem_count_t *count); # 31 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_task_sem.h" 1 # 16 "./kernel/rhino/core/include/k_task_sem.h" kstat_t krhino_task_sem_create(ktask_t *task, ksem_t *sem, const name_t *name, size_t count); kstat_t krhino_task_sem_del(ktask_t *task); kstat_t krhino_task_sem_give(ktask_t *task); kstat_t krhino_task_sem_take(tick_t ticks); kstat_t krhino_task_sem_count_set(ktask_t *task, sem_count_t count); kstat_t krhino_task_sem_count_get(ktask_t *task, sem_count_t *count); # 32 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_mutex.h" 1 typedef struct mutex_s { blk_obj_t blk_obj; ktask_t *mutex_task; struct mutex_s *mutex_list; mutex_nested_t owner_nested; klist_t mutex_item; uint8_t mm_alloc_flag; } kmutex_t; kstat_t krhino_mutex_create(kmutex_t *mutex, const name_t *name); kstat_t krhino_mutex_del(kmutex_t *mutex); # 43 "./kernel/rhino/core/include/k_mutex.h" kstat_t krhino_mutex_dyn_create(kmutex_t **mutex, const name_t *name); kstat_t krhino_mutex_dyn_del(kmutex_t *mutex); # 59 "./kernel/rhino/core/include/k_mutex.h" kstat_t krhino_mutex_lock(kmutex_t *mutex, tick_t ticks); kstat_t krhino_mutex_unlock(kmutex_t *mutex); # 33 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_timer.h" 1 enum { TIMER_CMD_CB = 0u, TIMER_CMD_START, TIMER_CMD_STOP, TIMER_CMD_CHG, TIMER_ARG_CHG, TIMER_ARG_CHG_AUTO, TIMER_CMD_DEL, TIMER_CMD_DYN_DEL }; typedef void (*timer_cb_t)(void *timer, void *arg); typedef struct { klist_t timer_list; klist_t *to_head; const name_t *name; timer_cb_t cb; void *timer_cb_arg; sys_time_t match; sys_time_t remain; sys_time_t init_count; sys_time_t round_ticks; void *priv; kobj_type_t obj_type; uint8_t timer_state; uint8_t mm_alloc_flag; } ktimer_t; typedef struct { ktimer_t *timer; uint8_t cb_num; sys_time_t first; union { sys_time_t round; void *arg; } u; } k_timer_queue_cb; typedef enum { TIMER_DEACTIVE = 0u, TIMER_ACTIVE } k_timer_state_t; # 63 "./kernel/rhino/core/include/k_timer.h" kstat_t krhino_timer_create(ktimer_t *timer, const name_t *name, timer_cb_t cb, sys_time_t first, sys_time_t round, void *arg, uint8_t auto_run); kstat_t krhino_timer_del(ktimer_t *timer); # 85 "./kernel/rhino/core/include/k_timer.h" kstat_t krhino_timer_dyn_create(ktimer_t **timer, const name_t *name, timer_cb_t cb, sys_time_t first, sys_time_t round, void *arg, uint8_t auto_run); kstat_t krhino_timer_dyn_del(ktimer_t *timer); kstat_t krhino_timer_start(ktimer_t *timer); kstat_t krhino_timer_stop(ktimer_t *timer); # 117 "./kernel/rhino/core/include/k_timer.h" kstat_t krhino_timer_change(ktimer_t *timer, sys_time_t first, sys_time_t round); # 126 "./kernel/rhino/core/include/k_timer.h" kstat_t krhino_timer_arg_change_auto(ktimer_t *timer, void *arg); kstat_t krhino_timer_arg_change(ktimer_t *timer, void *arg); # 34 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_time.h" 1 # 12 "./kernel/rhino/core/include/k_time.h" void krhino_tick_proc(void); sys_time_t krhino_sys_time_get(void); sys_time_t krhino_sys_tick_get(void); tick_t krhino_ms_to_ticks(sys_time_t ms); sys_time_t krhino_ticks_to_ms(tick_t ticks); # 35 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_event.h" 1 typedef struct { blk_obj_t blk_obj; uint32_t flags; klist_t event_item; uint8_t mm_alloc_flag; } kevent_t; # 34 "./kernel/rhino/core/include/k_event.h" kstat_t krhino_event_create(kevent_t *event, const name_t *name, uint32_t flags); kstat_t krhino_event_del(kevent_t *event); # 51 "./kernel/rhino/core/include/k_event.h" kstat_t krhino_event_dyn_create(kevent_t **event, const name_t *name, uint32_t flags); kstat_t krhino_event_dyn_del(kevent_t *event); # 71 "./kernel/rhino/core/include/k_event.h" kstat_t krhino_event_get(kevent_t *event, uint32_t flags, uint8_t opt, uint32_t *actl_flags, tick_t ticks); # 81 "./kernel/rhino/core/include/k_event.h" kstat_t krhino_event_set(kevent_t *event, uint32_t flags, uint8_t opt); # 36 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_stats.h" 1 # 9 "./kernel/rhino/core/include/k_stats.h" void kobj_list_init(void); void krhino_stack_ovf_check(void); # 37 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_mm_debug.h" 1 # 15 "./kernel/rhino/core/include/k_mm_debug.h" typedef struct { void *start; void *end; } mm_scan_region_t; # 1 "./kernel/rhino/core/include/k_mm.h" 1 # 78 "./kernel/rhino/core/include/k_mm.h" typedef struct free_ptr_struct { struct k_mm_list_struct *prev; struct k_mm_list_struct *next; } free_ptr_t; typedef struct k_mm_list_struct { size_t dye; size_t owner; struct k_mm_list_struct *prev; size_t buf_size; union { struct free_ptr_struct free_ptr; uint8_t buffer[1]; } mbinfo; } k_mm_list_t; typedef struct k_mm_region_info_struct { k_mm_list_t *end; struct k_mm_region_info_struct *next; } k_mm_region_info_t; typedef struct { kspinlock_t mm_lock; k_mm_region_info_t *regioninfo; void *fix_pool; size_t used_size; size_t maxused_size; size_t free_size; size_t alloc_times[(19 - 6 + 2)]; uint32_t free_bitmap; k_mm_list_t *freelist[(19 - 6 + 2)]; } k_mm_head; kstat_t krhino_init_mm_head(k_mm_head **ppmmhead, void *addr, size_t len ); kstat_t krhino_deinit_mm_head(k_mm_head *mmhead); kstat_t krhino_add_mm_region(k_mm_head *mmhead, void *addr, size_t len); void *k_mm_alloc(k_mm_head *mmhead, size_t size); void k_mm_free(k_mm_head *mmhead, void *ptr); void *k_mm_realloc(k_mm_head *mmhead, void *oldmem, size_t new_size); void *krhino_mm_alloc(size_t size); void krhino_mm_free(void *ptr); void *krhino_mm_realloc(void *oldmem, size_t newsize); # 22 "./kernel/rhino/core/include/k_mm_debug.h" 2 void krhino_owner_attach(k_mm_head *mmhead, void *addr, size_t allocator); uint32_t krhino_mm_leak_region_init(void *start, void *end); uint32_t dumpsys_mm_info_func(uint32_t len); uint32_t dump_mmleak(void); # 38 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_mm_blk.h" 1 typedef struct { const name_t *pool_name; void *pool_end; void *pool_start; size_t blk_size; size_t blk_avail; size_t blk_whole; uint8_t *avail_list; kspinlock_t blk_lock; klist_t mblkpool_stats_item; } mblk_pool_t; # 31 "./kernel/rhino/core/include/k_mm_blk.h" kstat_t krhino_mblk_pool_init(mblk_pool_t *pool, const name_t *name, void *pool_start, size_t blk_size, size_t pool_size); kstat_t krhino_mblk_alloc(mblk_pool_t *pool, void **blk); kstat_t krhino_mblk_free(mblk_pool_t *pool, void *blk); # 39 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_mm_region.h" 1 typedef struct { uint8_t *start; size_t len; } k_mm_region_t; # 40 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_workqueue.h" 1 # 11 "./kernel/rhino/core/include/k_workqueue.h" typedef void (*work_handle_t)(void *arg); typedef struct { klist_t work_node; work_handle_t handle; void *arg; tick_t dly; ktimer_t *timer; void *wq; uint8_t work_exit; } kwork_t; typedef struct { klist_t workqueue_node; klist_t work_list; kwork_t *work_current; const name_t *name; ktask_t worker; ksem_t sem; } kworkqueue_t; # 41 "./kernel/rhino/core/include/k_workqueue.h" kstat_t krhino_workqueue_create(kworkqueue_t *workqueue, const name_t *name, uint8_t pri, cpu_stack_t *stack_buf, size_t stack_size); # 52 "./kernel/rhino/core/include/k_workqueue.h" kstat_t krhino_work_init(kwork_t *work, work_handle_t handle, void *arg, tick_t dly); kstat_t krhino_work_run(kworkqueue_t *workqueue, kwork_t *work); kstat_t krhino_work_sched(kwork_t *work); kstat_t krhino_work_cancel(kwork_t *work); # 42 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_internal.h" 1 extern kstat_t g_sys_stat; extern uint8_t g_idle_task_spawned[1]; extern runqueue_t g_ready_queue; extern uint8_t g_sched_lock[1]; extern uint8_t g_intrpt_nested_level[1]; extern ktask_t *g_preferred_ready_task[1]; extern ktask_t *g_active_task[1]; extern ktask_t g_idle_task[1]; extern idle_count_t g_idle_count[1]; extern cpu_stack_t g_idle_task_stack[1][200]; extern tick_t g_tick_count; extern klist_t g_tick_head; extern kobj_list_t g_kobj_list; extern klist_t g_timer_head; extern sys_time_t g_timer_count; extern ktask_t g_timer_task; extern cpu_stack_t g_timer_task_stack[300]; extern kbuf_queue_t g_timer_queue; extern k_timer_queue_cb timer_queue_cb[20]; # 74 "./kernel/rhino/core/include/k_internal.h" extern ksem_t g_res_sem; extern klist_t g_res_list; extern ktask_t g_dyn_task; extern cpu_stack_t g_dyn_task_stack[256]; extern klist_t g_workqueue_list_head; extern kmutex_t g_workqueue_mutex; extern kworkqueue_t g_workqueue_default; extern cpu_stack_t g_workqueue_stack[768]; extern k_mm_head *g_kmm_head; # 115 "./kernel/rhino/core/include/k_internal.h" typedef struct { size_t cnt; void *res[4]; klist_t res_list; } res_free_t; ktask_t *preferred_cpu_ready_task_get(runqueue_t *rq, uint8_t cpu_num); void core_sched(void); void runqueue_init(runqueue_t *rq); void ready_list_add(runqueue_t *rq, ktask_t *task); void ready_list_add_head(runqueue_t *rq, ktask_t *task); void ready_list_add_tail(runqueue_t *rq, ktask_t *task); void ready_list_rm(runqueue_t *rq, ktask_t *task); void ready_list_head_to_tail(runqueue_t *rq, ktask_t *task); void time_slice_update(void); void timer_task_sched(void); void pend_list_reorder(ktask_t *task); void pend_task_wakeup(ktask_t *task); void pend_to_blk_obj(blk_obj_t *blk_obj, ktask_t *task, tick_t timeout); void pend_task_rm(ktask_t *task); kstat_t pend_state_end_proc(ktask_t *task); void idle_task(void *p_arg); void idle_count_set(idle_count_t value); idle_count_t idle_count_get(void); void tick_list_init(void); void tick_task_start(void); void tick_list_rm(ktask_t *task); void tick_list_insert(ktask_t *task, tick_t time); void tick_list_update(tick_i_t ticks); uint8_t mutex_pri_limit(ktask_t *tcb, uint8_t pri); void mutex_task_pri_reset(ktask_t *tcb); uint8_t mutex_pri_look(ktask_t *tcb, kmutex_t *mutex_rel); kstat_t task_pri_change(ktask_t *task, uint8_t new_pri); void k_err_proc(kstat_t err); void ktimer_init(void); void intrpt_disable_measure_start(void); void intrpt_disable_measure_stop(void); void dyn_mem_proc_task_start(void); void cpu_usage_stats_start(void); kstat_t ringbuf_init(k_ringbuf_t *p_ringbuf, void *buf, size_t len, size_t type, size_t block_size); kstat_t ringbuf_reset(k_ringbuf_t *p_ringbuf); kstat_t ringbuf_push(k_ringbuf_t *p_ringbuf, void *data, size_t len); kstat_t ringbuf_head_push(k_ringbuf_t *p_ringbuf, void *data, size_t len); kstat_t ringbuf_pop(k_ringbuf_t *p_ringbuf, void *pdata, size_t *plen); uint8_t ringbuf_is_full(k_ringbuf_t *p_ringbuf); uint8_t ringbuf_is_empty(k_ringbuf_t *p_ringbuf); void workqueue_init(void); void k_mm_init(void); # 43 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_trace.h" 1 # 44 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_soc.h" 1 # 35 "./kernel/rhino/core/include/k_soc.h" void soc_err_proc(kstat_t err); size_t soc_get_cur_sp(void); # 45 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_hook.h" 1 # 46 "./kernel/rhino/core/include/k_api.h" 2 # 1 "././platform/arch/arm/armv5/./gcc/port.h" 1 size_t cpu_intrpt_save(void); void cpu_intrpt_restore(size_t cpsr); void cpu_intrpt_switch(void); void cpu_task_switch(void); void cpu_first_task_start(void); void *cpu_task_stack_init(cpu_stack_t *base, size_t size, void *arg, task_entry_t entry); static inline uint8_t cpu_cur_get(void) { return 0; } # 47 "./kernel/rhino/core/include/k_api.h" 2 # 1 "./kernel/rhino/core/include/k_endian.h" 1 # 48 "./kernel/rhino/core/include/k_api.h" 2 # 6 "kernel/rhino/core/k_mm_blk.c" 2 kstat_t krhino_mblk_pool_init(mblk_pool_t *pool, const name_t *name, void *pool_start, size_t blk_size, size_t pool_size) { size_t cpsr; uint32_t blks; uint8_t *blk_cur; uint8_t *blk_next; uint8_t *pool_end; uint8_t addr_align_mask; do { if (pool == # 20 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 20 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); do { if (name == # 21 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 21 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); do { if (pool_start == # 22 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 22 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); if (pool_size < (blk_size << 1u)) { return RHINO_BLK_POOL_SIZE_ERR; } addr_align_mask = sizeof(void *) - 1u; if (((size_t)pool_start & addr_align_mask) > 0u) { return RHINO_INV_ALIGN; } if ((blk_size & addr_align_mask) > 0u) { return RHINO_INV_ALIGN; } if ((pool_size & addr_align_mask) > 0u) { return RHINO_INV_ALIGN; } ; pool_end = (uint8_t *)pool_start + pool_size; blks = 0u; blk_cur = (uint8_t *)pool_start; blk_next = blk_cur + blk_size; while (blk_next < pool_end) { blks++; *(uint8_t **)blk_cur = blk_next; blk_cur = blk_next; blk_next = blk_cur + blk_size; } if (blk_next == pool_end) { blks++; } *((uint8_t **)blk_cur) = # 64 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 64 "kernel/rhino/core/k_mm_blk.c" ; pool->pool_name = name; pool->pool_start = pool_start; pool->pool_end = pool_end; pool->blk_whole = blks; pool->blk_avail = blks; pool->blk_size = blk_size; pool->avail_list = (uint8_t *)pool_start; do { { cpsr = cpu_intrpt_save(); }; } while (0); klist_insert(&(g_kobj_list.mblkpool_head), &pool->mblkpool_stats_item); do { { cpu_intrpt_restore(cpsr); }; } while (0); ; return RHINO_SUCCESS; } kstat_t krhino_mblk_alloc(mblk_pool_t *pool, void **blk) { kstat_t status; uint8_t *avail_blk; do { if (pool == # 90 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 90 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); do { if (blk == # 91 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 91 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); do { kspinlock_t *s = (kspinlock_t *)(&pool->blk_lock); s->cpsr = cpu_intrpt_save(); } while (0); if (pool->blk_avail > 0u) { avail_blk = pool->avail_list; *((uint8_t **)blk) = avail_blk; pool->avail_list = *(uint8_t **)(avail_blk); pool->blk_avail--; status = RHINO_SUCCESS; } else { *((uint8_t **)blk) = # 103 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 103 "kernel/rhino/core/k_mm_blk.c" ; status = RHINO_NO_MEM; } do { kspinlock_t *s = (kspinlock_t *)(&pool->blk_lock); cpu_intrpt_restore(s->cpsr); } while (0); return status; } kstat_t krhino_mblk_free(mblk_pool_t *pool, void *blk) { do { if (pool == # 114 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 114 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); do { if (blk == # 115 "kernel/rhino/core/k_mm_blk.c" 3 4 ((void *)0) # 115 "kernel/rhino/core/k_mm_blk.c" ) { return RHINO_NULL_PTR; } } while (0); do { kspinlock_t *s = (kspinlock_t *)(&pool->blk_lock); s->cpsr = cpu_intrpt_save(); } while (0); *((uint8_t **)blk) = pool->avail_list; pool->avail_list = blk; pool->blk_avail++; do { kspinlock_t *s = (kspinlock_t *)(&pool->blk_lock); cpu_intrpt_restore(s->cpsr); } while (0); return RHINO_SUCCESS; }
the_stack_data/167331875.c
#include <stdio.h> int main() { // print() displays the string inside quotation printf("Hello World!"); return 0; }
the_stack_data/131491.c
#ifdef BUILD_NEON #ifdef BUILD_NEON_INTRINSICS #include <arm_neon.h> #endif #endif #define NEONDEBUG 0 #if NEONDEBUG #define DEBUG_FNCOUNT(x) \ do { \ static int _foo = 0; \ if (_foo++%10000 ==0) \ printf("%s %+d %s: %d (%s)\n",__FILE__,__LINE__,__FUNCTION__,\ _foo, x " optimised");\ } while (0) #else #define DEBUG_FNCOUNT(x) ((void)x) #endif /* blend mask x color -> dst */ #ifdef BUILD_NEON #ifdef BUILD_NEON_INTRINSICS static void _op_blend_rel_mas_c_dp_neon(DATA32 *s EINA_UNUSED, DATA8 *m, DATA32 c, DATA32 *d, int l) { uint16x8_t dc0_16x8; uint16x8_t dc1_16x8; uint16x8_t m_16x8; uint16x8_t mc0_16x8; uint16x8_t mc1_16x8; uint16x8_t temp0_16x8; uint16x8_t temp1_16x8; uint16x8_t x255_16x8; uint32x2_t c_32x2; uint32x2_t m_32x2; uint32x4_t a_32x4; uint32x4_t ad_32x4; uint32x4_t cond_32x4; uint32x4_t d_32x4; uint32x4_t dc_32x4; uint32x4_t m_32x4; uint32x4_t temp_32x4; uint32x4_t x0_32x4; uint32x4_t x1_32x4; uint8x16_t a_8x16; uint8x16_t d_8x16; uint8x16_t dc_8x16; uint8x16_t m_8x16; uint8x16_t mc_8x16; uint8x16_t temp_8x16; uint8x16_t x0_8x16; uint8x16_t x1_8x16; uint8x8_t a0_8x8; uint8x8_t a1_8x8; uint8x8_t c_8x8; uint8x8_t d0_8x8; uint8x8_t d1_8x8; uint8x8_t dc0_8x8; uint8x8_t dc1_8x8; uint8x8_t m0_8x8; uint8x8_t m1_8x8; uint8x8_t m_8x8; uint8x8_t mc0_8x8; uint8x8_t mc1_8x8; uint8x8_t temp0_8x8; uint8x8_t temp1_8x8; c_32x2 = vdup_n_u32(c); c_8x8 = vreinterpret_u8_u32(c_32x2); x1_8x16 = vdupq_n_u8(0x1); x1_32x4 = vreinterpretq_u32_u8(x1_8x16); x255_16x8 = vdupq_n_u16(0xff); x0_8x16 = vdupq_n_u8(0x0); x0_32x4 = vreinterpretq_u32_u8(x0_8x16); DATA32 *end = d + (l & ~3); while (d < end) { d_32x4 = vld1q_u32(d); d_8x16 = vreinterpretq_u8_u32(d_32x4); d0_8x8 = vget_low_u8(d_8x16); d1_8x8 = vget_high_u8(d_8x16); m_32x2 = vld1_lane_u32((DATA32*)m, m_32x2, 0); m_8x8 = vreinterpret_u8_u32(m_32x2); m_16x8 = vmovl_u8(m_8x8); m_8x16 = vreinterpretq_u8_u16(m_16x8); m_8x8 = vget_low_u8(m_8x16); m_16x8 = vmovl_u8(m_8x8); m_32x4 = vreinterpretq_u32_u16(m_16x8); m_32x4 = vmulq_u32(m_32x4, x1_32x4); m_8x16 = vreinterpretq_u8_u32(m_32x4); m0_8x8 = vget_low_u8(m_8x16); m1_8x8 = vget_high_u8(m_8x16); mc0_16x8 = vmull_u8(m0_8x8, c_8x8); mc1_16x8 = vmull_u8(m1_8x8, c_8x8); mc0_16x8 = vaddq_u16(mc0_16x8, x255_16x8); mc1_16x8 = vaddq_u16(mc1_16x8, x255_16x8); mc0_8x8 = vshrn_n_u16(mc0_16x8, 8); mc1_8x8 = vshrn_n_u16(mc1_16x8, 8); mc_8x16 = vcombine_u8(mc0_8x8, mc1_8x8); a_8x16 = vsubq_u8(x0_8x16, mc_8x16); a_32x4 = vreinterpretq_u32_u8(a_8x16); a_32x4 = vshrq_n_u32(a_32x4, 24); a_32x4 = vmulq_u32(a_32x4, x1_32x4); a_8x16 = vreinterpretq_u8_u32(a_32x4); a0_8x8 = vget_low_u8(a_8x16); a1_8x8 = vget_high_u8(a_8x16); temp0_16x8 = vmull_u8(a0_8x8, d0_8x8); temp1_16x8 = vmull_u8(a1_8x8, d1_8x8); temp0_8x8 = vshrn_n_u16(temp0_16x8,8); temp1_8x8 = vshrn_n_u16(temp1_16x8,8); temp_8x16 = vcombine_u8(temp0_8x8, temp1_8x8); temp_32x4 = vreinterpretq_u32_u8(temp_8x16); cond_32x4 = vceqq_u32(a_32x4, x0_32x4); ad_32x4 = vbslq_u32(cond_32x4, d_32x4, temp_32x4); // shift (*d >> 24) dc_32x4 = vshrq_n_u32(d_32x4, 24); dc_32x4 = vmulq_u32(x1_32x4, dc_32x4); dc_8x16 = vreinterpretq_u8_u32(dc_32x4); dc0_8x8 = vget_low_u8(dc_8x16); dc1_8x8 = vget_high_u8(dc_8x16); // multiply MUL_256(*d >> 24, sc); dc0_16x8 = vmull_u8(dc0_8x8, mc0_8x8); dc1_16x8 = vmull_u8(dc1_8x8, mc1_8x8); dc0_16x8 = vaddq_u16(dc0_16x8, x255_16x8); dc1_16x8 = vaddq_u16(dc1_16x8, x255_16x8); dc0_8x8 = vshrn_n_u16(dc0_16x8, 8); dc1_8x8 = vshrn_n_u16(dc1_16x8, 8); dc_8x16 = vcombine_u8(dc0_8x8, dc1_8x8); // add up everything dc_32x4 = vreinterpretq_u32_u8(dc_8x16); d_32x4 = vaddq_u32(dc_32x4, ad_32x4); // save result vst1q_u32(d, d_32x4); d+=4; m+=4; } end += (l & 3); while (d < end) { DATA32 mc = MUL_SYM(*m, c); int alpha = 256 - (mc >> 24); *d = MUL_SYM(*d >> 24, mc) + MUL_256(alpha, *d); d++; m++; } } #endif #endif #ifdef BUILD_NEON static void _op_blend_mas_c_dp_neon(DATA32 *s EINA_UNUSED, DATA8 *m, DATA32 c, DATA32 *d, int l) { #ifdef BUILD_NEON_INTRINSICS uint16x8_t m_16x8; uint16x8_t mc0_16x8; uint16x8_t mc1_16x8; uint16x8_t temp0_16x8; uint16x8_t temp1_16x8; uint16x8_t x255_16x8; uint32x2_t c_32x2; uint32x2_t m_32x2; uint32x4_t a_32x4; uint32x4_t ad_32x4; uint32x4_t cond_32x4; uint32x4_t d_32x4; uint32x4_t m_32x4; uint32x4_t temp_32x4; uint32x4_t mc_32x4; uint32x4_t x0_32x4; uint32x4_t x1_32x4; uint8x16_t a_8x16; uint8x16_t d_8x16; uint8x16_t m_8x16; uint8x16_t mc_8x16; uint8x16_t temp_8x16; uint8x16_t x0_8x16; uint8x16_t x1_8x16; uint8x8_t a0_8x8; uint8x8_t a1_8x8; uint8x8_t c_8x8; uint8x8_t d0_8x8; uint8x8_t d1_8x8; uint8x8_t m0_8x8; uint8x8_t m1_8x8; uint8x8_t m_8x8; uint8x8_t mc0_8x8; uint8x8_t mc1_8x8; uint8x8_t temp0_8x8; uint8x8_t temp1_8x8; x1_8x16 = vdupq_n_u8(0x1); x0_8x16 = vdupq_n_u8(0x0); x0_32x4 = vreinterpretq_u32_u8(x0_8x16); x255_16x8 = vdupq_n_u16(0xff); x1_32x4 = vreinterpretq_u32_u8(x1_8x16); c_32x2 = vdup_n_u32(c); c_8x8 = vreinterpret_u8_u32(c_32x2); DATA32 *start = d; int size = l; DATA32 *end = start + (size & ~3); while (start < end) { int k = *((int *)m); if (k == 0) { m+=4; start+=4; continue; } m_32x2 = vld1_lane_u32((DATA32*)m, m_32x2, 0); d_32x4 = vld1q_u32(start); m_8x8 = vreinterpret_u8_u32(m_32x2); m_16x8 = vmovl_u8(m_8x8); m_8x16 = vreinterpretq_u8_u16(m_16x8); m_8x8 = vget_low_u8(m_8x16); m_16x8 = vmovl_u8(m_8x8); m_32x4 = vreinterpretq_u32_u16(m_16x8); m_32x4 = vmulq_u32(m_32x4, x1_32x4); m_8x16 = vreinterpretq_u8_u32(m_32x4); m0_8x8 = vget_low_u8(m_8x16); m1_8x8 = vget_high_u8(m_8x16); mc0_16x8 = vmull_u8(m0_8x8, c_8x8); mc1_16x8 = vmull_u8(m1_8x8, c_8x8); mc0_16x8 = vaddq_u16(mc0_16x8, x255_16x8); mc1_16x8 = vaddq_u16(mc1_16x8, x255_16x8); mc0_8x8 = vshrn_n_u16(mc0_16x8, 8); mc1_8x8 = vshrn_n_u16(mc1_16x8, 8); mc_8x16 = vcombine_u8(mc0_8x8, mc1_8x8); a_8x16 = vsubq_u8(x0_8x16, mc_8x16); a_32x4 = vreinterpretq_u32_u8(a_8x16); a_32x4 = vshrq_n_u32(a_32x4, 24); a_32x4 = vmulq_u32(a_32x4, x1_32x4); a_8x16 = vreinterpretq_u8_u32(a_32x4); a0_8x8 = vget_low_u8(a_8x16); a1_8x8 = vget_high_u8(a_8x16); d_8x16 = vreinterpretq_u8_u32(d_32x4); d0_8x8 = vget_low_u8(d_8x16); d1_8x8 = vget_high_u8(d_8x16); temp0_16x8 = vmull_u8(a0_8x8, d0_8x8); temp1_16x8 = vmull_u8(a1_8x8, d1_8x8); temp0_8x8 = vshrn_n_u16(temp0_16x8,8); temp1_8x8 = vshrn_n_u16(temp1_16x8,8); temp_8x16 = vcombine_u8(temp0_8x8, temp1_8x8); temp_32x4 = vreinterpretq_u32_u8(temp_8x16); cond_32x4 = vceqq_u32(a_32x4, x0_32x4); ad_32x4 = vbslq_u32(cond_32x4, d_32x4, temp_32x4); mc_32x4 = vreinterpretq_u32_u8(mc_8x16); d_32x4 = vaddq_u32(mc_32x4, ad_32x4); vst1q_u32(start, d_32x4); start+=4; m+=4; } end += (size & 3); while (start < end) { DATA32 a = *m; DATA32 mc = MUL_SYM(a, c); a = 256 - (mc >> 24); *start = mc + MUL_256(a, *start); m++; start++; } #else DATA32 *e = d + l; // everything we can do only once per cycle // loading of 'c', initialization of some registers asm volatile ( " .fpu neon \n\t" " vdup.i32 q15, %[c] \n\t" " vmov.i8 q14, #1 \n\t" " vmov.i16 q12, #255 \n\t" : : [c] "r" (c) : "q12", "q14", "q15" ); //here we do unaligned part of 'd' while (((int)d & 0xf) && (d < e)) { asm volatile ( " vld1.8 d0[0], [%[m]]! \n\t" " vld1.32 d4[0], [%[d]] \n\t" " vdup.u8 d0, d0[0] \n\t" " vmull.u8 q4, d0, d30 \n\t" " vadd.u16 q4, q4, q12 \n\t" " vshrn.u16 d12, q4, #8 \n\t" " vmvn.u16 d14, d12 \n\t" " vshr.u32 d16, d14, #24 \n\t" " vmul.u32 d16, d16, d28 \n\t" " vmovl.u8 q9, d4 \n\t" " vmull.u8 q7, d16, d4 \n\t" " vadd.u16 q7, q9, q7 \n\t" " vshrn.u16 d0, q7, #8 \n\t" " vadd.u8 d0, d0, d12 \n\t" " vst1.32 d0[0], [%[d]]! \n\t" : [d] "+r" (d), [m] "+r" (m) : [c] "r" (c) : "q0", "q2", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q15", "q14", "memory" ); } //here e - d should be divisible by 4 while((unsigned int)d < ((unsigned int)e & 0xfffffff0)) { //check if all 4 *m values are zeros int k = *((int *)m); if (k == 0) { m+=4; d+=4; continue; } asm volatile ( // load pair '*d' and '*(d+1)' into vector register " vld1.32 d0[0], [%[m]]! \n\t" " vldm %[d], {q2} \n\t" " vmovl.u8 q0, d0 \n\t" " vmovl.u8 q0, d0 \n\t" " vmul.u32 q0, q14 \n\t" // Multiply a * c " vmull.u8 q4, d0, d30 \n\t" " vadd.u16 q4, q4, q12 \n\t" " vmull.u8 q5, d1, d31 \n\t" " vadd.u16 q5, q5, q12 \n\t" // Shorten " vshrn.u16 d12, q4, #8 \n\t" " vshrn.u16 d13, q5, #8 \n\t" // extract negated alpha " vmvn.u16 q7, q6 \n\t" " vshr.u32 q8, q7, #24 \n\t" " vmul.u32 q8, q8, q14 \n\t" // Multiply " vmovl.u8 q9, d4 \n\t" " vmull.u8 q7, d16, d4 \n\t" " vadd.u16 q7, q9, q7 \n\t" " vmovl.u8 q10, d5 \n\t" " vmull.u8 q8, d17, d5 \n\t" " vadd.u16 q8, q10, q8 \n\t" " vshrn.u16 d0, q7, #8 \n\t" " vshrn.u16 d1, q8, #8 \n\t" // Add " vadd.u8 q0, q0, q6 \n\t" " vstm %[d]!, {d0,d1} \n\t" : [d] "+r" (d), [m] "+r" (m) : [c] "r" (c), [x] "r" (42) : "q0", "q2", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q15", "q14", "memory" ); } //do the remaining part while (d < e) { asm volatile ( " vld1.8 d0[0], [%[m]]! \n\t" " vld1.32 d4[0], [%[d]] \n\t" " vdup.u8 d0, d0[0] \n\t" " vmull.u8 q4, d0, d30 \n\t" " vadd.u16 q4, q4, q12 \n\t" " vshrn.u16 d12, q4, #8 \n\t" " vmvn.u16 d14, d12 \n\t" " vshr.u32 d16, d14, #24 \n\t" " vmul.u32 d16, d16, d28 \n\t" " vmovl.u8 q9, d4 \n\t" " vmull.u8 q7, d16, d4 \n\t" " vadd.u16 q7, q9, q7 \n\t" " vshrn.u16 d0, q7, #8 \n\t" " vadd.u8 d0, d0, d12 \n\t" " vst1.32 d0[0], [%[d]]! \n\t" : [d] "+r" (d), [m] "+r" (m) : [c] "r" (c) : "q0", "q2", "q4", "q5", "q6", "q7", "q8", "q9", "q10", "q15", "q14", "memory" ); } #endif } #endif #ifdef BUILD_NEON static void _op_blend_mas_can_dp_neon(DATA32 *s EINA_UNUSED, DATA8 *m, DATA32 c, DATA32 *d, int l) { #ifdef BUILD_NEON_INTRINSICS int16x8_t c_i16x8; int16x8_t d0_i16x8; int16x8_t d1_i16x8; int16x8_t dc0_i16x8; int16x8_t dc1_i16x8; int16x8_t m0_i16x8; int16x8_t m1_i16x8; int8x16_t dc_i8x16; int8x8_t dc0_i8x8; int8x8_t dc1_i8x8; uint16x8_t c_16x8; uint16x8_t d0_16x8; uint16x8_t d1_16x8; uint16x8_t m0_16x8; uint16x8_t m1_16x8; uint16x8_t m_16x8; uint32x2_t c_32x2; uint32x2_t m_32x2; uint32x4_t d_32x4; uint32x4_t dc_32x4; uint32x4_t m_32x4; uint32x4_t x1_32x4; uint8x16_t d_8x16; uint8x16_t m_8x16; uint8x16_t x1_8x16; uint8x8_t c_8x8; uint8x8_t d0_8x8; uint8x8_t d1_8x8; uint8x8_t m0_8x8; uint8x8_t m1_8x8; uint8x8_t m_8x8; uint8x8_t x1_8x8; uint32x4_t x0_32x4; uint32x4_t cond_32x4; c_32x2 = vdup_n_u32(c); c_8x8 = vreinterpret_u8_u32(c_32x2); c_16x8 = vmovl_u8(c_8x8); c_i16x8 = vreinterpretq_s16_u16(c_16x8); x1_8x16 = vdupq_n_u8(0x1); x1_8x8 = vget_low_u8(x1_8x16); x1_32x4 = vreinterpretq_u32_u8(x1_8x16); x0_32x4 = vdupq_n_u32(0x0); DATA32 *start = d; int size = l; DATA32 *end = start + (size & ~3); while (start < end) { int k = *((int *)m); if (k == 0) { m+=4; start+=4; continue; } m_32x2 = vld1_lane_u32((DATA32*)m, m_32x2, 0); d_32x4 = vld1q_u32(start); d_8x16 = vreinterpretq_u8_u32(d_32x4); d0_8x8 = vget_low_u8(d_8x16); d1_8x8 = vget_high_u8(d_8x16); m_8x8 = vreinterpret_u8_u32(m_32x2); m_16x8 = vmovl_u8(m_8x8); m_8x16 = vreinterpretq_u8_u16(m_16x8); m_8x8 = vget_low_u8(m_8x16); m_16x8 = vmovl_u8(m_8x8); m_32x4 = vreinterpretq_u32_u16(m_16x8); m_32x4 = vmulq_u32(m_32x4, x1_32x4); m_8x16 = vreinterpretq_u8_u32(m_32x4); m0_8x8 = vget_low_u8(m_8x16); m1_8x8 = vget_high_u8(m_8x16); m0_16x8 = vaddl_u8(m0_8x8, x1_8x8); m1_16x8 = vaddl_u8(m1_8x8, x1_8x8); m0_i16x8 = vreinterpretq_s16_u16(m0_16x8); m1_i16x8 = vreinterpretq_s16_u16(m1_16x8); d0_16x8 = vmovl_u8(d0_8x8); d1_16x8 = vmovl_u8(d1_8x8); d0_i16x8 = vreinterpretq_s16_u16(d0_16x8); d1_i16x8 = vreinterpretq_s16_u16(d1_16x8); dc0_i16x8 = vsubq_s16(c_i16x8, d0_i16x8); dc1_i16x8 = vsubq_s16(c_i16x8, d1_i16x8); dc0_i16x8 = vmulq_s16(dc0_i16x8, m0_i16x8); dc1_i16x8 = vmulq_s16(dc1_i16x8, m1_i16x8); dc0_i16x8 = vshrq_n_s16(dc0_i16x8, 8); dc1_i16x8 = vshrq_n_s16(dc1_i16x8, 8); dc0_i16x8 = vaddq_s16(dc0_i16x8, d0_i16x8); dc1_i16x8 = vaddq_s16(dc1_i16x8, d1_i16x8); dc0_i8x8 = vmovn_s16(dc0_i16x8); dc1_i8x8 = vmovn_s16(dc1_i16x8); dc_i8x16 = vcombine_s8(dc0_i8x8, dc1_i8x8); dc_32x4 = vreinterpretq_u32_s8(dc_i8x16); cond_32x4 = vceqq_u32(m_32x4, x0_32x4); dc_32x4 = vbslq_u32(cond_32x4, d_32x4, dc_32x4); vst1q_u32(start, dc_32x4); m+=4; start+=4; } end += (size & 3); while (start < end) { DATA32 alpha = *m; alpha++; *start = INTERP_256(alpha, c, *start); m++; start++; } #else DATA32 *e; DEBUG_FNCOUNT(""); #define AP "_blend_mas_can_dp_neon_" asm volatile ( ".fpu neon \n\t" "vdup.u32 q9, %[c] \n\t" "vmov.i8 q15, #1 \n\t" "vmov.i8 q14, #0 \n\t" // Make C 16 bit (C in q3/q2) "vmovl.u8 q3, d19 \n\t" "vmovl.u8 q2, d18 \n\t" // Which loop to start " andS %[tmp], %[d],$0xf \n\t" " beq "AP"quadloop \n\t" " andS %[tmp], %[d], #4 \n\t" " beq "AP"dualstart \n\t" AP"singleloop: \n\t" " vld1.8 d0[0], [%[m]]! \n\t" " vld1.32 d8[0], [%[d]] \n\t" " vdup.u8 d0, d0[0] \n\t" " vshr.u8 d0, d0, #1 \n\t" " vmovl.u8 q0, d0 \n\t" " vmovl.u8 q4, d8 \n\t" " vsub.s16 q6, q2, q4 \n\t" " vmul.s16 q6, q0 \n\t" " vshr.s16 q6, #7 \n\t" " vadd.s16 q6, q4 \n\t" " vqmovun.s16 d2, q6 \n\t" " vst1.32 d2[0], [%[d]]! \n\t" " andS %[tmp], %[d], $0xf \n\t" " beq "AP"quadloop \n\t" AP"dualstart: \n\t" " sub %[tmp], %[e], %[d] \n\t" " cmp %[tmp], #16 \n\t" " blt "AP"loopout \n\t" AP"dualloop: \n\t" " vld1.16 d0[0], [%[m]]! \n\t" " vldm %[d], {d8} \n\t" " vmovl.u8 q0, d0 \n\t" " vmovl.u8 q0, d0 \n\t" " vmul.u32 d0, d0, d30 \n\t" " vshr.u8 d0, d0, #1 \n\t" " vmovl.u8 q0, d0 \n\t" " vmovl.u8 q4, d8 \n\t" " vsub.s16 q6, q2, q4 \n\t" " vmul.s16 q6, q0 \n\t" " vshr.s16 q6, #7 \n\t" " vadd.s16 q6, q4 \n\t" " vqmovun.s16 d2, q6 \n\t" " vstm %[d]!, {d2} \n\t" AP"quadloop: \n\t" " sub %[tmp], %[e], %[d] \n\t" " cmp %[tmp], #16 \n\t" " blt "AP"loopout \n\t" " sub %[tmp], %[e], #15 \n\t" " sub %[d], #16 \n\t" AP"fastloop: \n\t" " add %[d], #16 \n\t" " cmp %[tmp], %[d] \n\t" " blt "AP"loopout \n\t" AP"quadloopint: \n\t" // Load the mask: 4 bytes: It has d0/d1 " ldr %[x], [%[m]] \n\t" " add %[m], #4 \n\t" // Check for shortcuts " cmp %[x], #0 \n\t" " beq "AP"fastloop \n\t" " cmp %[x], $0xffffffff \n\t" " beq "AP"quadstore \n\t" " vmov.32 d0[0], %[x] \n\t" // Load d into d8/d9 q4 " vldm %[d], {d8,d9} \n\t" // Get the alpha channel ready (m) " vmovl.u8 q0, d0 \n\t" " vmovl.u8 q0, d0 \n\t" " vmul.u32 q0, q0,q15 \n\t" // Lop a bit off to prevent overflow " vshr.u8 q0, q0, #1 \n\t" // Now make it 16 bit " vmovl.u8 q1, d1 \n\t" " vmovl.u8 q0, d0 \n\t" // 16 bit 'd' " vmovl.u8 q5, d9 \n\t" " vmovl.u8 q4, d8 \n\t" // Diff 'd' & 'c' " vsub.s16 q7, q3, q5 \n\t" " vsub.s16 q6, q2, q4 \n\t" " vmul.s16 q7, q1 \n\t" " vmul.s16 q6, q0 \n\t" // Shift results a bit " vshr.s16 q7, #7 \n\t" " vshr.s16 q6, #7 \n\t" // Add 'd' " vadd.s16 q7, q5 \n\t" " vadd.s16 q6, q4 \n\t" // Make sure none are negative " vqmovun.s16 d9, q7 \n\t" " vqmovun.s16 d8, q6 \n\t" " vstm %[d]!, {d8,d9} \n\t" " cmp %[tmp], %[d] \n\t" " bhi "AP"quadloopint \n\t" " b "AP"loopout \n\t" AP"quadstore: \n\t" " vstm %[d]!, {d18,d19} \n\t" " cmp %[tmp], %[d] \n\t" " bhi "AP"quadloopint \n\t" AP"loopout: \n\t" #if NEONDEBUG "cmp %[d], %[e] \n\t" "ble "AP"foo \n\t" "sub %[tmp], %[tmp] \n\t" "vst1.32 d0[0], [%[tmp]] \n\t" AP"foo: \n\t" #endif " cmp %[e], %[d] \n\t" " beq "AP"done \n\t" " sub %[tmp],%[e], %[d] \n\t" " cmp %[tmp],#8 \n\t" " blt "AP"onebyte \n\t" // Load the mask: 2 bytes: It has d0 " vld1.16 d0[0], [%[m]]! \n\t" // Load d into d8/d9 q4 " vldm %[d], {d8} \n\t" // Get the alpha channel ready (m) " vmovl.u8 q0, d0 \n\t" " vmovl.u8 q0, d0 \n\t" " vmul.u32 d0, d0, d30 \n\t" // Lop a bit off to prevent overflow " vshr.u8 d0, d0, #1 \n\t" // Now make it 16 bit " vmovl.u8 q0, d0 \n\t" // 16 bit 'd' " vmovl.u8 q4, d8 \n\t" // Diff 'd' & 'c' " vsub.s16 q6, q2, q4 \n\t" " vmul.s16 q6, q0 \n\t" // Shift results a bit " vshr.s16 q6, #7 \n\t" // Add 'd' "vadd.s16 q6, q4 \n\t" // Make sure none are negative "vqmovun.s16 d2, q6 \n\t" "vstm %[d]!, {d2} \n\t" "cmp %[e], %[d] \n\t" "beq "AP"done \n\t" AP"onebyte: \n\t" "vld1.8 d0[0], [%[m]]! \n\t" "vld1.32 d8[0], [%[d]] \n\t" "vdup.u8 d0, d0[0] \n\t" "vshr.u8 d0, d0, #1 \n\t" "vmovl.u8 q0, d0 \n\t" "vmovl.u8 q4, d8 \n\t" "vsub.s16 q6, q2, q4 \n\t" "vmul.s16 q6, q0 \n\t" "vshr.s16 q6, #7 \n\t" "vadd.s16 q6, q4 \n\t" "vqmovun.s16 d2, q6 \n\t" "vst1.32 d2[0], [%[d]]! \n\t" AP"done: \n\t" #if NEONDEBUG "cmp %[d], %[e] \n\t" "beq "AP"reallydone \n\t" "sub %[m], %[m] \n\t" "vst1.32 d0[0], [%[m]] \n\t" AP"reallydone:" #endif : // output regs // Input : [e] "r" (e = d + l), [d] "r" (d), [c] "r" (c), [m] "r" (m), [tmp] "r" (7), [x] "r" (33) : "q0", "q1", "q2","q3", "q4","q5","q6", "q7","q9","q14","q15", "memory" // clobbered ); #undef AP #endif } #endif
the_stack_data/39120.c
#include <fcntl.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> #include <stdio.h> #include <unistd.h> #include <stdint.h> #include <time.h> #include <sys/ioctl.h> #include "linux/i2c-dev.h" /** * seven bit device address (binary): 011 1000 */ #define I2C_ALARM_PANEL_ADDRESS 0x38 /** * seven bit device address (binary): 011 1001 */ #define I2C_KEYBOARD_ADDRESS 0x39 #define LAMP(x) (0x8000>>x) #define LAMP_UPLINK_ACTY LAMP(0) #define LAMP_NO_ATT LAMP(1) #define LAMP_STBY LAMP(2) #define LAMP_KEY_REL LAMP(3) #define LAMP_OPR_ERR LAMP(4) #define LAMP_TEMP LAMP(7) #define LAMP_GIMBAL_LOCK LAMP(8) #define LAMP_PROG LAMP(9) #define LAMP_RESTART LAMP(10) #define LAMP_TRACKER LAMP(11) #define LAMP_ALT LAMP(12) #define LAMP_VEL LAMP(13) const char *key_name[] = { NULL, // entry 0 does not correspond to an S-key. "STBY", "KEY REL", "ENTR", "VERB", "NOUN", "CLR", "(minus)", "0", "(plus)", "1", "2", "3", "4", "5", "6", "7", "8", "9", "RESET" }; bool setLamps(int fd, unsigned int state) { char buf[2]; bool status = true; buf[0] = (state >> 8) & 0xff; buf[1] = (state & 0xff); if(write(fd, buf, 2) != 2) { status = false; } return status; } bool checkKeyEvent( int fd_key, unsigned long *millis, unsigned char *s_id, unsigned char *state) { unsigned char buf[6]; *millis = 0; *s_id = 0; *state = 0; bool status = false; if( read(fd_key, buf, 6) == 6 ) { *millis = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; //fprintf(stderr, "%ul\n", *millis); *s_id = buf[4]; *state = buf[5]; status = true; } return status; } int main(int argc, char *argv[]) { int fd; int fd_key; bool reported = false; bool reported2 = false; struct timespec _500ms; _500ms.tv_sec = 0; //_500ms.tv_nsec = 5000000L; _500ms.tv_nsec = 500 * 1000000L; fd = open("/dev/i2c-1", O_RDWR); if(fd < 0) { fprintf(stderr, "Error opening device\n"); exit(EXIT_FAILURE); } if(ioctl(fd, I2C_SLAVE, I2C_ALARM_PANEL_ADDRESS) < 0) { fprintf(stderr, "Error setting slave address\n"); close(fd); exit(EXIT_FAILURE); } fd_key = open("/dev/i2c-1", O_RDWR); if(fd_key < 0) { fprintf(stderr, "Error opening device\n"); exit(EXIT_FAILURE); } if(ioctl(fd_key, I2C_SLAVE, I2C_KEYBOARD_ADDRESS) < 0) { fprintf(stderr, "Error setting slave address\n"); close(fd_key); exit(EXIT_FAILURE); } unsigned short lamp = 0x8000; while (1) { if (!setLamps(fd, lamp)) { if (!reported) { reported = true; fprintf(stderr, "Error writing (1)\n"); } //close(fd); // exit(EXIT_FAILURE); } unsigned long millis; unsigned char s_id = 1; unsigned char state; while ( s_id > 0) { if (checkKeyEvent(fd_key, &millis, &s_id, &state) ) { if (s_id > 0) { printf("%s %s\n", key_name[s_id], state ? "down" : "up"); } } else { if (!reported2) { reported2 = true; printf ("error on keyboard poll\n"); } } } nanosleep(&_500ms, NULL); lamp = lamp >> 1; if (lamp == 0x0002) { lamp = 0x8000; } } close(fd); close(fd_key); exit(EXIT_SUCCESS); }
the_stack_data/96962.c
#include <stdio.h> int initialize_gameboy() { printf("Initializing GameBoy core...\n"); return 0; }
the_stack_data/140765334.c
/* Copyright (C) 1995, 1996, 1997, 1998, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <[email protected]>, August 1995. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <errno.h> #include <math.h> #include <stdlib.h> int drand48_r (buffer, result) struct drand48_data *buffer; double *result; { return __erand48_r (buffer->__x, buffer, result); }
the_stack_data/599765.c
/* https://www.urionlinejudge.com.br/judge/en/problems/view/1002 */ #include <stdio.h> int main(){ const double PI = 3.14159; double radius; scanf("%lf", &radius); printf("A=%.4lf\n", PI*radius*radius); return 0; }
the_stack_data/99974.c
#include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #define MSGSZ 128 // Declare the message structure typedef struct msgbuf { long mtype; char mtext[MSGSZ]; } message_buf; int main() { int msqid; int msgflg = IPC_CREAT | 0666; key_t key; message_buf sbuf; size_t buf_length; key = 2234; (void)fprintf(stderr, "\nmsgget: Calling msgget(%#1x,\%#o)\n", key, msgflg); if ((msqid = msgget(key, msgflg)) < 0) { perror("msgget"); exit(1); } else (void)fprintf(stderr, "msgget: msgget succeeded: msgqid = %d\n", msqid); // We'll send message type 1 sbuf.mtype = 1; (void) fprintf(stderr, "msggeet: msgget succeeded: msqid = %d\n", msqid); (void) strcpy(sbuf.mtext, "Did you get this?"); (void) fprintf(stderr, "msgget: msgget succeeded: msqid = %d\n", msqid); buf_length = strlen(sbuf.mtext) + 1; // Send a message. if((msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT)) < 0){ printf("%d, %ld, %s, %ld\n", msqid, sbuf.mtype, sbuf.mtext, buf_length); perror("msgsnd"); exit(1); } else printf("Message: \"%s\" Sent\n", sbuf.mtext); return 0; }
the_stack_data/36136.c
// Pemilihan menu #include <stdio.h> int main() { printf("[MENU SELECTION]\n"); printf("> 1. Tampilkan semua data tersimpan\n"); printf("> 2. Import data dari sebuah file\n"); printf("> 3. Export data laki-laki\n"); printf("> 4. Export data perempuan\n"); printf("> 5. Tampilkan 20 data GP3\n"); int menu; scanf("%d", &menu); switch (menu) { case 1: printf("Menu pertama"); break; case 2: printf("Menu kedua"); break; case 3: printf("Menu ketiga"); break; case 4: printf("Menu keempat"); break; case 5: printf("Menu kelima"); break; default: printf("Error\n"); break; } }
the_stack_data/11670.c
/*Exercise 2 - Selection Write a program to calculate the amount to be paid for a rented vehicle. • Input the distance the van has travelled • The first 30 km is at a rate of 50/= per km. • The remaining distance is calculated at the rate of 40/= per km. e.g. Distance -> 20 Amount = 20 x 50 = 1000 Distance -> 50 Amount = 30 x 50 + (50-30) x 40 = 2300*/ #include <stdio.h> int main() { int distance=0; float price; printf("Enter the Distance you travelled:"); scanf("%d", &distance); if (distance < 30){ price =distance * 50; } else if (distance >= 30){ price = (30 * 50)+((distance - 30)*40); } printf("Total Price : %.2f",price); return 0; }
the_stack_data/330859.c
/** @Generated PIC10 / PIC12 / PIC16 / PIC18 MCUs Source File @Company: Microchip Technology Inc. @File Name: mcc.c @Summary: This is the device_config.c file generated using PIC10 / PIC12 / PIC16 / PIC18 MCUs @Description: This header file provides implementations for driver APIs for all modules selected in the GUI. Generation Information : Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.81.7 Device : PIC18F47Q43 Driver Version : 2.00 The generated drivers are tested against the following: Compiler : XC8 2.31 and above or later MPLAB : MPLAB X 5.45 */ /* (c) 2018 Microchip Technology Inc. and its subsidiaries. Subject to your compliance with these terms, you may use Microchip software and any derivatives exclusively with Microchip products. It is your responsibility to comply with third party license terms applicable to your use of third party software (including open source software) that may accompany Microchip software. THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE. */ // Configuration bits: selected in the GUI // CONFIG1 #pragma config FEXTOSC = OFF // External Oscillator Selection->Oscillator not enabled #pragma config RSTOSC = HFINTOSC_64MHZ // Reset Oscillator Selection->HFINTOSC with HFFRQ = 64 MHz and CDIV = 1:1 // CONFIG2 #pragma config CLKOUTEN = OFF // Clock out Enable bit->CLKOUT function is disabled #pragma config PR1WAY = ON // PRLOCKED One-Way Set Enable bit->PRLOCKED bit can be cleared and set only once #pragma config CSWEN = ON // Clock Switch Enable bit->Writing to NOSC and NDIV is allowed #pragma config FCMEN = ON // Fail-Safe Clock Monitor Enable bit->Fail-Safe Clock Monitor enabled // CONFIG3 #pragma config MCLRE = EXTMCLR // MCLR Enable bit->If LVP = 0, MCLR pin is MCLR; If LVP = 1, RE3 pin function is MCLR #pragma config PWRTS = PWRT_OFF // Power-up timer selection bits->PWRT is disabled #pragma config MVECEN = ON // Multi-vector enable bit->Multi-vector enabled, Vector table used for interrupts #pragma config IVT1WAY = ON // IVTLOCK bit One-way set enable bit->IVTLOCKED bit can be cleared and set only once #pragma config LPBOREN = OFF // Low Power BOR Enable bit->Low-Power BOR disabled #pragma config BOREN = SBORDIS // Brown-out Reset Enable bits->Brown-out Reset enabled , SBOREN bit is ignored // CONFIG4 #pragma config BORV = VBOR_1P9 // Brown-out Reset Voltage Selection bits->Brown-out Reset Voltage (VBOR) set to 1.9V #pragma config ZCD = OFF // ZCD Disable bit->ZCD module is disabled. ZCD can be enabled by setting the ZCDSEN bit of ZCDCON #pragma config PPS1WAY = ON // PPSLOCK bit One-Way Set Enable bit->PPSLOCKED bit can be cleared and set only once; PPS registers remain locked after one clear/set cycle #pragma config STVREN = ON // Stack Full/Underflow Reset Enable bit->Stack full/underflow will cause Reset #pragma config LVP = ON // Low Voltage Programming Enable bit->Low voltage programming enabled. MCLR/VPP pin function is MCLR. MCLRE configuration bit is ignored #pragma config XINST = OFF // Extended Instruction Set Enable bit->Extended Instruction Set and Indexed Addressing Mode disabled // CONFIG5 #pragma config WDTCPS = WDTCPS_31 // WDT Period selection bits->Divider ratio 1:65536; software control of WDTPS #pragma config WDTE = OFF // WDT operating mode->WDT Disabled; SWDTEN is ignored // CONFIG6 #pragma config WDTCWS = WDTCWS_7 // WDT Window Select bits->window always open (100%); software control; keyed access not required #pragma config WDTCCS = SC // WDT input clock selector->Software Control // CONFIG7 #pragma config BBSIZE = BBSIZE_512 // Boot Block Size selection bits->Boot Block size is 512 words #pragma config BBEN = OFF // Boot Block enable bit->Boot block disabled #pragma config SAFEN = OFF // Storage Area Flash enable bit->SAF disabled #pragma config DEBUG = OFF // Background Debugger->Background Debugger disabled // CONFIG8 #pragma config WRTB = OFF // Boot Block Write Protection bit->Boot Block not Write protected #pragma config WRTC = OFF // Configuration Register Write Protection bit->Configuration registers not Write protected #pragma config WRTD = OFF // Data EEPROM Write Protection bit->Data EEPROM not Write protected #pragma config WRTSAF = OFF // SAF Write protection bit->SAF not Write Protected #pragma config WRTAPP = OFF // Application Block write protection bit->Application Block not write protected // CONFIG10 #pragma config CP = OFF // PFM and Data EEPROM Code Protection bit->PFM and Data EEPROM code protection disabled
the_stack_data/242331517.c
typedef int V2SI __attribute__((vector_size(8))); int main() { V2SI test1 = { -3, 8 }; V2SI test2 = { 2, 4 }; V2SI result = test1 / test2; return result[0] + result[1]; }
the_stack_data/159516215.c
/* SS_DBA_GRP defines the UNIX group ID for sqldba adminstrative access. */ /* Refer to the Installation and User's Guide for further information. */ /* IMPORTANT: this file needs to be in sync with rdbms/src/server/osds/config.c, specifically regarding the number of elements in the ss_dba_grp array. */ #if 0 /* * Linux x86_64 assembly code corresponding to C code below. This module * can be compiled both as C and ASM module, when changing code here * please keep both versions in sync. */ .section .rodata.str1.4, "aMS",@progbits,1 .align 4 .Ldba_string: .string "osdba" .Loper_string: .string "osoper" .Lasm_string: .string "" .Lbkp_string: .string "osbackupdba" .Ldgd_string: .string "osdgdba" .Lkmt_string: .string "oskmdba" .Lrac_string: .string "osracdba" .section .rodata .align 8 .globl ss_dba_grp ss_dba_grp: .quad .Ldba_string .quad .Loper_string .quad .Lasm_string .quad .Lbkp_string .quad .Ldgd_string .quad .Lkmt_string .quad .Lrac_string .type ss_dba_grp,@object .size ss_dba_grp,.-ss_dba_grp .section .note.GNU-stack, "" .end /* * Assembler will not parse a file past the .end directive */ #endif #define SS_DBA_GRP "osdba" #define SS_OPER_GRP "osoper" #define SS_ASM_GRP "" #define SS_BKP_GRP "osbackupdba" #define SS_DGD_GRP "osdgdba" #define SS_KMT_GRP "oskmdba" #define SS_RAC_GRP "osracdba" const char * const ss_dba_grp[] = {SS_DBA_GRP, SS_OPER_GRP, SS_ASM_GRP, SS_BKP_GRP, SS_DGD_GRP, SS_KMT_GRP, SS_RAC_GRP};
the_stack_data/118049.c
#include <math.h> /* * Compute average velocity */ double velavg(int npart, double vh[], double vaver, double h){ int i; double vaverh=vaver*h; double vel=0.0; double sq; extern double count; count=0.0; for (i=0; i<npart*3; i+=3){ sq=sqrt(vh[i]*vh[i]+vh[i+1]*vh[i+1]+vh[i+2]*vh[i+2]); if (sq>vaverh) count++; vel+=sq; } vel/=h; return(vel); }
the_stack_data/153267272.c
static const unsigned char KeyboardFilled25_array[2500] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xf3, 0xef, 0xeb, 0xf0, 0xf0, 0xef, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xe0, 0xf0, 0xef, 0xec, 0x40, 0xf3, 0xef, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf0, 0xef, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xdf, 0xf0, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf1, 0xef, 0xeb, 0x10, 0xff, 0xef, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0xa0, 0xf1, 0xef, 0xec, 0xaf, 0xf0, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf0, 0xef, 0xec, 0x20, 0xf7, 0xef, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xf0, 0xef, 0xeb, 0x4f, 0xf2, 0xf2, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf1, 0xef, 0xeb, 0x7f, 0xf1, 0xf1, 0xed, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0xf4, 0xef, 0xef, 0xdf, 0xf0, 0xf0, 0xec, 0x10, 0xff, 0xef, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x90, 0xf1, 0xef, 0xec, 0xef, 0xf0, 0xf0, 0xec, 0xa0, 0xf1, 0xef, 0xec, 0x40, 0xf3, 0xef, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xf7, 0xef, 0xef, 0x70, 0xf1, 0xef, 0xed, 0x40, 0xf3, 0xef, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0x80, 0xf1, 0xef, 0xeb, 0x80, 0xf1, 0xef, 0xeb, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0xf0, 0xef, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xdf, 0xf0, 0xf0, 0xec, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xf3, 0xef, 0xeb, 0xe0, 0xf0, 0xef, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xff, 0xf1, 0xf0, 0xec, 0xdf, 0xf0, 0xf0, 0xec, 0x40, 0xf3, 0xef, 0xeb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const int KeyboardFilled25_array_length = 2500; unsigned char *KeyboardFilled25 = (unsigned char *)KeyboardFilled25_array;
the_stack_data/834517.c
#include <stdio.h> int max(int a, int b) { if(a > b) return a; else return b; } int main(void) { int N, M; scanf("%d %d", &N, &M); int i, j, m[100], c[100]; for(i=0;i<N;i++) scanf("%d", &m[i]); for(i=0;i<N;i++) scanf("%d", &c[i]); int dp[10001] = {0,}; for(i=0;i<N;i++) { for(j=10000;j>0;j--) { if(dp[j] && j + c[i] <= 10000) { dp[j + c[i]] = max(dp[j + c[i]] , dp[j] + m[i]); } } dp[c[i]] = max(dp[c[i]], m[i]); } for(i=0;i<10000;i++) { if(dp[i] >= M) { printf("%d\n", i); return 0; } } }
the_stack_data/609586.c
/* Copyright (C) 1992-2019 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ #include <dirent.h> #if !_DIRENT_MATCHES_DIRENT64 int scandir(const char* dir, struct dirent*** namelist, int (*select)(const struct dirent*), int (*cmp)(const struct dirent**, const struct dirent**)) { return __scandir_tail(__opendir(dir), namelist, select, cmp); } #endif
the_stack_data/86838.c
/* Copyright 2016 Rose-Hulman */ #include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #define NUM_THREADS 10 /* * You can use the provided makefile to compile your code. */ int total; sem_t semaphore; void *add10000(void *arg) { int localTotal = 0; for (int i = 0; i < 10000; i++) { localTotal++; } sem_wait(&semaphore); total = total + localTotal; sem_post(&semaphore); return NULL; } int main(int argc, char **argv) { total = 0; pthread_t threads[NUM_THREADS]; sem_init(&semaphore, 0, 1); int i; for (i = 0; i < NUM_THREADS; i++) { pthread_create(&threads[i], NULL, add10000, NULL); } for (i = 0; i < NUM_THREADS; i++) { pthread_join(threads[i], NULL); } sem_destroy(&semaphore); printf("Everything finished. Final total %d\n", total); return 0; }
the_stack_data/111076977.c
// Ogg Vorbis audio decoder - v1.07 - public domain // http://nothings.org/stb_vorbis/ // // Original version written by Sean Barrett in 2007. // // Originally sponsored by RAD Game Tools. Seeking sponsored // by Phillip Bennefall, Marc Andersen, Aaron Baker, Elias Software, // Aras Pranckevicius, and Sean Barrett. // // LICENSE // // This software is in the public domain. Where that dedication is not // recognized, you are granted a perpetual, irrevocable license to copy, // distribute, and modify this file as you see fit. // // No warranty for any purpose is expressed or implied by the author (nor // by RAD Game Tools). Report bugs and send enhancements to the author. // // Limitations: // // - floor 0 not supported (used in old ogg vorbis files pre-2004) // - lossless sample-truncation at beginning ignored // - cannot concatenate multiple vorbis streams // - sample positions are 32-bit, limiting seekable 192Khz // files to around 6 hours (Ogg supports 64-bit) // // Feature contributors: // Dougall Johnson (sample-exact seeking) // // Bugfix/warning contributors: // Terje Mathisen Niklas Frykholm Andy Hill // Casey Muratori John Bolton Gargaj // Laurent Gomila Marc LeBlanc Ronny Chevalier // Bernhard Wodo Evan Balster "alxprd"@github // Tom Beaumont Ingo Leitgeb Nicolas Guillemot // Phillip Bennefall Rohit // // Partial history: // 1.07 - 2015/01/16 - fixes for crashes on invalid files; warning fixes; const // 1.06 - 2015/08/31 - full, correct support for seeking API (Dougall Johnson) // some crash fixes when out of memory or with corrupt files // fix some inappropriately signed shifts // 1.05 - 2015/04/19 - don't define __forceinline if it's redundant // 1.04 - 2014/08/27 - fix missing const-correct case in API // 1.03 - 2014/08/07 - warning fixes // 1.02 - 2014/07/09 - declare qsort comparison as explicitly _cdecl in Windows // 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float (interleaved was correct) // 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in >2-channel; // (API change) report sample rate for decode-full-file funcs // // See end of file for full version history. ////////////////////////////////////////////////////////////////////////////// // // HEADER BEGINS HERE // #ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H #define STB_VORBIS_INCLUDE_STB_VORBIS_H #if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) #define STB_VORBIS_NO_STDIO 1 #endif #ifndef STB_VORBIS_NO_STDIO #include <stdio.h> #endif #ifdef __cplusplus extern "C" { #endif /////////// THREAD SAFETY // Individual stb_vorbis* handles are not thread-safe; you cannot decode from // them from multiple threads at the same time. However, you can have multiple // stb_vorbis* handles and decode from them independently in multiple thrads. /////////// MEMORY ALLOCATION // normally stb_vorbis uses malloc() to allocate memory at startup, // and alloca() to allocate temporary memory during a frame on the // stack. (Memory consumption will depend on the amount of setup // data in the file and how you set the compile flags for speed // vs. size. In my test files the maximal-size usage is ~150KB.) // // You can modify the wrapper functions in the source (setup_malloc, // setup_temp_malloc, temp_malloc) to change this behavior, or you // can use a simpler allocation model: you pass in a buffer from // which stb_vorbis will allocate _all_ its memory (including the // temp memory). "open" may fail with a VORBIS_outofmem if you // do not pass in enough data; there is no way to determine how // much you do need except to succeed (at which point you can // query get_info to find the exact amount required. yes I know // this is lame). // // If you pass in a non-NULL buffer of the type below, allocation // will occur from it as described above. Otherwise just pass NULL // to use malloc()/alloca() typedef struct { char *alloc_buffer; int alloc_buffer_length_in_bytes; } stb_vorbis_alloc; /////////// FUNCTIONS USEABLE WITH ALL INPUT MODES typedef struct stb_vorbis stb_vorbis; typedef struct { unsigned int sample_rate; int channels; unsigned int setup_memory_required; unsigned int setup_temp_memory_required; unsigned int temp_memory_required; int max_frame_size; } stb_vorbis_info; // get general information about the file extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f); // get the last error detected (clears it, too) extern int stb_vorbis_get_error(stb_vorbis *f); // close an ogg vorbis file and free all memory in use extern void stb_vorbis_close(stb_vorbis *f); // this function returns the offset (in samples) from the beginning of the // file that will be returned by the next decode, if it is known, or -1 // otherwise. after a flush_pushdata() call, this may take a while before // it becomes valid again. // NOT WORKING YET after a seek with PULLDATA API extern int stb_vorbis_get_sample_offset(stb_vorbis *f); // returns the current seek point within the file, or offset from the beginning // of the memory buffer. In pushdata mode it returns 0. extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f); /////////// PUSHDATA API #ifndef STB_VORBIS_NO_PUSHDATA_API // this API allows you to get blocks of data from any source and hand // them to stb_vorbis. you have to buffer them; stb_vorbis will tell // you how much it used, and you have to give it the rest next time; // and stb_vorbis may not have enough data to work with and you will // need to give it the same data again PLUS more. Note that the Vorbis // specification does not bound the size of an individual frame. extern stb_vorbis *stb_vorbis_open_pushdata( const unsigned char * datablock, int datablock_length_in_bytes, int *datablock_memory_consumed_in_bytes, int *error, const stb_vorbis_alloc *alloc_buffer); // create a vorbis decoder by passing in the initial data block containing // the ogg&vorbis headers (you don't need to do parse them, just provide // the first N bytes of the file--you're told if it's not enough, see below) // on success, returns an stb_vorbis *, does not set error, returns the amount of // data parsed/consumed on this call in *datablock_memory_consumed_in_bytes; // on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed // if returns NULL and *error is VORBIS_need_more_data, then the input block was // incomplete and you need to pass in a larger block from the start of the file extern int stb_vorbis_decode_frame_pushdata( stb_vorbis *f, const unsigned char *datablock, int datablock_length_in_bytes, int *channels, // place to write number of float * buffers float ***output, // place to write float ** array of float * buffers int *samples // place to write number of output samples ); // decode a frame of audio sample data if possible from the passed-in data block // // return value: number of bytes we used from datablock // // possible cases: // 0 bytes used, 0 samples output (need more data) // N bytes used, 0 samples output (resynching the stream, keep going) // N bytes used, M samples output (one frame of data) // note that after opening a file, you will ALWAYS get one N-bytes,0-sample // frame, because Vorbis always "discards" the first frame. // // Note that on resynch, stb_vorbis will rarely consume all of the buffer, // instead only datablock_length_in_bytes-3 or less. This is because it wants // to avoid missing parts of a page header if they cross a datablock boundary, // without writing state-machiney code to record a partial detection. // // The number of channels returned are stored in *channels (which can be // NULL--it is always the same as the number of channels reported by // get_info). *output will contain an array of float* buffers, one per // channel. In other words, (*output)[0][0] contains the first sample from // the first channel, and (*output)[1][0] contains the first sample from // the second channel. extern void stb_vorbis_flush_pushdata(stb_vorbis *f); // inform stb_vorbis that your next datablock will not be contiguous with // previous ones (e.g. you've seeked in the data); future attempts to decode // frames will cause stb_vorbis to resynchronize (as noted above), and // once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it // will begin decoding the _next_ frame. // // if you want to seek using pushdata, you need to seek in your file, then // call stb_vorbis_flush_pushdata(), then start calling decoding, then once // decoding is returning you data, call stb_vorbis_get_sample_offset, and // if you don't like the result, seek your file again and repeat. #endif ////////// PULLING INPUT API #ifndef STB_VORBIS_NO_PULLDATA_API // This API assumes stb_vorbis is allowed to pull data from a source-- // either a block of memory containing the _entire_ vorbis stream, or a // FILE * that you or it create, or possibly some other reading mechanism // if you go modify the source to replace the FILE * case with some kind // of callback to your code. (But if you don't support seeking, you may // just want to go ahead and use pushdata.) #if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION) extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output); #endif #if !defined(STB_VORBIS_NO_INTEGER_CONVERSION) extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output); #endif // decode an entire file and output the data interleaved into a malloc()ed // buffer stored in *output. The return value is the number of samples // decoded, or -1 if the file could not be opened or was not an ogg vorbis file. // When you're done with it, just free() the pointer returned in *output. extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an ogg vorbis stream in memory (note // this must be the entire stream!). on failure, returns NULL and sets *error #ifndef STB_VORBIS_NO_STDIO extern stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from a filename via fopen(). on failure, // returns NULL and sets *error (possibly to VORBIS_file_open_failure). extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, int *error, const stb_vorbis_alloc *alloc_buffer); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell). on failure, returns NULL and sets *error. // note that stb_vorbis must "own" this stream; if you seek it in between // calls to stb_vorbis, it will become confused. Morever, if you attempt to // perform stb_vorbis_seek_*() operations on this file, it will assume it // owns the _entire_ rest of the file after the start point. Use the next // function, stb_vorbis_open_file_section(), to limit it. extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, int *error, const stb_vorbis_alloc *alloc_buffer, unsigned int len); // create an ogg vorbis decoder from an open FILE *, looking for a stream at // the _current_ seek point (ftell); the stream will be of length 'len' bytes. // on failure, returns NULL and sets *error. note that stb_vorbis must "own" // this stream; if you seek it in between calls to stb_vorbis, it will become // confused. #endif extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number); extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number); // these functions seek in the Vorbis file to (approximately) 'sample_number'. // after calling seek_frame(), the next call to get_frame_*() will include // the specified sample. after calling stb_vorbis_seek(), the next call to // stb_vorbis_get_samples_* will start with the specified sample. If you // do not need to seek to EXACTLY the target sample when using get_samples_*, // you can also use seek_frame(). extern void stb_vorbis_seek_start(stb_vorbis *f); // this function is equivalent to stb_vorbis_seek(f,0) extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); // these functions return the total length of the vorbis stream extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); // decode the next frame and return the number of samples. the number of // channels returned are stored in *channels (which can be NULL--it is always // the same as the number of channels reported by get_info). *output will // contain an array of float* buffers, one per channel. These outputs will // be overwritten on the next call to stb_vorbis_get_frame_*. // // You generally should not intermix calls to stb_vorbis_get_frame_*() // and stb_vorbis_get_samples_*(), since the latter calls the former. #ifndef STB_VORBIS_NO_INTEGER_CONVERSION extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts); extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples); #endif // decode the next frame and return the number of *samples* per channel. // Note that for interleaved data, you pass in the number of shorts (the // size of your array), but the return value is the number of samples per // channel, not the total number of samples. // // The data is coerced to the number of channels you request according to the // channel coercion rules (see below). You must pass in the size of your // buffer(s) so that stb_vorbis will not overwrite the end of the buffer. // The maximum buffer size needed can be gotten from get_info(); however, // the Vorbis I specification implies an absolute maximum of 4096 samples // per channel. // Channel coercion rules: // Let M be the number of channels requested, and N the number of channels present, // and Cn be the nth channel; let stereo L be the sum of all L and center channels, // and stereo R be the sum of all R and center channels (channel assignment from the // vorbis spec). // M N output // 1 k sum(Ck) for all k // 2 * stereo L, stereo R // k l k > l, the first l channels, then 0s // k l k <= l, the first k channels // Note that this is not _good_ surround etc. mixing at all! It's just so // you get something useful. extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats); extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples); // gets num_samples samples, not necessarily on a frame boundary--this requires // buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES. // Returns the number of samples stored per channel; it may be less than requested // at the end of the file. If there are no more samples in the file, returns 0. #ifndef STB_VORBIS_NO_INTEGER_CONVERSION extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts); extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples); #endif // gets num_samples samples, not necessarily on a frame boundary--this requires // buffering so you have to supply the buffers. Applies the coercion rules above // to produce 'channels' channels. Returns the number of samples stored per channel; // it may be less than requested at the end of the file. If there are no more // samples in the file, returns 0. #endif //////// ERROR CODES enum STBVorbisError { VORBIS__no_error, VORBIS_need_more_data=1, // not a real error VORBIS_invalid_api_mixing, // can't mix API modes VORBIS_outofmem, // not enough memory VORBIS_feature_not_supported, // uses floor 0 VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small VORBIS_file_open_failure, // fopen() failed VORBIS_seek_without_length, // can't seek in unknown-length file VORBIS_unexpected_eof=10, // file is truncated? VORBIS_seek_invalid, // seek past EOF // decoding errors (corrupt/invalid stream) -- you probably // don't care about the exact details of these // vorbis errors: VORBIS_invalid_setup=20, VORBIS_invalid_stream, // ogg errors: VORBIS_missing_capture_pattern=30, VORBIS_invalid_stream_structure_version, VORBIS_continued_packet_flag_invalid, VORBIS_incorrect_stream_serial_number, VORBIS_invalid_first_page, VORBIS_bad_packet_type, VORBIS_cant_find_last_page, VORBIS_seek_failed }; #ifdef __cplusplus } #endif #endif // STB_VORBIS_INCLUDE_STB_VORBIS_H // // HEADER ENDS HERE // ////////////////////////////////////////////////////////////////////////////// #ifndef STB_VORBIS_HEADER_ONLY // global configuration settings (e.g. set these in the project/makefile), // or just set them in this file at the top (although ideally the first few // should be visible when the header file is compiled too, although it's not // crucial) // STB_VORBIS_NO_PUSHDATA_API // does not compile the code for the various stb_vorbis_*_pushdata() // functions // #define STB_VORBIS_NO_PUSHDATA_API // STB_VORBIS_NO_PULLDATA_API // does not compile the code for the non-pushdata APIs // #define STB_VORBIS_NO_PULLDATA_API // STB_VORBIS_NO_STDIO // does not compile the code for the APIs that use FILE *s internally // or externally (implied by STB_VORBIS_NO_PULLDATA_API) // #define STB_VORBIS_NO_STDIO // STB_VORBIS_NO_INTEGER_CONVERSION // does not compile the code for converting audio sample data from // float to integer (implied by STB_VORBIS_NO_PULLDATA_API) // #define STB_VORBIS_NO_INTEGER_CONVERSION // STB_VORBIS_NO_FAST_SCALED_FLOAT // does not use a fast float-to-int trick to accelerate float-to-int on // most platforms which requires endianness be defined correctly. //#define STB_VORBIS_NO_FAST_SCALED_FLOAT // STB_VORBIS_MAX_CHANNELS [number] // globally define this to the maximum number of channels you need. // The spec does not put a restriction on channels except that // the count is stored in a byte, so 255 is the hard limit. // Reducing this saves about 16 bytes per value, so using 16 saves // (255-16)*16 or around 4KB. Plus anything other memory usage // I forgot to account for. Can probably go as low as 8 (7.1 audio), // 6 (5.1 audio), or 2 (stereo only). #ifndef STB_VORBIS_MAX_CHANNELS #define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone? #endif // STB_VORBIS_PUSHDATA_CRC_COUNT [number] // after a flush_pushdata(), stb_vorbis begins scanning for the // next valid page, without backtracking. when it finds something // that looks like a page, it streams through it and verifies its // CRC32. Should that validation fail, it keeps scanning. But it's // possible that _while_ streaming through to check the CRC32 of // one candidate page, it sees another candidate page. This #define // determines how many "overlapping" candidate pages it can search // at once. Note that "real" pages are typically ~4KB to ~8KB, whereas // garbage pages could be as big as 64KB, but probably average ~16KB. // So don't hose ourselves by scanning an apparent 64KB page and // missing a ton of real ones in the interim; so minimum of 2 #ifndef STB_VORBIS_PUSHDATA_CRC_COUNT #define STB_VORBIS_PUSHDATA_CRC_COUNT 4 #endif // STB_VORBIS_FAST_HUFFMAN_LENGTH [number] // sets the log size of the huffman-acceleration table. Maximum // supported value is 24. with larger numbers, more decodings are O(1), // but the table size is larger so worse cache missing, so you'll have // to probe (and try multiple ogg vorbis files) to find the sweet spot. #ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH #define STB_VORBIS_FAST_HUFFMAN_LENGTH 10 #endif // STB_VORBIS_FAST_BINARY_LENGTH [number] // sets the log size of the binary-search acceleration table. this // is used in similar fashion to the fast-huffman size to set initial // parameters for the binary search // STB_VORBIS_FAST_HUFFMAN_INT // The fast huffman tables are much more efficient if they can be // stored as 16-bit results instead of 32-bit results. This restricts // the codebooks to having only 65535 possible outcomes, though. // (At least, accelerated by the huffman table.) #ifndef STB_VORBIS_FAST_HUFFMAN_INT #define STB_VORBIS_FAST_HUFFMAN_SHORT #endif // STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH // If the 'fast huffman' search doesn't succeed, then stb_vorbis falls // back on binary searching for the correct one. This requires storing // extra tables with the huffman codes in sorted order. Defining this // symbol trades off space for speed by forcing a linear search in the // non-fast case, except for "sparse" codebooks. // #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH // STB_VORBIS_DIVIDES_IN_RESIDUE // stb_vorbis precomputes the result of the scalar residue decoding // that would otherwise require a divide per chunk. you can trade off // space for time by defining this symbol. // #define STB_VORBIS_DIVIDES_IN_RESIDUE // STB_VORBIS_DIVIDES_IN_CODEBOOK // vorbis VQ codebooks can be encoded two ways: with every case explicitly // stored, or with all elements being chosen from a small range of values, // and all values possible in all elements. By default, stb_vorbis expands // this latter kind out to look like the former kind for ease of decoding, // because otherwise an integer divide-per-vector-element is required to // unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can // trade off storage for speed. //#define STB_VORBIS_DIVIDES_IN_CODEBOOK #ifdef STB_VORBIS_CODEBOOK_SHORTS #error "STB_VORBIS_CODEBOOK_SHORTS is no longer supported as it produced incorrect results for some input formats" #endif // STB_VORBIS_DIVIDE_TABLE // this replaces small integer divides in the floor decode loop with // table lookups. made less than 1% difference, so disabled by default. // STB_VORBIS_NO_INLINE_DECODE // disables the inlining of the scalar codebook fast-huffman decode. // might save a little codespace; useful for debugging // #define STB_VORBIS_NO_INLINE_DECODE // STB_VORBIS_NO_DEFER_FLOOR // Normally we only decode the floor without synthesizing the actual // full curve. We can instead synthesize the curve immediately. This // requires more memory and is very likely slower, so I don't think // you'd ever want to do it except for debugging. // #define STB_VORBIS_NO_DEFER_FLOOR ////////////////////////////////////////////////////////////////////////////// #ifdef STB_VORBIS_NO_PULLDATA_API #define STB_VORBIS_NO_INTEGER_CONVERSION #define STB_VORBIS_NO_STDIO #endif #if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) #define STB_VORBIS_NO_STDIO 1 #endif #ifndef STB_VORBIS_NO_INTEGER_CONVERSION #ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT // only need endianness for fast-float-to-int, which we don't // use for pushdata #ifndef STB_VORBIS_BIG_ENDIAN #define STB_VORBIS_ENDIAN 0 #else #define STB_VORBIS_ENDIAN 1 #endif #endif #endif #ifndef STB_VORBIS_NO_STDIO #include <stdio.h> #endif #ifndef STB_VORBIS_NO_CRT #include <stdlib.h> #include <string.h> #include <assert.h> #include <math.h> #if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)) #include <stdlib.h> #endif #else // STB_VORBIS_NO_CRT #define NULL 0 #define malloc(s) 0 #define free(s) ((void) 0) #define realloc(s) 0 #endif // STB_VORBIS_NO_CRT #include <limits.h> #ifdef __MINGW32__ // eff you mingw: // "fixed": // http://sourceforge.net/p/mingw-w64/mailman/message/32882927/ // "no that broke the build, reverted, who cares about C": // http://sourceforge.net/p/mingw-w64/mailman/message/32890381/ #ifdef __forceinline #undef __forceinline #endif #define __forceinline #elif !defined(_MSC_VER) #if __GNUC__ #define __forceinline inline #else #define __forceinline #endif #endif #if STB_VORBIS_MAX_CHANNELS > 256 #error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range" #endif #if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24 #error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range" #endif #if 0 #include <crtdbg.h> #define CHECK(f) _CrtIsValidHeapPointer(f->channel_buffers[1]) #else #define CHECK(f) ((void) 0) #endif #define MAX_BLOCKSIZE_LOG 13 // from specification #define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG) typedef unsigned char uint8; typedef signed char int8; typedef unsigned short uint16; typedef signed short int16; typedef unsigned int uint32; typedef signed int int32; #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif typedef float codetype; // @NOTE // // Some arrays below are tagged "//varies", which means it's actually // a variable-sized piece of data, but rather than malloc I assume it's // small enough it's better to just allocate it all together with the // main thing // // Most of the variables are specified with the smallest size I could pack // them into. It might give better performance to make them all full-sized // integers. It should be safe to freely rearrange the structures or change // the sizes larger--nothing relies on silently truncating etc., nor the // order of variables. #define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH) #define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1) typedef struct { int dimensions, entries; uint8 *codeword_lengths; float minimum_value; float delta_value; uint8 value_bits; uint8 lookup_type; uint8 sequence_p; uint8 sparse; uint32 lookup_values; codetype *multiplicands; uint32 *codewords; #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; #else int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; #endif uint32 *sorted_codewords; int *sorted_values; int sorted_entries; } Codebook; typedef struct { uint8 order; uint16 rate; uint16 bark_map_size; uint8 amplitude_bits; uint8 amplitude_offset; uint8 number_of_books; uint8 book_list[16]; // varies } Floor0; typedef struct { uint8 partitions; uint8 partition_class_list[32]; // varies uint8 class_dimensions[16]; // varies uint8 class_subclasses[16]; // varies uint8 class_masterbooks[16]; // varies int16 subclass_books[16][8]; // varies uint16 Xlist[31*8+2]; // varies uint8 sorted_order[31*8+2]; uint8 neighbors[31*8+2][2]; uint8 floor1_multiplier; uint8 rangebits; int values; } Floor1; typedef union { Floor0 floor0; Floor1 floor1; } Floor; typedef struct { uint32 begin, end; uint32 part_size; uint8 classifications; uint8 classbook; uint8 **classdata; int16 (*residue_books)[8]; } Residue; typedef struct { uint8 magnitude; uint8 angle; uint8 mux; } MappingChannel; typedef struct { uint16 coupling_steps; MappingChannel *chan; uint8 submaps; uint8 submap_floor[15]; // varies uint8 submap_residue[15]; // varies } Mapping; typedef struct { uint8 blockflag; uint8 mapping; uint16 windowtype; uint16 transformtype; } Mode; typedef struct { uint32 goal_crc; // expected crc if match int bytes_left; // bytes left in packet uint32 crc_so_far; // running crc int bytes_done; // bytes processed in _current_ chunk uint32 sample_loc; // granule pos encoded in page } CRCscan; typedef struct { uint32 page_start, page_end; uint32 last_decoded_sample; } ProbedPage; struct stb_vorbis { // user-accessible info unsigned int sample_rate; int channels; unsigned int setup_memory_required; unsigned int temp_memory_required; unsigned int setup_temp_memory_required; // input config #ifndef STB_VORBIS_NO_STDIO FILE *f; uint32 f_start; int close_on_free; #endif uint8 *stream; uint8 *stream_start; uint8 *stream_end; uint32 stream_len; uint8 push_mode; uint32 first_audio_page_offset; ProbedPage p_first, p_last; // memory management stb_vorbis_alloc alloc; int setup_offset; int temp_offset; // run-time results int eof; enum STBVorbisError error; // user-useful data // header info int blocksize[2]; int blocksize_0, blocksize_1; int codebook_count; Codebook *codebooks; int floor_count; uint16 floor_types[64]; // varies Floor *floor_config; int residue_count; uint16 residue_types[64]; // varies Residue *residue_config; int mapping_count; Mapping *mapping; int mode_count; Mode mode_config[64]; // varies uint32 total_samples; // decode buffer float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; float *outputs [STB_VORBIS_MAX_CHANNELS]; float *previous_window[STB_VORBIS_MAX_CHANNELS]; int previous_length; #ifndef STB_VORBIS_NO_DEFER_FLOOR int16 *finalY[STB_VORBIS_MAX_CHANNELS]; #else float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; #endif uint32 current_loc; // sample location of next frame to decode int current_loc_valid; // per-blocksize precomputed data // twiddle factors float *A[2],*B[2],*C[2]; float *window[2]; uint16 *bit_reverse[2]; // current page/packet/segment streaming info uint32 serial; // stream serial number for verification int last_page; int segment_count; uint8 segments[255]; uint8 page_flag; uint8 bytes_in_seg; uint8 first_decode; int next_seg; int last_seg; // flag that we're on the last segment int last_seg_which; // what was the segment number of the last seg? uint32 acc; int valid_bits; int packet_bytes; int end_seg_with_known_loc; uint32 known_loc_for_packet; int discard_samples_deferred; uint32 samples_output; // push mode scanning int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching #ifndef STB_VORBIS_NO_PUSHDATA_API CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; #endif // sample-access int channel_buffer_start; int channel_buffer_end; }; #if defined(STB_VORBIS_NO_PUSHDATA_API) #define IS_PUSH_MODE(f) FALSE #elif defined(STB_VORBIS_NO_PULLDATA_API) #define IS_PUSH_MODE(f) TRUE #else #define IS_PUSH_MODE(f) ((f)->push_mode) #endif typedef struct stb_vorbis vorb; static int error(vorb *f, enum STBVorbisError e) { f->error = e; if (!f->eof && e != VORBIS_need_more_data) { f->error=e; // breakpoint for debugging } return 0; } // these functions are used for allocating temporary memory // while decoding. if you can afford the stack space, use // alloca(); otherwise, provide a temp buffer and it will // allocate out of those. #define array_size_required(count,size) (count*(sizeof(void *)+(size))) #define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) #ifdef dealloca #define temp_free(f,p) (f->alloc.alloc_buffer ? 0 : dealloca(size)) #else #define temp_free(f,p) 0 #endif #define temp_alloc_save(f) ((f)->temp_offset) #define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) #define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) // given a sufficiently large block of memory, make an array of pointers to subblocks of it static void *make_block_array(void *mem, int count, int size) { int i; void ** p = (void **) mem; char *q = (char *) (p + count); for (i=0; i < count; ++i) { p[i] = q; q += size; } return p; } static void *setup_malloc(vorb *f, int sz) { sz = (sz+3) & ~3; f->setup_memory_required += sz; if (f->alloc.alloc_buffer) { void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; if (f->setup_offset + sz > f->temp_offset) return NULL; f->setup_offset += sz; return p; } return sz ? malloc(sz) : NULL; } static void setup_free(vorb *f, void *p) { if (f->alloc.alloc_buffer) return; // do nothing; setup mem is a stack free(p); } static void *setup_temp_malloc(vorb *f, int sz) { sz = (sz+3) & ~3; if (f->alloc.alloc_buffer) { if (f->temp_offset - sz < f->setup_offset) return NULL; f->temp_offset -= sz; return (char *) f->alloc.alloc_buffer + f->temp_offset; } return malloc(sz); } static void setup_temp_free(vorb *f, void *p, int sz) { if (f->alloc.alloc_buffer) { f->temp_offset += (sz+3)&~3; return; } free(p); } #define CRC32_POLY 0x04c11db7 // from spec static uint32 crc_table[256]; static void crc32_init(void) { int i,j; uint32 s; for(i=0; i < 256; i++) { for (s=(uint32) i << 24, j=0; j < 8; ++j) s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); crc_table[i] = s; } } static __forceinline uint32 crc32_update(uint32 crc, uint8 byte) { return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; } // used in setup, and for huffman that doesn't go fast path static unsigned int bit_reverse(unsigned int n) { n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); return (n >> 16) | (n << 16); } static float square(float x) { return x*x; } // this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 // as required by the specification. fast(?) implementation from stb.h // @OPTIMIZE: called multiple times per-packet with "constants"; move to setup static int ilog(int32 n) { static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) if (n < (1 << 14)) if (n < (1 << 4)) return 0 + log2_4[n ]; else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; else return 10 + log2_4[n >> 10]; else if (n < (1 << 24)) if (n < (1 << 19)) return 15 + log2_4[n >> 15]; else return 20 + log2_4[n >> 20]; else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; else if (n < (1 << 31)) return 30 + log2_4[n >> 30]; else return 0; // signed n returns 0 } #ifndef M_PI #define M_PI 3.14159265358979323846264f // from CRC #endif // code length assigned to a value with no huffman encoding #define NO_CODE 255 /////////////////////// LEAF SETUP FUNCTIONS ////////////////////////// // // these functions are only called at setup, and only a few times // per file static float float32_unpack(uint32 x) { // from the specification uint32 mantissa = x & 0x1fffff; uint32 sign = x & 0x80000000; uint32 exp = (x & 0x7fe00000) >> 21; double res = sign ? -(double)mantissa : (double)mantissa; return (float) ldexp((float)res, exp-788); } // zlib & jpeg huffman tables assume that the output symbols // can either be arbitrarily arranged, or have monotonically // increasing frequencies--they rely on the lengths being sorted; // this makes for a very simple generation algorithm. // vorbis allows a huffman table with non-sorted lengths. This // requires a more sophisticated construction, since symbols in // order do not map to huffman codes "in order". static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) { if (!c->sparse) { c->codewords [symbol] = huff_code; } else { c->codewords [count] = huff_code; c->codeword_lengths[count] = len; values [count] = symbol; } } static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) { int i,k,m=0; uint32 available[32]; memset(available, 0, sizeof(available)); // find the first entry for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; if (k == n) { assert(c->sorted_entries == 0); return TRUE; } // add to the list add_entry(c, 0, k, m++, len[k], values); // add all available leaves for (i=1; i <= len[k]; ++i) available[i] = 1U << (32-i); // note that the above code treats the first case specially, // but it's really the same as the following code, so they // could probably be combined (except the initial code is 0, // and I use 0 in available[] to mean 'empty') for (i=k+1; i < n; ++i) { uint32 res; int z = len[i], y; if (z == NO_CODE) continue; // find lowest available leaf (should always be earliest, // which is what the specification calls for) // note that this property, and the fact we can never have // more than one free leaf at a given level, isn't totally // trivial to prove, but it seems true and the assert never // fires, so! while (z > 0 && !available[z]) --z; if (z == 0) { return FALSE; } res = available[z]; assert(z >= 0 && z < 32); available[z] = 0; add_entry(c, bit_reverse(res), i, m++, len[i], values); // propogate availability up the tree if (z != len[i]) { assert(len[i] >= 0 && len[i] < 32); for (y=len[i]; y > z; --y) { assert(available[y] == 0); available[y] = res + (1 << (32-y)); } } } return TRUE; } // accelerated huffman table allows fast O(1) match of all symbols // of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH static void compute_accelerated_huffman(Codebook *c) { int i, len; for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) c->fast_huffman[i] = -1; len = c->sparse ? c->sorted_entries : c->entries; #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT if (len > 32767) len = 32767; // largest possible value we can encode! #endif for (i=0; i < len; ++i) { if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; // set table entries for all bit combinations in the higher bits while (z < FAST_HUFFMAN_TABLE_SIZE) { c->fast_huffman[z] = i; z += 1 << c->codeword_lengths[i]; } } } } #ifdef _MSC_VER #define STBV_CDECL __cdecl #else #define STBV_CDECL #endif static int STBV_CDECL uint32_compare(const void *p, const void *q) { uint32 x = * (uint32 *) p; uint32 y = * (uint32 *) q; return x < y ? -1 : x > y; } static int include_in_sort(Codebook *c, uint8 len) { if (c->sparse) { assert(len != NO_CODE); return TRUE; } if (len == NO_CODE) return FALSE; if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE; return FALSE; } // if the fast table above doesn't work, we want to binary // search them... need to reverse the bits static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) { int i, len; // build a list of all the entries // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. // this is kind of a frivolous optimization--I don't see any performance improvement, // but it's like 4 extra lines of code, so. if (!c->sparse) { int k = 0; for (i=0; i < c->entries; ++i) if (include_in_sort(c, lengths[i])) c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); assert(k == c->sorted_entries); } else { for (i=0; i < c->sorted_entries; ++i) c->sorted_codewords[i] = bit_reverse(c->codewords[i]); } qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); c->sorted_codewords[c->sorted_entries] = 0xffffffff; len = c->sparse ? c->sorted_entries : c->entries; // now we need to indicate how they correspond; we could either // #1: sort a different data structure that says who they correspond to // #2: for each sorted entry, search the original list to find who corresponds // #3: for each original entry, find the sorted entry // #1 requires extra storage, #2 is slow, #3 can use binary search! for (i=0; i < len; ++i) { int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; if (include_in_sort(c,huff_len)) { uint32 code = bit_reverse(c->codewords[i]); int x=0, n=c->sorted_entries; while (n > 1) { // invariant: sc[x] <= code < sc[x+n] int m = x + (n >> 1); if (c->sorted_codewords[m] <= code) { x = m; n -= (n>>1); } else { n >>= 1; } } assert(c->sorted_codewords[x] == code); if (c->sparse) { c->sorted_values[x] = values[i]; c->codeword_lengths[x] = huff_len; } else { c->sorted_values[x] = i; } } } } // only run while parsing the header (3 times) static int vorbis_validate(uint8 *data) { static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' }; return memcmp(data, vorbis, 6) == 0; } // called from setup only, once per code book // (formula implied by specification) static int lookup1_values(int entries, int dim) { int r = (int) floor(exp((float) log((float) entries) / dim)); if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; ++r; // floor() to avoid _ftol() when non-CRT assert(pow((float) r+1, dim) > entries); assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above return r; } // called twice per file static void compute_twiddle_factors(int n, float *A, float *B, float *C) { int n4 = n >> 2, n8 = n >> 3; int k,k2; for (k=k2=0; k < n4; ++k,k2+=2) { A[k2 ] = (float) cos(4*k*M_PI/n); A[k2+1] = (float) -sin(4*k*M_PI/n); B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; } for (k=k2=0; k < n8; ++k,k2+=2) { C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); } } static void compute_window(int n, float *window) { int n2 = n >> 1, i; for (i=0; i < n2; ++i) window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); } static void compute_bitreverse(int n, uint16 *rev) { int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions int i, n8 = n >> 3; for (i=0; i < n8; ++i) rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2; } static int init_blocksize(vorb *f, int b, int n) { int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem); compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); if (!f->window[b]) return error(f, VORBIS_outofmem); compute_window(n, f->window[b]); f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem); compute_bitreverse(n, f->bit_reverse[b]); return TRUE; } static void neighbors(uint16 *x, int n, int *plow, int *phigh) { int low = -1; int high = 65536; int i; for (i=0; i < n; ++i) { if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; } if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; } } } // this has been repurposed so y is now the original index instead of y typedef struct { uint16 x,y; } Point; static int STBV_CDECL point_compare(const void *p, const void *q) { Point *a = (Point *) p; Point *b = (Point *) q; return a->x < b->x ? -1 : a->x > b->x; } // /////////////////////// END LEAF SETUP FUNCTIONS ////////////////////////// #if defined(STB_VORBIS_NO_STDIO) #define USE_MEMORY(z) TRUE #else #define USE_MEMORY(z) ((z)->stream) #endif static uint8 get8(vorb *z) { if (USE_MEMORY(z)) { if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } return *z->stream++; } #ifndef STB_VORBIS_NO_STDIO { int c = fgetc(z->f); if (c == EOF) { z->eof = TRUE; return 0; } return c; } #endif } static uint32 get32(vorb *f) { uint32 x; x = get8(f); x += get8(f) << 8; x += get8(f) << 16; x += (uint32) get8(f) << 24; return x; } static int getn(vorb *z, uint8 *data, int n) { if (USE_MEMORY(z)) { if (z->stream+n > z->stream_end) { z->eof = 1; return 0; } memcpy(data, z->stream, n); z->stream += n; return 1; } #ifndef STB_VORBIS_NO_STDIO if (fread(data, n, 1, z->f) == 1) return 1; else { z->eof = 1; return 0; } #endif } static void skip(vorb *z, int n) { if (USE_MEMORY(z)) { z->stream += n; if (z->stream >= z->stream_end) z->eof = 1; return; } #ifndef STB_VORBIS_NO_STDIO { long x = ftell(z->f); fseek(z->f, x+n, SEEK_SET); } #endif } static int set_file_offset(stb_vorbis *f, unsigned int loc) { #ifndef STB_VORBIS_NO_PUSHDATA_API if (f->push_mode) return 0; #endif f->eof = 0; if (USE_MEMORY(f)) { if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { f->stream = f->stream_end; f->eof = 1; return 0; } else { f->stream = f->stream_start + loc; return 1; } } #ifndef STB_VORBIS_NO_STDIO if (loc + f->f_start < loc || loc >= 0x80000000) { loc = 0x7fffffff; f->eof = 1; } else { loc += f->f_start; } if (!fseek(f->f, loc, SEEK_SET)) return 1; f->eof = 1; fseek(f->f, f->f_start, SEEK_END); return 0; #endif } static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 }; static int capture_pattern(vorb *f) { if (0x4f != get8(f)) return FALSE; if (0x67 != get8(f)) return FALSE; if (0x67 != get8(f)) return FALSE; if (0x53 != get8(f)) return FALSE; return TRUE; } #define PAGEFLAG_continued_packet 1 #define PAGEFLAG_first_page 2 #define PAGEFLAG_last_page 4 static int start_page_no_capturepattern(vorb *f) { uint32 loc0,loc1,n; // stream structure version if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); // header flag f->page_flag = get8(f); // absolute granule position loc0 = get32(f); loc1 = get32(f); // @TODO: validate loc0,loc1 as valid positions? // stream serial number -- vorbis doesn't interleave, so discard get32(f); //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); // page sequence number n = get32(f); f->last_page = n; // CRC32 get32(f); // page_segments f->segment_count = get8(f); if (!getn(f, f->segments, f->segment_count)) return error(f, VORBIS_unexpected_eof); // assume we _don't_ know any the sample position of any segments f->end_seg_with_known_loc = -2; if (loc0 != ~0U || loc1 != ~0U) { int i; // determine which packet is the last one that will complete for (i=f->segment_count-1; i >= 0; --i) if (f->segments[i] < 255) break; // 'i' is now the index of the _last_ segment of a packet that ends if (i >= 0) { f->end_seg_with_known_loc = i; f->known_loc_for_packet = loc0; } } if (f->first_decode) { int i,len; ProbedPage p; len = 0; for (i=0; i < f->segment_count; ++i) len += f->segments[i]; len += 27 + f->segment_count; p.page_start = f->first_audio_page_offset; p.page_end = p.page_start + len; p.last_decoded_sample = loc0; f->p_first = p; } f->next_seg = 0; return TRUE; } static int start_page(vorb *f) { if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern); return start_page_no_capturepattern(f); } static int start_packet(vorb *f) { while (f->next_seg == -1) { if (!start_page(f)) return FALSE; if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_continued_packet_flag_invalid); } f->last_seg = FALSE; f->valid_bits = 0; f->packet_bytes = 0; f->bytes_in_seg = 0; // f->next_seg is now valid return TRUE; } static int maybe_start_packet(vorb *f) { if (f->next_seg == -1) { int x = get8(f); if (f->eof) return FALSE; // EOF at page boundary is not an error! if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern); if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern); if (!start_page_no_capturepattern(f)) return FALSE; if (f->page_flag & PAGEFLAG_continued_packet) { // set up enough state that we can read this packet if we want, // e.g. during recovery f->last_seg = FALSE; f->bytes_in_seg = 0; return error(f, VORBIS_continued_packet_flag_invalid); } } return start_packet(f); } static int next_segment(vorb *f) { int len; if (f->last_seg) return 0; if (f->next_seg == -1) { f->last_seg_which = f->segment_count-1; // in case start_page fails if (!start_page(f)) { f->last_seg = 1; return 0; } if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid); } len = f->segments[f->next_seg++]; if (len < 255) { f->last_seg = TRUE; f->last_seg_which = f->next_seg-1; } if (f->next_seg >= f->segment_count) f->next_seg = -1; assert(f->bytes_in_seg == 0); f->bytes_in_seg = len; return len; } #define EOP (-1) #define INVALID_BITS (-1) static int get8_packet_raw(vorb *f) { if (!f->bytes_in_seg) { // CLANG! if (f->last_seg) return EOP; else if (!next_segment(f)) return EOP; } assert(f->bytes_in_seg > 0); --f->bytes_in_seg; ++f->packet_bytes; return get8(f); } static int get8_packet(vorb *f) { int x = get8_packet_raw(f); f->valid_bits = 0; return x; } static void flush_packet(vorb *f) { while (get8_packet_raw(f) != EOP); } // @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important // as the huffman decoder? static uint32 get_bits(vorb *f, int n) { uint32 z; if (f->valid_bits < 0) return 0; if (f->valid_bits < n) { if (n > 24) { // the accumulator technique below would not work correctly in this case z = get_bits(f, 24); z += get_bits(f, n-24) << 24; return z; } if (f->valid_bits == 0) f->acc = 0; while (f->valid_bits < n) { int z = get8_packet_raw(f); if (z == EOP) { f->valid_bits = INVALID_BITS; return 0; } f->acc += z << f->valid_bits; f->valid_bits += 8; } } if (f->valid_bits < 0) return 0; z = f->acc & ((1 << n)-1); f->acc >>= n; f->valid_bits -= n; return z; } // @OPTIMIZE: primary accumulator for huffman // expand the buffer to as many bits as possible without reading off end of packet // it might be nice to allow f->valid_bits and f->acc to be stored in registers, // e.g. cache them locally and decode locally static __forceinline void prep_huffman(vorb *f) { if (f->valid_bits <= 24) { if (f->valid_bits == 0) f->acc = 0; do { int z; if (f->last_seg && !f->bytes_in_seg) return; z = get8_packet_raw(f); if (z == EOP) return; f->acc += (unsigned) z << f->valid_bits; f->valid_bits += 8; } while (f->valid_bits <= 24); } } enum { VORBIS_packet_id = 1, VORBIS_packet_comment = 3, VORBIS_packet_setup = 5 }; static int codebook_decode_scalar_raw(vorb *f, Codebook *c) { int i; prep_huffman(f); if (c->codewords == NULL && c->sorted_codewords == NULL) return -1; // cases to use binary search: sorted_codewords && !c->codewords // sorted_codewords && c->entries > 8 if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { // binary search uint32 code = bit_reverse(f->acc); int x=0, n=c->sorted_entries, len; while (n > 1) { // invariant: sc[x] <= code < sc[x+n] int m = x + (n >> 1); if (c->sorted_codewords[m] <= code) { x = m; n -= (n>>1); } else { n >>= 1; } } // x is now the sorted index if (!c->sparse) x = c->sorted_values[x]; // x is now sorted index if sparse, or symbol otherwise len = c->codeword_lengths[x]; if (f->valid_bits >= len) { f->acc >>= len; f->valid_bits -= len; return x; } f->valid_bits = 0; return -1; } // if small, linear search assert(!c->sparse); for (i=0; i < c->entries; ++i) { if (c->codeword_lengths[i] == NO_CODE) continue; if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) { if (f->valid_bits >= c->codeword_lengths[i]) { f->acc >>= c->codeword_lengths[i]; f->valid_bits -= c->codeword_lengths[i]; return i; } f->valid_bits = 0; return -1; } } error(f, VORBIS_invalid_stream); f->valid_bits = 0; return -1; } #ifndef STB_VORBIS_NO_INLINE_DECODE #define DECODE_RAW(var, f,c) \ if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \ prep_huffman(f); \ var = f->acc & FAST_HUFFMAN_TABLE_MASK; \ var = c->fast_huffman[var]; \ if (var >= 0) { \ int n = c->codeword_lengths[var]; \ f->acc >>= n; \ f->valid_bits -= n; \ if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \ } else { \ var = codebook_decode_scalar_raw(f,c); \ } #else static int codebook_decode_scalar(vorb *f, Codebook *c) { int i; if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) prep_huffman(f); // fast huffman table lookup i = f->acc & FAST_HUFFMAN_TABLE_MASK; i = c->fast_huffman[i]; if (i >= 0) { f->acc >>= c->codeword_lengths[i]; f->valid_bits -= c->codeword_lengths[i]; if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } return i; } return codebook_decode_scalar_raw(f,c); } #define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c); #endif #define DECODE(var,f,c) \ DECODE_RAW(var,f,c) \ if (c->sparse) var = c->sorted_values[var]; #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c) #else #define DECODE_VQ(var,f,c) DECODE(var,f,c) #endif // CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case // where we avoid one addition #define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off]) #define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off]) #define CODEBOOK_ELEMENT_BASE(c) (0) static int codebook_decode_start(vorb *f, Codebook *c) { int z = -1; // type 0 is only legal in a scalar context if (c->lookup_type == 0) error(f, VORBIS_invalid_stream); else { DECODE_VQ(z,f,c); if (c->sparse) assert(z < c->sorted_entries); if (z < 0) { // check for EOP if (!f->bytes_in_seg) if (f->last_seg) return z; error(f, VORBIS_invalid_stream); } } return z; } static int codebook_decode(vorb *f, Codebook *c, float *output, int len) { int i,z = codebook_decode_start(f,c); if (z < 0) return FALSE; if (len > c->dimensions) len = c->dimensions; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { float last = CODEBOOK_ELEMENT_BASE(c); int div = 1; for (i=0; i < len; ++i) { int off = (z / div) % c->lookup_values; float val = CODEBOOK_ELEMENT_FAST(c,off) + last; output[i] += val; if (c->sequence_p) last = val + c->minimum_value; div *= c->lookup_values; } return TRUE; } #endif z *= c->dimensions; if (c->sequence_p) { float last = CODEBOOK_ELEMENT_BASE(c); for (i=0; i < len; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; output[i] += val; last = val + c->minimum_value; } } else { float last = CODEBOOK_ELEMENT_BASE(c); for (i=0; i < len; ++i) { output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last; } } return TRUE; } static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) { int i,z = codebook_decode_start(f,c); float last = CODEBOOK_ELEMENT_BASE(c); if (z < 0) return FALSE; if (len > c->dimensions) len = c->dimensions; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int div = 1; for (i=0; i < len; ++i) { int off = (z / div) % c->lookup_values; float val = CODEBOOK_ELEMENT_FAST(c,off) + last; output[i*step] += val; if (c->sequence_p) last = val; div *= c->lookup_values; } return TRUE; } #endif z *= c->dimensions; for (i=0; i < len; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; output[i*step] += val; if (c->sequence_p) last = val; } return TRUE; } static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode) { int c_inter = *c_inter_p; int p_inter = *p_inter_p; int i,z, effective = c->dimensions; // type 0 is only legal in a scalar context if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); while (total_decode > 0) { float last = CODEBOOK_ELEMENT_BASE(c); DECODE_VQ(z,f,c); #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK assert(!c->sparse || z < c->sorted_entries); #endif if (z < 0) { if (!f->bytes_in_seg) if (f->last_seg) return FALSE; return error(f, VORBIS_invalid_stream); } // if this will take us off the end of the buffers, stop short! // we check by computing the length of the virtual interleaved // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), // and the length we'll be using (effective) if (c_inter + p_inter*ch + effective > len * ch) { effective = len*ch - (p_inter*ch - c_inter); } #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int div = 1; for (i=0; i < effective; ++i) { int off = (z / div) % c->lookup_values; float val = CODEBOOK_ELEMENT_FAST(c,off) + last; if (outputs[c_inter]) outputs[c_inter][p_inter] += val; if (++c_inter == ch) { c_inter = 0; ++p_inter; } if (c->sequence_p) last = val; div *= c->lookup_values; } } else #endif { z *= c->dimensions; if (c->sequence_p) { for (i=0; i < effective; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; if (outputs[c_inter]) outputs[c_inter][p_inter] += val; if (++c_inter == ch) { c_inter = 0; ++p_inter; } last = val; } } else { for (i=0; i < effective; ++i) { float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; if (outputs[c_inter]) outputs[c_inter][p_inter] += val; if (++c_inter == ch) { c_inter = 0; ++p_inter; } } } } total_decode -= effective; } *c_inter_p = c_inter; *p_inter_p = p_inter; return TRUE; } static int predict_point(int x, int x0, int x1, int y0, int y1) { int dy = y1 - y0; int adx = x1 - x0; // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? int err = abs(dy) * (x - x0); int off = err / adx; return dy < 0 ? y0 - off : y0 + off; } // the following table is block-copied from the specification static float inverse_db_table[256] = { 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, 0.82788260f, 0.88168307f, 0.9389798f, 1.0f }; // @OPTIMIZE: if you want to replace this bresenham line-drawing routine, // note that you must produce bit-identical output to decode correctly; // this specific sequence of operations is specified in the spec (it's // drawing integer-quantized frequency-space lines that the encoder // expects to be exactly the same) // ... also, isn't the whole point of Bresenham's algorithm to NOT // have to divide in the setup? sigh. #ifndef STB_VORBIS_NO_DEFER_FLOOR #define LINE_OP(a,b) a *= b #else #define LINE_OP(a,b) a = b #endif #ifdef STB_VORBIS_DIVIDE_TABLE #define DIVTAB_NUMER 32 #define DIVTAB_DENOM 64 int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB #endif static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) { int dy = y1 - y0; int adx = x1 - x0; int ady = abs(dy); int base; int x=x0,y=y0; int err = 0; int sy; #ifdef STB_VORBIS_DIVIDE_TABLE if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { if (dy < 0) { base = -integer_divide_table[ady][adx]; sy = base-1; } else { base = integer_divide_table[ady][adx]; sy = base+1; } } else { base = dy / adx; if (dy < 0) sy = base - 1; else sy = base+1; } #else base = dy / adx; if (dy < 0) sy = base - 1; else sy = base+1; #endif ady -= abs(base) * adx; if (x1 > n) x1 = n; if (x < x1) { LINE_OP(output[x], inverse_db_table[y]); for (++x; x < x1; ++x) { err += ady; if (err >= adx) { err -= adx; y += sy; } else y += base; LINE_OP(output[x], inverse_db_table[y]); } } } static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) { int k; if (rtype == 0) { int step = n / book->dimensions; for (k=0; k < step; ++k) if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step)) return FALSE; } else { for (k=0; k < n; ) { if (!codebook_decode(f, book, target+offset, n-k)) return FALSE; k += book->dimensions; offset += book->dimensions; } } return TRUE; } static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) { int i,j,pass; Residue *r = f->residue_config + rn; int rtype = f->residue_types[rn]; int c = r->classbook; int classwords = f->codebooks[c].dimensions; int n_read = r->end - r->begin; int part_read = n_read / r->part_size; int temp_alloc_point = temp_alloc_save(f); #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata)); #else int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); #endif CHECK(f); for (i=0; i < ch; ++i) if (!do_not_decode[i]) memset(residue_buffers[i], 0, sizeof(float) * n); if (rtype == 2 && ch != 1) { for (j=0; j < ch; ++j) if (!do_not_decode[j]) break; if (j == ch) goto done; for (pass=0; pass < 8; ++pass) { int pcount = 0, class_set = 0; if (ch == 2) { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = (z & 1), p_inter = z>>1; if (pass == 0) { Codebook *c = f->codebooks+r->classbook; int q; DECODE(q,f,c); if (q == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[0][class_set] = r->classdata[q]; #else for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } #endif } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { int z = r->begin + pcount*r->part_size; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[0][class_set][i]; #else int c = classifications[0][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { Codebook *book = f->codebooks + b; #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; #else // saves 1% if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; #endif } else { z += r->part_size; c_inter = z & 1; p_inter = z >> 1; } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } else if (ch == 1) { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = 0, p_inter = z; if (pass == 0) { Codebook *c = f->codebooks+r->classbook; int q; DECODE(q,f,c); if (q == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[0][class_set] = r->classdata[q]; #else for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } #endif } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { int z = r->begin + pcount*r->part_size; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[0][class_set][i]; #else int c = classifications[0][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { Codebook *book = f->codebooks + b; if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; } else { z += r->part_size; c_inter = 0; p_inter = z; } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } else { while (pcount < part_read) { int z = r->begin + pcount*r->part_size; int c_inter = z % ch, p_inter = z/ch; if (pass == 0) { Codebook *c = f->codebooks+r->classbook; int q; DECODE(q,f,c); if (q == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[0][class_set] = r->classdata[q]; #else for (i=classwords-1; i >= 0; --i) { classifications[0][i+pcount] = q % r->classifications; q /= r->classifications; } #endif } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { int z = r->begin + pcount*r->part_size; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[0][class_set][i]; #else int c = classifications[0][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { Codebook *book = f->codebooks + b; if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) goto done; } else { z += r->part_size; c_inter = z % ch; p_inter = z / ch; } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } } goto done; } CHECK(f); for (pass=0; pass < 8; ++pass) { int pcount = 0, class_set=0; while (pcount < part_read) { if (pass == 0) { for (j=0; j < ch; ++j) { if (!do_not_decode[j]) { Codebook *c = f->codebooks+r->classbook; int temp; DECODE(temp,f,c); if (temp == EOP) goto done; #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE part_classdata[j][class_set] = r->classdata[temp]; #else for (i=classwords-1; i >= 0; --i) { classifications[j][i+pcount] = temp % r->classifications; temp /= r->classifications; } #endif } } } for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { for (j=0; j < ch; ++j) { if (!do_not_decode[j]) { #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE int c = part_classdata[j][class_set][i]; #else int c = classifications[j][pcount]; #endif int b = r->residue_books[c][pass]; if (b >= 0) { float *target = residue_buffers[j]; int offset = r->begin + pcount * r->part_size; int n = r->part_size; Codebook *book = f->codebooks + b; if (!residue_decode(f, book, target, offset, n, rtype)) goto done; } } } } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE ++class_set; #endif } } done: CHECK(f); temp_alloc_restore(f,temp_alloc_point); } #if 0 // slow way for debugging void inverse_mdct_slow(float *buffer, int n) { int i,j; int n2 = n >> 1; float *x = (float *) malloc(sizeof(*x) * n2); memcpy(x, buffer, sizeof(*x) * n2); for (i=0; i < n; ++i) { float acc = 0; for (j=0; j < n2; ++j) // formula from paper: //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); // formula from wikipedia //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); // these are equivalent, except the formula from the paper inverts the multiplier! // however, what actually works is NO MULTIPLIER!?! //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); buffer[i] = acc; } free(x); } #elif 0 // same as above, but just barely able to run in real time on modern machines void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) { float mcos[16384]; int i,j; int n2 = n >> 1, nmask = (n << 2) -1; float *x = (float *) malloc(sizeof(*x) * n2); memcpy(x, buffer, sizeof(*x) * n2); for (i=0; i < 4*n; ++i) mcos[i] = (float) cos(M_PI / 2 * i / n); for (i=0; i < n; ++i) { float acc = 0; for (j=0; j < n2; ++j) acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask]; buffer[i] = acc; } free(x); } #elif 0 // transform to use a slow dct-iv; this is STILL basically trivial, // but only requires half as many ops void dct_iv_slow(float *buffer, int n) { float mcos[16384]; float x[2048]; int i,j; int n2 = n >> 1, nmask = (n << 3) - 1; memcpy(x, buffer, sizeof(*x) * n); for (i=0; i < 8*n; ++i) mcos[i] = (float) cos(M_PI / 4 * i / n); for (i=0; i < n; ++i) { float acc = 0; for (j=0; j < n; ++j) acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask]; buffer[i] = acc; } } void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) { int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4; float temp[4096]; memcpy(temp, buffer, n2 * sizeof(float)); dct_iv_slow(temp, n2); // returns -c'-d, a-b' for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b' for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d' for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d } #endif #ifndef LIBVORBIS_MDCT #define LIBVORBIS_MDCT 0 #endif #if LIBVORBIS_MDCT // directly call the vorbis MDCT using an interface documented // by Jeff Roberts... useful for performance comparison typedef struct { int n; int log2n; float *trig; int *bitrev; float scale; } mdct_lookup; extern void mdct_init(mdct_lookup *lookup, int n); extern void mdct_clear(mdct_lookup *l); extern void mdct_backward(mdct_lookup *init, float *in, float *out); mdct_lookup M1,M2; void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) { mdct_lookup *M; if (M1.n == n) M = &M1; else if (M2.n == n) M = &M2; else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } else { if (M2.n) __asm int 3; mdct_init(&M2, n); M = &M2; } mdct_backward(M, buffer, buffer); } #endif // the following were split out into separate functions while optimizing; // they could be pushed back up but eh. __forceinline showed no change; // they're probably already being inlined. static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) { float *ee0 = e + i_off; float *ee2 = ee0 + k_off; int i; assert((n & 3) == 0); for (i=(n>>2); i > 0; --i) { float k00_20, k01_21; k00_20 = ee0[ 0] - ee2[ 0]; k01_21 = ee0[-1] - ee2[-1]; ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; ee2[ 0] = k00_20 * A[0] - k01_21 * A[1]; ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; A += 8; k00_20 = ee0[-2] - ee2[-2]; k01_21 = ee0[-3] - ee2[-3]; ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; A += 8; k00_20 = ee0[-4] - ee2[-4]; k01_21 = ee0[-5] - ee2[-5]; ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; A += 8; k00_20 = ee0[-6] - ee2[-6]; k01_21 = ee0[-7] - ee2[-7]; ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; A += 8; ee0 -= 8; ee2 -= 8; } } static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) { int i; float k00_20, k01_21; float *e0 = e + d0; float *e2 = e0 + k_off; for (i=lim >> 2; i > 0; --i) { k00_20 = e0[-0] - e2[-0]; k01_21 = e0[-1] - e2[-1]; e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; e2[-0] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-1] = (k01_21)*A[0] + (k00_20) * A[1]; A += k1; k00_20 = e0[-2] - e2[-2]; k01_21 = e0[-3] - e2[-3]; e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; e2[-2] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-3] = (k01_21)*A[0] + (k00_20) * A[1]; A += k1; k00_20 = e0[-4] - e2[-4]; k01_21 = e0[-5] - e2[-5]; e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; e2[-4] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-5] = (k01_21)*A[0] + (k00_20) * A[1]; A += k1; k00_20 = e0[-6] - e2[-6]; k01_21 = e0[-7] - e2[-7]; e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; e2[-6] = (k00_20)*A[0] - (k01_21) * A[1]; e2[-7] = (k01_21)*A[0] + (k00_20) * A[1]; e0 -= 8; e2 -= 8; A += k1; } } static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) { int i; float A0 = A[0]; float A1 = A[0+1]; float A2 = A[0+a_off]; float A3 = A[0+a_off+1]; float A4 = A[0+a_off*2+0]; float A5 = A[0+a_off*2+1]; float A6 = A[0+a_off*3+0]; float A7 = A[0+a_off*3+1]; float k00,k11; float *ee0 = e +i_off; float *ee2 = ee0+k_off; for (i=n; i > 0; --i) { k00 = ee0[ 0] - ee2[ 0]; k11 = ee0[-1] - ee2[-1]; ee0[ 0] = ee0[ 0] + ee2[ 0]; ee0[-1] = ee0[-1] + ee2[-1]; ee2[ 0] = (k00) * A0 - (k11) * A1; ee2[-1] = (k11) * A0 + (k00) * A1; k00 = ee0[-2] - ee2[-2]; k11 = ee0[-3] - ee2[-3]; ee0[-2] = ee0[-2] + ee2[-2]; ee0[-3] = ee0[-3] + ee2[-3]; ee2[-2] = (k00) * A2 - (k11) * A3; ee2[-3] = (k11) * A2 + (k00) * A3; k00 = ee0[-4] - ee2[-4]; k11 = ee0[-5] - ee2[-5]; ee0[-4] = ee0[-4] + ee2[-4]; ee0[-5] = ee0[-5] + ee2[-5]; ee2[-4] = (k00) * A4 - (k11) * A5; ee2[-5] = (k11) * A4 + (k00) * A5; k00 = ee0[-6] - ee2[-6]; k11 = ee0[-7] - ee2[-7]; ee0[-6] = ee0[-6] + ee2[-6]; ee0[-7] = ee0[-7] + ee2[-7]; ee2[-6] = (k00) * A6 - (k11) * A7; ee2[-7] = (k11) * A6 + (k00) * A7; ee0 -= k0; ee2 -= k0; } } static __forceinline void iter_54(float *z) { float k00,k11,k22,k33; float y0,y1,y2,y3; k00 = z[ 0] - z[-4]; y0 = z[ 0] + z[-4]; y2 = z[-2] + z[-6]; k22 = z[-2] - z[-6]; z[-0] = y0 + y2; // z0 + z4 + z2 + z6 z[-2] = y0 - y2; // z0 + z4 - z2 - z6 // done with y0,y2 k33 = z[-3] - z[-7]; z[-4] = k00 + k33; // z0 - z4 + z3 - z7 z[-6] = k00 - k33; // z0 - z4 - z3 + z7 // done with k33 k11 = z[-1] - z[-5]; y1 = z[-1] + z[-5]; y3 = z[-3] + z[-7]; z[-1] = y1 + y3; // z1 + z5 + z3 + z7 z[-3] = y1 - y3; // z1 + z5 - z3 - z7 z[-5] = k11 - k22; // z1 - z5 + z2 - z6 z[-7] = k11 + k22; // z1 - z5 - z2 + z6 } static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) { int a_off = base_n >> 3; float A2 = A[0+a_off]; float *z = e + i_off; float *base = z - 16 * n; while (z > base) { float k00,k11; k00 = z[-0] - z[-8]; k11 = z[-1] - z[-9]; z[-0] = z[-0] + z[-8]; z[-1] = z[-1] + z[-9]; z[-8] = k00; z[-9] = k11 ; k00 = z[ -2] - z[-10]; k11 = z[ -3] - z[-11]; z[ -2] = z[ -2] + z[-10]; z[ -3] = z[ -3] + z[-11]; z[-10] = (k00+k11) * A2; z[-11] = (k11-k00) * A2; k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation k11 = z[ -5] - z[-13]; z[ -4] = z[ -4] + z[-12]; z[ -5] = z[ -5] + z[-13]; z[-12] = k11; z[-13] = k00; k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation k11 = z[ -7] - z[-15]; z[ -6] = z[ -6] + z[-14]; z[ -7] = z[ -7] + z[-15]; z[-14] = (k00+k11) * A2; z[-15] = (k00-k11) * A2; iter_54(z); iter_54(z-8); z -= 16; } } static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) { int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; int ld; // @OPTIMIZE: reduce register pressure by using fewer variables? int save_point = temp_alloc_save(f); float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); float *u=NULL,*v=NULL; // twiddle factors float *A = f->A[blocktype]; // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. // kernel from paper // merged: // copy and reflect spectral data // step 0 // note that it turns out that the items added together during // this step are, in fact, being added to themselves (as reflected // by step 0). inexplicable inefficiency! this became obvious // once I combined the passes. // so there's a missing 'times 2' here (for adding X to itself). // this propogates through linearly to the end, where the numbers // are 1/2 too small, and need to be compensated for. { float *d,*e, *AA, *e_stop; d = &buf2[n2-2]; AA = A; e = &buffer[0]; e_stop = &buffer[n2]; while (e != e_stop) { d[1] = (e[0] * AA[0] - e[2]*AA[1]); d[0] = (e[0] * AA[1] + e[2]*AA[0]); d -= 2; AA += 2; e += 4; } e = &buffer[n2-3]; while (d >= buf2) { d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); d -= 2; AA += 2; e -= 4; } } // now we use symbolic names for these, so that we can // possibly swap their meaning as we change which operations // are in place u = buffer; v = buf2; // step 2 (paper output is w, now u) // this could be in place, but the data ends up in the wrong // place... _somebody_'s got to swap it, so this is nominated { float *AA = &A[n2-8]; float *d0,*d1, *e0, *e1; e0 = &v[n4]; e1 = &v[0]; d0 = &u[n4]; d1 = &u[0]; while (AA >= A) { float v40_20, v41_21; v41_21 = e0[1] - e1[1]; v40_20 = e0[0] - e1[0]; d0[1] = e0[1] + e1[1]; d0[0] = e0[0] + e1[0]; d1[1] = v41_21*AA[4] - v40_20*AA[5]; d1[0] = v40_20*AA[4] + v41_21*AA[5]; v41_21 = e0[3] - e1[3]; v40_20 = e0[2] - e1[2]; d0[3] = e0[3] + e1[3]; d0[2] = e0[2] + e1[2]; d1[3] = v41_21*AA[0] - v40_20*AA[1]; d1[2] = v40_20*AA[0] + v41_21*AA[1]; AA -= 8; d0 += 4; d1 += 4; e0 += 4; e1 += 4; } } // step 3 ld = ilog(n) - 1; // ilog is off-by-one from normal definitions // optimized step 3: // the original step3 loop can be nested r inside s or s inside r; // it's written originally as s inside r, but this is dumb when r // iterates many times, and s few. So I have two copies of it and // switch between them halfway. // this is iteration 0 of step 3 imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); // this is iteration 1 of step 3 imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); l=2; for (; l < (ld-3)>>1; ++l) { int k0 = n >> (l+2), k0_2 = k0>>1; int lim = 1 << (l+1); int i; for (i=0; i < lim; ++i) imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); } for (; l < ld-6; ++l) { int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; int rlim = n >> (l+6), r; int lim = 1 << (l+1); int i_off; float *A0 = A; i_off = n2-1; for (r=rlim; r > 0; --r) { imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); A0 += k1*4; i_off -= 8; } } // iterations with count: // ld-6,-5,-4 all interleaved together // the big win comes from getting rid of needless flops // due to the constants on pass 5 & 4 being all 1 and 0; // combining them to be simultaneous to improve cache made little difference imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); // output is u // step 4, 5, and 6 // cannot be in-place because of step 5 { uint16 *bitrev = f->bit_reverse[blocktype]; // weirdly, I'd have thought reading sequentially and writing // erratically would have been better than vice-versa, but in // fact that's not what my testing showed. (That is, with // j = bitreverse(i), do you read i and write j, or read j and write i.) float *d0 = &v[n4-4]; float *d1 = &v[n2-4]; while (d0 >= v) { int k4; k4 = bitrev[0]; d1[3] = u[k4+0]; d1[2] = u[k4+1]; d0[3] = u[k4+2]; d0[2] = u[k4+3]; k4 = bitrev[1]; d1[1] = u[k4+0]; d1[0] = u[k4+1]; d0[1] = u[k4+2]; d0[0] = u[k4+3]; d0 -= 4; d1 -= 4; bitrev += 2; } } // (paper output is u, now v) // data must be in buf2 assert(v == buf2); // step 7 (paper output is v, now v) // this is now in place { float *C = f->C[blocktype]; float *d, *e; d = v; e = v + n2 - 4; while (d < e) { float a02,a11,b0,b1,b2,b3; a02 = d[0] - e[2]; a11 = d[1] + e[3]; b0 = C[1]*a02 + C[0]*a11; b1 = C[1]*a11 - C[0]*a02; b2 = d[0] + e[ 2]; b3 = d[1] - e[ 3]; d[0] = b2 + b0; d[1] = b3 + b1; e[2] = b2 - b0; e[3] = b1 - b3; a02 = d[2] - e[0]; a11 = d[3] + e[1]; b0 = C[3]*a02 + C[2]*a11; b1 = C[3]*a11 - C[2]*a02; b2 = d[2] + e[ 0]; b3 = d[3] - e[ 1]; d[2] = b2 + b0; d[3] = b3 + b1; e[0] = b2 - b0; e[1] = b1 - b3; C += 4; d += 4; e -= 4; } } // data must be in buf2 // step 8+decode (paper output is X, now buffer) // this generates pairs of data a la 8 and pushes them directly through // the decode kernel (pushing rather than pulling) to avoid having // to make another pass later // this cannot POSSIBLY be in place, so we refer to the buffers directly { float *d0,*d1,*d2,*d3; float *B = f->B[blocktype] + n2 - 8; float *e = buf2 + n2 - 8; d0 = &buffer[0]; d1 = &buffer[n2-4]; d2 = &buffer[n2]; d3 = &buffer[n-4]; while (e >= v) { float p0,p1,p2,p3; p3 = e[6]*B[7] - e[7]*B[6]; p2 = -e[6]*B[6] - e[7]*B[7]; d0[0] = p3; d1[3] = - p3; d2[0] = p2; d3[3] = p2; p1 = e[4]*B[5] - e[5]*B[4]; p0 = -e[4]*B[4] - e[5]*B[5]; d0[1] = p1; d1[2] = - p1; d2[1] = p0; d3[2] = p0; p3 = e[2]*B[3] - e[3]*B[2]; p2 = -e[2]*B[2] - e[3]*B[3]; d0[2] = p3; d1[1] = - p3; d2[2] = p2; d3[1] = p2; p1 = e[0]*B[1] - e[1]*B[0]; p0 = -e[0]*B[0] - e[1]*B[1]; d0[3] = p1; d1[0] = - p1; d2[3] = p0; d3[0] = p0; B -= 8; e -= 8; d0 += 4; d2 += 4; d1 -= 4; d3 -= 4; } } temp_alloc_restore(f,save_point); } #if 0 // this is the original version of the above code, if you want to optimize it from scratch void inverse_mdct_naive(float *buffer, int n) { float s; float A[1 << 12], B[1 << 12], C[1 << 11]; int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; int n3_4 = n - n4, ld; // how can they claim this only uses N words?! // oh, because they're only used sparsely, whoops float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13]; // set up twiddle factors for (k=k2=0; k < n4; ++k,k2+=2) { A[k2 ] = (float) cos(4*k*M_PI/n); A[k2+1] = (float) -sin(4*k*M_PI/n); B[k2 ] = (float) cos((k2+1)*M_PI/n/2); B[k2+1] = (float) sin((k2+1)*M_PI/n/2); } for (k=k2=0; k < n8; ++k,k2+=2) { C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); } // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" // Note there are bugs in that pseudocode, presumably due to them attempting // to rename the arrays nicely rather than representing the way their actual // implementation bounces buffers back and forth. As a result, even in the // "some formulars corrected" version, a direct implementation fails. These // are noted below as "paper bug". // copy and reflect spectral data for (k=0; k < n2; ++k) u[k] = buffer[k]; for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1]; // kernel from paper // step 1 for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) { v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1]; v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2]; } // step 2 for (k=k4=0; k < n8; k+=1, k4+=4) { w[n2+3+k4] = v[n2+3+k4] + v[k4+3]; w[n2+1+k4] = v[n2+1+k4] + v[k4+1]; w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4]; w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4]; } // step 3 ld = ilog(n) - 1; // ilog is off-by-one from normal definitions for (l=0; l < ld-3; ++l) { int k0 = n >> (l+2), k1 = 1 << (l+3); int rlim = n >> (l+4), r4, r; int s2lim = 1 << (l+2), s2; for (r=r4=0; r < rlim; r4+=4,++r) { for (s2=0; s2 < s2lim; s2+=2) { u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4]; u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4]; u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1] - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1]; u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1] + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1]; } } if (l+1 < ld-3) { // paper bug: ping-ponging of u&w here is omitted memcpy(w, u, sizeof(u)); } } // step 4 for (i=0; i < n8; ++i) { int j = bit_reverse(i) >> (32-ld+3); assert(j < n8); if (i == j) { // paper bug: original code probably swapped in place; if copying, // need to directly copy in this case int i8 = i << 3; v[i8+1] = u[i8+1]; v[i8+3] = u[i8+3]; v[i8+5] = u[i8+5]; v[i8+7] = u[i8+7]; } else if (i < j) { int i8 = i << 3, j8 = j << 3; v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1]; v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3]; v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5]; v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7]; } } // step 5 for (k=0; k < n2; ++k) { w[k] = v[k*2+1]; } // step 6 for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) { u[n-1-k2] = w[k4]; u[n-2-k2] = w[k4+1]; u[n3_4 - 1 - k2] = w[k4+2]; u[n3_4 - 2 - k2] = w[k4+3]; } // step 7 for (k=k2=0; k < n8; ++k, k2 += 2) { v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; } // step 8 for (k=k2=0; k < n4; ++k,k2 += 2) { X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1]; X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ]; } // decode kernel to output // determined the following value experimentally // (by first figuring out what made inverse_mdct_slow work); then matching that here // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?) s = 0.5; // theoretically would be n4 // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code, // so it needs to use the "old" B values to behave correctly, or else // set s to 1.0 ]]] for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4]; for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1]; for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4]; } #endif static float *get_window(vorb *f, int len) { len <<= 1; if (len == f->blocksize_0) return f->window[0]; if (len == f->blocksize_1) return f->window[1]; assert(0); return NULL; } #ifndef STB_VORBIS_NO_DEFER_FLOOR typedef int16 YTYPE; #else typedef int YTYPE; #endif static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) { int n2 = n >> 1; int s = map->chan[i].mux, floor; floor = map->submap_floor[s]; if (f->floor_types[floor] == 0) { return error(f, VORBIS_invalid_stream); } else { Floor1 *g = &f->floor_config[floor].floor1; int j,q; int lx = 0, ly = finalY[0] * g->floor1_multiplier; for (q=1; q < g->values; ++q) { j = g->sorted_order[q]; #ifndef STB_VORBIS_NO_DEFER_FLOOR if (finalY[j] >= 0) #else if (step2_flag[j]) #endif { int hy = finalY[j] * g->floor1_multiplier; int hx = g->Xlist[j]; if (lx != hx) draw_line(target, lx,ly, hx,hy, n2); CHECK(f); lx = hx, ly = hy; } } if (lx < n2) { // optimization of: draw_line(target, lx,ly, n,ly, n2); for (j=lx; j < n2; ++j) LINE_OP(target[j], inverse_db_table[ly]); CHECK(f); } } return TRUE; } // The meaning of "left" and "right" // // For a given frame: // we compute samples from 0..n // window_center is n/2 // we'll window and mix the samples from left_start to left_end with data from the previous frame // all of the samples from left_end to right_start can be output without mixing; however, // this interval is 0-length except when transitioning between short and long frames // all of the samples from right_start to right_end need to be mixed with the next frame, // which we don't have, so those get saved in a buffer // frame N's right_end-right_start, the number of samples to mix with the next frame, // has to be the same as frame N+1's left_end-left_start (which they are by // construction) static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) { Mode *m; int i, n, prev, next, window_center; f->channel_buffer_start = f->channel_buffer_end = 0; retry: if (f->eof) return FALSE; if (!maybe_start_packet(f)) return FALSE; // check packet type if (get_bits(f,1) != 0) { if (IS_PUSH_MODE(f)) return error(f,VORBIS_bad_packet_type); while (EOP != get8_packet(f)); goto retry; } if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); i = get_bits(f, ilog(f->mode_count-1)); if (i == EOP) return FALSE; if (i >= f->mode_count) return FALSE; *mode = i; m = f->mode_config + i; if (m->blockflag) { n = f->blocksize_1; prev = get_bits(f,1); next = get_bits(f,1); } else { prev = next = 0; n = f->blocksize_0; } // WINDOWING window_center = n >> 1; if (m->blockflag && !prev) { *p_left_start = (n - f->blocksize_0) >> 2; *p_left_end = (n + f->blocksize_0) >> 2; } else { *p_left_start = 0; *p_left_end = window_center; } if (m->blockflag && !next) { *p_right_start = (n*3 - f->blocksize_0) >> 2; *p_right_end = (n*3 + f->blocksize_0) >> 2; } else { *p_right_start = window_center; *p_right_end = n; } return TRUE; } static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left) { Mapping *map; int i,j,k,n,n2; int zero_channel[256]; int really_zero_channel[256]; // WINDOWING n = f->blocksize[m->blockflag]; map = &f->mapping[m->mapping]; // FLOORS n2 = n >> 1; CHECK(f); for (i=0; i < f->channels; ++i) { int s = map->chan[i].mux, floor; zero_channel[i] = FALSE; floor = map->submap_floor[s]; if (f->floor_types[floor] == 0) { return error(f, VORBIS_invalid_stream); } else { Floor1 *g = &f->floor_config[floor].floor1; if (get_bits(f, 1)) { short *finalY; uint8 step2_flag[256]; static int range_list[4] = { 256, 128, 86, 64 }; int range = range_list[g->floor1_multiplier-1]; int offset = 2; finalY = f->finalY[i]; finalY[0] = get_bits(f, ilog(range)-1); finalY[1] = get_bits(f, ilog(range)-1); for (j=0; j < g->partitions; ++j) { int pclass = g->partition_class_list[j]; int cdim = g->class_dimensions[pclass]; int cbits = g->class_subclasses[pclass]; int csub = (1 << cbits)-1; int cval = 0; if (cbits) { Codebook *c = f->codebooks + g->class_masterbooks[pclass]; DECODE(cval,f,c); } for (k=0; k < cdim; ++k) { int book = g->subclass_books[pclass][cval & csub]; cval = cval >> cbits; if (book >= 0) { int temp; Codebook *c = f->codebooks + book; DECODE(temp,f,c); finalY[offset++] = temp; } else finalY[offset++] = 0; } } if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec step2_flag[0] = step2_flag[1] = 1; for (j=2; j < g->values; ++j) { int low, high, pred, highroom, lowroom, room, val; low = g->neighbors[j][0]; high = g->neighbors[j][1]; //neighbors(g->Xlist, j, &low, &high); pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); val = finalY[j]; highroom = range - pred; lowroom = pred; if (highroom < lowroom) room = highroom * 2; else room = lowroom * 2; if (val) { step2_flag[low] = step2_flag[high] = 1; step2_flag[j] = 1; if (val >= room) if (highroom > lowroom) finalY[j] = val - lowroom + pred; else finalY[j] = pred - val + highroom - 1; else if (val & 1) finalY[j] = pred - ((val+1)>>1); else finalY[j] = pred + (val>>1); } else { step2_flag[j] = 0; finalY[j] = pred; } } #ifdef STB_VORBIS_NO_DEFER_FLOOR do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); #else // defer final floor computation until _after_ residue for (j=0; j < g->values; ++j) { if (!step2_flag[j]) finalY[j] = -1; } #endif } else { error: zero_channel[i] = TRUE; } // So we just defer everything else to later // at this point we've decoded the floor into buffer } } CHECK(f); // at this point we've decoded all floors if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); // re-enable coupled channels if necessary memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); for (i=0; i < map->coupling_steps; ++i) if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; } CHECK(f); // RESIDUE DECODE for (i=0; i < map->submaps; ++i) { float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; int r; uint8 do_not_decode[256]; int ch = 0; for (j=0; j < f->channels; ++j) { if (map->chan[j].mux == i) { if (zero_channel[j]) { do_not_decode[ch] = TRUE; residue_buffers[ch] = NULL; } else { do_not_decode[ch] = FALSE; residue_buffers[ch] = f->channel_buffers[j]; } ++ch; } } r = map->submap_residue[i]; decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); } if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); CHECK(f); // INVERSE COUPLING for (i = map->coupling_steps-1; i >= 0; --i) { int n2 = n >> 1; float *m = f->channel_buffers[map->chan[i].magnitude]; float *a = f->channel_buffers[map->chan[i].angle ]; for (j=0; j < n2; ++j) { float a2,m2; if (m[j] > 0) if (a[j] > 0) m2 = m[j], a2 = m[j] - a[j]; else a2 = m[j], m2 = m[j] + a[j]; else if (a[j] > 0) m2 = m[j], a2 = m[j] + a[j]; else a2 = m[j], m2 = m[j] - a[j]; m[j] = m2; a[j] = a2; } } CHECK(f); // finish decoding the floors #ifndef STB_VORBIS_NO_DEFER_FLOOR for (i=0; i < f->channels; ++i) { if (really_zero_channel[i]) { memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); } else { do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); } } #else for (i=0; i < f->channels; ++i) { if (really_zero_channel[i]) { memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); } else { for (j=0; j < n2; ++j) f->channel_buffers[i][j] *= f->floor_buffers[i][j]; } } #endif // INVERSE MDCT CHECK(f); for (i=0; i < f->channels; ++i) inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); CHECK(f); // this shouldn't be necessary, unless we exited on an error // and want to flush to get to the next packet flush_packet(f); if (f->first_decode) { // assume we start so first non-discarded sample is sample 0 // this isn't to spec, but spec would require us to read ahead // and decode the size of all current frames--could be done, // but presumably it's not a commonly used feature f->current_loc = -n2; // start of first frame is positioned for discard // we might have to discard samples "from" the next frame too, // if we're lapping a large block then a small at the start? f->discard_samples_deferred = n - right_end; f->current_loc_valid = TRUE; f->first_decode = FALSE; } else if (f->discard_samples_deferred) { if (f->discard_samples_deferred >= right_start - left_start) { f->discard_samples_deferred -= (right_start - left_start); left_start = right_start; *p_left = left_start; } else { left_start += f->discard_samples_deferred; *p_left = left_start; f->discard_samples_deferred = 0; } } else if (f->previous_length == 0 && f->current_loc_valid) { // we're recovering from a seek... that means we're going to discard // the samples from this packet even though we know our position from // the last page header, so we need to update the position based on // the discarded samples here // but wait, the code below is going to add this in itself even // on a discard, so we don't need to do it here... } // check if we have ogg information about the sample # for this packet if (f->last_seg_which == f->end_seg_with_known_loc) { // if we have a valid current loc, and this is final: if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { uint32 current_end = f->known_loc_for_packet - (n-right_end); // then let's infer the size of the (probably) short final frame if (current_end < f->current_loc + (right_end-left_start)) { if (current_end < f->current_loc) { // negative truncation, that's impossible! *len = 0; } else { *len = current_end - f->current_loc; } *len += left_start; if (*len > right_end) *len = right_end; // this should never happen f->current_loc += *len; return TRUE; } } // otherwise, just set our sample loc // guess that the ogg granule pos refers to the _middle_ of the // last frame? // set f->current_loc to the position of left_start f->current_loc = f->known_loc_for_packet - (n2-left_start); f->current_loc_valid = TRUE; } if (f->current_loc_valid) f->current_loc += (right_start - left_start); if (f->alloc.alloc_buffer) assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); *len = right_end; // ignore samples after the window goes to 0 CHECK(f); return TRUE; } static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) { int mode, left_end, right_end; if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0; return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); } static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) { int prev,i,j; // we use right&left (the start of the right- and left-window sin()-regions) // to determine how much to return, rather than inferring from the rules // (same result, clearer code); 'left' indicates where our sin() window // starts, therefore where the previous window's right edge starts, and // therefore where to start mixing from the previous buffer. 'right' // indicates where our sin() ending-window starts, therefore that's where // we start saving, and where our returned-data ends. // mixin from previous window if (f->previous_length) { int i,j, n = f->previous_length; float *w = get_window(f, n); for (i=0; i < f->channels; ++i) { for (j=0; j < n; ++j) f->channel_buffers[i][left+j] = f->channel_buffers[i][left+j]*w[ j] + f->previous_window[i][ j]*w[n-1-j]; } } prev = f->previous_length; // last half of this data becomes previous window f->previous_length = len - right; // @OPTIMIZE: could avoid this copy by double-buffering the // output (flipping previous_window with channel_buffers), but // then previous_window would have to be 2x as large, and // channel_buffers couldn't be temp mem (although they're NOT // currently temp mem, they could be (unless we want to level // performance by spreading out the computation)) for (i=0; i < f->channels; ++i) for (j=0; right+j < len; ++j) f->previous_window[i][j] = f->channel_buffers[i][right+j]; if (!prev) // there was no previous packet, so this data isn't valid... // this isn't entirely true, only the would-have-overlapped data // isn't valid, but this seems to be what the spec requires return 0; // truncate a short frame if (len < right) right = len; f->samples_output += right-left; return right - left; } static void vorbis_pump_first_frame(stb_vorbis *f) { int len, right, left; if (vorbis_decode_packet(f, &len, &left, &right)) vorbis_finish_frame(f, len, left, right); } #ifndef STB_VORBIS_NO_PUSHDATA_API static int is_whole_packet_present(stb_vorbis *f, int end_page) { // make sure that we have the packet available before continuing... // this requires a full ogg parse, but we know we can fetch from f->stream // instead of coding this out explicitly, we could save the current read state, // read the next packet with get8() until end-of-packet, check f->eof, then // reset the state? but that would be slower, esp. since we'd have over 256 bytes // of state to restore (primarily the page segment table) int s = f->next_seg, first = TRUE; uint8 *p = f->stream; if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag for (; s < f->segment_count; ++s) { p += f->segments[s]; if (f->segments[s] < 255) // stop at first short segment break; } // either this continues, or it ends it... if (end_page) if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream); if (s == f->segment_count) s = -1; // set 'crosses page' flag if (p > f->stream_end) return error(f, VORBIS_need_more_data); first = FALSE; } for (; s == -1;) { uint8 *q; int n; // check that we have the page header ready if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data); // validate the page if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream); if (p[4] != 0) return error(f, VORBIS_invalid_stream); if (first) { // the first segment must NOT have 'continued_packet', later ones MUST if (f->previous_length) if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); // if no previous length, we're resynching, so we can come in on a continued-packet, // which we'll just drop } else { if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); } n = p[26]; // segment counts q = p+27; // q points to segment table p = q + n; // advance past header // make sure we've read the segment table if (p > f->stream_end) return error(f, VORBIS_need_more_data); for (s=0; s < n; ++s) { p += q[s]; if (q[s] < 255) break; } if (end_page) if (s < n-1) return error(f, VORBIS_invalid_stream); if (s == n) s = -1; // set 'crosses page' flag if (p > f->stream_end) return error(f, VORBIS_need_more_data); first = FALSE; } return TRUE; } #endif // !STB_VORBIS_NO_PUSHDATA_API static int start_decoder(vorb *f) { uint8 header[6], x,y; int len,i,j,k, max_submaps = 0; int longest_floorlist=0; // first page, first packet if (!start_page(f)) return FALSE; // validate page flag if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); // check for expected packet length if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); // read packet // check packet header if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); // vorbis_version if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); get32(f); // bitrate_maximum get32(f); // bitrate_nominal get32(f); // bitrate_minimum x = get8(f); { int log0,log1; log0 = x & 15; log1 = x >> 4; f->blocksize_0 = 1 << log0; f->blocksize_1 = 1 << log1; if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); if (log0 > log1) return error(f, VORBIS_invalid_setup); } // framing_flag x = get8(f); if (!(x & 1)) return error(f, VORBIS_invalid_first_page); // second packet! if (!start_page(f)) return FALSE; if (!start_packet(f)) return FALSE; do { len = next_segment(f); skip(f, len); f->bytes_in_seg = 0; } while (len); // third packet! if (!start_packet(f)) return FALSE; #ifndef STB_VORBIS_NO_PUSHDATA_API if (IS_PUSH_MODE(f)) { if (!is_whole_packet_present(f, TRUE)) { // convert error in ogg header to write type if (f->error == VORBIS_invalid_stream) f->error = VORBIS_invalid_setup; return FALSE; } } #endif crc32_init(); // always init it, to avoid multithread race conditions if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); for (i=0; i < 6; ++i) header[i] = get8_packet(f); if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); // codebooks f->codebook_count = get_bits(f,8) + 1; f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); if (f->codebooks == NULL) return error(f, VORBIS_outofmem); memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); for (i=0; i < f->codebook_count; ++i) { uint32 *values; int ordered, sorted_count; int total=0; uint8 *lengths; Codebook *c = f->codebooks+i; CHECK(f); x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); x = get_bits(f, 8); c->dimensions = (get_bits(f, 8)<<8) + x; x = get_bits(f, 8); y = get_bits(f, 8); c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; ordered = get_bits(f,1); c->sparse = ordered ? 0 : get_bits(f,1); if (c->dimensions == 0 && c->entries != 0) return error(f, VORBIS_invalid_setup); if (c->sparse) lengths = (uint8 *) setup_temp_malloc(f, c->entries); else lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); if (!lengths) return error(f, VORBIS_outofmem); if (ordered) { int current_entry = 0; int current_length = get_bits(f,5) + 1; while (current_entry < c->entries) { int limit = c->entries - current_entry; int n = get_bits(f, ilog(limit)); if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } memset(lengths + current_entry, current_length, n); current_entry += n; ++current_length; } } else { for (j=0; j < c->entries; ++j) { int present = c->sparse ? get_bits(f,1) : 1; if (present) { lengths[j] = get_bits(f, 5) + 1; ++total; if (lengths[j] == 32) return error(f, VORBIS_invalid_setup); } else { lengths[j] = NO_CODE; } } } if (c->sparse && total >= c->entries >> 2) { // convert sparse items to non-sparse! if (c->entries > (int) f->setup_temp_memory_required) f->setup_temp_memory_required = c->entries; c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); if (c->codeword_lengths == NULL) return error(f, VORBIS_outofmem); memcpy(c->codeword_lengths, lengths, c->entries); setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! lengths = c->codeword_lengths; c->sparse = 0; } // compute the size of the sorted tables if (c->sparse) { sorted_count = total; } else { sorted_count = 0; #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH for (j=0; j < c->entries; ++j) if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) ++sorted_count; #endif } c->sorted_entries = sorted_count; values = NULL; CHECK(f); if (!c->sparse) { c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); if (!c->codewords) return error(f, VORBIS_outofmem); } else { unsigned int size; if (c->sorted_entries) { c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); if (!c->codeword_lengths) return error(f, VORBIS_outofmem); c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); if (!c->codewords) return error(f, VORBIS_outofmem); values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); if (!values) return error(f, VORBIS_outofmem); } size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; if (size > f->setup_temp_memory_required) f->setup_temp_memory_required = size; } if (!compute_codewords(c, lengths, c->entries, values)) { if (c->sparse) setup_temp_free(f, values, 0); return error(f, VORBIS_invalid_setup); } if (c->sorted_entries) { // allocate an extra slot for sentinels c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); if (c->sorted_codewords == NULL) return error(f, VORBIS_outofmem); // allocate an extra slot at the front so that c->sorted_values[-1] is defined // so that we can catch that case without an extra if c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); if (c->sorted_values == NULL) return error(f, VORBIS_outofmem); ++c->sorted_values; c->sorted_values[-1] = -1; compute_sorted_huffman(c, lengths, values); } if (c->sparse) { setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); setup_temp_free(f, lengths, c->entries); c->codewords = NULL; } compute_accelerated_huffman(c); CHECK(f); c->lookup_type = get_bits(f, 4); if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); if (c->lookup_type > 0) { uint16 *mults; c->minimum_value = float32_unpack(get_bits(f, 32)); c->delta_value = float32_unpack(get_bits(f, 32)); c->value_bits = get_bits(f, 4)+1; c->sequence_p = get_bits(f,1); if (c->lookup_type == 1) { c->lookup_values = lookup1_values(c->entries, c->dimensions); } else { c->lookup_values = c->entries * c->dimensions; } if (c->lookup_values == 0) return error(f, VORBIS_invalid_setup); mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); if (mults == NULL) return error(f, VORBIS_outofmem); for (j=0; j < (int) c->lookup_values; ++j) { int q = get_bits(f, c->value_bits); if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } mults[j] = q; } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK if (c->lookup_type == 1) { int len, sparse = c->sparse; float last=0; // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop if (sparse) { if (c->sorted_entries == 0) goto skip; c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); } else c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } len = sparse ? c->sorted_entries : c->entries; for (j=0; j < len; ++j) { unsigned int z = sparse ? c->sorted_values[j] : j; unsigned int div=1; for (k=0; k < c->dimensions; ++k) { int off = (z / div) % c->lookup_values; float val = mults[off]; val = mults[off]*c->delta_value + c->minimum_value + last; c->multiplicands[j*c->dimensions + k] = val; if (c->sequence_p) last = val; if (k+1 < c->dimensions) { if (div > UINT_MAX / (unsigned int) c->lookup_values) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } div *= c->lookup_values; } } } setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); c->lookup_type = 2; } else #endif { float last=0; CHECK(f); c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); if (c->multiplicands == NULL) { setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } for (j=0; j < (int) c->lookup_values; ++j) { float val = mults[j] * c->delta_value + c->minimum_value + last; c->multiplicands[j] = val; if (c->sequence_p) last = val; } setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); } #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK skip:; #endif CHECK(f); } CHECK(f); } // time domain transfers (notused) x = get_bits(f, 6) + 1; for (i=0; i < x; ++i) { uint32 z = get_bits(f, 16); if (z != 0) return error(f, VORBIS_invalid_setup); } // Floors f->floor_count = get_bits(f, 6)+1; f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); if (f->floor_config == NULL) return error(f, VORBIS_outofmem); for (i=0; i < f->floor_count; ++i) { f->floor_types[i] = get_bits(f, 16); if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); if (f->floor_types[i] == 0) { Floor0 *g = &f->floor_config[i].floor0; g->order = get_bits(f,8); g->rate = get_bits(f,16); g->bark_map_size = get_bits(f,16); g->amplitude_bits = get_bits(f,6); g->amplitude_offset = get_bits(f,8); g->number_of_books = get_bits(f,4) + 1; for (j=0; j < g->number_of_books; ++j) g->book_list[j] = get_bits(f,8); return error(f, VORBIS_feature_not_supported); } else { Point p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; int max_class = -1; g->partitions = get_bits(f, 5); for (j=0; j < g->partitions; ++j) { g->partition_class_list[j] = get_bits(f, 4); if (g->partition_class_list[j] > max_class) max_class = g->partition_class_list[j]; } for (j=0; j <= max_class; ++j) { g->class_dimensions[j] = get_bits(f, 3)+1; g->class_subclasses[j] = get_bits(f, 2); if (g->class_subclasses[j]) { g->class_masterbooks[j] = get_bits(f, 8); if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } for (k=0; k < 1 << g->class_subclasses[j]; ++k) { g->subclass_books[j][k] = get_bits(f,8)-1; if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } } g->floor1_multiplier = get_bits(f,2)+1; g->rangebits = get_bits(f,4); g->Xlist[0] = 0; g->Xlist[1] = 1 << g->rangebits; g->values = 2; for (j=0; j < g->partitions; ++j) { int c = g->partition_class_list[j]; for (k=0; k < g->class_dimensions[c]; ++k) { g->Xlist[g->values] = get_bits(f, g->rangebits); ++g->values; } } // precompute the sorting for (j=0; j < g->values; ++j) { p[j].x = g->Xlist[j]; p[j].y = j; } qsort(p, g->values, sizeof(p[0]), point_compare); for (j=0; j < g->values; ++j) g->sorted_order[j] = (uint8) p[j].y; // precompute the neighbors for (j=2; j < g->values; ++j) { int low = 0, hi = 0; neighbors(g->Xlist, j, &low,&hi); g->neighbors[j][0] = low; g->neighbors[j][1] = hi; } if (g->values > longest_floorlist) longest_floorlist = g->values; } } // Residue f->residue_count = get_bits(f, 6)+1; f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(f->residue_config[0])); if (f->residue_config == NULL) return error(f, VORBIS_outofmem); memset(f->residue_config, 0, f->residue_count * sizeof(f->residue_config[0])); for (i=0; i < f->residue_count; ++i) { uint8 residue_cascade[64]; Residue *r = f->residue_config+i; f->residue_types[i] = get_bits(f, 16); if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); r->begin = get_bits(f, 24); r->end = get_bits(f, 24); if (r->end < r->begin) return error(f, VORBIS_invalid_setup); r->part_size = get_bits(f,24)+1; r->classifications = get_bits(f,6)+1; r->classbook = get_bits(f,8); if (r->classbook >= f->codebook_count) return error(f, VORBIS_invalid_setup); for (j=0; j < r->classifications; ++j) { uint8 high_bits=0; uint8 low_bits=get_bits(f,3); if (get_bits(f,1)) high_bits = get_bits(f,5); residue_cascade[j] = high_bits*8 + low_bits; } r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); if (r->residue_books == NULL) return error(f, VORBIS_outofmem); for (j=0; j < r->classifications; ++j) { for (k=0; k < 8; ++k) { if (residue_cascade[j] & (1 << k)) { r->residue_books[j][k] = get_bits(f, 8); if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); } else { r->residue_books[j][k] = -1; } } } // precompute the classifications[] array to avoid inner-loop mod/divide // call it 'classdata' since we already have r->classifications r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); if (!r->classdata) return error(f, VORBIS_outofmem); memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); for (j=0; j < f->codebooks[r->classbook].entries; ++j) { int classwords = f->codebooks[r->classbook].dimensions; int temp = j; r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); if (r->classdata[j] == NULL) return error(f, VORBIS_outofmem); for (k=classwords-1; k >= 0; --k) { r->classdata[j][k] = temp % r->classifications; temp /= r->classifications; } } } f->mapping_count = get_bits(f,6)+1; f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); if (f->mapping == NULL) return error(f, VORBIS_outofmem); memset(f->mapping, 0, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); if (m->chan == NULL) return error(f, VORBIS_outofmem); if (get_bits(f,1)) m->submaps = get_bits(f,4)+1; else m->submaps = 1; if (m->submaps > max_submaps) max_submaps = m->submaps; if (get_bits(f,1)) { m->coupling_steps = get_bits(f,8)+1; for (k=0; k < m->coupling_steps; ++k) { m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); m->chan[k].angle = get_bits(f, ilog(f->channels-1)); if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); } } else m->coupling_steps = 0; // reserved field if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); if (m->submaps > 1) { for (j=0; j < f->channels; ++j) { m->chan[j].mux = get_bits(f, 4); if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); } } else // @SPECIFICATION: this case is missing from the spec for (j=0; j < f->channels; ++j) m->chan[j].mux = 0; for (j=0; j < m->submaps; ++j) { get_bits(f,8); // discard m->submap_floor[j] = get_bits(f,8); m->submap_residue[j] = get_bits(f,8); if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); } } // Modes f->mode_count = get_bits(f, 6)+1; for (i=0; i < f->mode_count; ++i) { Mode *m = f->mode_config+i; m->blockflag = get_bits(f,1); m->windowtype = get_bits(f,16); m->transformtype = get_bits(f,16); m->mapping = get_bits(f,8); if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); } flush_packet(f); f->previous_length = 0; for (i=0; i < f->channels; ++i) { f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); if (f->channel_buffers[i] == NULL || f->previous_window[i] == NULL || f->finalY[i] == NULL) return error(f, VORBIS_outofmem); #ifdef STB_VORBIS_NO_DEFER_FLOOR f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); if (f->floor_buffers[i] == NULL) return error(f, VORBIS_outofmem); #endif } if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; f->blocksize[0] = f->blocksize_0; f->blocksize[1] = f->blocksize_1; #ifdef STB_VORBIS_DIVIDE_TABLE if (integer_divide_table[1][1]==0) for (i=0; i < DIVTAB_NUMER; ++i) for (j=1; j < DIVTAB_DENOM; ++j) integer_divide_table[i][j] = i / j; #endif // compute how much temporary memory is needed // 1. { uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); uint32 classify_mem; int i,max_part_read=0; for (i=0; i < f->residue_count; ++i) { Residue *r = f->residue_config + i; int n_read = r->end - r->begin; int part_read = n_read / r->part_size; if (part_read > max_part_read) max_part_read = part_read; } #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); #else classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); #endif f->temp_memory_required = classify_mem; if (imdct_mem > f->temp_memory_required) f->temp_memory_required = imdct_mem; } f->first_decode = TRUE; if (f->alloc.alloc_buffer) { assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); // check if there's enough temp memory so we don't error later if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) return error(f, VORBIS_outofmem); } f->first_audio_page_offset = stb_vorbis_get_file_offset(f); return TRUE; } static void vorbis_deinit(stb_vorbis *p) { int i,j; if (p->residue_config) { for (i=0; i < p->residue_count; ++i) { Residue *r = p->residue_config+i; if (r->classdata) { for (j=0; j < p->codebooks[r->classbook].entries; ++j) setup_free(p, r->classdata[j]); setup_free(p, r->classdata); } setup_free(p, r->residue_books); } } if (p->codebooks) { CHECK(p); for (i=0; i < p->codebook_count; ++i) { Codebook *c = p->codebooks + i; setup_free(p, c->codeword_lengths); setup_free(p, c->multiplicands); setup_free(p, c->codewords); setup_free(p, c->sorted_codewords); // c->sorted_values[-1] is the first entry in the array setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); } setup_free(p, p->codebooks); } setup_free(p, p->floor_config); setup_free(p, p->residue_config); if (p->mapping) { for (i=0; i < p->mapping_count; ++i) setup_free(p, p->mapping[i].chan); setup_free(p, p->mapping); } CHECK(p); for (i=0; i < p->channels && i < STB_VORBIS_MAX_CHANNELS; ++i) { setup_free(p, p->channel_buffers[i]); setup_free(p, p->previous_window[i]); #ifdef STB_VORBIS_NO_DEFER_FLOOR setup_free(p, p->floor_buffers[i]); #endif setup_free(p, p->finalY[i]); } for (i=0; i < 2; ++i) { setup_free(p, p->A[i]); setup_free(p, p->B[i]); setup_free(p, p->C[i]); setup_free(p, p->window[i]); setup_free(p, p->bit_reverse[i]); } #ifndef STB_VORBIS_NO_STDIO if (p->close_on_free) fclose(p->f); #endif } void stb_vorbis_close(stb_vorbis *p) { if (p == NULL) return; vorbis_deinit(p); setup_free(p,p); } static void vorbis_init(stb_vorbis *p, const stb_vorbis_alloc *z) { memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start if (z) { p->alloc = *z; p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; } p->eof = 0; p->error = VORBIS__no_error; p->stream = NULL; p->codebooks = NULL; p->page_crc_tests = -1; #ifndef STB_VORBIS_NO_STDIO p->close_on_free = FALSE; p->f = NULL; #endif } int stb_vorbis_get_sample_offset(stb_vorbis *f) { if (f->current_loc_valid) return f->current_loc; else return -1; } stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) { stb_vorbis_info d; d.channels = f->channels; d.sample_rate = f->sample_rate; d.setup_memory_required = f->setup_memory_required; d.setup_temp_memory_required = f->setup_temp_memory_required; d.temp_memory_required = f->temp_memory_required; d.max_frame_size = f->blocksize_1 >> 1; return d; } int stb_vorbis_get_error(stb_vorbis *f) { int e = f->error; f->error = VORBIS__no_error; return e; } static stb_vorbis * vorbis_alloc(stb_vorbis *f) { stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); return p; } #ifndef STB_VORBIS_NO_PUSHDATA_API void stb_vorbis_flush_pushdata(stb_vorbis *f) { f->previous_length = 0; f->page_crc_tests = 0; f->discard_samples_deferred = 0; f->current_loc_valid = FALSE; f->first_decode = FALSE; f->samples_output = 0; f->channel_buffer_start = 0; f->channel_buffer_end = 0; } static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) { int i,n; for (i=0; i < f->page_crc_tests; ++i) f->scan[i].bytes_done = 0; // if we have room for more scans, search for them first, because // they may cause us to stop early if their header is incomplete if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { if (data_len < 4) return 0; data_len -= 3; // need to look for 4-byte sequence, so don't miss // one that straddles a boundary for (i=0; i < data_len; ++i) { if (data[i] == 0x4f) { if (0==memcmp(data+i, ogg_page_header, 4)) { int j,len; uint32 crc; // make sure we have the whole page header if (i+26 >= data_len || i+27+data[i+26] >= data_len) { // only read up to this page start, so hopefully we'll // have the whole page header start next time data_len = i; break; } // ok, we have it all; compute the length of the page len = 27 + data[i+26]; for (j=0; j < data[i+26]; ++j) len += data[i+27+j]; // scan everything up to the embedded crc (which we must 0) crc = 0; for (j=0; j < 22; ++j) crc = crc32_update(crc, data[i+j]); // now process 4 0-bytes for ( ; j < 26; ++j) crc = crc32_update(crc, 0); // len is the total number of bytes we need to scan n = f->page_crc_tests++; f->scan[n].bytes_left = len-j; f->scan[n].crc_so_far = crc; f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24); // if the last frame on a page is continued to the next, then // we can't recover the sample_loc immediately if (data[i+27+data[i+26]-1] == 255) f->scan[n].sample_loc = ~0; else f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24); f->scan[n].bytes_done = i+j; if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) break; // keep going if we still have room for more } } } } for (i=0; i < f->page_crc_tests;) { uint32 crc; int j; int n = f->scan[i].bytes_done; int m = f->scan[i].bytes_left; if (m > data_len - n) m = data_len - n; // m is the bytes to scan in the current chunk crc = f->scan[i].crc_so_far; for (j=0; j < m; ++j) crc = crc32_update(crc, data[n+j]); f->scan[i].bytes_left -= m; f->scan[i].crc_so_far = crc; if (f->scan[i].bytes_left == 0) { // does it match? if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { // Houston, we have page data_len = n+m; // consumption amount is wherever that scan ended f->page_crc_tests = -1; // drop out of page scan mode f->previous_length = 0; // decode-but-don't-output one frame f->next_seg = -1; // start a new page f->current_loc = f->scan[i].sample_loc; // set the current sample location // to the amount we'd have decoded had we decoded this page f->current_loc_valid = f->current_loc != ~0U; return data_len; } // delete entry f->scan[i] = f->scan[--f->page_crc_tests]; } else { ++i; } } return data_len; } // return value: number of bytes we used int stb_vorbis_decode_frame_pushdata( stb_vorbis *f, // the file we're decoding const uint8 *data, int data_len, // the memory available for decoding int *channels, // place to write number of float * buffers float ***output, // place to write float ** array of float * buffers int *samples // place to write number of output samples ) { int i; int len,right,left; if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); if (f->page_crc_tests >= 0) { *samples = 0; return vorbis_search_for_page_pushdata(f, (uint8 *) data, data_len); } f->stream = (uint8 *) data; f->stream_end = (uint8 *) data + data_len; f->error = VORBIS__no_error; // check that we have the entire packet in memory if (!is_whole_packet_present(f, FALSE)) { *samples = 0; return 0; } if (!vorbis_decode_packet(f, &len, &left, &right)) { // save the actual error we encountered enum STBVorbisError error = f->error; if (error == VORBIS_bad_packet_type) { // flush and resynch f->error = VORBIS__no_error; while (get8_packet(f) != EOP) if (f->eof) break; *samples = 0; return f->stream - data; } if (error == VORBIS_continued_packet_flag_invalid) { if (f->previous_length == 0) { // we may be resynching, in which case it's ok to hit one // of these; just discard the packet f->error = VORBIS__no_error; while (get8_packet(f) != EOP) if (f->eof) break; *samples = 0; return f->stream - data; } } // if we get an error while parsing, what to do? // well, it DEFINITELY won't work to continue from where we are! stb_vorbis_flush_pushdata(f); // restore the error that actually made us bail f->error = error; *samples = 0; return 1; } // success! len = vorbis_finish_frame(f, len, left, right); for (i=0; i < f->channels; ++i) f->outputs[i] = f->channel_buffers[i] + left; if (channels) *channels = f->channels; *samples = len; *output = f->outputs; return f->stream - data; } stb_vorbis *stb_vorbis_open_pushdata( const unsigned char *data, int data_len, // the memory available for decoding int *data_used, // only defined if result is not NULL int *error, const stb_vorbis_alloc *alloc) { stb_vorbis *f, p; vorbis_init(&p, alloc); p.stream = (uint8 *) data; p.stream_end = (uint8 *) data + data_len; p.push_mode = TRUE; if (!start_decoder(&p)) { if (p.eof) *error = VORBIS_need_more_data; else *error = p.error; return NULL; } f = vorbis_alloc(&p); if (f) { *f = p; *data_used = f->stream - data; *error = 0; return f; } else { vorbis_deinit(&p); return NULL; } } #endif // STB_VORBIS_NO_PUSHDATA_API unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) { #ifndef STB_VORBIS_NO_PUSHDATA_API if (f->push_mode) return 0; #endif if (USE_MEMORY(f)) return f->stream - f->stream_start; #ifndef STB_VORBIS_NO_STDIO return ftell(f->f) - f->f_start; #endif } #ifndef STB_VORBIS_NO_PULLDATA_API // // DATA-PULLING API // static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) { for(;;) { int n; if (f->eof) return 0; n = get8(f); if (n == 0x4f) { // page header candidate unsigned int retry_loc = stb_vorbis_get_file_offset(f); int i; // check if we're off the end of a file_section stream if (retry_loc - 25 > f->stream_len) return 0; // check the rest of the header for (i=1; i < 4; ++i) if (get8(f) != ogg_page_header[i]) break; if (f->eof) return 0; if (i == 4) { uint8 header[27]; uint32 i, crc, goal, len; for (i=0; i < 4; ++i) header[i] = ogg_page_header[i]; for (; i < 27; ++i) header[i] = get8(f); if (f->eof) return 0; if (header[4] != 0) goto invalid; goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24); for (i=22; i < 26; ++i) header[i] = 0; crc = 0; for (i=0; i < 27; ++i) crc = crc32_update(crc, header[i]); len = 0; for (i=0; i < header[26]; ++i) { int s = get8(f); crc = crc32_update(crc, s); len += s; } if (len && f->eof) return 0; for (i=0; i < len; ++i) crc = crc32_update(crc, get8(f)); // finished parsing probable page if (crc == goal) { // we could now check that it's either got the last // page flag set, OR it's followed by the capture // pattern, but I guess TECHNICALLY you could have // a file with garbage between each ogg page and recover // from it automatically? So even though that paranoia // might decrease the chance of an invalid decode by // another 2^32, not worth it since it would hose those // invalid-but-useful files? if (end) *end = stb_vorbis_get_file_offset(f); if (last) { if (header[5] & 0x04) *last = 1; else *last = 0; } set_file_offset(f, retry_loc-1); return 1; } } invalid: // not a valid page, so rewind and look for next one set_file_offset(f, retry_loc); } } } #define SAMPLE_unknown 0xffffffff // seeking is implemented with a binary search, which narrows down the range to // 64K, before using a linear search (because finding the synchronization // pattern can be expensive, and the chance we'd find the end page again is // relatively high for small ranges) // // two initial interpolation-style probes are used at the start of the search // to try to bound either side of the binary search sensibly, while still // working in O(log n) time if they fail. static int get_seek_page_info(stb_vorbis *f, ProbedPage *z) { uint8 header[27], lacing[255]; int i,len; // record where the page starts z->page_start = stb_vorbis_get_file_offset(f); // parse the header getn(f, header, 27); if (header[0] != 'O' || header[1] != 'g' || header[2] != 'g' || header[3] != 'S') return 0; getn(f, lacing, header[26]); // determine the length of the payload len = 0; for (i=0; i < header[26]; ++i) len += lacing[i]; // this implies where the page ends z->page_end = z->page_start + 27 + header[26] + len; // read the last-decoded sample out of the data z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 24); // restore file state to where we were set_file_offset(f, z->page_start); return 1; } // rarely used function to seek back to the preceeding page while finding the // start of a packet static int go_to_page_before(stb_vorbis *f, unsigned int limit_offset) { unsigned int previous_safe, end; // now we want to seek back 64K from the limit if (limit_offset >= 65536 && limit_offset-65536 >= f->first_audio_page_offset) previous_safe = limit_offset - 65536; else previous_safe = f->first_audio_page_offset; set_file_offset(f, previous_safe); while (vorbis_find_page(f, &end, NULL)) { if (end >= limit_offset && stb_vorbis_get_file_offset(f) < limit_offset) return 1; set_file_offset(f, end); } return 0; } // implements the search logic for finding a page and starting decoding. if // the function succeeds, current_loc_valid will be true and current_loc will // be less than or equal to the provided sample number (the closer the // better). static int seek_to_sample_coarse(stb_vorbis *f, uint32 sample_number) { ProbedPage left, right, mid; int i, start_seg_with_known_loc, end_pos, page_start; uint32 delta, stream_length, padding; double offset = 0, bytes_per_sample = 0; int probe = 0; // find the last page and validate the target sample stream_length = stb_vorbis_stream_length_in_samples(f); if (stream_length == 0) return error(f, VORBIS_seek_without_length); if (sample_number > stream_length) return error(f, VORBIS_seek_invalid); // this is the maximum difference between the window-center (which is the // actual granule position value), and the right-start (which the spec // indicates should be the granule position (give or take one)). padding = ((f->blocksize_1 - f->blocksize_0) >> 2); if (sample_number < padding) sample_number = 0; else sample_number -= padding; left = f->p_first; while (left.last_decoded_sample == ~0U) { // (untested) the first page does not have a 'last_decoded_sample' set_file_offset(f, left.page_end); if (!get_seek_page_info(f, &left)) goto error; } right = f->p_last; assert(right.last_decoded_sample != ~0U); // starting from the start is handled differently if (sample_number <= left.last_decoded_sample) { stb_vorbis_seek_start(f); return 1; } while (left.page_end != right.page_start) { assert(left.page_end < right.page_start); // search range in bytes delta = right.page_start - left.page_end; if (delta <= 65536) { // there's only 64K left to search - handle it linearly set_file_offset(f, left.page_end); } else { if (probe < 2) { if (probe == 0) { // first probe (interpolate) double data_bytes = right.page_end - left.page_start; bytes_per_sample = data_bytes / right.last_decoded_sample; offset = left.page_start + bytes_per_sample * (sample_number - left.last_decoded_sample); } else { // second probe (try to bound the other side) double error = ((double) sample_number - mid.last_decoded_sample) * bytes_per_sample; if (error >= 0 && error < 8000) error = 8000; if (error < 0 && error > -8000) error = -8000; offset += error * 2; } // ensure the offset is valid if (offset < left.page_end) offset = left.page_end; if (offset > right.page_start - 65536) offset = right.page_start - 65536; set_file_offset(f, (unsigned int) offset); } else { // binary search for large ranges (offset by 32K to ensure // we don't hit the right page) set_file_offset(f, left.page_end + (delta / 2) - 32768); } if (!vorbis_find_page(f, NULL, NULL)) goto error; } for (;;) { if (!get_seek_page_info(f, &mid)) goto error; if (mid.last_decoded_sample != ~0U) break; // (untested) no frames end on this page set_file_offset(f, mid.page_end); assert(mid.page_start < right.page_start); } // if we've just found the last page again then we're in a tricky file, // and we're close enough. if (mid.page_start == right.page_start) break; if (sample_number < mid.last_decoded_sample) right = mid; else left = mid; ++probe; } // seek back to start of the last packet page_start = left.page_start; set_file_offset(f, page_start); if (!start_page(f)) return error(f, VORBIS_seek_failed); end_pos = f->end_seg_with_known_loc; assert(end_pos >= 0); for (;;) { for (i = end_pos; i > 0; --i) if (f->segments[i-1] != 255) break; start_seg_with_known_loc = i; if (start_seg_with_known_loc > 0 || !(f->page_flag & PAGEFLAG_continued_packet)) break; // (untested) the final packet begins on an earlier page if (!go_to_page_before(f, page_start)) goto error; page_start = stb_vorbis_get_file_offset(f); if (!start_page(f)) goto error; end_pos = f->segment_count - 1; } // prepare to start decoding f->current_loc_valid = FALSE; f->last_seg = FALSE; f->valid_bits = 0; f->packet_bytes = 0; f->bytes_in_seg = 0; f->previous_length = 0; f->next_seg = start_seg_with_known_loc; for (i = 0; i < start_seg_with_known_loc; i++) skip(f, f->segments[i]); // start decoding (optimizable - this frame is generally discarded) vorbis_pump_first_frame(f); return 1; error: // try to restore the file to a valid state stb_vorbis_seek_start(f); return error(f, VORBIS_seek_failed); } // the same as vorbis_decode_initial, but without advancing static int peek_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) { int bits_read, bytes_read; if (!vorbis_decode_initial(f, p_left_start, p_left_end, p_right_start, p_right_end, mode)) return 0; // either 1 or 2 bytes were read, figure out which so we can rewind bits_read = 1 + ilog(f->mode_count-1); if (f->mode_config[*mode].blockflag) bits_read += 2; bytes_read = (bits_read + 7) / 8; f->bytes_in_seg += bytes_read; f->packet_bytes -= bytes_read; skip(f, -bytes_read); if (f->next_seg == -1) f->next_seg = f->segment_count - 1; else f->next_seg--; f->valid_bits = 0; return 1; } int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) { uint32 max_frame_samples; if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); // fast page-level search if (!seek_to_sample_coarse(f, sample_number)) return 0; assert(f->current_loc_valid); assert(f->current_loc <= sample_number); // linear search for the relevant packet max_frame_samples = (f->blocksize_1*3 - f->blocksize_0) >> 2; while (f->current_loc < sample_number) { int left_start, left_end, right_start, right_end, mode, frame_samples; if (!peek_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) return error(f, VORBIS_seek_failed); // calculate the number of samples returned by the next frame frame_samples = right_start - left_start; if (f->current_loc + frame_samples > sample_number) { return 1; // the next frame will contain the sample } else if (f->current_loc + frame_samples + max_frame_samples > sample_number) { // there's a chance the frame after this could contain the sample vorbis_pump_first_frame(f); } else { // this frame is too early to be relevant f->current_loc += frame_samples; f->previous_length = 0; maybe_start_packet(f); flush_packet(f); } } // the next frame will start with the sample assert(f->current_loc == sample_number); return 1; } int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) { if (!stb_vorbis_seek_frame(f, sample_number)) return 0; if (sample_number != f->current_loc) { int n; uint32 frame_start = f->current_loc; stb_vorbis_get_frame_float(f, &n, NULL); assert(sample_number > frame_start); assert(f->channel_buffer_start + (int) (sample_number-frame_start) <= f->channel_buffer_end); f->channel_buffer_start += (sample_number - frame_start); } return 1; } void stb_vorbis_seek_start(stb_vorbis *f) { if (IS_PUSH_MODE(f)) { error(f, VORBIS_invalid_api_mixing); return; } set_file_offset(f, f->first_audio_page_offset); f->previous_length = 0; f->first_decode = TRUE; f->next_seg = -1; vorbis_pump_first_frame(f); } unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) { unsigned int restore_offset, previous_safe; unsigned int end, last_page_loc; if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); if (!f->total_samples) { unsigned int last; uint32 lo,hi; char header[6]; // first, store the current decode position so we can restore it restore_offset = stb_vorbis_get_file_offset(f); // now we want to seek back 64K from the end (the last page must // be at most a little less than 64K, but let's allow a little slop) if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) previous_safe = f->stream_len - 65536; else previous_safe = f->first_audio_page_offset; set_file_offset(f, previous_safe); // previous_safe is now our candidate 'earliest known place that seeking // to will lead to the final page' if (!vorbis_find_page(f, &end, &last)) { // if we can't find a page, we're hosed! f->error = VORBIS_cant_find_last_page; f->total_samples = 0xffffffff; goto done; } // check if there are more pages last_page_loc = stb_vorbis_get_file_offset(f); // stop when the last_page flag is set, not when we reach eof; // this allows us to stop short of a 'file_section' end without // explicitly checking the length of the section while (!last) { set_file_offset(f, end); if (!vorbis_find_page(f, &end, &last)) { // the last page we found didn't have the 'last page' flag // set. whoops! break; } previous_safe = last_page_loc+1; last_page_loc = stb_vorbis_get_file_offset(f); } set_file_offset(f, last_page_loc); // parse the header getn(f, (unsigned char *)header, 6); // extract the absolute granule position lo = get32(f); hi = get32(f); if (lo == 0xffffffff && hi == 0xffffffff) { f->error = VORBIS_cant_find_last_page; f->total_samples = SAMPLE_unknown; goto done; } if (hi) lo = 0xfffffffe; // saturate f->total_samples = lo; f->p_last.page_start = last_page_loc; f->p_last.page_end = end; f->p_last.last_decoded_sample = lo; done: set_file_offset(f, restore_offset); } return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; } float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) { return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; } int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) { int len, right,left,i; if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); if (!vorbis_decode_packet(f, &len, &left, &right)) { f->channel_buffer_start = f->channel_buffer_end = 0; return 0; } len = vorbis_finish_frame(f, len, left, right); for (i=0; i < f->channels; ++i) f->outputs[i] = f->channel_buffers[i] + left; f->channel_buffer_start = left; f->channel_buffer_end = left+len; if (channels) *channels = f->channels; if (output) *output = f->outputs; return len; } #ifndef STB_VORBIS_NO_STDIO stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc, unsigned int length) { stb_vorbis *f, p; vorbis_init(&p, alloc); p.f = file; p.f_start = ftell(file); p.stream_len = length; p.close_on_free = close_on_free; if (start_decoder(&p)) { f = vorbis_alloc(&p); if (f) { *f = p; vorbis_pump_first_frame(f); return f; } } if (error) *error = p.error; vorbis_deinit(&p); return NULL; } stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, const stb_vorbis_alloc *alloc) { unsigned int len, start; start = ftell(file); fseek(file, 0, SEEK_END); len = ftell(file) - start; fseek(file, start, SEEK_SET); return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); } stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, const stb_vorbis_alloc *alloc) { FILE *f = fopen(filename, "rb"); if (f) return stb_vorbis_open_file(f, TRUE, error, alloc); if (error) *error = VORBIS_file_open_failure; return NULL; } #endif // STB_VORBIS_NO_STDIO stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, const stb_vorbis_alloc *alloc) { stb_vorbis *f, p; if (data == NULL) return NULL; vorbis_init(&p, alloc); p.stream = (uint8 *) data; p.stream_end = (uint8 *) data + len; p.stream_start = (uint8 *) p.stream; p.stream_len = len; p.push_mode = FALSE; if (start_decoder(&p)) { f = vorbis_alloc(&p); if (f) { *f = p; vorbis_pump_first_frame(f); return f; } } if (error) *error = p.error; vorbis_deinit(&p); return NULL; } #ifndef STB_VORBIS_NO_INTEGER_CONVERSION #define PLAYBACK_MONO 1 #define PLAYBACK_LEFT 2 #define PLAYBACK_RIGHT 4 #define L (PLAYBACK_LEFT | PLAYBACK_MONO) #define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO) #define R (PLAYBACK_RIGHT | PLAYBACK_MONO) static int8 channel_position[7][6] = { { 0 }, { C }, { L, R }, { L, C, R }, { L, R, L, R }, { L, C, R, L, R }, { L, C, R, L, R, C }, }; #ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT typedef union { float f; int i; } float_conv; typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4]; #define FASTDEF(x) float_conv x // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) #define check_endianness() #else #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) #define check_endianness() #define FASTDEF(x) #endif static void copy_samples(short *dest, float *src, int len) { int i; check_endianness(); for (i=0; i < len; ++i) { FASTDEF(temp); int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; dest[i] = v; } } static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) { #define BUFFER_SIZE 32 float buffer[BUFFER_SIZE]; int i,j,o,n = BUFFER_SIZE; check_endianness(); for (o = 0; o < len; o += BUFFER_SIZE) { memset(buffer, 0, sizeof(buffer)); if (o + n > len) n = len - o; for (j=0; j < num_c; ++j) { if (channel_position[num_c][j] & mask) { for (i=0; i < n; ++i) buffer[i] += data[j][d_offset+o+i]; } } for (i=0; i < n; ++i) { FASTDEF(temp); int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; output[o+i] = v; } } } static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) { #define BUFFER_SIZE 32 float buffer[BUFFER_SIZE]; int i,j,o,n = BUFFER_SIZE >> 1; // o is the offset in the source data check_endianness(); for (o = 0; o < len; o += BUFFER_SIZE >> 1) { // o2 is the offset in the output data int o2 = o << 1; memset(buffer, 0, sizeof(buffer)); if (o + n > len) n = len - o; for (j=0; j < num_c; ++j) { int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { for (i=0; i < n; ++i) { buffer[i*2+0] += data[j][d_offset+o+i]; buffer[i*2+1] += data[j][d_offset+o+i]; } } else if (m == PLAYBACK_LEFT) { for (i=0; i < n; ++i) { buffer[i*2+0] += data[j][d_offset+o+i]; } } else if (m == PLAYBACK_RIGHT) { for (i=0; i < n; ++i) { buffer[i*2+1] += data[j][d_offset+o+i]; } } } for (i=0; i < (n<<1); ++i) { FASTDEF(temp); int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; output[o2+i] = v; } } } static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) { int i; if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} }; for (i=0; i < buf_c; ++i) compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples); } else { int limit = buf_c < data_c ? buf_c : data_c; for (i=0; i < limit; ++i) copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples); for ( ; i < buf_c; ++i) memset(buffer[i]+b_offset, 0, sizeof(short) * samples); } } int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) { float **output; int len = stb_vorbis_get_frame_float(f, NULL, &output); if (len > num_samples) len = num_samples; if (len) convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); return len; } static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len) { int i; check_endianness(); if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { assert(buf_c == 2); for (i=0; i < buf_c; ++i) compute_stereo_samples(buffer, data_c, data, d_offset, len); } else { int limit = buf_c < data_c ? buf_c : data_c; int j; for (j=0; j < len; ++j) { for (i=0; i < limit; ++i) { FASTDEF(temp); float f = data[i][d_offset+j]; int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15); if ((unsigned int) (v + 32768) > 65535) v = v < 0 ? -32768 : 32767; *buffer++ = v; } for ( ; i < buf_c; ++i) *buffer++ = 0; } } } int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) { float **output; int len; if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); len = stb_vorbis_get_frame_float(f, NULL, &output); if (len) { if (len*num_c > num_shorts) len = num_shorts / num_c; convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); } return len; } int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) { float **outputs; int len = num_shorts / channels; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < len) { int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; if (k) convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k); buffer += k*channels; n += k; f->channel_buffer_start += k; if (n == len) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) { float **outputs; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < len) { int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; if (k) convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); n += k; f->channel_buffer_start += k; if (n == len) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } #ifndef STB_VORBIS_NO_STDIO int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) { int data_len, offset, total, limit, error; short *data; stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); if (v == NULL) return -1; limit = v->channels * 4096; *channels = v->channels; if (sample_rate) *sample_rate = v->sample_rate; offset = data_len = 0; total = limit; data = (short *) malloc(total * sizeof(*data)); if (data == NULL) { stb_vorbis_close(v); return -2; } for (;;) { int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); if (n == 0) break; data_len += n; offset += n * v->channels; if (offset + limit > total) { short *data2; total *= 2; data2 = (short *) realloc(data, total * sizeof(*data)); if (data2 == NULL) { free(data); stb_vorbis_close(v); return -2; } data = data2; } } *output = data; stb_vorbis_close(v); return data_len; } #endif // NO_STDIO int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) { int data_len, offset, total, limit, error; short *data; stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); if (v == NULL) return -1; limit = v->channels * 4096; *channels = v->channels; if (sample_rate) *sample_rate = v->sample_rate; offset = data_len = 0; total = limit; data = (short *) malloc(total * sizeof(*data)); if (data == NULL) { stb_vorbis_close(v); return -2; } for (;;) { int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); if (n == 0) break; data_len += n; offset += n * v->channels; if (offset + limit > total) { short *data2; total *= 2; data2 = (short *) realloc(data, total * sizeof(*data)); if (data2 == NULL) { free(data); stb_vorbis_close(v); return -2; } data = data2; } } *output = data; stb_vorbis_close(v); return data_len; } #endif // STB_VORBIS_NO_INTEGER_CONVERSION int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) { float **outputs; int len = num_floats / channels; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < len) { int i,j; int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= len) k = len - n; for (j=0; j < k; ++j) { for (i=0; i < z; ++i) *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j]; for ( ; i < channels; ++i) *buffer++ = 0; } n += k; f->channel_buffer_start += k; if (n == len) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) { float **outputs; int n=0; int z = f->channels; if (z > channels) z = channels; while (n < num_samples) { int i; int k = f->channel_buffer_end - f->channel_buffer_start; if (n+k >= num_samples) k = num_samples - n; if (k) { for (i=0; i < z; ++i) memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); for ( ; i < channels; ++i) memset(buffer[i]+n, 0, sizeof(float) * k); } n += k; f->channel_buffer_start += k; if (n == num_samples) break; if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; } return n; } #endif // STB_VORBIS_NO_PULLDATA_API /* Version history 1.07 - 2015/01/16 - fixed some warnings, fix mingw, const-correct API some more crash fixes when out of memory or with corrupt files 1.06 - 2015/08/31 - full, correct support for seeking API (Dougall Johnson) some crash fixes when out of memory or with corrupt files 1.05 - 2015/04/19 - don't define __forceinline if it's redundant 1.04 - 2014/08/27 - fix missing const-correct case in API 1.03 - 2014/08/07 - Warning fixes 1.02 - 2014/07/09 - Declare qsort compare function _cdecl on windows 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in multichannel (API change) report sample rate for decode-full-file funcs 0.99996 - bracket #include <malloc.h> for macintosh compilation by Laurent Gomila 0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem 0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence 0.99993 - remove assert that fired on legal files with empty tables 0.99992 - rewind-to-start 0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo 0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++ 0.9998 - add a full-decode function with a memory source 0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition 0.9996 - query length of vorbis stream in samples/seconds 0.9995 - bugfix to another optimization that only happened in certain files 0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors 0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation 0.9992 - performance improvement of IMDCT; now performs close to reference implementation 0.9991 - performance improvement of IMDCT 0.999 - (should have been 0.9990) performance improvement of IMDCT 0.998 - no-CRT support from Casey Muratori 0.997 - bugfixes for bugs found by Terje Mathisen 0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen 0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen 0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen 0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen 0.992 - fixes for MinGW warning 0.991 - turn fast-float-conversion on by default 0.990 - fix push-mode seek recovery if you seek into the headers 0.98b - fix to bad release of 0.98 0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode 0.97 - builds under c++ (typecasting, don't use 'class' keyword) 0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code 0.95 - clamping code for 16-bit functions 0.94 - not publically released 0.93 - fixed all-zero-floor case (was decoding garbage) 0.92 - fixed a memory leak 0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION 0.90 - first public release */ #endif // STB_VORBIS_HEADER_ONLY
the_stack_data/31388280.c
// RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD %s // CHECK-LD: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-LD: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // Check for --eh-frame-hdr being passed with static linking // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD-STATIC-EH %s // CHECK-LD-STATIC-EH: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-LD-STATIC-EH: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bstatic" "-o" "a.out" "{{.*}}rcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pg -pthread %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-PG %s // CHECK-PG: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-PG: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-nopie" "-o" "a.out" "{{.*}}gcrt0.o" "{{.*}}crtbegin.o" "{{.*}}.o" "-lcompiler_rt" "-lpthread_p" "-lc_p" "-lcompiler_rt" "{{.*}}crtend.o" // Check CPU type for MIPS64 // RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-MIPS64-CPU %s // RUN: %clang -target mips64el-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-MIPS64EL-CPU %s // CHECK-MIPS64-CPU: "-target-cpu" "mips3" // CHECK-MIPS64EL-CPU: "-target-cpu" "mips3" // Check that the new linker flags are passed to OpenBSD // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -r %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD-R %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -s %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD-S %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -t %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD-T %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -Z %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-LD-Z %s // RUN: %clang -no-canonical-prefixes -target mips64-unknown-openbsd %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64-LD %s // RUN: %clang -no-canonical-prefixes -target mips64el-unknown-openbsd %s -### 2>&1 \ // RUN: | FileCheck --check-prefix=CHECK-MIPS64EL-LD %s // CHECK-LD-R: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-LD-R: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-r" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // CHECK-LD-S: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-LD-S: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-s" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // CHECK-LD-T: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-LD-T: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-t" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // CHECK-LD-Z: clang{{.*}}" "-cc1" "-triple" "i686-pc-openbsd" // CHECK-LD-Z: ld{{.*}}" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "-Z" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // CHECK-MIPS64-LD: clang{{.*}}" "-cc1" "-triple" "mips64-unknown-openbsd" // CHECK-MIPS64-LD: ld{{.*}}" "-EB" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // CHECK-MIPS64EL-LD: clang{{.*}}" "-cc1" "-triple" "mips64el-unknown-openbsd" // CHECK-MIPS64EL-LD: ld{{.*}}" "-EL" "-e" "__start" "--eh-frame-hdr" "-Bdynamic" "-dynamic-linker" "{{.*}}ld.so" "-o" "a.out" "{{.*}}crt0.o" "{{.*}}crtbegin.o" "-L{{.*}}" "{{.*}}.o" "-lcompiler_rt" "-lc" "-lcompiler_rt" "{{.*}}crtend.o" // Check passing options to the assembler for various OpenBSD targets // RUN: %clang -target amd64-pc-openbsd -m32 -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-AMD64-M32 %s // RUN: %clang -target powerpc-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-POWERPC %s // RUN: %clang -target sparc-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SPARC %s // RUN: %clang -target sparc64-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-SPARC64 %s // RUN: %clang -target mips64-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-MIPS64 %s // RUN: %clang -target mips64-unknown-openbsd -fPIC -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-MIPS64-PIC %s // RUN: %clang -target mips64el-unknown-openbsd -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-MIPS64EL %s // RUN: %clang -target mips64el-unknown-openbsd -fPIC -### -no-integrated-as -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-MIPS64EL-PIC %s // CHECK-AMD64-M32: as{{.*}}" "--32" // CHECK-POWERPC: as{{.*}}" "-mppc" "-many" // CHECK-SPARC: as{{.*}}" "-32" "-Av8" // CHECK-SPARC64: as{{.*}}" "-64" "-Av9" // CHECK-MIPS64: as{{.*}}" "-mabi" "64" "-EB" // CHECK-MIPS64-PIC: as{{.*}}" "-mabi" "64" "-EB" "-KPIC" // CHECK-MIPS64EL: as{{.*}}" "-mabi" "64" "-EL" // CHECK-MIPS64EL-PIC: as{{.*}}" "-mabi" "64" "-EL" "-KPIC" // Check that the integrated assembler is enabled for MIPS64/SPARC // RUN: %clang -target mips64-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-IAS %s // RUN: %clang -target mips64el-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-IAS %s // RUN: %clang -target sparc-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-IAS %s // RUN: %clang -target sparc64-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-IAS %s // CHECK-IAS-NOT: "-no-integrated-as" // Check linking against correct startup code when (not) using PIE // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -pie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE-FLAG %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-PIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-STATIC-PIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -fno-pie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-STATIC-PIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -nopie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-NOPIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie -nopie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-NOPIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -static -nopie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-NOPIE %s // RUN: %clang -no-canonical-prefixes -target i686-pc-openbsd -fno-pie -static -nopie %s -### 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-NOPIE %s // CHECK-PIE: "{{.*}}crt0.o" // CHECK-PIE-NOT: "-nopie" // CHECK-PIE-FLAG: "-pie" // CHECK-STATIC-PIE: "{{.*}}rcrt0.o" // CHECK-STATIC-PIE-NOT: "-nopie" // CHECK-NOPIE: "-nopie" "{{.*}}crt0.o" // Check ARM float ABI // RUN: %clang -target arm-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ARM-FLOAT-ABI %s // CHECK-ARM-FLOAT-ABI-NOT: "-target-feature" "+soft-float" // CHECK-ARM-FLOAT-ABI: "-target-feature" "+soft-float-abi" // Check PowerPC for Secure PLT // RUN: %clang -target powerpc-unknown-openbsd -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-POWERPC-SECUREPLT %s // CHECK-POWERPC-SECUREPLT: "-target-feature" "+secure-plt"
the_stack_data/25138368.c
/* Code generated from eC source file: CustomAVLTree.ec */ #if defined(__GNUC__) typedef long long int64; typedef unsigned long long uint64; #ifndef _WIN32 #define __declspec(x) #endif #elif defined(__TINYC__) #include <stdarg.h> #define __builtin_va_list va_list #define __builtin_va_start va_start #define __builtin_va_end va_end #ifdef _WIN32 #define strcasecmp stricmp #define strncasecmp strnicmp #define __declspec(x) __attribute__((x)) #else #define __declspec(x) #endif typedef long long int64; typedef unsigned long long uint64; #else typedef __int64 int64; typedef unsigned __int64 uint64; #endif #ifdef __BIG_ENDIAN__ #define __ENDIAN_PAD(x) (8 - (x)) #else #define __ENDIAN_PAD(x) 0 #endif #include <stdint.h> #include <sys/types.h> #if /*defined(_W64) || */(defined(__WORDSIZE) && __WORDSIZE == 8) || defined(__x86_64__) #define _64BIT 1 #else #define _64BIT 0 #endif #define arch_PointerSize sizeof(void *) #define structSize_Instance (_64BIT ? 24 : 12) #define AVLNode_PrivateData (_64BIT ? 32 : 16) #define _STR(x) #x #define _XSTR(x) _STR(x) extern void * __ecereNameSpace__ecere__com__eSystem_New(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_New0(unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew(void * memory, unsigned int size); extern void * __ecereNameSpace__ecere__com__eSystem_Renew0(void * memory, unsigned int size); extern void __ecereNameSpace__ecere__com__eSystem_Delete(void * memory); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BTNode; struct __ecereNameSpace__ecere__sys__BTNode; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__BinaryTree; struct __ecereNameSpace__ecere__sys__BinaryTree { struct __ecereNameSpace__ecere__sys__BTNode * root; int count; int (* CompareKey)(struct __ecereNameSpace__ecere__sys__BinaryTree * tree, uintptr_t a, uintptr_t b); void (* FreeKey)(void * key); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__sys__OldList; struct __ecereNameSpace__ecere__sys__OldList { void * first; void * last; int count; unsigned int offset; unsigned int circ; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Class; struct __ecereNameSpace__ecere__com__Class { struct __ecereNameSpace__ecere__com__Class * prev; struct __ecereNameSpace__ecere__com__Class * next; char * name; int offset; int structSize; int (* * _vTbl)(); int vTblSize; int (* Constructor)(struct __ecereNameSpace__ecere__com__Instance *); void (* Destructor)(struct __ecereNameSpace__ecere__com__Instance *); int offsetClass; int sizeClass; struct __ecereNameSpace__ecere__com__Class * base; struct __ecereNameSpace__ecere__sys__BinaryTree methods; struct __ecereNameSpace__ecere__sys__BinaryTree members; struct __ecereNameSpace__ecere__sys__BinaryTree prop; struct __ecereNameSpace__ecere__sys__OldList membersAndProperties; struct __ecereNameSpace__ecere__sys__BinaryTree classProperties; struct __ecereNameSpace__ecere__sys__OldList derivatives; int memberID; int startMemberID; int type; struct __ecereNameSpace__ecere__com__Instance * module; struct __ecereNameSpace__ecere__com__NameSpace * nameSpace; char * dataTypeString; struct __ecereNameSpace__ecere__com__Instance * dataType; int typeSize; int defaultAlignment; void (* Initialize)(); int memberOffset; struct __ecereNameSpace__ecere__sys__OldList selfWatchers; char * designerClass; unsigned int noExpansion; char * defaultProperty; unsigned int comRedefinition; int count; unsigned int isRemote; unsigned int internalDecl; void * data; unsigned int computeSize; int structAlignment; int destructionWatchOffset; unsigned int fixed; struct __ecereNameSpace__ecere__sys__OldList delayedCPValues; int inheritanceAccess; char * fullName; void * symbol; struct __ecereNameSpace__ecere__sys__OldList conversions; struct __ecereNameSpace__ecere__sys__OldList templateParams; struct __ecereNameSpace__ecere__com__ClassTemplateArgument * templateArgs; struct __ecereNameSpace__ecere__com__Class * templateClass; struct __ecereNameSpace__ecere__sys__OldList templatized; int numParams; unsigned int isInstanceClass; unsigned int byValueSystemClass; } __attribute__ ((gcc_struct)); extern long long __ecereNameSpace__ecere__com__eClass_GetProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Property; struct __ecereNameSpace__ecere__com__Property { struct __ecereNameSpace__ecere__com__Property * prev; struct __ecereNameSpace__ecere__com__Property * next; char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct __ecereNameSpace__ecere__com__Instance * dataType; void (* Set)(void * , int); int (* Get)(void * ); unsigned int (* IsSet)(void * ); void * data; void * symbol; int vid; unsigned int conversion; unsigned int watcherOffset; char * category; unsigned int compiled; unsigned int selfWatchable; unsigned int isWatchable; } __attribute__ ((gcc_struct)); extern void __ecereNameSpace__ecere__com__eInstance_FireSelfWatchers(struct __ecereNameSpace__ecere__com__Instance * instance, struct __ecereNameSpace__ecere__com__Property * _property); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Instance; struct __ecereNameSpace__ecere__com__Instance { int (* * _vTbl)(); struct __ecereNameSpace__ecere__com__Class * _class; int _refCount; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataMember; struct __ecereNameSpace__ecere__com__DataMember { struct __ecereNameSpace__ecere__com__DataMember * prev; struct __ecereNameSpace__ecere__com__DataMember * next; char * name; unsigned int isProperty; int memberAccess; int id; struct __ecereNameSpace__ecere__com__Class * _class; char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; struct __ecereNameSpace__ecere__com__Instance * dataType; int type; int offset; int memberID; struct __ecereNameSpace__ecere__sys__OldList members; struct __ecereNameSpace__ecere__sys__BinaryTree membersAlpha; int memberOffset; int structAlignment; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Method; struct __ecereNameSpace__ecere__com__Method { char * name; struct __ecereNameSpace__ecere__com__Method * parent; struct __ecereNameSpace__ecere__com__Method * left; struct __ecereNameSpace__ecere__com__Method * right; int depth; int (* function)(); int vid; int type; struct __ecereNameSpace__ecere__com__Class * _class; void * symbol; char * dataTypeString; struct __ecereNameSpace__ecere__com__Instance * dataType; int memberAccess; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__SerialBuffer; struct __ecereNameSpace__ecere__com__SerialBuffer { unsigned char * _buffer; unsigned int count; unsigned int _size; unsigned int pos; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__DataValue; struct __ecereNameSpace__ecere__com__DataValue { union { char c; unsigned char uc; short s; unsigned short us; int i; unsigned int ui; void * p; float f; double d; long long i64; uint64 ui64; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateArgument; struct __ecereNameSpace__ecere__com__ClassTemplateArgument { union { struct { char * dataTypeString; struct __ecereNameSpace__ecere__com__Class * dataTypeClass; } __attribute__ ((gcc_struct)); struct __ecereNameSpace__ecere__com__DataValue expression; struct { char * memberString; union { struct __ecereNameSpace__ecere__com__DataMember * member; struct __ecereNameSpace__ecere__com__Property * prop; struct __ecereNameSpace__ecere__com__Method * method; } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); } __attribute__ ((gcc_struct)); extern int __ecereVMethodID_class_OnCompare; extern int __ecereVMethodID_class_OnCopy; static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_prev, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_prev; static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_next, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_next; static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_count, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_count; static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_depthProp, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_depthProp; static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_balanceFactor, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_balanceFactor; struct __ecereNameSpace__ecere__com__AVLNode { struct __ecereNameSpace__ecere__com__AVLNode * parent, * left, * right; int depth; uint64 key; } __attribute__ ((gcc_struct)); static struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__AVLNode; struct __ecereNameSpace__ecere__com__AVLNode * __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_maximum(struct __ecereNameSpace__ecere__com__AVLNode * this); static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_maximum, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_maximum; struct __ecereNameSpace__ecere__com__AVLNode * __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_prev(struct __ecereNameSpace__ecere__com__AVLNode * this) { if(this->left) return __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_maximum(this->left); while(this) { if(this->parent && this == this->parent->right) return this->parent; else this = this->parent; } return this; } struct __ecereNameSpace__ecere__com__AVLNode * __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_minimum(struct __ecereNameSpace__ecere__com__AVLNode * this); static struct __ecereNameSpace__ecere__com__Property * __ecereProp___ecereNameSpace__ecere__com__AVLNode_minimum, * __ecerePropM___ecereNameSpace__ecere__com__AVLNode_minimum; struct __ecereNameSpace__ecere__com__AVLNode * __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_next(struct __ecereNameSpace__ecere__com__AVLNode * this) { struct __ecereNameSpace__ecere__com__AVLNode * right = this->right; if(right) return __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_minimum(right); while(this) { struct __ecereNameSpace__ecere__com__AVLNode * parent = this->parent; if(parent && this == parent->left) return parent; else this = parent; } return (((void *)0)); } struct __ecereNameSpace__ecere__com__AVLNode * __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_minimum(struct __ecereNameSpace__ecere__com__AVLNode * this) { while(this->left) this = this->left; return this; } struct __ecereNameSpace__ecere__com__AVLNode * __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_maximum(struct __ecereNameSpace__ecere__com__AVLNode * this) { while(this->right) this = this->right; return this; } int __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_count(struct __ecereNameSpace__ecere__com__AVLNode * this) { return 1 + (this->left ? __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_count(this->left) : 0) + (this->right ? __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_count(this->right) : 0); } int __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_depthProp(struct __ecereNameSpace__ecere__com__AVLNode * this) { int leftDepth = this->left ? (__ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_depthProp(this->left) + 1) : 0; int rightDepth = this->right ? (__ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_depthProp(this->right) + 1) : 0; return ((leftDepth > rightDepth) ? leftDepth : rightDepth); } extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__IteratorPointer; void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Free(struct __ecereNameSpace__ecere__com__AVLNode * this) { if(this->left) __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Free(this->left); if(this->right) __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Free(this->right); ((this ? (__ecereClass___ecereNameSpace__ecere__com__AVLNode->Destructor ? __ecereClass___ecereNameSpace__ecere__com__AVLNode->Destructor(this) : 0, __ecereClass___ecereNameSpace__ecere__com__IteratorPointer->Destructor ? __ecereClass___ecereNameSpace__ecere__com__IteratorPointer->Destructor(this) : 0, __ecereNameSpace__ecere__com__eSystem_Delete(this)) : 0), this = 0); } extern struct __ecereNameSpace__ecere__com__Class * __ecereClass_uint64; unsigned int __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Add(struct __ecereNameSpace__ecere__com__AVLNode * this, struct __ecereNameSpace__ecere__com__Class * Tclass, struct __ecereNameSpace__ecere__com__AVLNode * node) { uint64 newKey = node->key; if(!Tclass) Tclass = __ecereClass_uint64; while(0x1) { int result = ((int (*)(void *, void *, void *))(void *)Tclass->_vTbl[__ecereVMethodID_class_OnCompare])(Tclass, ((Tclass->type == 1000 && !Tclass->byValueSystemClass) || Tclass->type == 2 || Tclass->type == 4 || Tclass->type == 3 || Tclass->type == 1) ? (((unsigned char *)&node->key) + __ENDIAN_PAD((Tclass->type == 1) ? sizeof(void *) : Tclass->typeSize)) : (void *)*(uint64 *)(&node->key), ((Tclass->type == 1000 && !Tclass->byValueSystemClass) || Tclass->type == 2 || Tclass->type == 4 || Tclass->type == 3 || Tclass->type == 1) ? (((unsigned char *)&this->key) + __ENDIAN_PAD((Tclass->type == 1) ? sizeof(void *) : Tclass->typeSize)) : (void *)*(uint64 *)(&this->key)); if(!result) { return 0x0; } else if(result > 0) { if(this->right) this = this->right; else { node->parent = this; this->right = node; node->depth = 0; { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = this; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth) break; n->depth = newDepth; } } return 0x1; } } else { if(this->left) this = this->left; else { node->parent = this; this->left = node; node->depth = 0; { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = this; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth) break; n->depth = newDepth; } } return 0x1; } } } } struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Find(struct __ecereNameSpace__ecere__com__AVLNode * this, struct __ecereNameSpace__ecere__com__Class * Tclass, uint64 key) { while(this) { int result = ((int (*)(void *, void *, void *))(void *)Tclass->_vTbl[__ecereVMethodID_class_OnCompare])(Tclass, ((Tclass->type == 1000 && !Tclass->byValueSystemClass) || Tclass->type == 2 || Tclass->type == 4 || Tclass->type == 3) ? (((unsigned char *)&key) + __ENDIAN_PAD(Tclass->typeSize)) : (void *)key, ((Tclass->type == 1000 && !Tclass->byValueSystemClass) || Tclass->type == 2 || Tclass->type == 4 || Tclass->type == 3 || Tclass->type == 1) ? (((unsigned char *)&this->key) + __ENDIAN_PAD((Tclass->type == 1) ? sizeof(void *) : Tclass->typeSize)) : (void *)*(uint64 *)(&this->key)); if(result < 0) this = this->left; else if(result > 0) this = this->right; else break; } return this; } struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__AVLNode_FindAll(struct __ecereNameSpace__ecere__com__AVLNode * this, uint64 key) { struct __ecereNameSpace__ecere__com__AVLNode * result = (((void *)0)); if(this->key == key) result = this; if(!result && this->left) result = __ecereMethod___ecereNameSpace__ecere__com__AVLNode_FindAll(this->left, key); if(!result && this->right) result = __ecereMethod___ecereNameSpace__ecere__com__AVLNode_FindAll(this->right, key); return result; } void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_RemoveSwap(struct __ecereNameSpace__ecere__com__AVLNode * this, struct __ecereNameSpace__ecere__com__AVLNode * swap) { if(swap->left) { swap->left->parent = swap->parent; if(swap == swap->parent->left) swap->parent->left = swap->left; else if(swap == swap->parent->right) swap->parent->right = swap->left; swap->left = (((void *)0)); } if(swap->right) { swap->right->parent = swap->parent; if(swap == swap->parent->left) swap->parent->left = swap->right; else if(swap == swap->parent->right) swap->parent->right = swap->right; swap->right = (((void *)0)); } if(swap == swap->parent->left) swap->parent->left = (((void *)0)); else if(swap == swap->parent->right) swap->parent->right = (((void *)0)); { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = swap->parent; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth) break; n->depth = newDepth; if(n == this) break; } } swap->left = this->left; if(this->left) this->left->parent = swap; swap->right = this->right; if(this->right) this->right->parent = swap; swap->parent = this->parent; this->left = (((void *)0)); this->right = (((void *)0)); if(this->parent) { if(this == this->parent->left) this->parent->left = swap; else if(this == this->parent->right) this->parent->right = swap; } } struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(); struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__AVLNode_RemoveSwapLeft(struct __ecereNameSpace__ecere__com__AVLNode * this) { struct __ecereNameSpace__ecere__com__AVLNode * swap = this->left ? __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_maximum(this->left) : this->right; struct __ecereNameSpace__ecere__com__AVLNode * swapParent = (((void *)0)); if(swap) { swapParent = swap->parent; __ecereMethod___ecereNameSpace__ecere__com__AVLNode_RemoveSwap(this, swap); } if(this->parent) { if(this == this->parent->left) this->parent->left = (((void *)0)); else if(this == this->parent->right) this->parent->right = (((void *)0)); } { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = swap ? swap : this->parent; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth && n != swap) break; n->depth = newDepth; } } if(swapParent && swapParent != this) return __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(swapParent); else if(swap) return __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(swap); else if(this->parent) return __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(this->parent); else return (((void *)0)); } struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__AVLNode_RemoveSwapRight(struct __ecereNameSpace__ecere__com__AVLNode * this) { struct __ecereNameSpace__ecere__com__AVLNode * result; struct __ecereNameSpace__ecere__com__AVLNode * swap = this->right ? __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_minimum(this->right) : this->left; struct __ecereNameSpace__ecere__com__AVLNode * swapParent = (((void *)0)); if(swap) { swapParent = swap->parent; __ecereMethod___ecereNameSpace__ecere__com__AVLNode_RemoveSwap(this, swap); } if(this->parent) { if(this == this->parent->left) this->parent->left = (((void *)0)); else if(this == this->parent->right) this->parent->right = (((void *)0)); } { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = swap ? swap : this->parent; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth && n != swap) break; n->depth = newDepth; } } if(swapParent && swapParent != this) result = __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(swapParent); else if(swap) result = __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(swap); else if(this->parent) result = __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(this->parent); else result = (((void *)0)); return result; } int __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_balanceFactor(struct __ecereNameSpace__ecere__com__AVLNode * this) { int leftDepth = this->left ? (this->left->depth + 1) : 0; int rightDepth = this->right ? (this->right->depth + 1) : 0; return rightDepth - leftDepth; } void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_DoubleRotateRight(); void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateRight(); void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_DoubleRotateLeft(); void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateLeft(); struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(struct __ecereNameSpace__ecere__com__AVLNode * this) { while(0x1) { int factor = __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_balanceFactor(this); if(factor < -1) { if(__ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_balanceFactor(this->left) == 1) __ecereMethod___ecereNameSpace__ecere__com__AVLNode_DoubleRotateRight(this); else __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateRight(this); } else if(factor > 1) { if(__ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_balanceFactor(this->right) == -1) __ecereMethod___ecereNameSpace__ecere__com__AVLNode_DoubleRotateLeft(this); else __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateLeft(this); } if(this->parent) this = this->parent; else return this; } } void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateRight(struct __ecereNameSpace__ecere__com__AVLNode * this) { int __simpleStruct2, __simpleStruct3; int __simpleStruct0, __simpleStruct1; if(this->parent) { if(this == this->parent->left) this->parent->left = this->left; else if(this == this->parent->right) this->parent->right = this->left; } this->left->parent = this->parent; this->parent = this->left; this->left = this->parent->right; if(this->left) this->left->parent = this; this->parent->right = this; this->depth = (__simpleStruct0 = this->left ? (this->left->depth + 1) : 0, __simpleStruct1 = this->right ? (this->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); this->parent->depth = (__simpleStruct2 = this->parent->left ? (this->parent->left->depth + 1) : 0, __simpleStruct3 = this->parent->right ? (this->parent->right->depth + 1) : 0, (__simpleStruct2 > __simpleStruct3) ? __simpleStruct2 : __simpleStruct3); { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = this->parent->parent; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth) break; n->depth = newDepth; } } } void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateLeft(struct __ecereNameSpace__ecere__com__AVLNode * this) { int __simpleStruct2, __simpleStruct3; int __simpleStruct0, __simpleStruct1; if(this->parent) { if(this == this->parent->right) this->parent->right = this->right; else if(this == this->parent->left) this->parent->left = this->right; } this->right->parent = this->parent; this->parent = this->right; this->right = this->parent->left; if(this->right) this->right->parent = this; this->parent->left = this; this->depth = (__simpleStruct0 = this->left ? (this->left->depth + 1) : 0, __simpleStruct1 = this->right ? (this->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); this->parent->depth = (__simpleStruct2 = this->parent->left ? (this->parent->left->depth + 1) : 0, __simpleStruct3 = this->parent->right ? (this->parent->right->depth + 1) : 0, (__simpleStruct2 > __simpleStruct3) ? __simpleStruct2 : __simpleStruct3); { struct __ecereNameSpace__ecere__com__AVLNode * n; for(n = this->parent->parent; n; n = n->parent) { int __simpleStruct0, __simpleStruct1; int newDepth = (__simpleStruct0 = n->left ? (n->left->depth + 1) : 0, __simpleStruct1 = n->right ? (n->right->depth + 1) : 0, (__simpleStruct0 > __simpleStruct1) ? __simpleStruct0 : __simpleStruct1); if(newDepth == n->depth) break; n->depth = newDepth; } } } void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_DoubleRotateRight(struct __ecereNameSpace__ecere__com__AVLNode * this) { __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateLeft(this->left); __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateRight(this); } void __ecereMethod___ecereNameSpace__ecere__com__AVLNode_DoubleRotateLeft(struct __ecereNameSpace__ecere__com__AVLNode * this) { __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateRight(this->right); __ecereMethod___ecereNameSpace__ecere__com__AVLNode_SingleRotateLeft(this); } struct __ecereNameSpace__ecere__com__CustomAVLTree { struct __ecereNameSpace__ecere__com__AVLNode * root; int count; } __attribute__ ((gcc_struct)); static struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__CustomAVLTree; struct __ecereNameSpace__ecere__com__IteratorPointer * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetFirst(struct __ecereNameSpace__ecere__com__Instance * this) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return (struct __ecereNameSpace__ecere__com__IteratorPointer *)(__ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root ? __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_minimum(__ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root) : (((void *)0))); } struct __ecereNameSpace__ecere__com__IteratorPointer * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetLast(struct __ecereNameSpace__ecere__com__Instance * this) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return (struct __ecereNameSpace__ecere__com__IteratorPointer *)(__ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root ? __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_maximum(__ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root) : (((void *)0))); } struct __ecereNameSpace__ecere__com__IteratorPointer * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetPrev(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__IteratorPointer * node) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_prev(((struct __ecereNameSpace__ecere__com__AVLNode *)node)); } struct __ecereNameSpace__ecere__com__IteratorPointer * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetNext(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__IteratorPointer * node) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_next(((struct __ecereNameSpace__ecere__com__AVLNode *)node)); } struct __ecereNameSpace__ecere__com__AVLNode * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetData(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__IteratorPointer * node) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return (struct __ecereNameSpace__ecere__com__AVLNode *)node; } unsigned int __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_SetData(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__IteratorPointer * node, uint64 data) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return 0x0; } extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_FindClass(struct __ecereNameSpace__ecere__com__Instance * module, char * name); extern struct __ecereNameSpace__ecere__com__Instance * __thisModule; extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__NameSpace; struct __ecereNameSpace__ecere__com__NameSpace { char * name; struct __ecereNameSpace__ecere__com__NameSpace * btParent; struct __ecereNameSpace__ecere__com__NameSpace * left; struct __ecereNameSpace__ecere__com__NameSpace * right; int depth; struct __ecereNameSpace__ecere__com__NameSpace * parent; struct __ecereNameSpace__ecere__sys__BinaryTree nameSpaces; struct __ecereNameSpace__ecere__sys__BinaryTree classes; struct __ecereNameSpace__ecere__sys__BinaryTree defines; struct __ecereNameSpace__ecere__sys__BinaryTree functions; } __attribute__ ((gcc_struct)); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__Module; struct __ecereNameSpace__ecere__com__Module { struct __ecereNameSpace__ecere__com__Instance * application; struct __ecereNameSpace__ecere__sys__OldList classes; struct __ecereNameSpace__ecere__sys__OldList defines; struct __ecereNameSpace__ecere__sys__OldList functions; struct __ecereNameSpace__ecere__sys__OldList modules; struct __ecereNameSpace__ecere__com__Instance * prev; struct __ecereNameSpace__ecere__com__Instance * next; char * name; void * library; void * Unload; int importType; int origImportType; struct __ecereNameSpace__ecere__com__NameSpace privateNameSpace; struct __ecereNameSpace__ecere__com__NameSpace publicNameSpace; } __attribute__ ((gcc_struct)); struct __ecereNameSpace__ecere__com__IteratorPointer * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Add(struct __ecereNameSpace__ecere__com__Instance * this, uint64 node) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); if(!__ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root) __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root = node; else { struct __ecereNameSpace__ecere__com__Class * Tclass = ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass->templateArgs[0].dataTypeClass; if(!Tclass) { Tclass = ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass->templateArgs[0].dataTypeClass = __ecereNameSpace__ecere__com__eSystem_FindClass(((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application, ((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass->templateArgs[0].dataTypeString); } if(__ecereMethod___ecereNameSpace__ecere__com__AVLNode_Add(__ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root, Tclass, node)) __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root = (uint64)(__ecereMethod___ecereNameSpace__ecere__com__AVLNode_Rebalance(node)); else return (((void *)0)); } __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->count++; return (struct __ecereNameSpace__ecere__com__IteratorPointer *)node; } void __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Remove(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__IteratorPointer * node) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); struct __ecereNameSpace__ecere__com__AVLNode * parent = ((struct __ecereNameSpace__ecere__com__AVLNode *)node)->parent; if(parent || __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root == (struct __ecereNameSpace__ecere__com__AVLNode *)node) { __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root = (uint64)(__ecereMethod___ecereNameSpace__ecere__com__AVLNode_RemoveSwapRight(((struct __ecereNameSpace__ecere__com__AVLNode *)node))); __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->count--; ((struct __ecereNameSpace__ecere__com__AVLNode *)node)->parent = (((void *)0)); } } int __ecereVMethodID___ecereNameSpace__ecere__com__Container_Remove; int __ecereVMethodID_class_OnFree; void __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Delete(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__IteratorPointer * _item) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); struct __ecereNameSpace__ecere__com__AVLNode * item = (struct __ecereNameSpace__ecere__com__AVLNode *)_item; ((void (*)(struct __ecereNameSpace__ecere__com__Instance *, struct __ecereNameSpace__ecere__com__IteratorPointer * it))__ecereClass___ecereNameSpace__ecere__com__CustomAVLTree->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Container_Remove])(this, _item); (((void (* )(void * _class, void * data))((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass->_vTbl[__ecereVMethodID_class_OnFree])(((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass, item), item = 0); } void __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Free(struct __ecereNameSpace__ecere__com__Instance * this) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); struct __ecereNameSpace__ecere__com__AVLNode * item; while(item = __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree->root) { ((void (*)(struct __ecereNameSpace__ecere__com__Instance *, struct __ecereNameSpace__ecere__com__IteratorPointer * it))__ecereClass___ecereNameSpace__ecere__com__CustomAVLTree->_vTbl[__ecereVMethodID___ecereNameSpace__ecere__com__Container_Remove])(this, item); (((void (* )(void * _class, void * data))((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass->_vTbl[__ecereVMethodID_class_OnFree])(((struct __ecereNameSpace__ecere__com__Instance *)(char *)this)->_class->templateArgs[3].dataTypeClass, item), item = 0); } } struct __ecereNameSpace__ecere__com__IteratorPointer * __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Find(struct __ecereNameSpace__ecere__com__Instance * this, uint64 value) { struct __ecereNameSpace__ecere__com__CustomAVLTree * __ecerePointer___ecereNameSpace__ecere__com__CustomAVLTree = (struct __ecereNameSpace__ecere__com__CustomAVLTree *)(this ? (((char *)this) + structSize_Instance) : 0); return (struct __ecereNameSpace__ecere__com__IteratorPointer *)value; } extern struct __ecereNameSpace__ecere__com__Class * __ecereNameSpace__ecere__com__eSystem_RegisterClass(int type, char * name, char * baseName, int size, int sizeClass, unsigned int (* Constructor)(void * ), void (* Destructor)(void * ), struct __ecereNameSpace__ecere__com__Instance * module, int declMode, int inheritanceAccess); extern struct __ecereNameSpace__ecere__com__Method * __ecereNameSpace__ecere__com__eClass_AddMethod(struct __ecereNameSpace__ecere__com__Class * _class, char * name, char * type, void * function, int declMode); extern struct __ecereNameSpace__ecere__com__DataMember * __ecereNameSpace__ecere__com__eClass_AddDataMember(struct __ecereNameSpace__ecere__com__Class * _class, char * name, char * type, unsigned int size, unsigned int alignment, int declMode); extern struct __ecereNameSpace__ecere__com__Property * __ecereNameSpace__ecere__com__eClass_AddProperty(struct __ecereNameSpace__ecere__com__Class * _class, char * name, char * dataType, void * setStmt, void * getStmt, int declMode); extern struct __ecereNameSpace__ecere__com__Class * __ecereClass___ecereNameSpace__ecere__com__ClassTemplateParameter; struct __ecereNameSpace__ecere__com__ClassTemplateParameter; extern struct __ecereNameSpace__ecere__com__ClassTemplateParameter * __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(struct __ecereNameSpace__ecere__com__Class * _class, char * name, int type, void * info, struct __ecereNameSpace__ecere__com__ClassTemplateArgument * defaultArg); extern void __ecereNameSpace__ecere__com__eClass_DoneAddingTemplateParameters(struct __ecereNameSpace__ecere__com__Class * base); void __ecereRegisterModule_CustomAVLTree(struct __ecereNameSpace__ecere__com__Instance * module) { struct __ecereNameSpace__ecere__com__ClassTemplateArgument __simpleStruct0 = { "uint64", 0, 0, 0, 0 }; struct __ecereNameSpace__ecere__com__Class * class; class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(5, "ecere::com::AVLNode", "ecere::com::IteratorPointer", sizeof(struct __ecereNameSpace__ecere__com__AVLNode), 0, 0, 0, module, 4, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class) __ecereClass___ecereNameSpace__ecere__com__AVLNode = class; __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Find", "thisclass Find(ecere::com::Class Tclass, T key)", __ecereMethod___ecereNameSpace__ecere__com__AVLNode_Find, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "__ecerePrivateData0", "byte[" _XSTR(AVLNode_PrivateData) "]", AVLNode_PrivateData, 1, 2); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "key", "T", 8, 8, 1); __ecerePropM___ecereNameSpace__ecere__com__AVLNode_prev = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "prev", "thisclass", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_prev, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_prev = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_prev, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_prev = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_next = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "next", "thisclass", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_next, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_next = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_next, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_next = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_minimum = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "minimum", "thisclass", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_minimum, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_minimum = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_minimum, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_minimum = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_maximum = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "maximum", "thisclass", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_maximum, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_maximum = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_maximum, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_maximum = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_count = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "count", "int", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_count, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_count = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_count, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_count = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_depthProp = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "depthProp", "int", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_depthProp, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_depthProp = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_depthProp, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_depthProp = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_balanceFactor = __ecereNameSpace__ecere__com__eClass_AddProperty(class, "balanceFactor", "int", 0, __ecereProp___ecereNameSpace__ecere__com__AVLNode_Get_balanceFactor, 2); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application) __ecereProp___ecereNameSpace__ecere__com__AVLNode_balanceFactor = __ecerePropM___ecereNameSpace__ecere__com__AVLNode_balanceFactor, __ecerePropM___ecereNameSpace__ecere__com__AVLNode_balanceFactor = (void *)0; __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(class, "T", 0, 0, (((void *)0))); __ecereNameSpace__ecere__com__eClass_DoneAddingTemplateParameters(class); if(class) class->fixed = (unsigned int)1; class = __ecereNameSpace__ecere__com__eSystem_RegisterClass(0, "ecere::com::CustomAVLTree", "ecere::com::Container<BT>", sizeof(struct __ecereNameSpace__ecere__com__CustomAVLTree), 0, 0, 0, module, 4, 1); if(((struct __ecereNameSpace__ecere__com__Module *)(((char *)module + structSize_Instance)))->application == ((struct __ecereNameSpace__ecere__com__Module *)(((char *)__thisModule + structSize_Instance)))->application && class) __ecereClass___ecereNameSpace__ecere__com__CustomAVLTree = class; __ecereNameSpace__ecere__com__eClass_AddMethod(class, "GetFirst", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetFirst, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "GetLast", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetLast, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "GetPrev", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetPrev, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "GetNext", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetNext, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "GetData", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_GetData, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "SetData", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_SetData, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Add", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Add, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Remove", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Remove, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Find", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Find, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Free", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Free, 1); __ecereNameSpace__ecere__com__eClass_AddMethod(class, "Delete", 0, __ecereMethod___ecereNameSpace__ecere__com__CustomAVLTree_Delete, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "root", "BT", arch_PointerSize, arch_PointerSize, 1); __ecereNameSpace__ecere__com__eClass_AddDataMember(class, "count", "int", 4, 4, 1); __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(class, "BT", 0, "ecere::com::AVLNode", (((void *)0))); __ecereNameSpace__ecere__com__eClass_AddTemplateParameter(class, "KT", 0, 0, &__simpleStruct0); __ecereNameSpace__ecere__com__eClass_DoneAddingTemplateParameters(class); if(class) class->fixed = (unsigned int)1; } void __ecereUnregisterModule_CustomAVLTree(struct __ecereNameSpace__ecere__com__Instance * module) { __ecerePropM___ecereNameSpace__ecere__com__AVLNode_prev = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_next = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_minimum = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_maximum = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_count = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_depthProp = (void *)0; __ecerePropM___ecereNameSpace__ecere__com__AVLNode_balanceFactor = (void *)0; }
the_stack_data/120643.c
typedef struct { char pad[0x10]; int whatever[0x1000]; } SomeStruct; extern SomeStruct glob;
the_stack_data/31389108.c
#include <stdio.h> #include <stdlib.h> #include <stdio.h> #include <stdlib.h> int main() { printf("--------------Troca de Luz-----------------\n"); printf("- Desligue a energia\n"); printf("- Pegue uma escada\n"); printf("- Espere a lampada esfriar\n"); printf("- Desenrosque a lampada no sentido anti-horario\n"); printf("- Descarte a lampada queimada\n"); printf("- Coloque a lampada nova no sentido horario\n"); printf("- Restaure a energia\n"); printf("---------------FIM------------------------\n"); return 0; }
the_stack_data/107105.c
#include "stdio.h" int main() { int i, j; char a[2] [3] = { {'a', 'b', 'c'}, {'d', 'e', 'f'}}; /* This will give an undefined output since the array a doesn't end with \0 */ char b[3] [2]; char *p = *b; for (i=0; i<2; i++) { for(j=0; j<3; j++) { *(p+2 * j + i) = a[i][j]; } } for ( i = 0; i < 3; i++) { for ( j = 0; j < 2; j++) { printf("%c",b[i][j]); } } }
the_stack_data/123898.c
/* $OpenBSD: freeaddrinfo.c,v 1.9 2016/09/21 04:38:56 guenther Exp $ */ /* * Copyright (c) 1996, 1997, 1998, 1999, Craig Metz, All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by Craig Metz and * by other contributors. * 4. Neither the name of the author nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <stdlib.h> #include <netdb.h> void freeaddrinfo(struct addrinfo *ai) { struct addrinfo *p; do { p = ai; ai = ai->ai_next; free(p->ai_canonname); free(p); } while (ai); } DEF_WEAK(freeaddrinfo);
the_stack_data/836844.c
// Here, using fraction 312689 / 99532 // "The fraction 355/113 is incredibly close to pi, within a third of a millionth of the exact value." - http://davidbau.com // can also use 22/7 //PIproximate - by unsuitable001 // Who the heck am I? - read on github repo // https://github.com/unsuitable001/usnippet/blob/master/PIproximate.md #include<stdio.h> int main() { FILE *out = fopen("PI", "a"); setvbuf(out, NULL, _IONBF, 0); int div = 312689,r, rem; r = div / 99532; rem = div % 99532; fprintf(out,"%d.",r); while(rem != 0){ div = rem * 10; r = div / 99532; rem = div % 99532; fprintf(out,"%d",r); } fclose(out); return 0; }
the_stack_data/165767288.c
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> int main( ) { pid_t c1=1,c2=1; c1 = fork(); if (c1 != 0) c2 = fork(); if (c2== 0) fork(); printf(" 1"); return 0; }
the_stack_data/1134283.c
/* This file is part of The Firekylin Operating System. * * Copyright 2016 Liuxiaofeng * * 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. */ #include <wctype.h> #undef towlower wint_t towlower(wint_t c) { return iswupper(c) ? c+0x20 : c; }
the_stack_data/70449244.c
/* Abhinav Gupta ES15BTECH11002 Assignment 2 - Multi-Processing */ #include <stdio.h> #include <sys/types.h> #include <unistd.h> #include <stdlib.h> #include <sys/shm.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/mman.h> #include <sys/wait.h> #include <time.h> int shm_fd; int *primes; /* pointer to shared memory obect */ int isPrime(long n) { // Corner cases if (n <= 1) return 0; if (n <= 3) return 1; // This is checked so that we can skip // middle five numbers in below loop if (n%2 == 0 || n%3 == 0) return 0; for (long long i=5; i*i<=n; i=i+6) if (n%i == 0 || n%(i+2) == 0) return 0; return 1; } int main(int argc, char *argv[]) { clock_t start,end; double net_time; if(argc != 3) { printf("Enter Correct Run Command - ( ./a.out n k) where 1 < n < 1000000 and 2 < k < 32 "); return 0; } // declaring n and k variables long n; int k; n = atoi(argv[1]); k = atoi(argv[2]); const long SIZE = n*sizeof(int); /* the size (in bytes) of shared memory object */ pid_t pid[k]; /* shared memory file descriptor */ shm_fd = shm_open("prime", O_CREAT | O_RDWR, 0666); /* create the shared memory object */ ftruncate(shm_fd, SIZE); /* configure the size of the shared memory object */ primes = (int *)mmap(0, SIZE, PROT_WRITE | PROT_READ, MAP_SHARED, shm_fd, 0); /* memory map the shared memory object */ start = clock(); for(int i=0;i<k;++i) // parent creates k child processes { pid[i] = fork(); if(pid[i]==0) { int processid = i; if(processid == 0) processid = k; while(processid < n) { if(isPrime(processid)) primes[processid] = 1; else primes[processid]=0; processid += k; } exit(0); } else if (pid[i] < 0) // if error in creating child process { printf("Error Creating Process ! \n"); exit(0); } } for(int i=0;i<k;++i) if(pid[i]>0) wait(NULL); end = clock(); net_time = ((double)end-start)/CLOCKS_PER_SEC; FILE *fptr; fptr = fopen("primes-proc.txt", "w"); for (long i=1;i<n;++i) { if(primes[i]==1) fprintf(fptr,"%ld ",i); } fclose(fptr); printf("** Time used:- %f **\n", net_time); // printing out the time used shm_unlink("prime"); // deallocating shared memory return 0; }
the_stack_data/362942.c
/** @test */
the_stack_data/165766100.c
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> struct palindrome { int low; int high; }; static void collect(char *s, int len, int low, int high, struct palindrome *results, int *count) { while (low >= 0 && high < len && s[low] == s[high]) { results[*count].low = low; results[*count].high = high; (*count)++; low--; high++; } } static void dfs(struct palindrome *pal_set, int num, int start, char *s, int len, struct palindrome **stack, int size, char ***results, int *count, int *col_sizes) { int i; if (size > 0 && stack[size - 1]->high == len - 1) { col_sizes[*count] = size; results[*count] = malloc(size * sizeof(char *)); for (i = 0; i < size; i++) { int low = stack[i]->low; int high = stack[i]->high; results[*count][i] = malloc(high - low + 2); memcpy(results[*count][i], s + low, high - low + 1); results[*count][i][high - low + 1] = '\0'; } (*count)++; } else { for (i = start; i < num; i++) { if ((size == 0 && pal_set[i].low == 0) || (size > 0 && stack[size - 1]->high + 1 == pal_set[i].low)) { stack[size] = &pal_set[i]; dfs(pal_set, num, i + 1, s, len, stack, size + 1, results, count, col_sizes); } } } } /** ** Return an array of arrays of size *returnSize. ** The sizes of the arrays are returned as *returnColumnSizes array. ** Note: Both returned array and *columnSizes array must be malloced, assume caller calls free(). **/ static char ***partition(char* s, int* returnSize, int** returnColumnSizes) { int len = strlen(s); if (len == 0) { *returnSize = 0; return NULL; } int i, cap = 800, count = 0; struct palindrome *pal_set = malloc(cap * sizeof(*pal_set)); for (i = 0; i < len; i++) { collect(s, len, i, i, pal_set, &count); collect(s, len, i, i + 1, pal_set, &count); } char ***results = malloc(cap * sizeof(char **)); struct palindrome **stack = malloc(count * sizeof(*stack)); *returnColumnSizes = malloc(cap * sizeof(int)); dfs(pal_set, count, 0, s, len, stack, 0, results, returnSize, *returnColumnSizes); return results; } int main(int argc, char **argv) { if (argc != 2) { fprintf(stderr, "Usage: ./test string\n"); exit(-1); } int i, j, count = 0; int *col_sizes; char ***lists = partition(argv[1], &count, &col_sizes); for (i = 0; i < count; i++) { char **list = lists[i]; for (j = 0; j < col_sizes[i]; j++) { printf("%s ", list[j]); } printf("\n"); } return 0; }
the_stack_data/57949743.c
#include <stdio.h> #include <string.h> #include <sys/socket.h> #include <arpa/inet.h> #include <unistd.h> #include <pthread.h> #include <fcntl.h> #include <sys/types.h> #include <sys/stat.h> #define MAX_THREAD 3 char *model = "GET /1.txt HTTP/1.1"; char *ok = "HTTP/1.0 200 OK\r\nContent-Length: 15\r\n\r\n"; char OK[2000] = {0}; char buf[1000] = {0}; char *no = "HTTP/1.0 404 FILE NOT FOUND\r\n\r\n"; int s; int cs; struct sockaddr_in server, client; char msg[2000]; int main(int argc, const char *argv[]) { int x; pthread_t thread[MAX_THREAD]; pid_t pid; //read file FILE *fd; if(!(fd = fopen("1.txt","r"))) { printf("open 1.txt failed!\n"); return 1; } int m = 0; while((x = fgetc(fd))!= EOF) { buf[m] = x; m++; } strcat(OK,ok); strcat(OK,buf); //strcat(OK,"\r\n"); // create socket if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { perror("create socket failed"); return -1; } printf("socket created"); // prepare the sockaddr_in structure //for(int i = 0; i < MAX_THREAD; i++) server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(80); // bind if (bind(s,(struct sockaddr *)&server, sizeof(server)) < 0) { perror("bind failed"); return -1; } printf("bind done"); // listen listen(s, 6); printf("waiting for incoming connections..."); while(1) { // accept connection from an incoming client int c = sizeof(struct sockaddr_in); if ((cs = accept(s, (struct sockaddr *)&client, (socklen_t *)&c)) < 0) { perror("accept failed"); return -1; } printf("connection accepted"); pid = fork(); if(pid==0) {//child close(s); int msg_len = 0; // receive a message from client while ((msg_len = recv(cs, msg, sizeof(msg), 0)) > 0) { // send the message back to client printf("%s\n",msg); char message[4000]={0}; strcat(message,msg); for(int j = 19; j < strlen(msg);j++) message[j] = 0; printf("%s\n",message); if(strcmp(message,model) == 0) { write(cs,OK,strlen(OK)); } else write(cs,no,strlen(no)); //write(cs, msg, msg_len); } if (msg_len == 0) { printf("client disconnected"); } else { // msg_len < 0 perror("recv failed"); close(cs); return -1; } close(cs); return 0; } else if(pid > 0) {//parent close(cs); } else { printf("fork failed!\n"); exit(1); } } return 0; }
the_stack_data/43888286.c
// RUN: %clang_cc1 -analyze -analyzer-checker=core %s // PR12905 void C(void); void t(void) { C(); }
the_stack_data/72013674.c
#include <stdio.h> #include <stdlib.h> #define ll long long #define f(i,a,b) for(ll i=a;i<b;i++) #define fd(i,b,a) for(ll i=b;i>=a;i--) int max(int a, int b) { return (a>b?a:b); } struct node { int data; struct node* next; }; typedef struct node node; void insert(node** h, int key) { node* temp = (node*)malloc(sizeof(node)); temp->data = key; if(*h) { temp->next = *h; *h = temp; } else { *h = temp; temp->next = NULL; } } int getCount(node* h) { int count=0; node* i = h; while(i) { count++; i = i->next; } return count; } int getIntersection(int d, node* h1, node* h2) { node* curr1 = h1; node* curr2 = h2; f(i,0,d) { if(!curr1) return -1; else curr1 = curr1->next; } while(curr1 && curr2) { if(curr1->data == curr2->data) { return curr1->data; } else { curr1 = curr1->next; curr2 = curr2->next; } } return -1; } void printlist(node** h) { node* i = *h; while(i) { if(i->next) printf("%d->",i->data); else printf("%d->NULL\n",i->data); i = i->next; } } int main() { int n1, n2; scanf("%d",&n1); scanf("%d",&n2); int a[n1], b[n2]; int c1, c2, d; node* head1=NULL; node** h1 = &head1; node* head2=NULL; node** h2 = &head2; f(i,0,n1) scanf("%d",&a[i]); fd(i,n1-1,0) insert(h1, a[i]); f(i,0,n2) scanf("%d",&b[i]); fd(i,n2-1,0) insert(h2, b[i]); c1 = getCount(head1); c2 = getCount(head2); printlist(h1); printlist(h2); if(c1 > c2) { d = c1 - c2; if(getIntersection(d, head1, head2)!=-1) printf("\n%d is the intersection point\n",getIntersection(d, head1, head2)); else printf("\nNo intersection point\n"); } else{ d = c2 - c1; if(getIntersection(d, head2, head1)!=-1) printf("\n%d is the intersection point\n",getIntersection(d, head2, head1)); else printf("\nNo intersection point\n"); } return 0; }
the_stack_data/829908.c
#include<stdio.h> #include<stdlib.h> #include <sys/ipc.h> #include <sys/msg.h> #include <sys/types.h> #include <unistd.h> #define DECLARE_ARGS(val, low, high) unsigned long low, high #define EAX_EDX_VAL(val, low, high) ((low) | (high) << 32) #define EAX_EDX_RET(val, low, high) "=a" (low), "=d" (high) static __always_inline unsigned long long rdtsc(void) { DECLARE_ARGS(val, low, high); asm volatile("rdtscp" : EAX_EDX_RET(val, low, high)); return EAX_EDX_VAL(val, low, high); } #define BULK (16*1024*1024) #define TOTAL_SIZE (16*1024*1024) #define TOTAL_TIMES 100000 void main(void) { unsigned long long start,end, single, avg; char *testmem; int cnt; /* start = rdtsc(); end = rdtsc(); printf("tsc cost: %llu\n", end - start); */ // to eliminate the influece of first syscall getpid(); start = rdtsc(); getpid(); end = rdtsc(); single = end-start; start = rdtsc(); for(cnt=0;cnt<TOTAL_TIMES;cnt++) { getpid(); } end = rdtsc(); avg=(end-start)/TOTAL_TIMES; printf("getpid - single takes: %llu \n", single); printf("getpid - avrage takes: %llu\n", avg); }
the_stack_data/867784.c
// Считать с клавиатуры целое неотрицательное число в десятичной системе счисления и основание новой системы счисления (целое число от 2 до 10). // Вывести в консоль число, записанное в новой системе счисления. // Задача решается без массивов. #include <stdio.h> int main() { int current, base; int level = 1; scanf("%d %d", &current, &base); for ( ; current / level >= base; level *= base ); for ( ; level >= 1; ) { printf("%d", current/level); current %= level; level /= base; } printf("\n"); return 0; }
the_stack_data/4720.c
#include <stdio.h> int rust_function(int); int main(void) { rust_function(10); return 0; }
the_stack_data/154396.c
#include <stdio.h> #include <string.h> int main() { char str[20], temp; printf("Enter the input string\n"); scanf("%s", str); int len = strlen(str); for(int i = 0; i < len; i++) { for(int j = i+1; j < len; j++) { if(str[j] < str[i]) { temp = str[j]; str[j] = str[i]; str[i] = temp; } } } printf("The output string is %s", str); return 0; }
the_stack_data/51699199.c
/* Copyright (c) 2019 KrossX <[email protected]> * License: http://www.opensource.org/licenses/mit-license.html MIT License */ int input[] = { 3,8,1001,8,10,8,105,1,0,0,21,42,67,76,89,110,191,272,353,434,99999,3,9,102,2,9,9,1001,9,2,9,1002,9,2,9,1001,9,2,9,4,9,99,3,9,1001,9,4,9,102,4,9,9,101,3,9,9,1002,9,2,9,1001,9,4,9,4,9,99,3,9,102,5,9,9,4,9,99,3,9,1001,9,3,9,1002,9,3,9,4,9,99,3,9,102,3,9,9,101,2,9,9,1002,9,3,9,101,5,9,9,4,9,99,3,9,1001,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,2,9,9,4,9,99,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,102,2,9,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,2,9,9,4,9,99,3,9,102,2,9,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,1,9,9,4,9,3,9,102,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,101,2,9,9,4,9,3,9,1002,9,2,9,4,9,3,9,101,1,9,9,4,9,3,9,1002,9,2,9,4,9,99,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,1002,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,102,2,9,9,4,9,3,9,102,2,9,9,4,9,3,9,1001,9,1,9,4,9,3,9,1001,9,2,9,4,9,3,9,1001,9,1,9,4,9,3,9,101,2,9,9,4,9,99 };
the_stack_data/967240.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #define MAXLINE 1024 int main(int argc, char const *argv[]) { int fd[2]; int n; char buf[MAXLINE]; pid_t pid; if (pipe(fd) < 0) { fprintf(stderr, "pipe error\n"); exit(1); } if ((pid = fork()) < 0) { fprintf(stderr, "fork error\n"); exit(1); } else if (pid > 0) { close(fd[0]); write(fd[1], "hello world\n", 12); } else { close(fd[1]); n = read(fd[0], buf, MAXLINE); write(STDOUT_FILENO, buf, n); } return 0; }
the_stack_data/73758.c
/*! pstr string functions The author disclaims copyright to this source code. In place of a legal notice, here is a blessing: May you do good and not evil. May you find forgiveness for yourself and forgive others. May you share freely, never taking more than you give. */ #include <assert.h> #include <ctype.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdlib.h> #include <string.h> bool pstr_is_valid(char const *str, size_t const size) { for (size_t idx = 0; idx < size; idx++) { if (str[idx] == 0) { return true; } } return false; } int64_t pstr_len(char const *str) { return strlen(str); } bool pstr_is_empty(char const *str) { return str[0] == '\0'; } bool pstr_eq(char const *str1, char const *str2) { return strcmp(str1, str2) == 0; } bool pstr_starts_with_char(char const *str, char const character) { return str[0] == character; } bool pstr_starts_with(char const *str, char const *prefix) { size_t str_len = pstr_len(str); size_t prefix_len = pstr_len(prefix); if (str_len == 0 || prefix_len == 0) { return false; } if (str_len < prefix_len) { return false; } return memcmp(str, prefix, prefix_len) == 0; } bool pstr_ends_with_char(char const *str, char const character) { size_t str_len = pstr_len(str); return str[str_len - 1] == character; } bool pstr_ends_with(char const *str, char const *prefix) { size_t str_len = pstr_len(str); size_t prefix_len = pstr_len(prefix); if (str_len == 0 || prefix_len == 0) { return false; } if (str_len < prefix_len) { return false; } return memcmp(str + str_len - prefix_len, prefix, prefix_len) == 0; } bool pstr_copy(char *dest, size_t const dest_size, char const *src) { size_t const src_len = pstr_len(src); // If there's no room, return false if (dest_size < src_len + 1) { return false; } memcpy(dest, src, src_len); dest[src_len] = '\0'; return true; } bool pstr_copy_n(char *dest, size_t const dest_size, char const *src, size_t const n) { size_t const src_len = pstr_len(src); // If there's no room, return false if (src_len < n || dest_size < n + 1) { return false; } memcpy(dest, src, n); dest[n] = '\0'; return true; } bool pstr_cat(char *dest, size_t const dest_size, char const *src) { size_t const src_len = pstr_len(src); size_t const dest_len = pstr_len(dest); size_t const free_size = dest_size - dest_len; // If there's no room, return false if (free_size < src_len + 1 || src_len == 0) { return false; } memcpy(dest + dest_len, src, src_len); dest[dest_len + src_len] = '\0'; return true; } bool pstr_vcat(char *dest, size_t const dest_size, ...) { size_t const dest_len = pstr_len(dest); size_t free_size = dest_size - dest_len; char *cursor = dest + dest_len; va_list args; va_start(args, dest_size); char const *src; while (true) { src = va_arg(args, char const*); if (!src) { break; } size_t const src_len = pstr_len(src); // If there's no room, return false if (free_size < src_len + 1 || src_len == 0) { // Restore our string to what it was before dest[dest_len] = 0; return false; } memcpy(cursor, src, src_len); cursor += src_len; free_size -= src_len; } *cursor = '\0'; return true; } bool pstr_split_on_first_occurrence( char const *src, char *part1, size_t const part1_size, char *part2, size_t const part2_size, char const separator ) { size_t const src_len = pstr_len(src); // Find separator char const *separator_start = strchr(src, separator); if (!separator_start) { return false; } size_t idx_separator = separator_start - src; // Find how much space we need before and after the separator size_t const src_len_before_sep = idx_separator; size_t const src_len_after_sep = src_len - idx_separator - 1; // Return if we don't have enough space if (part1_size < src_len_before_sep + 1 || part2_size < src_len_after_sep + 1) { return false; } memcpy(part1, src, src_len_before_sep); memcpy(part2, separator_start + 1, src_len_after_sep); return true; } void pstr_clear(char *str) { str[0] = '\0'; } bool pstr_slice_from(char *str, size_t const start) { size_t const str_len = pstr_len(str); if (start >= str_len) { return false; } uint32_t idx = 0; char *cursor = &str[start]; do { str[idx++] = *cursor; cursor++; } while (*cursor != 0); str[idx++] = 0; return true; } bool pstr_slice_to(char *str, size_t const end) { size_t const str_len = pstr_len(str); if (end >= str_len) { return false; } str[end] = 0; return true; } bool pstr_slice(char *str, size_t const start, size_t const end) { if (start >= end) { return false; } return pstr_slice_to(str, end) && pstr_slice_from(str, start); } void pstr_ltrim(char *str) { size_t n_spaces = 0; while (isspace(str[n_spaces])) { n_spaces++; } pstr_slice_from(str, n_spaces); } void pstr_rtrim(char *str) { size_t str_len = pstr_len(str); size_t n_spaces = 0; while (isspace(str[str_len - n_spaces - 1])) { n_spaces++; } pstr_slice_to(str, str_len - n_spaces); } void pstr_trim(char *str) { pstr_ltrim(str); pstr_rtrim(str); } void pstr_ltrim_char(char *str, char const target) { size_t n_matches = 0; while (str[n_matches] == target) { n_matches++; } pstr_slice_from(str, n_matches); } void pstr_rtrim_char(char *str, char const target) { size_t str_len = pstr_len(str); size_t n_matches = 0; while (str[str_len - n_matches - 1] == target) { n_matches++; } pstr_slice_to(str, str_len - n_matches); } void pstr_trim_char(char *str, char const target) { pstr_ltrim_char(str, target); pstr_rtrim_char(str, target); } bool pstr_from_int64( char *str, size_t const str_size, int64_t number, size_t *new_str_len ) { char *cursor = str; *new_str_len = 0; uint64_t number_abs = (number < 0) ? -number : number; // Make a backwards string, since that's easier to produce do { *cursor++ = '0' + (number_abs % 10); (*new_str_len)++; // Check that we have space for the string so far, the NULL terminator and a // potential '-' character if (*new_str_len > str_size - 2) { str[0] = 0; return false; } number_abs /= 10; } while(number_abs > 0); if (number < 0) { *cursor++ = '-'; } *cursor = '\0'; // Reverse our string so it's the right way around again char swapped_char; cursor--; while(str < cursor) { swapped_char = *str; *str = *cursor; *cursor = swapped_char; str++; cursor--; } return true; }
the_stack_data/92196.c
/* Copyright 2014-2016 Free Software Foundation, Inc. This file is part of GDB. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern void hello (void); extern void world (void); int v; int main (void) { hello (); world (); }
the_stack_data/176704460.c
// ---- begin global declarations ---- int RetVal; int Cur_Vertical_Sep; int High_Confidence; int Two_of_Three_Reports_Valid; int Own_Tracked_Alt; int Own_Tracked_Alt_Rate; int Other_Tracked_Alt; int Alt_Layer_Value; int Positive_RA_Alt_Thresh__0; int Positive_RA_Alt_Thresh__1; int Positive_RA_Alt_Thresh__2; int Positive_RA_Alt_Thresh__3; int Up_Separation; int Down_Separation; int Other_RAC; int Other_Capability; int Climb_Inhibit; // ---- end global declarations ---- int main() { // ---- begin local declarations ---- // ---- func_main ---- int func_main_Enabled; int func_main_Tcas_equipped; int func_main_Intent_not_known; int func_main_Need_upward_RA; int func_main_Need_downward_RA; int func_main_Alt_sep; int func_main_Alim; int func_main_Temp1; int func_main_Temp2; int func_main_Temp3; int func_main_Temp4; int func_main_Result_Non_Crossing_Biased_Climb; int func_main_Result_Non_Crossing_Biased_Descend; int func_main_Upward_preferred_1; int func_main_Alim_Non_Crossing_Biased_Climb; int func_main_Temp11; int func_main_Temp12; int func_main_Temp13; int func_main_Upward_preferred_2; int func_main_Alim_Non_Crossing_Biased_Descend; int func_main_Temp21; int func_main_Temp22; int func_main_Temp23; // ---- func___TRACER_INIT ---- // ---- end local declarations ---- RetVal = 0; ; Positive_RA_Alt_Thresh__0 = 400; Positive_RA_Alt_Thresh__1 = 500; Positive_RA_Alt_Thresh__2 = 640; Positive_RA_Alt_Thresh__3 = 740; func_main_Enabled = 0; func_main_Tcas_equipped = 0; func_main_Intent_not_known = 0; func_main_Need_upward_RA = 0; func_main_Need_downward_RA = 0; if((Alt_Layer_Value == 0)) { func_main_Alim = Positive_RA_Alt_Thresh__0; func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L1: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L2: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L3: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L4: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L5: func_main_Upward_preferred_2 = 1; func_main_Temp22 = 1; func_main_Temp3 = func_main_Result_Non_Crossing_Biased_Descend; func_main_Temp4 = 0; if((func_main_Temp3 == 0)) { L6: func_main_Alt_sep = 1; L7: RetVal = 0; return RetVal; } else { goto L6; } } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L8: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L9: func_main_Upward_preferred_2 = 1; func_main_Temp22 = 1; func_main_Result_Non_Crossing_Biased_Descend = 1; L10: func_main_Temp3 = func_main_Result_Non_Crossing_Biased_Descend; L11: func_main_Temp4 = 0; L12: if((func_main_Need_upward_RA == 0)) { L13: func_main_Alt_sep = 0; goto L7; } else { goto L13; } } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L14: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L15: func_main_Upward_preferred_2 = 1; func_main_Temp22 = 0; if((func_main_Temp22 == 0)) { L16:L17: func_main_Temp3 = func_main_Result_Non_Crossing_Biased_Descend; if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp4 = 1; goto L12; } else { func_main_Temp4 = 0; if((func_main_Temp3 == 0)) { goto L12; } else { goto L12; } } } else { goto L16; } } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L18: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L19: func_main_Temp23 = 1; func_main_Result_Non_Crossing_Biased_Descend = 1; func_main_Temp3 = func_main_Result_Non_Crossing_Biased_Descend; func_main_Temp4 = 1; func_main_Need_downward_RA = 1; _ABORT(((Up_Separation >= func_main_Alim) && (Down_Separation >= func_main_Alim) && (Own_Tracked_Alt > Other_Tracked_Alt))); func_main_Alt_sep = 2; goto L7; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L20: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L21: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L22: func_main_Temp23 = 1; goto L17; } else { goto L20; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L23: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L24: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L25: func_main_Temp23 = 0; func_main_Result_Non_Crossing_Biased_Descend = 1; goto L10; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L26: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L27: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; func_main_Temp21 = (Up_Separation + 100); L28: func_main_Temp23 = 0; func_main_Result_Non_Crossing_Biased_Descend = 1; func_main_Temp3 = func_main_Result_Non_Crossing_Biased_Descend; goto L11; } else { goto L26; } } } else { goto L23; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L29: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L30: func_main_Temp21 = Up_Separation; goto L5; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L31: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L32: func_main_Temp21 = Up_Separation; goto L9; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L33: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L34: func_main_Temp21 = Up_Separation; goto L15; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L35: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L36: func_main_Temp21 = Up_Separation; goto L19; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L37: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L38: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L39: func_main_Temp21 = Up_Separation; goto L22; } else { goto L37; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L40: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L41: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L42: func_main_Temp21 = Up_Separation; goto L25; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L43: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L44: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; L45: func_main_Temp21 = Up_Separation; goto L28; } else { goto L43; } } } else { goto L40; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L46: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L30; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L47: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L32; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L48: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L34; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L49: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L36; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L50: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L51: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L39; } else { goto L50; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L52: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L53: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L42; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L54: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__0; L55: func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__3; goto L45; } else { goto L54; } } } else { goto L52; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L2; } else if((Two_of_Three_Reports_Valid == 0)) { L56: func_main_Alt_sep = 0; goto L7; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L57: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L58: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L3; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L58; } else if((Two_of_Three_Reports_Valid == 0)) { L59: func_main_Alt_sep = 0; goto L3; } else if((0 > Other_RAC)) { goto L59; } else { goto L59; } } else { goto L57; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L1; } else if((High_Confidence == 0)) { L60: if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L61: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L7; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L61; } else if((Two_of_Three_Reports_Valid == 0)) { L62: func_main_Alt_sep = 0; if((func_main_Enabled == 0)) { goto L7; } else { goto L7; } } else if((0 > Other_RAC)) { goto L62; } else { goto L62; } } else if((0 > Other_Capability)) { L63: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { goto L61; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L61; } else if((Two_of_Three_Reports_Valid == 0)) { L64: func_main_Alt_sep = 0; goto L7; } else if((0 > Other_RAC)) { goto L64; } else { goto L64; } } else { goto L63; } } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } else if((0 > Alt_Layer_Value)) { func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L65: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L66: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L67: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L4; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L8; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L14; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L18; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L68: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L21; } else { goto L68; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L69: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L24; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L70: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L27; } else { goto L70; } } } else { goto L69; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L29; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L31; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L33; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L35; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L71: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L38; } else { goto L71; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L72: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L41; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L73: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L44; } else { goto L73; } } } else { goto L72; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L46; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L47; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L48; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L49; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L74: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L51; } else { goto L74; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L75: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L53; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L76: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L55; } else { goto L76; } } } else { goto L75; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L66; } else if((Two_of_Three_Reports_Valid == 0)) { goto L56; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L77: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L78: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L67; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L78; } else if((Two_of_Three_Reports_Valid == 0)) { L79: func_main_Alt_sep = 0; goto L67; } else if((0 > Other_RAC)) { goto L79; } else { goto L79; } } else { goto L77; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L65; } else if((High_Confidence == 0)) { goto L60; } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } else { if((Alt_Layer_Value == 1)) { func_main_Alim = Positive_RA_Alt_Thresh__1; func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L80: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L81: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L82: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__1; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L4; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L8; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L14; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L18; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L83: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L21; } else { goto L83; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L84: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L24; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L85: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L27; } else { goto L85; } } } else { goto L84; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L29; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L31; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L33; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L35; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L86: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L38; } else { goto L86; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L87: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L41; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L88: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L44; } else { goto L88; } } } else { goto L87; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L46; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L47; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L48; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L49; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L89: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L51; } else { goto L89; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L90: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L53; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L91: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__1; goto L55; } else { goto L91; } } } else { goto L90; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L81; } else if((Two_of_Three_Reports_Valid == 0)) { goto L56; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L92: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L93: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L82; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L93; } else if((Two_of_Three_Reports_Valid == 0)) { L94: func_main_Alt_sep = 0; goto L82; } else if((0 > Other_RAC)) { goto L94; } else { goto L94; } } else { goto L92; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L80; } else if((High_Confidence == 0)) { goto L60; } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } else if((1 > Alt_Layer_Value)) { func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L95: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L96: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L97: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L4; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L8; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L14; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L18; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L98: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L21; } else { goto L98; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L99: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L24; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L100: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L27; } else { goto L100; } } } else { goto L99; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L29; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L31; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L33; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L35; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L101: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L38; } else { goto L101; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L102: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L41; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L103: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L44; } else { goto L103; } } } else { goto L102; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L46; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L47; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L48; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L49; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L104: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L51; } else { goto L104; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L105: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L53; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L106: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L55; } else { goto L106; } } } else { goto L105; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L96; } else if((Two_of_Three_Reports_Valid == 0)) { goto L56; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L107: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L108: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L97; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L108; } else if((Two_of_Three_Reports_Valid == 0)) { L109: func_main_Alt_sep = 0; goto L97; } else if((0 > Other_RAC)) { goto L109; } else { goto L109; } } else { goto L107; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L95; } else if((High_Confidence == 0)) { goto L60; } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } else { if((Alt_Layer_Value == 2)) { func_main_Alim = Positive_RA_Alt_Thresh__2; func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L110: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L111: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L112: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__2; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L4; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L8; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L14; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L18; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L113: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L21; } else { goto L113; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L114: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L24; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L115: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L27; } else { goto L115; } } } else { goto L114; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L29; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L31; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L33; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L35; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L116: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L38; } else { goto L116; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L117: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L41; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L118: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L44; } else { goto L118; } } } else { goto L117; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L46; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L47; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L48; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L49; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L119: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L51; } else { goto L119; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L120: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L53; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L121: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; func_main_Alim_Non_Crossing_Biased_Descend = Positive_RA_Alt_Thresh__2; goto L55; } else { goto L121; } } } else { goto L120; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L111; } else if((Two_of_Three_Reports_Valid == 0)) { goto L56; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L122: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L123: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L112; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L123; } else if((Two_of_Three_Reports_Valid == 0)) { L124: func_main_Alt_sep = 0; goto L112; } else if((0 > Other_RAC)) { goto L124; } else { goto L124; } } else { goto L122; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L110; } else if((High_Confidence == 0)) { goto L60; } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } else if((2 > Alt_Layer_Value)) { func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L125: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L126: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L127: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L4; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L8; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L14; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L18; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L128: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L21; } else { goto L128; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L129: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L24; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L130: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L27; } else { goto L130; } } } else { goto L129; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L29; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L31; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L33; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L35; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L131: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L38; } else { goto L131; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L132: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L41; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L133: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L44; } else { goto L133; } } } else { goto L132; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L46; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L47; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L48; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L49; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L134: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L51; } else { goto L134; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L135: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L53; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L136: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L55; } else { goto L136; } } } else { goto L135; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L126; } else if((Two_of_Three_Reports_Valid == 0)) { goto L56; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L137: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L138: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L127; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L138; } else if((Two_of_Three_Reports_Valid == 0)) { L139: func_main_Alt_sep = 0; goto L127; } else if((0 > Other_RAC)) { goto L139; } else { goto L139; } } else { goto L137; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L125; } else if((High_Confidence == 0)) { goto L60; } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } else { func_main_Alim = Positive_RA_Alt_Thresh__3; if((0 > High_Confidence) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { L140: func_main_Enabled = 1; if((Other_Capability == 0)) { func_main_Tcas_equipped = 1; if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L141: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; L142: func_main_Upward_preferred_1 = 0; func_main_Result_Non_Crossing_Biased_Climb = 0; func_main_Alim_Non_Crossing_Biased_Climb = Positive_RA_Alt_Thresh__3; if((Climb_Inhibit == 1)) { func_main_Temp11 = (Up_Separation + 100); if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L4; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L8; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L14; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L18; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L143: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L21; } else { goto L143; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L144: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L24; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L145: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L27; } else { goto L145; } } } else { goto L144; } } } } else if((1 > Climb_Inhibit)) { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L29; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L31; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L33; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L35; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L146: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L38; } else { goto L146; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L147: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L41; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L148: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L44; } else { goto L148; } } } else { goto L147; } } } } else { func_main_Temp11 = Up_Separation; if((func_main_Temp11 > Down_Separation)) { func_main_Upward_preferred_1 = 1; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp12 = 1; if((func_main_Temp12 > 0) && (func_main_Alim_Non_Crossing_Biased_Climb > Down_Separation)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Need_upward_RA = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L46; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L47; } } else { func_main_Temp12 = 0; func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L48; } } else { if((Own_Tracked_Alt > Other_Tracked_Alt)) { func_main_Temp13 = 1; if((func_main_Temp13 > 0) && (Cur_Vertical_Sep >= 300) && (Up_Separation >= func_main_Alim_Non_Crossing_Biased_Climb)) { func_main_Result_Non_Crossing_Biased_Climb = 1; func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L49; } else { func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L149: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L51; } else { goto L149; } } } else { func_main_Temp13 = 0; if((func_main_Temp13 == 0)) { L150: func_main_Temp1 = func_main_Result_Non_Crossing_Biased_Climb; if((Other_Tracked_Alt > Own_Tracked_Alt)) { func_main_Temp2 = 1; func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L53; } else { func_main_Temp2 = 0; if((func_main_Temp1 == 0)) { L151: func_main_Upward_preferred_2 = 0; func_main_Result_Non_Crossing_Biased_Descend = 0; goto L55; } else { goto L151; } } } else { goto L150; } } } } } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L141; } else if((Two_of_Three_Reports_Valid == 0)) { goto L56; } else if((0 > Other_RAC)) { goto L56; } else { goto L56; } } else if((0 > Other_Capability)) { L152: if((0 > Two_of_Three_Reports_Valid) && (Other_RAC == 0)) { L153: func_main_Intent_not_known = 1; func_main_Alt_sep = 0; goto L142; } else if((Two_of_Three_Reports_Valid > 0) && (Other_RAC == 0)) { goto L153; } else if((Two_of_Three_Reports_Valid == 0)) { L154: func_main_Alt_sep = 0; goto L142; } else if((0 > Other_RAC)) { goto L154; } else { goto L154; } } else { goto L152; } } else if((High_Confidence > 0) && (600 >= Own_Tracked_Alt_Rate) && (Cur_Vertical_Sep > 600)) { goto L140; } else if((High_Confidence == 0)) { goto L60; } else if((Own_Tracked_Alt_Rate > 600)) { goto L60; } else { goto L60; } } } } }
the_stack_data/26699940.c
/** ****************************************************************************** * @file stm32l4xx_ll_adc.c * @author MCD Application Team * @brief ADC LL module driver ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics 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. * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32l4xx_ll_adc.h" #include "stm32l4xx_ll_bus.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32L4xx_LL_Driver * @{ */ #if defined (ADC1) || defined (ADC2) || defined (ADC3) /** @addtogroup ADC_LL ADC * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @addtogroup ADC_LL_Private_Constants * @{ */ /* Definitions of ADC hardware constraints delays */ /* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */ /* not timeout values: */ /* Timeout values for ADC operations are dependent to device clock */ /* configuration (system clock versus ADC clock), */ /* and therefore must be defined in user application. */ /* Refer to @ref ADC_LL_EC_HW_DELAYS for description of ADC timeout */ /* values definition. */ /* Note: ADC timeout values are defined here in CPU cycles to be independent */ /* of device clock setting. */ /* In user application, ADC timeout values should be defined with */ /* temporal values, in function of device clock settings. */ /* Highest ratio CPU clock frequency vs ADC clock frequency: */ /* - ADC clock from synchronous clock with AHB prescaler 512, */ /* APB prescaler 16, ADC prescaler 4. */ /* - ADC clock from asynchronous clock (PLLSAI) with prescaler 1, */ /* with highest ratio CPU clock frequency vs HSI clock frequency: */ /* CPU clock frequency max 72MHz, PLLSAI freq min 26MHz: ratio 4. */ /* Unit: CPU cycles. */ #define ADC_CLOCK_RATIO_VS_CPU_HIGHEST ((uint32_t) 512U * 16U * 4U) #define ADC_TIMEOUT_DISABLE_CPU_CYCLES (ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U) #define ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES (ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U) /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @addtogroup ADC_LL_Private_Macros * @{ */ /* Check of parameters for configuration of ADC hierarchical scope: */ /* common to several ADC instances. */ #define IS_LL_ADC_COMMON_CLOCK(__CLOCK__) \ ( ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV1) \ || ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV2) \ || ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV4) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV1) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV2) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV4) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV6) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV8) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV10) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV12) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV16) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV32) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV64) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV128) \ || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV256) \ ) /* Check of parameters for configuration of ADC hierarchical scope: */ /* ADC instance. */ #define IS_LL_ADC_RESOLUTION(__RESOLUTION__) \ ( ((__RESOLUTION__) == LL_ADC_RESOLUTION_12B) \ || ((__RESOLUTION__) == LL_ADC_RESOLUTION_10B) \ || ((__RESOLUTION__) == LL_ADC_RESOLUTION_8B) \ || ((__RESOLUTION__) == LL_ADC_RESOLUTION_6B) \ ) #define IS_LL_ADC_DATA_ALIGN(__DATA_ALIGN__) \ ( ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_RIGHT) \ || ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_LEFT) \ ) #define IS_LL_ADC_LOW_POWER(__LOW_POWER__) \ ( ((__LOW_POWER__) == LL_ADC_LP_MODE_NONE) \ || ((__LOW_POWER__) == LL_ADC_LP_AUTOWAIT) \ ) /* Check of parameters for configuration of ADC hierarchical scope: */ /* ADC group regular */ #define IS_LL_ADC_REG_TRIG_SOURCE(__REG_TRIG_SOURCE__) \ ( ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_TRGO2) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH1) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH2) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM1_CH3) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH2) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_CH4) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM4_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM4_CH4) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM6_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM8_TRGO2) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM15_TRGO) \ || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_EXTI_LINE11) \ ) #define IS_LL_ADC_REG_CONTINUOUS_MODE(__REG_CONTINUOUS_MODE__) \ ( ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_SINGLE) \ || ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_CONTINUOUS) \ ) #define IS_LL_ADC_REG_DMA_TRANSFER(__REG_DMA_TRANSFER__) \ ( ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_NONE) \ || ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_LIMITED) \ || ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_UNLIMITED) \ ) #define IS_LL_ADC_REG_OVR_DATA_BEHAVIOR(__REG_OVR_DATA_BEHAVIOR__) \ ( ((__REG_OVR_DATA_BEHAVIOR__) == LL_ADC_REG_OVR_DATA_PRESERVED) \ || ((__REG_OVR_DATA_BEHAVIOR__) == LL_ADC_REG_OVR_DATA_OVERWRITTEN) \ ) #define IS_LL_ADC_REG_SEQ_SCAN_LENGTH(__REG_SEQ_SCAN_LENGTH__) \ ( ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_DISABLE) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS) \ || ((__REG_SEQ_SCAN_LENGTH__) == LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS) \ ) #define IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(__REG_SEQ_DISCONT_MODE__) \ ( ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_DISABLE) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_1RANK) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_2RANKS) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_3RANKS) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_4RANKS) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_5RANKS) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_6RANKS) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_7RANKS) \ || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_8RANKS) \ ) /* Check of parameters for configuration of ADC hierarchical scope: */ /* ADC group injected */ #define IS_LL_ADC_INJ_TRIG_SOURCE(__INJ_TRIG_SOURCE__) \ ( ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_SOFTWARE) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_TRGO2) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM1_CH4) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM2_CH1) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH1) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH3) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM3_CH4) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM4_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM6_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_CH4) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM8_TRGO2) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_TIM15_TRGO) \ || ((__INJ_TRIG_SOURCE__) == LL_ADC_INJ_TRIG_EXT_EXTI_LINE15) \ ) #define IS_LL_ADC_INJ_TRIG_EXT_EDGE(__INJ_TRIG_EXT_EDGE__) \ ( ((__INJ_TRIG_EXT_EDGE__) == LL_ADC_INJ_TRIG_EXT_RISING) \ || ((__INJ_TRIG_EXT_EDGE__) == LL_ADC_INJ_TRIG_EXT_FALLING) \ || ((__INJ_TRIG_EXT_EDGE__) == LL_ADC_INJ_TRIG_EXT_RISINGFALLING) \ ) #define IS_LL_ADC_INJ_TRIG_AUTO(__INJ_TRIG_AUTO__) \ ( ((__INJ_TRIG_AUTO__) == LL_ADC_INJ_TRIG_INDEPENDENT) \ || ((__INJ_TRIG_AUTO__) == LL_ADC_INJ_TRIG_FROM_GRP_REGULAR) \ ) #define IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(__INJ_SEQ_SCAN_LENGTH__) \ ( ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_DISABLE) \ || ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS) \ || ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS) \ || ((__INJ_SEQ_SCAN_LENGTH__) == LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS) \ ) #define IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(__INJ_SEQ_DISCONT_MODE__) \ ( ((__INJ_SEQ_DISCONT_MODE__) == LL_ADC_INJ_SEQ_DISCONT_DISABLE) \ || ((__INJ_SEQ_DISCONT_MODE__) == LL_ADC_INJ_SEQ_DISCONT_1RANK) \ ) #if defined(ADC_MULTIMODE_SUPPORT) /* Check of parameters for configuration of ADC hierarchical scope: */ /* multimode. */ #define IS_LL_ADC_MULTI_MODE(__MULTI_MODE__) \ ( ((__MULTI_MODE__) == LL_ADC_MULTI_INDEPENDENT) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIMULT) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INTERL) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_SIMULT) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_INJ_ALTERN) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_SIM) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_SIM_INJ_ALT) \ || ((__MULTI_MODE__) == LL_ADC_MULTI_DUAL_REG_INT_INJ_SIM) \ ) #define IS_LL_ADC_MULTI_DMA_TRANSFER(__MULTI_DMA_TRANSFER__) \ ( ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_EACH_ADC) \ || ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_LIMIT_RES12_10B) \ || ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_LIMIT_RES8_6B) \ || ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_UNLMT_RES12_10B) \ || ((__MULTI_DMA_TRANSFER__) == LL_ADC_MULTI_REG_DMA_UNLMT_RES8_6B) \ ) #define IS_LL_ADC_MULTI_TWOSMP_DELAY(__MULTI_TWOSMP_DELAY__) \ ( ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_2CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_3CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_4CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_5CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_6CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_7CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_8CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_9CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_10CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_11CYCLES) \ || ((__MULTI_TWOSMP_DELAY__) == LL_ADC_MULTI_TWOSMP_DELAY_12CYCLES) \ ) #define IS_LL_ADC_MULTI_MASTER_SLAVE(__MULTI_MASTER_SLAVE__) \ ( ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_MASTER) \ || ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_SLAVE) \ || ((__MULTI_MASTER_SLAVE__) == LL_ADC_MULTI_MASTER_SLAVE) \ ) #endif /* ADC_MULTIMODE_SUPPORT */ /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup ADC_LL_Exported_Functions * @{ */ /** @addtogroup ADC_LL_EF_Init * @{ */ /** * @brief De-initialize registers of all ADC instances belonging to * the same ADC common instance to their default reset values. * @note This function is performing a hard reset, using high level * clock source RCC ADC reset. * Caution: On this STM32 serie, if several ADC instances are available * on the selected device, RCC ADC reset will reset * all ADC instances belonging to the common ADC instance. * To de-initialize only 1 ADC instance, use * function @ref LL_ADC_DeInit(). * @param ADCxy_COMMON ADC common instance * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) * @retval An ErrorStatus enumeration value: * - SUCCESS: ADC common registers are de-initialized * - ERROR: not applicable */ ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON) { /* Check the parameters */ assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON)); /* Force reset of ADC clock (core clock) */ LL_AHB2_GRP1_ForceReset(LL_AHB2_GRP1_PERIPH_ADC); /* Release reset of ADC clock (core clock) */ LL_AHB2_GRP1_ReleaseReset(LL_AHB2_GRP1_PERIPH_ADC); return SUCCESS; } /** * @brief Initialize some features of ADC common parameters * (all ADC instances belonging to the same ADC common instance) * and multimode (for devices with several ADC instances available). * @note The setting of ADC common parameters is conditioned to * ADC instances state: * All ADC instances belonging to the same ADC common instance * must be disabled. * @param ADCxy_COMMON ADC common instance * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() ) * @param ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: ADC common registers are initialized * - ERROR: ADC common registers are not initialized */ ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON)); assert_param(IS_LL_ADC_COMMON_CLOCK(ADC_CommonInitStruct->CommonClock)); #if defined(ADC_MULTIMODE_SUPPORT) assert_param(IS_LL_ADC_MULTI_MODE(ADC_CommonInitStruct->Multimode)); if(ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT) { assert_param(IS_LL_ADC_MULTI_DMA_TRANSFER(ADC_CommonInitStruct->MultiDMATransfer)); assert_param(IS_LL_ADC_MULTI_TWOSMP_DELAY(ADC_CommonInitStruct->MultiTwoSamplingDelay)); } #endif /* ADC_MULTIMODE_SUPPORT */ /* Note: Hardware constraint (refer to description of functions */ /* "LL_ADC_SetCommonXXX()" and "LL_ADC_SetMultiXXX()"): */ /* On this STM32 serie, setting of these features is conditioned to */ /* ADC state: */ /* All ADC instances of the ADC common group must be disabled. */ if(__LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(ADCxy_COMMON) == 0U) { /* Configuration of ADC hierarchical scope: */ /* - common to several ADC */ /* (all ADC instances belonging to the same ADC common instance) */ /* - Set ADC clock (conversion clock) */ /* - multimode (if several ADC instances available on the */ /* selected device) */ /* - Set ADC multimode configuration */ /* - Set ADC multimode DMA transfer */ /* - Set ADC multimode: delay between 2 sampling phases */ #if defined(ADC_MULTIMODE_SUPPORT) if(ADC_CommonInitStruct->Multimode != LL_ADC_MULTI_INDEPENDENT) { MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC | ADC_CCR_DUAL | ADC_CCR_MDMA | ADC_CCR_DELAY , ADC_CommonInitStruct->CommonClock | ADC_CommonInitStruct->Multimode | ADC_CommonInitStruct->MultiDMATransfer | ADC_CommonInitStruct->MultiTwoSamplingDelay ); } else { MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_CKMODE | ADC_CCR_PRESC | ADC_CCR_DUAL | ADC_CCR_MDMA | ADC_CCR_DELAY , ADC_CommonInitStruct->CommonClock | LL_ADC_MULTI_INDEPENDENT ); } #else LL_ADC_SetCommonClock(ADCxy_COMMON, ADC_CommonInitStruct->CommonClock); #endif } else { /* Initialization error: One or several ADC instances belonging to */ /* the same ADC common instance are not disabled. */ status = ERROR; } return status; } /** * @brief Set each @ref LL_ADC_CommonInitTypeDef field to default value. * @param ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct) { /* Set ADC_CommonInitStruct fields to default values */ /* Set fields of ADC common */ /* (all ADC instances belonging to the same ADC common instance) */ ADC_CommonInitStruct->CommonClock = LL_ADC_CLOCK_SYNC_PCLK_DIV2; #if defined(ADC_MULTIMODE_SUPPORT) /* Set fields of ADC multimode */ ADC_CommonInitStruct->Multimode = LL_ADC_MULTI_INDEPENDENT; ADC_CommonInitStruct->MultiDMATransfer = LL_ADC_MULTI_REG_DMA_EACH_ADC; ADC_CommonInitStruct->MultiTwoSamplingDelay = LL_ADC_MULTI_TWOSMP_DELAY_1CYCLE; #endif /* ADC_MULTIMODE_SUPPORT */ } /** * @brief De-initialize registers of the selected ADC instance * to their default reset values. * @note To reset all ADC instances quickly (perform a hard reset), * use function @ref LL_ADC_CommonDeInit(). * @note If this functions returns error status, it means that ADC instance * is in an unknown state. * In this case, perform a hard reset using high level * clock source RCC ADC reset. * Caution: On this STM32 serie, if several ADC instances are available * on the selected device, RCC ADC reset will reset * all ADC instances belonging to the common ADC instance. * Refer to function @ref LL_ADC_CommonDeInit(). * @param ADCx ADC instance * @retval An ErrorStatus enumeration value: * - SUCCESS: ADC registers are de-initialized * - ERROR: ADC registers are not de-initialized */ ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx) { ErrorStatus status = SUCCESS; __IO uint32_t timeout_cpu_cycles = 0U; /* Check the parameters */ assert_param(IS_ADC_ALL_INSTANCE(ADCx)); /* Disable ADC instance if not already disabled. */ if(LL_ADC_IsEnabled(ADCx) == 1U) { /* Set ADC group regular trigger source to SW start to ensure to not */ /* have an external trigger event occurring during the conversion stop */ /* ADC disable process. */ LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE); /* Stop potential ADC conversion on going on ADC group regular. */ if(LL_ADC_REG_IsConversionOngoing(ADCx) != 0U) { if(LL_ADC_REG_IsStopConversionOngoing(ADCx) == 0U) { LL_ADC_REG_StopConversion(ADCx); } } /* Set ADC group injected trigger source to SW start to ensure to not */ /* have an external trigger event occurring during the conversion stop */ /* ADC disable process. */ LL_ADC_INJ_SetTriggerSource(ADCx, LL_ADC_INJ_TRIG_SOFTWARE); /* Stop potential ADC conversion on going on ADC group injected. */ if(LL_ADC_INJ_IsConversionOngoing(ADCx) != 0U) { if(LL_ADC_INJ_IsStopConversionOngoing(ADCx) == 0U) { LL_ADC_INJ_StopConversion(ADCx); } } /* Wait for ADC conversions are effectively stopped */ timeout_cpu_cycles = ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES; while (( LL_ADC_REG_IsStopConversionOngoing(ADCx) | LL_ADC_INJ_IsStopConversionOngoing(ADCx)) == 1U) { if(timeout_cpu_cycles-- == 0U) { /* Time-out error */ status = ERROR; } } /* Flush group injected contexts queue (register JSQR): */ /* Note: Bit JQM must be set to empty the contexts queue (otherwise */ /* contexts queue is maintained with the last active context). */ LL_ADC_INJ_SetQueueMode(ADCx, LL_ADC_INJ_QUEUE_2CONTEXTS_END_EMPTY); /* Disable the ADC instance */ LL_ADC_Disable(ADCx); /* Wait for ADC instance is effectively disabled */ timeout_cpu_cycles = ADC_TIMEOUT_DISABLE_CPU_CYCLES; while (LL_ADC_IsDisableOngoing(ADCx) == 1U) { if(timeout_cpu_cycles-- == 0U) { /* Time-out error */ status = ERROR; } } } /* Check whether ADC state is compliant with expected state */ if(READ_BIT(ADCx->CR, ( ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN ) ) == 0U) { /* ========== Reset ADC registers ========== */ /* Reset register IER */ CLEAR_BIT(ADCx->IER, ( LL_ADC_IT_ADRDY | LL_ADC_IT_EOC | LL_ADC_IT_EOS | LL_ADC_IT_OVR | LL_ADC_IT_EOSMP | LL_ADC_IT_JEOC | LL_ADC_IT_JEOS | LL_ADC_IT_JQOVF | LL_ADC_IT_AWD1 | LL_ADC_IT_AWD2 | LL_ADC_IT_AWD3 ) ); /* Reset register ISR */ SET_BIT(ADCx->ISR, ( LL_ADC_FLAG_ADRDY | LL_ADC_FLAG_EOC | LL_ADC_FLAG_EOS | LL_ADC_FLAG_OVR | LL_ADC_FLAG_EOSMP | LL_ADC_FLAG_JEOC | LL_ADC_FLAG_JEOS | LL_ADC_FLAG_JQOVF | LL_ADC_FLAG_AWD1 | LL_ADC_FLAG_AWD2 | LL_ADC_FLAG_AWD3 ) ); /* Reset register CR */ /* - Bits ADC_CR_JADSTP, ADC_CR_ADSTP, ADC_CR_JADSTART, ADC_CR_ADSTART, */ /* ADC_CR_ADCAL, ADC_CR_ADDIS, ADC_CR_ADEN are in */ /* access mode "read-set": no direct reset applicable. */ /* - Reset Calibration mode to default setting (single ended). */ /* - Disable ADC internal voltage regulator. */ /* - Enable ADC deep power down. */ /* Note: ADC internal voltage regulator disable and ADC deep power */ /* down enable are conditioned to ADC state disabled: */ /* already done above. */ CLEAR_BIT(ADCx->CR, ADC_CR_ADVREGEN | ADC_CR_ADCALDIF); SET_BIT(ADCx->CR, ADC_CR_DEEPPWD); /* Reset register CFGR */ MODIFY_REG(ADCx->CFGR, ( ADC_CFGR_AWD1CH | ADC_CFGR_JAUTO | ADC_CFGR_JAWD1EN | ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL | ADC_CFGR_JQM | ADC_CFGR_JDISCEN | ADC_CFGR_DISCNUM | ADC_CFGR_DISCEN | ADC_CFGR_AUTDLY | ADC_CFGR_CONT | ADC_CFGR_OVRMOD | ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL | ADC_CFGR_ALIGN | ADC_CFGR_RES | ADC_CFGR_DMACFG | ADC_CFGR_DMAEN ), ADC_CFGR_JQDIS ); /* Reset register CFGR2 */ CLEAR_BIT(ADCx->CFGR2, ( ADC_CFGR2_ROVSM | ADC_CFGR2_TROVS | ADC_CFGR2_OVSS | ADC_CFGR2_OVSR | ADC_CFGR2_JOVSE | ADC_CFGR2_ROVSE) ); /* Reset register SMPR1 */ CLEAR_BIT(ADCx->SMPR1, ( ADC_SMPR1_SMP9 | ADC_SMPR1_SMP8 | ADC_SMPR1_SMP7 | ADC_SMPR1_SMP6 | ADC_SMPR1_SMP5 | ADC_SMPR1_SMP4 | ADC_SMPR1_SMP3 | ADC_SMPR1_SMP2 | ADC_SMPR1_SMP1) ); /* Reset register SMPR2 */ CLEAR_BIT(ADCx->SMPR2, ( ADC_SMPR2_SMP18 | ADC_SMPR2_SMP17 | ADC_SMPR2_SMP16 | ADC_SMPR2_SMP15 | ADC_SMPR2_SMP14 | ADC_SMPR2_SMP13 | ADC_SMPR2_SMP12 | ADC_SMPR2_SMP11 | ADC_SMPR2_SMP10) ); /* Reset register TR1 */ MODIFY_REG(ADCx->TR1, ADC_TR1_HT1 | ADC_TR1_LT1, ADC_TR1_HT1); /* Reset register TR2 */ MODIFY_REG(ADCx->TR2, ADC_TR2_HT2 | ADC_TR2_LT2, ADC_TR2_HT2); /* Reset register TR3 */ MODIFY_REG(ADCx->TR3, ADC_TR3_HT3 | ADC_TR3_LT3, ADC_TR3_HT3); /* Reset register SQR1 */ CLEAR_BIT(ADCx->SQR1, ( ADC_SQR1_SQ4 | ADC_SQR1_SQ3 | ADC_SQR1_SQ2 | ADC_SQR1_SQ1 | ADC_SQR1_L) ); /* Reset register SQR2 */ CLEAR_BIT(ADCx->SQR2, ( ADC_SQR2_SQ9 | ADC_SQR2_SQ8 | ADC_SQR2_SQ7 | ADC_SQR2_SQ6 | ADC_SQR2_SQ5) ); /* Reset register SQR3 */ CLEAR_BIT(ADCx->SQR3, ( ADC_SQR3_SQ14 | ADC_SQR3_SQ13 | ADC_SQR3_SQ12 | ADC_SQR3_SQ11 | ADC_SQR3_SQ10) ); /* Reset register SQR4 */ CLEAR_BIT(ADCx->SQR4, ADC_SQR4_SQ16 | ADC_SQR4_SQ15); /* Reset register JSQR */ CLEAR_BIT(ADCx->JSQR, ( ADC_JSQR_JL | ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN | ADC_JSQR_JSQ4 | ADC_JSQR_JSQ3 | ADC_JSQR_JSQ2 | ADC_JSQR_JSQ1 ) ); /* Reset register DR */ /* Note: bits in access mode read only, no direct reset applicable */ /* Reset register OFR1 */ CLEAR_BIT(ADCx->OFR1, ADC_OFR1_OFFSET1_EN | ADC_OFR1_OFFSET1_CH | ADC_OFR1_OFFSET1); /* Reset register OFR2 */ CLEAR_BIT(ADCx->OFR2, ADC_OFR2_OFFSET2_EN | ADC_OFR2_OFFSET2_CH | ADC_OFR2_OFFSET2); /* Reset register OFR3 */ CLEAR_BIT(ADCx->OFR3, ADC_OFR3_OFFSET3_EN | ADC_OFR3_OFFSET3_CH | ADC_OFR3_OFFSET3); /* Reset register OFR4 */ CLEAR_BIT(ADCx->OFR4, ADC_OFR4_OFFSET4_EN | ADC_OFR4_OFFSET4_CH | ADC_OFR4_OFFSET4); /* Reset registers JDR1, JDR2, JDR3, JDR4 */ /* Note: bits in access mode read only, no direct reset applicable */ /* Reset register AWD2CR */ CLEAR_BIT(ADCx->AWD2CR, ADC_AWD2CR_AWD2CH); /* Reset register AWD3CR */ CLEAR_BIT(ADCx->AWD3CR, ADC_AWD3CR_AWD3CH); /* Reset register DIFSEL */ CLEAR_BIT(ADCx->DIFSEL, ADC_DIFSEL_DIFSEL); /* Reset register CALFACT */ CLEAR_BIT(ADCx->CALFACT, ADC_CALFACT_CALFACT_D | ADC_CALFACT_CALFACT_S); } else { /* ADC instance is in an unknown state */ /* Need to performing a hard reset of ADC instance, using high level */ /* clock source RCC ADC reset. */ /* Caution: On this STM32 serie, if several ADC instances are available */ /* on the selected device, RCC ADC reset will reset */ /* all ADC instances belonging to the common ADC instance. */ /* Caution: On this STM32 serie, if several ADC instances are available */ /* on the selected device, RCC ADC reset will reset */ /* all ADC instances belonging to the common ADC instance. */ status = ERROR; } return status; } /** * @brief Initialize some features of ADC instance. * @note These parameters have an impact on ADC scope: ADC instance. * Affects both group regular and group injected (availability * of ADC group injected depends on STM32 families). * Refer to corresponding unitary functions into * @ref ADC_LL_EF_Configuration_ADC_Instance . * @note The setting of these parameters by function @ref LL_ADC_Init() * is conditioned to ADC state: * ADC instance must be disabled. * This condition is applied to all ADC features, for efficiency * and compatibility over all STM32 families. However, the different * features can be set under different ADC state conditions * (setting possible with ADC enabled without conversion on going, * ADC enabled with conversion on going, ...) * Each feature can be updated afterwards with a unitary function * and potentially with ADC in a different state than disabled, * refer to description of each function for setting * conditioned to ADC state. * @note After using this function, some other features must be configured * using LL unitary functions. * The minimum configuration remaining to be done is: * - Set ADC group regular or group injected sequencer: * map channel on the selected sequencer rank. * Refer to function @ref LL_ADC_REG_SetSequencerRanks(). * - Set ADC channel sampling time * Refer to function LL_ADC_SetChannelSamplingTime(); * @param ADCx ADC instance * @param ADC_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: ADC registers are initialized * - ERROR: ADC registers are not initialized */ ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_ADC_ALL_INSTANCE(ADCx)); assert_param(IS_LL_ADC_RESOLUTION(ADC_InitStruct->Resolution)); assert_param(IS_LL_ADC_DATA_ALIGN(ADC_InitStruct->DataAlignment)); assert_param(IS_LL_ADC_LOW_POWER(ADC_InitStruct->LowPowerMode)); /* Note: Hardware constraint (refer to description of this function): */ /* ADC instance must be disabled. */ if(LL_ADC_IsEnabled(ADCx) == 0U) { /* Configuration of ADC hierarchical scope: */ /* - ADC instance */ /* - Set ADC data resolution */ /* - Set ADC conversion data alignment */ /* - Set ADC low power mode */ MODIFY_REG(ADCx->CFGR, ADC_CFGR_RES | ADC_CFGR_ALIGN | ADC_CFGR_AUTDLY , ADC_InitStruct->Resolution | ADC_InitStruct->DataAlignment | ADC_InitStruct->LowPowerMode ); } else { /* Initialization error: ADC instance is not disabled. */ status = ERROR; } return status; } /** * @brief Set each @ref LL_ADC_InitTypeDef field to default value. * @param ADC_InitStruct Pointer to a @ref LL_ADC_InitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct) { /* Set ADC_InitStruct fields to default values */ /* Set fields of ADC instance */ ADC_InitStruct->Resolution = LL_ADC_RESOLUTION_12B; ADC_InitStruct->DataAlignment = LL_ADC_DATA_ALIGN_RIGHT; ADC_InitStruct->LowPowerMode = LL_ADC_LP_MODE_NONE; } /** * @brief Initialize some features of ADC group regular. * @note These parameters have an impact on ADC scope: ADC group regular. * Refer to corresponding unitary functions into * @ref ADC_LL_EF_Configuration_ADC_Group_Regular * (functions with prefix "REG"). * @note The setting of these parameters by function @ref LL_ADC_Init() * is conditioned to ADC state: * ADC instance must be disabled. * This condition is applied to all ADC features, for efficiency * and compatibility over all STM32 families. However, the different * features can be set under different ADC state conditions * (setting possible with ADC enabled without conversion on going, * ADC enabled with conversion on going, ...) * Each feature can be updated afterwards with a unitary function * and potentially with ADC in a different state than disabled, * refer to description of each function for setting * conditioned to ADC state. * @note After using this function, other features must be configured * using LL unitary functions. * The minimum configuration remaining to be done is: * - Set ADC group regular or group injected sequencer: * map channel on the selected sequencer rank. * Refer to function @ref LL_ADC_REG_SetSequencerRanks(). * - Set ADC channel sampling time * Refer to function LL_ADC_SetChannelSamplingTime(); * @param ADCx ADC instance * @param ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: ADC registers are initialized * - ERROR: ADC registers are not initialized */ ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_ADC_ALL_INSTANCE(ADCx)); assert_param(IS_LL_ADC_REG_TRIG_SOURCE(ADC_REG_InitStruct->TriggerSource)); assert_param(IS_LL_ADC_REG_SEQ_SCAN_LENGTH(ADC_REG_InitStruct->SequencerLength)); if(ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE) { assert_param(IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(ADC_REG_InitStruct->SequencerDiscont)); } assert_param(IS_LL_ADC_REG_CONTINUOUS_MODE(ADC_REG_InitStruct->ContinuousMode)); assert_param(IS_LL_ADC_REG_DMA_TRANSFER(ADC_REG_InitStruct->DMATransfer)); assert_param(IS_LL_ADC_REG_OVR_DATA_BEHAVIOR(ADC_REG_InitStruct->Overrun)); /* Note: Hardware constraint (refer to description of this function): */ /* ADC instance must be disabled. */ if(LL_ADC_IsEnabled(ADCx) == 0U) { /* Configuration of ADC hierarchical scope: */ /* - ADC group regular */ /* - Set ADC group regular trigger source */ /* - Set ADC group regular sequencer length */ /* - Set ADC group regular sequencer discontinuous mode */ /* - Set ADC group regular continuous mode */ /* - Set ADC group regular conversion data transfer: no transfer or */ /* transfer by DMA, and DMA requests mode */ /* - Set ADC group regular overrun behavior */ /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by */ /* setting of trigger source to SW start. */ if(ADC_REG_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE) { MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN | ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM | ADC_CFGR_CONT | ADC_CFGR_DMAEN | ADC_CFGR_DMACFG | ADC_CFGR_OVRMOD , ADC_REG_InitStruct->TriggerSource | ADC_REG_InitStruct->SequencerDiscont | ADC_REG_InitStruct->ContinuousMode | ADC_REG_InitStruct->DMATransfer | ADC_REG_InitStruct->Overrun ); } else { MODIFY_REG(ADCx->CFGR, ADC_CFGR_EXTSEL | ADC_CFGR_EXTEN | ADC_CFGR_DISCEN | ADC_CFGR_DISCNUM | ADC_CFGR_CONT | ADC_CFGR_DMAEN | ADC_CFGR_DMACFG | ADC_CFGR_OVRMOD , ADC_REG_InitStruct->TriggerSource | LL_ADC_REG_SEQ_DISCONT_DISABLE | ADC_REG_InitStruct->ContinuousMode | ADC_REG_InitStruct->DMATransfer | ADC_REG_InitStruct->Overrun ); } /* Set ADC group regular sequencer length and scan direction */ LL_ADC_REG_SetSequencerLength(ADCx, ADC_REG_InitStruct->SequencerLength); } else { /* Initialization error: ADC instance is not disabled. */ status = ERROR; } return status; } /** * @brief Set each @ref LL_ADC_REG_InitTypeDef field to default value. * @param ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct) { /* Set ADC_REG_InitStruct fields to default values */ /* Set fields of ADC group regular */ /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by */ /* setting of trigger source to SW start. */ ADC_REG_InitStruct->TriggerSource = LL_ADC_REG_TRIG_SOFTWARE; ADC_REG_InitStruct->SequencerLength = LL_ADC_REG_SEQ_SCAN_DISABLE; ADC_REG_InitStruct->SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE; ADC_REG_InitStruct->ContinuousMode = LL_ADC_REG_CONV_SINGLE; ADC_REG_InitStruct->DMATransfer = LL_ADC_REG_DMA_TRANSFER_NONE; ADC_REG_InitStruct->Overrun = LL_ADC_REG_OVR_DATA_OVERWRITTEN; } /** * @brief Initialize some features of ADC group injected. * @note These parameters have an impact on ADC scope: ADC group injected. * Refer to corresponding unitary functions into * @ref ADC_LL_EF_Configuration_ADC_Group_Regular * (functions with prefix "INJ"). * @note The setting of these parameters by function @ref LL_ADC_Init() * is conditioned to ADC state: * ADC instance must be disabled. * This condition is applied to all ADC features, for efficiency * and compatibility over all STM32 families. However, the different * features can be set under different ADC state conditions * (setting possible with ADC enabled without conversion on going, * ADC enabled with conversion on going, ...) * Each feature can be updated afterwards with a unitary function * and potentially with ADC in a different state than disabled, * refer to description of each function for setting * conditioned to ADC state. * @note After using this function, other features must be configured * using LL unitary functions. * The minimum configuration remaining to be done is: * - Set ADC group injected sequencer: * map channel on the selected sequencer rank. * Refer to function @ref LL_ADC_INJ_SetSequencerRanks(). * - Set ADC channel sampling time * Refer to function LL_ADC_SetChannelSamplingTime(); * @param ADCx ADC instance * @param ADC_INJ_InitStruct Pointer to a @ref LL_ADC_INJ_InitTypeDef structure * @retval An ErrorStatus enumeration value: * - SUCCESS: ADC registers are initialized * - ERROR: ADC registers are not initialized */ ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct) { ErrorStatus status = SUCCESS; /* Check the parameters */ assert_param(IS_ADC_ALL_INSTANCE(ADCx)); assert_param(IS_LL_ADC_INJ_TRIG_SOURCE(ADC_INJ_InitStruct->TriggerSource)); assert_param(IS_LL_ADC_INJ_SEQ_SCAN_LENGTH(ADC_INJ_InitStruct->SequencerLength)); if(ADC_INJ_InitStruct->SequencerLength != LL_ADC_INJ_SEQ_SCAN_DISABLE) { assert_param(IS_LL_ADC_INJ_SEQ_SCAN_DISCONT_MODE(ADC_INJ_InitStruct->SequencerDiscont)); } assert_param(IS_LL_ADC_INJ_TRIG_AUTO(ADC_INJ_InitStruct->TrigAuto)); /* Note: Hardware constraint (refer to description of this function): */ /* ADC instance must be disabled. */ if(LL_ADC_IsEnabled(ADCx) == 0U) { /* Configuration of ADC hierarchical scope: */ /* - ADC group injected */ /* - Set ADC group injected trigger source */ /* - Set ADC group injected sequencer length */ /* - Set ADC group injected sequencer discontinuous mode */ /* - Set ADC group injected conversion trigger: independent or */ /* from ADC group regular */ /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by */ /* setting of trigger source to SW start. */ if(ADC_INJ_InitStruct->SequencerLength != LL_ADC_REG_SEQ_SCAN_DISABLE) { MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN | ADC_CFGR_JAUTO , ADC_INJ_InitStruct->SequencerDiscont | ADC_INJ_InitStruct->TrigAuto ); } else { MODIFY_REG(ADCx->CFGR, ADC_CFGR_JDISCEN | ADC_CFGR_JAUTO , LL_ADC_REG_SEQ_DISCONT_DISABLE | ADC_INJ_InitStruct->TrigAuto ); } MODIFY_REG(ADCx->JSQR, ADC_JSQR_JEXTSEL | ADC_JSQR_JEXTEN | ADC_JSQR_JL , ADC_INJ_InitStruct->TriggerSource | ADC_INJ_InitStruct->SequencerLength ); } else { /* Initialization error: ADC instance is not disabled. */ status = ERROR; } return status; } /** * @brief Set each @ref LL_ADC_INJ_InitTypeDef field to default value. * @param ADC_INJ_InitStruct Pointer to a @ref LL_ADC_INJ_InitTypeDef structure * whose fields will be set to default values. * @retval None */ void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct) { /* Set ADC_INJ_InitStruct fields to default values */ /* Set fields of ADC group injected */ ADC_INJ_InitStruct->TriggerSource = LL_ADC_INJ_TRIG_SOFTWARE; ADC_INJ_InitStruct->SequencerLength = LL_ADC_INJ_SEQ_SCAN_DISABLE; ADC_INJ_InitStruct->SequencerDiscont = LL_ADC_INJ_SEQ_DISCONT_DISABLE; ADC_INJ_InitStruct->TrigAuto = LL_ADC_INJ_TRIG_INDEPENDENT; } /** * @} */ /** * @} */ /** * @} */ #endif /* ADC1 || ADC2 || ADC3 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/573949.c
#include <stdio.h> #include <stdlib.h> //https://www.hackerrank.com/challenges/ctci-recursive-staircase/problem?h_l=interview&playlist_slugs%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D=recursion-backtracking // Complexity: O(n) int stepPermsMemo(int n,int memo[]){ printf("n: %d memo: %d\t",n,memo[n]); if(n<0){ return 0; }else if(n==0){ return 1; }else if(memo[n]>-1){ return memo[n]; }else{ memo[n]=stepPermsMemo(n-1,memo)+stepPermsMemo(n-2,memo)+stepPermsMemo(n-3,memo); return memo[n]; } } // Complete the stepPerms function below. int stepPerms(int n) { int memo[n+1]; for(int i=0;i<=n;i++){ memo[i]=-1; } return stepPermsMemo(n,memo); } int main() { printf("%d\n",stepPerms(3)); }
the_stack_data/55396.c
#define NITER 4 void psdes(unsigned long *lword, unsigned long *irword) { unsigned long i,ia,ib,iswap,itmph=0,itmpl=0; static unsigned long c1[NITER]={ 0xbaa96887L, 0x1e17d32cL, 0x03bcdc3cL, 0x0f33d1b2L}; static unsigned long c2[NITER]={ 0x4b0f3b58L, 0xe874f0c3L, 0x6955c5a6L, 0x55a7ca46L}; for (i=0;i<NITER;i++) { ia=(iswap=(*irword)) ^ c1[i]; itmpl = ia & 0xffff; itmph = ia >> 16; ib=itmpl*itmpl+ ~(itmph*itmph); *irword=(*lword) ^ (((ia = (ib >> 16) | ((ib & 0xffff) << 16)) ^ c2[i])+itmpl*itmph); *lword=iswap; } } #undef NITER
the_stack_data/156394014.c
void foo() { int a; #pragma scop A: a = 5; B: a = 7; #pragma endscop }
the_stack_data/1065887.c
// Andrew Taylor - [email protected] // 08/06/2020 // Convert an integer to a string of hexadecimal digits // without using snprintf // to demonstrate using bitwise operators to extract digits /*``` $ dcc int_to_hex_string.c -o int_to_hex_string $ ./int_to_hex_string $ ./int_to_hex_string Enter a positive int: 42 42 = 0x0000002A $ ./int_to_hex_string Enter a positive int: 65535 65535 = 0x0000FFFF $ ./int_to_hex_string Enter a positive int: 3735928559 3735928559 = 0xDEADBEEF $ ```*/ #include <stdio.h> #include <stdint.h> #include <stdlib.h> char *int_to_hex_string(uint32_t n); int main(void) { uint32_t a = 0; printf("Enter a positive int: "); scanf("%u", &a); char *hex_string = int_to_hex_string(a); // print the returned string printf("%u = 0x%s\n", a, hex_string); free(hex_string); return 0; } // return a malloced string containing the hexadecimal digits of n char *int_to_hex_string(uint32_t n) { // sizeof return number of bytes in n's representation // each byte is 2 hexadecimal digits int n_hex_digits = 2 * (sizeof n); // allocate memory to hold the hex digits + a terminating 0 char *string = malloc(n_hex_digits + 1); // print hex digits from most significant to least significant for (int which_digit = 0; which_digit < n_hex_digits; which_digit++) { // shift value across so hex digit we want // is in bottom 4 bits int bit_shift = 4 * which_digit; uint32_t shifted_value = n >> bit_shift; // mask off (zero) all bits but the bottom 4 bites int hex_digit = shifted_value & 0xF; // hex digit will be a value 0..15 // obtain the corresponding ASCII value // "0123456789ABCDEF" is a char array // containing the appropriate ASCII values int hex_digit_ascii = "0123456789ABCDEF"[hex_digit]; string[which_digit] = hex_digit_ascii; } // 0 terminate the array string[n_hex_digits] = 0; return string; }
the_stack_data/22898.c
#include <stdio.h> #include <stdlib.h> struct NODE { int key; struct NODE *next; }; struct NODE *createNewNode(int key) { struct NODE *newNode = (struct NODE *)malloc(sizeof(struct NODE)); newNode->key = key; newNode->next = NULL; return newNode; } struct NODE *buildingOneTwoThree() { struct NODE *first = NULL; struct NODE *second = NULL; struct NODE *third = NULL; first = (struct NODE *)malloc(sizeof(struct NODE)); second = (struct NODE *)malloc(sizeof(struct NODE)); third = (struct NODE *)malloc(sizeof(struct NODE)); first->key = 1; first->next = second; second->key = 250; second->next = third; third->key = 3; third->next = NULL; return first; } int Length(struct NODE *head) { struct NODE *ptr = head; int count = 0; while (ptr != NULL) { count++; ptr = ptr->next; } return count; } int searchKey(struct NODE *list_head, int searchKey) { struct NODE *ptr = list_head; while (ptr != NULL) { if (ptr->key != searchKey) ptr = ptr->next; else return 1; } return 0; } void addNode(struct NODE *head, struct NODE *node) { struct NODE *prev; while (head != NULL) { if (head->key > node->key) break; prev = head; head = head->next; } prev->next = node; node->next = head; } void searchTest() { struct NODE *myList = buildingOneTwoThree(); addNode(myList, createNewNode(200)); int found = searchKey(myList, 250); if (found) printf("Search key found\n"); else printf("Search key not found\n"); } void deleteNode(struct NODE *head, struct NODE node) { struct NODE *ptr = head; struct NODE *prev = NULL; while (ptr != NULL) { if (ptr->key == node.key) break; prev = ptr; ptr = ptr->next; } prev->next = ptr->next; } void displayList(struct NODE *head) { struct NODE *ptr = head; while (ptr != NULL) { printf("[%d]-->", ptr->key); ptr = ptr->next; } printf("[NULL]\n\n"); } int main() { searchTest(); }
the_stack_data/37637849.c
/* * Copyright (c) 2003 Constantin S. Svintsoff <[email protected]> * * 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 names of the authors may not be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 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. */ #include <sys/cdefs.h> #include <sys/param.h> #include <sys/stat.h> #include <errno.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #if !__APPLE__ extern size_t strlcpy(char * dst, const char * src, size_t size); extern size_t strlcat(char * dst, const char * src, size_t size); #endif /* * Find the real name of path, by removing all ".", ".." and symlink * components. Returns (resolved) on success, or (NULL) on failure, * in which case the path which caused trouble is left in (resolved). */ char * realpath(const char * __restrict path, char * __restrict resolved) { struct stat sb; char *p, *q, *s; size_t left_len, resolved_len; unsigned symlinks; int m, slen; char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX]; if (path == NULL) { errno = EINVAL; return (NULL); } if (path[0] == '\0') { errno = ENOENT; return (NULL); } if (resolved == NULL) { resolved = malloc(PATH_MAX); if (resolved == NULL) return (NULL); m = 1; } else m = 0; symlinks = 0; if (path[0] == '/') { resolved[0] = '/'; resolved[1] = '\0'; if (path[1] == '\0') return (resolved); resolved_len = 1; left_len = strlcpy(left, path + 1, sizeof(left)); } else { if (getcwd(resolved, PATH_MAX) == NULL) { if (m) free(resolved); else { resolved[0] = '.'; resolved[1] = '\0'; } return (NULL); } resolved_len = strlen(resolved); left_len = strlcpy(left, path, sizeof(left)); } if (left_len >= sizeof(left) || resolved_len >= PATH_MAX) { if (m) free(resolved); errno = ENAMETOOLONG; return (NULL); } /* * Iterate over path components in `left'. */ while (left_len != 0) { /* * Extract the next path component and adjust `left' * and its length. */ p = strchr(left, '/'); s = p ? p : left + left_len; if (s - left >= sizeof(next_token)) { if (m) free(resolved); errno = ENAMETOOLONG; return (NULL); } memcpy(next_token, left, s - left); next_token[s - left] = '\0'; left_len -= s - left; if (p != NULL) memmove(left, s + 1, left_len + 1); if (resolved[resolved_len - 1] != '/') { if (resolved_len + 1 >= PATH_MAX) { if (m) free(resolved); errno = ENAMETOOLONG; return (NULL); } resolved[resolved_len++] = '/'; resolved[resolved_len] = '\0'; } if (next_token[0] == '\0') { /* * Handle consequential slashes. The path * before slash shall point to a directory. * * Only the trailing slashes are not covered * by other checks in the loop, but we verify * the prefix for any (rare) "//" or "/\0" * occurrence to not implement lookahead. */ if (lstat(resolved, &sb) != 0) { if (m) free(resolved); return (NULL); } if (!S_ISDIR(sb.st_mode)) { if (m) free(resolved); errno = ENOTDIR; return (NULL); } continue; } else if (strcmp(next_token, ".") == 0) continue; else if (strcmp(next_token, "..") == 0) { /* * Strip the last path component except when we have * single "/" */ if (resolved_len > 1) { resolved[resolved_len - 1] = '\0'; q = strrchr(resolved, '/') + 1; *q = '\0'; resolved_len = q - resolved; } continue; } /* * Append the next path component and lstat() it. */ resolved_len = strlcat(resolved, next_token, PATH_MAX); if (resolved_len >= PATH_MAX) { if (m) free(resolved); errno = ENAMETOOLONG; return (NULL); } if (lstat(resolved, &sb) != 0) { if (m) free(resolved); return (NULL); } if (S_ISLNK(sb.st_mode)) { if (symlinks++ > MAXSYMLINKS) { if (m) free(resolved); errno = ELOOP; return (NULL); } slen = readlink(resolved, symlink, sizeof(symlink) - 1); if (slen < 0) { if (m) free(resolved); return (NULL); } symlink[slen] = '\0'; if (symlink[0] == '/') { resolved[1] = 0; resolved_len = 1; } else if (resolved_len > 1) { /* Strip the last path component. */ resolved[resolved_len - 1] = '\0'; q = strrchr(resolved, '/') + 1; *q = '\0'; resolved_len = q - resolved; } /* * If there are any path components left, then * append them to symlink. The result is placed * in `left'. */ if (p != NULL) { if (symlink[slen - 1] != '/') { if (slen + 1 >= sizeof(symlink)) { if (m) free(resolved); errno = ENAMETOOLONG; return (NULL); } symlink[slen] = '/'; symlink[slen + 1] = 0; } left_len = strlcat(symlink, left, sizeof(symlink)); if (left_len >= sizeof(left)) { if (m) free(resolved); errno = ENAMETOOLONG; return (NULL); } } left_len = strlcpy(left, symlink, sizeof(left)); } } /* * Remove trailing slash except when the resolved pathname * is a single "/". */ if (resolved_len > 1 && resolved[resolved_len - 1] == '/') resolved[resolved_len - 1] = '\0'; return (resolved); }
the_stack_data/15763630.c
/*------------------------------------------------------------------------- * * spt_python.c * A simple function for the module debugging. * * Copyright (c) 2009-2012 Daniele Varrazzo <[email protected]> * * Debug logging is enabled if the extension is compiled with the * SPT_DEBUG symbol and is emitted on stdout. * *------------------------------------------------------------------------- */ #include <stdarg.h> #include <stdio.h> void spt_debug(const char *fmt, ...) { #ifdef SPT_DEBUG va_list ap; fprintf(stderr, "[SPT]: "); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); #endif }
the_stack_data/151704604.c
#include <stdio.h> /* for printf() and fprintf() */ #include <sys/socket.h> /* for socket() and bind() */ #include <arpa/inet.h> /* for sockaddr_in */ #include <stdlib.h> /* for atoi() and exit() */ #include <string.h> /* for memset() */ #include <unistd.h> /* for close() */ //void DieWithError(char *errorMessage); /* External error handling function */ int main(int argc, char *argv[]) { int sock; /* Socket */ struct sockaddr_in broadcastAddr; /* Broadcast address */ char *broadcastIP; /* IP broadcast address */ unsigned short broadcastPort; /* Server port */ char *sendString; /* String to broadcast */ int broadcastPermission; /* Socket opt to set permission to broadcast */ unsigned int sendStringLen; /* Length of string to broadcast */ if (argc < 4) /* Test for correct number of parameters */ { fprintf(stderr,"Usage: %s <IP Address> <Port> <Send String>\n", argv[0]); exit(1); } broadcastIP = argv[1]; /* First arg: broadcast IP address */ broadcastPort = atoi(argv[2]); /* Second arg: broadcast port */ sendString = argv[3]; /* Third arg: string to broadcast */ /* Create socket for sending/receiving datagrams */ if ((sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) //if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) { printf("socket() failed"); } //DieWithError("socket() failed"); /* Set socket to allow broadcast */ broadcastPermission = 1; if (setsockopt(sock, SOL_SOCKET, SO_BROADCAST, (void *) &broadcastPermission, //if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (void *) &broadcastPermission, sizeof(broadcastPermission)) < 0) { printf("setsockeopt() failed"); } //DieWithError("setsockopt() failed"); /* Construct local address structure */ memset(&broadcastAddr, 0, sizeof(broadcastAddr)); /* Zero out structure */ broadcastAddr.sin_family = AF_INET; /* Internet address family */ broadcastAddr.sin_addr.s_addr = inet_addr(broadcastIP);/* Broadcast IP address */ broadcastAddr.sin_port = htons(broadcastPort); /* Broadcast port */ sendStringLen = strlen(sendString); /* Find length of sendString */ for (int i = 0; i < 5; i++) /* Run forever */ { /* Broadcast sendString in datagram to clients every 3 seconds*/ if (sendto(sock, sendString, sendStringLen, 0, (struct sockaddr *) &broadcastAddr, sizeof(broadcastAddr)) != sendStringLen) { printf("sendto() sent a different number of bytes than expected"); } //DieWithError("sendto() sent a different number of bytes than expected"); sleep(3); /* Avoids flooding the network */ } /* NOT REACHED */ }
the_stack_data/7951136.c
/* Tests for loading and unloading of iconv modules. Copyright (C) 2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <[email protected]>, 2000. The GNU C Library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. The GNU C Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with the GNU C Library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ #include <iconv.h> #include <mcheck.h> #include <stdio.h> #include <stdlib.h> /* How many load/unload operations do we do. */ #define TEST_ROUNDS 5000 enum state { unloaded, loaded }; struct { const char *name; enum state state; iconv_t cd; } modules[] = { #define MODULE(Name) { .name = #Name, .state = unloaded } MODULE (ISO-8859-1), MODULE (ISO-8859-2), MODULE (ISO-8859-3), MODULE (ISO-8859-4), MODULE (ISO-8859-5), MODULE (ISO-8859-6), MODULE (ISO-8859-15), MODULE (EUC-JP), MODULE (EUC-KR), MODULE (EUC-CN), MODULE (EUC-TW), MODULE (SJIS), MODULE (UHC), MODULE (KOI8-R), MODULE (BIG5), MODULE (BIG5HKSCS) }; #define nmodules (sizeof (modules) / sizeof (modules[0])) /* The test data. */ static const char inbuf[] = "The first step is the function to create a handle.\n" "\n" " - Function: iconv_t iconv_open (const char *TOCODE, const char\n" " *FROMCODE)\n" " The `iconv_open' function has to be used before starting a\n" " conversion. The two parameters this function takes determine the\n" " source and destination character set for the conversion and if the\n" " implementation has the possibility to perform such a conversion the\n" " function returns a handle.\n" "\n" " If the wanted conversion is not available the function returns\n" " `(iconv_t) -1'. In this case the global variable `errno' can have\n" " the following values:\n" "\n" " `EMFILE'\n" " The process already has `OPEN_MAX' file descriptors open.\n" "\n" " `ENFILE'\n" " The system limit of open file is reached.\n" "\n" " `ENOMEM'\n" " Not enough memory to carry out the operation.\n" "\n" " `EINVAL'\n" " The conversion from FROMCODE to TOCODE is not supported.\n" "\n" " It is not possible to use the same descriptor in different threads\n" " to perform independent conversions. Within the data structures\n" " associated with the descriptor there is information about the\n" " conversion state. This must not be messed up by using it in\n" " different conversions.\n" "\n" " An `iconv' descriptor is like a file descriptor as for every use a\n" " new descriptor must be created. The descriptor does not stand for\n" " all of the conversions from FROMSET to TOSET.\n" "\n" " The GNU C library implementation of `iconv_open' has one\n" " significant extension to other implementations. To ease the\n" " extension of the set of available conversions the implementation\n" " allows storing the necessary files with data and code in\n" " arbitrarily many directories. How this extension has to be\n" " written will be explained below (*note glibc iconv\n" " Implementation::). Here it is only important to say that all\n" " directories mentioned in the `GCONV_PATH' environment variable are\n" " considered if they contain a file `gconv-modules'. These\n" " directories need not necessarily be created by the system\n" " administrator. In fact, this extension is introduced to help users\n" " writing and using their own, new conversions. Of course this does\n" " not work for security reasons in SUID binaries; in this case only\n" " the system directory is considered and this normally is\n" " `PREFIX/lib/gconv'. The `GCONV_PATH' environment variable is\n" " examined exactly once at the first call of the `iconv_open'\n" " function. Later modifications of the variable have no effect.\n"; int main (void) { int count = TEST_ROUNDS; int result = 0; mtrace (); /* Just a seed. */ srandom (TEST_ROUNDS); while (count--) { int idx = random () % nmodules; if (modules[idx].state == unloaded) { char outbuf[10000]; char *inptr = (char *) inbuf; size_t insize = sizeof (inbuf) - 1; char *outptr = outbuf; size_t outsize = sizeof (outbuf); /* Load the module and do the conversion. */ modules[idx].cd = iconv_open ("UTF-8", modules[idx].name); if (modules[idx].cd == (iconv_t) -1) { printf ("opening of %s failed: %m\n", modules[idx].name); result = 1; break; } modules[idx].state = loaded; /* Now a simple test. */ if (iconv (modules[idx].cd, &inptr, &insize, &outptr, &outsize) != 0 || *inptr != '\0') { printf ("conversion with %s failed\n", modules[idx].name); result = 1; } } else { /* Unload the module. */ if (iconv_close (modules[idx].cd) != 0) { printf ("closing of %s failed: %m\n", modules[idx].name); result = 1; break; } modules[idx].state = unloaded; } } for (count = 0; count < nmodules; ++count) if (modules[count].state == loaded && iconv_close (modules[count].cd) != 0) { printf ("closing of %s failed: %m\n", modules[count].name); result = 1; } return result; }
the_stack_data/440265.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <arpa/inet.h> /* udp의 패킷로스에 대해 타임아웃을 걸어서 recvfrom의 블락킹함 수 성질을 해결하기 위한 헤더 부분 선언 */ #include <errno.h> #include <signal.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> /* udp에서 패킷로스에 대한 체크를 위해, tcp에서 하는 동작인 시퀀싱과 타임아웃 리트랜스미션을 제공하기 위하여 헤더정보에 시퀀스 정보 추가 udp의 버퍼는 사이즈는 1024로 설정 이중 16바이트는 헤더 정보가 들어가고 1008 사이즈는 데이터가 들어감 */ #define BUF_SIZE 1024 #define HEADER_SIZE 16 #define DATA_SIZE 1008 static const unsigned int TIMEOUT_SECS = 2; //재전송 기다리는 시간 static const unsigned int MAXTRIES = 5;// 포기할 때까지 반복하는 횟수 unsigned int tries = 0;//보낸 횟수( 시그널 핸들러의 접근을 위해 전역변수 처리) void CatchAlarm( int ignored ) //타임아웃이 났을 경우 재시도 하는 횟수를 설정 { tries += 1; }//SIGALRM 핸들러 void error_handling(char *message){ fputs(message, stderr); fputc('\n',stderr); exit(1); } int main(int argc, char *argv[]){ int serv_sd, clnt_sd; //소켓 생성을 위한 변수 선언 char buf[BUF_SIZE], temp[DATA_SIZE],header[BUF_SIZE], data[DATA_SIZE], init[DATA_SIZE], recv_buf[BUF_SIZE],send_buf[BUF_SIZE]; //정보를 담을 버퍼사이즈, 처음 udp의 시작을 알리는 init 버퍼, 헤더와 payload를 담을 버퍼 및 보내는 버퍼, 받는 버퍼를 각각 따로 설정 int read_cnt, send_str_len,recv_str_len; //각각의 받은 길이, 보낸 길이의 정보를 담을 변수 선언 struct sockaddr_in serv_adr; struct sockaddr_in clnt_adr; //현재 소켓 정보와, 어디로부터 왔는지 목적지 주소를 담을 변수 선언 socklen_t clnt_adr_sz; // 주소의 사이즈 정보를 담을 변수 선언 FILE * fp; //읽고자 하는 파일을 읽어오기 위한 파일 포인터 선언 // IP와 포트로의 접속 성공여부확인을 위한 함수 if(argc!=2){ printf("Usage : %s <port>\n",argv[0]); exit(1); } //보낼 파일을 읽기 전용으로 열고, 파일포인터에 담음 fp = fopen("lec11.pdf","rb"); serv_sd = socket( PF_INET, SOCK_DGRAM, 0 );//IPv4프로토콜 체계로 udp 의 데이터 그램 형식의 소켓을 생성 if(serv_sd==-1)//소켓 생성 여부 확인 error_handling("socket() error"); memset(&serv_adr,0,sizeof(serv_adr));//주소정보를 담을 구조체 초기화 serv_adr.sin_family=AF_INET;//IPv4 주소 체계 이용 serv_adr.sin_addr.s_addr=htonl(INADDR_ANY); //해당 IP주소를 저장 serv_adr.sin_port=htons(atoi(argv[1]));//포트 정보를 저장 //소켓과 포트 정보를 연결 if(bind(serv_sd,(struct sockaddr*)&serv_adr, sizeof(serv_adr))==-1) error_handling("bind() error"); //처음에는 발신지를 모르므로, 이닛 패킷을 하나 받음 clnt_adr_sz=sizeof(clnt_adr); recv_str_len = recvfrom(serv_sd, buf, BUF_SIZE,0,(struct sockaddr*)&clnt_adr,&clnt_adr_sz); /* 패킷 로스에 의한 타임아웃 설정을 위하여 시그널 함수를 사요. */ struct sigaction handler; handler.sa_handler = CatchAlarm; if( sigfillset(&handler.sa_mask)<0) printf("sigfillsetn() failed\n"); //DieWithSystemMessage("sigfillsetn() failed"); handler.sa_flags = 0; if(sigaction(SIGALRM,&handler,0)<0) printf("sigaction() failed for SIGALRM\n"); //DieWithSystemMessage("sigaction() failed for SIGALRM"); //해당 타임아웃의 시간을 설정 alarm(TIMEOUT_SECS); //타이머 값 설정 int server_seq = 1, client_seq = 0;//시퀀싱을 위한 변수 선언 ,client_seq : client가 다음 번 받을 패킷의 순서, server_seq : 서버가 보낸 패킷 순서 while(1) { //해당 정보를 담을 버퍼들을 초기화 memset(buf,0,sizeof(buf)); memset(header,0,sizeof(header)); memset(data,0,sizeof(data)); memset(temp,0,sizeof(temp)); read_cnt = fread((void*)temp,1,DATA_SIZE, fp); //temp버퍼에 데이터 사이즈만큼 읽어와서 데이터를 담음 sprintf( buf, "%d", server_seq ); //버퍼의 16바이에 해당하는 앞쪽에는 서버가 보내는 시퀀싱 넘버를 헤더정보로 넣어줌 if( read_cnt < DATA_SIZE ) //보내고자 하는 파일이 마지막 부분이라면 해당 파일을 보내주고 종료 { for( int i=HEADER_SIZE; i<HEADER_SIZE+read_cnt; ++i ) { buf[i] = temp[i-HEADER_SIZE]; //버퍼의 데이터가 들어가야할 부분에 temp에 담아두었던 데이터 복사 } while(1) { int flag = 0; //재전송을 확인하는 flag 변수 while(1) { send_str_len = sendto(serv_sd, buf, HEADER_SIZE+read_cnt, 0,(struct sockaddr*)&clnt_adr,clnt_adr_sz); //클라이언트로 해당 버퍼를 전송 if( send_str_len == -1 ) { //printf("서버에서 패킷을 전송하지 못했음 \n"); continue; } else break; } while(1) { alarm(TIMEOUT_SECS); //타이머 값 설정 recv_str_len = recvfrom(serv_sd, recv_buf, BUF_SIZE,0,(struct sockaddr*)&clnt_adr,&clnt_adr_sz); //클라이언트로부터 ack를 잘 받았는지 확인 //만약 타임아웃이 나면 다시 재전송을 요청. if( errno == EINTR && recv_str_len == -1) { printf("server time out!!"); flag = 1; alarm(0); //타이머 값 설정 break; } if( recv_str_len == -1 ) { //printf( "client로부터 seq못받음 \n"); continue; } else break; } if( flag ) continue;//타임아웃이 났다면 다시 위로가서 재전송을 함. if( !strcmp(recv_buf,"resend") ) //역시 resend라는 값이 왔다면 재전송. { continue; } else //잘 받았으면 { client_seq = atoi(recv_buf); //받은 헤더에서 시퀀싱 넘버를 보고 , 갱신 //printf("마지막 부분 %d에서부터 %d까지 패킷을 전송 \n",server_seq, client_seq -1 ); server_seq = client_seq; //서버에서 보낼 시퀀싱 넘버 갱신 break; } } //전송 끝 break; } for( int i=HEADER_SIZE; i<HEADER_SIZE+DATA_SIZE; ++i ) { buf[ i ] = temp[ i-HEADER_SIZE ];//버퍼의 데이터가 들어가야할 부분에 temp에 담아두었던 데이터 복사 } while(1) { int flag = 0;//재전송을 확인하는 flag 변수 while(1) { send_str_len = sendto(serv_sd, buf, BUF_SIZE, 0,(struct sockaddr*)&clnt_adr,clnt_adr_sz); //클라이언트로 해당 버퍼를 전송 if( send_str_len == -1 ) { // printf("서버에서 패킷을 전송하지 못했음 \n"); continue; } else { //memset(chk_send,0,sizeof(chk_send)); // printf("client로 패킷 전송 잘했음\n"); //strcpy(chk_send, buf); break; } } while(1) { alarm(TIMEOUT_SECS); //타이머 값 설정 recv_str_len = recvfrom(serv_sd, recv_buf, BUF_SIZE,0,(struct sockaddr*)&clnt_adr,&clnt_adr_sz); //클라이언트로부터 ack를 잘 받았는지 확인 //만약 타임아웃이 나면 다시 재전송을 요청 if ( errno == EINTR && recv_str_len == -1) { printf("server time out\n"); flag = 1; alarm(0); //타이머 값 설정 // printf(" intrrupt server recv \n"); break; } if( recv_str_len == -1 ) { // printf( "client로부터 seq못받음 \n"); continue; } else { // printf("client로부터 seq잘 받음\n"); //strcpy(chk_recv, buf); break; } } if( flag == 1)//타임아웃이 났다면 다시 위로가서 재전송을 함. continue; if( !strcmp(recv_buf,"resend") )//역시 resend라는 값이 왔다면 재전송. { // printf(" resend 해주세요 from server \n"); continue; } else //잘 받았으면 { client_seq = atoi(recv_buf);//받은 헤더에서 시퀀싱 넘버를 보고 , 갱신 /* // printf("%d 에서부터 %d까지 패킷을 전송 \n",server_seq, client_seq -1 ); for( int i=0; i<BUF_SIZE; ++i ) { // printf("%02x",chk_send[i]); } // printf("\n\n\n"); */ server_seq = client_seq; break; } } } alarm(0); //타임아웃 설정 해제 printf("server end\n"); //서버에서 전송이 끝났음을 알리는 메시지 출력 fclose(fp);// 파일 포인터를 닫음 close(serv_sd);//소켓을 닫음 return 0; }
the_stack_data/521852.c
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <sys/wait.h> // Unix.c is mainly comprised of functions that can be used across multiple GNU/Linux distributions and even *BSD systems. /* GNU/Linux + *BSD supported function. * Get's number of packages installed by calling a shell command then * saving the output into a file in /tmp/ and then counting by line. */ void get_packages(const char *command) { int count = 0; int currchar = 0; pid_t child_pid = fork(); if (child_pid == -1) { perror("There was an error with a child process."); } else if (child_pid == 0) { execlp( "/bin/sh", "/bin/sh", "-c", command, (char *)NULL ); } else { wait(NULL); // Wait for the child process to finish otherwise we may get a NULL pointer back from fopen(); FILE *f_ptr; f_ptr = fopen("/tmp/pkglist", "r"); if (f_ptr == NULL) { printf("Failed to open the file %s\n", "/tmp/pkglist"); if (f_ptr) { fclose(f_ptr); } exit(1); } while((currchar = fgetc(f_ptr)) != EOF) { if (currchar == '\n') { count = count + 1; } } fclose(f_ptr); printf("Packages: %d\n", count); } } /* GNU/Linux + *BSD Function. * This function prints out an environment variable. * * This should work in most UNIX environments. */ const char *printenv(const char *env) { const char *arg = getenv(env); if (arg == NULL) { printf("Failed to get variable %s.\n", env); } return arg; } /* GNU/Linux Function. * Get's the current version of the GNU/Linux distro by reading a file * commonly stored in /etc/ * * This will work on BSD but typically only GNU/Linux distributions do this. * * Example: /etc/fedora-release */ void linux_version(const char *filename) { FILE *f_ptr; char buffer[50] = ""; f_ptr = fopen(filename, "r"); if (f_ptr == NULL) { printf("Failed to open the file %s\n", filename); if (f_ptr) { fclose(f_ptr); } exit(1); } fgets(buffer, sizeof(buffer), f_ptr); buffer[50] = '\0'; fclose(f_ptr); printf("Version: %s", buffer); }
the_stack_data/234519025.c
#include <stdio.h> #include <stdlib.h> /*Displays the array, passed to this method*/ void display(int arr[], int n) { int i; for (i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); } /*Swap function to swap two values*/ void swap(int *first, int *second) { int temp = *first; *first = *second; *second = temp; } /*Partition method which selects a pivot and places each element which is less than the pivot value to its left and the elements greater than the pivot value to its right arr[] --- array to be partitioned lower --- lower index upper --- upper index */ int partition(int arr[], int lower, int upper) { int i = (lower - 1); int pivot = arr[upper]; // Selects last element as the pivot value int j; for (j = lower; j < upper; j++) { if (arr[j] <= pivot) { // if current element is smaller than the pivot i++; // increment the index of smaller element swap(&arr[i], &arr[j]); } } swap(&arr[i + 1], &arr[upper]); // places the last element i.e, the pivot to its correct position return (i + 1); } /*This is where the sorting of the array takes place arr[] --- Array to be sorted lower --- Starting index upper --- Ending index */ void quickSort(int arr[], int lower, int upper) { if (upper > lower) { // partitioning index is returned by the partition method , partition element is at its correct poition int partitionIndex = partition(arr, lower, upper); // Sorting elements before and after the partition index quickSort(arr, lower, partitionIndex - 1); quickSort(arr, partitionIndex + 1, upper); } } int main() { int n; printf("Enter size of array:\n"); scanf("%d", &n); // E.g. 8 printf("Enter the elements of the array\n"); int i; int *arr = (int *)malloc(sizeof(int) * n); for (i = 0; i < n; i++) { scanf("%d", &arr[i]); } printf("Original array: "); display(arr, n); // Original array : 10 11 9 8 4 7 3 8 quickSort(arr, 0, n - 1); printf("Sorted array: "); display(arr, n); // Sorted array : 3 4 7 8 8 9 10 11 getchar(); return 0; }
the_stack_data/190767426.c
#include<stdio.h> #define M 10 #define N 3 int main(void) { int a[M], b[M]; /* 数组a存放圈中人的编号,数组b存放出圈人的编号 */ int i, j, k; for (i = 0; i < M; i++) /* 对圈中人按顺序编号1—M */ a[i] = i + 1; for (i = M, j = 0; i > 0; i--) { /* i表示圈中人个数,初始为M个,剩1个人时结束循环;j表示当前报数人的位置 */ for (k = 1; k <= N; k++) /* 1至N报数 */ { while(!a[j]) if (++j > M - 1) j = 0; /* 最后一个人报数后第一个人接着报,形成一个圈 */ if (++j > M - 1) j = 0; } // b[M - i] =j ? _______ : ______; /* 将报数为N的人的编号存入数组b */ b[M - i] = j ? a[j - 1] : a[M - 1]; if(--j == -1) j = M - 1; a[j] = 0; #if 0 if (j) for (k = --j; k < i; k++) /* 压缩数组a,使报数为N的人出圈 */ ______________; #endif } for (i = 0; i < M; i++) /* 按次序输出出圈人的编号 */ printf("%6d", b[i]); // printf("%6d\n", a[0]); /* 输出圈中最后一个人的编号 */ return 0; }
the_stack_data/21643.c
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <unistd.h> #include <signal.h> #include <string.h> sig_atomic_t sig_count = 0; void handler (int signal_number) { ++sig_count; } int main () { int c=0; struct sigaction sa; memset (&sa, 0, sizeof (sa)); sa.sa_handler = &handler; sigaction (SIGQUIT, &sa, NULL); printf("\nPress 'CTRL C' to quit or 'CTRL \\' to send signal SIGQUIT\n\n"); while (1) { if ( c<sig_count ) { printf ("SIGQUIT was raised %d times\n", sig_count); c=sig_count; } } return EXIT_SUCCESS; }
the_stack_data/148577725.c
// RUN: %clang_cc1 -E -dM -x assembler-with-cpp < /dev/null | FileCheck -match-full-lines -check-prefix ASM %s // // ASM:#define __ASSEMBLER__ 1 // // // RUN: %clang_cc1 -fblocks -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix BLOCKS %s // // BLOCKS:#define __BLOCKS__ 1 // BLOCKS:#define __block __attribute__((__blocks__(byref))) // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s // // CXX2B:#define __GNUG__ 4 // CXX2B:#define __GXX_EXPERIMENTAL_CXX0X__ 1 // CXX2B:#define __GXX_RTTI 1 // CXX2B:#define __GXX_WEAK__ 1 // CXX2B:#define __cplusplus 202101L // CXX2B:#define __private_extern__ extern // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s // // CXX2A:#define __GNUG__ 4 // CXX2A:#define __GXX_EXPERIMENTAL_CXX0X__ 1 // CXX2A:#define __GXX_RTTI 1 // CXX2A:#define __GXX_WEAK__ 1 // CXX2A:#define __cplusplus 202002L // CXX2A:#define __private_extern__ extern // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++17 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Z %s // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Z %s // // CXX1Z:#define __GNUG__ 4 // CXX1Z:#define __GXX_EXPERIMENTAL_CXX0X__ 1 // CXX1Z:#define __GXX_RTTI 1 // CXX1Z:#define __GXX_WEAK__ 1 // CXX1Z:#define __cplusplus 201703L // CXX1Z:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++14 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Y %s // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++1y -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX1Y %s // // CXX1Y:#define __GNUG__ 4 // CXX1Y:#define __GXX_EXPERIMENTAL_CXX0X__ 1 // CXX1Y:#define __GXX_RTTI 1 // CXX1Y:#define __GXX_WEAK__ 1 // CXX1Y:#define __cplusplus 201402L // CXX1Y:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX11 %s // // CXX11:#define __GNUG__ 4 // CXX11:#define __GXX_EXPERIMENTAL_CXX0X__ 1 // CXX11:#define __GXX_RTTI 1 // CXX11:#define __GXX_WEAK__ 1 // CXX11:#define __cplusplus 201103L // CXX11:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++98 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX98 %s // // CXX98:#define __GNUG__ 4 // CXX98:#define __GXX_RTTI 1 // CXX98:#define __GXX_WEAK__ 1 // CXX98:#define __cplusplus 199711L // CXX98:#define __private_extern__ extern // // // RUN: %clang_cc1 -fdeprecated-macro -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix DEPRECATED %s // // DEPRECATED:#define __DEPRECATED 1 // // // RUN: %clang_cc1 -std=c99 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C99 %s // // C99:#define __STDC_VERSION__ 199901L // C99:#define __STRICT_ANSI__ 1 // C99-NOT: __GXX_EXPERIMENTAL_CXX0X__ // C99-NOT: __GXX_RTTI // C99-NOT: __GXX_WEAK__ // C99-NOT: __cplusplus // // // RUN: %clang_cc1 -std=c11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s // RUN: %clang_cc1 -std=c1x -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s // RUN: %clang_cc1 -std=iso9899:2011 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s // RUN: %clang_cc1 -std=iso9899:201x -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C11 %s // // C11:#define __STDC_UTF_16__ 1 // C11:#define __STDC_UTF_32__ 1 // C11:#define __STDC_VERSION__ 201112L // C11:#define __STRICT_ANSI__ 1 // C11-NOT: __GXX_EXPERIMENTAL_CXX0X__ // C11-NOT: __GXX_RTTI // C11-NOT: __GXX_WEAK__ // C11-NOT: __cplusplus // // // RUN: %clang_cc1 -fgnuc-version=4.2.1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix COMMON %s // // COMMON:#define __CONSTANT_CFSTRINGS__ 1 // COMMON:#define __FINITE_MATH_ONLY__ 0 // COMMON:#define __GNUC_MINOR__ {{.*}} // COMMON:#define __GNUC_PATCHLEVEL__ {{.*}} // COMMON:#define __GNUC_STDC_INLINE__ 1 // COMMON:#define __GNUC__ {{.*}} // COMMON:#define __GXX_ABI_VERSION {{.*}} // COMMON:#define __ORDER_BIG_ENDIAN__ 4321 // COMMON:#define __ORDER_LITTLE_ENDIAN__ 1234 // COMMON:#define __ORDER_PDP_ENDIAN__ 3412 // COMMON:#define __STDC_HOSTED__ 1 // COMMON:#define __STDC__ 1 // COMMON:#define __VERSION__ {{.*}} // COMMON:#define __clang__ 1 // COMMON:#define __clang_literal_encoding__ {{.*}} // COMMON:#define __clang_major__ {{[0-9]+}} // COMMON:#define __clang_minor__ {{[0-9]+}} // COMMON:#define __clang_patchlevel__ {{[0-9]+}} // COMMON:#define __clang_version__ {{.*}} // COMMON:#define __clang_wide_literal_encoding__ {{.*}} // COMMON:#define __llvm__ 1 // // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-win32 < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s // RUN: %clang_cc1 -E -dM -triple=x86_64-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s // RUN: %clang_cc1 -E -dM -triple=armv7a-apple-darwin < /dev/null | FileCheck -match-full-lines -check-prefix C-DEFAULT %s // // C-DEFAULT:#define __STDC_VERSION__ 201710L // // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s // FREESTANDING:#define __STDC_HOSTED__ 0 // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s // // GXX2B:#define __GNUG__ 4 // GXX2B:#define __GXX_WEAK__ 1 // GXX2B:#define __cplusplus 202101L // GXX2B:#define __private_extern__ extern // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s // // GXX2A:#define __GNUG__ 4 // GXX2A:#define __GXX_WEAK__ 1 // GXX2A:#define __cplusplus 202002L // GXX2A:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++17 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX1Z %s // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++1z -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX1Z %s // // GXX1Z:#define __GNUG__ 4 // GXX1Z:#define __GXX_WEAK__ 1 // GXX1Z:#define __cplusplus 201703L // GXX1Z:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++14 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX1Y %s // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++1y -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX1Y %s // // GXX1Y:#define __GNUG__ 4 // GXX1Y:#define __GXX_WEAK__ 1 // GXX1Y:#define __cplusplus 201402L // GXX1Y:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++11 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX11 %s // // GXX11:#define __GNUG__ 4 // GXX11:#define __GXX_WEAK__ 1 // GXX11:#define __cplusplus 201103L // GXX11:#define __private_extern__ extern // // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++98 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX98 %s // // GXX98:#define __GNUG__ 4 // GXX98:#define __GXX_WEAK__ 1 // GXX98:#define __cplusplus 199711L // GXX98:#define __private_extern__ extern // // // RUN: %clang_cc1 -std=iso9899:199409 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix C94 %s // // C94:#define __STDC_VERSION__ 199409L // // // RUN: %clang_cc1 -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT %s // // MSEXT-NOT:#define __STDC__ // MSEXT:#define _INTEGRAL_MAX_BITS 64 // MSEXT-NOT:#define _NATIVE_WCHAR_T_DEFINED 1 // MSEXT-NOT:#define _WCHAR_T_DEFINED 1 // // // RUN: %clang_cc1 -x c++ -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT-CXX %s // // MSEXT-CXX:#define _NATIVE_WCHAR_T_DEFINED 1 // MSEXT-CXX:#define _WCHAR_T_DEFINED 1 // MSEXT-CXX:#define __BOOL_DEFINED 1 // // // RUN: %clang_cc1 -x c++ -fno-wchar -fms-extensions -triple i686-pc-win32 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix MSEXT-CXX-NOWCHAR %s // // MSEXT-CXX-NOWCHAR-NOT:#define _NATIVE_WCHAR_T_DEFINED 1 // MSEXT-CXX-NOWCHAR-NOT:#define _WCHAR_T_DEFINED 1 // MSEXT-CXX-NOWCHAR:#define __BOOL_DEFINED 1 // // // RUN: %clang_cc1 -x objective-c -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJC %s // RUN: %clang_cc1 -x objective-c++ -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJC %s // // OBJC:#define OBJC_NEW_PROPERTIES 1 // OBJC:#define __NEXT_RUNTIME__ 1 // OBJC:#define __OBJC__ 1 // // // RUN: %clang_cc1 -x objective-c -fobjc-gc -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix OBJCGC %s // // OBJCGC:#define __OBJC_GC__ 1 // // // RUN: %clang_cc1 -x objective-c -fobjc-exceptions -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NONFRAGILE %s // // NONFRAGILE:#define OBJC_ZEROCOST_EXCEPTIONS 1 // NONFRAGILE:#define __OBJC2__ 1 // // // RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix O0 %s // // O0:#define __NO_INLINE__ 1 // O0-NOT:#define __OPTIMIZE_SIZE__ // O0-NOT:#define __OPTIMIZE__ // // // RUN: %clang_cc1 -fno-inline -O3 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NO_INLINE %s // // NO_INLINE:#define __NO_INLINE__ 1 // NO_INLINE-NOT:#define __OPTIMIZE_SIZE__ // NO_INLINE:#define __OPTIMIZE__ 1 // // // RUN: %clang_cc1 -O1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix O1 %s // // O1-NOT:#define __OPTIMIZE_SIZE__ // O1:#define __OPTIMIZE__ 1 // // // RUN: %clang_cc1 -Og -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Og %s // // Og-NOT:#define __OPTIMIZE_SIZE__ // Og:#define __OPTIMIZE__ 1 // // // RUN: %clang_cc1 -Os -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Os %s // // Os:#define __OPTIMIZE_SIZE__ 1 // Os:#define __OPTIMIZE__ 1 // // // RUN: %clang_cc1 -Oz -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix Oz %s // // Oz:#define __OPTIMIZE_SIZE__ 1 // Oz:#define __OPTIMIZE__ 1 // // // RUN: %clang_cc1 -fpascal-strings -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix PASCAL %s // // PASCAL:#define __PASCAL_STRINGS__ 1 // // // RUN: %clang_cc1 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix SCHAR %s // // SCHAR:#define __STDC__ 1 // SCHAR-NOT:#define __UNSIGNED_CHAR__ // SCHAR:#define __clang__ 1 // // RUN: %clang_cc1 -E -dM -fwchar-type=short -fno-signed-wchar < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s // wchar_t is u16 for targeting Win32. // RUN: %clang_cc1 -E -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-w64-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s // RUN: %clang_cc1 -dM -fwchar-type=short -fno-signed-wchar -triple=x86_64-unknown-windows-cygnus -E /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR %s // // SHORTWCHAR: #define __SIZEOF_WCHAR_T__ 2 // SHORTWCHAR: #define __WCHAR_MAX__ 65535 // SHORTWCHAR: #define __WCHAR_TYPE__ unsigned short // SHORTWCHAR: #define __WCHAR_WIDTH__ 16 // // RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=i686-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s // RUN: %clang_cc1 -E -dM -fwchar-type=int -triple=x86_64-unknown-unknown < /dev/null | FileCheck -match-full-lines -check-prefix SHORTWCHAR2 %s // // SHORTWCHAR2: #define __SIZEOF_WCHAR_T__ 4 // SHORTWCHAR2: #define __WCHAR_WIDTH__ 32 // Other definitions vary from platform to platform // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MSP430 %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=msp430-none-none < /dev/null | FileCheck -match-full-lines -check-prefix MSP430 -check-prefix MSP430-CXX %s // // MSP430:#define MSP430 1 // MSP430-NOT:#define _LP64 // MSP430:#define __BIGGEST_ALIGNMENT__ 2 // MSP430:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // MSP430:#define __CHAR16_TYPE__ unsigned short // MSP430:#define __CHAR32_TYPE__ unsigned int // MSP430:#define __CHAR_BIT__ 8 // MSP430:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // MSP430:#define __DBL_DIG__ 15 // MSP430:#define __DBL_EPSILON__ 2.2204460492503131e-16 // MSP430:#define __DBL_HAS_DENORM__ 1 // MSP430:#define __DBL_HAS_INFINITY__ 1 // MSP430:#define __DBL_HAS_QUIET_NAN__ 1 // MSP430:#define __DBL_MANT_DIG__ 53 // MSP430:#define __DBL_MAX_10_EXP__ 308 // MSP430:#define __DBL_MAX_EXP__ 1024 // MSP430:#define __DBL_MAX__ 1.7976931348623157e+308 // MSP430:#define __DBL_MIN_10_EXP__ (-307) // MSP430:#define __DBL_MIN_EXP__ (-1021) // MSP430:#define __DBL_MIN__ 2.2250738585072014e-308 // MSP430:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // MSP430:#define __FLT_DENORM_MIN__ 1.40129846e-45F // MSP430:#define __FLT_DIG__ 6 // MSP430:#define __FLT_EPSILON__ 1.19209290e-7F // MSP430:#define __FLT_EVAL_METHOD__ 0 // MSP430:#define __FLT_HAS_DENORM__ 1 // MSP430:#define __FLT_HAS_INFINITY__ 1 // MSP430:#define __FLT_HAS_QUIET_NAN__ 1 // MSP430:#define __FLT_MANT_DIG__ 24 // MSP430:#define __FLT_MAX_10_EXP__ 38 // MSP430:#define __FLT_MAX_EXP__ 128 // MSP430:#define __FLT_MAX__ 3.40282347e+38F // MSP430:#define __FLT_MIN_10_EXP__ (-37) // MSP430:#define __FLT_MIN_EXP__ (-125) // MSP430:#define __FLT_MIN__ 1.17549435e-38F // MSP430:#define __FLT_RADIX__ 2 // MSP430:#define __INT16_C_SUFFIX__ // MSP430:#define __INT16_FMTd__ "hd" // MSP430:#define __INT16_FMTi__ "hi" // MSP430:#define __INT16_MAX__ 32767 // MSP430:#define __INT16_TYPE__ short // MSP430:#define __INT32_C_SUFFIX__ L // MSP430:#define __INT32_FMTd__ "ld" // MSP430:#define __INT32_FMTi__ "li" // MSP430:#define __INT32_MAX__ 2147483647L // MSP430:#define __INT32_TYPE__ long int // MSP430:#define __INT64_C_SUFFIX__ LL // MSP430:#define __INT64_FMTd__ "lld" // MSP430:#define __INT64_FMTi__ "lli" // MSP430:#define __INT64_MAX__ 9223372036854775807LL // MSP430:#define __INT64_TYPE__ long long int // MSP430:#define __INT8_C_SUFFIX__ // MSP430:#define __INT8_FMTd__ "hhd" // MSP430:#define __INT8_FMTi__ "hhi" // MSP430:#define __INT8_MAX__ 127 // MSP430:#define __INT8_TYPE__ signed char // MSP430:#define __INTMAX_C_SUFFIX__ LL // MSP430:#define __INTMAX_FMTd__ "lld" // MSP430:#define __INTMAX_FMTi__ "lli" // MSP430:#define __INTMAX_MAX__ 9223372036854775807LL // MSP430:#define __INTMAX_TYPE__ long long int // MSP430:#define __INTMAX_WIDTH__ 64 // MSP430:#define __INTPTR_FMTd__ "d" // MSP430:#define __INTPTR_FMTi__ "i" // MSP430:#define __INTPTR_MAX__ 32767 // MSP430:#define __INTPTR_TYPE__ int // MSP430:#define __INTPTR_WIDTH__ 16 // MSP430:#define __INT_FAST16_FMTd__ "hd" // MSP430:#define __INT_FAST16_FMTi__ "hi" // MSP430:#define __INT_FAST16_MAX__ 32767 // MSP430:#define __INT_FAST16_TYPE__ short // MSP430:#define __INT_FAST32_FMTd__ "ld" // MSP430:#define __INT_FAST32_FMTi__ "li" // MSP430:#define __INT_FAST32_MAX__ 2147483647L // MSP430:#define __INT_FAST32_TYPE__ long int // MSP430:#define __INT_FAST64_FMTd__ "lld" // MSP430:#define __INT_FAST64_FMTi__ "lli" // MSP430:#define __INT_FAST64_MAX__ 9223372036854775807LL // MSP430:#define __INT_FAST64_TYPE__ long long int // MSP430:#define __INT_FAST8_FMTd__ "hhd" // MSP430:#define __INT_FAST8_FMTi__ "hhi" // MSP430:#define __INT_FAST8_MAX__ 127 // MSP430:#define __INT_FAST8_TYPE__ signed char // MSP430:#define __INT_LEAST16_FMTd__ "hd" // MSP430:#define __INT_LEAST16_FMTi__ "hi" // MSP430:#define __INT_LEAST16_MAX__ 32767 // MSP430:#define __INT_LEAST16_TYPE__ short // MSP430:#define __INT_LEAST32_FMTd__ "ld" // MSP430:#define __INT_LEAST32_FMTi__ "li" // MSP430:#define __INT_LEAST32_MAX__ 2147483647L // MSP430:#define __INT_LEAST32_TYPE__ long int // MSP430:#define __INT_LEAST64_FMTd__ "lld" // MSP430:#define __INT_LEAST64_FMTi__ "lli" // MSP430:#define __INT_LEAST64_MAX__ 9223372036854775807LL // MSP430:#define __INT_LEAST64_TYPE__ long long int // MSP430:#define __INT_LEAST8_FMTd__ "hhd" // MSP430:#define __INT_LEAST8_FMTi__ "hhi" // MSP430:#define __INT_LEAST8_MAX__ 127 // MSP430:#define __INT_LEAST8_TYPE__ signed char // MSP430:#define __INT_MAX__ 32767 // MSP430:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L // MSP430:#define __LDBL_DIG__ 15 // MSP430:#define __LDBL_EPSILON__ 2.2204460492503131e-16L // MSP430:#define __LDBL_HAS_DENORM__ 1 // MSP430:#define __LDBL_HAS_INFINITY__ 1 // MSP430:#define __LDBL_HAS_QUIET_NAN__ 1 // MSP430:#define __LDBL_MANT_DIG__ 53 // MSP430:#define __LDBL_MAX_10_EXP__ 308 // MSP430:#define __LDBL_MAX_EXP__ 1024 // MSP430:#define __LDBL_MAX__ 1.7976931348623157e+308L // MSP430:#define __LDBL_MIN_10_EXP__ (-307) // MSP430:#define __LDBL_MIN_EXP__ (-1021) // MSP430:#define __LDBL_MIN__ 2.2250738585072014e-308L // MSP430:#define __LITTLE_ENDIAN__ 1 // MSP430:#define __LONG_LONG_MAX__ 9223372036854775807LL // MSP430:#define __LONG_MAX__ 2147483647L // MSP430-NOT:#define __LP64__ // MSP430:#define __MSP430__ 1 // MSP430:#define __POINTER_WIDTH__ 16 // MSP430:#define __PTRDIFF_TYPE__ int // MSP430:#define __PTRDIFF_WIDTH__ 16 // MSP430:#define __SCHAR_MAX__ 127 // MSP430:#define __SHRT_MAX__ 32767 // MSP430:#define __SIG_ATOMIC_MAX__ 2147483647L // MSP430:#define __SIG_ATOMIC_WIDTH__ 32 // MSP430:#define __SIZEOF_DOUBLE__ 8 // MSP430:#define __SIZEOF_FLOAT__ 4 // MSP430:#define __SIZEOF_INT__ 2 // MSP430:#define __SIZEOF_LONG_DOUBLE__ 8 // MSP430:#define __SIZEOF_LONG_LONG__ 8 // MSP430:#define __SIZEOF_LONG__ 4 // MSP430:#define __SIZEOF_POINTER__ 2 // MSP430:#define __SIZEOF_PTRDIFF_T__ 2 // MSP430:#define __SIZEOF_SHORT__ 2 // MSP430:#define __SIZEOF_SIZE_T__ 2 // MSP430:#define __SIZEOF_WCHAR_T__ 2 // MSP430:#define __SIZEOF_WINT_T__ 2 // MSP430:#define __SIZE_MAX__ 65535U // MSP430:#define __SIZE_TYPE__ unsigned int // MSP430:#define __SIZE_WIDTH__ 16 // MSP430-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 2U // MSP430:#define __UINT16_C_SUFFIX__ U // MSP430:#define __UINT16_MAX__ 65535U // MSP430:#define __UINT16_TYPE__ unsigned short // MSP430:#define __UINT32_C_SUFFIX__ UL // MSP430:#define __UINT32_MAX__ 4294967295UL // MSP430:#define __UINT32_TYPE__ long unsigned int // MSP430:#define __UINT64_C_SUFFIX__ ULL // MSP430:#define __UINT64_MAX__ 18446744073709551615ULL // MSP430:#define __UINT64_TYPE__ long long unsigned int // MSP430:#define __UINT8_C_SUFFIX__ // MSP430:#define __UINT8_MAX__ 255 // MSP430:#define __UINT8_TYPE__ unsigned char // MSP430:#define __UINTMAX_C_SUFFIX__ ULL // MSP430:#define __UINTMAX_MAX__ 18446744073709551615ULL // MSP430:#define __UINTMAX_TYPE__ long long unsigned int // MSP430:#define __UINTMAX_WIDTH__ 64 // MSP430:#define __UINTPTR_MAX__ 65535U // MSP430:#define __UINTPTR_TYPE__ unsigned int // MSP430:#define __UINTPTR_WIDTH__ 16 // MSP430:#define __UINT_FAST16_MAX__ 65535U // MSP430:#define __UINT_FAST16_TYPE__ unsigned short // MSP430:#define __UINT_FAST32_MAX__ 4294967295UL // MSP430:#define __UINT_FAST32_TYPE__ long unsigned int // MSP430:#define __UINT_FAST64_MAX__ 18446744073709551615ULL // MSP430:#define __UINT_FAST64_TYPE__ long long unsigned int // MSP430:#define __UINT_FAST8_MAX__ 255 // MSP430:#define __UINT_FAST8_TYPE__ unsigned char // MSP430:#define __UINT_LEAST16_MAX__ 65535U // MSP430:#define __UINT_LEAST16_TYPE__ unsigned short // MSP430:#define __UINT_LEAST32_MAX__ 4294967295UL // MSP430:#define __UINT_LEAST32_TYPE__ long unsigned int // MSP430:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL // MSP430:#define __UINT_LEAST64_TYPE__ long long unsigned int // MSP430:#define __UINT_LEAST8_MAX__ 255 // MSP430:#define __UINT_LEAST8_TYPE__ unsigned char // MSP430:#define __USER_LABEL_PREFIX__ // MSP430:#define __WCHAR_MAX__ 32767 // MSP430:#define __WCHAR_TYPE__ int // MSP430:#define __WCHAR_WIDTH__ 16 // MSP430:#define __WINT_TYPE__ int // MSP430:#define __WINT_WIDTH__ 16 // MSP430:#define __clang__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=nvptx-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX32 %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=nvptx-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX32 -check-prefix NVPTX32-CXX %s // // NVPTX32-NOT:#define _LP64 // NVPTX32:#define __BIGGEST_ALIGNMENT__ 8 // NVPTX32:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // NVPTX32:#define __CHAR16_TYPE__ unsigned short // NVPTX32:#define __CHAR32_TYPE__ unsigned int // NVPTX32:#define __CHAR_BIT__ 8 // NVPTX32:#define __CONSTANT_CFSTRINGS__ 1 // NVPTX32:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // NVPTX32:#define __DBL_DIG__ 15 // NVPTX32:#define __DBL_EPSILON__ 2.2204460492503131e-16 // NVPTX32:#define __DBL_HAS_DENORM__ 1 // NVPTX32:#define __DBL_HAS_INFINITY__ 1 // NVPTX32:#define __DBL_HAS_QUIET_NAN__ 1 // NVPTX32:#define __DBL_MANT_DIG__ 53 // NVPTX32:#define __DBL_MAX_10_EXP__ 308 // NVPTX32:#define __DBL_MAX_EXP__ 1024 // NVPTX32:#define __DBL_MAX__ 1.7976931348623157e+308 // NVPTX32:#define __DBL_MIN_10_EXP__ (-307) // NVPTX32:#define __DBL_MIN_EXP__ (-1021) // NVPTX32:#define __DBL_MIN__ 2.2250738585072014e-308 // NVPTX32:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // NVPTX32:#define __FINITE_MATH_ONLY__ 0 // NVPTX32:#define __FLT_DENORM_MIN__ 1.40129846e-45F // NVPTX32:#define __FLT_DIG__ 6 // NVPTX32:#define __FLT_EPSILON__ 1.19209290e-7F // NVPTX32:#define __FLT_EVAL_METHOD__ 0 // NVPTX32:#define __FLT_HAS_DENORM__ 1 // NVPTX32:#define __FLT_HAS_INFINITY__ 1 // NVPTX32:#define __FLT_HAS_QUIET_NAN__ 1 // NVPTX32:#define __FLT_MANT_DIG__ 24 // NVPTX32:#define __FLT_MAX_10_EXP__ 38 // NVPTX32:#define __FLT_MAX_EXP__ 128 // NVPTX32:#define __FLT_MAX__ 3.40282347e+38F // NVPTX32:#define __FLT_MIN_10_EXP__ (-37) // NVPTX32:#define __FLT_MIN_EXP__ (-125) // NVPTX32:#define __FLT_MIN__ 1.17549435e-38F // NVPTX32:#define __FLT_RADIX__ 2 // NVPTX32:#define __INT16_C_SUFFIX__ // NVPTX32:#define __INT16_FMTd__ "hd" // NVPTX32:#define __INT16_FMTi__ "hi" // NVPTX32:#define __INT16_MAX__ 32767 // NVPTX32:#define __INT16_TYPE__ short // NVPTX32:#define __INT32_C_SUFFIX__ // NVPTX32:#define __INT32_FMTd__ "d" // NVPTX32:#define __INT32_FMTi__ "i" // NVPTX32:#define __INT32_MAX__ 2147483647 // NVPTX32:#define __INT32_TYPE__ int // NVPTX32:#define __INT64_C_SUFFIX__ LL // NVPTX32:#define __INT64_FMTd__ "lld" // NVPTX32:#define __INT64_FMTi__ "lli" // NVPTX32:#define __INT64_MAX__ 9223372036854775807LL // NVPTX32:#define __INT64_TYPE__ long long int // NVPTX32:#define __INT8_C_SUFFIX__ // NVPTX32:#define __INT8_FMTd__ "hhd" // NVPTX32:#define __INT8_FMTi__ "hhi" // NVPTX32:#define __INT8_MAX__ 127 // NVPTX32:#define __INT8_TYPE__ signed char // NVPTX32:#define __INTMAX_C_SUFFIX__ LL // NVPTX32:#define __INTMAX_FMTd__ "lld" // NVPTX32:#define __INTMAX_FMTi__ "lli" // NVPTX32:#define __INTMAX_MAX__ 9223372036854775807LL // NVPTX32:#define __INTMAX_TYPE__ long long int // NVPTX32:#define __INTMAX_WIDTH__ 64 // NVPTX32:#define __INTPTR_FMTd__ "d" // NVPTX32:#define __INTPTR_FMTi__ "i" // NVPTX32:#define __INTPTR_MAX__ 2147483647 // NVPTX32:#define __INTPTR_TYPE__ int // NVPTX32:#define __INTPTR_WIDTH__ 32 // NVPTX32:#define __INT_FAST16_FMTd__ "hd" // NVPTX32:#define __INT_FAST16_FMTi__ "hi" // NVPTX32:#define __INT_FAST16_MAX__ 32767 // NVPTX32:#define __INT_FAST16_TYPE__ short // NVPTX32:#define __INT_FAST32_FMTd__ "d" // NVPTX32:#define __INT_FAST32_FMTi__ "i" // NVPTX32:#define __INT_FAST32_MAX__ 2147483647 // NVPTX32:#define __INT_FAST32_TYPE__ int // NVPTX32:#define __INT_FAST64_FMTd__ "lld" // NVPTX32:#define __INT_FAST64_FMTi__ "lli" // NVPTX32:#define __INT_FAST64_MAX__ 9223372036854775807LL // NVPTX32:#define __INT_FAST64_TYPE__ long long int // NVPTX32:#define __INT_FAST8_FMTd__ "hhd" // NVPTX32:#define __INT_FAST8_FMTi__ "hhi" // NVPTX32:#define __INT_FAST8_MAX__ 127 // NVPTX32:#define __INT_FAST8_TYPE__ signed char // NVPTX32:#define __INT_LEAST16_FMTd__ "hd" // NVPTX32:#define __INT_LEAST16_FMTi__ "hi" // NVPTX32:#define __INT_LEAST16_MAX__ 32767 // NVPTX32:#define __INT_LEAST16_TYPE__ short // NVPTX32:#define __INT_LEAST32_FMTd__ "d" // NVPTX32:#define __INT_LEAST32_FMTi__ "i" // NVPTX32:#define __INT_LEAST32_MAX__ 2147483647 // NVPTX32:#define __INT_LEAST32_TYPE__ int // NVPTX32:#define __INT_LEAST64_FMTd__ "lld" // NVPTX32:#define __INT_LEAST64_FMTi__ "lli" // NVPTX32:#define __INT_LEAST64_MAX__ 9223372036854775807LL // NVPTX32:#define __INT_LEAST64_TYPE__ long long int // NVPTX32:#define __INT_LEAST8_FMTd__ "hhd" // NVPTX32:#define __INT_LEAST8_FMTi__ "hhi" // NVPTX32:#define __INT_LEAST8_MAX__ 127 // NVPTX32:#define __INT_LEAST8_TYPE__ signed char // NVPTX32:#define __INT_MAX__ 2147483647 // NVPTX32:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L // NVPTX32:#define __LDBL_DIG__ 15 // NVPTX32:#define __LDBL_EPSILON__ 2.2204460492503131e-16L // NVPTX32:#define __LDBL_HAS_DENORM__ 1 // NVPTX32:#define __LDBL_HAS_INFINITY__ 1 // NVPTX32:#define __LDBL_HAS_QUIET_NAN__ 1 // NVPTX32:#define __LDBL_MANT_DIG__ 53 // NVPTX32:#define __LDBL_MAX_10_EXP__ 308 // NVPTX32:#define __LDBL_MAX_EXP__ 1024 // NVPTX32:#define __LDBL_MAX__ 1.7976931348623157e+308L // NVPTX32:#define __LDBL_MIN_10_EXP__ (-307) // NVPTX32:#define __LDBL_MIN_EXP__ (-1021) // NVPTX32:#define __LDBL_MIN__ 2.2250738585072014e-308L // NVPTX32:#define __LITTLE_ENDIAN__ 1 // NVPTX32:#define __LONG_LONG_MAX__ 9223372036854775807LL // NVPTX32:#define __LONG_MAX__ 2147483647L // NVPTX32-NOT:#define __LP64__ // NVPTX32:#define __NVPTX__ 1 // NVPTX32:#define __POINTER_WIDTH__ 32 // NVPTX32:#define __PRAGMA_REDEFINE_EXTNAME 1 // NVPTX32:#define __PTRDIFF_TYPE__ int // NVPTX32:#define __PTRDIFF_WIDTH__ 32 // NVPTX32:#define __PTX__ 1 // NVPTX32:#define __SCHAR_MAX__ 127 // NVPTX32:#define __SHRT_MAX__ 32767 // NVPTX32:#define __SIG_ATOMIC_MAX__ 2147483647 // NVPTX32:#define __SIG_ATOMIC_WIDTH__ 32 // NVPTX32:#define __SIZEOF_DOUBLE__ 8 // NVPTX32:#define __SIZEOF_FLOAT__ 4 // NVPTX32:#define __SIZEOF_INT__ 4 // NVPTX32:#define __SIZEOF_LONG_DOUBLE__ 8 // NVPTX32:#define __SIZEOF_LONG_LONG__ 8 // NVPTX32:#define __SIZEOF_LONG__ 4 // NVPTX32:#define __SIZEOF_POINTER__ 4 // NVPTX32:#define __SIZEOF_PTRDIFF_T__ 4 // NVPTX32:#define __SIZEOF_SHORT__ 2 // NVPTX32:#define __SIZEOF_SIZE_T__ 4 // NVPTX32:#define __SIZEOF_WCHAR_T__ 4 // NVPTX32:#define __SIZEOF_WINT_T__ 4 // NVPTX32:#define __SIZE_MAX__ 4294967295U // NVPTX32:#define __SIZE_TYPE__ unsigned int // NVPTX32:#define __SIZE_WIDTH__ 32 // NVPTX32-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // NVPTX32:#define __UINT16_C_SUFFIX__ // NVPTX32:#define __UINT16_MAX__ 65535 // NVPTX32:#define __UINT16_TYPE__ unsigned short // NVPTX32:#define __UINT32_C_SUFFIX__ U // NVPTX32:#define __UINT32_MAX__ 4294967295U // NVPTX32:#define __UINT32_TYPE__ unsigned int // NVPTX32:#define __UINT64_C_SUFFIX__ ULL // NVPTX32:#define __UINT64_MAX__ 18446744073709551615ULL // NVPTX32:#define __UINT64_TYPE__ long long unsigned int // NVPTX32:#define __UINT8_C_SUFFIX__ // NVPTX32:#define __UINT8_MAX__ 255 // NVPTX32:#define __UINT8_TYPE__ unsigned char // NVPTX32:#define __UINTMAX_C_SUFFIX__ ULL // NVPTX32:#define __UINTMAX_MAX__ 18446744073709551615ULL // NVPTX32:#define __UINTMAX_TYPE__ long long unsigned int // NVPTX32:#define __UINTMAX_WIDTH__ 64 // NVPTX32:#define __UINTPTR_MAX__ 4294967295U // NVPTX32:#define __UINTPTR_TYPE__ unsigned int // NVPTX32:#define __UINTPTR_WIDTH__ 32 // NVPTX32:#define __UINT_FAST16_MAX__ 65535 // NVPTX32:#define __UINT_FAST16_TYPE__ unsigned short // NVPTX32:#define __UINT_FAST32_MAX__ 4294967295U // NVPTX32:#define __UINT_FAST32_TYPE__ unsigned int // NVPTX32:#define __UINT_FAST64_MAX__ 18446744073709551615ULL // NVPTX32:#define __UINT_FAST64_TYPE__ long long unsigned int // NVPTX32:#define __UINT_FAST8_MAX__ 255 // NVPTX32:#define __UINT_FAST8_TYPE__ unsigned char // NVPTX32:#define __UINT_LEAST16_MAX__ 65535 // NVPTX32:#define __UINT_LEAST16_TYPE__ unsigned short // NVPTX32:#define __UINT_LEAST32_MAX__ 4294967295U // NVPTX32:#define __UINT_LEAST32_TYPE__ unsigned int // NVPTX32:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL // NVPTX32:#define __UINT_LEAST64_TYPE__ long long unsigned int // NVPTX32:#define __UINT_LEAST8_MAX__ 255 // NVPTX32:#define __UINT_LEAST8_TYPE__ unsigned char // NVPTX32:#define __USER_LABEL_PREFIX__ // NVPTX32:#define __WCHAR_MAX__ 2147483647 // NVPTX32:#define __WCHAR_TYPE__ int // NVPTX32:#define __WCHAR_WIDTH__ 32 // NVPTX32:#define __WINT_TYPE__ int // NVPTX32:#define __WINT_WIDTH__ 32 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=nvptx64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX64 %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=nvptx64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix NVPTX64 -check-prefix NVPTX64-CXX %s // // NVPTX64:#define _LP64 1 // NVPTX64:#define __BIGGEST_ALIGNMENT__ 8 // NVPTX64:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // NVPTX64:#define __CHAR16_TYPE__ unsigned short // NVPTX64:#define __CHAR32_TYPE__ unsigned int // NVPTX64:#define __CHAR_BIT__ 8 // NVPTX64:#define __CONSTANT_CFSTRINGS__ 1 // NVPTX64:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // NVPTX64:#define __DBL_DIG__ 15 // NVPTX64:#define __DBL_EPSILON__ 2.2204460492503131e-16 // NVPTX64:#define __DBL_HAS_DENORM__ 1 // NVPTX64:#define __DBL_HAS_INFINITY__ 1 // NVPTX64:#define __DBL_HAS_QUIET_NAN__ 1 // NVPTX64:#define __DBL_MANT_DIG__ 53 // NVPTX64:#define __DBL_MAX_10_EXP__ 308 // NVPTX64:#define __DBL_MAX_EXP__ 1024 // NVPTX64:#define __DBL_MAX__ 1.7976931348623157e+308 // NVPTX64:#define __DBL_MIN_10_EXP__ (-307) // NVPTX64:#define __DBL_MIN_EXP__ (-1021) // NVPTX64:#define __DBL_MIN__ 2.2250738585072014e-308 // NVPTX64:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // NVPTX64:#define __FINITE_MATH_ONLY__ 0 // NVPTX64:#define __FLT_DENORM_MIN__ 1.40129846e-45F // NVPTX64:#define __FLT_DIG__ 6 // NVPTX64:#define __FLT_EPSILON__ 1.19209290e-7F // NVPTX64:#define __FLT_EVAL_METHOD__ 0 // NVPTX64:#define __FLT_HAS_DENORM__ 1 // NVPTX64:#define __FLT_HAS_INFINITY__ 1 // NVPTX64:#define __FLT_HAS_QUIET_NAN__ 1 // NVPTX64:#define __FLT_MANT_DIG__ 24 // NVPTX64:#define __FLT_MAX_10_EXP__ 38 // NVPTX64:#define __FLT_MAX_EXP__ 128 // NVPTX64:#define __FLT_MAX__ 3.40282347e+38F // NVPTX64:#define __FLT_MIN_10_EXP__ (-37) // NVPTX64:#define __FLT_MIN_EXP__ (-125) // NVPTX64:#define __FLT_MIN__ 1.17549435e-38F // NVPTX64:#define __FLT_RADIX__ 2 // NVPTX64:#define __INT16_C_SUFFIX__ // NVPTX64:#define __INT16_FMTd__ "hd" // NVPTX64:#define __INT16_FMTi__ "hi" // NVPTX64:#define __INT16_MAX__ 32767 // NVPTX64:#define __INT16_TYPE__ short // NVPTX64:#define __INT32_C_SUFFIX__ // NVPTX64:#define __INT32_FMTd__ "d" // NVPTX64:#define __INT32_FMTi__ "i" // NVPTX64:#define __INT32_MAX__ 2147483647 // NVPTX64:#define __INT32_TYPE__ int // NVPTX64:#define __INT64_C_SUFFIX__ LL // NVPTX64:#define __INT64_FMTd__ "lld" // NVPTX64:#define __INT64_FMTi__ "lli" // NVPTX64:#define __INT64_MAX__ 9223372036854775807LL // NVPTX64:#define __INT64_TYPE__ long long int // NVPTX64:#define __INT8_C_SUFFIX__ // NVPTX64:#define __INT8_FMTd__ "hhd" // NVPTX64:#define __INT8_FMTi__ "hhi" // NVPTX64:#define __INT8_MAX__ 127 // NVPTX64:#define __INT8_TYPE__ signed char // NVPTX64:#define __INTMAX_C_SUFFIX__ LL // NVPTX64:#define __INTMAX_FMTd__ "lld" // NVPTX64:#define __INTMAX_FMTi__ "lli" // NVPTX64:#define __INTMAX_MAX__ 9223372036854775807LL // NVPTX64:#define __INTMAX_TYPE__ long long int // NVPTX64:#define __INTMAX_WIDTH__ 64 // NVPTX64:#define __INTPTR_FMTd__ "ld" // NVPTX64:#define __INTPTR_FMTi__ "li" // NVPTX64:#define __INTPTR_MAX__ 9223372036854775807L // NVPTX64:#define __INTPTR_TYPE__ long int // NVPTX64:#define __INTPTR_WIDTH__ 64 // NVPTX64:#define __INT_FAST16_FMTd__ "hd" // NVPTX64:#define __INT_FAST16_FMTi__ "hi" // NVPTX64:#define __INT_FAST16_MAX__ 32767 // NVPTX64:#define __INT_FAST16_TYPE__ short // NVPTX64:#define __INT_FAST32_FMTd__ "d" // NVPTX64:#define __INT_FAST32_FMTi__ "i" // NVPTX64:#define __INT_FAST32_MAX__ 2147483647 // NVPTX64:#define __INT_FAST32_TYPE__ int // NVPTX64:#define __INT_FAST64_FMTd__ "ld" // NVPTX64:#define __INT_FAST64_FMTi__ "li" // NVPTX64:#define __INT_FAST64_MAX__ 9223372036854775807L // NVPTX64:#define __INT_FAST64_TYPE__ long int // NVPTX64:#define __INT_FAST8_FMTd__ "hhd" // NVPTX64:#define __INT_FAST8_FMTi__ "hhi" // NVPTX64:#define __INT_FAST8_MAX__ 127 // NVPTX64:#define __INT_FAST8_TYPE__ signed char // NVPTX64:#define __INT_LEAST16_FMTd__ "hd" // NVPTX64:#define __INT_LEAST16_FMTi__ "hi" // NVPTX64:#define __INT_LEAST16_MAX__ 32767 // NVPTX64:#define __INT_LEAST16_TYPE__ short // NVPTX64:#define __INT_LEAST32_FMTd__ "d" // NVPTX64:#define __INT_LEAST32_FMTi__ "i" // NVPTX64:#define __INT_LEAST32_MAX__ 2147483647 // NVPTX64:#define __INT_LEAST32_TYPE__ int // NVPTX64:#define __INT_LEAST64_FMTd__ "ld" // NVPTX64:#define __INT_LEAST64_FMTi__ "li" // NVPTX64:#define __INT_LEAST64_MAX__ 9223372036854775807L // NVPTX64:#define __INT_LEAST64_TYPE__ long int // NVPTX64:#define __INT_LEAST8_FMTd__ "hhd" // NVPTX64:#define __INT_LEAST8_FMTi__ "hhi" // NVPTX64:#define __INT_LEAST8_MAX__ 127 // NVPTX64:#define __INT_LEAST8_TYPE__ signed char // NVPTX64:#define __INT_MAX__ 2147483647 // NVPTX64:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L // NVPTX64:#define __LDBL_DIG__ 15 // NVPTX64:#define __LDBL_EPSILON__ 2.2204460492503131e-16L // NVPTX64:#define __LDBL_HAS_DENORM__ 1 // NVPTX64:#define __LDBL_HAS_INFINITY__ 1 // NVPTX64:#define __LDBL_HAS_QUIET_NAN__ 1 // NVPTX64:#define __LDBL_MANT_DIG__ 53 // NVPTX64:#define __LDBL_MAX_10_EXP__ 308 // NVPTX64:#define __LDBL_MAX_EXP__ 1024 // NVPTX64:#define __LDBL_MAX__ 1.7976931348623157e+308L // NVPTX64:#define __LDBL_MIN_10_EXP__ (-307) // NVPTX64:#define __LDBL_MIN_EXP__ (-1021) // NVPTX64:#define __LDBL_MIN__ 2.2250738585072014e-308L // NVPTX64:#define __LITTLE_ENDIAN__ 1 // NVPTX64:#define __LONG_LONG_MAX__ 9223372036854775807LL // NVPTX64:#define __LONG_MAX__ 9223372036854775807L // NVPTX64:#define __LP64__ 1 // NVPTX64:#define __NVPTX__ 1 // NVPTX64:#define __POINTER_WIDTH__ 64 // NVPTX64:#define __PRAGMA_REDEFINE_EXTNAME 1 // NVPTX64:#define __PTRDIFF_TYPE__ long int // NVPTX64:#define __PTRDIFF_WIDTH__ 64 // NVPTX64:#define __PTX__ 1 // NVPTX64:#define __SCHAR_MAX__ 127 // NVPTX64:#define __SHRT_MAX__ 32767 // NVPTX64:#define __SIG_ATOMIC_MAX__ 2147483647 // NVPTX64:#define __SIG_ATOMIC_WIDTH__ 32 // NVPTX64:#define __SIZEOF_DOUBLE__ 8 // NVPTX64:#define __SIZEOF_FLOAT__ 4 // NVPTX64:#define __SIZEOF_INT__ 4 // NVPTX64:#define __SIZEOF_LONG_DOUBLE__ 8 // NVPTX64:#define __SIZEOF_LONG_LONG__ 8 // NVPTX64:#define __SIZEOF_LONG__ 8 // NVPTX64:#define __SIZEOF_POINTER__ 8 // NVPTX64:#define __SIZEOF_PTRDIFF_T__ 8 // NVPTX64:#define __SIZEOF_SHORT__ 2 // NVPTX64:#define __SIZEOF_SIZE_T__ 8 // NVPTX64:#define __SIZEOF_WCHAR_T__ 4 // NVPTX64:#define __SIZEOF_WINT_T__ 4 // NVPTX64:#define __SIZE_MAX__ 18446744073709551615UL // NVPTX64:#define __SIZE_TYPE__ long unsigned int // NVPTX64:#define __SIZE_WIDTH__ 64 // NVPTX64-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL // NVPTX64:#define __UINT16_C_SUFFIX__ // NVPTX64:#define __UINT16_MAX__ 65535 // NVPTX64:#define __UINT16_TYPE__ unsigned short // NVPTX64:#define __UINT32_C_SUFFIX__ U // NVPTX64:#define __UINT32_MAX__ 4294967295U // NVPTX64:#define __UINT32_TYPE__ unsigned int // NVPTX64:#define __UINT64_C_SUFFIX__ ULL // NVPTX64:#define __UINT64_MAX__ 18446744073709551615ULL // NVPTX64:#define __UINT64_TYPE__ long long unsigned int // NVPTX64:#define __UINT8_C_SUFFIX__ // NVPTX64:#define __UINT8_MAX__ 255 // NVPTX64:#define __UINT8_TYPE__ unsigned char // NVPTX64:#define __UINTMAX_C_SUFFIX__ ULL // NVPTX64:#define __UINTMAX_MAX__ 18446744073709551615ULL // NVPTX64:#define __UINTMAX_TYPE__ long long unsigned int // NVPTX64:#define __UINTMAX_WIDTH__ 64 // NVPTX64:#define __UINTPTR_MAX__ 18446744073709551615UL // NVPTX64:#define __UINTPTR_TYPE__ long unsigned int // NVPTX64:#define __UINTPTR_WIDTH__ 64 // NVPTX64:#define __UINT_FAST16_MAX__ 65535 // NVPTX64:#define __UINT_FAST16_TYPE__ unsigned short // NVPTX64:#define __UINT_FAST32_MAX__ 4294967295U // NVPTX64:#define __UINT_FAST32_TYPE__ unsigned int // NVPTX64:#define __UINT_FAST64_MAX__ 18446744073709551615UL // NVPTX64:#define __UINT_FAST64_TYPE__ long unsigned int // NVPTX64:#define __UINT_FAST8_MAX__ 255 // NVPTX64:#define __UINT_FAST8_TYPE__ unsigned char // NVPTX64:#define __UINT_LEAST16_MAX__ 65535 // NVPTX64:#define __UINT_LEAST16_TYPE__ unsigned short // NVPTX64:#define __UINT_LEAST32_MAX__ 4294967295U // NVPTX64:#define __UINT_LEAST32_TYPE__ unsigned int // NVPTX64:#define __UINT_LEAST64_MAX__ 18446744073709551615UL // NVPTX64:#define __UINT_LEAST64_TYPE__ long unsigned int // NVPTX64:#define __UINT_LEAST8_MAX__ 255 // NVPTX64:#define __UINT_LEAST8_TYPE__ unsigned char // NVPTX64:#define __USER_LABEL_PREFIX__ // NVPTX64:#define __WCHAR_MAX__ 2147483647 // NVPTX64:#define __WCHAR_TYPE__ int // NVPTX64:#define __WCHAR_WIDTH__ 32 // NVPTX64:#define __WINT_TYPE__ int // NVPTX64:#define __WINT_WIDTH__ 32 // // RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=amdgcn < /dev/null | FileCheck -match-full-lines -check-prefix AMDGCN --check-prefix AMDGPU %s // RUN: %clang_cc1 -x cl -E -dM -ffreestanding -triple=r600 -target-cpu caicos < /dev/null | FileCheck -match-full-lines --check-prefix AMDGPU %s // // AMDGPU:#define __ENDIAN_LITTLE__ 1 // AMDGPU:#define cl_khr_byte_addressable_store 1 // AMDGCN:#define cl_khr_fp64 1 // AMDGPU:#define cl_khr_global_int32_base_atomics 1 // AMDGPU:#define cl_khr_global_int32_extended_atomics 1 // AMDGPU:#define cl_khr_local_int32_base_atomics 1 // AMDGPU:#define cl_khr_local_int32_extended_atomics 1 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-rtems-elf < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-netbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-DEFAULT -check-prefix SPARC-DEFAULT-CXX %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=sparc-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC -check-prefix SPARC-NETOPENBSD -check-prefix SPARC-NETOPENBSD-CXX %s // // SPARC-NOT:#define _LP64 // SPARC:#define __BIGGEST_ALIGNMENT__ 8 // SPARC:#define __BIG_ENDIAN__ 1 // SPARC:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // SPARC:#define __CHAR16_TYPE__ unsigned short // SPARC:#define __CHAR32_TYPE__ unsigned int // SPARC:#define __CHAR_BIT__ 8 // SPARC:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // SPARC:#define __DBL_DIG__ 15 // SPARC:#define __DBL_EPSILON__ 2.2204460492503131e-16 // SPARC:#define __DBL_HAS_DENORM__ 1 // SPARC:#define __DBL_HAS_INFINITY__ 1 // SPARC:#define __DBL_HAS_QUIET_NAN__ 1 // SPARC:#define __DBL_MANT_DIG__ 53 // SPARC:#define __DBL_MAX_10_EXP__ 308 // SPARC:#define __DBL_MAX_EXP__ 1024 // SPARC:#define __DBL_MAX__ 1.7976931348623157e+308 // SPARC:#define __DBL_MIN_10_EXP__ (-307) // SPARC:#define __DBL_MIN_EXP__ (-1021) // SPARC:#define __DBL_MIN__ 2.2250738585072014e-308 // SPARC:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // SPARC:#define __FLT_DENORM_MIN__ 1.40129846e-45F // SPARC:#define __FLT_DIG__ 6 // SPARC:#define __FLT_EPSILON__ 1.19209290e-7F // SPARC:#define __FLT_EVAL_METHOD__ 0 // SPARC:#define __FLT_HAS_DENORM__ 1 // SPARC:#define __FLT_HAS_INFINITY__ 1 // SPARC:#define __FLT_HAS_QUIET_NAN__ 1 // SPARC:#define __FLT_MANT_DIG__ 24 // SPARC:#define __FLT_MAX_10_EXP__ 38 // SPARC:#define __FLT_MAX_EXP__ 128 // SPARC:#define __FLT_MAX__ 3.40282347e+38F // SPARC:#define __FLT_MIN_10_EXP__ (-37) // SPARC:#define __FLT_MIN_EXP__ (-125) // SPARC:#define __FLT_MIN__ 1.17549435e-38F // SPARC:#define __FLT_RADIX__ 2 // SPARC:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 // SPARC:#define __INT16_C_SUFFIX__ // SPARC:#define __INT16_FMTd__ "hd" // SPARC:#define __INT16_FMTi__ "hi" // SPARC:#define __INT16_MAX__ 32767 // SPARC:#define __INT16_TYPE__ short // SPARC:#define __INT32_C_SUFFIX__ // SPARC:#define __INT32_FMTd__ "d" // SPARC:#define __INT32_FMTi__ "i" // SPARC:#define __INT32_MAX__ 2147483647 // SPARC:#define __INT32_TYPE__ int // SPARC:#define __INT64_C_SUFFIX__ LL // SPARC:#define __INT64_FMTd__ "lld" // SPARC:#define __INT64_FMTi__ "lli" // SPARC:#define __INT64_MAX__ 9223372036854775807LL // SPARC:#define __INT64_TYPE__ long long int // SPARC:#define __INT8_C_SUFFIX__ // SPARC:#define __INT8_FMTd__ "hhd" // SPARC:#define __INT8_FMTi__ "hhi" // SPARC:#define __INT8_MAX__ 127 // SPARC:#define __INT8_TYPE__ signed char // SPARC:#define __INTMAX_C_SUFFIX__ LL // SPARC:#define __INTMAX_FMTd__ "lld" // SPARC:#define __INTMAX_FMTi__ "lli" // SPARC:#define __INTMAX_MAX__ 9223372036854775807LL // SPARC:#define __INTMAX_TYPE__ long long int // SPARC:#define __INTMAX_WIDTH__ 64 // SPARC-DEFAULT:#define __INTPTR_FMTd__ "d" // SPARC-DEFAULT:#define __INTPTR_FMTi__ "i" // SPARC-DEFAULT:#define __INTPTR_MAX__ 2147483647 // SPARC-DEFAULT:#define __INTPTR_TYPE__ int // SPARC-NETOPENBSD:#define __INTPTR_FMTd__ "ld" // SPARC-NETOPENBSD:#define __INTPTR_FMTi__ "li" // SPARC-NETOPENBSD:#define __INTPTR_MAX__ 2147483647L // SPARC-NETOPENBSD:#define __INTPTR_TYPE__ long int // SPARC:#define __INTPTR_WIDTH__ 32 // SPARC:#define __INT_FAST16_FMTd__ "hd" // SPARC:#define __INT_FAST16_FMTi__ "hi" // SPARC:#define __INT_FAST16_MAX__ 32767 // SPARC:#define __INT_FAST16_TYPE__ short // SPARC:#define __INT_FAST32_FMTd__ "d" // SPARC:#define __INT_FAST32_FMTi__ "i" // SPARC:#define __INT_FAST32_MAX__ 2147483647 // SPARC:#define __INT_FAST32_TYPE__ int // SPARC:#define __INT_FAST64_FMTd__ "lld" // SPARC:#define __INT_FAST64_FMTi__ "lli" // SPARC:#define __INT_FAST64_MAX__ 9223372036854775807LL // SPARC:#define __INT_FAST64_TYPE__ long long int // SPARC:#define __INT_FAST8_FMTd__ "hhd" // SPARC:#define __INT_FAST8_FMTi__ "hhi" // SPARC:#define __INT_FAST8_MAX__ 127 // SPARC:#define __INT_FAST8_TYPE__ signed char // SPARC:#define __INT_LEAST16_FMTd__ "hd" // SPARC:#define __INT_LEAST16_FMTi__ "hi" // SPARC:#define __INT_LEAST16_MAX__ 32767 // SPARC:#define __INT_LEAST16_TYPE__ short // SPARC:#define __INT_LEAST32_FMTd__ "d" // SPARC:#define __INT_LEAST32_FMTi__ "i" // SPARC:#define __INT_LEAST32_MAX__ 2147483647 // SPARC:#define __INT_LEAST32_TYPE__ int // SPARC:#define __INT_LEAST64_FMTd__ "lld" // SPARC:#define __INT_LEAST64_FMTi__ "lli" // SPARC:#define __INT_LEAST64_MAX__ 9223372036854775807LL // SPARC:#define __INT_LEAST64_TYPE__ long long int // SPARC:#define __INT_LEAST8_FMTd__ "hhd" // SPARC:#define __INT_LEAST8_FMTi__ "hhi" // SPARC:#define __INT_LEAST8_MAX__ 127 // SPARC:#define __INT_LEAST8_TYPE__ signed char // SPARC:#define __INT_MAX__ 2147483647 // SPARC:#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L // SPARC:#define __LDBL_DIG__ 15 // SPARC:#define __LDBL_EPSILON__ 2.2204460492503131e-16L // SPARC:#define __LDBL_HAS_DENORM__ 1 // SPARC:#define __LDBL_HAS_INFINITY__ 1 // SPARC:#define __LDBL_HAS_QUIET_NAN__ 1 // SPARC:#define __LDBL_MANT_DIG__ 53 // SPARC:#define __LDBL_MAX_10_EXP__ 308 // SPARC:#define __LDBL_MAX_EXP__ 1024 // SPARC:#define __LDBL_MAX__ 1.7976931348623157e+308L // SPARC:#define __LDBL_MIN_10_EXP__ (-307) // SPARC:#define __LDBL_MIN_EXP__ (-1021) // SPARC:#define __LDBL_MIN__ 2.2250738585072014e-308L // SPARC:#define __LONG_LONG_MAX__ 9223372036854775807LL // SPARC:#define __LONG_MAX__ 2147483647L // SPARC-NOT:#define __LP64__ // SPARC:#define __POINTER_WIDTH__ 32 // SPARC-DEFAULT:#define __PTRDIFF_TYPE__ int // SPARC-NETOPENBSD:#define __PTRDIFF_TYPE__ long int // SPARC:#define __PTRDIFF_WIDTH__ 32 // SPARC:#define __REGISTER_PREFIX__ // SPARC:#define __SCHAR_MAX__ 127 // SPARC:#define __SHRT_MAX__ 32767 // SPARC:#define __SIG_ATOMIC_MAX__ 2147483647 // SPARC:#define __SIG_ATOMIC_WIDTH__ 32 // SPARC:#define __SIZEOF_DOUBLE__ 8 // SPARC:#define __SIZEOF_FLOAT__ 4 // SPARC:#define __SIZEOF_INT__ 4 // SPARC:#define __SIZEOF_LONG_DOUBLE__ 8 // SPARC:#define __SIZEOF_LONG_LONG__ 8 // SPARC:#define __SIZEOF_LONG__ 4 // SPARC:#define __SIZEOF_POINTER__ 4 // SPARC:#define __SIZEOF_PTRDIFF_T__ 4 // SPARC:#define __SIZEOF_SHORT__ 2 // SPARC:#define __SIZEOF_SIZE_T__ 4 // SPARC:#define __SIZEOF_WCHAR_T__ 4 // SPARC:#define __SIZEOF_WINT_T__ 4 // SPARC-DEFAULT:#define __SIZE_MAX__ 4294967295U // SPARC-DEFAULT:#define __SIZE_TYPE__ unsigned int // SPARC-NETOPENBSD:#define __SIZE_MAX__ 4294967295UL // SPARC-NETOPENBSD:#define __SIZE_TYPE__ long unsigned int // SPARC:#define __SIZE_WIDTH__ 32 // SPARC-DEFAULT-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // SPARC-NETOPENBSD-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8UL // SPARC:#define __UINT16_C_SUFFIX__ // SPARC:#define __UINT16_MAX__ 65535 // SPARC:#define __UINT16_TYPE__ unsigned short // SPARC:#define __UINT32_C_SUFFIX__ U // SPARC:#define __UINT32_MAX__ 4294967295U // SPARC:#define __UINT32_TYPE__ unsigned int // SPARC:#define __UINT64_C_SUFFIX__ ULL // SPARC:#define __UINT64_MAX__ 18446744073709551615ULL // SPARC:#define __UINT64_TYPE__ long long unsigned int // SPARC:#define __UINT8_C_SUFFIX__ // SPARC:#define __UINT8_MAX__ 255 // SPARC:#define __UINT8_TYPE__ unsigned char // SPARC:#define __UINTMAX_C_SUFFIX__ ULL // SPARC:#define __UINTMAX_MAX__ 18446744073709551615ULL // SPARC:#define __UINTMAX_TYPE__ long long unsigned int // SPARC:#define __UINTMAX_WIDTH__ 64 // SPARC-DEFAULT:#define __UINTPTR_MAX__ 4294967295U // SPARC-DEFAULT:#define __UINTPTR_TYPE__ unsigned int // SPARC-NETOPENBSD:#define __UINTPTR_MAX__ 4294967295UL // SPARC-NETOPENBSD:#define __UINTPTR_TYPE__ long unsigned int // SPARC:#define __UINTPTR_WIDTH__ 32 // SPARC:#define __UINT_FAST16_MAX__ 65535 // SPARC:#define __UINT_FAST16_TYPE__ unsigned short // SPARC:#define __UINT_FAST32_MAX__ 4294967295U // SPARC:#define __UINT_FAST32_TYPE__ unsigned int // SPARC:#define __UINT_FAST64_MAX__ 18446744073709551615ULL // SPARC:#define __UINT_FAST64_TYPE__ long long unsigned int // SPARC:#define __UINT_FAST8_MAX__ 255 // SPARC:#define __UINT_FAST8_TYPE__ unsigned char // SPARC:#define __UINT_LEAST16_MAX__ 65535 // SPARC:#define __UINT_LEAST16_TYPE__ unsigned short // SPARC:#define __UINT_LEAST32_MAX__ 4294967295U // SPARC:#define __UINT_LEAST32_TYPE__ unsigned int // SPARC:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL // SPARC:#define __UINT_LEAST64_TYPE__ long long unsigned int // SPARC:#define __UINT_LEAST8_MAX__ 255 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char // SPARC:#define __USER_LABEL_PREFIX__ // SPARC:#define __VERSION__ "{{.*}}Clang{{.*}} // SPARC:#define __WCHAR_MAX__ 2147483647 // SPARC:#define __WCHAR_TYPE__ int // SPARC:#define __WCHAR_WIDTH__ 32 // SPARC:#define __WINT_TYPE__ int // SPARC:#define __WINT_WIDTH__ 32 // SPARC:#define __sparc 1 // SPARC:#define __sparc__ 1 // SPARC:#define __sparcv8 1 // SPARC:#define sparc 1 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=tce-none-none < /dev/null | FileCheck -match-full-lines -check-prefix TCE %s // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=tce-none-none < /dev/null | FileCheck -match-full-lines -check-prefix TCE -check-prefix TCE-CXX %s // // TCE-NOT:#define _LP64 // TCE:#define __BIGGEST_ALIGNMENT__ 4 // TCE:#define __BIG_ENDIAN__ 1 // TCE:#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__ // TCE:#define __CHAR16_TYPE__ unsigned short // TCE:#define __CHAR32_TYPE__ unsigned int // TCE:#define __CHAR_BIT__ 8 // TCE:#define __DBL_DENORM_MIN__ 1.40129846e-45 // TCE:#define __DBL_DIG__ 6 // TCE:#define __DBL_EPSILON__ 1.19209290e-7 // TCE:#define __DBL_HAS_DENORM__ 1 // TCE:#define __DBL_HAS_INFINITY__ 1 // TCE:#define __DBL_HAS_QUIET_NAN__ 1 // TCE:#define __DBL_MANT_DIG__ 24 // TCE:#define __DBL_MAX_10_EXP__ 38 // TCE:#define __DBL_MAX_EXP__ 128 // TCE:#define __DBL_MAX__ 3.40282347e+38 // TCE:#define __DBL_MIN_10_EXP__ (-37) // TCE:#define __DBL_MIN_EXP__ (-125) // TCE:#define __DBL_MIN__ 1.17549435e-38 // TCE:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // TCE:#define __FLT_DENORM_MIN__ 1.40129846e-45F // TCE:#define __FLT_DIG__ 6 // TCE:#define __FLT_EPSILON__ 1.19209290e-7F // TCE:#define __FLT_EVAL_METHOD__ 0 // TCE:#define __FLT_HAS_DENORM__ 1 // TCE:#define __FLT_HAS_INFINITY__ 1 // TCE:#define __FLT_HAS_QUIET_NAN__ 1 // TCE:#define __FLT_MANT_DIG__ 24 // TCE:#define __FLT_MAX_10_EXP__ 38 // TCE:#define __FLT_MAX_EXP__ 128 // TCE:#define __FLT_MAX__ 3.40282347e+38F // TCE:#define __FLT_MIN_10_EXP__ (-37) // TCE:#define __FLT_MIN_EXP__ (-125) // TCE:#define __FLT_MIN__ 1.17549435e-38F // TCE:#define __FLT_RADIX__ 2 // TCE:#define __INT16_C_SUFFIX__ // TCE:#define __INT16_FMTd__ "hd" // TCE:#define __INT16_FMTi__ "hi" // TCE:#define __INT16_MAX__ 32767 // TCE:#define __INT16_TYPE__ short // TCE:#define __INT32_C_SUFFIX__ // TCE:#define __INT32_FMTd__ "d" // TCE:#define __INT32_FMTi__ "i" // TCE:#define __INT32_MAX__ 2147483647 // TCE:#define __INT32_TYPE__ int // TCE:#define __INT8_C_SUFFIX__ // TCE:#define __INT8_FMTd__ "hhd" // TCE:#define __INT8_FMTi__ "hhi" // TCE:#define __INT8_MAX__ 127 // TCE:#define __INT8_TYPE__ signed char // TCE:#define __INTMAX_C_SUFFIX__ L // TCE:#define __INTMAX_FMTd__ "ld" // TCE:#define __INTMAX_FMTi__ "li" // TCE:#define __INTMAX_MAX__ 2147483647L // TCE:#define __INTMAX_TYPE__ long int // TCE:#define __INTMAX_WIDTH__ 32 // TCE:#define __INTPTR_FMTd__ "d" // TCE:#define __INTPTR_FMTi__ "i" // TCE:#define __INTPTR_MAX__ 2147483647 // TCE:#define __INTPTR_TYPE__ int // TCE:#define __INTPTR_WIDTH__ 32 // TCE:#define __INT_FAST16_FMTd__ "hd" // TCE:#define __INT_FAST16_FMTi__ "hi" // TCE:#define __INT_FAST16_MAX__ 32767 // TCE:#define __INT_FAST16_TYPE__ short // TCE:#define __INT_FAST32_FMTd__ "d" // TCE:#define __INT_FAST32_FMTi__ "i" // TCE:#define __INT_FAST32_MAX__ 2147483647 // TCE:#define __INT_FAST32_TYPE__ int // TCE:#define __INT_FAST8_FMTd__ "hhd" // TCE:#define __INT_FAST8_FMTi__ "hhi" // TCE:#define __INT_FAST8_MAX__ 127 // TCE:#define __INT_FAST8_TYPE__ signed char // TCE:#define __INT_LEAST16_FMTd__ "hd" // TCE:#define __INT_LEAST16_FMTi__ "hi" // TCE:#define __INT_LEAST16_MAX__ 32767 // TCE:#define __INT_LEAST16_TYPE__ short // TCE:#define __INT_LEAST32_FMTd__ "d" // TCE:#define __INT_LEAST32_FMTi__ "i" // TCE:#define __INT_LEAST32_MAX__ 2147483647 // TCE:#define __INT_LEAST32_TYPE__ int // TCE:#define __INT_LEAST8_FMTd__ "hhd" // TCE:#define __INT_LEAST8_FMTi__ "hhi" // TCE:#define __INT_LEAST8_MAX__ 127 // TCE:#define __INT_LEAST8_TYPE__ signed char // TCE:#define __INT_MAX__ 2147483647 // TCE:#define __LDBL_DENORM_MIN__ 1.40129846e-45L // TCE:#define __LDBL_DIG__ 6 // TCE:#define __LDBL_EPSILON__ 1.19209290e-7L // TCE:#define __LDBL_HAS_DENORM__ 1 // TCE:#define __LDBL_HAS_INFINITY__ 1 // TCE:#define __LDBL_HAS_QUIET_NAN__ 1 // TCE:#define __LDBL_MANT_DIG__ 24 // TCE:#define __LDBL_MAX_10_EXP__ 38 // TCE:#define __LDBL_MAX_EXP__ 128 // TCE:#define __LDBL_MAX__ 3.40282347e+38L // TCE:#define __LDBL_MIN_10_EXP__ (-37) // TCE:#define __LDBL_MIN_EXP__ (-125) // TCE:#define __LDBL_MIN__ 1.17549435e-38L // TCE:#define __LONG_LONG_MAX__ 2147483647LL // TCE:#define __LONG_MAX__ 2147483647L // TCE-NOT:#define __LP64__ // TCE:#define __POINTER_WIDTH__ 32 // TCE:#define __PTRDIFF_TYPE__ int // TCE:#define __PTRDIFF_WIDTH__ 32 // TCE:#define __SCHAR_MAX__ 127 // TCE:#define __SHRT_MAX__ 32767 // TCE:#define __SIG_ATOMIC_MAX__ 2147483647 // TCE:#define __SIG_ATOMIC_WIDTH__ 32 // TCE:#define __SIZEOF_DOUBLE__ 4 // TCE:#define __SIZEOF_FLOAT__ 4 // TCE:#define __SIZEOF_INT__ 4 // TCE:#define __SIZEOF_LONG_DOUBLE__ 4 // TCE:#define __SIZEOF_LONG_LONG__ 4 // TCE:#define __SIZEOF_LONG__ 4 // TCE:#define __SIZEOF_POINTER__ 4 // TCE:#define __SIZEOF_PTRDIFF_T__ 4 // TCE:#define __SIZEOF_SHORT__ 2 // TCE:#define __SIZEOF_SIZE_T__ 4 // TCE:#define __SIZEOF_WCHAR_T__ 4 // TCE:#define __SIZEOF_WINT_T__ 4 // TCE:#define __SIZE_MAX__ 4294967295U // TCE:#define __SIZE_TYPE__ unsigned int // TCE:#define __SIZE_WIDTH__ 32 // TCE-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U // TCE:#define __TCE_V1__ 1 // TCE:#define __TCE__ 1 // TCE:#define __UINT16_C_SUFFIX__ // TCE:#define __UINT16_MAX__ 65535 // TCE:#define __UINT16_TYPE__ unsigned short // TCE:#define __UINT32_C_SUFFIX__ U // TCE:#define __UINT32_MAX__ 4294967295U // TCE:#define __UINT32_TYPE__ unsigned int // TCE:#define __UINT8_C_SUFFIX__ // TCE:#define __UINT8_MAX__ 255 // TCE:#define __UINT8_TYPE__ unsigned char // TCE:#define __UINTMAX_C_SUFFIX__ UL // TCE:#define __UINTMAX_MAX__ 4294967295UL // TCE:#define __UINTMAX_TYPE__ long unsigned int // TCE:#define __UINTMAX_WIDTH__ 32 // TCE:#define __UINTPTR_MAX__ 4294967295U // TCE:#define __UINTPTR_TYPE__ unsigned int // TCE:#define __UINTPTR_WIDTH__ 32 // TCE:#define __UINT_FAST16_MAX__ 65535 // TCE:#define __UINT_FAST16_TYPE__ unsigned short // TCE:#define __UINT_FAST32_MAX__ 4294967295U // TCE:#define __UINT_FAST32_TYPE__ unsigned int // TCE:#define __UINT_FAST8_MAX__ 255 // TCE:#define __UINT_FAST8_TYPE__ unsigned char // TCE:#define __UINT_LEAST16_MAX__ 65535 // TCE:#define __UINT_LEAST16_TYPE__ unsigned short // TCE:#define __UINT_LEAST32_MAX__ 4294967295U // TCE:#define __UINT_LEAST32_TYPE__ unsigned int // TCE:#define __UINT_LEAST8_MAX__ 255 // TCE:#define __UINT_LEAST8_TYPE__ unsigned char // TCE:#define __USER_LABEL_PREFIX__ // TCE:#define __WCHAR_MAX__ 2147483647 // TCE:#define __WCHAR_TYPE__ int // TCE:#define __WCHAR_WIDTH__ 32 // TCE:#define __WINT_TYPE__ int // TCE:#define __WINT_WIDTH__ 32 // TCE:#define __tce 1 // TCE:#define __tce__ 1 // TCE:#define tce 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4 %s // // PS4:#define _LP64 1 // PS4:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // PS4:#define __CHAR16_TYPE__ unsigned short // PS4:#define __CHAR32_TYPE__ unsigned int // PS4:#define __CHAR_BIT__ 8 // PS4:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // PS4:#define __DBL_DIG__ 15 // PS4:#define __DBL_EPSILON__ 2.2204460492503131e-16 // PS4:#define __DBL_HAS_DENORM__ 1 // PS4:#define __DBL_HAS_INFINITY__ 1 // PS4:#define __DBL_HAS_QUIET_NAN__ 1 // PS4:#define __DBL_MANT_DIG__ 53 // PS4:#define __DBL_MAX_10_EXP__ 308 // PS4:#define __DBL_MAX_EXP__ 1024 // PS4:#define __DBL_MAX__ 1.7976931348623157e+308 // PS4:#define __DBL_MIN_10_EXP__ (-307) // PS4:#define __DBL_MIN_EXP__ (-1021) // PS4:#define __DBL_MIN__ 2.2250738585072014e-308 // PS4:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // PS4:#define __ELF__ 1 // PS4:#define __FLT_DENORM_MIN__ 1.40129846e-45F // PS4:#define __FLT_DIG__ 6 // PS4:#define __FLT_EPSILON__ 1.19209290e-7F // PS4:#define __FLT_EVAL_METHOD__ 0 // PS4:#define __FLT_HAS_DENORM__ 1 // PS4:#define __FLT_HAS_INFINITY__ 1 // PS4:#define __FLT_HAS_QUIET_NAN__ 1 // PS4:#define __FLT_MANT_DIG__ 24 // PS4:#define __FLT_MAX_10_EXP__ 38 // PS4:#define __FLT_MAX_EXP__ 128 // PS4:#define __FLT_MAX__ 3.40282347e+38F // PS4:#define __FLT_MIN_10_EXP__ (-37) // PS4:#define __FLT_MIN_EXP__ (-125) // PS4:#define __FLT_MIN__ 1.17549435e-38F // PS4:#define __FLT_RADIX__ 2 // PS4:#define __FreeBSD__ 9 // PS4:#define __FreeBSD_cc_version 900001 // PS4:#define __INT16_TYPE__ short // PS4:#define __INT32_TYPE__ int // PS4:#define __INT64_C_SUFFIX__ L // PS4:#define __INT64_TYPE__ long int // PS4:#define __INT8_TYPE__ signed char // PS4:#define __INTMAX_MAX__ 9223372036854775807L // PS4:#define __INTMAX_TYPE__ long int // PS4:#define __INTMAX_WIDTH__ 64 // PS4:#define __INTPTR_TYPE__ long int // PS4:#define __INTPTR_WIDTH__ 64 // PS4:#define __INT_MAX__ 2147483647 // PS4:#define __KPRINTF_ATTRIBUTE__ 1 // PS4:#define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L // PS4:#define __LDBL_DIG__ 18 // PS4:#define __LDBL_EPSILON__ 1.08420217248550443401e-19L // PS4:#define __LDBL_HAS_DENORM__ 1 // PS4:#define __LDBL_HAS_INFINITY__ 1 // PS4:#define __LDBL_HAS_QUIET_NAN__ 1 // PS4:#define __LDBL_MANT_DIG__ 64 // PS4:#define __LDBL_MAX_10_EXP__ 4932 // PS4:#define __LDBL_MAX_EXP__ 16384 // PS4:#define __LDBL_MAX__ 1.18973149535723176502e+4932L // PS4:#define __LDBL_MIN_10_EXP__ (-4931) // PS4:#define __LDBL_MIN_EXP__ (-16381) // PS4:#define __LDBL_MIN__ 3.36210314311209350626e-4932L // PS4:#define __LITTLE_ENDIAN__ 1 // PS4:#define __LONG_LONG_MAX__ 9223372036854775807LL // PS4:#define __LONG_MAX__ 9223372036854775807L // PS4:#define __LP64__ 1 // PS4:#define __MMX__ 1 // PS4:#define __NO_MATH_INLINES 1 // PS4:#define __ORBIS__ 1 // PS4:#define __POINTER_WIDTH__ 64 // PS4:#define __PTRDIFF_MAX__ 9223372036854775807L // PS4:#define __PTRDIFF_TYPE__ long int // PS4:#define __PTRDIFF_WIDTH__ 64 // PS4:#define __REGISTER_PREFIX__ // PS4:#define __SCE__ 1 // PS4:#define __SCHAR_MAX__ 127 // PS4:#define __SHRT_MAX__ 32767 // PS4:#define __SIG_ATOMIC_MAX__ 2147483647 // PS4:#define __SIG_ATOMIC_WIDTH__ 32 // PS4:#define __SIZEOF_DOUBLE__ 8 // PS4:#define __SIZEOF_FLOAT__ 4 // PS4:#define __SIZEOF_INT__ 4 // PS4:#define __SIZEOF_LONG_DOUBLE__ 16 // PS4:#define __SIZEOF_LONG_LONG__ 8 // PS4:#define __SIZEOF_LONG__ 8 // PS4:#define __SIZEOF_POINTER__ 8 // PS4:#define __SIZEOF_PTRDIFF_T__ 8 // PS4:#define __SIZEOF_SHORT__ 2 // PS4:#define __SIZEOF_SIZE_T__ 8 // PS4:#define __SIZEOF_WCHAR_T__ 2 // PS4:#define __SIZEOF_WINT_T__ 4 // PS4:#define __SIZE_TYPE__ long unsigned int // PS4:#define __SIZE_WIDTH__ 64 // PS4:#define __SSE2_MATH__ 1 // PS4:#define __SSE2__ 1 // PS4:#define __SSE_MATH__ 1 // PS4:#define __SSE__ 1 // PS4:#define __STDC_VERSION__ 199901L // PS4:#define __UINTMAX_TYPE__ long unsigned int // PS4:#define __USER_LABEL_PREFIX__ // PS4:#define __WCHAR_MAX__ 65535 // PS4:#define __WCHAR_TYPE__ unsigned short // PS4:#define __WCHAR_UNSIGNED__ 1 // PS4:#define __WCHAR_WIDTH__ 16 // PS4:#define __WINT_TYPE__ int // PS4:#define __WINT_WIDTH__ 32 // PS4:#define __amd64 1 // PS4:#define __amd64__ 1 // PS4:#define __unix 1 // PS4:#define __unix__ 1 // PS4:#define __x86_64 1 // PS4:#define __x86_64__ 1 // PS4:#define unix 1 // // RUN: %clang_cc1 -x c++ -E -dM -ffreestanding -triple=x86_64-scei-ps4 < /dev/null | FileCheck -match-full-lines -check-prefix PS4-CXX %s // PS4-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 32UL // // RUN: %clang_cc1 -E -dM -triple=x86_64-pc-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s // RUN: %clang_cc1 -E -dM -fms-extensions -triple=x86_64-unknown-mingw32 < /dev/null | FileCheck -match-full-lines -check-prefix X86-64-DECLSPEC %s // X86-64-DECLSPEC: #define __declspec{{.*}} // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARCV9 %s // SPARCV9:#define __BIGGEST_ALIGNMENT__ 16 // SPARCV9:#define __INT64_TYPE__ long int // SPARCV9:#define __INTMAX_C_SUFFIX__ L // SPARCV9:#define __INTMAX_TYPE__ long int // SPARCV9:#define __INTPTR_TYPE__ long int // SPARCV9:#define __LONG_MAX__ 9223372036854775807L // SPARCV9:#define __LP64__ 1 // SPARCV9:#define __SIZEOF_LONG__ 8 // SPARCV9:#define __SIZEOF_POINTER__ 8 // SPARCV9:#define __UINTPTR_TYPE__ long unsigned int // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix SPARC64-OBSD %s // SPARC64-OBSD:#define __INT64_TYPE__ long long int // SPARC64-OBSD:#define __INTMAX_C_SUFFIX__ LL // SPARC64-OBSD:#define __INTMAX_TYPE__ long long int // SPARC64-OBSD:#define __UINTMAX_C_SUFFIX__ ULL // SPARC64-OBSD:#define __UINTMAX_TYPE__ long long unsigned int // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=x86_64-pc-kfreebsd-gnu < /dev/null | FileCheck -match-full-lines -check-prefix KFREEBSD-DEFINE %s // KFREEBSD-DEFINE:#define __FreeBSD_kernel__ 1 // KFREEBSD-DEFINE:#define __GLIBC__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i686-pc-kfreebsd-gnu < /dev/null | FileCheck -match-full-lines -check-prefix KFREEBSDI686-DEFINE %s // KFREEBSDI686-DEFINE:#define __FreeBSD_kernel__ 1 // KFREEBSDI686-DEFINE:#define __GLIBC__ 1 // // RUN: %clang_cc1 -x c++ -triple i686-pc-linux-gnu -fobjc-runtime=gcc -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s // RUN: %clang_cc1 -x c++ -triple sparc-rtems-elf -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSOURCE %s // GNUSOURCE:#define _GNU_SOURCE 1 // // Check that the GNUstep Objective-C ABI defines exist and are clamped at the // highest supported version. // RUN: %clang_cc1 -x objective-c -triple i386-unknown-freebsd -fobjc-runtime=gnustep-1.9 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSTEP1 %s // GNUSTEP1:#define __OBJC_GNUSTEP_RUNTIME_ABI__ 18 // RUN: %clang_cc1 -x objective-c -triple i386-unknown-freebsd -fobjc-runtime=gnustep-2.5 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GNUSTEP2 %s // GNUSTEP2:#define __OBJC_GNUSTEP_RUNTIME_ABI__ 20 // // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++98 -fno-rtti -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix NORTTI %s // NORTTI: #define __GXX_ABI_VERSION {{.*}} // NORTTI-NOT:#define __GXX_RTTI // NORTTI:#define __STDC__ 1 // // RUN: %clang_cc1 -triple arm-linux-androideabi -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID %s // ANDROID-NOT:#define __ANDROID_API__ // ANDROID-NOT:#define __ANDROID_MIN_SDK_VERSION__ // ANDROID:#define __ANDROID__ 1 // ANDROID-NOT:#define __gnu_linux__ // // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s // I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL // // RUN: %clang_cc1 -triple arm-linux-androideabi20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix ANDROID20 %s // ANDROID20:#define __ANDROID_API__ __ANDROID_MIN_SDK_VERSION__ // ANDROID20:#define __ANDROID_MIN_SDK_VERSION__ 20 // ANDROID20:#define __ANDROID__ 1 // ANDROID-NOT:#define __gnu_linux__ // // RUN: %clang_cc1 -triple lanai-unknown-unknown -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix LANAI %s // LANAI: #define __lanai__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=amd64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=arm-unknown-openbsd6.1-gnueabi < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=i386-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=mips64el-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv64-unknown-openbsd6.1 < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD %s // OPENBSD:#define __ELF__ 1 // OPENBSD:#define __INT16_TYPE__ short // OPENBSD:#define __INT32_TYPE__ int // OPENBSD:#define __INT64_TYPE__ long long int // OPENBSD:#define __INT8_TYPE__ signed char // OPENBSD:#define __INTMAX_TYPE__ long long int // OPENBSD:#define __INTPTR_TYPE__ long int // OPENBSD:#define __OpenBSD__ 1 // OPENBSD:#define __PTRDIFF_TYPE__ long int // OPENBSD:#define __SIZE_TYPE__ long unsigned int // OPENBSD:#define __UINT16_TYPE__ unsigned short // OPENBSD:#define __UINT32_TYPE__ unsigned int // OPENBSD:#define __UINT64_TYPE__ long long unsigned int // OPENBSD:#define __UINT8_TYPE__ unsigned char // OPENBSD:#define __UINTMAX_TYPE__ long long unsigned int // OPENBSD:#define __UINTPTR_TYPE__ long unsigned int // OPENBSD:#define __WCHAR_TYPE__ int // OPENBSD:#define __WINT_TYPE__ int // // RUN: %clang_cc1 -x c -std=c11 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC %s // RUN: %clang_cc1 -x c -std=gnu11 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC %s // RUN: %clang_cc1 -x c -std=c17 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC %s // OPENBSD-STDC:#define __STDC_NO_ATOMICS__ 1 // OPENBSD-STDC:#define __STDC_NO_THREADS__ 1 // // RUN: %clang_cc1 -x c -std=c99 -E -dM -ffreestanding -triple=amd64-unknown-openbsd < /dev/null | FileCheck -match-full-lines -check-prefix OPENBSD-STDC-N %s // OPENBSD-STDC-N-NOT:#define __STDC_NO_ATOMICS__ 1 // OPENBSD-STDC-N-NOT:#define __STDC_NO_THREADS__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -triple=xcore-none-none < /dev/null | FileCheck -match-full-lines -check-prefix XCORE %s // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // XCORE:#define __LITTLE_ENDIAN__ 1 // XCORE:#define __XS1B__ 1 // XCORE:#define __xcore__ 1 // // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-unknown-unknown \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32 %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm64-unknown-unknown \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64 %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-emscripten \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,EMSCRIPTEN %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-emscripten -pthread -target-feature +atomics \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,EMSCRIPTEN,EMSCRIPTEN-THREADS %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm64-emscripten \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,EMSCRIPTEN %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-wasi \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY32,WEBASSEMBLY-WASI %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm64-wasi \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY,WEBASSEMBLY64,WEBASSEMBLY-WASI %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-unknown-unknown -x c++ \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY-CXX %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=wasm32-unknown-unknown -x c++ -pthread -target-feature +atomics \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=WEBASSEMBLY-CXX-ATOMICS %s // // WEBASSEMBLY32:#define _ILP32 1 // WEBASSEMBLY32-NOT:#define _LP64 // WEBASSEMBLY64-NOT:#define _ILP32 // WEBASSEMBLY64:#define _LP64 1 // EMSCRIPTEN-THREADS:#define _REENTRANT 1 // WEBASSEMBLY-NEXT:#define __ATOMIC_ACQUIRE 2 // WEBASSEMBLY-NEXT:#define __ATOMIC_ACQ_REL 4 // WEBASSEMBLY-NEXT:#define __ATOMIC_CONSUME 1 // WEBASSEMBLY-NEXT:#define __ATOMIC_RELAXED 0 // WEBASSEMBLY-NEXT:#define __ATOMIC_RELEASE 3 // WEBASSEMBLY-NEXT:#define __ATOMIC_SEQ_CST 5 // WEBASSEMBLY-NEXT:#define __BIGGEST_ALIGNMENT__ 16 // WEBASSEMBLY-NEXT:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // WEBASSEMBLY-NEXT:#define __CHAR16_TYPE__ unsigned short // WEBASSEMBLY-NEXT:#define __CHAR32_TYPE__ unsigned int // WEBASSEMBLY-NEXT:#define __CHAR_BIT__ 8 // WEBASSEMBLY-NOT:#define __CHAR_UNSIGNED__ // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_INT_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_LONG_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __CONSTANT_CFSTRINGS__ 1 // WEBASSEMBLY-NEXT:#define __DBL_DECIMAL_DIG__ 17 // WEBASSEMBLY-NEXT:#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // WEBASSEMBLY-NEXT:#define __DBL_DIG__ 15 // WEBASSEMBLY-NEXT:#define __DBL_EPSILON__ 2.2204460492503131e-16 // WEBASSEMBLY-NEXT:#define __DBL_HAS_DENORM__ 1 // WEBASSEMBLY-NEXT:#define __DBL_HAS_INFINITY__ 1 // WEBASSEMBLY-NEXT:#define __DBL_HAS_QUIET_NAN__ 1 // WEBASSEMBLY-NEXT:#define __DBL_MANT_DIG__ 53 // WEBASSEMBLY-NEXT:#define __DBL_MAX_10_EXP__ 308 // WEBASSEMBLY-NEXT:#define __DBL_MAX_EXP__ 1024 // WEBASSEMBLY-NEXT:#define __DBL_MAX__ 1.7976931348623157e+308 // WEBASSEMBLY-NEXT:#define __DBL_MIN_10_EXP__ (-307) // WEBASSEMBLY-NEXT:#define __DBL_MIN_EXP__ (-1021) // WEBASSEMBLY-NEXT:#define __DBL_MIN__ 2.2250738585072014e-308 // WEBASSEMBLY-NEXT:#define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // WEBASSEMBLY-NOT:#define __ELF__ // EMSCRIPTEN-THREADS-NEXT:#define __EMSCRIPTEN_PTHREADS__ 1 // EMSCRIPTEN-NEXT:#define __EMSCRIPTEN__ 1 // WEBASSEMBLY-NEXT:#define __FINITE_MATH_ONLY__ 0 // WEBASSEMBLY-NEXT:#define __FLOAT128__ 1 // WEBASSEMBLY-NOT:#define __FLT16_DECIMAL_DIG__ // WEBASSEMBLY-NOT:#define __FLT16_DENORM_MIN__ // WEBASSEMBLY-NOT:#define __FLT16_DIG__ // WEBASSEMBLY-NOT:#define __FLT16_EPSILON__ // WEBASSEMBLY-NOT:#define __FLT16_HAS_DENORM__ // WEBASSEMBLY-NOT:#define __FLT16_HAS_INFINITY__ // WEBASSEMBLY-NOT:#define __FLT16_HAS_QUIET_NAN__ // WEBASSEMBLY-NOT:#define __FLT16_MANT_DIG__ // WEBASSEMBLY-NOT:#define __FLT16_MAX_10_EXP__ // WEBASSEMBLY-NOT:#define __FLT16_MAX_EXP__ // WEBASSEMBLY-NOT:#define __FLT16_MAX__ // WEBASSEMBLY-NOT:#define __FLT16_MIN_10_EXP__ // WEBASSEMBLY-NOT:#define __FLT16_MIN_EXP__ // WEBASSEMBLY-NOT:#define __FLT16_MIN__ // WEBASSEMBLY-NEXT:#define __FLT_DECIMAL_DIG__ 9 // WEBASSEMBLY-NEXT:#define __FLT_DENORM_MIN__ 1.40129846e-45F // WEBASSEMBLY-NEXT:#define __FLT_DIG__ 6 // WEBASSEMBLY-NEXT:#define __FLT_EPSILON__ 1.19209290e-7F // WEBASSEMBLY-NEXT:#define __FLT_EVAL_METHOD__ 0 // WEBASSEMBLY-NEXT:#define __FLT_HAS_DENORM__ 1 // WEBASSEMBLY-NEXT:#define __FLT_HAS_INFINITY__ 1 // WEBASSEMBLY-NEXT:#define __FLT_HAS_QUIET_NAN__ 1 // WEBASSEMBLY-NEXT:#define __FLT_MANT_DIG__ 24 // WEBASSEMBLY-NEXT:#define __FLT_MAX_10_EXP__ 38 // WEBASSEMBLY-NEXT:#define __FLT_MAX_EXP__ 128 // WEBASSEMBLY-NEXT:#define __FLT_MAX__ 3.40282347e+38F // WEBASSEMBLY-NEXT:#define __FLT_MIN_10_EXP__ (-37) // WEBASSEMBLY-NEXT:#define __FLT_MIN_EXP__ (-125) // WEBASSEMBLY-NEXT:#define __FLT_MIN__ 1.17549435e-38F // WEBASSEMBLY-NEXT:#define __FLT_RADIX__ 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_BOOL_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_CHAR_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_INT_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_LLONG_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_LONG_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_POINTER_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2 // WEBASSEMBLY-NEXT:#define __GNUC_MINOR__ {{.*}} // WEBASSEMBLY-NEXT:#define __GNUC_PATCHLEVEL__ {{.*}} // WEBASSEMBLY-NEXT:#define __GNUC_STDC_INLINE__ 1 // WEBASSEMBLY-NEXT:#define __GNUC__ {{.*}} // WEBASSEMBLY-NEXT:#define __GXX_ABI_VERSION 1002 // WEBASSEMBLY32-NEXT:#define __ILP32__ 1 // WEBASSEMBLY64-NOT:#define __ILP32__ // WEBASSEMBLY-NEXT:#define __INT16_C_SUFFIX__ // WEBASSEMBLY-NEXT:#define __INT16_FMTd__ "hd" // WEBASSEMBLY-NEXT:#define __INT16_FMTi__ "hi" // WEBASSEMBLY-NEXT:#define __INT16_MAX__ 32767 // WEBASSEMBLY-NEXT:#define __INT16_TYPE__ short // WEBASSEMBLY-NEXT:#define __INT32_C_SUFFIX__ // WEBASSEMBLY-NEXT:#define __INT32_FMTd__ "d" // WEBASSEMBLY-NEXT:#define __INT32_FMTi__ "i" // WEBASSEMBLY-NEXT:#define __INT32_MAX__ 2147483647 // WEBASSEMBLY-NEXT:#define __INT32_TYPE__ int // WEBASSEMBLY-NEXT:#define __INT64_C_SUFFIX__ LL // WEBASSEMBLY-NEXT:#define __INT64_FMTd__ "lld" // WEBASSEMBLY-NEXT:#define __INT64_FMTi__ "lli" // WEBASSEMBLY-NEXT:#define __INT64_MAX__ 9223372036854775807LL // WEBASSEMBLY-NEXT:#define __INT64_TYPE__ long long int // WEBASSEMBLY-NEXT:#define __INT8_C_SUFFIX__ // WEBASSEMBLY-NEXT:#define __INT8_FMTd__ "hhd" // WEBASSEMBLY-NEXT:#define __INT8_FMTi__ "hhi" // WEBASSEMBLY-NEXT:#define __INT8_MAX__ 127 // WEBASSEMBLY-NEXT:#define __INT8_TYPE__ signed char // WEBASSEMBLY-NEXT:#define __INTMAX_C_SUFFIX__ LL // WEBASSEMBLY-NEXT:#define __INTMAX_FMTd__ "lld" // WEBASSEMBLY-NEXT:#define __INTMAX_FMTi__ "lli" // WEBASSEMBLY-NEXT:#define __INTMAX_MAX__ 9223372036854775807LL // WEBASSEMBLY-NEXT:#define __INTMAX_TYPE__ long long int // WEBASSEMBLY-NEXT:#define __INTMAX_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __INTPTR_FMTd__ "ld" // WEBASSEMBLY-NEXT:#define __INTPTR_FMTi__ "li" // WEBASSEMBLY32-NEXT:#define __INTPTR_MAX__ 2147483647L // WEBASSEMBLY64-NEXT:#define __INTPTR_MAX__ 9223372036854775807L // WEBASSEMBLY-NEXT:#define __INTPTR_TYPE__ long int // WEBASSEMBLY32-NEXT:#define __INTPTR_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __INTPTR_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __INT_FAST16_FMTd__ "hd" // WEBASSEMBLY-NEXT:#define __INT_FAST16_FMTi__ "hi" // WEBASSEMBLY-NEXT:#define __INT_FAST16_MAX__ 32767 // WEBASSEMBLY-NEXT:#define __INT_FAST16_TYPE__ short // WEBASSEMBLY-NEXT:#define __INT_FAST32_FMTd__ "d" // WEBASSEMBLY-NEXT:#define __INT_FAST32_FMTi__ "i" // WEBASSEMBLY-NEXT:#define __INT_FAST32_MAX__ 2147483647 // WEBASSEMBLY-NEXT:#define __INT_FAST32_TYPE__ int // WEBASSEMBLY-NEXT:#define __INT_FAST64_FMTd__ "lld" // WEBASSEMBLY-NEXT:#define __INT_FAST64_FMTi__ "lli" // WEBASSEMBLY-NEXT:#define __INT_FAST64_MAX__ 9223372036854775807LL // WEBASSEMBLY-NEXT:#define __INT_FAST64_TYPE__ long long int // WEBASSEMBLY-NEXT:#define __INT_FAST8_FMTd__ "hhd" // WEBASSEMBLY-NEXT:#define __INT_FAST8_FMTi__ "hhi" // WEBASSEMBLY-NEXT:#define __INT_FAST8_MAX__ 127 // WEBASSEMBLY-NEXT:#define __INT_FAST8_TYPE__ signed char // WEBASSEMBLY-NEXT:#define __INT_LEAST16_FMTd__ "hd" // WEBASSEMBLY-NEXT:#define __INT_LEAST16_FMTi__ "hi" // WEBASSEMBLY-NEXT:#define __INT_LEAST16_MAX__ 32767 // WEBASSEMBLY-NEXT:#define __INT_LEAST16_TYPE__ short // WEBASSEMBLY-NEXT:#define __INT_LEAST32_FMTd__ "d" // WEBASSEMBLY-NEXT:#define __INT_LEAST32_FMTi__ "i" // WEBASSEMBLY-NEXT:#define __INT_LEAST32_MAX__ 2147483647 // WEBASSEMBLY-NEXT:#define __INT_LEAST32_TYPE__ int // WEBASSEMBLY-NEXT:#define __INT_LEAST64_FMTd__ "lld" // WEBASSEMBLY-NEXT:#define __INT_LEAST64_FMTi__ "lli" // WEBASSEMBLY-NEXT:#define __INT_LEAST64_MAX__ 9223372036854775807LL // WEBASSEMBLY-NEXT:#define __INT_LEAST64_TYPE__ long long int // WEBASSEMBLY-NEXT:#define __INT_LEAST8_FMTd__ "hhd" // WEBASSEMBLY-NEXT:#define __INT_LEAST8_FMTi__ "hhi" // WEBASSEMBLY-NEXT:#define __INT_LEAST8_MAX__ 127 // WEBASSEMBLY-NEXT:#define __INT_LEAST8_TYPE__ signed char // WEBASSEMBLY-NEXT:#define __INT_MAX__ 2147483647 // WEBASSEMBLY-NEXT:#define __LDBL_DECIMAL_DIG__ 36 // WEBASSEMBLY-NEXT:#define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L // WEBASSEMBLY-NEXT:#define __LDBL_DIG__ 33 // WEBASSEMBLY-NEXT:#define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L // WEBASSEMBLY-NEXT:#define __LDBL_HAS_DENORM__ 1 // WEBASSEMBLY-NEXT:#define __LDBL_HAS_INFINITY__ 1 // WEBASSEMBLY-NEXT:#define __LDBL_HAS_QUIET_NAN__ 1 // WEBASSEMBLY-NEXT:#define __LDBL_MANT_DIG__ 113 // WEBASSEMBLY-NEXT:#define __LDBL_MAX_10_EXP__ 4932 // WEBASSEMBLY-NEXT:#define __LDBL_MAX_EXP__ 16384 // WEBASSEMBLY-NEXT:#define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L // WEBASSEMBLY-NEXT:#define __LDBL_MIN_10_EXP__ (-4931) // WEBASSEMBLY-NEXT:#define __LDBL_MIN_EXP__ (-16381) // WEBASSEMBLY-NEXT:#define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L // WEBASSEMBLY-NEXT:#define __LITTLE_ENDIAN__ 1 // WEBASSEMBLY-NEXT:#define __LONG_LONG_MAX__ 9223372036854775807LL // WEBASSEMBLY32-NEXT:#define __LONG_MAX__ 2147483647L // WEBASSEMBLY32-NOT:#define __LP64__ // WEBASSEMBLY64-NEXT:#define __LONG_MAX__ 9223372036854775807L // WEBASSEMBLY64-NEXT:#define __LP64__ 1 // WEBASSEMBLY-NEXT:#define __NO_INLINE__ 1 // WEBASSEMBLY-NEXT:#define __OBJC_BOOL_IS_BOOL 0 // WEBASSEMBLY-NEXT:#define __OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES 3 // WEBASSEMBLY-NEXT:#define __OPENCL_MEMORY_SCOPE_DEVICE 2 // WEBASSEMBLY-NEXT:#define __OPENCL_MEMORY_SCOPE_SUB_GROUP 4 // WEBASSEMBLY-NEXT:#define __OPENCL_MEMORY_SCOPE_WORK_GROUP 1 // WEBASSEMBLY-NEXT:#define __OPENCL_MEMORY_SCOPE_WORK_ITEM 0 // WEBASSEMBLY-NEXT:#define __ORDER_BIG_ENDIAN__ 4321 // WEBASSEMBLY-NEXT:#define __ORDER_LITTLE_ENDIAN__ 1234 // WEBASSEMBLY-NEXT:#define __ORDER_PDP_ENDIAN__ 3412 // WEBASSEMBLY32-NEXT:#define __POINTER_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __POINTER_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __PRAGMA_REDEFINE_EXTNAME 1 // WEBASSEMBLY-NEXT:#define __PTRDIFF_FMTd__ "ld" // WEBASSEMBLY-NEXT:#define __PTRDIFF_FMTi__ "li" // WEBASSEMBLY32-NEXT:#define __PTRDIFF_MAX__ 2147483647L // WEBASSEMBLY64-NEXT:#define __PTRDIFF_MAX__ 9223372036854775807L // WEBASSEMBLY-NEXT:#define __PTRDIFF_TYPE__ long int // WEBASSEMBLY32-NEXT:#define __PTRDIFF_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __PTRDIFF_WIDTH__ 64 // WEBASSEMBLY-NOT:#define __REGISTER_PREFIX__ // WEBASSEMBLY-NEXT:#define __SCHAR_MAX__ 127 // WEBASSEMBLY-NEXT:#define __SHRT_MAX__ 32767 // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_MAX__ 2147483647L // WEBASSEMBLY32-NEXT:#define __SIG_ATOMIC_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_MAX__ 9223372036854775807L // WEBASSEMBLY64-NEXT:#define __SIG_ATOMIC_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __SIZEOF_DOUBLE__ 8 // WEBASSEMBLY-NEXT:#define __SIZEOF_FLOAT__ 4 // WEBASSEMBLY-NEXT:#define __SIZEOF_INT128__ 16 // WEBASSEMBLY-NEXT:#define __SIZEOF_INT__ 4 // WEBASSEMBLY-NEXT:#define __SIZEOF_LONG_DOUBLE__ 16 // WEBASSEMBLY-NEXT:#define __SIZEOF_LONG_LONG__ 8 // WEBASSEMBLY32-NEXT:#define __SIZEOF_LONG__ 4 // WEBASSEMBLY32-NEXT:#define __SIZEOF_POINTER__ 4 // WEBASSEMBLY32-NEXT:#define __SIZEOF_PTRDIFF_T__ 4 // WEBASSEMBLY64-NEXT:#define __SIZEOF_LONG__ 8 // WEBASSEMBLY64-NEXT:#define __SIZEOF_POINTER__ 8 // WEBASSEMBLY64-NEXT:#define __SIZEOF_PTRDIFF_T__ 8 // WEBASSEMBLY-NEXT:#define __SIZEOF_SHORT__ 2 // WEBASSEMBLY32-NEXT:#define __SIZEOF_SIZE_T__ 4 // WEBASSEMBLY64-NEXT:#define __SIZEOF_SIZE_T__ 8 // WEBASSEMBLY-NEXT:#define __SIZEOF_WCHAR_T__ 4 // WEBASSEMBLY-NEXT:#define __SIZEOF_WINT_T__ 4 // WEBASSEMBLY-NEXT:#define __SIZE_FMTX__ "lX" // WEBASSEMBLY-NEXT:#define __SIZE_FMTo__ "lo" // WEBASSEMBLY-NEXT:#define __SIZE_FMTu__ "lu" // WEBASSEMBLY-NEXT:#define __SIZE_FMTx__ "lx" // WEBASSEMBLY32-NEXT:#define __SIZE_MAX__ 4294967295UL // WEBASSEMBLY64-NEXT:#define __SIZE_MAX__ 18446744073709551615UL // WEBASSEMBLY-NEXT:#define __SIZE_TYPE__ long unsigned int // WEBASSEMBLY32-NEXT:#define __SIZE_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __SIZE_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __STDC_HOSTED__ 0 // WEBASSEMBLY-NOT:#define __STDC_MB_MIGHT_NEQ_WC__ // WEBASSEMBLY-NOT:#define __STDC_NO_ATOMICS__ // WEBASSEMBLY-NOT:#define __STDC_NO_COMPLEX__ // WEBASSEMBLY-NOT:#define __STDC_NO_VLA__ // WEBASSEMBLY-NOT:#define __STDC_NO_THREADS__ // WEBASSEMBLY-NEXT:#define __STDC_UTF_16__ 1 // WEBASSEMBLY-NEXT:#define __STDC_UTF_32__ 1 // WEBASSEMBLY-NEXT:#define __STDC_VERSION__ 201710L // WEBASSEMBLY-NEXT:#define __STDC__ 1 // WEBASSEMBLY-NEXT:#define __UINT16_C_SUFFIX__ // WEBASSEMBLY-NEXT:#define __UINT16_FMTX__ "hX" // WEBASSEMBLY-NEXT:#define __UINT16_FMTo__ "ho" // WEBASSEMBLY-NEXT:#define __UINT16_FMTu__ "hu" // WEBASSEMBLY-NEXT:#define __UINT16_FMTx__ "hx" // WEBASSEMBLY-NEXT:#define __UINT16_MAX__ 65535 // WEBASSEMBLY-NEXT:#define __UINT16_TYPE__ unsigned short // WEBASSEMBLY-NEXT:#define __UINT32_C_SUFFIX__ U // WEBASSEMBLY-NEXT:#define __UINT32_FMTX__ "X" // WEBASSEMBLY-NEXT:#define __UINT32_FMTo__ "o" // WEBASSEMBLY-NEXT:#define __UINT32_FMTu__ "u" // WEBASSEMBLY-NEXT:#define __UINT32_FMTx__ "x" // WEBASSEMBLY-NEXT:#define __UINT32_MAX__ 4294967295U // WEBASSEMBLY-NEXT:#define __UINT32_TYPE__ unsigned int // WEBASSEMBLY-NEXT:#define __UINT64_C_SUFFIX__ ULL // WEBASSEMBLY-NEXT:#define __UINT64_FMTX__ "llX" // WEBASSEMBLY-NEXT:#define __UINT64_FMTo__ "llo" // WEBASSEMBLY-NEXT:#define __UINT64_FMTu__ "llu" // WEBASSEMBLY-NEXT:#define __UINT64_FMTx__ "llx" // WEBASSEMBLY-NEXT:#define __UINT64_MAX__ 18446744073709551615ULL // WEBASSEMBLY-NEXT:#define __UINT64_TYPE__ long long unsigned int // WEBASSEMBLY-NEXT:#define __UINT8_C_SUFFIX__ // WEBASSEMBLY-NEXT:#define __UINT8_FMTX__ "hhX" // WEBASSEMBLY-NEXT:#define __UINT8_FMTo__ "hho" // WEBASSEMBLY-NEXT:#define __UINT8_FMTu__ "hhu" // WEBASSEMBLY-NEXT:#define __UINT8_FMTx__ "hhx" // WEBASSEMBLY-NEXT:#define __UINT8_MAX__ 255 // WEBASSEMBLY-NEXT:#define __UINT8_TYPE__ unsigned char // WEBASSEMBLY-NEXT:#define __UINTMAX_C_SUFFIX__ ULL // WEBASSEMBLY-NEXT:#define __UINTMAX_FMTX__ "llX" // WEBASSEMBLY-NEXT:#define __UINTMAX_FMTo__ "llo" // WEBASSEMBLY-NEXT:#define __UINTMAX_FMTu__ "llu" // WEBASSEMBLY-NEXT:#define __UINTMAX_FMTx__ "llx" // WEBASSEMBLY-NEXT:#define __UINTMAX_MAX__ 18446744073709551615ULL // WEBASSEMBLY-NEXT:#define __UINTMAX_TYPE__ long long unsigned int // WEBASSEMBLY-NEXT:#define __UINTMAX_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __UINTPTR_FMTX__ "lX" // WEBASSEMBLY-NEXT:#define __UINTPTR_FMTo__ "lo" // WEBASSEMBLY-NEXT:#define __UINTPTR_FMTu__ "lu" // WEBASSEMBLY-NEXT:#define __UINTPTR_FMTx__ "lx" // WEBASSEMBLY32-NEXT:#define __UINTPTR_MAX__ 4294967295UL // WEBASSEMBLY64-NEXT:#define __UINTPTR_MAX__ 18446744073709551615UL // WEBASSEMBLY-NEXT:#define __UINTPTR_TYPE__ long unsigned int // WEBASSEMBLY32-NEXT:#define __UINTPTR_WIDTH__ 32 // WEBASSEMBLY64-NEXT:#define __UINTPTR_WIDTH__ 64 // WEBASSEMBLY-NEXT:#define __UINT_FAST16_FMTX__ "hX" // WEBASSEMBLY-NEXT:#define __UINT_FAST16_FMTo__ "ho" // WEBASSEMBLY-NEXT:#define __UINT_FAST16_FMTu__ "hu" // WEBASSEMBLY-NEXT:#define __UINT_FAST16_FMTx__ "hx" // WEBASSEMBLY-NEXT:#define __UINT_FAST16_MAX__ 65535 // WEBASSEMBLY-NEXT:#define __UINT_FAST16_TYPE__ unsigned short // WEBASSEMBLY-NEXT:#define __UINT_FAST32_FMTX__ "X" // WEBASSEMBLY-NEXT:#define __UINT_FAST32_FMTo__ "o" // WEBASSEMBLY-NEXT:#define __UINT_FAST32_FMTu__ "u" // WEBASSEMBLY-NEXT:#define __UINT_FAST32_FMTx__ "x" // WEBASSEMBLY-NEXT:#define __UINT_FAST32_MAX__ 4294967295U // WEBASSEMBLY-NEXT:#define __UINT_FAST32_TYPE__ unsigned int // WEBASSEMBLY-NEXT:#define __UINT_FAST64_FMTX__ "llX" // WEBASSEMBLY-NEXT:#define __UINT_FAST64_FMTo__ "llo" // WEBASSEMBLY-NEXT:#define __UINT_FAST64_FMTu__ "llu" // WEBASSEMBLY-NEXT:#define __UINT_FAST64_FMTx__ "llx" // WEBASSEMBLY-NEXT:#define __UINT_FAST64_MAX__ 18446744073709551615ULL // WEBASSEMBLY-NEXT:#define __UINT_FAST64_TYPE__ long long unsigned int // WEBASSEMBLY-NEXT:#define __UINT_FAST8_FMTX__ "hhX" // WEBASSEMBLY-NEXT:#define __UINT_FAST8_FMTo__ "hho" // WEBASSEMBLY-NEXT:#define __UINT_FAST8_FMTu__ "hhu" // WEBASSEMBLY-NEXT:#define __UINT_FAST8_FMTx__ "hhx" // WEBASSEMBLY-NEXT:#define __UINT_FAST8_MAX__ 255 // WEBASSEMBLY-NEXT:#define __UINT_FAST8_TYPE__ unsigned char // WEBASSEMBLY-NEXT:#define __UINT_LEAST16_FMTX__ "hX" // WEBASSEMBLY-NEXT:#define __UINT_LEAST16_FMTo__ "ho" // WEBASSEMBLY-NEXT:#define __UINT_LEAST16_FMTu__ "hu" // WEBASSEMBLY-NEXT:#define __UINT_LEAST16_FMTx__ "hx" // WEBASSEMBLY-NEXT:#define __UINT_LEAST16_MAX__ 65535 // WEBASSEMBLY-NEXT:#define __UINT_LEAST16_TYPE__ unsigned short // WEBASSEMBLY-NEXT:#define __UINT_LEAST32_FMTX__ "X" // WEBASSEMBLY-NEXT:#define __UINT_LEAST32_FMTo__ "o" // WEBASSEMBLY-NEXT:#define __UINT_LEAST32_FMTu__ "u" // WEBASSEMBLY-NEXT:#define __UINT_LEAST32_FMTx__ "x" // WEBASSEMBLY-NEXT:#define __UINT_LEAST32_MAX__ 4294967295U // WEBASSEMBLY-NEXT:#define __UINT_LEAST32_TYPE__ unsigned int // WEBASSEMBLY-NEXT:#define __UINT_LEAST64_FMTX__ "llX" // WEBASSEMBLY-NEXT:#define __UINT_LEAST64_FMTo__ "llo" // WEBASSEMBLY-NEXT:#define __UINT_LEAST64_FMTu__ "llu" // WEBASSEMBLY-NEXT:#define __UINT_LEAST64_FMTx__ "llx" // WEBASSEMBLY-NEXT:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL // WEBASSEMBLY-NEXT:#define __UINT_LEAST64_TYPE__ long long unsigned int // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_FMTX__ "hhX" // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_FMTo__ "hho" // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_FMTu__ "hhu" // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_FMTx__ "hhx" // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_MAX__ 255 // WEBASSEMBLY-NEXT:#define __UINT_LEAST8_TYPE__ unsigned char // WEBASSEMBLY-NEXT:#define __USER_LABEL_PREFIX__ // WEBASSEMBLY-NEXT:#define __VERSION__ "{{.*}}" // WEBASSEMBLY-NEXT:#define __WCHAR_MAX__ 2147483647 // WEBASSEMBLY-NEXT:#define __WCHAR_TYPE__ int // WEBASSEMBLY-NOT:#define __WCHAR_UNSIGNED__ // WEBASSEMBLY-NEXT:#define __WCHAR_WIDTH__ 32 // WEBASSEMBLY-NEXT:#define __WINT_MAX__ 2147483647 // WEBASSEMBLY-NEXT:#define __WINT_TYPE__ int // WEBASSEMBLY-NOT:#define __WINT_UNSIGNED__ // WEBASSEMBLY-NEXT:#define __WINT_WIDTH__ 32 // WEBASSEMBLY-NEXT:#define __clang__ 1 // WEBASSEMBLY-NEXT:#define __clang_literal_encoding__ {{.*}} // WEBASSEMBLY-NEXT:#define __clang_major__ {{.*}} // WEBASSEMBLY-NEXT:#define __clang_minor__ {{.*}} // WEBASSEMBLY-NEXT:#define __clang_patchlevel__ {{.*}} // WEBASSEMBLY-NEXT:#define __clang_version__ "{{.*}}" // WEBASSEMBLY-NEXT:#define __clang_wide_literal_encoding__ {{.*}} // WEBASSEMBLY-NEXT:#define __llvm__ 1 // WEBASSEMBLY-WASI-NOT:#define __unix // WEBASSEMBLY-WASI-NOT:#define __unix__ // EMSCRIPTEN-NEXT:#define __unix 1 // EMSCRIPTEN-NEXT:#define __unix__ 1 // WEBASSEMBLY-WASI-NEXT:#define __wasi__ 1 // WEBASSEMBLY-NOT:#define __wasm_simd128__ // WEBASSEMBLY-NOT:#define __wasm_simd256__ // WEBASSEMBLY-NOT:#define __wasm_simd512__ // WEBASSEMBLY-NEXT:#define __wasm 1 // WEBASSEMBLY32-NEXT:#define __wasm32 1 // WEBASSEMBLY64-NOT:#define __wasm32 // WEBASSEMBLY32-NEXT:#define __wasm32__ 1 // WEBASSEMBLY64-NOT:#define __wasm32__ // WEBASSEMBLY32-NOT:#define __wasm64__ // WEBASSEMBLY32-NOT:#define __wasm64 // WEBASSEMBLY64-NEXT:#define __wasm64 1 // WEBASSEMBLY64-NEXT:#define __wasm64__ 1 // WEBASSEMBLY-NEXT:#define __wasm__ 1 // EMSCRIPTEN:#define unix 1 // WEBASSEMBLY-WASI-NOT:#define unix 1 // WEBASSEMBLY-CXX-NOT:_REENTRANT // WEBASSEMBLY-CXX-NOT:__STDCPP_THREADS__ // WEBASSEMBLY-CXX-ATOMICS:#define _REENTRANT 1 // WEBASSEMBLY-CXX-ATOMICS:#define __STDCPP_THREADS__ 1 // RUN: %clang_cc1 -E -dM -ffreestanding -triple i686-windows-cygnus < /dev/null | FileCheck -match-full-lines -check-prefix CYGWIN-X32 %s // CYGWIN-X32: #define __USER_LABEL_PREFIX__ _ // RUN: %clang_cc1 -E -dM -ffreestanding -triple x86_64-windows-cygnus < /dev/null | FileCheck -match-full-lines -check-prefix CYGWIN-X64 %s // CYGWIN-X64: #define __USER_LABEL_PREFIX__ // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=avr \ // RUN: < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix=AVR %s // // AVR:#define __ATOMIC_ACQUIRE 2 // AVR:#define __ATOMIC_ACQ_REL 4 // AVR:#define __ATOMIC_CONSUME 1 // AVR:#define __ATOMIC_RELAXED 0 // AVR:#define __ATOMIC_RELEASE 3 // AVR:#define __ATOMIC_SEQ_CST 5 // AVR:#define __AVR__ 1 // AVR:#define __BIGGEST_ALIGNMENT__ 1 // AVR:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // AVR:#define __CHAR16_TYPE__ unsigned int // AVR:#define __CHAR32_TYPE__ long unsigned int // AVR:#define __CHAR_BIT__ 8 // AVR:#define __DBL_DECIMAL_DIG__ 9 // AVR:#define __DBL_DENORM_MIN__ 1.40129846e-45 // AVR:#define __DBL_DIG__ 6 // AVR:#define __DBL_EPSILON__ 1.19209290e-7 // AVR:#define __DBL_HAS_DENORM__ 1 // AVR:#define __DBL_HAS_INFINITY__ 1 // AVR:#define __DBL_HAS_QUIET_NAN__ 1 // AVR:#define __DBL_MANT_DIG__ 24 // AVR:#define __DBL_MAX_10_EXP__ 38 // AVR:#define __DBL_MAX_EXP__ 128 // AVR:#define __DBL_MAX__ 3.40282347e+38 // AVR:#define __DBL_MIN_10_EXP__ (-37) // AVR:#define __DBL_MIN_EXP__ (-125) // AVR:#define __DBL_MIN__ 1.17549435e-38 // AVR:#define __FINITE_MATH_ONLY__ 0 // AVR:#define __FLT_DECIMAL_DIG__ 9 // AVR:#define __FLT_DENORM_MIN__ 1.40129846e-45F // AVR:#define __FLT_DIG__ 6 // AVR:#define __FLT_EPSILON__ 1.19209290e-7F // AVR:#define __FLT_EVAL_METHOD__ 0 // AVR:#define __FLT_HAS_DENORM__ 1 // AVR:#define __FLT_HAS_INFINITY__ 1 // AVR:#define __FLT_HAS_QUIET_NAN__ 1 // AVR:#define __FLT_MANT_DIG__ 24 // AVR:#define __FLT_MAX_10_EXP__ 38 // AVR:#define __FLT_MAX_EXP__ 128 // AVR:#define __FLT_MAX__ 3.40282347e+38F // AVR:#define __FLT_MIN_10_EXP__ (-37) // AVR:#define __FLT_MIN_EXP__ (-125) // AVR:#define __FLT_MIN__ 1.17549435e-38F // AVR:#define __FLT_RADIX__ 2 // AVR:#define __GCC_ATOMIC_BOOL_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_CHAR_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_INT_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_LLONG_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_LONG_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_POINTER_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_SHORT_LOCK_FREE 1 // AVR:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 // AVR:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1 // AVR:#define __GXX_ABI_VERSION 1002 // AVR:#define __INT16_C_SUFFIX__ // AVR:#define __INT16_MAX__ 32767 // AVR:#define __INT16_TYPE__ int // AVR:#define __INT32_C_SUFFIX__ L // AVR:#define __INT32_MAX__ 2147483647L // AVR:#define __INT32_TYPE__ long int // AVR:#define __INT64_C_SUFFIX__ LL // AVR:#define __INT64_MAX__ 9223372036854775807LL // AVR:#define __INT64_TYPE__ long long int // AVR:#define __INT8_C_SUFFIX__ // AVR:#define __INT8_MAX__ 127 // AVR:#define __INT8_TYPE__ signed char // AVR:#define __INTMAX_C_SUFFIX__ LL // AVR:#define __INTMAX_MAX__ 9223372036854775807LL // AVR:#define __INTMAX_TYPE__ long long int // AVR:#define __INTPTR_MAX__ 32767 // AVR:#define __INTPTR_TYPE__ int // AVR:#define __INT_FAST16_MAX__ 32767 // AVR:#define __INT_FAST16_TYPE__ int // AVR:#define __INT_FAST32_MAX__ 2147483647L // AVR:#define __INT_FAST32_TYPE__ long int // AVR:#define __INT_FAST64_MAX__ 9223372036854775807LL // AVR:#define __INT_FAST64_TYPE__ long long int // AVR:#define __INT_FAST8_MAX__ 127 // AVR:#define __INT_FAST8_TYPE__ signed char // AVR:#define __INT_LEAST16_MAX__ 32767 // AVR:#define __INT_LEAST16_TYPE__ int // AVR:#define __INT_LEAST32_MAX__ 2147483647L // AVR:#define __INT_LEAST32_TYPE__ long int // AVR:#define __INT_LEAST64_MAX__ 9223372036854775807LL // AVR:#define __INT_LEAST64_TYPE__ long long int // AVR:#define __INT_LEAST8_MAX__ 127 // AVR:#define __INT_LEAST8_TYPE__ signed char // AVR:#define __INT_MAX__ 32767 // AVR:#define __LDBL_DECIMAL_DIG__ 9 // AVR:#define __LDBL_DENORM_MIN__ 1.40129846e-45L // AVR:#define __LDBL_DIG__ 6 // AVR:#define __LDBL_EPSILON__ 1.19209290e-7L // AVR:#define __LDBL_HAS_DENORM__ 1 // AVR:#define __LDBL_HAS_INFINITY__ 1 // AVR:#define __LDBL_HAS_QUIET_NAN__ 1 // AVR:#define __LDBL_MANT_DIG__ 24 // AVR:#define __LDBL_MAX_10_EXP__ 38 // AVR:#define __LDBL_MAX_EXP__ 128 // AVR:#define __LDBL_MAX__ 3.40282347e+38L // AVR:#define __LDBL_MIN_10_EXP__ (-37) // AVR:#define __LDBL_MIN_EXP__ (-125) // AVR:#define __LDBL_MIN__ 1.17549435e-38L // AVR:#define __LONG_LONG_MAX__ 9223372036854775807LL // AVR:#define __LONG_MAX__ 2147483647L // AVR:#define __NO_INLINE__ 1 // AVR:#define __ORDER_BIG_ENDIAN__ 4321 // AVR:#define __ORDER_LITTLE_ENDIAN__ 1234 // AVR:#define __ORDER_PDP_ENDIAN__ 3412 // AVR:#define __PRAGMA_REDEFINE_EXTNAME 1 // AVR:#define __PTRDIFF_MAX__ 32767 // AVR:#define __PTRDIFF_TYPE__ int // AVR:#define __SCHAR_MAX__ 127 // AVR:#define __SHRT_MAX__ 32767 // AVR:#define __SIG_ATOMIC_MAX__ 127 // AVR:#define __SIG_ATOMIC_WIDTH__ 8 // AVR:#define __SIZEOF_DOUBLE__ 4 // AVR:#define __SIZEOF_FLOAT__ 4 // AVR:#define __SIZEOF_INT__ 2 // AVR:#define __SIZEOF_LONG_DOUBLE__ 4 // AVR:#define __SIZEOF_LONG_LONG__ 8 // AVR:#define __SIZEOF_LONG__ 4 // AVR:#define __SIZEOF_POINTER__ 2 // AVR:#define __SIZEOF_PTRDIFF_T__ 2 // AVR:#define __SIZEOF_SHORT__ 2 // AVR:#define __SIZEOF_SIZE_T__ 2 // AVR:#define __SIZEOF_WCHAR_T__ 2 // AVR:#define __SIZEOF_WINT_T__ 2 // AVR:#define __SIZE_MAX__ 65535U // AVR:#define __SIZE_TYPE__ unsigned int // AVR:#define __STDC__ 1 // AVR:#define __UINT16_MAX__ 65535U // AVR:#define __UINT16_TYPE__ unsigned int // AVR:#define __UINT32_C_SUFFIX__ UL // AVR:#define __UINT32_MAX__ 4294967295UL // AVR:#define __UINT32_TYPE__ long unsigned int // AVR:#define __UINT64_C_SUFFIX__ ULL // AVR:#define __UINT64_MAX__ 18446744073709551615ULL // AVR:#define __UINT64_TYPE__ long long unsigned int // AVR:#define __UINT8_C_SUFFIX__ // AVR:#define __UINT8_MAX__ 255 // AVR:#define __UINT8_TYPE__ unsigned char // AVR:#define __UINTMAX_C_SUFFIX__ ULL // AVR:#define __UINTMAX_MAX__ 18446744073709551615ULL // AVR:#define __UINTMAX_TYPE__ long long unsigned int // AVR:#define __UINTPTR_MAX__ 65535U // AVR:#define __UINTPTR_TYPE__ unsigned int // AVR:#define __UINT_FAST16_MAX__ 65535U // AVR:#define __UINT_FAST16_TYPE__ unsigned int // AVR:#define __UINT_FAST32_MAX__ 4294967295UL // AVR:#define __UINT_FAST32_TYPE__ long unsigned int // AVR:#define __UINT_FAST64_MAX__ 18446744073709551615ULL // AVR:#define __UINT_FAST64_TYPE__ long long unsigned int // AVR:#define __UINT_FAST8_MAX__ 255 // AVR:#define __UINT_FAST8_TYPE__ unsigned char // AVR:#define __UINT_LEAST16_MAX__ 65535U // AVR:#define __UINT_LEAST16_TYPE__ unsigned int // AVR:#define __UINT_LEAST32_MAX__ 4294967295UL // AVR:#define __UINT_LEAST32_TYPE__ long unsigned int // AVR:#define __UINT_LEAST64_MAX__ 18446744073709551615ULL // AVR:#define __UINT_LEAST64_TYPE__ long long unsigned int // AVR:#define __UINT_LEAST8_MAX__ 255 // AVR:#define __UINT_LEAST8_TYPE__ unsigned char // AVR:#define __USER_LABEL_PREFIX__ // AVR:#define __WCHAR_MAX__ 32767 // AVR:#define __WCHAR_TYPE__ int // AVR:#define __WINT_TYPE__ int // RUN: %clang_cc1 -E -dM -ffreestanding \ // RUN: -triple i686-windows-msvc -fms-compatibility -x c++ < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix MSVC-X32 %s // RUN: %clang_cc1 -E -dM -ffreestanding \ // RUN: -triple x86_64-windows-msvc -fms-compatibility -x c++ < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix MSVC-X64 %s // MSVC-X32:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_INT_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_LONG_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2 // MSVC-X32-NOT:#define __GCC_ATOMIC{{.*}} // MSVC-X32:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U // MSVC-X64:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_CHAR32_T_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_CHAR_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_INT_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_LLONG_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_LONG_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2 // MSVC-X64-NOT:#define __GCC_ATOMIC{{.*}} // MSVC-X64:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16ULL // RUN: %clang_cc1 -E -dM -ffreestanding \ // RUN: -fgnuc-version=4.2.1 -triple=aarch64-apple-ios9 < /dev/null \ // RUN: | FileCheck -check-prefix=DARWIN %s // RUN: %clang_cc1 -E -dM -ffreestanding \ // RUN: -fgnuc-version=4.2.1 -triple=aarch64-apple-macosx10.12 < /dev/null \ // RUN: | FileCheck -check-prefix=DARWIN %s // DARWIN-NOT: OBJC_NEW_PROPERTIES // DARWIN:#define __STDC_NO_THREADS__ 1 // RUN: %clang_cc1 -triple i386-apple-macosx -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix MACOS-32 %s // RUN: %clang_cc1 -triple x86_64-apple-macosx -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix MACOS-64 %s // MACOS-32: #define __INTPTR_TYPE__ long int // MACOS-32: #define __PTRDIFF_TYPE__ int // MACOS-32: #define __SIZE_TYPE__ long unsigned int // MACOS-64: #define __INTPTR_TYPE__ long int // MACOS-64: #define __PTRDIFF_TYPE__ long int // MACOS-64: #define __SIZE_TYPE__ long unsigned int // RUN: %clang_cc1 -triple i386-apple-ios-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-32 %s // RUN: %clang_cc1 -triple armv7-apple-ios -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-32 %s // RUN: %clang_cc1 -triple x86_64-apple-ios-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-64 %s // RUN: %clang_cc1 -triple arm64-apple-ios -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix IOS-64 %s // IOS-32: #define __INTPTR_TYPE__ long int // IOS-32: #define __PTRDIFF_TYPE__ int // IOS-32: #define __SIZE_TYPE__ long unsigned int // IOS-64: #define __INTPTR_TYPE__ long int // IOS-64: #define __PTRDIFF_TYPE__ long int // IOS-64: #define __SIZE_TYPE__ long unsigned int // RUN: %clang_cc1 -triple i386-apple-tvos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-32 %s // RUN: %clang_cc1 -triple armv7-apple-tvos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-32 %s // RUN: %clang_cc1 -triple x86_64-apple-tvos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-64 %s // RUN: %clang_cc1 -triple arm64-apple-tvos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix TVOS-64 %s // TVOS-32: #define __INTPTR_TYPE__ long int // TVOS-32: #define __PTRDIFF_TYPE__ int // TVOS-32: #define __SIZE_TYPE__ long unsigned int // TVOS-64: #define __INTPTR_TYPE__ long int // TVOS-64: #define __PTRDIFF_TYPE__ long int // TVOS-64: #define __SIZE_TYPE__ long unsigned int // RUN: %clang_cc1 -triple i386-apple-watchos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-32 %s // RUN: %clang_cc1 -triple armv7k-apple-watchos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-64 %s // RUN: %clang_cc1 -triple x86_64-apple-watchos-simulator -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-64 %s // RUN: %clang_cc1 -triple arm64-apple-watchos -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix WATCHOS-64 %s // WATCHOS-32: #define __INTPTR_TYPE__ long int // WATCHOS-32: #define __PTRDIFF_TYPE__ int // WATCHOS-32: #define __SIZE_TYPE__ long unsigned int // WATCHOS-64: #define __INTPTR_TYPE__ long int // WATCHOS-64: #define __PTRDIFF_TYPE__ long int // WATCHOS-64: #define __SIZE_TYPE__ long unsigned int // RUN: %clang_cc1 -triple armv7-apple-none-macho -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-DARWIN-BAREMETAL-32 %s // RUN: %clang_cc1 -triple arm64-apple-none-macho -ffreestanding -dM -E /dev/null -o - | FileCheck -match-full-lines -check-prefix ARM-DARWIN-BAREMETAL-64 %s // ARM-DARWIN-BAREMETAL-32: #define __INTPTR_TYPE__ long int // ARM-DARWIN-BAREMETAL-32: #define __PTRDIFF_TYPE__ int // ARM-DARWIN-BAREMETAL-32: #define __SIZE_TYPE__ long unsigned int // ARM-DARWIN-BAREMETAL-64: #define __INTPTR_TYPE__ long int // ARM-DARWIN-BAREMETAL-64: #define __PTRDIFF_TYPE__ long int // ARM-DARWIN-BAREMETAL-64: #define __SIZE_TYPE__ long unsigned int // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv32 < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix=RISCV32 %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv32-unknown-linux < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=RISCV32,RISCV32-LINUX %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv32 \ // RUN: -fforce-enable-int128 < /dev/null | FileCheck -match-full-lines \ // RUN: -check-prefixes=RISCV32,RISCV32-INT128 %s // RISCV32: #define _ILP32 1 // RISCV32: #define __ATOMIC_ACQUIRE 2 // RISCV32: #define __ATOMIC_ACQ_REL 4 // RISCV32: #define __ATOMIC_CONSUME 1 // RISCV32: #define __ATOMIC_RELAXED 0 // RISCV32: #define __ATOMIC_RELEASE 3 // RISCV32: #define __ATOMIC_SEQ_CST 5 // RISCV32: #define __BIGGEST_ALIGNMENT__ 16 // RISCV32: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // RISCV32: #define __CHAR16_TYPE__ unsigned short // RISCV32: #define __CHAR32_TYPE__ unsigned int // RISCV32: #define __CHAR_BIT__ 8 // RISCV32: #define __DBL_DECIMAL_DIG__ 17 // RISCV32: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // RISCV32: #define __DBL_DIG__ 15 // RISCV32: #define __DBL_EPSILON__ 2.2204460492503131e-16 // RISCV32: #define __DBL_HAS_DENORM__ 1 // RISCV32: #define __DBL_HAS_INFINITY__ 1 // RISCV32: #define __DBL_HAS_QUIET_NAN__ 1 // RISCV32: #define __DBL_MANT_DIG__ 53 // RISCV32: #define __DBL_MAX_10_EXP__ 308 // RISCV32: #define __DBL_MAX_EXP__ 1024 // RISCV32: #define __DBL_MAX__ 1.7976931348623157e+308 // RISCV32: #define __DBL_MIN_10_EXP__ (-307) // RISCV32: #define __DBL_MIN_EXP__ (-1021) // RISCV32: #define __DBL_MIN__ 2.2250738585072014e-308 // RISCV32: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // RISCV32: #define __ELF__ 1 // RISCV32: #define __FINITE_MATH_ONLY__ 0 // RISCV32: #define __FLT_DECIMAL_DIG__ 9 // RISCV32: #define __FLT_DENORM_MIN__ 1.40129846e-45F // RISCV32: #define __FLT_DIG__ 6 // RISCV32: #define __FLT_EPSILON__ 1.19209290e-7F // RISCV32: #define __FLT_EVAL_METHOD__ 0 // RISCV32: #define __FLT_HAS_DENORM__ 1 // RISCV32: #define __FLT_HAS_INFINITY__ 1 // RISCV32: #define __FLT_HAS_QUIET_NAN__ 1 // RISCV32: #define __FLT_MANT_DIG__ 24 // RISCV32: #define __FLT_MAX_10_EXP__ 38 // RISCV32: #define __FLT_MAX_EXP__ 128 // RISCV32: #define __FLT_MAX__ 3.40282347e+38F // RISCV32: #define __FLT_MIN_10_EXP__ (-37) // RISCV32: #define __FLT_MIN_EXP__ (-125) // RISCV32: #define __FLT_MIN__ 1.17549435e-38F // RISCV32: #define __FLT_RADIX__ 2 // RISCV32: #define __GCC_ATOMIC_BOOL_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_CHAR_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_INT_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_LLONG_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_LONG_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_POINTER_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_SHORT_LOCK_FREE 1 // RISCV32: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 // RISCV32: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1 // RISCV32: #define __GNUC_MINOR__ {{.*}} // RISCV32: #define __GNUC_PATCHLEVEL__ {{.*}} // RISCV32: #define __GNUC_STDC_INLINE__ 1 // RISCV32: #define __GNUC__ {{.*}} // RISCV32: #define __GXX_ABI_VERSION {{.*}} // RISCV32: #define __ILP32__ 1 // RISCV32: #define __INT16_C_SUFFIX__ // RISCV32: #define __INT16_MAX__ 32767 // RISCV32: #define __INT16_TYPE__ short // RISCV32: #define __INT32_C_SUFFIX__ // RISCV32: #define __INT32_MAX__ 2147483647 // RISCV32: #define __INT32_TYPE__ int // RISCV32: #define __INT64_C_SUFFIX__ LL // RISCV32: #define __INT64_MAX__ 9223372036854775807LL // RISCV32: #define __INT64_TYPE__ long long int // RISCV32: #define __INT8_C_SUFFIX__ // RISCV32: #define __INT8_MAX__ 127 // RISCV32: #define __INT8_TYPE__ signed char // RISCV32: #define __INTMAX_C_SUFFIX__ LL // RISCV32: #define __INTMAX_MAX__ 9223372036854775807LL // RISCV32: #define __INTMAX_TYPE__ long long int // RISCV32: #define __INTMAX_WIDTH__ 64 // RISCV32: #define __INTPTR_MAX__ 2147483647 // RISCV32: #define __INTPTR_TYPE__ int // RISCV32: #define __INTPTR_WIDTH__ 32 // TODO: RISC-V GCC defines INT_FAST16 as int // RISCV32: #define __INT_FAST16_MAX__ 32767 // RISCV32: #define __INT_FAST16_TYPE__ short // RISCV32: #define __INT_FAST32_MAX__ 2147483647 // RISCV32: #define __INT_FAST32_TYPE__ int // RISCV32: #define __INT_FAST64_MAX__ 9223372036854775807LL // RISCV32: #define __INT_FAST64_TYPE__ long long int // TODO: RISC-V GCC defines INT_FAST8 as int // RISCV32: #define __INT_FAST8_MAX__ 127 // RISCV32: #define __INT_FAST8_TYPE__ signed char // RISCV32: #define __INT_LEAST16_MAX__ 32767 // RISCV32: #define __INT_LEAST16_TYPE__ short // RISCV32: #define __INT_LEAST32_MAX__ 2147483647 // RISCV32: #define __INT_LEAST32_TYPE__ int // RISCV32: #define __INT_LEAST64_MAX__ 9223372036854775807LL // RISCV32: #define __INT_LEAST64_TYPE__ long long int // RISCV32: #define __INT_LEAST8_MAX__ 127 // RISCV32: #define __INT_LEAST8_TYPE__ signed char // RISCV32: #define __INT_MAX__ 2147483647 // RISCV32: #define __LDBL_DECIMAL_DIG__ 36 // RISCV32: #define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L // RISCV32: #define __LDBL_DIG__ 33 // RISCV32: #define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L // RISCV32: #define __LDBL_HAS_DENORM__ 1 // RISCV32: #define __LDBL_HAS_INFINITY__ 1 // RISCV32: #define __LDBL_HAS_QUIET_NAN__ 1 // RISCV32: #define __LDBL_MANT_DIG__ 113 // RISCV32: #define __LDBL_MAX_10_EXP__ 4932 // RISCV32: #define __LDBL_MAX_EXP__ 16384 // RISCV32: #define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L // RISCV32: #define __LDBL_MIN_10_EXP__ (-4931) // RISCV32: #define __LDBL_MIN_EXP__ (-16381) // RISCV32: #define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L // RISCV32: #define __LITTLE_ENDIAN__ 1 // RISCV32: #define __LONG_LONG_MAX__ 9223372036854775807LL // RISCV32: #define __LONG_MAX__ 2147483647L // RISCV32: #define __NO_INLINE__ 1 // RISCV32: #define __POINTER_WIDTH__ 32 // RISCV32: #define __PRAGMA_REDEFINE_EXTNAME 1 // RISCV32: #define __PTRDIFF_MAX__ 2147483647 // RISCV32: #define __PTRDIFF_TYPE__ int // RISCV32: #define __PTRDIFF_WIDTH__ 32 // RISCV32: #define __SCHAR_MAX__ 127 // RISCV32: #define __SHRT_MAX__ 32767 // RISCV32: #define __SIG_ATOMIC_MAX__ 2147483647 // RISCV32: #define __SIG_ATOMIC_WIDTH__ 32 // RISCV32: #define __SIZEOF_DOUBLE__ 8 // RISCV32: #define __SIZEOF_FLOAT__ 4 // RISCV32-INT128: #define __SIZEOF_INT128__ 16 // RISCV32: #define __SIZEOF_INT__ 4 // RISCV32: #define __SIZEOF_LONG_DOUBLE__ 16 // RISCV32: #define __SIZEOF_LONG_LONG__ 8 // RISCV32: #define __SIZEOF_LONG__ 4 // RISCV32: #define __SIZEOF_POINTER__ 4 // RISCV32: #define __SIZEOF_PTRDIFF_T__ 4 // RISCV32: #define __SIZEOF_SHORT__ 2 // RISCV32: #define __SIZEOF_SIZE_T__ 4 // RISCV32: #define __SIZEOF_WCHAR_T__ 4 // RISCV32: #define __SIZEOF_WINT_T__ 4 // RISCV32: #define __SIZE_MAX__ 4294967295U // RISCV32: #define __SIZE_TYPE__ unsigned int // RISCV32: #define __SIZE_WIDTH__ 32 // RISCV32: #define __STDC_HOSTED__ 0 // RISCV32: #define __STDC_UTF_16__ 1 // RISCV32: #define __STDC_UTF_32__ 1 // RISCV32: #define __STDC_VERSION__ 201710L // RISCV32: #define __STDC__ 1 // RISCV32: #define __UINT16_C_SUFFIX__ // RISCV32: #define __UINT16_MAX__ 65535 // RISCV32: #define __UINT16_TYPE__ unsigned short // RISCV32: #define __UINT32_C_SUFFIX__ U // RISCV32: #define __UINT32_MAX__ 4294967295U // RISCV32: #define __UINT32_TYPE__ unsigned int // RISCV32: #define __UINT64_C_SUFFIX__ ULL // RISCV32: #define __UINT64_MAX__ 18446744073709551615ULL // RISCV32: #define __UINT64_TYPE__ long long unsigned int // RISCV32: #define __UINT8_C_SUFFIX__ // RISCV32: #define __UINT8_MAX__ 255 // RISCV32: #define __UINT8_TYPE__ unsigned char // RISCV32: #define __UINTMAX_C_SUFFIX__ ULL // RISCV32: #define __UINTMAX_MAX__ 18446744073709551615ULL // RISCV32: #define __UINTMAX_TYPE__ long long unsigned int // RISCV32: #define __UINTMAX_WIDTH__ 64 // RISCV32: #define __UINTPTR_MAX__ 4294967295U // RISCV32: #define __UINTPTR_TYPE__ unsigned int // RISCV32: #define __UINTPTR_WIDTH__ 32 // TODO: RISC-V GCC defines UINT_FAST16 to be unsigned int // RISCV32: #define __UINT_FAST16_MAX__ 65535 // RISCV32: #define __UINT_FAST16_TYPE__ unsigned short // RISCV32: #define __UINT_FAST32_MAX__ 4294967295U // RISCV32: #define __UINT_FAST32_TYPE__ unsigned int // RISCV32: #define __UINT_FAST64_MAX__ 18446744073709551615ULL // RISCV32: #define __UINT_FAST64_TYPE__ long long unsigned int // TODO: RISC-V GCC defines UINT_FAST8 to be unsigned int // RISCV32: #define __UINT_FAST8_MAX__ 255 // RISCV32: #define __UINT_FAST8_TYPE__ unsigned char // RISCV32: #define __UINT_LEAST16_MAX__ 65535 // RISCV32: #define __UINT_LEAST16_TYPE__ unsigned short // RISCV32: #define __UINT_LEAST32_MAX__ 4294967295U // RISCV32: #define __UINT_LEAST32_TYPE__ unsigned int // RISCV32: #define __UINT_LEAST64_MAX__ 18446744073709551615ULL // RISCV32: #define __UINT_LEAST64_TYPE__ long long unsigned int // RISCV32: #define __UINT_LEAST8_MAX__ 255 // RISCV32: #define __UINT_LEAST8_TYPE__ unsigned char // RISCV32: #define __USER_LABEL_PREFIX__ // RISCV32: #define __WCHAR_MAX__ 2147483647 // RISCV32: #define __WCHAR_TYPE__ int // RISCV32: #define __WCHAR_WIDTH__ 32 // RISCV32: #define __WINT_TYPE__ unsigned int // RISCV32: #define __WINT_UNSIGNED__ 1 // RISCV32: #define __WINT_WIDTH__ 32 // RISCV32-LINUX: #define __gnu_linux__ 1 // RISCV32-LINUX: #define __linux 1 // RISCV32-LINUX: #define __linux__ 1 // RISCV32: #define __riscv 1 // RISCV32: #define __riscv_cmodel_medlow 1 // RISCV32: #define __riscv_float_abi_soft 1 // RISCV32: #define __riscv_xlen 32 // RISCV32-LINUX: #define __unix 1 // RISCV32-LINUX: #define __unix__ 1 // RISCV32-LINUX: #define linux 1 // RISCV32-LINUX: #define unix 1 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv64 < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefix=RISCV64 %s // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=riscv64-unknown-linux < /dev/null \ // RUN: | FileCheck -match-full-lines -check-prefixes=RISCV64,RISCV64-LINUX %s // RISCV64: #define _LP64 1 // RISCV64: #define __ATOMIC_ACQUIRE 2 // RISCV64: #define __ATOMIC_ACQ_REL 4 // RISCV64: #define __ATOMIC_CONSUME 1 // RISCV64: #define __ATOMIC_RELAXED 0 // RISCV64: #define __ATOMIC_RELEASE 3 // RISCV64: #define __ATOMIC_SEQ_CST 5 // RISCV64: #define __BIGGEST_ALIGNMENT__ 16 // RISCV64: #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ // RISCV64: #define __CHAR16_TYPE__ unsigned short // RISCV64: #define __CHAR32_TYPE__ unsigned int // RISCV64: #define __CHAR_BIT__ 8 // RISCV64: #define __DBL_DECIMAL_DIG__ 17 // RISCV64: #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 // RISCV64: #define __DBL_DIG__ 15 // RISCV64: #define __DBL_EPSILON__ 2.2204460492503131e-16 // RISCV64: #define __DBL_HAS_DENORM__ 1 // RISCV64: #define __DBL_HAS_INFINITY__ 1 // RISCV64: #define __DBL_HAS_QUIET_NAN__ 1 // RISCV64: #define __DBL_MANT_DIG__ 53 // RISCV64: #define __DBL_MAX_10_EXP__ 308 // RISCV64: #define __DBL_MAX_EXP__ 1024 // RISCV64: #define __DBL_MAX__ 1.7976931348623157e+308 // RISCV64: #define __DBL_MIN_10_EXP__ (-307) // RISCV64: #define __DBL_MIN_EXP__ (-1021) // RISCV64: #define __DBL_MIN__ 2.2250738585072014e-308 // RISCV64: #define __DECIMAL_DIG__ __LDBL_DECIMAL_DIG__ // RISCV64: #define __ELF__ 1 // RISCV64: #define __FINITE_MATH_ONLY__ 0 // RISCV64: #define __FLT_DECIMAL_DIG__ 9 // RISCV64: #define __FLT_DENORM_MIN__ 1.40129846e-45F // RISCV64: #define __FLT_DIG__ 6 // RISCV64: #define __FLT_EPSILON__ 1.19209290e-7F // RISCV64: #define __FLT_EVAL_METHOD__ 0 // RISCV64: #define __FLT_HAS_DENORM__ 1 // RISCV64: #define __FLT_HAS_INFINITY__ 1 // RISCV64: #define __FLT_HAS_QUIET_NAN__ 1 // RISCV64: #define __FLT_MANT_DIG__ 24 // RISCV64: #define __FLT_MAX_10_EXP__ 38 // RISCV64: #define __FLT_MAX_EXP__ 128 // RISCV64: #define __FLT_MAX__ 3.40282347e+38F // RISCV64: #define __FLT_MIN_10_EXP__ (-37) // RISCV64: #define __FLT_MIN_EXP__ (-125) // RISCV64: #define __FLT_MIN__ 1.17549435e-38F // RISCV64: #define __FLT_RADIX__ 2 // RISCV64: #define __GCC_ATOMIC_BOOL_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_CHAR_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_INT_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_LLONG_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_LONG_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_POINTER_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_SHORT_LOCK_FREE 1 // RISCV64: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1 // RISCV64: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 1 // RISCV64: #define __GNUC_MINOR__ {{.*}} // RISCV64: #define __GNUC_PATCHLEVEL__ {{.*}} // RISCV64: #define __GNUC_STDC_INLINE__ 1 // RISCV64: #define __GNUC__ {{.*}} // RISCV64: #define __GXX_ABI_VERSION {{.*}} // RISCV64: #define __INT16_C_SUFFIX__ // RISCV64: #define __INT16_MAX__ 32767 // RISCV64: #define __INT16_TYPE__ short // RISCV64: #define __INT32_C_SUFFIX__ // RISCV64: #define __INT32_MAX__ 2147483647 // RISCV64: #define __INT32_TYPE__ int // RISCV64: #define __INT64_C_SUFFIX__ L // RISCV64: #define __INT64_MAX__ 9223372036854775807L // RISCV64: #define __INT64_TYPE__ long int // RISCV64: #define __INT8_C_SUFFIX__ // RISCV64: #define __INT8_MAX__ 127 // RISCV64: #define __INT8_TYPE__ signed char // RISCV64: #define __INTMAX_C_SUFFIX__ L // RISCV64: #define __INTMAX_MAX__ 9223372036854775807L // RISCV64: #define __INTMAX_TYPE__ long int // RISCV64: #define __INTMAX_WIDTH__ 64 // RISCV64: #define __INTPTR_MAX__ 9223372036854775807L // RISCV64: #define __INTPTR_TYPE__ long int // RISCV64: #define __INTPTR_WIDTH__ 64 // TODO: RISC-V GCC defines INT_FAST16 as int // RISCV64: #define __INT_FAST16_MAX__ 32767 // RISCV64: #define __INT_FAST16_TYPE__ short // RISCV64: #define __INT_FAST32_MAX__ 2147483647 // RISCV64: #define __INT_FAST32_TYPE__ int // RISCV64: #define __INT_FAST64_MAX__ 9223372036854775807L // RISCV64: #define __INT_FAST64_TYPE__ long int // TODO: RISC-V GCC defines INT_FAST8 as int // RISCV64: #define __INT_FAST8_MAX__ 127 // RISCV64: #define __INT_FAST8_TYPE__ signed char // RISCV64: #define __INT_LEAST16_MAX__ 32767 // RISCV64: #define __INT_LEAST16_TYPE__ short // RISCV64: #define __INT_LEAST32_MAX__ 2147483647 // RISCV64: #define __INT_LEAST32_TYPE__ int // RISCV64: #define __INT_LEAST64_MAX__ 9223372036854775807L // RISCV64: #define __INT_LEAST64_TYPE__ long int // RISCV64: #define __INT_LEAST8_MAX__ 127 // RISCV64: #define __INT_LEAST8_TYPE__ signed char // RISCV64: #define __INT_MAX__ 2147483647 // RISCV64: #define __LDBL_DECIMAL_DIG__ 36 // RISCV64: #define __LDBL_DENORM_MIN__ 6.47517511943802511092443895822764655e-4966L // RISCV64: #define __LDBL_DIG__ 33 // RISCV64: #define __LDBL_EPSILON__ 1.92592994438723585305597794258492732e-34L // RISCV64: #define __LDBL_HAS_DENORM__ 1 // RISCV64: #define __LDBL_HAS_INFINITY__ 1 // RISCV64: #define __LDBL_HAS_QUIET_NAN__ 1 // RISCV64: #define __LDBL_MANT_DIG__ 113 // RISCV64: #define __LDBL_MAX_10_EXP__ 4932 // RISCV64: #define __LDBL_MAX_EXP__ 16384 // RISCV64: #define __LDBL_MAX__ 1.18973149535723176508575932662800702e+4932L // RISCV64: #define __LDBL_MIN_10_EXP__ (-4931) // RISCV64: #define __LDBL_MIN_EXP__ (-16381) // RISCV64: #define __LDBL_MIN__ 3.36210314311209350626267781732175260e-4932L // RISCV64: #define __LITTLE_ENDIAN__ 1 // RISCV64: #define __LONG_LONG_MAX__ 9223372036854775807LL // RISCV64: #define __LONG_MAX__ 9223372036854775807L // RISCV64: #define __LP64__ 1 // RISCV64: #define __NO_INLINE__ 1 // RISCV64: #define __POINTER_WIDTH__ 64 // RISCV64: #define __PRAGMA_REDEFINE_EXTNAME 1 // RISCV64: #define __PTRDIFF_MAX__ 9223372036854775807L // RISCV64: #define __PTRDIFF_TYPE__ long int // RISCV64: #define __PTRDIFF_WIDTH__ 64 // RISCV64: #define __SCHAR_MAX__ 127 // RISCV64: #define __SHRT_MAX__ 32767 // RISCV64: #define __SIG_ATOMIC_MAX__ 2147483647 // RISCV64: #define __SIG_ATOMIC_WIDTH__ 32 // RISCV64: #define __SIZEOF_DOUBLE__ 8 // RISCV64: #define __SIZEOF_FLOAT__ 4 // RISCV64: #define __SIZEOF_INT__ 4 // RISCV64: #define __SIZEOF_LONG_DOUBLE__ 16 // RISCV64: #define __SIZEOF_LONG_LONG__ 8 // RISCV64: #define __SIZEOF_LONG__ 8 // RISCV64: #define __SIZEOF_POINTER__ 8 // RISCV64: #define __SIZEOF_PTRDIFF_T__ 8 // RISCV64: #define __SIZEOF_SHORT__ 2 // RISCV64: #define __SIZEOF_SIZE_T__ 8 // RISCV64: #define __SIZEOF_WCHAR_T__ 4 // RISCV64: #define __SIZEOF_WINT_T__ 4 // RISCV64: #define __SIZE_MAX__ 18446744073709551615UL // RISCV64: #define __SIZE_TYPE__ long unsigned int // RISCV64: #define __SIZE_WIDTH__ 64 // RISCV64: #define __STDC_HOSTED__ 0 // RISCV64: #define __STDC_UTF_16__ 1 // RISCV64: #define __STDC_UTF_32__ 1 // RISCV64: #define __STDC_VERSION__ 201710L // RISCV64: #define __STDC__ 1 // RISCV64: #define __UINT16_C_SUFFIX__ // RISCV64: #define __UINT16_MAX__ 65535 // RISCV64: #define __UINT16_TYPE__ unsigned short // RISCV64: #define __UINT32_C_SUFFIX__ U // RISCV64: #define __UINT32_MAX__ 4294967295U // RISCV64: #define __UINT32_TYPE__ unsigned int // RISCV64: #define __UINT64_C_SUFFIX__ UL // RISCV64: #define __UINT64_MAX__ 18446744073709551615UL // RISCV64: #define __UINT64_TYPE__ long unsigned int // RISCV64: #define __UINT8_C_SUFFIX__ // RISCV64: #define __UINT8_MAX__ 255 // RISCV64: #define __UINT8_TYPE__ unsigned char // RISCV64: #define __UINTMAX_C_SUFFIX__ UL // RISCV64: #define __UINTMAX_MAX__ 18446744073709551615UL // RISCV64: #define __UINTMAX_TYPE__ long unsigned int // RISCV64: #define __UINTMAX_WIDTH__ 64 // RISCV64: #define __UINTPTR_MAX__ 18446744073709551615UL // RISCV64: #define __UINTPTR_TYPE__ long unsigned int // RISCV64: #define __UINTPTR_WIDTH__ 64 // TODO: RISC-V GCC defines UINT_FAST16 to be unsigned int // RISCV64: #define __UINT_FAST16_MAX__ 65535 // RISCV64: #define __UINT_FAST16_TYPE__ unsigned short // RISCV64: #define __UINT_FAST32_MAX__ 4294967295U // RISCV64: #define __UINT_FAST32_TYPE__ unsigned int // RISCV64: #define __UINT_FAST64_MAX__ 18446744073709551615UL // RISCV64: #define __UINT_FAST64_TYPE__ long unsigned int // TODO: RISC-V GCC defines UINT_FAST8 to be unsigned int // RISCV64: #define __UINT_FAST8_MAX__ 255 // RISCV64: #define __UINT_FAST8_TYPE__ unsigned char // RISCV64: #define __UINT_LEAST16_MAX__ 65535 // RISCV64: #define __UINT_LEAST16_TYPE__ unsigned short // RISCV64: #define __UINT_LEAST32_MAX__ 4294967295U // RISCV64: #define __UINT_LEAST32_TYPE__ unsigned int // RISCV64: #define __UINT_LEAST64_MAX__ 18446744073709551615UL // RISCV64: #define __UINT_LEAST64_TYPE__ long unsigned int // RISCV64: #define __UINT_LEAST8_MAX__ 255 // RISCV64: #define __UINT_LEAST8_TYPE__ unsigned char // RISCV64: #define __USER_LABEL_PREFIX__ // RISCV64: #define __WCHAR_MAX__ 2147483647 // RISCV64: #define __WCHAR_TYPE__ int // RISCV64: #define __WCHAR_WIDTH__ 32 // RISCV64: #define __WINT_TYPE__ unsigned int // RISCV64: #define __WINT_UNSIGNED__ 1 // RISCV64: #define __WINT_WIDTH__ 32 // RISCV64-LINUX: #define __gnu_linux__ 1 // RISCV64-LINUX: #define __linux 1 // RISCV64-LINUX: #define __linux__ 1 // RISCV64: #define __riscv 1 // RISCV64: #define __riscv_cmodel_medlow 1 // RISCV64: #define __riscv_float_abi_soft 1 // RISCV64: #define __riscv_xlen 64 // RISCV64-LINUX: #define __unix 1 // RISCV64-LINUX: #define __unix__ 1 // RISCV64-LINUX: #define linux 1 // RISCV64-LINUX: #define unix 1
the_stack_data/248579536.c
// This file is the source code for 4 binaries. // It comes from one of the comments of bug libabigail/19173. // To compile the first two binaries, please do: // gcc test35-pr19173-libfoo-long.c -shared -fpic -o test35-pr19173-libfoo-long-gcc.so -g // gcc test35-pr19173-libfoo-long.c -shared -fpic -o test35-pr19173-libfoo-long-gcc2.so -g -DLONG // // To compile the next two binaries, please do: // clang test35-pr19173-libfoo-long.c -shared -fpic -o test35-pr19173-libfoo-long-clang.so -g // clang test35-pr19173-libfoo-long.c -shared -fpic -o test35-pr19173-libfoo-long-clang2.so -g -DLONG #ifdef LONG char buggy_symbol[10]; #else char buggy_symbol[5]; #endif
the_stack_data/176706933.c
#include <stdio.h> int main(void) { char first[10]; char last[10]; printf("Enter your name: "); scanf("%s %s", first, last); printf("Hi, %s %s!\n", last, first); return 0; }
the_stack_data/110670.c
#include <stdio.h> #include <assert.h> int mainQ(int A, int B){ assert(A > 0 && B > 0); int q = 0; int r = A; int b = B; while(1){ //%%%traces: int A, int B, int q, int b, int r if (!(r>=b)) break; b=2*b; } while(1){ //assert(A == q*b + r && r >= 0); //%%%traces: int A, int B, int q, int b, int r if (!(b!=B)) break; q = 2*q; b = b/2; if (r >= b) { q = q + 1; r = r - b; } } return q; } int main(int argc, char **argv){ mainQ(atoi(argv[1]), atoi(argv[2])); return 0; }
the_stack_data/137136.c
/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2. * * 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. * * Test that the function: * int mlockall(int) * is declared. * * @pt:ML */ #include <sys/mman.h> typedef int (*mlockall_test)(int); int dummyfcn (void) { mlockall_test dummyvar; dummyvar = mlockall; return 0; }
the_stack_data/215767832.c
#include <stdlib.h> #include <stdio.h> int main(){ printf("Hello\n"); //cosas varias //cosas }
the_stack_data/103264614.c
#include <stdio.h> #include <string.h> typedef struct statu { int n, s; } statu; int magic; statu dp[209][209]; int vis[209][209]; int A[209]; int min(int a, int b); int max(int a, int b); void dfs(int l, int r, statu *ret, int (*cmp)(int a, int b)); int main(void) { statu rcv; int ans, i, N; #ifdef DEBUG freopen("in", "r", stdin); #endif scanf("%d", &N); for (i = 0; i < N; ++i) scanf("%d", A + i); for (i = 0; i < N; ++i) A[i + N] = A[i]; magic = 10000000, ans = magic; memset(vis, 0, sizeof(vis)); for (i = 0; i < N; ++i) { dfs(i, i + N - 1, &rcv, min); ans = min(rcv.s, ans); } printf("%d\n", ans); magic = 0, ans = magic; memset(vis, 0, sizeof(vis)); for (i = 0; i < N; ++i) { dfs(i, i + N - 1, &rcv, max); ans = max(rcv.s, ans); } printf("%d\n", ans); return 0; } void dfs(int l, int r, statu *ret, int (*cmp)(int a, int b)) { int i; statu rcv1, rcv2; if (l == r) { ret->n = A[l], ret->s = 0; } else if (vis[l][r]) { *ret = dp[l][r]; } else { ret->n = 0, ret->s = magic; for (i = l; i < r; ++i) { dfs(l, i, &rcv1, cmp); dfs(i + 1, r, &rcv2, cmp); ret->s = cmp(ret->s, rcv1.s + rcv2.s); } ret->n = rcv1.n + rcv2.n; ret->s += ret->n; dp[l][r] = *ret, vis[l][r] = 1; } } int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; }
the_stack_data/70983.c
/** ****************************************************************************** * @file stm32l4xx_ll_i2c.c * @author MCD Application Team * @version V1.7.0 * @date 17-February-2017 * @brief I2C LL module driver. ****************************************************************************** * @attention * * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2> * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics 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. * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32l4xx_ll_i2c.h" #include "stm32l4xx_ll_bus.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32L4xx_LL_Driver * @{ */ #if defined (I2C1) || defined (I2C2) || defined (I2C3) || defined (I2C4) /** @defgroup I2C_LL I2C * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ /** @addtogroup I2C_LL_Private_Macros * @{ */ #define IS_LL_I2C_PERIPHERAL_MODE(__VALUE__) (((__VALUE__) == LL_I2C_MODE_I2C) || \ ((__VALUE__) == LL_I2C_MODE_SMBUS_HOST) || \ ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE) || \ ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE_ARP)) #define IS_LL_I2C_ANALOG_FILTER(__VALUE__) (((__VALUE__) == LL_I2C_ANALOGFILTER_ENABLE) || \ ((__VALUE__) == LL_I2C_ANALOGFILTER_DISABLE)) #define IS_LL_I2C_DIGITAL_FILTER(__VALUE__) ((__VALUE__) <= 0x0000000FU) #define IS_LL_I2C_OWN_ADDRESS1(__VALUE__) ((__VALUE__) <= 0x000003FFU) #define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__) (((__VALUE__) == LL_I2C_ACK) || \ ((__VALUE__) == LL_I2C_NACK)) #define IS_LL_I2C_OWN_ADDRSIZE(__VALUE__) (((__VALUE__) == LL_I2C_OWNADDRESS1_7BIT) || \ ((__VALUE__) == LL_I2C_OWNADDRESS1_10BIT)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup I2C_LL_Exported_Functions * @{ */ /** @addtogroup I2C_LL_EF_Init * @{ */ /** * @brief De-initialize the I2C registers to their default reset values. * @param I2Cx I2C Instance. * @retval An ErrorStatus enumeration value: * - SUCCESS: I2C registers are de-initialized * - ERROR: I2C registers are not de-initialized */ uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx) { ErrorStatus status = SUCCESS; /* Check the I2C Instance I2Cx */ assert_param(IS_I2C_ALL_INSTANCE(I2Cx)); if (I2Cx == I2C1) { /* Force reset of I2C clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1); /* Release reset of I2C clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1); } #if defined(I2C2) else if (I2Cx == I2C2) { /* Force reset of I2C clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2); /* Release reset of I2C clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2); } #endif else if (I2Cx == I2C3) { /* Force reset of I2C clock */ LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C3); /* Release reset of I2C clock */ LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C3); } #if defined(I2C4) else if (I2Cx == I2C4) { /* Force reset of I2C clock */ LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_I2C4); /* Release reset of I2C clock */ LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_I2C4); } #endif else { status = ERROR; } return status; } /** * @brief Initialize the I2C registers according to the specified parameters in I2C_InitStruct. * @param I2Cx I2C Instance. * @param I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure. * @retval An ErrorStatus enumeration value: * - SUCCESS: I2C registers are initialized * - ERROR: Not applicable */ uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct) { /* Check the I2C Instance I2Cx */ assert_param(IS_I2C_ALL_INSTANCE(I2Cx)); /* Check the I2C parameters from I2C_InitStruct */ assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode)); assert_param(IS_LL_I2C_ANALOG_FILTER(I2C_InitStruct->AnalogFilter)); assert_param(IS_LL_I2C_DIGITAL_FILTER(I2C_InitStruct->DigitalFilter)); assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1)); assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge)); assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize)); /* Disable the selected I2Cx Peripheral */ LL_I2C_Disable(I2Cx); /*---------------------------- I2Cx CR1 Configuration ------------------------ * Configure the analog and digital noise filters with parameters : * - AnalogFilter: I2C_CR1_ANFOFF bit * - DigitalFilter: I2C_CR1_DNF[3:0] bits */ LL_I2C_ConfigFilters(I2Cx, I2C_InitStruct->AnalogFilter, I2C_InitStruct->DigitalFilter); /*---------------------------- I2Cx TIMINGR Configuration -------------------- * Configure the SDA setup, hold time and the SCL high, low period with parameter : * - Timing: I2C_TIMINGR_PRESC[3:0], I2C_TIMINGR_SCLDEL[3:0], I2C_TIMINGR_SDADEL[3:0], * I2C_TIMINGR_SCLH[7:0] and I2C_TIMINGR_SCLL[7:0] bits */ LL_I2C_SetTiming(I2Cx, I2C_InitStruct->Timing); /* Enable the selected I2Cx Peripheral */ LL_I2C_Enable(I2Cx); /*---------------------------- I2Cx OAR1 Configuration ----------------------- * Disable, Configure and Enable I2Cx device own address 1 with parameters : * - OwnAddress1: I2C_OAR1_OA1[9:0] bits * - OwnAddrSize: I2C_OAR1_OA1MODE bit */ LL_I2C_DisableOwnAddress1(I2Cx); LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize); /* OwnAdress1 == 0 is reserved for General Call address */ if (I2C_InitStruct->OwnAddress1 != 0U) LL_I2C_EnableOwnAddress1(I2Cx); /*---------------------------- I2Cx MODE Configuration ----------------------- * Configure I2Cx peripheral mode with parameter : * - PeripheralMode: I2C_CR1_SMBDEN and I2C_CR1_SMBHEN bits */ LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode); /*---------------------------- I2Cx CR2 Configuration ------------------------ * Configure the ACKnowledge or Non ACKnowledge condition * after the address receive match code or next received byte with parameter : * - TypeAcknowledge: I2C_CR2_NACK bit */ LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge); return SUCCESS; } /** * @brief Set each @ref LL_I2C_InitTypeDef field to default value. * @param I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure. * @retval None */ void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct) { /* Set I2C_InitStruct fields to default values */ I2C_InitStruct->PeripheralMode = LL_I2C_MODE_I2C; I2C_InitStruct->Timing = 0U; I2C_InitStruct->AnalogFilter = LL_I2C_ANALOGFILTER_ENABLE; I2C_InitStruct->DigitalFilter = 0U; I2C_InitStruct->OwnAddress1 = 0U; I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK; I2C_InitStruct->OwnAddrSize = LL_I2C_OWNADDRESS1_7BIT; } /** * @} */ /** * @} */ /** * @} */ #endif /* I2C1 || I2C2 || I2C3 || I2C4 */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/247017638.c
#include <stdio.h> int main(int argc, char const *argv[]) { int a, b, c, d; scanf("%d %d", &a, &b); d = a; while(a > 0) { scanf("%d", &c); if (a == d) { d = c + b; } b += c; d > b ? (d = b) : (d = d); a--; } printf("%d", d); return 0; }
the_stack_data/19049.c
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> int main(int argc, char *argv[]) { pid_t *pids,t; int nchilds,i; if (argc!=2 || (nchilds=atoi(argv[1]))<0) { fprintf(stderr,"Usage:\n\t%s <nchild>\n",argv[0]); exit(1); } if (!(pids=malloc(nchilds*sizeof(pid_t)))) { perror("malloc"); exit(1); } for (i=0; i<nchilds; i++) { t=fork(); if (t<0) { perror("fork"); exit(1); } else if (t==0) { int sl; srand(getpid()); sl=((double)rand()/RAND_MAX)*5; sleep(sl); exit(sl); } else { pids[i]=t; } } i=0; do { int t,status; printf("now waiting for ANY child\n"); if ((t=waitpid(-1,&status,0))<0) { perror("waitpid"); } printf ("Child:%d returned %d\n",t,WEXITSTATUS(status)); i+=1; } while (i<nchilds); }
the_stack_data/82949067.c
/* Example for Section 1.2.1, , chapitre affectation d'un pointeur de * la valeur retrounée par une fonction interprocedural. */ #include<stdlib.h> typedef int * pointer; pointer pointer_assign01(pointer fp) { return fp; } int main(void) { int i = 1; pointer p1 = &i, p2; p2 = pointer_assign01(p1); return; }
the_stack_data/31719.c
#include<stdio.h> #include<sys/wait.h> #include<pthread.h> #include<unistd.h> #define N 5 void *producer(void *param); void *consumer(void *param); int buf[N]; int in=0,out=0,counter=0; int flag[]={0,0}; int turn=0; void lock(int self) { // Set flag[self] = 1 saying you want to acquire lock flag[self] = 1; // But, first give the other thread the chance to // acquire lock turn = 1-self; // Wait until the other thread looses the desire // to acquire lock or it is your turn to get the lock. while (flag[1-self]==1 && turn==1-self) ; } // Executed after leaving critical section void unlock(int self) { // You do not desire to acquire lock in future. // This will allow the other thread to acquire // the lock. flag[self] = 0; } int main() { pthread_t tid[2]; pthread_create(&tid[0],NULL,producer,NULL); pthread_create(&tid[1],NULL,consumer,NULL); pthread_join(tid[0],NULL); pthread_join(tid[1],NULL); return 0; } void *producer(void *param) { int data=3,i=0; while(i<10) { while(counter==N) ; lock(0); buf[in]=data; printf("producing index %d\n",in); in=(in+1)%N; ++i; counter++; unlock(0); } pthread_exit(0); } void *consumer(void *param) { int data,i=0; while(i<10) { while(counter==0); lock(1); data=buf[out]; printf("consuming index %d\n",out); out=(out+1)%N; ++i; counter--; unlock(1); //sleep(1); } pthread_exit(0); }
the_stack_data/398634.c
/* { dg-do compile } */ /* { dg-options "-O2 -frounding-math" } */ double foo_d (double a, double b) { /* { dg-final { scan-assembler "fnmul\\td\[0-9\]+, d\[0-9\]+, d\[0-9\]+" } } */ return -(a * b); } float foo_s (float a, float b) { /* { dg-final { scan-assembler "fnmul\\ts\[0-9\]+, s\[0-9\]+, s\[0-9\]+" } } */ return -(a * b); }
the_stack_data/215768824.c
#include<stdio.h> struct fish { char *name; char *species; int teeth; int age; }; struct fish snappy = {"snappy","pirahna",69,4}; void catlog (struct fish f) { printf("%s is a %s with %i teeth. He is %i. \n",f.name,f.species,f.teeth,f.age); } void label (struct fish f) { printf("Name: %s.\nSpecies: %s.\nTeeth: %i. \nAge: %i. \n",f.name,f.species,f.teeth,f.age); } int main() { catlog(snappy); label(snappy); return 0; }
the_stack_data/138120.c
#include "stdio.h" int main(){ char a,b; scanf("%c %c",&a,&b); if (a<=b) { for (char i = a; i <= b; i++) { printf("%c ",i); } } else if (a>b) { for (char i = a; i <= 'Z'; i++) { printf("%c ",i); } for (char i = 'A'; i <= b; i++) { printf("%c ",i); } } }
the_stack_data/95451128.c
int f(int n) { int i = 1; int x = 1; while (i <= n) { x = x * 1; i++; } i = 0; while (i <= n) { x = x + i; i++; } i = 1; while (i <= n) { x = x * 2; i++; } return x; }
the_stack_data/30491.c
/*** * This code is a part of EvoApproxLib library (ehw.fit.vutbr.cz/approxlib) distributed under The MIT License. * When used, please cite the following article(s): V. Mrazek, L. Sekanina, Z. Vasicek "Libraries of Approximate Circuits: Automated Design and Application in CNN Accelerators" IEEE Journal on Emerging and Selected Topics in Circuits and Systems, Vol 10, No 4, 2020 * This file contains a circuit from a sub-set of pareto optimal circuits with respect to the pwr and wce parameters ***/ // MAE% = 1.17 % // MAE = 12 // WCE% = 3.81 % // WCE = 39 // WCRE% = 100.00 % // EP% = 71.29 % // MRE% = 15.38 % // MSE = 296 // PDK45_PWR = 0.010 mW // PDK45_AREA = 55.8 um2 // PDK45_DELAY = 0.21 ns #include <stdint.h> #include <stdlib.h> uint64_t mul8x2u_11V(const uint64_t A,const uint64_t B) { uint64_t dout_11, dout_12, dout_14, dout_17, dout_19, dout_20, dout_22, dout_25, dout_26, dout_27, dout_28, dout_39, dout_44, dout_51, dout_53, dout_55, dout_56, dout_57, dout_58, dout_59; uint64_t O; dout_11=((A >> 6)&1)&((B >> 0)&1); dout_12=((A >> 4)&1)&((B >> 0)&1); dout_14=((B >> 0)&1)&((A >> 3)&1); dout_17=((A >> 7)&1)&((B >> 0)&1); dout_19=((A >> 5)&1)&((B >> 1)&1); dout_20=((B >> 1)&1)&((A >> 6)&1); dout_22=((A >> 4)&1)&((B >> 1)&1); dout_25=dout_19&((B >> 0)&1); dout_26=((A >> 6)&1)|((A >> 7)&1); dout_27=dout_17&dout_20; dout_28=dout_11^dout_19; dout_39=((B >> 1)&1)&((A >> 7)&1); dout_44=((B >> 0)&1)&dout_25; dout_51=dout_28^dout_44; dout_53=dout_17^dout_20; dout_55=dout_26&dout_25; dout_56=dout_53^dout_44; dout_57=dout_27|dout_55; dout_58=dout_57&dout_39; dout_59=dout_57^dout_39; O = 0; O |= (dout_12&1) << 0; O |= (dout_56&1) << 1; O |= (dout_12&1) << 2; O |= (dout_14&1) << 3; O |= (dout_12&1) << 4; O |= (dout_22&1) << 5; O |= (dout_51&1) << 6; O |= (dout_56&1) << 7; O |= (dout_59&1) << 8; O |= (dout_58&1) << 9; return O; }
the_stack_data/192332000.c
// Verify that we return j=0 int main() { int i = 0, j=-1; int *p; p=&i; j = ((*p=0)?0:1); return j; }
the_stack_data/211080941.c
#include <stdio.h> #include <stdlib.h> int main (int argc, char *argv[]) { printf("\nCMake is love. CMake is life.\n\n"); return EXIT_SUCCESS; }
the_stack_data/145453141.c
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int primos_vizinhos(int n, int x) { if (x == -1) { for (int i = n - 2; i > 1; i -= 2) { if (check_primo(i)) { return i; } } } if (x == 1) { for (int i = n + 2; i > 1; i += 2) { if (check_primo(i)) { return i; } } } } int check_primo_zeca(int n) { int n_p1 = primos_vizinhos(n, 1), n_n1 = primos_vizinhos(n, -1); if ((n_p1 + n_n1)/2 == n) { return 1; } else { return 0; } } int check_primo(int n) { if (n == 2) { return 1; } else if (n % 2 == 0) { return 0; } for (int i = 3; i <= sqrt(n); i += 2) { if (n % i == 0) { return 0; } } return 1; } int main() { int li, lf, q = 0; scanf("%d %d", &li, &lf); for (int i = li; i <= lf; i++) { if (i >= 5) { if (check_primo(i)) { if (check_primo_zeca(i)) { q++; } } } } printf("%d", q); return 0; }
the_stack_data/148578733.c
#include <stdlib.h> #include <unistd.h> #include <stdio.h> #include <string.h> #if defined (READLINE_LIBRARY) # include "readline.h" # include "history.h" #else # include <readline/readline.h> # include <readline/history.h> #endif int main (int c, char **v) { char *input; for (;;) { input = readline ((char *)NULL); if (input == 0) break; printf ("%s\n", input); if (strcmp (input, "exit") == 0) break; free (input); } exit (0); }
the_stack_data/190768430.c
#include <stdlib.h> #include <stdio.h> void another() { printf("Another lib.\n"); }
the_stack_data/1211212.c
// RUN: %clang -target i686-pc-win32 -loldnames -lkernel32.lib -luser32.lib -### %s 2>&1 | FileCheck %s // CHECK-NOT: "-loldnames.lib" // CHECK-NOT: "-lkernel32.lib" // CHECK-NOT: "-luser32.lib" // CHECK: "oldnames.lib" // CHECK: "kernel32.lib" // CHECK: "user32.lib"
the_stack_data/1076706.c
float isi1(float x, int y) { if (y==0){ return 1;} else if (y>0) { return isi1(x,-y);} else { return isi1(x, y+1)/x;} }
the_stack_data/340578.c
/* * untgz.c -- Display contents and extract files from a gzip'd TAR file * * written by Pedro A. Aranda Gutierrez <[email protected]> * adaptation to Unix by Jean-loup Gailly <[email protected]> * various fixes by Cosmin Truta <[email protected]> */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <errno.h> #include "zlib.h" #ifdef unix # include <unistd.h> #else # include <direct.h> # include <io.h> #endif #ifdef WIN32 #include <windows.h> # ifndef F_OK # define F_OK 0 # endif # define mkdir(dirname,mode) _mkdir(dirname) # ifdef _MSC_VER # define access(path,mode) _access(path,mode) # define chmod(path,mode) _chmod(path,mode) # define strdup(str) _strdup(str) # endif #else # include <utime.h> #endif /* values used in typeflag field */ #define REGTYPE '0' /* regular file */ #define AREGTYPE '\0' /* regular file */ #define LNKTYPE '1' /* link */ #define SYMTYPE '2' /* reserved */ #define CHRTYPE '3' /* character special */ #define BLKTYPE '4' /* block special */ #define DIRTYPE '5' /* directory */ #define FIFOTYPE '6' /* FIFO special */ #define CONTTYPE '7' /* reserved */ /* GNU tar extensions */ #define GNUTYPE_DUMPDIR 'D' /* file names from dumped directory */ #define GNUTYPE_LONGLINK 'K' /* long link name */ #define GNUTYPE_LONGNAME 'L' /* long file name */ #define GNUTYPE_MULTIVOL 'M' /* continuation of file from another volume */ #define GNUTYPE_NAMES 'N' /* file name that does not fit into main hdr */ #define GNUTYPE_SPARSE 'S' /* sparse file */ #define GNUTYPE_VOLHDR 'V' /* tape/volume header */ /* tar header */ #define BLOCKSIZE 512 #define SHORTNAMESIZE 100 struct tar_header { /* byte offset */ char name[100]; /* 0 */ char mode[8]; /* 100 */ char uid[8]; /* 108 */ char gid[8]; /* 116 */ char size[12]; /* 124 */ char mtime[12]; /* 136 */ char chksum[8]; /* 148 */ char typeflag; /* 156 */ char linkname[100]; /* 157 */ char magic[6]; /* 257 */ char version[2]; /* 263 */ char uname[32]; /* 265 */ char gname[32]; /* 297 */ char devmajor[8]; /* 329 */ char devminor[8]; /* 337 */ char prefix[155]; /* 345 */ /* 500 */ }; union tar_buffer { char buffer[BLOCKSIZE]; struct tar_header header; }; struct attr_item { struct attr_item *next; char *fname; int mode; time_t time; }; enum { TGZ_EXTRACT, TGZ_LIST, TGZ_INVALID }; char *TGZfname OF((const char *)); void TGZnotfound OF((const char *)); int getoct OF((char *, int)); char *strtime OF((time_t *)); int setfiletime OF((char *, time_t)); void push_attr OF((struct attr_item **, char *, int, time_t)); void restore_attr OF((struct attr_item **)); int ExprMatch OF((char *, char *)); int makedir OF((char *)); int matchname OF((int, int, char **, char *)); void error OF((const char *)); int tar OF((gzFile, int, int, int, char **)); void help OF((int)); int main OF((int, char **)); char *prog; const char *TGZsuffix[] = { "\0", ".tar", ".tar.gz", ".taz", ".tgz", NULL }; /* return the file name of the TGZ archive */ /* or NULL if it does not exist */ char *TGZfname (const char *arcname) { static char buffer[1024]; int origlen,i; strcpy(buffer,arcname); origlen = strlen(buffer); for (i=0; TGZsuffix[i]; i++) { strcpy(buffer+origlen,TGZsuffix[i]); if (access(buffer,F_OK) == 0) return buffer; } return NULL; } /* error message for the filename */ void TGZnotfound (const char *arcname) { int i; fprintf(stderr,"%s: Couldn't find ",prog); for (i=0;TGZsuffix[i];i++) fprintf(stderr,(TGZsuffix[i+1]) ? "%s%s, " : "or %s%s\n", arcname, TGZsuffix[i]); exit(1); } /* convert octal digits to int */ /* on error return -1 */ int getoct (char *p,int width) { int result = 0; char c; while (width--) { c = *p++; if (c == 0) break; if (c == ' ') continue; if (c < '0' || c > '7') return -1; result = result * 8 + (c - '0'); } return result; } /* convert time_t to string */ /* use the "YYYY/MM/DD hh:mm:ss" format */ char *strtime (time_t *t) { struct tm *local; static char result[32]; local = localtime(t); sprintf(result,"%4d/%02d/%02d %02d:%02d:%02d", local->tm_year+1900, local->tm_mon+1, local->tm_mday, local->tm_hour, local->tm_min, local->tm_sec); return result; } /* set file time */ int setfiletime (char *fname,time_t ftime) { #ifdef WIN32 static int isWinNT = -1; SYSTEMTIME st; FILETIME locft, modft; struct tm *loctm; HANDLE hFile; int result; loctm = localtime(&ftime); if (loctm == NULL) return -1; st.wYear = (WORD)loctm->tm_year + 1900; st.wMonth = (WORD)loctm->tm_mon + 1; st.wDayOfWeek = (WORD)loctm->tm_wday; st.wDay = (WORD)loctm->tm_mday; st.wHour = (WORD)loctm->tm_hour; st.wMinute = (WORD)loctm->tm_min; st.wSecond = (WORD)loctm->tm_sec; st.wMilliseconds = 0; if (!SystemTimeToFileTime(&st, &locft) || !LocalFileTimeToFileTime(&locft, &modft)) return -1; if (isWinNT < 0) isWinNT = (GetVersion() < 0x80000000) ? 1 : 0; hFile = CreateFile(fname, GENERIC_WRITE, 0, NULL, OPEN_EXISTING, (isWinNT ? FILE_FLAG_BACKUP_SEMANTICS : 0), NULL); if (hFile == INVALID_HANDLE_VALUE) return -1; result = SetFileTime(hFile, NULL, NULL, &modft) ? 0 : -1; CloseHandle(hFile); return result; #else struct utimbuf settime; settime.actime = settime.modtime = ftime; return utime(fname,&settime); #endif } /* push file attributes */ void push_attr(struct attr_item **list,char *fname,int mode,time_t time) { struct attr_item *item; item = (struct attr_item *)malloc(sizeof(struct attr_item)); if (item == NULL) error("Out of memory"); item->fname = strdup(fname); item->mode = mode; item->time = time; item->next = *list; *list = item; } /* restore file attributes */ void restore_attr(struct attr_item **list) { struct attr_item *item, *prev; for (item = *list; item != NULL; ) { setfiletime(item->fname,item->time); chmod(item->fname,item->mode); prev = item; item = item->next; free(prev); } *list = NULL; } /* match regular expression */ #define ISSPECIAL(c) (((c) == '*') || ((c) == '/')) int ExprMatch (char *string,char *expr) { while (1) { if (ISSPECIAL(*expr)) { if (*expr == '/') { if (*string != '\\' && *string != '/') return 0; string ++; expr++; } else if (*expr == '*') { if (*expr ++ == 0) return 1; while (*++string != *expr) if (*string == 0) return 0; } } else { if (*string != *expr) return 0; if (*expr++ == 0) return 1; string++; } } } /* recursive mkdir */ /* abort on ENOENT; ignore other errors like "directory already exists" */ /* return 1 if OK */ /* 0 on error */ int makedir (char *newdir) { char *buffer = strdup(newdir); char *p; int len = strlen(buffer); if (len <= 0) { free(buffer); return 0; } if (buffer[len-1] == '/') { buffer[len-1] = '\0'; } if (mkdir(buffer, 0755) == 0) { free(buffer); return 1; } p = buffer+1; while (1) { char hold; while(*p && *p != '\\' && *p != '/') p++; hold = *p; *p = 0; if ((mkdir(buffer, 0755) == -1) && (errno == ENOENT)) { fprintf(stderr,"%s: Couldn't create directory %s\n",prog,buffer); free(buffer); return 0; } if (hold == 0) break; *p++ = hold; } free(buffer); return 1; } int matchname (int arg,int argc,char **argv,char *fname) { if (arg == argc) /* no arguments given (untgz tgzarchive) */ return 1; while (arg < argc) if (ExprMatch(fname,argv[arg++])) return 1; return 0; /* ignore this for the moment being */ } /* tar file list or extract */ int tar (gzFile in,int action,int arg,int argc,char **argv) { union tar_buffer buffer; int len; int err; int getheader = 1; int remaining = 0; FILE *outfile = NULL; char fname[BLOCKSIZE]; int tarmode; time_t tartime; struct attr_item *attributes = NULL; if (action == TGZ_LIST) printf(" date time size file\n" " ---------- -------- --------- -------------------------------------\n"); while (1) { len = gzread(in, &buffer, BLOCKSIZE); if (len < 0) error(gzerror(in, &err)); /* * Always expect complete blocks to process * the tar information. */ if (len != BLOCKSIZE) { action = TGZ_INVALID; /* force error exit */ remaining = 0; /* force I/O cleanup */ } /* * If we have to get a tar header */ if (getheader >= 1) { /* * if we met the end of the tar * or the end-of-tar block, * we are done */ if (len == 0 || buffer.header.name[0] == 0) break; tarmode = getoct(buffer.header.mode,8); tartime = (time_t)getoct(buffer.header.mtime,12); if (tarmode == -1 || tartime == (time_t)-1) { buffer.header.name[0] = 0; action = TGZ_INVALID; } if (getheader == 1) { strncpy(fname,buffer.header.name,SHORTNAMESIZE); if (fname[SHORTNAMESIZE-1] != 0) fname[SHORTNAMESIZE] = 0; } else { /* * The file name is longer than SHORTNAMESIZE */ if (strncmp(fname,buffer.header.name,SHORTNAMESIZE-1) != 0) error("bad long name"); getheader = 1; } /* * Act according to the type flag */ switch (buffer.header.typeflag) { case DIRTYPE: if (action == TGZ_LIST) printf(" %s <dir> %s\n",strtime(&tartime),fname); if (action == TGZ_EXTRACT) { makedir(fname); push_attr(&attributes,fname,tarmode,tartime); } break; case REGTYPE: case AREGTYPE: remaining = getoct(buffer.header.size,12); if (remaining == -1) { action = TGZ_INVALID; break; } if (action == TGZ_LIST) printf(" %s %9d %s\n",strtime(&tartime),remaining,fname); else if (action == TGZ_EXTRACT) { if (matchname(arg,argc,argv,fname)) { outfile = fopen(fname,"wb"); if (outfile == NULL) { /* try creating directory */ char *p = strrchr(fname, '/'); if (p != NULL) { *p = '\0'; makedir(fname); *p = '/'; outfile = fopen(fname,"wb"); } } if (outfile != NULL) printf("Extracting %s\n",fname); else fprintf(stderr, "%s: Couldn't create %s",prog,fname); } else outfile = NULL; } getheader = 0; break; case GNUTYPE_LONGLINK: case GNUTYPE_LONGNAME: remaining = getoct(buffer.header.size,12); if (remaining < 0 || remaining >= BLOCKSIZE) { action = TGZ_INVALID; break; } len = gzread(in, fname, BLOCKSIZE); if (len < 0) error(gzerror(in, &err)); if (fname[BLOCKSIZE-1] != 0 || (int)strlen(fname) > remaining) { action = TGZ_INVALID; break; } getheader = 2; break; default: if (action == TGZ_LIST) printf(" %s <---> %s\n",strtime(&tartime),fname); break; } } else { unsigned int bytes = (remaining > BLOCKSIZE) ? BLOCKSIZE : remaining; if (outfile != NULL) { if (fwrite(&buffer,sizeof(char),bytes,outfile) != bytes) { fprintf(stderr, "%s: Error writing %s -- skipping\n",prog,fname); fclose(outfile); outfile = NULL; remove(fname); } } remaining -= bytes; } if (remaining == 0) { getheader = 1; if (outfile != NULL) { fclose(outfile); outfile = NULL; if (action != TGZ_INVALID) push_attr(&attributes,fname,tarmode,tartime); } } /* * Abandon if errors are found */ if (action == TGZ_INVALID) { error("broken archive"); break; } } /* * Restore file modes and time stamps */ restore_attr(&attributes); if (gzclose(in) != Z_OK) error("failed gzclose"); return 0; } /* ============================================================ */ void help(int exitval) { printf("untgz version 0.2.1\n" " using zlib version %s\n\n", zlibVersion()); printf("Usage: untgz file.tgz extract all files\n" " untgz file.tgz fname ... extract selected files\n" " untgz -l file.tgz list archive contents\n" " untgz -h display this help\n"); exit(exitval); } void error(const char *msg) { fprintf(stderr, "%s: %s\n", prog, msg); exit(1); } /* ============================================================ */ #if defined(WIN32) && defined(__GNUC__) int _CRT_glob = 0; /* disable argument globbing in MinGW */ #endif int main(int argc,char **argv) { int action = TGZ_EXTRACT; int arg = 1; char *TGZfile; gzFile *f; prog = strrchr(argv[0],'\\'); if (prog == NULL) { prog = strrchr(argv[0],'/'); if (prog == NULL) { prog = strrchr(argv[0],':'); if (prog == NULL) prog = argv[0]; else prog++; } else prog++; } else prog++; if (argc == 1) help(0); if (strcmp(argv[arg],"-l") == 0) { action = TGZ_LIST; if (argc == ++arg) help(0); } else if (strcmp(argv[arg],"-h") == 0) { help(0); } if ((TGZfile = TGZfname(argv[arg])) == NULL) TGZnotfound(argv[arg]); ++arg; if ((action == TGZ_LIST) && (arg != argc)) help(1); /* * Process the TGZ file */ switch(action) { case TGZ_LIST: case TGZ_EXTRACT: f = gzopen(TGZfile,"rb"); if (f == NULL) { fprintf(stderr,"%s: Couldn't gzopen %s\n",prog,TGZfile); return 1; } exit(tar(f, action, arg, argc, argv)); break; default: error("Unknown option"); exit(1); } return 0; }
the_stack_data/187643930.c
/*memleak_example.c*/ #include <stdio.h> #include <stdlib.h> int main(int argc, char * argv[]){ int * a = malloc(sizeof(int *)); *a = 10; printf("%d\n", *a); free(a); a = malloc(sizeof(int *)*3); a[0] = 10; a[1] = 20; a[2] = 30; printf("%d %d %d\n", a[0], a[1], a[2]); free(a); } // -The memory for the first malloc pointer is never freed; The second malloc statement rewrites and erases the value of the first malloc pointer and causes a leak. //- leak fix: free memory after each print statement