file
stringlengths
18
26
data
stringlengths
3
1.04M
the_stack_data/198579343.c
#include <stdio.h> #include <stdlib.h> char ch, sdvig; int i, j, k; int main() { printf("Enter CHAR: "); scanf("%c", &ch); sdvig = ch - 65; for (i=0;i<sdvig;i++) { for (ch=42, j=(sdvig-i); j>0; j--) printf("%c", ch); for (ch='A', k=0; k<=i; ch++, k++) printf("%c", ch); for (;ch>='A';ch--) printf("%c", ch); printf("\n"); } return 0; }
the_stack_data/59512023.c
int tribonacci(int n){ int t0 = 0, t1 = 1, t2 = 1, tn = 0; if(n < 3) { return (n + 1) / 2; } for(int i=2; i<n; i++) { tn = t0 + t1 + t2; t0 = t1; t1 = t2; t2 = tn; } return tn; }
the_stack_data/62637228.c
/** * @file 1-8.c * strlolにlong型の範囲を超える大きな数を与えた場合 * エラーにならずLONG_MAX(int 64最大値 9223372036854775807)が返る * また整数を表さない文字列("10xyz")を与えてもエラーにならず、10が返る。 * xを発見した時点で変換をやめて、それまでの変換結果を返すのがその理由 * * ./a.out 9223372036854775808 * 9223372036854775807 * * ./a.out 10xyz * 10 * * このプログラムを修正して、上の実行例をエラーとするようにエラー処理のコードを加える */ #include <stdlib.h> // strtol #include <stdio.h> // printf #include <errno.h> // ERANGE #include <limits.h> // strtol LONG_MAX int main (int argc, char *argv[]) { // 注意点として、errnoが実行時にすでに0以外の場合、正常でも予期せぬ不具合になるので // strtolの実行前にerrnoを0に設定しておく // SUSv4[6]に strtol関数は成功時にはerrnoを変更しないとあるので、この方法が使える errno = 0; // strtolの第1引数に変な文字が入っているかの検知には、strtolの第2引数を使う // strtolは変換をやめた位置を第2引数にセットする char* test = NULL; long val = strtol (argv[1], &test, 0); printf("LONG_MAX is %ld\n", LONG_MAX); if (val == LONG_MAX) { // 範囲越えエラーの場合errnoにERANGEがセットされる if (errno == ERANGE) { int old_errno = errno; perror("strtol: ERANGE"); exit(1); } } else if (test != NULL) { printf("strtol: data cannot be parsed all. test:%s", test); exit(1); } printf("success test:%s \n", test); printf("%ld\n", val); } /** * 本に記載の正解版 */ int main2(int argc, char *argv[]) { long val; char *end; errno = 0; val = strtol(argv[1], &end, 0); if (errno != 0) { // 何かしらエラーがあったらperrorで終了 perror("strtol"); exit(1); } // NULL文字でない = 変な文字が入っていたエラー if (end[0] != '\0') { fprintf(stderr, "Non-digit character: %c\n", end [0]); exit(1); } printf("%ld\n", val); }
the_stack_data/77215.c
#include<stdio.h> #include<stdlib.h> //void ReadMatrix(int mat[ROW][COL], int row, int col); void ReadMatrix(int **mat, int row, int col); void PrintMatrix(int **mat, int row, int col); int** CreateMatrix(int row, int col); void FreeMatrix(int **mat, int row); int main() { int row, col, r,c; int **ptr=NULL; printf("\n Enter How Many Rows You want :: "); scanf("%d", &row); printf("\n Enter How Many Cols You want :: "); scanf("%d", &col); ptr=CreateMatrix(row, col); printf("\n Enter elements of matrix :: \n"); ReadMatrix(ptr, row, col); printf("\n Elements of matrix ::\n "); PrintMatrix(ptr, row, col); FreeMatrix(ptr, row); return 0; } int** CreateMatrix(int row, int col) { int r; int **mat= (int**)malloc(sizeof(int*)*row); for(r=0; r<row; r++) { mat[r]= (int*)malloc(sizeof(int)*col); } return mat; // return &mat --- int*** } void ReadMatrix(int **mat, int row,int col) { int r,c; for(r=0; r<row; r++) { for(c=0; c<col; c++) { printf("\n mat[%d][%d]", r,c); //scanf("%d", &mat[r][c]); scanf("%d", (*(mat+r)+c)); } } return; } void PrintMatrix(int **mat, int row, int col) { int r,c; printf("\&mat=%u mat=%u\n", &mat, mat); for(r=0; r<row; r++) { printf("\n &mat[%d] %u mat[%d] %u \n ", r, &mat[r], r, mat[r]); for(c=0; c<col; c++) { //printf("\t %d [%u]", mat[r][c], &mat[r][c]); printf("\t %d [%u]", *(*(mat+r)+c),(*(mat+r)+c)); } printf("\n"); } return; } void FreeMatrix(int **mat, int row) { int r; for(r=0; r<row; r++) { free(mat[r]); mat[r]=NULL; } free(mat); mat=NULL; printf("\n Memory is freed..."); return; }
the_stack_data/50553.c
// bb5.c // "construction of efficient generalized lr parsers": i == 5 int main() { int a, b; a = b+b+b+b+b+b; return a; }
the_stack_data/131928.c
/* { dg-options "-O -fexpensive-optimizations -fno-tree-bit-ccp" } */ __attribute__ ((noinline, noclone)) int foo (unsigned short x, unsigned short y) { int r; if (__builtin_mul_overflow (x, y, &r)) __builtin_abort (); return r; } int main (void) { int x = 1; int y = 2; if (foo (x, y) != x * y) __builtin_abort (); return 0; }
the_stack_data/8454.c
#include <stdio.h> #include <stdlib.h> int main() { char sentence[1000]; // creating file pointer to work with files FILE *fptr; // opening file in writing mode fptr = fopen("program.txt", "w"); // exiting program if (fptr == NULL) { printf("Error!"); exit(1); } printf("Enter a sentence:\n"); fgets(sentence, sizeof(sentence), stdin); fprintf(fptr, "%s", sentence); fclose(fptr); return 0; }
the_stack_data/154827149.c
/* 1028 人口普查 (20 分) 解析: 1. 多字段排序。 2. 注意。测试点:没有一个生日是合理的情况。 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> typedef struct { char name[6]; int year; int month; int day; int is_valid; } Person; int date_a_gt_b(int a_year, int a_month, int a_day, int b_year, int b_month, int b_day) { if (a_year < b_year) { return 0; } else if (a_year == b_year) { if (a_month < b_month) { return 0; } else if (a_month == b_month) { if (a_day < b_day) { return 0; } else { return 1; } } else { return 1; } } else { return 1; } } int comfunc(const void *a, const void *b) { Person aa = *(Person *)a; Person bb = *(Person *)b; return date_a_gt_b(aa.year, aa.month, aa.day, bb.year, bb.month, bb.day); } int main(int argc, char *argv[]) { // 处理输入 int n; if (scanf("%d", &n) != 1) return EXIT_FAILURE; char temp; if (scanf("%c", &temp) != 1) return EXIT_FAILURE; Person persons[n]; for (int i = 0; i < n; i++) { if (scanf("%s %d/%d/%d", persons[i].name, &persons[i].year, &persons[i].month, &persons[i].day) != 4) return EXIT_FAILURE; } // 判断有效性 int valid_count = 0; int now_year = 2014, now_month = 9, now_day = 6; for (int i = 0; i < n; i++) { if (date_a_gt_b(persons[i].year, persons[i].month, persons[i].day, now_year - 200, now_month, now_day) && date_a_gt_b(now_year, now_month, now_day, persons[i].year, persons[i].month, persons[i].day)) { persons[i].is_valid = 1; valid_count++; } else { persons[i].is_valid = 0; } } // 排序 qsort(persons, n, sizeof(Person), comfunc); // 找最年长和最年轻的人的名字 char oldest_name[6], youngest[6]; for (int i = 0; i < n; i++) { if (persons[i].is_valid) { memcpy(oldest_name, persons[i].name, 6); break; } } for (int i = n - 1; i >= 0; i--) { if (persons[i].is_valid) { memcpy(youngest, persons[i].name, 6); break; } } // 处理输出 if (valid_count >= 1) { printf("%d %s %s", valid_count, oldest_name, youngest); } else { printf("0"); } return EXIT_SUCCESS; }
the_stack_data/23575893.c
int get_int_from_user(void); int main(void) { int x, y; x = get_int_from_user() % 50; if(x < 0) x = 0; if(x < 12) y = 72; y += 32; return y; }
the_stack_data/97753.c
/* * 编写一个函数escape(s, t),将字符串t复制到字符串s中,并在复制过程中将换行符, * 制表符等不可见字符分别转换为\n、\t等相应的可见的转义字符序列。 * 要求使用switch语句。 */ void escape(char s[], char t[]) { int i = 0; int j = 0; while (s[i] != '\0') { switch (t[j]) { case '\n': s[i++] = '\\'; s[i++] = 'n'; break; case '\t': s[i++] = '\\'; s[i++] = 't'; break; case '\0': return; default: s[i++] = t[j]; break; } ++j; } return; }
the_stack_data/167330644.c
#include <stdio.h> int main() { int age; printf("Enter Your Age:"); scanf("%d", &age); (age >= 18) ? printf("You age is %d You are eligible for voting.",age) : printf(" You age is %d You are Not eligible for Voting.",age); return 0; }
the_stack_data/68359.c
#include <stdio.h> #include <stdlib.h> #include <time.h> // 물고기가 6마리가 있어요 // 이들은 어항에 살고 있는데, 사막이에요 // 사막이 너무 다워서, 너무 건조해서 물이 아주 빨리 증발을 해요 // 물이 다 증발하기 전에 부지런히 어항에 물을 줘서 물고기를 살려주세요~ int level; int arrayFish[6]; int *cursor; void initData(); void printFishes(); void decreaseWater(long elapsedTime); int checkFishAlive(); int main(void) { long startTime = 0; //게임 시작 시간 long totalElapsedTime = 0; //총 경과 시간 long prevElapsedTime = 0; //직전 경과 시간 (최근에 물을 준 시간 간격) int num; //몇 번 어항에 물을 줄 것인지, 사용자 입력 initData(); cursor = arrayFish; // cursor[0] .. cursor[1] .. startTime = clock(); // 현재 시간을 millisecond (1000분의 1초) 단위로 반환 while(1) { printFishes(); printf("몇 번 어항에 물을 주시겠어요? "); scanf("%d", &num); // 입력값 체크 if(num <1 || num >6) { printf("입력값이 잘못되었습니다\n"); continue; } //총 경과 시간 totalElapsedTime = (clock() - startTime) / CLOCKS_PER_SEC; printf("총 경과 시간 : %ld초\n", totalElapsedTime); //직전 물 준 시간 (마지막으로 물 준 시간) 이후로 흐른 시간 prevElapsedTime = totalElapsedTime - prevElapsedTime; printf("최근 경과 시간 : %ld초\n", prevElapsedTime); //어항의 물을 감소 (증발) decreaseWater(prevElapsedTime); //사용자가 입력한 어항에 물을 준다 //1. 어항의 물이 0이면? 물을 주지 않는다... 이미 고기가 사망함. if(cursor[num -1] <= 0) //-1은 사람은 1~6번 어항 고를테니까 우린 0~5쓰니가 -1함 { printf("%d 번 물고기는 이미 죽었습니다.. 물을 주지 않습니다\n", num); } //2. 어항의 물이 0이 아닌 경우? 물을 준다! 단,100을 넘지 않는지 체크 else if (cursor[num -1] + 1 <= 100) { //물을 준다 printf("%d 번 어항에 물을 줍니다\n\n", num); cursor[num -1] += 1; } //레벨업을 할 건지 확인 (레벨업은 20초마다 한번씩 수행) if(totalElapsedTime/20 > level -1) { //레벨업 level++; //level : 1 -> level : 2 printf(" ***축 레벨업! 기존 %d 레벨에서 %d 레벨로 업그레이드! ***\n\n",level-1, level); //최종 레벨:5 if(level == 5) { printf("\n\n축하합니다. 최고 레벨을 달성하셨습니다. 게임을 종료합니다\n\n"); exit(0); } } //모든 물고기가 죽었는지 확인 if(checkFishAlive() == 0) { //물고기 모두 ㅠ printf("모든 물고기가.. ㅠㅠ... \n"); exit(0); } else { //최소 한마리 이상의 물고기는 살아 있음 printf("물고기가 아직 살아있어요!\n"); } prevElapsedTime = totalElapsedTime; // 10초 -> 15초 (5초 : prevElapsedTime) -> 25초 (10초를 계산..?) // 15초를 저장할 공간이 필요한데 이미 prevElapsedTime의 5초는 사용을 했으므로 그냥 15초를 prevElapsedTime에 저장 // 10초 -> 15초 (5초 : prevElapsedTime -> 15초) -> 25초 } return 0; } void initData() { level = 1; //게임 레벨 (1~5) for(int i=0; i<6; i++) { arrayFish[i] = 100; //어항의 물 높이 (0~100) } } void printFishes() { printf("%3d번 %3d번 %3d번 %3d번 %3d번 %3d번\n", 1, 2, 3, 4, 5, 6); //(%3d번 ) -> 6칸, 3d=3, 번=2, =1 for(int i=0; i<6; i++){ printf(" %4d ", arrayFish[i]); //( %4d ) -> 6칸으로 위랑 맞춘거 } printf("\n\n"); } void decreaseWater(long elapsedTime) { for(int i=0; i<6; i++) { arrayFish[i] -= (level * 3 *(int)elapsedTime); //3은 난이도 조절을 위한 값 if(arrayFish[i]<0) { arrayFish[i]=0; } } } int checkFishAlive() { for(int i=0; i<6 ;i++) { if(arrayFish[i]>0) return 1;// 참 True } return 0; }
the_stack_data/89597.c
#include <stdlib.h> #define _GNU_SOURCE #include <stdio.h> #include <string.h> #include <unistd.h> #include <pthread.h> #include <arpa/inet.h> #include <errno.h> #include <signal.h> #include <sys/types.h> #include <sys/socket.h> #include <event.h> /* * Connection object. */ struct cx { int fd; int *counter; /* shared counter of the number of messages received. */ int total; /* total number of messages to send */ char *http_request; void (*read_fun)(int,short,void*); /* called when able to read fd */ void (*write_fun)(int,short,void*); /* called when able to write fd */ /* libevent data structures */ struct event evr, evw; struct event_base *base; }; int webdis_connect(const char *host, short port) { int ret; int fd; struct sockaddr_in addr; /* connect socket */ fd = socket(AF_INET, SOCK_STREAM, 0); addr.sin_family = AF_INET; addr.sin_port = htons(port); memset(&(addr.sin_addr), 0, sizeof(addr.sin_addr)); addr.sin_addr.s_addr = inet_addr(host); ret = connect(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr)); if(ret != 0) { fprintf(stderr, "connect: ret=%d: %s\n", ret, strerror(errno)); return -1; } return fd; } /** * Send request and read until the delimiter string is reached. blocking. */ void reader_http_request(struct cx *c, const char* buffer, const char *limit) { char resp[2048]; int pos = 0; int r = write(c->fd, buffer, strlen(buffer)); (void)r; memset(resp, 0, sizeof(resp)); while(1) { int ret = read(c->fd, resp+pos, sizeof(resp)-pos); if(ret <= 0) { return; } pos += ret; if(strstr(resp, limit) != NULL) { break; } } } /** * (re)install connection in the event loop. */ void cx_install(struct cx *c) { if(c->read_fun) { /* attach callback for read. */ event_set(&c->evr, c->fd, EV_READ, c->read_fun, c); event_base_set(c->base, &c->evr); event_add(&c->evr, NULL); } if(c->write_fun) { /* attach callback for write. */ event_set(&c->evw, c->fd, EV_WRITE, c->write_fun, c); event_base_set(c->base, &c->evw); event_add(&c->evw, NULL); } } /** * Called when a reader has received data. */ void reader_can_read(int fd, short event, void *ptr) { char buffer[1024]; struct cx *c = ptr; const char *p; (void)event; int ret = read(fd, buffer, sizeof(buffer)); if(ret > 0) { /* count messages, each message starts with '{' */ p = buffer; do { /* look for the start of a message */ p = memchr(p, '{', buffer + ret - p); if(!p) break; /* none left. */ p++; (*c->counter)++; /* increment the global message counter. */ if(((*c->counter * 100) % c->total) == 0) { /* show progress. */ printf("\r%d %%", 100 * *c->counter / c->total); fflush(stdout); } if(*c->counter > c->total) { /* halt event loop. */ event_base_loopbreak(c->base); } } while(1); } cx_install(c); } /** * create a new reader object. */ void reader_new(struct event_base *base, const char *host, short port, int total, int *counter, int chan) { struct cx *c = calloc(1, sizeof(struct cx)); c->base = base; c->counter = counter; c->total = total; c->fd = webdis_connect(host, port); c->read_fun = reader_can_read; /* send subscription request. */ c->http_request = malloc(100); sprintf(c->http_request, "GET /SUBSCRIBE/chan:%d HTTP/1.1\r\n\r\n", chan); reader_http_request(c, c->http_request, "{\"SUBSCRIBE\":[\"subscribe\""); /* add to the event loop. */ cx_install(c); } /** * Called when a writer has received data back. read and ignore. */ void writer_can_read(int fd, short event, void *ptr) { char buffer[1024]; struct cx *c = ptr; int r; (void)event; r = read(fd, buffer, sizeof(buffer)); /* discard */ (void)r; /* re-install in the event loop. */ cx_install(c); } /* send request */ void writer_can_write(int fd, short event, void *ptr) { struct cx *c = ptr; (void)fd; (void)event; reader_http_request(c, c->http_request, "{\"PUBLISH\":"); cx_install(c); } void writer_new(struct event_base *base, const char *host, short port, int chan) { struct cx *c = malloc(sizeof(struct cx)); c->base = base; c->fd = webdis_connect(host, port); c->read_fun = writer_can_read; c->write_fun = writer_can_write; /* send request. */ c->http_request = malloc(100); sprintf(c->http_request, "GET /PUBLISH/chan:%d/hi HTTP/1.1\r\n\r\n", chan); reader_http_request(c, c->http_request, "{\"PUBLISH\":"); cx_install(c); } void usage(const char* argv0, char *host_default, short port_default, int r_default, int w_default, int n_default, int c_default) { printf("Usage: %s [options]\n" "Options are:\n" "\t-h host\t\t(default = \"%s\")\n" "\t-p port\t\t(default = %d)\n" "\t-r readers\t(default = %d)\n" "\t-w writers\t(default = %d)\n" "\t-c channels\t(default = %d)\n" "\t-n messages\t(number of messages to read in total, default = %d)\n", argv0, host_default, (int)port_default, r_default, w_default, c_default, n_default); } static struct event_base *__base; void on_sigint(int s) { (void)s; event_base_loopbreak(__base); } int main(int argc, char *argv[]) { /* Create R readers and W writers, send N messages in total. */ struct timespec t0, t1; struct event_base *base = event_base_new(); int i, count = 0; /* getopt vars */ int opt; char *colon; /* default values */ short port_default = 7379; char *host_default = "127.0.0.1"; int r_default = 450, w_default = 10, n_default = 100000, c_default = 1; /* real values */ int r = r_default, w = w_default, chans = c_default, n = n_default; char *host = host_default; short port = port_default; /* getopt */ while ((opt = getopt(argc, argv, "h:p:r:w:c:n:")) != -1) { switch (opt) { case 'h': colon = strchr(optarg, ':'); if(!colon) { size_t sz = strlen(optarg); host = calloc(1 + sz, 1); strncpy(host, optarg, sz); } else { host = calloc(1+colon-optarg, 1); strncpy(host, optarg, colon-optarg); port = (short)atol(colon+1); } break; case 'p': port = (short)atol(optarg); break; case 'r': r = atoi(optarg); break; case 'w': w = atoi(optarg); break; case 'c': chans = atoi(optarg); break; case 'n': n = atoi(optarg); break; default: usage(argv[0], host_default, port_default, r_default, w_default, n_default, c_default); exit(EXIT_FAILURE); } } for(i = 0; i < r; ++i) { reader_new(base, host, port, n, &count, i % chans); } for(i = 0; i < w; ++i) { writer_new(base, host, port, i % chans); } /* install signal handler */ __base = base; signal(SIGINT, on_sigint); /* save time now */ clock_gettime(CLOCK_MONOTONIC, &t0); /* run test */ event_base_dispatch(base); /* timing */ clock_gettime(CLOCK_MONOTONIC, &t1); float mili0 = t0.tv_sec * 1000 + t0.tv_nsec / 1000000; float mili1 = t1.tv_sec * 1000 + t1.tv_nsec / 1000000; printf("\rReceived %d messages from %d writers to %d readers through %d channels in %0.2f sec: received %0.2f msg/sec\n", count, w, r, chans, (mili1-mili0)/1000.0, 1000*count/(mili1-mili0)); return EXIT_SUCCESS; }
the_stack_data/606829.c
#include <stdlib.h> char* serpentino_encode(const char* s) { if (!s) return NULL; if (s == "") return 0; int v = 0, len = strlen(s); for (int i = 0; i < len; i++) { if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') v++; } int bytes = len + v * 2, k = 0; char* ns = malloc(bytes + 1); for (int i = 0; i < len; i++) { ns[k] = s[i]; if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u') { ns[++k] = 's'; ns[++k] = s[i]; } k++; } ns[k] = 0; return ns; }
the_stack_data/111078750.c
/* * Contains the entry point for the project, and defines the ISR vectors * Copyright (C) 2013 Richard Meadows * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject to * the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* * A function for each of the interrupt vectors is weakly defined with an alias * so it may be optionally overridden elsewhere in the project. */ #define alias(f) __attribute__ ((alias(#f))) #define weak __attribute__ ((weak)) /* Cortex-M# Core Interrupts */ weak void Reset_Handler(void); weak void NMI_Handler(void) alias (Default_Handler); weak void HardFault_Handler(void); /* LPCxxxx Chip Interrupts */ /* This is defined in the linker script */ extern void __StackLimit(void); /* * This array of interrupt vectors is decared in a special section so that the * linker script can position it at 0x00000000. */ __attribute__ ((section(".isr_vector"))) const void *isr_vectors[] = { /* Cortex-M3 Core Interrupts */ &__StackLimit, // The end of the stack. Reset_Handler, // The Reset handler NMI_Handler, // The NMI handler HardFault_Handler, // The Hard Fault Handler }; /* These are defined in the linker script */ extern unsigned int __etext; extern unsigned int __data_start__; extern unsigned int __data_end__; extern unsigned int __bss_start__; extern unsigned int __bss_end__; extern int main(void); /* The entry point to our program */ __attribute__ ((naked)) void Reset_Handler (void) { /* Load constants / initial values */ for (unsigned int *source = &__etext, *destination = &__data_start__; destination < &__data_end__; ) *destination++ = *source++; /* Zero out bss data */ for (unsigned int *destination = &__bss_start__; destination < &__bss_end__; ) *destination++ = 0; main(); /* Wait here forever so the chip doesn't go haywire */ while (1); } /* Default handler for undefined interrupts */ void Default_Handler(void) { /* You shouldn't have got here! There's been an undefined interrupt triggered somewhere.. */ while(1); } /* HardFault Handler */ void HardFault_Handler(void) { /* Drat! A HardFault */ while(1); }
the_stack_data/61075659.c
int foo(){ return 95; } int main(){ int x = 56; if(x > 100){ #pragma spf transform inline x += foo(); } else x -= foo(); return 0; } //CHECK:
the_stack_data/173577806.c
//////////////////////////////////////////////////////////////////////////// // // Function Name : NonFact() // Description : Accept Number From User And Display Non Factors Of That Number // Input : Integer // Output : Integer // Author : Prasad Dangare // Date : 03 Mar 2021 // //////////////////////////////////////////////////////////////////////////// #include<stdio.h> void NonFact(int iNo) { int iCnt = 0; if(iNo <= 0) { iNo =- iNo; } for(iCnt = 1; iCnt < iNo; iCnt++) { if(iNo % iCnt != 0) { printf("%d ", iCnt); } } } int main() { int iValue = 0; printf("Enter number : "); scanf("%d",&iValue); NonFact(iValue); return 0; }
the_stack_data/146226.c
#include <stdio.h> #include <stdlib.h> int main() { int a; scanf("%d", &a); a+=a*=a-=a*=3; printf("a = %d\n", a); return 0; }
the_stack_data/740558.c
#include <locale.h> extern char* __en_US_langinfo[]; char* setlocale(int category, const char* locale) { return (char*)locale; }
the_stack_data/248580922.c
/* Exercise 1 - Calculations Write a C program to input marks of two subjects. Calculate and print the average of the two marks. */ #include <stdio.h> int main() { int mark1, mark2; float average; printf("Enter mark-1: "); scanf("%d", &mark1); printf("Enter mark-2: "); scanf("%d", &mark2); average = (mark1+mark2)/2.0; printf("Average is: %.2f", average); return 0; }
the_stack_data/20451223.c
#include <stdio.h> static struct sss{ short f; long :0; int i; } sss; #define _offsetof(st,f) ((char *)&((st *) 16)->f - (char *) 16) int main (void) { printf ("+++long zerofield inside struct starting with short:\n"); printf ("size=%d,align=%d\n", sizeof (sss), __alignof__ (sss)); printf ("offset-short=%d,offset-last=%d,\nalign-short=%d,align-last=%d\n", _offsetof (struct sss, f), _offsetof (struct sss, i), __alignof__ (sss.f), __alignof__ (sss.i)); return 0; }
the_stack_data/149230.c
#define SCREEN_WIDTH 80 #define SCREEN_HEIGHT 60 static inline void write_char(const char c, const unsigned int index) { char *const video_ptr = ((char*) 0xb8000); unsigned int fbf_index = index * 2; video_ptr[fbf_index++] = c; video_ptr[fbf_index++] = 0x07; } void clear(void) { unsigned idx = 0; while (idx < SCREEN_WIDTH * SCREEN_HEIGHT) { write_char(' ', idx++); } } void write(const char *const str) { unsigned str_idx = 0; while (str[str_idx] != '\0') { write_char(str[str_idx], str_idx); str_idx++; } } void kmain(void) { clear(); write("Hello, World!"); }
the_stack_data/126704364.c
/* * tracepath6.c * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version * 2 of the License, or (at your option) any later version. * * Authors: Alexey Kuznetsov, <[email protected]> */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <netinet/icmp6.h> #include <linux/types.h> #include <linux/errqueue.h> #include <errno.h> #include <string.h> #include <netdb.h> #include <resolv.h> #include <sys/time.h> #include <sys/uio.h> #include <arpa/inet.h> #ifdef USE_IDN #include <idna.h> #include <locale.h> #endif #ifndef SOL_IPV6 #define SOL_IPV6 IPPROTO_IPV6 #endif #ifndef IP_PMTUDISC_DO #define IP_PMTUDISC_DO 3 #endif #ifndef IPV6_PMTUDISC_DO #define IPV6_PMTUDISC_DO 3 #endif #define MAX_HOPS_LIMIT 255 #define MAX_HOPS_DEFAULT 30 struct hhistory { int hops; struct timeval sendtime; }; struct hhistory his[64]; int hisptr; sa_family_t family = AF_INET6; struct sockaddr_storage target; socklen_t targetlen; __u16 base_port; int max_hops = MAX_HOPS_DEFAULT; int overhead; int mtu; void *pktbuf; int hops_to = -1; int hops_from = -1; int no_resolve = 0; int show_both = 0; int mapped; #define HOST_COLUMN_SIZE 52 struct probehdr { __u32 ttl; struct timeval tv; }; void data_wait(int fd) { fd_set fds; struct timeval tv; FD_ZERO(&fds); FD_SET(fd, &fds); tv.tv_sec = 1; tv.tv_usec = 0; select(fd+1, &fds, NULL, NULL, &tv); } void print_host(const char *a, const char *b, int both) { int plen; plen = printf("%s", a); if (both) plen += printf(" (%s)", b); if (plen >= HOST_COLUMN_SIZE) plen = HOST_COLUMN_SIZE - 1; printf("%*s", HOST_COLUMN_SIZE - plen, ""); } int recverr(int fd, int ttl) { int res; struct probehdr rcvbuf; char cbuf[512]; struct iovec iov; struct msghdr msg; struct cmsghdr *cmsg; struct sock_extended_err *e; struct sockaddr_storage addr; struct timeval tv; struct timeval *rettv; int slot = 0; int rethops; int sndhops; int progress = -1; int broken_router; restart: memset(&rcvbuf, -1, sizeof(rcvbuf)); iov.iov_base = &rcvbuf; iov.iov_len = sizeof(rcvbuf); msg.msg_name = (caddr_t)&addr; msg.msg_namelen = sizeof(addr); msg.msg_iov = &iov; msg.msg_iovlen = 1; msg.msg_flags = 0; msg.msg_control = cbuf; msg.msg_controllen = sizeof(cbuf); gettimeofday(&tv, NULL); res = recvmsg(fd, &msg, MSG_ERRQUEUE); if (res < 0) { if (errno == EAGAIN) return progress; goto restart; } progress = mtu; rethops = -1; sndhops = -1; e = NULL; rettv = NULL; slot = -base_port; switch (family) { case AF_INET6: slot += ntohs(((struct sockaddr_in6 *)&addr)->sin6_port); break; case AF_INET: slot += ntohs(((struct sockaddr_in *)&addr)->sin_port); break; } if (slot >= 0 && slot < 63 && his[slot].hops) { sndhops = his[slot].hops; rettv = &his[slot].sendtime; his[slot].hops = 0; } broken_router = 0; if (res == sizeof(rcvbuf)) { if (rcvbuf.ttl == 0 || rcvbuf.tv.tv_sec == 0) broken_router = 1; else { sndhops = rcvbuf.ttl; rettv = &rcvbuf.tv; } } for (cmsg = CMSG_FIRSTHDR(&msg); cmsg; cmsg = CMSG_NXTHDR(&msg, cmsg)) { switch (cmsg->cmsg_level) { case SOL_IPV6: switch(cmsg->cmsg_type) { case IPV6_RECVERR: e = (struct sock_extended_err *)CMSG_DATA(cmsg); break; case IPV6_HOPLIMIT: #ifdef IPV6_2292HOPLIMIT case IPV6_2292HOPLIMIT: #endif memcpy(&rethops, CMSG_DATA(cmsg), sizeof(rethops)); break; default: printf("cmsg6:%d\n ", cmsg->cmsg_type); } break; case SOL_IP: switch(cmsg->cmsg_type) { case IP_RECVERR: e = (struct sock_extended_err *)CMSG_DATA(cmsg); break; case IP_TTL: rethops = *(__u8*)CMSG_DATA(cmsg); break; default: printf("cmsg4:%d\n ", cmsg->cmsg_type); } } } if (e == NULL) { printf("no info\n"); return 0; } if (e->ee_origin == SO_EE_ORIGIN_LOCAL) printf("%2d?: %-32s ", ttl, "[LOCALHOST]"); else if (e->ee_origin == SO_EE_ORIGIN_ICMP6 || e->ee_origin == SO_EE_ORIGIN_ICMP) { char abuf[NI_MAXHOST], hbuf[NI_MAXHOST]; struct sockaddr *sa = (struct sockaddr *)(e + 1); socklen_t salen; if (sndhops>0) printf("%2d: ", sndhops); else printf("%2d?: ", ttl); switch (sa->sa_family) { case AF_INET6: salen = sizeof(struct sockaddr_in6); break; case AF_INET: salen = sizeof(struct sockaddr_in); break; default: salen = 0; } if (no_resolve || show_both) { if (getnameinfo(sa, salen, abuf, sizeof(abuf), NULL, 0, NI_NUMERICHOST)) strcpy(abuf, "???"); } else abuf[0] = 0; if (!no_resolve || show_both) { fflush(stdout); if (getnameinfo(sa, salen, hbuf, sizeof(hbuf), NULL, 0, 0 #ifdef USE_IDN | NI_IDN #endif )) strcpy(hbuf, "???"); } else hbuf[0] = 0; if (no_resolve) print_host(abuf, hbuf, show_both); else print_host(hbuf, abuf, show_both); } if (rettv) { int diff = (tv.tv_sec-rettv->tv_sec)*1000000+(tv.tv_usec-rettv->tv_usec); printf("%3d.%03dms ", diff/1000, diff%1000); if (broken_router) printf("(This broken router returned corrupted payload) "); } switch (e->ee_errno) { case ETIMEDOUT: printf("\n"); break; case EMSGSIZE: printf("pmtu %d\n", e->ee_info); mtu = e->ee_info; progress = mtu; break; case ECONNREFUSED: printf("reached\n"); hops_to = sndhops<0 ? ttl : sndhops; hops_from = rethops; return 0; case EPROTO: printf("!P\n"); return 0; case EHOSTUNREACH: if ((e->ee_origin == SO_EE_ORIGIN_ICMP && e->ee_type == 11 && e->ee_code == 0) || (e->ee_origin == SO_EE_ORIGIN_ICMP6 && e->ee_type == 3 && e->ee_code == 0)) { if (rethops>=0) { if (rethops<=64) rethops = 65-rethops; else if (rethops<=128) rethops = 129-rethops; else rethops = 256-rethops; if (sndhops>=0 && rethops != sndhops) printf("asymm %2d ", rethops); else if (sndhops<0 && rethops != ttl) printf("asymm %2d ", rethops); } printf("\n"); break; } printf("!H\n"); return 0; case ENETUNREACH: printf("!N\n"); return 0; case EACCES: printf("!A\n"); return 0; default: printf("\n"); errno = e->ee_errno; perror("NET ERROR"); return 0; } goto restart; } int probe_ttl(int fd, int ttl) { int i; struct probehdr *hdr = pktbuf; memset(pktbuf, 0, mtu); restart: for (i=0; i<10; i++) { int res; hdr->ttl = ttl; switch (family) { case AF_INET6: ((struct sockaddr_in6 *)&target)->sin6_port = htons(base_port + hisptr); break; case AF_INET: ((struct sockaddr_in *)&target)->sin_port = htons(base_port + hisptr); break; } gettimeofday(&hdr->tv, NULL); his[hisptr].hops = ttl; his[hisptr].sendtime = hdr->tv; if (sendto(fd, pktbuf, mtu-overhead, 0, (struct sockaddr *)&target, targetlen) > 0) break; res = recverr(fd, ttl); his[hisptr].hops = 0; if (res==0) return 0; if (res > 0) goto restart; } hisptr = (hisptr + 1) & 63; if (i<10) { data_wait(fd); if (recv(fd, pktbuf, mtu, MSG_DONTWAIT) > 0) { printf("%2d?: reply received 8)\n", ttl); return 0; } return recverr(fd, ttl); } printf("%2d: send failed\n", ttl); return 0; } static void usage(void) __attribute((noreturn)); static void usage(void) { fprintf(stderr, "Usage: tracepath6 [-n] [-b] [-l <len>] [-p port] <destination>\n"); exit(-1); } int main(int argc, char **argv) { int fd; int on; int ttl; char *p; struct addrinfo hints, *ai, *ai0; int ch; int gai; char pbuf[NI_MAXSERV]; #ifdef USE_IDN setlocale(LC_ALL, ""); #endif while ((ch = getopt(argc, argv, "nbh?l:m:p:")) != EOF) { switch(ch) { case 'n': no_resolve = 1; break; case 'b': show_both = 1; break; case 'l': mtu = atoi(optarg); break; case 'm': max_hops = atoi(optarg); if (max_hops < 0 || max_hops > MAX_HOPS_LIMIT) { fprintf(stderr, "Error: max hops must be 0 .. %d (inclusive).\n", MAX_HOPS_LIMIT); } break; case 'p': base_port = atoi(optarg); break; default: usage(); } } argc -= optind; argv += optind; if (argc != 1) usage(); /* Backward compatiblity */ if (!base_port) { p = strchr(argv[0], '/'); if (p) { *p = 0; base_port = (unsigned)atoi(p+1); } else { base_port = 44444; } } sprintf(pbuf, "%u", base_port); memset(&hints, 0, sizeof(hints)); hints.ai_family = family; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = IPPROTO_UDP; #ifdef USE_IDN hints.ai_flags = AI_IDN; #endif gai = getaddrinfo(argv[0], pbuf, &hints, &ai0); if (gai) { fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(gai)); exit(1); } fd = -1; for (ai = ai0; ai; ai = ai->ai_next) { /* sanity check */ if (family && ai->ai_family != family) continue; if (ai->ai_family != AF_INET6 && ai->ai_family != AF_INET) continue; family = ai->ai_family; fd = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); if (fd < 0) continue; memcpy(&target, ai->ai_addr, sizeof(target)); targetlen = ai->ai_addrlen; break; } if (fd < 0) { perror("socket/connect"); exit(1); } freeaddrinfo(ai0); switch (family) { case AF_INET6: overhead = 48; if (!mtu) mtu = 128000; if (mtu <= overhead) goto pktlen_error; on = IPV6_PMTUDISC_DO; if (setsockopt(fd, SOL_IPV6, IPV6_MTU_DISCOVER, &on, sizeof(on)) && (on = IPV6_PMTUDISC_DO, setsockopt(fd, SOL_IPV6, IPV6_MTU_DISCOVER, &on, sizeof(on)))) { perror("IPV6_MTU_DISCOVER"); exit(1); } on = 1; if (setsockopt(fd, SOL_IPV6, IPV6_RECVERR, &on, sizeof(on))) { perror("IPV6_RECVERR"); exit(1); } if ( #ifdef IPV6_RECVHOPLIMIT setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &on, sizeof(on)) && setsockopt(fd, SOL_IPV6, IPV6_2292HOPLIMIT, &on, sizeof(on)) #else setsockopt(fd, SOL_IPV6, IPV6_HOPLIMIT, &on, sizeof(on)) #endif ) { perror("IPV6_HOPLIMIT"); exit(1); } if (!IN6_IS_ADDR_V4MAPPED(&(((struct sockaddr_in6 *)&target)->sin6_addr))) break; mapped = 1; /*FALLTHROUGH*/ case AF_INET: overhead = 28; if (!mtu) mtu = 65535; if (mtu <= overhead) goto pktlen_error; on = IP_PMTUDISC_DO; if (setsockopt(fd, SOL_IP, IP_MTU_DISCOVER, &on, sizeof(on))) { perror("IP_MTU_DISCOVER"); exit(1); } on = 1; if (setsockopt(fd, SOL_IP, IP_RECVERR, &on, sizeof(on))) { perror("IP_RECVERR"); exit(1); } if (setsockopt(fd, SOL_IP, IP_RECVTTL, &on, sizeof(on))) { perror("IP_RECVTTL"); exit(1); } } pktbuf = malloc(mtu); if (!pktbuf) { perror("malloc"); exit(1); } for (ttl = 1; ttl <= max_hops; ttl++) { int res; int i; on = ttl; switch (family) { case AF_INET6: if (setsockopt(fd, SOL_IPV6, IPV6_UNICAST_HOPS, &on, sizeof(on))) { perror("IPV6_UNICAST_HOPS"); exit(1); } if (!mapped) break; /*FALLTHROUGH*/ case AF_INET: if (setsockopt(fd, SOL_IP, IP_TTL, &on, sizeof(on))) { perror("IP_TTL"); exit(1); } } restart: for (i=0; i<3; i++) { int old_mtu; old_mtu = mtu; res = probe_ttl(fd, ttl); if (mtu != old_mtu) goto restart; if (res == 0) goto done; if (res > 0) break; } if (res < 0) printf("%2d: no reply\n", ttl); } printf(" Too many hops: pmtu %d\n", mtu); done: printf(" Resume: pmtu %d ", mtu); if (hops_to>=0) printf("hops %d ", hops_to); if (hops_from>=0) printf("back %d ", hops_from); printf("\n"); exit(0); pktlen_error: fprintf(stderr, "Error: pktlen must be > %d and <= %d\n", overhead, INT_MAX); exit(1); }
the_stack_data/41781.c
#include <stdlib.h> #include <stdio.h> #include <time.h> #include <x86intrin.h> #define N_MIN 256 #define N_MAX (32*1024*256) #define K 10 void DirectFill(int *arr, int n) { for(int i = 0; i < n - 1; i++) { arr[i] = i + 1; } arr[n - 1] = 0; } void ReverseFill(int *arr, int n) { for(int i = n; i > 1; i--) { arr[i] = i - 1; } arr[0] = n - 1; } void RandFill(int *arr, int n) { for(int i = 0; i < n; i++) { int j = rand()%(i+1); arr[j] = arr[i]; arr[i] = j; } } void PrintDetourTime(int *arr, int n) { long long total_time[K]; long long start; long long end; for(int i = 0; i < K; i++) { int index = 0; start = _rdtsc(); for(int j = 0; j < n; j++) { index = arr[index]; } end = _rdtsc(); total_time[i] = end - start; } } int main() { for(int i = N_MIN; i < N_MAX; i*=2) { int *arr = (int*)malloc(sizeof(int) * i); } }
the_stack_data/173578810.c
/* signames.c -- Create and write `signames.c', which contains an array of signal names. */ /* Copyright (C) 1992 Free Software Foundation, Inc. This file is part of GNU Bash, the Bourne Again SHell. Bash is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. Bash 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 Bash; see the file COPYING. If not, write to the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */ #include <stdio.h> #include <sys/types.h> #include <signal.h> #include <stdlib.h> #if !defined (NSIG) # define NSIG 64 #endif /* * Special traps: * EXIT == 0 */ #define LASTSIG NSIG-1 char *signal_names[2 * NSIG + 3]; #define signal_names_size (sizeof(signal_names)/sizeof(signal_names[0])) char *progname; /* AIX 4.3 defines SIGRTMIN and SIGRTMAX as 888 and 999 respectively. I don't want to allocate so much unused space for the intervening signal numbers, so we just punt if SIGRTMAX is past the bounds of the signal_names array (handled in configure). */ #if defined (SIGRTMAX) && defined (UNUSABLE_RT_SIGNALS) # undef SIGRTMAX # undef SIGRTMIN #endif #if defined (SIGRTMAX) || defined (SIGRTMIN) # define RTLEN 14 # define RTLIM 256 #endif void initialize_signames () { register int i; #if defined (SIGRTMAX) || defined (SIGRTMIN) int rtmin, rtmax, rtcnt; #endif for (i = 1; i < signal_names_size; i++) signal_names[i] = (char *)NULL; /* `signal' 0 is what we do on exit. */ signal_names[0] = "EXIT"; /* Place signal names which can be aliases for more common signal names first. This allows (for example) SIGABRT to overwrite SIGLOST. */ /* POSIX 1003.1b-1993 real time signals, but take care of incomplete implementations. Acoording to the standard, both, SIGRTMIN and SIGRTMAX must be defined, SIGRTMIN must be stricly less than SIGRTMAX, and the difference must be at least 7, that is, there must be at least eight distinct real time signals. */ /* The generated signal names are SIGRTMIN, SIGRTMIN+1, ..., SIGRTMIN+x, SIGRTMAX-x, ..., SIGRTMAX-1, SIGRTMAX. If the number of RT signals is odd, there is an extra SIGRTMIN+(x+1). These names are the ones used by ksh and /usr/xpg4/bin/sh on SunOS5. */ #if defined (SIGRTMIN) rtmin = SIGRTMIN; signal_names[rtmin] = "RTMIN"; #endif #if defined (SIGRTMAX) rtmax = SIGRTMAX; signal_names[rtmax] = "RTMAX"; #endif #if defined (SIGRTMAX) && defined (SIGRTMIN) if (rtmax > rtmin) { rtcnt = (rtmax - rtmin - 1) / 2; /* croak if there are too many RT signals */ if (rtcnt >= RTLIM/2) { rtcnt = RTLIM/2-1; fprintf(stderr, "%s: error: more than %i real time signals, fix `%s'\n", progname, RTLIM, progname); } for (i = 1; i <= rtcnt; i++) { signal_names[rtmin+i] = (char *)malloc(RTLEN); if (signal_names[rtmin+i]) sprintf (signal_names[rtmin+i], "RTMIN+%d", i); signal_names[rtmax-i] = (char *)malloc(RTLEN); if (signal_names[rtmax-i]) sprintf (signal_names[rtmax-i], "RTMAX-%d", i); } if (rtcnt < RTLIM/2-1 && rtcnt != (rtmax-rtmin)/2) { /* Need an extra RTMIN signal */ signal_names[rtmin+rtcnt+1] = (char *)malloc(RTLEN); if (signal_names[rtmin+rtcnt+1]) sprintf (signal_names[rtmin+rtcnt+1], "RTMIN+%d", rtcnt+1); } } #endif /* SIGRTMIN && SIGRTMAX */ /* AIX */ #if defined (SIGLOST) /* resource lost (eg, record-lock lost) */ signal_names[SIGLOST] = "LOST"; #endif #if defined (SIGMSG) /* HFT input data pending */ signal_names[SIGMSG] = "MSG"; #endif #if defined (SIGDANGER) /* system crash imminent */ signal_names[SIGDANGER] = "DANGER"; #endif #if defined (SIGMIGRATE) /* migrate process to another CPU */ signal_names[SIGMIGRATE] = "MIGRATE"; #endif #if defined (SIGPRE) /* programming error */ signal_names[SIGPRE] = "PRE"; #endif #if defined (SIGVIRT) /* AIX virtual time alarm */ signal_names[SIGVIRT] = "VIRT"; #endif #if defined (SIGALRM1) /* m:n condition variables */ signal_names[SIGALRM1] = "ALRM1"; #endif #if defined (SIGWAITING) /* m:n scheduling */ signal_names[SIGWAITING] = "WAITING"; #endif #if defined (SIGGRANT) /* HFT monitor mode granted */ signal_names[SIGGRANT] = "GRANT"; #endif #if defined (SIGKAP) /* keep alive poll from native keyboard */ signal_names[SIGKAP] = "KAP"; #endif #if defined (SIGRETRACT) /* HFT monitor mode retracted */ signal_names[SIGRETRACT] = "RETRACT"; #endif #if defined (SIGSOUND) /* HFT sound sequence has completed */ signal_names[SIGSOUND] = "SOUND"; #endif #if defined (SIGSAK) /* Secure Attention Key */ signal_names[SIGSAK] = "SAK"; #endif /* SunOS5 */ #if defined (SIGLWP) /* special signal used by thread library */ signal_names[SIGLWP] = "LWP"; #endif #if defined (SIGFREEZE) /* special signal used by CPR */ signal_names[SIGFREEZE] = "FREEZE"; #endif #if defined (SIGTHAW) /* special signal used by CPR */ signal_names[SIGTHAW] = "THAW"; #endif #if defined (SIGCANCEL) /* thread cancellation signal used by libthread */ signal_names[SIGCANCEL] = "CANCEL"; #endif /* HP-UX */ #if defined (SIGDIL) /* DIL signal (?) */ signal_names[SIGDIL] = "DIL"; #endif /* System V */ #if defined (SIGCLD) /* Like SIGCHLD. */ signal_names[SIGCLD] = "CLD"; #endif #if defined (SIGPWR) /* power state indication */ signal_names[SIGPWR] = "PWR"; #endif #if defined (SIGPOLL) /* Pollable event (for streams) */ signal_names[SIGPOLL] = "POLL"; #endif /* Unknown */ #if defined (SIGWINDOW) signal_names[SIGWINDOW] = "WINDOW"; #endif /* Common */ #if defined (SIGHUP) /* hangup */ signal_names[SIGHUP] = "HUP"; #endif #if defined (SIGINT) /* interrupt */ signal_names[SIGINT] = "INT"; #endif #if defined (SIGQUIT) /* quit */ signal_names[SIGQUIT] = "QUIT"; #endif #if defined (SIGILL) /* illegal instruction (not reset when caught) */ signal_names[SIGILL] = "ILL"; #endif #if defined (SIGTRAP) /* trace trap (not reset when caught) */ signal_names[SIGTRAP] = "TRAP"; #endif #if defined (SIGIOT) /* IOT instruction */ signal_names[SIGIOT] = "IOT"; #endif #if defined (SIGABRT) /* Cause current process to dump core. */ signal_names[SIGABRT] = "ABRT"; #endif #if defined (SIGEMT) /* EMT instruction */ signal_names[SIGEMT] = "EMT"; #endif #if defined (SIGFPE) /* floating point exception */ signal_names[SIGFPE] = "FPE"; #endif #if defined (SIGKILL) /* kill (cannot be caught or ignored) */ signal_names[SIGKILL] = "KILL"; #endif #if defined (SIGBUS) /* bus error */ signal_names[SIGBUS] = "BUS"; #endif #if defined (SIGSEGV) /* segmentation violation */ signal_names[SIGSEGV] = "SEGV"; #endif #if defined (SIGSYS) /* bad argument to system call */ signal_names[SIGSYS] = "SYS"; #endif #if defined (SIGPIPE) /* write on a pipe with no one to read it */ signal_names[SIGPIPE] = "PIPE"; #endif #if defined (SIGALRM) /* alarm clock */ signal_names[SIGALRM] = "ALRM"; #endif #if defined (SIGTERM) /* software termination signal from kill */ signal_names[SIGTERM] = "TERM"; #endif #if defined (SIGURG) /* urgent condition on IO channel */ signal_names[SIGURG] = "URG"; #endif #if defined (SIGSTOP) /* sendable stop signal not from tty */ signal_names[SIGSTOP] = "STOP"; #endif #if defined (SIGTSTP) /* stop signal from tty */ signal_names[SIGTSTP] = "TSTP"; #endif #if defined (SIGCONT) /* continue a stopped process */ signal_names[SIGCONT] = "CONT"; #endif #if defined (SIGCHLD) /* to parent on child stop or exit */ signal_names[SIGCHLD] = "CHLD"; #endif #if defined (SIGTTIN) /* to readers pgrp upon background tty read */ signal_names[SIGTTIN] = "TTIN"; #endif #if defined (SIGTTOU) /* like TTIN for output if (tp->t_local&LTOSTOP) */ signal_names[SIGTTOU] = "TTOU"; #endif #if defined (SIGIO) /* input/output possible signal */ signal_names[SIGIO] = "IO"; #endif #if defined (SIGXCPU) /* exceeded CPU time limit */ signal_names[SIGXCPU] = "XCPU"; #endif #if defined (SIGXFSZ) /* exceeded file size limit */ signal_names[SIGXFSZ] = "XFSZ"; #endif #if defined (SIGVTALRM) /* virtual time alarm */ signal_names[SIGVTALRM] = "VTALRM"; #endif #if defined (SIGPROF) /* profiling time alarm */ signal_names[SIGPROF] = "PROF"; #endif #if defined (SIGWINCH) /* window changed */ signal_names[SIGWINCH] = "WINCH"; #endif /* 4.4 BSD */ #if defined (SIGINFO) && !defined (_SEQUENT_) /* information request */ signal_names[SIGINFO] = "INFO"; #endif #if defined (SIGUSR1) /* user defined signal 1 */ signal_names[SIGUSR1] = "USR1"; #endif #if defined (SIGUSR2) /* user defined signal 2 */ signal_names[SIGUSR2] = "USR2"; #endif #if defined (SIGKILLTHR) /* BeOS: Kill Thread */ signal_names[SIGKILLTHR] = "KILLTHR"; #endif for (i = 0; i < NSIG; i++) if (signal_names[i] == (char *)NULL) { signal_names[i] = (char *)malloc (18); if (signal_names[i]) sprintf (signal_names[i], "%d", i); } } void write_signames (stream) FILE *stream; { register int i; fprintf (stream, "/* This file was automatically created by %s.\n", progname); fprintf (stream, " Do not edit. Edit support/mksignames.c instead. */\n\n"); fprintf (stream, "#include <signal.h>\n\n"); fprintf (stream, "/* A translation list so we can be polite to our users. */\n"); fprintf (stream, "const char *const signal_names[NSIG + 1] = {\n"); for (i = 0; i <= LASTSIG; i++) fprintf (stream, " \"%s\",\n", signal_names[i]); fprintf (stream, " (char *)0x0\n"); fprintf (stream, "};\n"); } int main(int argc, char **argv) { char *stream_name; FILE *stream; progname = argv[0]; if (argc == 1) { stream_name = "signames.c"; } else if (argc == 2) { stream_name = argv[1]; } else { fprintf (stderr, "Usage: %s [output-file]\n", progname); exit (1); } stream = fopen (stream_name, "w"); if (!stream) { fprintf (stderr, "%s: %s: cannot open for writing\n", progname, stream_name); exit (2); } initialize_signames (); write_signames (stream); exit (0); }
the_stack_data/9512135.c
/***********************************************************************************************//** * \file xensiv_bgt60trxx_mtb.c * * Description: This file contains the MTB platform functions implementation * for interacting with the XENSIV(TM) BGT60TRxx 60GHz FMCW radar sensors. * *************************************************************************************************** * \copyright * Copyright 2021 Infineon Technologies AG * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. **************************************************************************************************/ #if defined(CY_USING_HAL) #include "cyhal_system.h" #include "xensiv_bgt60trxx_mtb.h" #define XENSIV_BGT60TRXX_ERROR(x) (((x) == XENSIV_BGT60TRXX_STATUS_OK) ? CY_RSLT_SUCCESS :\ CY_RSLT_CREATE(CY_RSLT_TYPE_ERROR, CY_RSLT_MODULE_BOARD_HARDWARE_XENSIV_BGT60TRXX, (x))) static cy_rslt_t xensiv_bgt60trxx_mtb_hard_reset(const xensiv_bgt60trxx_mtb_t* obj); cy_rslt_t xensiv_bgt60trxx_mtb_init(xensiv_bgt60trxx_mtb_t* obj, cyhal_spi_t* spi, cyhal_gpio_t selpin, cyhal_gpio_t rstpin, const uint32_t* regs, size_t len) { CY_ASSERT(obj != NULL); CY_ASSERT(spi != NULL); CY_ASSERT(selpin != NC); CY_ASSERT(rstpin != NC); cy_rslt_t rslt; obj->selpin = NC; obj->rstpin = NC; rslt = cyhal_gpio_init(selpin, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, true); if (CY_RSLT_SUCCESS == rslt) { obj->selpin = selpin; obj->rstpin = NC; rslt = cyhal_gpio_init(rstpin, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, true); } if (CY_RSLT_SUCCESS == rslt) { obj->rstpin = rstpin; rslt = xensiv_bgt60trxx_mtb_hard_reset(obj); } if (CY_RSLT_SUCCESS == rslt) { obj->spi = spi; int32_t res = xensiv_bgt60trxx_init((xensiv_bgt60trxx_t)obj, regs, len); if (res != XENSIV_BGT60TRXX_STATUS_OK) { obj->spi = NULL; } rslt = XENSIV_BGT60TRXX_ERROR(res); } return rslt; } cy_rslt_t xensiv_bgt60trxx_mtb_interrupt_init(xensiv_bgt60trxx_mtb_t* obj, uint16_t fifo_limit, cyhal_gpio_t intpin, uint8_t intr_priority, xensiv_bgt60trxx_mtb_interrupt_cb_t* interrupt_cb) { CY_ASSERT(obj != NULL); CY_ASSERT(obj->spi != NULL); CY_ASSERT(interrupt_cb != NULL); obj->intpin = intpin; int32_t res = xensiv_bgt60trxx_set_fifo_limit((xensiv_bgt60trxx_t)obj, fifo_limit); cy_rslt_t rslt = XENSIV_BGT60TRXX_ERROR(res); if (CY_RSLT_SUCCESS == rslt) { rslt = cyhal_gpio_init(intpin, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLDOWN, false); if (rslt == CY_RSLT_SUCCESS) { #if defined(CYHAL_API_VERSION) && (CYHAL_API_VERSION >= 2) cyhal_gpio_register_callback(intpin, (cyhal_gpio_callback_data_t*)interrupt_cb); #else cyhal_gpio_register_callback(intpin, interrupt_cb->callback, interrupt_cb->callback_arg); #endif cyhal_gpio_enable_event(intpin, CYHAL_GPIO_IRQ_RISE, intr_priority, true); } } return rslt; } void xensiv_bgt60trxx_mtb_free(const xensiv_bgt60trxx_mtb_t* obj) { CY_ASSERT(obj != NULL); if (obj->selpin != NC) { cyhal_gpio_free(obj->selpin); } if (obj->rstpin != NC) { cyhal_gpio_free(obj->rstpin); } if (obj->intpin != NC) { cyhal_gpio_free(obj->intpin); } } static cy_rslt_t xensiv_bgt60trxx_mtb_hard_reset(const xensiv_bgt60trxx_mtb_t* obj) { CY_ASSERT(obj != NULL); CY_ASSERT(obj->rstpin != NC); CY_ASSERT(obj->selpin != NC); cyhal_gpio_t rstpin = obj->rstpin; cyhal_gpio_t selpin = obj->selpin; cyhal_gpio_write(selpin, 1); cyhal_gpio_write(rstpin, 1); cy_rslt_t rslt = cyhal_system_delay_ms(1); cyhal_gpio_write(rstpin, 0); rslt |= cyhal_system_delay_ms(1); cyhal_gpio_write(rstpin, 1); rslt |= cyhal_system_delay_ms(1); return rslt; } /********************** driver platform specific implementation ****************************/ #if !defined(XENSIV_BGT60TRXX_MTB_USE_DMA) int32_t xensiv_bgt60trxx_platform_spi_transfer(void* dev, const uint8_t* tx_data, uint32_t tx_len, uint8_t* rx_data, uint32_t rx_len) { CY_ASSERT(dev != NULL); CY_ASSERT((tx_data != NULL) || (rx_data != NULL)); xensiv_bgt60trxx_mtb_t* obj = (xensiv_bgt60trxx_mtb_t*)dev; cyhal_gpio_write(obj->selpin, 0); cy_rslt_t result = cyhal_spi_transfer(obj->spi, tx_data, (tx_data != NULL) ? tx_len : 0U, rx_data, (rx_data != NULL) ? rx_len : 0U, 0xFFU); cyhal_gpio_write(obj->selpin, 1); return ((CY_RSLT_SUCCESS == result) ? XENSIV_BGT60TRXX_STATUS_OK : XENSIV_BGT60TRXX_STATUS_SPI_ERROR); } #endif // if !defined(XENSIV_BGT60TRXX_MTB_USE_DMA) void xensiv_bgt60trxx_platform_delay(uint32_t ms) { (void)cyhal_system_delay_ms(ms); } uint32_t xensiv_bgt60trxx_platform_word_reverse(uint32_t x) { return __REV(x); } void xensiv_bgt60trxx_platform_assert(bool expr) { CY_ASSERT(expr); (void)expr; /* make release build */ } #endif // defined(CY_USING_HAL)
the_stack_data/111077746.c
/*- * Copyright (c) 1980 The Regents of the University of California. * All rights reserved. * * %sccs.include.proprietary.c% */ #ifndef lint static char sccsid[] = "@(#)hl_le.c 5.2 (Berkeley) 04/12/91"; #endif /* not lint */ short hl_le(a,b,la,lb) char *a, *b; long int la, lb; { return(s_cmp(a,b,la,lb) <= 0); }
the_stack_data/87609.c
/* print name x until y number 1 - 9 => print name of the number number >9 => print odd or even Sample Input : 2 15 Sample Output : two three four five six seven eight nine even odd even odd even odd */ #include <stdio.h> int main() { int c, b; scanf("%d%d", &c, &b); int i; int d = b-c+1; for(i=0;i<d;i++) { if(c==1) printf("one\n"); else if(c==2) printf("two\n"); else if(c==3) printf("three\n"); else if(c==4) printf("four\n"); else if(c==5) printf("five\n"); else if(c==6) printf("six\n"); else if(c==7) printf("seven\n"); else if(c==8) printf("eight\n"); else if(c==9) printf("nine\n"); else { if(c%2==0) printf("even\n"); else printf("odd\n"); } c++; } return 0; }
the_stack_data/82950935.c
#include <stdio.h> #if !defined(USE_SEMIHOST) && !defined(USE_NOHOST) /* Read from a file. -------------------------------------------------------- */ __attribute__((weak)) size_t __read( int file, char *buf, size_t size ) { (void) file; (void) buf; (void) size; return 0; } /* Write to a file. --------------------------------------------------------- */ __attribute__((weak)) size_t __write( int file, const char *buf, size_t size ) { if (file == -1) return -1U; // flush (void) buf; return size; } /* -------------------------------------------------------------------------- */ #endif // !USE_SEMIHOST && !USE_NOHOST
the_stack_data/86581.c
#include <stdio.h> int main(int argc, char** argv) { printf("1..1\n"); printf("ok 1 - hello world\n"); return 0; }
the_stack_data/121872.c
#include <stdio.h> #include <stdlib.h> int main() { struct { char nome[80]; int idade; } reg; strcpy(reg.nome,"Maria"); reg.idade = 24; printf("%s", reg.nome); printf(" tem "); printf("%d", reg.idade); printf(" anos"); return 0; }
the_stack_data/40409.c
/* Test step/next in presence of #line directives. Copyright (C) 2001-2017 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/>. */ void dummy (int, int); int f1 (int); int f2 (int); int main (int argc, char **argv) { int i; i = f1 (4); i = f1 (i); dummy (0, i); return 0; } int f1 (int i) { #line 40 "step-line.c" dummy (1, i); #line 24 "step-line.inp" i = f2 (i); #line 44 "step-line.c" dummy (2, i); #line 25 "step-line.inp" i = f2 (i); #line 48 "step-line.c" dummy (3, i); #line 26 "step-line.inp" return i; #line 52 "step-line.c" } int f2 (int i) { #line 31 "step-line.inp" int j; #line 60 "step-line.c" dummy (4, i); #line 32 "step-line.inp" j = i; #line 64 "step-line.c" dummy (5, i); dummy (6, j); #line 33 "step-line.inp" j = j + 1; #line 69 "step-line.c" dummy (7, i); dummy (8, j); #line 34 "step-line.inp" j = j - i; #line 74 "step-line.c" dummy (9, i); dummy (10, j); #line 35 "step-line.inp" return i; #line 79 "step-line.c" } void dummy (int num, int i) { }
the_stack_data/165765262.c
#include <stdio.h> int add2(int x, int y); int main(){ int x, y; scanf("%d%d", &x, &y); printf("%d\n", add2(x, y)); return 0; }
the_stack_data/491921.c
/**~action~ * AcceptEventAction [Class] * * Description * * An AcceptEventAction is an Action that waits for the occurrence of one or more specific Events. * * Diagrams * * Accept Event Actions * * Generalizations * * Action * * Specializations * * AcceptCallAction * * Attributes * *  isUnmarshall : Boolean [1..1] = false * * Indicates whether there is a single OutputPin for a SignalEvent occurrence, or multiple OutputPins for attribute * values of the instance of the Signal associated with a SignalEvent occurrence. * * Association Ends * *  ♦ result : OutputPin [0..*]{ordered, subsets Action::output} (opposite * A_result_acceptEventAction::acceptEventAction) * * OutputPins holding the values received from an Event occurrence. * *  ♦ trigger : Trigger [1..*]{subsets Element::ownedElement} (opposite * A_trigger_acceptEventAction::acceptEventAction) * * The Triggers specifying the Events of which the AcceptEventAction waits for occurrences. * * Constraints * *  one_output_pin * * If isUnmarshall=false and any of the triggers are for SignalEvents or TimeEvents, there must be exactly one * result OutputPin with multiplicity 1..1. * * inv: not isUnmarshall and trigger->exists(event.oclIsKindOf(SignalEvent) or * event.oclIsKindOf(TimeEvent)) implies * output->size() = 1 and output->first().is(1,1) * *  no_input_pins * * AcceptEventActions may have no input pins. * inv: input->size() = 0 * *  no_output_pins * * There are no OutputPins if the trigger events are only ChangeEvents and/or CallEvents when this action is an * instance of AcceptEventAction and not an instance of a descendant of AcceptEventAction (such as * AcceptCallAction). * * inv: (self.oclIsTypeOf(AcceptEventAction) and * (trigger->forAll(event.oclIsKindOf(ChangeEvent) or * event.oclIsKindOf(CallEvent)))) * implies output->size() = 0 * *  unmarshall_signal_events * * If isUnmarshall is true (and this is not an AcceptCallAction), there must be exactly one trigger, which is for a * SignalEvent. The number of result output pins must be the same as the number of attributes of the signal. The * type and ordering of each result output pin must be the same as the corresponding attribute of the signal. The * multiplicity of each result output pin must be compatible with the multiplicity of the corresponding attribute. * * inv: isUnmarshall and self.oclIsTypeOf(AcceptEventAction) implies * trigger->size()=1 and * trigger->asSequence()->first().event.oclIsKindOf(SignalEvent) and * let attribute: OrderedSet(Property) = trigger->asSequence()- * >first().event.oclAsType(SignalEvent).signal.allAttributes() in * attribute->size()>0 and result->size() = attribute->size() and * Sequence{1..result->size()}->forAll(i | * result->at(i).type = attribute->at(i).type and * result->at(i).isOrdered = attribute->at(i).isOrdered and * result->at(i).includesMultiplicity(attribute->at(i))) * *  conforming_type * * If isUnmarshall=false and all the triggers are for SignalEvents, then the type of the single result OutputPin * must either be null or all the signals must conform to it. * * inv: not isUnmarshall implies * result->isEmpty() or * let type: Type = result->first().type in * type=null or * (trigger->forAll(event.oclIsKindOf(SignalEvent)) and * trigger.event.oclAsType(SignalEvent).signal->forAll(s | s.conformsTo(type))) **/
the_stack_data/10841.c
/* $OpenBSD: strlcpy.c,v 1.11 2006/05/05 15:27:38 millert Exp $ */ /* * Copyright (c) 1998 Todd C. Miller <[email protected]> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ //#include <sys/cdefs.h> //__FBSDID("$FreeBSD$"); // //#include <sys/types.h> #include <string.h> /* * Copy src to string dst of size siz. At most siz-1 characters * will be copied. Always NUL terminates (unless siz == 0). * Returns strlen(src); if retval >= siz, truncation occurred. */ size_t strlcpy(char * __restrict dst, const char * __restrict src, size_t siz) { char *d = dst; const char *s = src; size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0) { while (--n != 0) { if ((*d++ = *s++) == '\0') break; } } /* Not enough room in dst, add NUL and traverse rest of src */ if (n == 0) { if (siz != 0) *d = '\0'; /* NUL-terminate dst */ while (*s++) ; } return(s - src - 1); /* count does not include NUL */ }
the_stack_data/98745.c
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_itox.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: jihhan <[email protected]> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2020/09/13 16:05:52 by jihhan #+# #+# */ /* Updated: 2020/09/13 16:06:31 by jihhan ### ########.fr */ /* */ /* ************************************************************************** */ #include <string.h> char *ft_itox(int n) { char ret[3]; char key; if (n < 0 || n > 127) return (NULL); ret[0] = '0'; ret[1] = '0'; if (n) { key = n / 16; ret[0] = '0' + key; if (key > 9) ret[0] = 'a' + (key - 10); key = n % 16; ret[1] = '0' + key; if (key > 9) ret[1] = 'a' + (key - 10); } ret[2] = '\0'; return (strdup(ret)); }
the_stack_data/885228.c
int main() { return 1*2+3*4+5*6+7*8; }
the_stack_data/750402.c
int main(){5+20-4;}
the_stack_data/7442.c
#include <stdio.h> #define MAX (100000) #define INVALID (-1) struct NODE { int left; int right; int value; struct NODE *left_node; struct NODE *right_node; }; struct NODE max_tree[(MAX + 1) * 2 + 1]; struct NODE min_tree[(MAX + 1) * 2 + 1]; int N, Q; int index; int buffer[MAX + 1]; struct NODE * init(struct NODE tree[], int left, int right) { struct NODE *ret; ret = &tree[index++]; ret->left = left; ret->right = right; ret->value = INVALID; if (left < right) { ret->left_node = init(tree, left, (left + right) / 2); ret->right_node = init(tree, (left + right) / 2 + 1, right); } else { ret->left_node = NULL; ret->right_node = NULL; } return ret; } int insert_max_tree(struct NODE *nd) { int val, ret; if (nd->left_node != NULL) val = insert_max_tree(nd->left_node); else val = INVALID; if (nd->right_node != NULL) { ret = insert_max_tree(nd->right_node); if ((val == INVALID) || (val < ret)) val = ret; } if (val == INVALID) nd->value = buffer[nd->left]; else nd->value = val; return nd->value; } int insert_min_tree(struct NODE *nd) { int val, ret; if (nd->left_node != NULL) val = insert_min_tree(nd->left_node); else val = INVALID; if (nd->right_node != NULL) { ret = insert_min_tree(nd->right_node); if ((val == INVALID) || (val > ret)) val = ret; } if (val == INVALID) nd->value = buffer[nd->left]; else nd->value = val; return nd->value; return nd->value; } int find_max_tree(struct NODE *nd, int left, int right) { int ret1, ret2; if ((nd->left == left) && (nd->right == right)) { return nd->value; } else { ret1 = INVALID; ret2 = INVALID; if ((nd->left_node != NULL) && (left <= nd->left_node->right)) { ret1 = find_max_tree(nd->left_node, left, ((right < nd->left_node->right) ? (right) : (nd->left_node->right))); } if ((nd->right_node != NULL) && (right >= nd->right_node->left)) { ret2 = find_max_tree(nd->right_node, ((left > nd->right_node->left) ? (left) : (nd->right_node->left)), right); } } if (ret1 == INVALID) return ret2; else if (ret2 == INVALID) return ret1; else return ((ret1 > ret2) ? ret1 : ret2); } int find_min_tree(struct NODE *nd, int left, int right) { int ret1, ret2; if ((nd->left == left) && (nd->right == right)) { return nd->value; } else { ret1 = INVALID; ret2 = INVALID; if ((nd->left_node != NULL) && (left <= nd->left_node->right)) { ret1 = find_min_tree(nd->left_node, left, ((right < nd->left_node->right) ? (right) : (nd->left_node->right))); } if ((nd->right_node != NULL) && (right >= nd->right_node->left)) { ret2 = find_min_tree(nd->right_node, ((left > nd->right_node->left) ? (left) : (nd->right_node->left)), right); } } if (ret1 == INVALID) return ret2; else if (ret2 == INVALID) return ret1; else return ((ret1 < ret2) ? ret1 : ret2); } int main(void) { int tc, T; int i, a, b; // freopen("sample_input.txt", "r", stdin); setbuf(stdout, NULL); scanf("%d", &T); for (tc = 0; tc < T; ++tc) { scanf("%d %d\n", &N, &Q); index = 0; init(min_tree, 0, N - 1); index = 0; init(max_tree, 0, N - 1); for (i = 0; i < N; ++i) { scanf("%d", &buffer[i]); } insert_max_tree(&max_tree[0]); insert_min_tree(&min_tree[0]); for (i = 0; i < Q; ++i) { scanf("%d %d\n", &a, &b); printf("%d\n", find_max_tree(&max_tree[0], a, b) - find_min_tree(&min_tree[0], a, b)); } } return 0; }
the_stack_data/3263152.c
int main() { unsigned int i0 ; unsigned int i1 ; unsigned int i2 ; int i3 ; int i4 ; int i5 ; int i6 ; { i0 = 256U; i1 = i0 + 1024U; i2 = i1 + 4294967040U; i3 = 256; i4 = i3 + 1024; i5 = i4 + -2048; i6 = i5 + -2147483648; return i6; } }
the_stack_data/78203.c
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> int main (void) { pid_t childpid; /* set up signal handlers here ... */ childpid = fork(); if (childpid == -1) { perror("Failed to fork"); return 1; } if (childpid == 0) fprintf(stderr, "I am child %ld\n", (long)getpid()); else if (wait(NULL) != childpid) fprintf(stderr, "A signal must have interrupted the wait!\n"); else fprintf(stderr, "I am parent %ld with child %ld\n", (long)getpid(), (long)childpid); return 0; }
the_stack_data/211079555.c
#include <stdio.h> #include <stdlib.h> #define SUCCESS 1 #define UNSUCCESS 0 #define HASHSIZE 12 #define NULLKEY -32768 #define OK 1 #define ERROR 0 typedef int Status; typedef struct { int *elem; int count; } HashTable; int m = 0; Status InitHashTable(HashTable *H) { int i; m = HASHSIZE; H->count = m; H->elem = (int *)malloc(m * sizeof(int)); for (i=0; i<m; i++) { H->elem[i] = NULLKEY; } return OK; } int Hash(int key) { return key % m; } void InsertHash(HashTable *H, int key) { int addr = Hash(key); while (H->elem[addr] != NULLKEY) { addr = (addr + 1) % m; } H->elem[addr] = key; } Status SearchHash(HashTable H, int key, int *addr) { *addr = Hash(key); while (H.elem[*addr] != key) { *addr = (*addr + 1) % m; if (H.elem[*addr] == NULLKEY || *addr == Hash(key)) { return UNSUCCESS; } } return SUCCESS; }
the_stack_data/243893071.c
#include <stdio.h> int main() { printf("this is a new HW feature 2\n"); }
the_stack_data/140766056.c
/* Generated by CIL v. 1.7.0 */ /* print_CIL_Input is false */ struct _IO_FILE; struct timeval; extern void signal(int sig , void *func ) ; extern float strtof(char const *str , char const *endptr ) ; typedef struct _IO_FILE FILE; extern int atoi(char const *s ) ; extern double strtod(char const *str , char const *endptr ) ; extern int fclose(void *stream ) ; extern void *fopen(char const *filename , char const *mode ) ; extern void abort() ; extern void exit(int status ) ; extern int raise(int sig ) ; extern int fprintf(struct _IO_FILE *stream , char const *format , ...) ; extern int strcmp(char const *a , char const *b ) ; extern int rand() ; extern unsigned long strtoul(char const *str , char const *endptr , int base ) ; void RandomFunc(unsigned long input[1] , unsigned long output[1] ) ; extern int strncmp(char const *s1 , char const *s2 , unsigned long maxlen ) ; extern int gettimeofday(struct timeval *tv , void *tz , ...) ; extern int printf(char const *format , ...) ; int main(int argc , char *argv[] ) ; void megaInit(void) ; extern unsigned long strlen(char const *s ) ; extern long strtol(char const *str , char const *endptr , int base ) ; extern unsigned long strnlen(char const *s , unsigned long maxlen ) ; extern void *memcpy(void *s1 , void const *s2 , unsigned long size ) ; struct timeval { long tv_sec ; long tv_usec ; }; extern void *malloc(unsigned long size ) ; extern int scanf(char const *format , ...) ; int main(int argc , char *argv[] ) { unsigned long input[1] ; unsigned long output[1] ; int randomFuns_i5 ; unsigned long randomFuns_value6 ; int randomFuns_main_i7 ; { megaInit(); if (argc != 2) { printf("Call this program with %i arguments\n", 1); exit(-1); } else { } randomFuns_i5 = 0; while (randomFuns_i5 < 1) { randomFuns_value6 = strtoul(argv[randomFuns_i5 + 1], 0, 10); input[randomFuns_i5] = randomFuns_value6; randomFuns_i5 ++; } RandomFunc(input, output); if (output[0] == 18366963008423553463UL) { printf("You win!\n"); } else { } randomFuns_main_i7 = 0; while (randomFuns_main_i7 < 1) { printf("%lu\n", output[randomFuns_main_i7]); randomFuns_main_i7 ++; } } } void megaInit(void) { { } } void RandomFunc(unsigned long input[1] , unsigned long output[1] ) { unsigned long state[1] ; unsigned long local1 ; char copy12 ; { state[0UL] = (input[0UL] - 51238316UL) - 339126204UL; local1 = 0UL; while (local1 < input[1UL]) { copy12 = *((char *)(& state[0UL]) + 0); *((char *)(& state[0UL]) + 0) = *((char *)(& state[0UL]) + 5); *((char *)(& state[0UL]) + 5) = copy12; local1 ++; } output[0UL] = (state[0UL] | 985731240UL) * 947879471UL; } }
the_stack_data/12512.c
int f() { 2 + 2; return; } int main() { f(); return 0; }
the_stack_data/35254.c
/* Copyright (C) 2000, 2001, 2003 Free Software Foundation. Ensure all expected transformations of builtin strncmp occur and perform correctly. Written by Kaveh R. Ghazi, 11/26/2000. */ extern void abort (void); typedef __SIZE_TYPE__ size_t; extern int strncmp (const char *, const char *, size_t); void main_test (void) { const char *const s1 = "hello world"; const char *s2, *s3; if (strncmp (s1, "hello world", 12) != 0) abort(); if (strncmp ("hello world", s1, 12) != 0) abort(); if (strncmp ("hello", "hello", 6) != 0) abort(); if (strncmp ("hello", "hello", 2) != 0) abort(); if (strncmp ("hello", "hello", 100) != 0) abort(); if (strncmp (s1+10, "d", 100) != 0) abort(); if (strncmp (10+s1, "d", 100) != 0) abort(); if (strncmp ("d", s1+10, 1) != 0) abort(); if (strncmp ("d", 10+s1, 1) != 0) abort(); if (strncmp ("hello", "aaaaa", 100) <= 0) abort(); if (strncmp ("aaaaa", "hello", 100) >= 0) abort(); if (strncmp ("hello", "aaaaa", 1) <= 0) abort(); if (strncmp ("aaaaa", "hello", 1) >= 0) abort(); s2 = s1; s3 = s1+4; if (strncmp (++s2, ++s3, 0) != 0 || s2 != s1+1 || s3 != s1+5) abort(); s2 = s1; if (strncmp (++s2, "", 1) <= 0 || s2 != s1+1) abort(); if (strncmp ("", ++s2, 1) >= 0 || s2 != s1+2) abort(); if (strncmp (++s2, "", 100) <= 0 || s2 != s1+3) abort(); if (strncmp ("", ++s2, 100) >= 0 || s2 != s1+4) abort(); if (strncmp (++s2+6, "", 100) != 0 || s2 != s1+5) abort(); if (strncmp ("", ++s2+5, 100) != 0 || s2 != s1+6) abort(); if (strncmp ("ozz", ++s2, 1) != 0 || s2 != s1+7) abort(); if (strncmp (++s2, "rzz", 1) != 0 || s2 != s1+8) abort(); s2 = s1; s3 = s1+4; if (strncmp (++s2, ++s3+2, 1) >= 0 || s2 != s1+1 || s3 != s1+5) abort(); /* Test at least one instance of the __builtin_ style. We do this to ensure that it works and that the prototype is correct. */ if (__builtin_strncmp ("hello", "a", 100) <= 0) abort(); }
the_stack_data/72012845.c
/* Sample TCP client */ #include <sys/socket.h> #include <netinet/in.h> #include <stdio.h> int main(int argc, char**argv) { int sockfd,n; struct sockaddr_in servaddr; char * sendline; // sendline = "hellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellohellolohellohellohellohellohellohellohellohellohellolohellohellohellohellohellohellohellohellohellolohellohellohellohellohellohellohellohellohellolo\r\n"; //sendline = "{\"cmd\":\"relaymsg\", \"to_pubkey_sha256\":\"SHA256 DIGEST OUTPUT\", \"to_message\":\"YHxkTtaZJJJgxmkmMcyNWRjC5Dw4KQCJJjc3BlBFCJPnEsTOAL0800AWwsuD3ztsXnOOhITjuxPRYggepL0lomMoKS2y68X0YutB1wHeWJauRDfY93NVAsvkVa7IiVrfj6HzSdCCA5bL3LfADGjChLMAVpaAQMgAGzwIef0wwBONQ7qtE9Si73cze47PlyI1LJtTJjVKJyHpCpLsVBLXRi0RWNDJCrBnyYCKGayXDy4RVdy9O4dnCY635HaP2zQXewvDbDcg1udM26BooWuw01C3HrgklELHFJQGiM3KirHl00D1H4xuMuow8FLQPdzmCwTBul7ftKWDJwms2Upz8DYmZKOBnQzRwl1AyCfuWsePpw78yRaDvoKy8o5YdSwATk1VaaJDWaykkbRS4cc8lcPOn05PNdpyWGTsM2qJfWo0VLH6o9s7DFSqOzADgDqIo5iArhXLtHuY3CbEo7lqLZ7bVXhCU1Gm3Plt4csuQ1onG9522Ad1tG6Gtdez1Q2dX5n8IcTW0pUrcVKTZdO8YZ4w0HUNL25OcDle7gmzkIgid036j9LpDk52gck8RShQMj8BApM9sSLrDujQzI7J9KQvfOnGHsY86Ph1SPFwgbjm1W3Kz49dEva9yXOLE3M9kIAPP2pvwcwGy5gwwlR4n7Hdbollx7RDrTe5JvHPWJN6hJqcbQzCFcTiW2TVPC9hbqbRDZzB7kZfF2R0vt9IKcnafLOEHH1MI58Av7Dxqikb7SG7TLNKjwEDQfjyCmJOFHp52Fa5OyhoLBmgBRyp7EDW6BCyCiPng58xWbZB6XgXF8UluqiPZzqQ8dzR2mgsHZZzGgpROIBI7H6dBnm9QxWhRIDlE6TfT9VrHTOjXXS558Zba6M8xATI73yNGrGOVxVrm0AgXyKxQKXvEZY28bEdA7LkQwalZWGbv1KqquJn4RDcYXD1iNPDPgRupPmBvgnPCUwi9zeb2lIE5o93Jp7aJWHobrhe4TE4j8Qjgp19fmJF7gSyb0n0SxawF8aPv6lHQn9wuG2iJwaGdsxboyzy3xWA2zFt0edqBHLbZvQ4DuURi7yDsNLvA80j46FDMYmbWzjduGKezq5R88tyrIBfxdfZTC9LwHlsB2zhI02fUSjj53NlQGvn3jfkUuGiotbOSILmIdnBEOqidDHIgrG9U5W9lwW6WfeoRI5e21sQYtPRvr5uCkzo9KPRPgri5zeMSYNdvailLyajPUrtV9OQrbNPeBv8fXYyZz61omQUS\"}\r\n"; sendline = "{\"cmd\":\"identupdate\", \"public_key\":\"sGuLWerX\"}\n"; sockfd=socket(AF_INET,SOCK_STREAM,0); memset(&servaddr, 0, sizeof(servaddr)); servaddr.sin_family = AF_INET; servaddr.sin_addr.s_addr=inet_addr("127.0.0.1"); servaddr.sin_port=htons(8024); int connect_status = connect(sockfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); printf("%d\n", connect_status); int send_status = send(sockfd,sendline,strlen(sendline),0); printf("%d\n", send_status); char buffer[1024]; char buff[1024]; int continue_recieve = 1; while(continue_recieve == 1){ int num = recv(sockfd, buffer, 1, 0); if(num <= 0){ printf("Either Connection Closed or Error\n"); }else{ if(strcmp(buffer, "}") == 0){ continue_recieve = 0; } buffer[num] = '\0'; printf("%s\n",buffer); } } printf("END\n"); return 0; }
the_stack_data/159515177.c
/** ****************************************************************************** * @file stm32wbxx_ll_rtc.c * @author MCD Application Team * @brief RTC LL module driver. ****************************************************************************** * @attention * * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. * All rights reserved.</center></h2> * * This software component is licensed by ST under BSD 3-Clause license, * the "License"; You may not use this file except in compliance with the * License. You may obtain a copy of the License at: * opensource.org/licenses/BSD-3-Clause * ****************************************************************************** */ #if defined(USE_FULL_LL_DRIVER) /* Includes ------------------------------------------------------------------*/ #include "stm32wbxx_ll_rtc.h" #include "stm32wbxx_ll_cortex.h" #ifdef USE_FULL_ASSERT #include "stm32_assert.h" #else #define assert_param(expr) ((void)0U) #endif /** @addtogroup STM32WBxx_LL_Driver * @{ */ #if defined(RTC) /** @addtogroup RTC_LL * @{ */ /* Private types -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private constants ---------------------------------------------------------*/ /** @addtogroup RTC_LL_Private_Constants * @{ */ /* Default values used for prescaler */ #define RTC_ASYNCH_PRESC_DEFAULT 0x0000007FU #define RTC_SYNCH_PRESC_DEFAULT 0x000000FFU /* Values used for timeout */ #define RTC_INITMODE_TIMEOUT 1000U /* 1s when tick set to 1ms */ #define RTC_SYNCHRO_TIMEOUT 1000U /* 1s when tick set to 1ms */ /** * @} */ /* Private macros ------------------------------------------------------------*/ /** @addtogroup RTC_LL_Private_Macros * @{ */ #define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \ || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM)) #define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FU) #define IS_LL_RTC_SYNCH_PREDIV(__VALUE__) ((__VALUE__) <= 0x7FFFU) #define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \ || ((__VALUE__) == LL_RTC_FORMAT_BCD)) #define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \ || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM)) #define IS_LL_RTC_HOUR12(__HOUR__) (((__HOUR__) > 0U) && ((__HOUR__) <= 12U)) #define IS_LL_RTC_HOUR24(__HOUR__) ((__HOUR__) <= 23U) #define IS_LL_RTC_MINUTES(__MINUTES__) ((__MINUTES__) <= 59U) #define IS_LL_RTC_SECONDS(__SECONDS__) ((__SECONDS__) <= 59U) #define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \ || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \ || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \ || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \ || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \ || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \ || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY)) #define IS_LL_RTC_DAY(__DAY__) (((__DAY__) >= 1U) && ((__DAY__) <= 31U)) #define IS_LL_RTC_MONTH(__VALUE__) (((__VALUE__) == LL_RTC_MONTH_JANUARY) \ || ((__VALUE__) == LL_RTC_MONTH_FEBRUARY) \ || ((__VALUE__) == LL_RTC_MONTH_MARCH) \ || ((__VALUE__) == LL_RTC_MONTH_APRIL) \ || ((__VALUE__) == LL_RTC_MONTH_MAY) \ || ((__VALUE__) == LL_RTC_MONTH_JUNE) \ || ((__VALUE__) == LL_RTC_MONTH_JULY) \ || ((__VALUE__) == LL_RTC_MONTH_AUGUST) \ || ((__VALUE__) == LL_RTC_MONTH_SEPTEMBER) \ || ((__VALUE__) == LL_RTC_MONTH_OCTOBER) \ || ((__VALUE__) == LL_RTC_MONTH_NOVEMBER) \ || ((__VALUE__) == LL_RTC_MONTH_DECEMBER)) #define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U) #define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \ || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \ || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \ || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \ || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \ || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL)) #define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \ || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \ || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \ || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \ || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \ || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL)) #define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \ ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY)) #define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \ ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY)) /** * @} */ /* Private function prototypes -----------------------------------------------*/ /* Exported functions --------------------------------------------------------*/ /** @addtogroup RTC_LL_Exported_Functions * @{ */ /** @addtogroup RTC_LL_EF_Init * @{ */ /** * @brief De-Initializes the RTC registers to their default reset values. * @note This function doesn't reset the RTC Clock source and RTC Backup Data * registers. * @param RTCx RTC Instance * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC registers are de-initialized * - ERROR: RTC registers are not de-initialized */ ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx) { ErrorStatus status = ERROR; /* Check the parameter */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); /* Disable the write protection for RTC registers */ LL_RTC_DisableWriteProtection(RTCx); /* Set Initialization mode */ if (LL_RTC_EnterInitMode(RTCx) != ERROR) { /* Reset TR, DR and CR registers */ WRITE_REG(RTCx->TR, 0x00000000U); #if defined(RTC_WAKEUP_SUPPORT) WRITE_REG(RTCx->WUTR, RTC_WUTR_WUT); #endif /* RTC_WAKEUP_SUPPORT */ WRITE_REG(RTCx->DR, (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0)); /* Reset All CR bits except CR[2:0] */ #if defined(RTC_WAKEUP_SUPPORT) WRITE_REG(RTCx->CR, (READ_REG(RTCx->CR) & RTC_CR_WUCKSEL)); #else WRITE_REG(RTCx, CR, 0x00000000U); #endif /* RTC_WAKEUP_SUPPORT */ WRITE_REG(RTCx->PRER, (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT)); WRITE_REG(RTCx->ALRMAR, 0x00000000U); WRITE_REG(RTCx->ALRMBR, 0x00000000U); WRITE_REG(RTCx->SHIFTR, 0x00000000U); WRITE_REG(RTCx->CALR, 0x00000000U); WRITE_REG(RTCx->ALRMASSR, 0x00000000U); WRITE_REG(RTCx->ALRMBSSR, 0x00000000U); /* Reset ISR register and exit initialization mode */ WRITE_REG(RTCx->ISR, 0x00000000U); /* Reset Tamper and alternate functions configuration register */ WRITE_REG(RTCx->TAMPCR, 0x00000000U); /* Reset Option register */ WRITE_REG(RTCx->OR, 0x00000000U); /* Wait till the RTC RSF flag is set */ status = LL_RTC_WaitForSynchro(RTCx); } /* Enable the write protection for RTC registers */ LL_RTC_EnableWriteProtection(RTCx); return status; } /** * @brief Initializes the RTC registers according to the specified parameters * in RTC_InitStruct. * @param RTCx RTC Instance * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains * the configuration information for the RTC peripheral. * @note The RTC Prescaler register is write protected and can be written in * initialization mode only. * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC registers are initialized * - ERROR: RTC registers are not initialized */ ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct) { ErrorStatus status = ERROR; /* Check the parameters */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->HourFormat)); assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler)); assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->SynchPrescaler)); /* Disable the write protection for RTC registers */ LL_RTC_DisableWriteProtection(RTCx); /* Set Initialization mode */ if (LL_RTC_EnterInitMode(RTCx) != ERROR) { /* Set Hour Format */ LL_RTC_SetHourFormat(RTCx, RTC_InitStruct->HourFormat); /* Configure Synchronous and Asynchronous prescaler factor */ LL_RTC_SetSynchPrescaler(RTCx, RTC_InitStruct->SynchPrescaler); LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler); /* Exit Initialization mode */ LL_RTC_DisableInitMode(RTCx); status = SUCCESS; } /* Enable the write protection for RTC registers */ LL_RTC_EnableWriteProtection(RTCx); return status; } /** * @brief Set each @ref LL_RTC_InitTypeDef field to default value. * @param RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized. * @retval None */ void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct) { /* Set RTC_InitStruct fields to default values */ RTC_InitStruct->HourFormat = LL_RTC_HOURFORMAT_24HOUR; RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT; RTC_InitStruct->SynchPrescaler = RTC_SYNCH_PRESC_DEFAULT; } /** * @brief Set the RTC current time. * @param RTCx RTC Instance * @param RTC_Format This parameter can be one of the following values: * @arg @ref LL_RTC_FORMAT_BIN * @arg @ref LL_RTC_FORMAT_BCD * @param RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains * the time configuration information for the RTC. * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC Time register is configured * - ERROR: RTC Time register is not configured */ ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct) { ErrorStatus status = ERROR; /* Check the parameters */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); assert_param(IS_LL_RTC_FORMAT(RTC_Format)); if (RTC_Format == LL_RTC_FORMAT_BIN) { if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) { assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->Hours)); assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); } else { RTC_TimeStruct->TimeFormat = 0x00U; assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours)); } assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes)); assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds)); } else { if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) { assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat)); } else { RTC_TimeStruct->TimeFormat = 0x00U; assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours))); } assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes))); assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds))); } /* Disable the write protection for RTC registers */ LL_RTC_DisableWriteProtection(RTCx); /* Set Initialization mode */ if (LL_RTC_EnterInitMode(RTCx) != ERROR) { /* Check the input parameters format */ if (RTC_Format != LL_RTC_FORMAT_BIN) { LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, RTC_TimeStruct->Hours, RTC_TimeStruct->Minutes, RTC_TimeStruct->Seconds); } else { LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Hours), __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Minutes), __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Seconds)); } /* Exit Initialization mode */ LL_RTC_DisableInitMode(RTCx); /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) { status = LL_RTC_WaitForSynchro(RTCx); } else { status = SUCCESS; } } /* Enable the write protection for RTC registers */ LL_RTC_EnableWriteProtection(RTCx); return status; } /** * @brief Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec). * @param RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized. * @retval None */ void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct) { /* Time = 00h:00min:00sec */ RTC_TimeStruct->TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24; RTC_TimeStruct->Hours = 0U; RTC_TimeStruct->Minutes = 0U; RTC_TimeStruct->Seconds = 0U; } /** * @brief Set the RTC current date. * @param RTCx RTC Instance * @param RTC_Format This parameter can be one of the following values: * @arg @ref LL_RTC_FORMAT_BIN * @arg @ref LL_RTC_FORMAT_BCD * @param RTC_DateStruct pointer to a RTC_DateTypeDef structure that contains * the date configuration information for the RTC. * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC Day register is configured * - ERROR: RTC Day register is not configured */ ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct) { ErrorStatus status = ERROR; /* Check the parameters */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); assert_param(IS_LL_RTC_FORMAT(RTC_Format)); if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U)) { RTC_DateStruct->Month = (RTC_DateStruct->Month & (uint8_t)~(0x10U)) + 0x0AU; } if (RTC_Format == LL_RTC_FORMAT_BIN) { assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->Year)); assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month)); assert_param(IS_LL_RTC_DAY(RTC_DateStruct->Day)); } else { assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Year))); assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month))); assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Day))); } assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->WeekDay)); /* Disable the write protection for RTC registers */ LL_RTC_DisableWriteProtection(RTCx); /* Set Initialization mode */ if (LL_RTC_EnterInitMode(RTCx) != ERROR) { /* Check the input parameters format */ if (RTC_Format != LL_RTC_FORMAT_BIN) { LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, RTC_DateStruct->Day, RTC_DateStruct->Month, RTC_DateStruct->Year); } else { LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Day), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Year)); } /* Exit Initialization mode */ LL_RTC_DisableInitMode(RTCx); /* If RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */ if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U) { status = LL_RTC_WaitForSynchro(RTCx); } else { status = SUCCESS; } } /* Enable the write protection for RTC registers */ LL_RTC_EnableWriteProtection(RTCx); return status; } /** * @brief Set each @ref LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00) * @param RTC_DateStruct pointer to a @ref LL_RTC_DateTypeDef structure which will be initialized. * @retval None */ void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct) { /* Monday, January 01 xx00 */ RTC_DateStruct->WeekDay = LL_RTC_WEEKDAY_MONDAY; RTC_DateStruct->Day = 1U; RTC_DateStruct->Month = LL_RTC_MONTH_JANUARY; RTC_DateStruct->Year = 0U; } /** * @brief Set the RTC Alarm A. * @note The Alarm register can only be written when the corresponding Alarm * is disabled (Use @ref LL_RTC_ALMA_Disable function). * @param RTCx RTC Instance * @param RTC_Format This parameter can be one of the following values: * @arg @ref LL_RTC_FORMAT_BIN * @arg @ref LL_RTC_FORMAT_BCD * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that * contains the alarm configuration parameters. * @retval An ErrorStatus enumeration value: * - SUCCESS: ALARMA registers are configured * - ERROR: ALARMA registers are not configured */ ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) { /* Check the parameters */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); assert_param(IS_LL_RTC_FORMAT(RTC_Format)); assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->AlarmMask)); assert_param(IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); if (RTC_Format == LL_RTC_FORMAT_BIN) { if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) { assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); } else { RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); } assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) { assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); } else { assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); } } else { if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) { assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); } else { RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); } assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) { assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); } else { assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); } } /* Disable the write protection for RTC registers */ LL_RTC_DisableWriteProtection(RTCx); /* Select weekday selection */ if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) { /* Set the date for ALARM */ LL_RTC_ALMA_DisableWeekday(RTCx); if (RTC_Format != LL_RTC_FORMAT_BIN) { LL_RTC_ALMA_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); } else { LL_RTC_ALMA_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); } } else { /* Set the week day for ALARM */ LL_RTC_ALMA_EnableWeekday(RTCx); LL_RTC_ALMA_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); } /* Configure the Alarm register */ if (RTC_Format != LL_RTC_FORMAT_BIN) { LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); } else { LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); } /* Set ALARM mask */ LL_RTC_ALMA_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); /* Enable the write protection for RTC registers */ LL_RTC_EnableWriteProtection(RTCx); return SUCCESS; } /** * @brief Set the RTC Alarm B. * @note The Alarm register can only be written when the corresponding Alarm * is disabled (@ref LL_RTC_ALMB_Disable function). * @param RTCx RTC Instance * @param RTC_Format This parameter can be one of the following values: * @arg @ref LL_RTC_FORMAT_BIN * @arg @ref LL_RTC_FORMAT_BCD * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that * contains the alarm configuration parameters. * @retval An ErrorStatus enumeration value: * - SUCCESS: ALARMB registers are configured * - ERROR: ALARMB registers are not configured */ ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct) { /* Check the parameters */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); assert_param(IS_LL_RTC_FORMAT(RTC_Format)); assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->AlarmMask)); assert_param(IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel)); if (RTC_Format == LL_RTC_FORMAT_BIN) { if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) { assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours)); assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); } else { RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours)); } assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes)); assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds)); if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) { assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay)); } else { assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay)); } } else { if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR) { assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat)); } else { RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U; assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours))); } assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes))); assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds))); if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) { assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); } else { assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay))); } } /* Disable the write protection for RTC registers */ LL_RTC_DisableWriteProtection(RTCx); /* Select weekday selection */ if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) { /* Set the date for ALARM */ LL_RTC_ALMB_DisableWeekday(RTCx); if (RTC_Format != LL_RTC_FORMAT_BIN) { LL_RTC_ALMB_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); } else { LL_RTC_ALMB_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay)); } } else { /* Set the week day for ALARM */ LL_RTC_ALMB_EnableWeekday(RTCx); LL_RTC_ALMB_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay); } /* Configure the Alarm register */ if (RTC_Format != LL_RTC_FORMAT_BIN) { LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours, RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds); } else { LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours), __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes), __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds)); } /* Set ALARM mask */ LL_RTC_ALMB_SetMask(RTCx, RTC_AlarmStruct->AlarmMask); /* Enable the write protection for RTC registers */ LL_RTC_EnableWriteProtection(RTCx); return SUCCESS; } /** * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / * Day = 1st day of the month/Mask = all fields are masked). * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. * @retval None */ void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) { /* Alarm Time Settings : Time = 00h:00mn:00sec */ RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMA_TIME_FORMAT_AM; RTC_AlarmStruct->AlarmTime.Hours = 0U; RTC_AlarmStruct->AlarmTime.Minutes = 0U; RTC_AlarmStruct->AlarmTime.Seconds = 0U; /* Alarm Day Settings : Day = 1st day of the month */ RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMA_DATEWEEKDAYSEL_DATE; RTC_AlarmStruct->AlarmDateWeekDay = 1U; /* Alarm Masks Settings : Mask = all fields are not masked */ RTC_AlarmStruct->AlarmMask = LL_RTC_ALMA_MASK_NONE; } /** * @brief Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec / * Day = 1st day of the month/Mask = all fields are masked). * @param RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized. * @retval None */ void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct) { /* Alarm Time Settings : Time = 00h:00mn:00sec */ RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMB_TIME_FORMAT_AM; RTC_AlarmStruct->AlarmTime.Hours = 0U; RTC_AlarmStruct->AlarmTime.Minutes = 0U; RTC_AlarmStruct->AlarmTime.Seconds = 0U; /* Alarm Day Settings : Day = 1st day of the month */ RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMB_DATEWEEKDAYSEL_DATE; RTC_AlarmStruct->AlarmDateWeekDay = 1U; /* Alarm Masks Settings : Mask = all fields are not masked */ RTC_AlarmStruct->AlarmMask = LL_RTC_ALMB_MASK_NONE; } /** * @brief Enters the RTC Initialization mode. * @note The RTC Initialization mode is write protected, use the * @ref LL_RTC_DisableWriteProtection before calling this function. * @param RTCx RTC Instance * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC is in Init mode * - ERROR: RTC is not in Init mode */ ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx) { __IO uint32_t timeout = RTC_INITMODE_TIMEOUT; ErrorStatus status = SUCCESS; uint32_t tmp; /* Check the parameter */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); /* Check if the Initialization mode is set */ if (LL_RTC_IsActiveFlag_INIT(RTCx) == 0U) { /* Set the Initialization mode */ LL_RTC_EnableInitMode(RTCx); /* Wait till RTC is in INIT state and if Time out is reached exit */ tmp = LL_RTC_IsActiveFlag_INIT(RTCx); while ((timeout != 0U) && (tmp != 1U)) { if (LL_SYSTICK_IsActiveCounterFlag() == 1U) { timeout --; } tmp = LL_RTC_IsActiveFlag_INIT(RTCx); if (timeout == 0U) { status = ERROR; } } } return status; } /** * @brief Exit the RTC Initialization mode. * @note When the initialization sequence is complete, the calendar restarts * counting after 4 RTCCLK cycles. * @note The RTC Initialization mode is write protected, use the * @ref LL_RTC_DisableWriteProtection before calling this function. * @param RTCx RTC Instance * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC exited from in Init mode * - ERROR: Not applicable */ ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx) { /* Check the parameter */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); /* Disable initialization mode */ LL_RTC_DisableInitMode(RTCx); return SUCCESS; } /** * @brief Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are * synchronized with RTC APB clock. * @note The RTC Resynchronization mode is write protected, use the * @ref LL_RTC_DisableWriteProtection before calling this function. * @note To read the calendar through the shadow registers after Calendar * initialization, calendar update or after wakeup from low power modes * the software must first clear the RSF flag. * The software must then wait until it is set again before reading * the calendar, which means that the calendar registers have been * correctly copied into the RTC_TR and RTC_DR shadow registers. * @param RTCx RTC Instance * @retval An ErrorStatus enumeration value: * - SUCCESS: RTC registers are synchronised * - ERROR: RTC registers are not synchronised */ ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx) { __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT; ErrorStatus status = SUCCESS; uint32_t tmp; /* Check the parameter */ assert_param(IS_RTC_ALL_INSTANCE(RTCx)); /* Clear RSF flag */ LL_RTC_ClearFlag_RS(RTCx); /* Wait the registers to be synchronised */ timeout = RTC_SYNCHRO_TIMEOUT; tmp = LL_RTC_IsActiveFlag_RS(RTCx); while ((timeout != 0U) && (tmp != 1U)) { if (LL_SYSTICK_IsActiveCounterFlag() == 1U) { timeout--; } tmp = LL_RTC_IsActiveFlag_RS(RTCx); if (timeout == 0U) { status = ERROR; } } return (status); } /** * @} */ /** * @} */ /** * @} */ #endif /* defined(RTC) */ /** * @} */ #endif /* USE_FULL_LL_DRIVER */ /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
the_stack_data/6387441.c
#pragma line 1 "fir.c" #pragma line 1 "fir.c" 1 #pragma line 1 "<built-in>" 1 #pragma line 1 "<built-in>" 3 #pragma line 148 "<built-in>" 3 #pragma line 1 "<command line>" 1 #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" 1 /* autopilot_ssdm_op.h*/ /* #- (c) Copyright 2011-2017 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ #pragma empty_line * * $Id$ */ #pragma line 289 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" /*#define AP_SPEC_ATTR __attribute__ ((pure))*/ #pragma empty_line #pragma empty_line #pragma empty_line /****** SSDM Intrinsics: OPERATIONS ***/ // Interface operations //typedef unsigned int __attribute__ ((bitwidth(1))) _uint1_; void _ssdm_op_IfRead() __attribute__ ((nothrow)); void _ssdm_op_IfWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_op_IfNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_op_IfCanWrite() SSDM_OP_ATTR; #pragma empty_line // Stream Intrinsics void _ssdm_StreamRead() __attribute__ ((nothrow)); void _ssdm_StreamWrite() __attribute__ ((nothrow)); //_uint1_ _ssdm_StreamNbRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamNbWrite() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanRead() SSDM_OP_ATTR; //_uint1_ _ssdm_StreamCanWrite() SSDM_OP_ATTR; #pragma empty_line // Misc void _ssdm_op_MemShiftRead() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_Wait() __attribute__ ((nothrow)); void _ssdm_op_Poll() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_Return() __attribute__ ((nothrow)); #pragma empty_line /* SSDM Intrinsics: SPECIFICATIONS */ void _ssdm_op_SpecSynModule() __attribute__ ((nothrow)); void _ssdm_op_SpecTopModule() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDecl() __attribute__ ((nothrow)); void _ssdm_op_SpecProcessDef() __attribute__ ((nothrow)); void _ssdm_op_SpecPort() __attribute__ ((nothrow)); void _ssdm_op_SpecConnection() __attribute__ ((nothrow)); void _ssdm_op_SpecChannel() __attribute__ ((nothrow)); void _ssdm_op_SpecSensitive() __attribute__ ((nothrow)); void _ssdm_op_SpecModuleInst() __attribute__ ((nothrow)); void _ssdm_op_SpecPortMap() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecReset() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecPlatform() __attribute__ ((nothrow)); void _ssdm_op_SpecClockDomain() __attribute__ ((nothrow)); void _ssdm_op_SpecPowerDomain() __attribute__ ((nothrow)); #pragma empty_line int _ssdm_op_SpecRegionBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecRegionEnd() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecLoopName() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecLoopTripCount() __attribute__ ((nothrow)); #pragma empty_line int _ssdm_op_SpecStateBegin() __attribute__ ((nothrow)); int _ssdm_op_SpecStateEnd() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecInterface() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecPipeline() __attribute__ ((nothrow)); void _ssdm_op_SpecDataflowPipeline() __attribute__ ((nothrow)); #pragma empty_line #pragma empty_line void _ssdm_op_SpecLatency() __attribute__ ((nothrow)); void _ssdm_op_SpecParallel() __attribute__ ((nothrow)); void _ssdm_op_SpecProtocol() __attribute__ ((nothrow)); void _ssdm_op_SpecOccurrence() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecResource() __attribute__ ((nothrow)); void _ssdm_op_SpecResourceLimit() __attribute__ ((nothrow)); void _ssdm_op_SpecCHCore() __attribute__ ((nothrow)); void _ssdm_op_SpecFUCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIFCore() __attribute__ ((nothrow)); void _ssdm_op_SpecIPCore() __attribute__ ((nothrow)); void _ssdm_op_SpecKeepValue() __attribute__ ((nothrow)); void _ssdm_op_SpecMemCore() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecExt() __attribute__ ((nothrow)); /*void* _ssdm_op_SpecProcess() SSDM_SPEC_ATTR; void* _ssdm_op_SpecEdge() SSDM_SPEC_ATTR; */ #pragma empty_line /* Presynthesis directive functions */ void _ssdm_SpecArrayDimSize() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_RegionBegin() __attribute__ ((nothrow)); void _ssdm_RegionEnd() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_Unroll() __attribute__ ((nothrow)); void _ssdm_UnrollRegion() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_InlineAll() __attribute__ ((nothrow)); void _ssdm_InlineLoop() __attribute__ ((nothrow)); void _ssdm_Inline() __attribute__ ((nothrow)); void _ssdm_InlineSelf() __attribute__ ((nothrow)); void _ssdm_InlineRegion() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecArrayMap() __attribute__ ((nothrow)); void _ssdm_SpecArrayPartition() __attribute__ ((nothrow)); void _ssdm_SpecArrayReshape() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecStream() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecExpr() __attribute__ ((nothrow)); void _ssdm_SpecExprBalance() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecDependence() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecLoopMerge() __attribute__ ((nothrow)); void _ssdm_SpecLoopFlatten() __attribute__ ((nothrow)); void _ssdm_SpecLoopRewind() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_SpecFuncInstantiation() __attribute__ ((nothrow)); void _ssdm_SpecFuncBuffer() __attribute__ ((nothrow)); void _ssdm_SpecFuncExtract() __attribute__ ((nothrow)); void _ssdm_SpecConstant() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_DataPack() __attribute__ ((nothrow)); void _ssdm_SpecDataPack() __attribute__ ((nothrow)); #pragma empty_line void _ssdm_op_SpecBitsMap() __attribute__ ((nothrow)); void _ssdm_op_SpecLicense() __attribute__ ((nothrow)); #pragma empty_line #pragma empty_line /*#define _ssdm_op_WaitUntil(X) while (!(X)) _ssdm_op_Wait(1); #define _ssdm_op_Delayed(X) X */ #pragma line 427 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_op.h" // 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 #pragma line 7 "<command line>" 2 #pragma line 1 "<built-in>" 2 #pragma line 1 "fir.c" 2 #pragma line 1 "./fir.h" 1 #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" 1 /* ap_cint.h */ /* #- (c) Copyright 2011-2017 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ #pragma empty_line * * $Id$ */ #pragma line 62 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma line 18 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 3 /* mingw.org's version macros: these make gcc to define MINGW32_SUPPORTS_MT_EH and to use the _CRT_MT global and the __mingwthr_key_dtor() function from the MinGW CRT in its private gthr-win32.h header. */ #pragma line 47 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 3 /* For 32-bits we have always to prefix by underscore. */ #pragma line 62 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 3 /* Use alias for msvcr80 export of get/set_output_format. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line /* Set VC specific compiler target macros. */ #pragma line 79 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/_mingw_mac.h" 3 /* This gives wrong (600 instead of 300) value if -march=i386 is specified but we cannot check for__i386__ as it is defined for all 32-bit CPUs. */ #pragma line 10 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 #pragma empty_line #pragma empty_line /* C/C++ specific language defines. */ #pragma line 32 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* Note the extern. This is needed to work around GCC's limitations in handling dllimport attribute. */ #pragma line 147 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's variadiac macro facility, because variadic macros cause syntax errors with --traditional-cpp. */ #pragma line 225 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* High byte is the major version, low byte is the minor. */ #pragma line 277 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma line 674 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/sdks/_mingw_directx.h" 1 3 #pragma line 674 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include/sdks/_mingw_ddk.h" 1 3 #pragma line 675 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 #pragma line 13 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 2 3 #pragma empty_line #pragma empty_line #pragma pack(push,_CRT_PACKING) #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef __builtin_va_list __gnuc_va_list; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef __gnuc_va_list va_list; #pragma line 46 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 3 /* Use GCC builtins */ #pragma line 102 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\vadefs.h" 3 #pragma pack(pop) #pragma line 277 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 2 3 #pragma empty_line #pragma empty_line #pragma pack(push,_CRT_PACKING) #pragma line 316 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* We have to define _DLL for gcc based mingw version. This define is set by VC, when DLL-based runtime is used. So, gcc based runtime just have DLL-base runtime, therefore this define has to be set. As our headers are possibly used by windows compiler having a static C-runtime, we make this definition gnu compiler specific here. */ #pragma line 372 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef unsigned int size_t; #pragma line 382 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef int ssize_t; #pragma line 394 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef int intptr_t; #pragma line 407 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef unsigned int uintptr_t; #pragma line 420 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef int ptrdiff_t; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef unsigned short wchar_t; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef unsigned short wint_t; typedef unsigned short wctype_t; #pragma line 456 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 typedef int errno_t; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef long __time32_t; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line __extension__ typedef long long __time64_t; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef __time32_t time_t; #pragma line 518 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* _dowildcard is an int that controls the globbing of the command line. * The MinGW32 (mingw.org) runtime calls it _CRT_glob, so we are adding * a compatibility definition here: you can use either of _CRT_glob or * _dowildcard . * If _dowildcard is non-zero, the command line will be globbed: *.* * will be expanded to be all files in the startup directory. * In the mingw-w64 library a _dowildcard variable is defined as being * 0, therefore command line globbing is DISABLED by default. To turn it * on and to leave wildcard command line processing MS's globbing code, * include a line in one of your source modules defining _dowildcard and * setting it to -1, like so: * int _dowildcard = -1; */ #pragma line 605 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 3 /* MSVC-isms: */ #pragma empty_line struct threadlocaleinfostruct; struct threadmbcinfostruct; typedef struct threadlocaleinfostruct *pthreadlocinfo; typedef struct threadmbcinfostruct *pthreadmbcinfo; struct __lc_time_data; #pragma empty_line typedef struct localeinfo_struct { pthreadlocinfo locinfo; pthreadmbcinfo mbcinfo; } _locale_tstruct,*_locale_t; #pragma empty_line #pragma empty_line #pragma empty_line typedef struct tagLC_ID { unsigned short wLanguage; unsigned short wCountry; unsigned short wCodePage; } LC_ID,*LPLC_ID; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line typedef struct threadlocaleinfostruct { int refcount; unsigned int lc_codepage; unsigned int lc_collate_cp; unsigned long lc_handle[6]; LC_ID lc_id[6]; struct { char *locale; wchar_t *wlocale; int *refcount; int *wrefcount; } lc_category[6]; int lc_clike; int mb_cur_max; int *lconv_intl_refcount; int *lconv_num_refcount; int *lconv_mon_refcount; struct lconv *lconv; int *ctype1_refcount; unsigned short *ctype1; const unsigned short *pctype; const unsigned char *pclmap; const unsigned char *pcumap; struct __lc_time_data *lc_time_curr; } threadlocinfo; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line /* mingw-w64 specific functions: */ const char *__mingw_get_crt_info (void); #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma pack(pop) #pragma line 9 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 2 3 #pragma line 36 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 3 __attribute__ ((__dllimport__)) void * _memccpy(void *_Dst,const void *_Src,int _Val,size_t _MaxCount); void * memchr(const void *_Buf ,int _Val,size_t _MaxCount); __attribute__ ((__dllimport__)) int _memicmp(const void *_Buf1,const void *_Buf2,size_t _Size); __attribute__ ((__dllimport__)) int _memicmp_l(const void *_Buf1,const void *_Buf2,size_t _Size,_locale_t _Locale); int memcmp(const void *_Buf1,const void *_Buf2,size_t _Size); void * memcpy(void * __restrict__ _Dst,const void * __restrict__ _Src,size_t _Size) ; void * memset(void *_Dst,int _Val,size_t _Size); #pragma empty_line void * memccpy(void *_Dst,const void *_Src,int _Val,size_t _Size) ; int memicmp(const void *_Buf1,const void *_Buf2,size_t _Size) ; #pragma empty_line #pragma empty_line char * _strset(char *_Str,int _Val) ; char * _strset_l(char *_Str,int _Val,_locale_t _Locale) ; char * strcpy(char * __restrict__ _Dest,const char * __restrict__ _Source); char * strcat(char * __restrict__ _Dest,const char * __restrict__ _Source); int strcmp(const char *_Str1,const char *_Str2); size_t strlen(const char *_Str); size_t strnlen(const char *_Str,size_t _MaxCount); void * memmove(void *_Dst,const void *_Src,size_t _Size) ; __attribute__ ((__dllimport__)) char * _strdup(const char *_Src); char * strchr(const char *_Str,int _Val); __attribute__ ((__dllimport__)) int _stricmp(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _strcmpi(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _stricmp_l(const char *_Str1,const char *_Str2,_locale_t _Locale); int strcoll(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _strcoll_l(const char *_Str1,const char *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _stricoll(const char *_Str1,const char *_Str2); __attribute__ ((__dllimport__)) int _stricoll_l(const char *_Str1,const char *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _strncoll (const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strncoll_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) int _strnicoll (const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strnicoll_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale); size_t strcspn(const char *_Str,const char *_Control); __attribute__ ((__dllimport__)) char * _strerror(const char *_ErrMsg) ; char * strerror(int) ; __attribute__ ((__dllimport__)) char * _strlwr(char *_String) ; char *strlwr_l(char *_String,_locale_t _Locale) ; char * strncat(char * __restrict__ _Dest,const char * __restrict__ _Source,size_t _Count) ; int strncmp(const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strnicmp(const char *_Str1,const char *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _strnicmp_l(const char *_Str1,const char *_Str2,size_t _MaxCount,_locale_t _Locale); char *strncpy(char * __restrict__ _Dest,const char * __restrict__ _Source,size_t _Count) ; __attribute__ ((__dllimport__)) char * _strnset(char *_Str,int _Val,size_t _MaxCount) ; __attribute__ ((__dllimport__)) char * _strnset_l(char *str,int c,size_t count,_locale_t _Locale) ; char * strpbrk(const char *_Str,const char *_Control); char * strrchr(const char *_Str,int _Ch); __attribute__ ((__dllimport__)) char * _strrev(char *_Str); size_t strspn(const char *_Str,const char *_Control); char * strstr(const char *_Str,const char *_SubStr); char * strtok(char * __restrict__ _Str,const char * __restrict__ _Delim) ; __attribute__ ((__dllimport__)) char * _strupr(char *_String) ; __attribute__ ((__dllimport__)) char *_strupr_l(char *_String,_locale_t _Locale) ; size_t strxfrm(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount); __attribute__ ((__dllimport__)) size_t _strxfrm_l(char * __restrict__ _Dst,const char * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale); #pragma empty_line #pragma empty_line char * strdup(const char *_Src) ; int strcmpi(const char *_Str1,const char *_Str2) ; int stricmp(const char *_Str1,const char *_Str2) ; char * strlwr(char *_Str) ; int strnicmp(const char *_Str1,const char *_Str,size_t _MaxCount) ; int strncasecmp (const char *, const char *, size_t); int strcasecmp (const char *, const char *); #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line char * strnset(char *_Str,int _Val,size_t _MaxCount) ; char * strrev(char *_Str) ; char * strset(char *_Str,int _Val) ; char * strupr(char *_Str) ; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line __attribute__ ((__dllimport__)) wchar_t * _wcsdup(const wchar_t *_Str); wchar_t * wcscat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) ; wchar_t * wcschr(const wchar_t *_Str,wchar_t _Ch); int wcscmp(const wchar_t *_Str1,const wchar_t *_Str2); wchar_t * wcscpy(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source) ; size_t wcscspn(const wchar_t *_Str,const wchar_t *_Control); size_t wcslen(const wchar_t *_Str); size_t wcsnlen(const wchar_t *_Src,size_t _MaxCount); wchar_t *wcsncat(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count) ; int wcsncmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); wchar_t *wcsncpy(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count) ; wchar_t * _wcsncpy_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Source,size_t _Count,_locale_t _Locale) ; wchar_t * wcspbrk(const wchar_t *_Str,const wchar_t *_Control); wchar_t * wcsrchr(const wchar_t *_Str,wchar_t _Ch); size_t wcsspn(const wchar_t *_Str,const wchar_t *_Control); wchar_t * wcsstr(const wchar_t *_Str,const wchar_t *_SubStr); wchar_t * wcstok(wchar_t * __restrict__ _Str,const wchar_t * __restrict__ _Delim) ; __attribute__ ((__dllimport__)) wchar_t * _wcserror(int _ErrNum) ; __attribute__ ((__dllimport__)) wchar_t * __wcserror(const wchar_t *_Str) ; __attribute__ ((__dllimport__)) int _wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2); __attribute__ ((__dllimport__)) int _wcsicmp_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _wcsnicmp_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) wchar_t * _wcsnset(wchar_t *_Str,wchar_t _Val,size_t _MaxCount) ; __attribute__ ((__dllimport__)) wchar_t * _wcsrev(wchar_t *_Str); __attribute__ ((__dllimport__)) wchar_t * _wcsset(wchar_t *_Str,wchar_t _Val) ; __attribute__ ((__dllimport__)) wchar_t * _wcslwr(wchar_t *_String) ; __attribute__ ((__dllimport__)) wchar_t *_wcslwr_l(wchar_t *_String,_locale_t _Locale) ; __attribute__ ((__dllimport__)) wchar_t * _wcsupr(wchar_t *_String) ; __attribute__ ((__dllimport__)) wchar_t *_wcsupr_l(wchar_t *_String,_locale_t _Locale) ; size_t wcsxfrm(wchar_t * __restrict__ _Dst,const wchar_t * __restrict__ _Src,size_t _MaxCount); __attribute__ ((__dllimport__)) size_t _wcsxfrm_l(wchar_t * __restrict__ _Dst,const wchar_t * __restrict__ _Src,size_t _MaxCount,_locale_t _Locale); int wcscoll(const wchar_t *_Str1,const wchar_t *_Str2); __attribute__ ((__dllimport__)) int _wcscoll_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2); __attribute__ ((__dllimport__)) int _wcsicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsncoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _wcsncoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); __attribute__ ((__dllimport__)) int _wcsnicoll(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount); __attribute__ ((__dllimport__)) int _wcsnicoll_l(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount,_locale_t _Locale); #pragma empty_line #pragma empty_line wchar_t * wcsdup(const wchar_t *_Str) ; #pragma empty_line int wcsicmp(const wchar_t *_Str1,const wchar_t *_Str2) ; int wcsnicmp(const wchar_t *_Str1,const wchar_t *_Str2,size_t _MaxCount) ; wchar_t * wcsnset(wchar_t *_Str,wchar_t _Val,size_t _MaxCount) ; wchar_t * wcsrev(wchar_t *_Str) ; wchar_t * wcsset(wchar_t *_Str,wchar_t _Val) ; wchar_t * wcslwr(wchar_t *_Str) ; wchar_t * wcsupr(wchar_t *_Str) ; int wcsicoll(const wchar_t *_Str1,const wchar_t *_Str2) ; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/string_s.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma line 9 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/string_s.h" 2 3 #pragma line 175 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\string.h" 2 3 #pragma line 63 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" 2 #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma line 9 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw_print_push.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line /* Undefine __mingw_<printf> macros. */ #pragma line 11 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 #pragma empty_line #pragma empty_line #pragma pack(push,_CRT_PACKING) #pragma line 26 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 struct _iobuf { char *_ptr; int _cnt; char *_base; int _flag; int _file; int _charbuf; int _bufsiz; char *_tmpfname; }; typedef struct _iobuf FILE; #pragma line 84 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 typedef long _off_t; #pragma empty_line typedef long off_t; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line __extension__ typedef long long _off64_t; #pragma empty_line __extension__ typedef long long off64_t; #pragma line 108 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 extern FILE (* _imp___iob)[]; /* A pointer to an array of FILE */ #pragma line 120 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __extension__ typedef long long fpos_t; #pragma line 157 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) int _filbuf(FILE *_File); __attribute__ ((__dllimport__)) int _flsbuf(int _Ch,FILE *_File); #pragma empty_line #pragma empty_line #pragma empty_line __attribute__ ((__dllimport__)) FILE * _fsopen(const char *_Filename,const char *_Mode,int _ShFlag); #pragma empty_line void clearerr(FILE *_File); int fclose(FILE *_File); __attribute__ ((__dllimport__)) int _fcloseall(void); #pragma empty_line #pragma empty_line #pragma empty_line __attribute__ ((__dllimport__)) FILE * _fdopen(int _FileHandle,const char *_Mode); #pragma empty_line int feof(FILE *_File); int ferror(FILE *_File); int fflush(FILE *_File); int fgetc(FILE *_File); __attribute__ ((__dllimport__)) int _fgetchar(void); int fgetpos(FILE * __restrict__ _File ,fpos_t * __restrict__ _Pos); char * fgets(char * __restrict__ _Buf,int _MaxCount,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) int _fileno(FILE *_File); #pragma empty_line #pragma empty_line #pragma empty_line __attribute__ ((__dllimport__)) char * _tempnam(const char *_DirName,const char *_FilePrefix); __attribute__ ((__dllimport__)) int _flushall(void); FILE * fopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode) ; FILE *fopen64(const char * __restrict__ filename,const char * __restrict__ mode); int fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,...); int fputc(int _Ch,FILE *_File); __attribute__ ((__dllimport__)) int _fputchar(int _Ch); int fputs(const char * __restrict__ _Str,FILE * __restrict__ _File); size_t fread(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File); FILE * freopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode,FILE * __restrict__ _File) ; int fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,...) ; int _fscanf_l(FILE * __restrict__ _File,const char * __restrict__ _Format,_locale_t locale,...) ; int fsetpos(FILE *_File,const fpos_t *_Pos); int fseek(FILE *_File,long _Offset,int _Origin); int fseeko64(FILE* stream, _off64_t offset, int whence); long ftell(FILE *_File); _off64_t ftello64(FILE * stream); __extension__ int _fseeki64(FILE *_File,long long _Offset,int _Origin); __extension__ long long _ftelli64(FILE *_File); size_t fwrite(const void * __restrict__ _Str,size_t _Size,size_t _Count,FILE * __restrict__ _File); int getc(FILE *_File); int getchar(void); __attribute__ ((__dllimport__)) int _getmaxstdio(void); char * gets(char *_Buffer) ; int _getw(FILE *_File); #pragma empty_line #pragma empty_line void perror(const char *_ErrMsg); #pragma empty_line __attribute__ ((__dllimport__)) int _pclose(FILE *_File); __attribute__ ((__dllimport__)) FILE * _popen(const char *_Command,const char *_Mode); #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line int printf(const char * __restrict__ _Format,...); int putc(int _Ch,FILE *_File); int putchar(int _Ch); int puts(const char *_Str); __attribute__ ((__dllimport__)) int _putw(int _Word,FILE *_File); #pragma empty_line #pragma empty_line int remove(const char *_Filename); int rename(const char *_OldFilename,const char *_NewFilename); __attribute__ ((__dllimport__)) int _unlink(const char *_Filename); #pragma empty_line int unlink(const char *_Filename) ; #pragma empty_line #pragma empty_line void rewind(FILE *_File); __attribute__ ((__dllimport__)) int _rmtmp(void); int scanf(const char * __restrict__ _Format,...) ; int _scanf_l(const char * __restrict__ format,_locale_t locale,... ) ; void setbuf(FILE * __restrict__ _File,char * __restrict__ _Buffer) ; __attribute__ ((__dllimport__)) int _setmaxstdio(int _Max); __attribute__ ((__dllimport__)) unsigned int _set_output_format(unsigned int _Format); __attribute__ ((__dllimport__)) unsigned int _get_output_format(void); unsigned int __mingw_set_output_format(unsigned int _Format); unsigned int __mingw_get_output_format(void); #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line int setvbuf(FILE * __restrict__ _File,char * __restrict__ _Buf,int _Mode,size_t _Size); __attribute__ ((__dllimport__)) int _scprintf(const char * __restrict__ _Format,...); int sscanf(const char * __restrict__ _Src,const char * __restrict__ _Format,...) ; int _sscanf_l(const char * __restrict__ buffer,const char * __restrict__ format,_locale_t locale,...) ; __attribute__ ((__dllimport__)) int _snscanf(const char * __restrict__ _Src,size_t _MaxCount,const char * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _snscanf_l(const char * __restrict__ input,size_t length,const char * __restrict__ format,_locale_t locale,...) ; FILE * tmpfile(void) ; char * tmpnam(char *_Buffer); int ungetc(int _Ch,FILE *_File); int vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,va_list _ArgList); int vprintf(const char * __restrict__ _Format,va_list _ArgList); #pragma empty_line /* Make sure macros are not defined. */ extern __attribute__((__format__ (gnu_printf, 3, 0))) __attribute__ ((__nonnull__ (3))) int __mingw_vsnprintf(char * __restrict__ _DstBuf,size_t _MaxCount,const char * __restrict__ _Format, va_list _ArgList); extern __attribute__((__format__ (gnu_printf, 3, 4))) __attribute__ ((__nonnull__ (3))) int __mingw_snprintf(char * __restrict__ s, size_t n, const char * __restrict__ format, ...); extern __attribute__((__format__ (gnu_printf, 1, 2))) __attribute__ ((__nonnull__ (1))) int __mingw_printf(const char * __restrict__ , ... ) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 1, 0))) __attribute__ ((__nonnull__ (1))) int __mingw_vprintf (const char * __restrict__ , va_list) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 3))) __attribute__ ((__nonnull__ (2))) int __mingw_fprintf (FILE * __restrict__ , const char * __restrict__ , ...) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 0))) __attribute__ ((__nonnull__ (2))) int __mingw_vfprintf (FILE * __restrict__ , const char * __restrict__ , va_list) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 3))) __attribute__ ((__nonnull__ (2))) int __mingw_sprintf (char * __restrict__ , const char * __restrict__ , ...) __attribute__ ((__nothrow__)); extern __attribute__((__format__ (gnu_printf, 2, 0))) __attribute__ ((__nonnull__ (2))) int __mingw_vsprintf (char * __restrict__ , const char * __restrict__ , va_list) __attribute__ ((__nothrow__)); #pragma empty_line __attribute__ ((__dllimport__)) int _snprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _snprintf_l(char * __restrict__ buffer,size_t count,const char * __restrict__ format,_locale_t locale,...) ; __attribute__ ((__dllimport__)) int _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __restrict__ _Format,va_list _Args) ; __attribute__ ((__dllimport__)) int _vsnprintf_l(char * __restrict__ buffer,size_t count,const char * __restrict__ format,_locale_t locale,va_list argptr) ; int sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,...) ; int _sprintf_l(char * __restrict__ buffer,const char * __restrict__ format,_locale_t locale,...) ; int vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format,va_list _Args) ; #pragma empty_line /* this is here to deal with software defining * vsnprintf as _vsnprintf, eg. libxml2. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line int vsnprintf(char * __restrict__ _DstBuf,size_t _MaxCount,const char * __restrict__ _Format,va_list _ArgList) ; #pragma empty_line int snprintf(char * __restrict__ s, size_t n, const char * __restrict__ format, ...); #pragma line 312 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 int vscanf(const char * __restrict__ Format, va_list argp); int vfscanf (FILE * __restrict__ fp, const char * __restrict__ Format,va_list argp); int vsscanf (const char * __restrict__ _Str,const char * __restrict__ Format,va_list argp); #pragma empty_line __attribute__ ((__dllimport__)) int _vscprintf(const char * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _set_printf_count_output(int _Value); __attribute__ ((__dllimport__)) int _get_printf_count_output(void); #pragma line 330 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) FILE * _wfsopen(const wchar_t *_Filename,const wchar_t *_Mode,int _ShFlag); #pragma empty_line #pragma empty_line wint_t fgetwc(FILE *_File); __attribute__ ((__dllimport__)) wint_t _fgetwchar(void); wint_t fputwc(wchar_t _Ch,FILE *_File); __attribute__ ((__dllimport__)) wint_t _fputwchar(wchar_t _Ch); wint_t getwc(FILE *_File); wint_t getwchar(void); wint_t putwc(wchar_t _Ch,FILE *_File); wint_t putwchar(wchar_t _Ch); wint_t ungetwc(wint_t _Ch,FILE *_File); wchar_t * fgetws(wchar_t * __restrict__ _Dst,int _SizeInWords,FILE * __restrict__ _File); int fputws(const wchar_t * __restrict__ _Str,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) wchar_t * _getws(wchar_t *_String) ; __attribute__ ((__dllimport__)) int _putws(const wchar_t *_Str); int fwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); int wprintf(const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _scwprintf(const wchar_t * __restrict__ _Format,...); int vfwprintf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); int vwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int swprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ , ...) ; __attribute__ ((__dllimport__)) int _swprintf_l(wchar_t * __restrict__ buffer,size_t count,const wchar_t * __restrict__ format,_locale_t locale,... ) ; __attribute__ ((__dllimport__)) int vswprintf(wchar_t * __restrict__ , const wchar_t * __restrict__ ,va_list) ; __attribute__ ((__dllimport__)) int _swprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vswprintf_c(wchar_t * __restrict__ _DstBuf,size_t _SizeInWords,const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _snwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) ; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line int snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...); int vsnwprintf (wchar_t * __restrict__ , size_t, const wchar_t * __restrict__ , va_list); #pragma line 373 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 int vwscanf (const wchar_t * __restrict__ , va_list); int vfwscanf (FILE * __restrict__ ,const wchar_t * __restrict__ ,va_list); int vswscanf (const wchar_t * __restrict__ ,const wchar_t * __restrict__ ,va_list); #pragma empty_line __attribute__ ((__dllimport__)) int _fwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _wprintf_p(const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vfwprintf_p(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _vwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _swprintf_p(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vswprintf_p(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _scwprintf_p(const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vscwprintf_p(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _wprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _wprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _vwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _fwprintf_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _fwprintf_p_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vfwprintf_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _vfwprintf_p_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _swprintf_c_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _swprintf_p_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vswprintf_c_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _vswprintf_p_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _scwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _scwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vscwprintf_p_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); __attribute__ ((__dllimport__)) int _snwprintf_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); __attribute__ ((__dllimport__)) int _vsnwprintf_l(wchar_t * __restrict__ _DstBuf,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList) ; __attribute__ ((__dllimport__)) int _swprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _vswprintf(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,va_list _Args); __attribute__ ((__dllimport__)) int __swprintf_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,_locale_t _Plocinfo,...) ; __attribute__ ((__dllimport__)) int _vswprintf_l(wchar_t * __restrict__ buffer,size_t count,const wchar_t * __restrict__ format,_locale_t locale,va_list argptr) ; __attribute__ ((__dllimport__)) int __vswprintf_l(wchar_t * __restrict__ _Dest,const wchar_t * __restrict__ _Format,_locale_t _Plocinfo,va_list _Args) ; #pragma line 417 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) wchar_t * _wtempnam(const wchar_t *_Directory,const wchar_t *_FilePrefix); __attribute__ ((__dllimport__)) int _vscwprintf(const wchar_t * __restrict__ _Format,va_list _ArgList); __attribute__ ((__dllimport__)) int _vscwprintf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,va_list _ArgList); int fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _fwscanf_l(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,_locale_t _Locale,...) ; int swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _swscanf_l(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,_locale_t _Locale,...) ; __attribute__ ((__dllimport__)) int _snwscanf(const wchar_t * __restrict__ _Src,size_t _MaxCount,const wchar_t * __restrict__ _Format,...); __attribute__ ((__dllimport__)) int _snwscanf_l(const wchar_t * __restrict__ _Src,size_t _MaxCount,const wchar_t * __restrict__ _Format,_locale_t _Locale,...); int wscanf(const wchar_t * __restrict__ _Format,...) ; __attribute__ ((__dllimport__)) int _wscanf_l(const wchar_t * __restrict__ _Format,_locale_t _Locale,...) ; __attribute__ ((__dllimport__)) FILE * _wfdopen(int _FileHandle ,const wchar_t *_Mode); __attribute__ ((__dllimport__)) FILE * _wfopen(const wchar_t * __restrict__ _Filename,const wchar_t *__restrict__ _Mode) ; __attribute__ ((__dllimport__)) FILE * _wfreopen(const wchar_t * __restrict__ _Filename,const wchar_t * __restrict__ _Mode,FILE * __restrict__ _OldFile) ; #pragma empty_line #pragma empty_line #pragma empty_line __attribute__ ((__dllimport__)) void _wperror(const wchar_t *_ErrMsg); #pragma empty_line __attribute__ ((__dllimport__)) FILE * _wpopen(const wchar_t *_Command,const wchar_t *_Mode); #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line __attribute__ ((__dllimport__)) int _wremove(const wchar_t *_Filename); __attribute__ ((__dllimport__)) wchar_t * _wtmpnam(wchar_t *_Buffer); __attribute__ ((__dllimport__)) wint_t _fgetwc_nolock(FILE *_File); __attribute__ ((__dllimport__)) wint_t _fputwc_nolock(wchar_t _Ch,FILE *_File); __attribute__ ((__dllimport__)) wint_t _ungetwc_nolock(wint_t _Ch,FILE *_File); #pragma line 475 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 3 __attribute__ ((__dllimport__)) void _lock_file(FILE *_File); __attribute__ ((__dllimport__)) void _unlock_file(FILE *_File); __attribute__ ((__dllimport__)) int _fclose_nolock(FILE *_File); __attribute__ ((__dllimport__)) int _fflush_nolock(FILE *_File); __attribute__ ((__dllimport__)) size_t _fread_nolock(void * __restrict__ _DstBuf,size_t _ElementSize,size_t _Count,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) int _fseek_nolock(FILE *_File,long _Offset,int _Origin); __attribute__ ((__dllimport__)) long _ftell_nolock(FILE *_File); __extension__ __attribute__ ((__dllimport__)) int _fseeki64_nolock(FILE *_File,long long _Offset,int _Origin); __extension__ __attribute__ ((__dllimport__)) long long _ftelli64_nolock(FILE *_File); __attribute__ ((__dllimport__)) size_t _fwrite_nolock(const void * __restrict__ _DstBuf,size_t _Size,size_t _Count,FILE * __restrict__ _File); __attribute__ ((__dllimport__)) int _ungetc_nolock(int _Ch,FILE *_File); #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line char * tempnam(const char *_Directory,const char *_FilePrefix) ; int fcloseall(void) ; FILE * fdopen(int _FileHandle,const char *_Format) ; int fgetchar(void) ; int fileno(FILE *_File) ; int flushall(void) ; int fputchar(int _Ch) ; int getw(FILE *_File) ; int putw(int _Ch,FILE *_File) ; int rmtmp(void) ; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma pack(pop) #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/stdio_s.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma line 9 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\sec_api/stdio_s.h" 2 3 #pragma line 509 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\_mingw_print_pop.h" 1 3 /** * This file has no copyright assigned and is placed in the Public Domain. * This file is part of the w64 mingw-runtime package. * No warranty is given; refer to the file DISCLAIMER.PD within this package. */ #pragma empty_line /* Define __mingw_<printf> macros. */ #pragma line 511 "C:/Xilinx/Vivado_HLS/2017.2/win64/tools/clang/bin/../lib/clang/3.1/../../../x86_64-w64-mingw32/include\\stdio.h" 2 3 #pragma line 64 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" 2 #pragma line 77 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot/etc/autopilot_apint.h" 1 /* autopilot_apint.h*/ /* #- (c) Copyright 2011-2017 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ #pragma empty_line * * $Id$ */ #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" 1 /*-*-c++-*-*/ /* autopilot_dt.h: defines all bit-accurate data types.*/ /* #- (c) Copyright 2011-2017 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ #pragma empty_line * * $Id$ */ #pragma line 97 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.def" 1 #pragma empty_line #pragma empty_line typedef int __attribute__ ((bitwidth(1))) int1; typedef int __attribute__ ((bitwidth(2))) int2; typedef int __attribute__ ((bitwidth(3))) int3; typedef int __attribute__ ((bitwidth(4))) int4; typedef int __attribute__ ((bitwidth(5))) int5; typedef int __attribute__ ((bitwidth(6))) int6; typedef int __attribute__ ((bitwidth(7))) int7; typedef int __attribute__ ((bitwidth(8))) int8; typedef int __attribute__ ((bitwidth(9))) int9; typedef int __attribute__ ((bitwidth(10))) int10; typedef int __attribute__ ((bitwidth(11))) int11; typedef int __attribute__ ((bitwidth(12))) int12; typedef int __attribute__ ((bitwidth(13))) int13; typedef int __attribute__ ((bitwidth(14))) int14; typedef int __attribute__ ((bitwidth(15))) int15; typedef int __attribute__ ((bitwidth(16))) int16; typedef int __attribute__ ((bitwidth(17))) int17; typedef int __attribute__ ((bitwidth(18))) int18; typedef int __attribute__ ((bitwidth(19))) int19; typedef int __attribute__ ((bitwidth(20))) int20; typedef int __attribute__ ((bitwidth(21))) int21; typedef int __attribute__ ((bitwidth(22))) int22; typedef int __attribute__ ((bitwidth(23))) int23; typedef int __attribute__ ((bitwidth(24))) int24; typedef int __attribute__ ((bitwidth(25))) int25; typedef int __attribute__ ((bitwidth(26))) int26; typedef int __attribute__ ((bitwidth(27))) int27; typedef int __attribute__ ((bitwidth(28))) int28; typedef int __attribute__ ((bitwidth(29))) int29; typedef int __attribute__ ((bitwidth(30))) int30; typedef int __attribute__ ((bitwidth(31))) int31; typedef int __attribute__ ((bitwidth(32))) int32; typedef int __attribute__ ((bitwidth(33))) int33; typedef int __attribute__ ((bitwidth(34))) int34; typedef int __attribute__ ((bitwidth(35))) int35; typedef int __attribute__ ((bitwidth(36))) int36; typedef int __attribute__ ((bitwidth(37))) int37; typedef int __attribute__ ((bitwidth(38))) int38; typedef int __attribute__ ((bitwidth(39))) int39; typedef int __attribute__ ((bitwidth(40))) int40; typedef int __attribute__ ((bitwidth(41))) int41; typedef int __attribute__ ((bitwidth(42))) int42; typedef int __attribute__ ((bitwidth(43))) int43; typedef int __attribute__ ((bitwidth(44))) int44; typedef int __attribute__ ((bitwidth(45))) int45; typedef int __attribute__ ((bitwidth(46))) int46; typedef int __attribute__ ((bitwidth(47))) int47; typedef int __attribute__ ((bitwidth(48))) int48; typedef int __attribute__ ((bitwidth(49))) int49; typedef int __attribute__ ((bitwidth(50))) int50; typedef int __attribute__ ((bitwidth(51))) int51; typedef int __attribute__ ((bitwidth(52))) int52; typedef int __attribute__ ((bitwidth(53))) int53; typedef int __attribute__ ((bitwidth(54))) int54; typedef int __attribute__ ((bitwidth(55))) int55; typedef int __attribute__ ((bitwidth(56))) int56; typedef int __attribute__ ((bitwidth(57))) int57; typedef int __attribute__ ((bitwidth(58))) int58; typedef int __attribute__ ((bitwidth(59))) int59; typedef int __attribute__ ((bitwidth(60))) int60; typedef int __attribute__ ((bitwidth(61))) int61; typedef int __attribute__ ((bitwidth(62))) int62; typedef int __attribute__ ((bitwidth(63))) int63; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line /*#if AUTOPILOT_VERSION >= 1 */ #pragma empty_line typedef int __attribute__ ((bitwidth(65))) int65; typedef int __attribute__ ((bitwidth(66))) int66; typedef int __attribute__ ((bitwidth(67))) int67; typedef int __attribute__ ((bitwidth(68))) int68; typedef int __attribute__ ((bitwidth(69))) int69; typedef int __attribute__ ((bitwidth(70))) int70; typedef int __attribute__ ((bitwidth(71))) int71; typedef int __attribute__ ((bitwidth(72))) int72; typedef int __attribute__ ((bitwidth(73))) int73; typedef int __attribute__ ((bitwidth(74))) int74; typedef int __attribute__ ((bitwidth(75))) int75; typedef int __attribute__ ((bitwidth(76))) int76; typedef int __attribute__ ((bitwidth(77))) int77; typedef int __attribute__ ((bitwidth(78))) int78; typedef int __attribute__ ((bitwidth(79))) int79; typedef int __attribute__ ((bitwidth(80))) int80; typedef int __attribute__ ((bitwidth(81))) int81; typedef int __attribute__ ((bitwidth(82))) int82; typedef int __attribute__ ((bitwidth(83))) int83; typedef int __attribute__ ((bitwidth(84))) int84; typedef int __attribute__ ((bitwidth(85))) int85; typedef int __attribute__ ((bitwidth(86))) int86; typedef int __attribute__ ((bitwidth(87))) int87; typedef int __attribute__ ((bitwidth(88))) int88; typedef int __attribute__ ((bitwidth(89))) int89; typedef int __attribute__ ((bitwidth(90))) int90; typedef int __attribute__ ((bitwidth(91))) int91; typedef int __attribute__ ((bitwidth(92))) int92; typedef int __attribute__ ((bitwidth(93))) int93; typedef int __attribute__ ((bitwidth(94))) int94; typedef int __attribute__ ((bitwidth(95))) int95; typedef int __attribute__ ((bitwidth(96))) int96; typedef int __attribute__ ((bitwidth(97))) int97; typedef int __attribute__ ((bitwidth(98))) int98; typedef int __attribute__ ((bitwidth(99))) int99; typedef int __attribute__ ((bitwidth(100))) int100; typedef int __attribute__ ((bitwidth(101))) int101; typedef int __attribute__ ((bitwidth(102))) int102; typedef int __attribute__ ((bitwidth(103))) int103; typedef int __attribute__ ((bitwidth(104))) int104; typedef int __attribute__ ((bitwidth(105))) int105; typedef int __attribute__ ((bitwidth(106))) int106; typedef int __attribute__ ((bitwidth(107))) int107; typedef int __attribute__ ((bitwidth(108))) int108; typedef int __attribute__ ((bitwidth(109))) int109; typedef int __attribute__ ((bitwidth(110))) int110; typedef int __attribute__ ((bitwidth(111))) int111; typedef int __attribute__ ((bitwidth(112))) int112; typedef int __attribute__ ((bitwidth(113))) int113; typedef int __attribute__ ((bitwidth(114))) int114; typedef int __attribute__ ((bitwidth(115))) int115; typedef int __attribute__ ((bitwidth(116))) int116; typedef int __attribute__ ((bitwidth(117))) int117; typedef int __attribute__ ((bitwidth(118))) int118; typedef int __attribute__ ((bitwidth(119))) int119; typedef int __attribute__ ((bitwidth(120))) int120; typedef int __attribute__ ((bitwidth(121))) int121; typedef int __attribute__ ((bitwidth(122))) int122; typedef int __attribute__ ((bitwidth(123))) int123; typedef int __attribute__ ((bitwidth(124))) int124; typedef int __attribute__ ((bitwidth(125))) int125; typedef int __attribute__ ((bitwidth(126))) int126; typedef int __attribute__ ((bitwidth(127))) int127; typedef int __attribute__ ((bitwidth(128))) int128; #pragma empty_line /*#endif*/ #pragma empty_line #pragma empty_line /*#ifdef EXTENDED_GCC*/ #pragma empty_line typedef int __attribute__ ((bitwidth(129))) int129; typedef int __attribute__ ((bitwidth(130))) int130; typedef int __attribute__ ((bitwidth(131))) int131; typedef int __attribute__ ((bitwidth(132))) int132; typedef int __attribute__ ((bitwidth(133))) int133; typedef int __attribute__ ((bitwidth(134))) int134; typedef int __attribute__ ((bitwidth(135))) int135; typedef int __attribute__ ((bitwidth(136))) int136; typedef int __attribute__ ((bitwidth(137))) int137; typedef int __attribute__ ((bitwidth(138))) int138; typedef int __attribute__ ((bitwidth(139))) int139; typedef int __attribute__ ((bitwidth(140))) int140; typedef int __attribute__ ((bitwidth(141))) int141; typedef int __attribute__ ((bitwidth(142))) int142; typedef int __attribute__ ((bitwidth(143))) int143; typedef int __attribute__ ((bitwidth(144))) int144; typedef int __attribute__ ((bitwidth(145))) int145; typedef int __attribute__ ((bitwidth(146))) int146; typedef int __attribute__ ((bitwidth(147))) int147; typedef int __attribute__ ((bitwidth(148))) int148; typedef int __attribute__ ((bitwidth(149))) int149; typedef int __attribute__ ((bitwidth(150))) int150; typedef int __attribute__ ((bitwidth(151))) int151; typedef int __attribute__ ((bitwidth(152))) int152; typedef int __attribute__ ((bitwidth(153))) int153; typedef int __attribute__ ((bitwidth(154))) int154; typedef int __attribute__ ((bitwidth(155))) int155; typedef int __attribute__ ((bitwidth(156))) int156; typedef int __attribute__ ((bitwidth(157))) int157; typedef int __attribute__ ((bitwidth(158))) int158; typedef int __attribute__ ((bitwidth(159))) int159; typedef int __attribute__ ((bitwidth(160))) int160; typedef int __attribute__ ((bitwidth(161))) int161; typedef int __attribute__ ((bitwidth(162))) int162; typedef int __attribute__ ((bitwidth(163))) int163; typedef int __attribute__ ((bitwidth(164))) int164; typedef int __attribute__ ((bitwidth(165))) int165; typedef int __attribute__ ((bitwidth(166))) int166; typedef int __attribute__ ((bitwidth(167))) int167; typedef int __attribute__ ((bitwidth(168))) int168; typedef int __attribute__ ((bitwidth(169))) int169; typedef int __attribute__ ((bitwidth(170))) int170; typedef int __attribute__ ((bitwidth(171))) int171; typedef int __attribute__ ((bitwidth(172))) int172; typedef int __attribute__ ((bitwidth(173))) int173; typedef int __attribute__ ((bitwidth(174))) int174; typedef int __attribute__ ((bitwidth(175))) int175; typedef int __attribute__ ((bitwidth(176))) int176; typedef int __attribute__ ((bitwidth(177))) int177; typedef int __attribute__ ((bitwidth(178))) int178; typedef int __attribute__ ((bitwidth(179))) int179; typedef int __attribute__ ((bitwidth(180))) int180; typedef int __attribute__ ((bitwidth(181))) int181; typedef int __attribute__ ((bitwidth(182))) int182; typedef int __attribute__ ((bitwidth(183))) int183; typedef int __attribute__ ((bitwidth(184))) int184; typedef int __attribute__ ((bitwidth(185))) int185; typedef int __attribute__ ((bitwidth(186))) int186; typedef int __attribute__ ((bitwidth(187))) int187; typedef int __attribute__ ((bitwidth(188))) int188; typedef int __attribute__ ((bitwidth(189))) int189; typedef int __attribute__ ((bitwidth(190))) int190; typedef int __attribute__ ((bitwidth(191))) int191; typedef int __attribute__ ((bitwidth(192))) int192; typedef int __attribute__ ((bitwidth(193))) int193; typedef int __attribute__ ((bitwidth(194))) int194; typedef int __attribute__ ((bitwidth(195))) int195; typedef int __attribute__ ((bitwidth(196))) int196; typedef int __attribute__ ((bitwidth(197))) int197; typedef int __attribute__ ((bitwidth(198))) int198; typedef int __attribute__ ((bitwidth(199))) int199; typedef int __attribute__ ((bitwidth(200))) int200; typedef int __attribute__ ((bitwidth(201))) int201; typedef int __attribute__ ((bitwidth(202))) int202; typedef int __attribute__ ((bitwidth(203))) int203; typedef int __attribute__ ((bitwidth(204))) int204; typedef int __attribute__ ((bitwidth(205))) int205; typedef int __attribute__ ((bitwidth(206))) int206; typedef int __attribute__ ((bitwidth(207))) int207; typedef int __attribute__ ((bitwidth(208))) int208; typedef int __attribute__ ((bitwidth(209))) int209; typedef int __attribute__ ((bitwidth(210))) int210; typedef int __attribute__ ((bitwidth(211))) int211; typedef int __attribute__ ((bitwidth(212))) int212; typedef int __attribute__ ((bitwidth(213))) int213; typedef int __attribute__ ((bitwidth(214))) int214; typedef int __attribute__ ((bitwidth(215))) int215; typedef int __attribute__ ((bitwidth(216))) int216; typedef int __attribute__ ((bitwidth(217))) int217; typedef int __attribute__ ((bitwidth(218))) int218; typedef int __attribute__ ((bitwidth(219))) int219; typedef int __attribute__ ((bitwidth(220))) int220; typedef int __attribute__ ((bitwidth(221))) int221; typedef int __attribute__ ((bitwidth(222))) int222; typedef int __attribute__ ((bitwidth(223))) int223; typedef int __attribute__ ((bitwidth(224))) int224; typedef int __attribute__ ((bitwidth(225))) int225; typedef int __attribute__ ((bitwidth(226))) int226; typedef int __attribute__ ((bitwidth(227))) int227; typedef int __attribute__ ((bitwidth(228))) int228; typedef int __attribute__ ((bitwidth(229))) int229; typedef int __attribute__ ((bitwidth(230))) int230; typedef int __attribute__ ((bitwidth(231))) int231; typedef int __attribute__ ((bitwidth(232))) int232; typedef int __attribute__ ((bitwidth(233))) int233; typedef int __attribute__ ((bitwidth(234))) int234; typedef int __attribute__ ((bitwidth(235))) int235; typedef int __attribute__ ((bitwidth(236))) int236; typedef int __attribute__ ((bitwidth(237))) int237; typedef int __attribute__ ((bitwidth(238))) int238; typedef int __attribute__ ((bitwidth(239))) int239; typedef int __attribute__ ((bitwidth(240))) int240; typedef int __attribute__ ((bitwidth(241))) int241; typedef int __attribute__ ((bitwidth(242))) int242; typedef int __attribute__ ((bitwidth(243))) int243; typedef int __attribute__ ((bitwidth(244))) int244; typedef int __attribute__ ((bitwidth(245))) int245; typedef int __attribute__ ((bitwidth(246))) int246; typedef int __attribute__ ((bitwidth(247))) int247; typedef int __attribute__ ((bitwidth(248))) int248; typedef int __attribute__ ((bitwidth(249))) int249; typedef int __attribute__ ((bitwidth(250))) int250; typedef int __attribute__ ((bitwidth(251))) int251; typedef int __attribute__ ((bitwidth(252))) int252; typedef int __attribute__ ((bitwidth(253))) int253; typedef int __attribute__ ((bitwidth(254))) int254; typedef int __attribute__ ((bitwidth(255))) int255; typedef int __attribute__ ((bitwidth(256))) int256; typedef int __attribute__ ((bitwidth(257))) int257; typedef int __attribute__ ((bitwidth(258))) int258; typedef int __attribute__ ((bitwidth(259))) int259; typedef int __attribute__ ((bitwidth(260))) int260; typedef int __attribute__ ((bitwidth(261))) int261; typedef int __attribute__ ((bitwidth(262))) int262; typedef int __attribute__ ((bitwidth(263))) int263; typedef int __attribute__ ((bitwidth(264))) int264; typedef int __attribute__ ((bitwidth(265))) int265; typedef int __attribute__ ((bitwidth(266))) int266; typedef int __attribute__ ((bitwidth(267))) int267; typedef int __attribute__ ((bitwidth(268))) int268; typedef int __attribute__ ((bitwidth(269))) int269; typedef int __attribute__ ((bitwidth(270))) int270; typedef int __attribute__ ((bitwidth(271))) int271; typedef int __attribute__ ((bitwidth(272))) int272; typedef int __attribute__ ((bitwidth(273))) int273; typedef int __attribute__ ((bitwidth(274))) int274; typedef int __attribute__ ((bitwidth(275))) int275; typedef int __attribute__ ((bitwidth(276))) int276; typedef int __attribute__ ((bitwidth(277))) int277; typedef int __attribute__ ((bitwidth(278))) int278; typedef int __attribute__ ((bitwidth(279))) int279; typedef int __attribute__ ((bitwidth(280))) int280; typedef int __attribute__ ((bitwidth(281))) int281; typedef int __attribute__ ((bitwidth(282))) int282; typedef int __attribute__ ((bitwidth(283))) int283; typedef int __attribute__ ((bitwidth(284))) int284; typedef int __attribute__ ((bitwidth(285))) int285; typedef int __attribute__ ((bitwidth(286))) int286; typedef int __attribute__ ((bitwidth(287))) int287; typedef int __attribute__ ((bitwidth(288))) int288; typedef int __attribute__ ((bitwidth(289))) int289; typedef int __attribute__ ((bitwidth(290))) int290; typedef int __attribute__ ((bitwidth(291))) int291; typedef int __attribute__ ((bitwidth(292))) int292; typedef int __attribute__ ((bitwidth(293))) int293; typedef int __attribute__ ((bitwidth(294))) int294; typedef int __attribute__ ((bitwidth(295))) int295; typedef int __attribute__ ((bitwidth(296))) int296; typedef int __attribute__ ((bitwidth(297))) int297; typedef int __attribute__ ((bitwidth(298))) int298; typedef int __attribute__ ((bitwidth(299))) int299; typedef int __attribute__ ((bitwidth(300))) int300; typedef int __attribute__ ((bitwidth(301))) int301; typedef int __attribute__ ((bitwidth(302))) int302; typedef int __attribute__ ((bitwidth(303))) int303; typedef int __attribute__ ((bitwidth(304))) int304; typedef int __attribute__ ((bitwidth(305))) int305; typedef int __attribute__ ((bitwidth(306))) int306; typedef int __attribute__ ((bitwidth(307))) int307; typedef int __attribute__ ((bitwidth(308))) int308; typedef int __attribute__ ((bitwidth(309))) int309; typedef int __attribute__ ((bitwidth(310))) int310; typedef int __attribute__ ((bitwidth(311))) int311; typedef int __attribute__ ((bitwidth(312))) int312; typedef int __attribute__ ((bitwidth(313))) int313; typedef int __attribute__ ((bitwidth(314))) int314; typedef int __attribute__ ((bitwidth(315))) int315; typedef int __attribute__ ((bitwidth(316))) int316; typedef int __attribute__ ((bitwidth(317))) int317; typedef int __attribute__ ((bitwidth(318))) int318; typedef int __attribute__ ((bitwidth(319))) int319; typedef int __attribute__ ((bitwidth(320))) int320; typedef int __attribute__ ((bitwidth(321))) int321; typedef int __attribute__ ((bitwidth(322))) int322; typedef int __attribute__ ((bitwidth(323))) int323; typedef int __attribute__ ((bitwidth(324))) int324; typedef int __attribute__ ((bitwidth(325))) int325; typedef int __attribute__ ((bitwidth(326))) int326; typedef int __attribute__ ((bitwidth(327))) int327; typedef int __attribute__ ((bitwidth(328))) int328; typedef int __attribute__ ((bitwidth(329))) int329; typedef int __attribute__ ((bitwidth(330))) int330; typedef int __attribute__ ((bitwidth(331))) int331; typedef int __attribute__ ((bitwidth(332))) int332; typedef int __attribute__ ((bitwidth(333))) int333; typedef int __attribute__ ((bitwidth(334))) int334; typedef int __attribute__ ((bitwidth(335))) int335; typedef int __attribute__ ((bitwidth(336))) int336; typedef int __attribute__ ((bitwidth(337))) int337; typedef int __attribute__ ((bitwidth(338))) int338; typedef int __attribute__ ((bitwidth(339))) int339; typedef int __attribute__ ((bitwidth(340))) int340; typedef int __attribute__ ((bitwidth(341))) int341; typedef int __attribute__ ((bitwidth(342))) int342; typedef int __attribute__ ((bitwidth(343))) int343; typedef int __attribute__ ((bitwidth(344))) int344; typedef int __attribute__ ((bitwidth(345))) int345; typedef int __attribute__ ((bitwidth(346))) int346; typedef int __attribute__ ((bitwidth(347))) int347; typedef int __attribute__ ((bitwidth(348))) int348; typedef int __attribute__ ((bitwidth(349))) int349; typedef int __attribute__ ((bitwidth(350))) int350; typedef int __attribute__ ((bitwidth(351))) int351; typedef int __attribute__ ((bitwidth(352))) int352; typedef int __attribute__ ((bitwidth(353))) int353; typedef int __attribute__ ((bitwidth(354))) int354; typedef int __attribute__ ((bitwidth(355))) int355; typedef int __attribute__ ((bitwidth(356))) int356; typedef int __attribute__ ((bitwidth(357))) int357; typedef int __attribute__ ((bitwidth(358))) int358; typedef int __attribute__ ((bitwidth(359))) int359; typedef int __attribute__ ((bitwidth(360))) int360; typedef int __attribute__ ((bitwidth(361))) int361; typedef int __attribute__ ((bitwidth(362))) int362; typedef int __attribute__ ((bitwidth(363))) int363; typedef int __attribute__ ((bitwidth(364))) int364; typedef int __attribute__ ((bitwidth(365))) int365; typedef int __attribute__ ((bitwidth(366))) int366; typedef int __attribute__ ((bitwidth(367))) int367; typedef int __attribute__ ((bitwidth(368))) int368; typedef int __attribute__ ((bitwidth(369))) int369; typedef int __attribute__ ((bitwidth(370))) int370; typedef int __attribute__ ((bitwidth(371))) int371; typedef int __attribute__ ((bitwidth(372))) int372; typedef int __attribute__ ((bitwidth(373))) int373; typedef int __attribute__ ((bitwidth(374))) int374; typedef int __attribute__ ((bitwidth(375))) int375; typedef int __attribute__ ((bitwidth(376))) int376; typedef int __attribute__ ((bitwidth(377))) int377; typedef int __attribute__ ((bitwidth(378))) int378; typedef int __attribute__ ((bitwidth(379))) int379; typedef int __attribute__ ((bitwidth(380))) int380; typedef int __attribute__ ((bitwidth(381))) int381; typedef int __attribute__ ((bitwidth(382))) int382; typedef int __attribute__ ((bitwidth(383))) int383; typedef int __attribute__ ((bitwidth(384))) int384; typedef int __attribute__ ((bitwidth(385))) int385; typedef int __attribute__ ((bitwidth(386))) int386; typedef int __attribute__ ((bitwidth(387))) int387; typedef int __attribute__ ((bitwidth(388))) int388; typedef int __attribute__ ((bitwidth(389))) int389; typedef int __attribute__ ((bitwidth(390))) int390; typedef int __attribute__ ((bitwidth(391))) int391; typedef int __attribute__ ((bitwidth(392))) int392; typedef int __attribute__ ((bitwidth(393))) int393; typedef int __attribute__ ((bitwidth(394))) int394; typedef int __attribute__ ((bitwidth(395))) int395; typedef int __attribute__ ((bitwidth(396))) int396; typedef int __attribute__ ((bitwidth(397))) int397; typedef int __attribute__ ((bitwidth(398))) int398; typedef int __attribute__ ((bitwidth(399))) int399; typedef int __attribute__ ((bitwidth(400))) int400; typedef int __attribute__ ((bitwidth(401))) int401; typedef int __attribute__ ((bitwidth(402))) int402; typedef int __attribute__ ((bitwidth(403))) int403; typedef int __attribute__ ((bitwidth(404))) int404; typedef int __attribute__ ((bitwidth(405))) int405; typedef int __attribute__ ((bitwidth(406))) int406; typedef int __attribute__ ((bitwidth(407))) int407; typedef int __attribute__ ((bitwidth(408))) int408; typedef int __attribute__ ((bitwidth(409))) int409; typedef int __attribute__ ((bitwidth(410))) int410; typedef int __attribute__ ((bitwidth(411))) int411; typedef int __attribute__ ((bitwidth(412))) int412; typedef int __attribute__ ((bitwidth(413))) int413; typedef int __attribute__ ((bitwidth(414))) int414; typedef int __attribute__ ((bitwidth(415))) int415; typedef int __attribute__ ((bitwidth(416))) int416; typedef int __attribute__ ((bitwidth(417))) int417; typedef int __attribute__ ((bitwidth(418))) int418; typedef int __attribute__ ((bitwidth(419))) int419; typedef int __attribute__ ((bitwidth(420))) int420; typedef int __attribute__ ((bitwidth(421))) int421; typedef int __attribute__ ((bitwidth(422))) int422; typedef int __attribute__ ((bitwidth(423))) int423; typedef int __attribute__ ((bitwidth(424))) int424; typedef int __attribute__ ((bitwidth(425))) int425; typedef int __attribute__ ((bitwidth(426))) int426; typedef int __attribute__ ((bitwidth(427))) int427; typedef int __attribute__ ((bitwidth(428))) int428; typedef int __attribute__ ((bitwidth(429))) int429; typedef int __attribute__ ((bitwidth(430))) int430; typedef int __attribute__ ((bitwidth(431))) int431; typedef int __attribute__ ((bitwidth(432))) int432; typedef int __attribute__ ((bitwidth(433))) int433; typedef int __attribute__ ((bitwidth(434))) int434; typedef int __attribute__ ((bitwidth(435))) int435; typedef int __attribute__ ((bitwidth(436))) int436; typedef int __attribute__ ((bitwidth(437))) int437; typedef int __attribute__ ((bitwidth(438))) int438; typedef int __attribute__ ((bitwidth(439))) int439; typedef int __attribute__ ((bitwidth(440))) int440; typedef int __attribute__ ((bitwidth(441))) int441; typedef int __attribute__ ((bitwidth(442))) int442; typedef int __attribute__ ((bitwidth(443))) int443; typedef int __attribute__ ((bitwidth(444))) int444; typedef int __attribute__ ((bitwidth(445))) int445; typedef int __attribute__ ((bitwidth(446))) int446; typedef int __attribute__ ((bitwidth(447))) int447; typedef int __attribute__ ((bitwidth(448))) int448; typedef int __attribute__ ((bitwidth(449))) int449; typedef int __attribute__ ((bitwidth(450))) int450; typedef int __attribute__ ((bitwidth(451))) int451; typedef int __attribute__ ((bitwidth(452))) int452; typedef int __attribute__ ((bitwidth(453))) int453; typedef int __attribute__ ((bitwidth(454))) int454; typedef int __attribute__ ((bitwidth(455))) int455; typedef int __attribute__ ((bitwidth(456))) int456; typedef int __attribute__ ((bitwidth(457))) int457; typedef int __attribute__ ((bitwidth(458))) int458; typedef int __attribute__ ((bitwidth(459))) int459; typedef int __attribute__ ((bitwidth(460))) int460; typedef int __attribute__ ((bitwidth(461))) int461; typedef int __attribute__ ((bitwidth(462))) int462; typedef int __attribute__ ((bitwidth(463))) int463; typedef int __attribute__ ((bitwidth(464))) int464; typedef int __attribute__ ((bitwidth(465))) int465; typedef int __attribute__ ((bitwidth(466))) int466; typedef int __attribute__ ((bitwidth(467))) int467; typedef int __attribute__ ((bitwidth(468))) int468; typedef int __attribute__ ((bitwidth(469))) int469; typedef int __attribute__ ((bitwidth(470))) int470; typedef int __attribute__ ((bitwidth(471))) int471; typedef int __attribute__ ((bitwidth(472))) int472; typedef int __attribute__ ((bitwidth(473))) int473; typedef int __attribute__ ((bitwidth(474))) int474; typedef int __attribute__ ((bitwidth(475))) int475; typedef int __attribute__ ((bitwidth(476))) int476; typedef int __attribute__ ((bitwidth(477))) int477; typedef int __attribute__ ((bitwidth(478))) int478; typedef int __attribute__ ((bitwidth(479))) int479; typedef int __attribute__ ((bitwidth(480))) int480; typedef int __attribute__ ((bitwidth(481))) int481; typedef int __attribute__ ((bitwidth(482))) int482; typedef int __attribute__ ((bitwidth(483))) int483; typedef int __attribute__ ((bitwidth(484))) int484; typedef int __attribute__ ((bitwidth(485))) int485; typedef int __attribute__ ((bitwidth(486))) int486; typedef int __attribute__ ((bitwidth(487))) int487; typedef int __attribute__ ((bitwidth(488))) int488; typedef int __attribute__ ((bitwidth(489))) int489; typedef int __attribute__ ((bitwidth(490))) int490; typedef int __attribute__ ((bitwidth(491))) int491; typedef int __attribute__ ((bitwidth(492))) int492; typedef int __attribute__ ((bitwidth(493))) int493; typedef int __attribute__ ((bitwidth(494))) int494; typedef int __attribute__ ((bitwidth(495))) int495; typedef int __attribute__ ((bitwidth(496))) int496; typedef int __attribute__ ((bitwidth(497))) int497; typedef int __attribute__ ((bitwidth(498))) int498; typedef int __attribute__ ((bitwidth(499))) int499; typedef int __attribute__ ((bitwidth(500))) int500; typedef int __attribute__ ((bitwidth(501))) int501; typedef int __attribute__ ((bitwidth(502))) int502; typedef int __attribute__ ((bitwidth(503))) int503; typedef int __attribute__ ((bitwidth(504))) int504; typedef int __attribute__ ((bitwidth(505))) int505; typedef int __attribute__ ((bitwidth(506))) int506; typedef int __attribute__ ((bitwidth(507))) int507; typedef int __attribute__ ((bitwidth(508))) int508; typedef int __attribute__ ((bitwidth(509))) int509; typedef int __attribute__ ((bitwidth(510))) int510; typedef int __attribute__ ((bitwidth(511))) int511; typedef int __attribute__ ((bitwidth(512))) int512; typedef int __attribute__ ((bitwidth(513))) int513; typedef int __attribute__ ((bitwidth(514))) int514; typedef int __attribute__ ((bitwidth(515))) int515; typedef int __attribute__ ((bitwidth(516))) int516; typedef int __attribute__ ((bitwidth(517))) int517; typedef int __attribute__ ((bitwidth(518))) int518; typedef int __attribute__ ((bitwidth(519))) int519; typedef int __attribute__ ((bitwidth(520))) int520; typedef int __attribute__ ((bitwidth(521))) int521; typedef int __attribute__ ((bitwidth(522))) int522; typedef int __attribute__ ((bitwidth(523))) int523; typedef int __attribute__ ((bitwidth(524))) int524; typedef int __attribute__ ((bitwidth(525))) int525; typedef int __attribute__ ((bitwidth(526))) int526; typedef int __attribute__ ((bitwidth(527))) int527; typedef int __attribute__ ((bitwidth(528))) int528; typedef int __attribute__ ((bitwidth(529))) int529; typedef int __attribute__ ((bitwidth(530))) int530; typedef int __attribute__ ((bitwidth(531))) int531; typedef int __attribute__ ((bitwidth(532))) int532; typedef int __attribute__ ((bitwidth(533))) int533; typedef int __attribute__ ((bitwidth(534))) int534; typedef int __attribute__ ((bitwidth(535))) int535; typedef int __attribute__ ((bitwidth(536))) int536; typedef int __attribute__ ((bitwidth(537))) int537; typedef int __attribute__ ((bitwidth(538))) int538; typedef int __attribute__ ((bitwidth(539))) int539; typedef int __attribute__ ((bitwidth(540))) int540; typedef int __attribute__ ((bitwidth(541))) int541; typedef int __attribute__ ((bitwidth(542))) int542; typedef int __attribute__ ((bitwidth(543))) int543; typedef int __attribute__ ((bitwidth(544))) int544; typedef int __attribute__ ((bitwidth(545))) int545; typedef int __attribute__ ((bitwidth(546))) int546; typedef int __attribute__ ((bitwidth(547))) int547; typedef int __attribute__ ((bitwidth(548))) int548; typedef int __attribute__ ((bitwidth(549))) int549; typedef int __attribute__ ((bitwidth(550))) int550; typedef int __attribute__ ((bitwidth(551))) int551; typedef int __attribute__ ((bitwidth(552))) int552; typedef int __attribute__ ((bitwidth(553))) int553; typedef int __attribute__ ((bitwidth(554))) int554; typedef int __attribute__ ((bitwidth(555))) int555; typedef int __attribute__ ((bitwidth(556))) int556; typedef int __attribute__ ((bitwidth(557))) int557; typedef int __attribute__ ((bitwidth(558))) int558; typedef int __attribute__ ((bitwidth(559))) int559; typedef int __attribute__ ((bitwidth(560))) int560; typedef int __attribute__ ((bitwidth(561))) int561; typedef int __attribute__ ((bitwidth(562))) int562; typedef int __attribute__ ((bitwidth(563))) int563; typedef int __attribute__ ((bitwidth(564))) int564; typedef int __attribute__ ((bitwidth(565))) int565; typedef int __attribute__ ((bitwidth(566))) int566; typedef int __attribute__ ((bitwidth(567))) int567; typedef int __attribute__ ((bitwidth(568))) int568; typedef int __attribute__ ((bitwidth(569))) int569; typedef int __attribute__ ((bitwidth(570))) int570; typedef int __attribute__ ((bitwidth(571))) int571; typedef int __attribute__ ((bitwidth(572))) int572; typedef int __attribute__ ((bitwidth(573))) int573; typedef int __attribute__ ((bitwidth(574))) int574; typedef int __attribute__ ((bitwidth(575))) int575; typedef int __attribute__ ((bitwidth(576))) int576; typedef int __attribute__ ((bitwidth(577))) int577; typedef int __attribute__ ((bitwidth(578))) int578; typedef int __attribute__ ((bitwidth(579))) int579; typedef int __attribute__ ((bitwidth(580))) int580; typedef int __attribute__ ((bitwidth(581))) int581; typedef int __attribute__ ((bitwidth(582))) int582; typedef int __attribute__ ((bitwidth(583))) int583; typedef int __attribute__ ((bitwidth(584))) int584; typedef int __attribute__ ((bitwidth(585))) int585; typedef int __attribute__ ((bitwidth(586))) int586; typedef int __attribute__ ((bitwidth(587))) int587; typedef int __attribute__ ((bitwidth(588))) int588; typedef int __attribute__ ((bitwidth(589))) int589; typedef int __attribute__ ((bitwidth(590))) int590; typedef int __attribute__ ((bitwidth(591))) int591; typedef int __attribute__ ((bitwidth(592))) int592; typedef int __attribute__ ((bitwidth(593))) int593; typedef int __attribute__ ((bitwidth(594))) int594; typedef int __attribute__ ((bitwidth(595))) int595; typedef int __attribute__ ((bitwidth(596))) int596; typedef int __attribute__ ((bitwidth(597))) int597; typedef int __attribute__ ((bitwidth(598))) int598; typedef int __attribute__ ((bitwidth(599))) int599; typedef int __attribute__ ((bitwidth(600))) int600; typedef int __attribute__ ((bitwidth(601))) int601; typedef int __attribute__ ((bitwidth(602))) int602; typedef int __attribute__ ((bitwidth(603))) int603; typedef int __attribute__ ((bitwidth(604))) int604; typedef int __attribute__ ((bitwidth(605))) int605; typedef int __attribute__ ((bitwidth(606))) int606; typedef int __attribute__ ((bitwidth(607))) int607; typedef int __attribute__ ((bitwidth(608))) int608; typedef int __attribute__ ((bitwidth(609))) int609; typedef int __attribute__ ((bitwidth(610))) int610; typedef int __attribute__ ((bitwidth(611))) int611; typedef int __attribute__ ((bitwidth(612))) int612; typedef int __attribute__ ((bitwidth(613))) int613; typedef int __attribute__ ((bitwidth(614))) int614; typedef int __attribute__ ((bitwidth(615))) int615; typedef int __attribute__ ((bitwidth(616))) int616; typedef int __attribute__ ((bitwidth(617))) int617; typedef int __attribute__ ((bitwidth(618))) int618; typedef int __attribute__ ((bitwidth(619))) int619; typedef int __attribute__ ((bitwidth(620))) int620; typedef int __attribute__ ((bitwidth(621))) int621; typedef int __attribute__ ((bitwidth(622))) int622; typedef int __attribute__ ((bitwidth(623))) int623; typedef int __attribute__ ((bitwidth(624))) int624; typedef int __attribute__ ((bitwidth(625))) int625; typedef int __attribute__ ((bitwidth(626))) int626; typedef int __attribute__ ((bitwidth(627))) int627; typedef int __attribute__ ((bitwidth(628))) int628; typedef int __attribute__ ((bitwidth(629))) int629; typedef int __attribute__ ((bitwidth(630))) int630; typedef int __attribute__ ((bitwidth(631))) int631; typedef int __attribute__ ((bitwidth(632))) int632; typedef int __attribute__ ((bitwidth(633))) int633; typedef int __attribute__ ((bitwidth(634))) int634; typedef int __attribute__ ((bitwidth(635))) int635; typedef int __attribute__ ((bitwidth(636))) int636; typedef int __attribute__ ((bitwidth(637))) int637; typedef int __attribute__ ((bitwidth(638))) int638; typedef int __attribute__ ((bitwidth(639))) int639; typedef int __attribute__ ((bitwidth(640))) int640; typedef int __attribute__ ((bitwidth(641))) int641; typedef int __attribute__ ((bitwidth(642))) int642; typedef int __attribute__ ((bitwidth(643))) int643; typedef int __attribute__ ((bitwidth(644))) int644; typedef int __attribute__ ((bitwidth(645))) int645; typedef int __attribute__ ((bitwidth(646))) int646; typedef int __attribute__ ((bitwidth(647))) int647; typedef int __attribute__ ((bitwidth(648))) int648; typedef int __attribute__ ((bitwidth(649))) int649; typedef int __attribute__ ((bitwidth(650))) int650; typedef int __attribute__ ((bitwidth(651))) int651; typedef int __attribute__ ((bitwidth(652))) int652; typedef int __attribute__ ((bitwidth(653))) int653; typedef int __attribute__ ((bitwidth(654))) int654; typedef int __attribute__ ((bitwidth(655))) int655; typedef int __attribute__ ((bitwidth(656))) int656; typedef int __attribute__ ((bitwidth(657))) int657; typedef int __attribute__ ((bitwidth(658))) int658; typedef int __attribute__ ((bitwidth(659))) int659; typedef int __attribute__ ((bitwidth(660))) int660; typedef int __attribute__ ((bitwidth(661))) int661; typedef int __attribute__ ((bitwidth(662))) int662; typedef int __attribute__ ((bitwidth(663))) int663; typedef int __attribute__ ((bitwidth(664))) int664; typedef int __attribute__ ((bitwidth(665))) int665; typedef int __attribute__ ((bitwidth(666))) int666; typedef int __attribute__ ((bitwidth(667))) int667; typedef int __attribute__ ((bitwidth(668))) int668; typedef int __attribute__ ((bitwidth(669))) int669; typedef int __attribute__ ((bitwidth(670))) int670; typedef int __attribute__ ((bitwidth(671))) int671; typedef int __attribute__ ((bitwidth(672))) int672; typedef int __attribute__ ((bitwidth(673))) int673; typedef int __attribute__ ((bitwidth(674))) int674; typedef int __attribute__ ((bitwidth(675))) int675; typedef int __attribute__ ((bitwidth(676))) int676; typedef int __attribute__ ((bitwidth(677))) int677; typedef int __attribute__ ((bitwidth(678))) int678; typedef int __attribute__ ((bitwidth(679))) int679; typedef int __attribute__ ((bitwidth(680))) int680; typedef int __attribute__ ((bitwidth(681))) int681; typedef int __attribute__ ((bitwidth(682))) int682; typedef int __attribute__ ((bitwidth(683))) int683; typedef int __attribute__ ((bitwidth(684))) int684; typedef int __attribute__ ((bitwidth(685))) int685; typedef int __attribute__ ((bitwidth(686))) int686; typedef int __attribute__ ((bitwidth(687))) int687; typedef int __attribute__ ((bitwidth(688))) int688; typedef int __attribute__ ((bitwidth(689))) int689; typedef int __attribute__ ((bitwidth(690))) int690; typedef int __attribute__ ((bitwidth(691))) int691; typedef int __attribute__ ((bitwidth(692))) int692; typedef int __attribute__ ((bitwidth(693))) int693; typedef int __attribute__ ((bitwidth(694))) int694; typedef int __attribute__ ((bitwidth(695))) int695; typedef int __attribute__ ((bitwidth(696))) int696; typedef int __attribute__ ((bitwidth(697))) int697; typedef int __attribute__ ((bitwidth(698))) int698; typedef int __attribute__ ((bitwidth(699))) int699; typedef int __attribute__ ((bitwidth(700))) int700; typedef int __attribute__ ((bitwidth(701))) int701; typedef int __attribute__ ((bitwidth(702))) int702; typedef int __attribute__ ((bitwidth(703))) int703; typedef int __attribute__ ((bitwidth(704))) int704; typedef int __attribute__ ((bitwidth(705))) int705; typedef int __attribute__ ((bitwidth(706))) int706; typedef int __attribute__ ((bitwidth(707))) int707; typedef int __attribute__ ((bitwidth(708))) int708; typedef int __attribute__ ((bitwidth(709))) int709; typedef int __attribute__ ((bitwidth(710))) int710; typedef int __attribute__ ((bitwidth(711))) int711; typedef int __attribute__ ((bitwidth(712))) int712; typedef int __attribute__ ((bitwidth(713))) int713; typedef int __attribute__ ((bitwidth(714))) int714; typedef int __attribute__ ((bitwidth(715))) int715; typedef int __attribute__ ((bitwidth(716))) int716; typedef int __attribute__ ((bitwidth(717))) int717; typedef int __attribute__ ((bitwidth(718))) int718; typedef int __attribute__ ((bitwidth(719))) int719; typedef int __attribute__ ((bitwidth(720))) int720; typedef int __attribute__ ((bitwidth(721))) int721; typedef int __attribute__ ((bitwidth(722))) int722; typedef int __attribute__ ((bitwidth(723))) int723; typedef int __attribute__ ((bitwidth(724))) int724; typedef int __attribute__ ((bitwidth(725))) int725; typedef int __attribute__ ((bitwidth(726))) int726; typedef int __attribute__ ((bitwidth(727))) int727; typedef int __attribute__ ((bitwidth(728))) int728; typedef int __attribute__ ((bitwidth(729))) int729; typedef int __attribute__ ((bitwidth(730))) int730; typedef int __attribute__ ((bitwidth(731))) int731; typedef int __attribute__ ((bitwidth(732))) int732; typedef int __attribute__ ((bitwidth(733))) int733; typedef int __attribute__ ((bitwidth(734))) int734; typedef int __attribute__ ((bitwidth(735))) int735; typedef int __attribute__ ((bitwidth(736))) int736; typedef int __attribute__ ((bitwidth(737))) int737; typedef int __attribute__ ((bitwidth(738))) int738; typedef int __attribute__ ((bitwidth(739))) int739; typedef int __attribute__ ((bitwidth(740))) int740; typedef int __attribute__ ((bitwidth(741))) int741; typedef int __attribute__ ((bitwidth(742))) int742; typedef int __attribute__ ((bitwidth(743))) int743; typedef int __attribute__ ((bitwidth(744))) int744; typedef int __attribute__ ((bitwidth(745))) int745; typedef int __attribute__ ((bitwidth(746))) int746; typedef int __attribute__ ((bitwidth(747))) int747; typedef int __attribute__ ((bitwidth(748))) int748; typedef int __attribute__ ((bitwidth(749))) int749; typedef int __attribute__ ((bitwidth(750))) int750; typedef int __attribute__ ((bitwidth(751))) int751; typedef int __attribute__ ((bitwidth(752))) int752; typedef int __attribute__ ((bitwidth(753))) int753; typedef int __attribute__ ((bitwidth(754))) int754; typedef int __attribute__ ((bitwidth(755))) int755; typedef int __attribute__ ((bitwidth(756))) int756; typedef int __attribute__ ((bitwidth(757))) int757; typedef int __attribute__ ((bitwidth(758))) int758; typedef int __attribute__ ((bitwidth(759))) int759; typedef int __attribute__ ((bitwidth(760))) int760; typedef int __attribute__ ((bitwidth(761))) int761; typedef int __attribute__ ((bitwidth(762))) int762; typedef int __attribute__ ((bitwidth(763))) int763; typedef int __attribute__ ((bitwidth(764))) int764; typedef int __attribute__ ((bitwidth(765))) int765; typedef int __attribute__ ((bitwidth(766))) int766; typedef int __attribute__ ((bitwidth(767))) int767; typedef int __attribute__ ((bitwidth(768))) int768; typedef int __attribute__ ((bitwidth(769))) int769; typedef int __attribute__ ((bitwidth(770))) int770; typedef int __attribute__ ((bitwidth(771))) int771; typedef int __attribute__ ((bitwidth(772))) int772; typedef int __attribute__ ((bitwidth(773))) int773; typedef int __attribute__ ((bitwidth(774))) int774; typedef int __attribute__ ((bitwidth(775))) int775; typedef int __attribute__ ((bitwidth(776))) int776; typedef int __attribute__ ((bitwidth(777))) int777; typedef int __attribute__ ((bitwidth(778))) int778; typedef int __attribute__ ((bitwidth(779))) int779; typedef int __attribute__ ((bitwidth(780))) int780; typedef int __attribute__ ((bitwidth(781))) int781; typedef int __attribute__ ((bitwidth(782))) int782; typedef int __attribute__ ((bitwidth(783))) int783; typedef int __attribute__ ((bitwidth(784))) int784; typedef int __attribute__ ((bitwidth(785))) int785; typedef int __attribute__ ((bitwidth(786))) int786; typedef int __attribute__ ((bitwidth(787))) int787; typedef int __attribute__ ((bitwidth(788))) int788; typedef int __attribute__ ((bitwidth(789))) int789; typedef int __attribute__ ((bitwidth(790))) int790; typedef int __attribute__ ((bitwidth(791))) int791; typedef int __attribute__ ((bitwidth(792))) int792; typedef int __attribute__ ((bitwidth(793))) int793; typedef int __attribute__ ((bitwidth(794))) int794; typedef int __attribute__ ((bitwidth(795))) int795; typedef int __attribute__ ((bitwidth(796))) int796; typedef int __attribute__ ((bitwidth(797))) int797; typedef int __attribute__ ((bitwidth(798))) int798; typedef int __attribute__ ((bitwidth(799))) int799; typedef int __attribute__ ((bitwidth(800))) int800; typedef int __attribute__ ((bitwidth(801))) int801; typedef int __attribute__ ((bitwidth(802))) int802; typedef int __attribute__ ((bitwidth(803))) int803; typedef int __attribute__ ((bitwidth(804))) int804; typedef int __attribute__ ((bitwidth(805))) int805; typedef int __attribute__ ((bitwidth(806))) int806; typedef int __attribute__ ((bitwidth(807))) int807; typedef int __attribute__ ((bitwidth(808))) int808; typedef int __attribute__ ((bitwidth(809))) int809; typedef int __attribute__ ((bitwidth(810))) int810; typedef int __attribute__ ((bitwidth(811))) int811; typedef int __attribute__ ((bitwidth(812))) int812; typedef int __attribute__ ((bitwidth(813))) int813; typedef int __attribute__ ((bitwidth(814))) int814; typedef int __attribute__ ((bitwidth(815))) int815; typedef int __attribute__ ((bitwidth(816))) int816; typedef int __attribute__ ((bitwidth(817))) int817; typedef int __attribute__ ((bitwidth(818))) int818; typedef int __attribute__ ((bitwidth(819))) int819; typedef int __attribute__ ((bitwidth(820))) int820; typedef int __attribute__ ((bitwidth(821))) int821; typedef int __attribute__ ((bitwidth(822))) int822; typedef int __attribute__ ((bitwidth(823))) int823; typedef int __attribute__ ((bitwidth(824))) int824; typedef int __attribute__ ((bitwidth(825))) int825; typedef int __attribute__ ((bitwidth(826))) int826; typedef int __attribute__ ((bitwidth(827))) int827; typedef int __attribute__ ((bitwidth(828))) int828; typedef int __attribute__ ((bitwidth(829))) int829; typedef int __attribute__ ((bitwidth(830))) int830; typedef int __attribute__ ((bitwidth(831))) int831; typedef int __attribute__ ((bitwidth(832))) int832; typedef int __attribute__ ((bitwidth(833))) int833; typedef int __attribute__ ((bitwidth(834))) int834; typedef int __attribute__ ((bitwidth(835))) int835; typedef int __attribute__ ((bitwidth(836))) int836; typedef int __attribute__ ((bitwidth(837))) int837; typedef int __attribute__ ((bitwidth(838))) int838; typedef int __attribute__ ((bitwidth(839))) int839; typedef int __attribute__ ((bitwidth(840))) int840; typedef int __attribute__ ((bitwidth(841))) int841; typedef int __attribute__ ((bitwidth(842))) int842; typedef int __attribute__ ((bitwidth(843))) int843; typedef int __attribute__ ((bitwidth(844))) int844; typedef int __attribute__ ((bitwidth(845))) int845; typedef int __attribute__ ((bitwidth(846))) int846; typedef int __attribute__ ((bitwidth(847))) int847; typedef int __attribute__ ((bitwidth(848))) int848; typedef int __attribute__ ((bitwidth(849))) int849; typedef int __attribute__ ((bitwidth(850))) int850; typedef int __attribute__ ((bitwidth(851))) int851; typedef int __attribute__ ((bitwidth(852))) int852; typedef int __attribute__ ((bitwidth(853))) int853; typedef int __attribute__ ((bitwidth(854))) int854; typedef int __attribute__ ((bitwidth(855))) int855; typedef int __attribute__ ((bitwidth(856))) int856; typedef int __attribute__ ((bitwidth(857))) int857; typedef int __attribute__ ((bitwidth(858))) int858; typedef int __attribute__ ((bitwidth(859))) int859; typedef int __attribute__ ((bitwidth(860))) int860; typedef int __attribute__ ((bitwidth(861))) int861; typedef int __attribute__ ((bitwidth(862))) int862; typedef int __attribute__ ((bitwidth(863))) int863; typedef int __attribute__ ((bitwidth(864))) int864; typedef int __attribute__ ((bitwidth(865))) int865; typedef int __attribute__ ((bitwidth(866))) int866; typedef int __attribute__ ((bitwidth(867))) int867; typedef int __attribute__ ((bitwidth(868))) int868; typedef int __attribute__ ((bitwidth(869))) int869; typedef int __attribute__ ((bitwidth(870))) int870; typedef int __attribute__ ((bitwidth(871))) int871; typedef int __attribute__ ((bitwidth(872))) int872; typedef int __attribute__ ((bitwidth(873))) int873; typedef int __attribute__ ((bitwidth(874))) int874; typedef int __attribute__ ((bitwidth(875))) int875; typedef int __attribute__ ((bitwidth(876))) int876; typedef int __attribute__ ((bitwidth(877))) int877; typedef int __attribute__ ((bitwidth(878))) int878; typedef int __attribute__ ((bitwidth(879))) int879; typedef int __attribute__ ((bitwidth(880))) int880; typedef int __attribute__ ((bitwidth(881))) int881; typedef int __attribute__ ((bitwidth(882))) int882; typedef int __attribute__ ((bitwidth(883))) int883; typedef int __attribute__ ((bitwidth(884))) int884; typedef int __attribute__ ((bitwidth(885))) int885; typedef int __attribute__ ((bitwidth(886))) int886; typedef int __attribute__ ((bitwidth(887))) int887; typedef int __attribute__ ((bitwidth(888))) int888; typedef int __attribute__ ((bitwidth(889))) int889; typedef int __attribute__ ((bitwidth(890))) int890; typedef int __attribute__ ((bitwidth(891))) int891; typedef int __attribute__ ((bitwidth(892))) int892; typedef int __attribute__ ((bitwidth(893))) int893; typedef int __attribute__ ((bitwidth(894))) int894; typedef int __attribute__ ((bitwidth(895))) int895; typedef int __attribute__ ((bitwidth(896))) int896; typedef int __attribute__ ((bitwidth(897))) int897; typedef int __attribute__ ((bitwidth(898))) int898; typedef int __attribute__ ((bitwidth(899))) int899; typedef int __attribute__ ((bitwidth(900))) int900; typedef int __attribute__ ((bitwidth(901))) int901; typedef int __attribute__ ((bitwidth(902))) int902; typedef int __attribute__ ((bitwidth(903))) int903; typedef int __attribute__ ((bitwidth(904))) int904; typedef int __attribute__ ((bitwidth(905))) int905; typedef int __attribute__ ((bitwidth(906))) int906; typedef int __attribute__ ((bitwidth(907))) int907; typedef int __attribute__ ((bitwidth(908))) int908; typedef int __attribute__ ((bitwidth(909))) int909; typedef int __attribute__ ((bitwidth(910))) int910; typedef int __attribute__ ((bitwidth(911))) int911; typedef int __attribute__ ((bitwidth(912))) int912; typedef int __attribute__ ((bitwidth(913))) int913; typedef int __attribute__ ((bitwidth(914))) int914; typedef int __attribute__ ((bitwidth(915))) int915; typedef int __attribute__ ((bitwidth(916))) int916; typedef int __attribute__ ((bitwidth(917))) int917; typedef int __attribute__ ((bitwidth(918))) int918; typedef int __attribute__ ((bitwidth(919))) int919; typedef int __attribute__ ((bitwidth(920))) int920; typedef int __attribute__ ((bitwidth(921))) int921; typedef int __attribute__ ((bitwidth(922))) int922; typedef int __attribute__ ((bitwidth(923))) int923; typedef int __attribute__ ((bitwidth(924))) int924; typedef int __attribute__ ((bitwidth(925))) int925; typedef int __attribute__ ((bitwidth(926))) int926; typedef int __attribute__ ((bitwidth(927))) int927; typedef int __attribute__ ((bitwidth(928))) int928; typedef int __attribute__ ((bitwidth(929))) int929; typedef int __attribute__ ((bitwidth(930))) int930; typedef int __attribute__ ((bitwidth(931))) int931; typedef int __attribute__ ((bitwidth(932))) int932; typedef int __attribute__ ((bitwidth(933))) int933; typedef int __attribute__ ((bitwidth(934))) int934; typedef int __attribute__ ((bitwidth(935))) int935; typedef int __attribute__ ((bitwidth(936))) int936; typedef int __attribute__ ((bitwidth(937))) int937; typedef int __attribute__ ((bitwidth(938))) int938; typedef int __attribute__ ((bitwidth(939))) int939; typedef int __attribute__ ((bitwidth(940))) int940; typedef int __attribute__ ((bitwidth(941))) int941; typedef int __attribute__ ((bitwidth(942))) int942; typedef int __attribute__ ((bitwidth(943))) int943; typedef int __attribute__ ((bitwidth(944))) int944; typedef int __attribute__ ((bitwidth(945))) int945; typedef int __attribute__ ((bitwidth(946))) int946; typedef int __attribute__ ((bitwidth(947))) int947; typedef int __attribute__ ((bitwidth(948))) int948; typedef int __attribute__ ((bitwidth(949))) int949; typedef int __attribute__ ((bitwidth(950))) int950; typedef int __attribute__ ((bitwidth(951))) int951; typedef int __attribute__ ((bitwidth(952))) int952; typedef int __attribute__ ((bitwidth(953))) int953; typedef int __attribute__ ((bitwidth(954))) int954; typedef int __attribute__ ((bitwidth(955))) int955; typedef int __attribute__ ((bitwidth(956))) int956; typedef int __attribute__ ((bitwidth(957))) int957; typedef int __attribute__ ((bitwidth(958))) int958; typedef int __attribute__ ((bitwidth(959))) int959; typedef int __attribute__ ((bitwidth(960))) int960; typedef int __attribute__ ((bitwidth(961))) int961; typedef int __attribute__ ((bitwidth(962))) int962; typedef int __attribute__ ((bitwidth(963))) int963; typedef int __attribute__ ((bitwidth(964))) int964; typedef int __attribute__ ((bitwidth(965))) int965; typedef int __attribute__ ((bitwidth(966))) int966; typedef int __attribute__ ((bitwidth(967))) int967; typedef int __attribute__ ((bitwidth(968))) int968; typedef int __attribute__ ((bitwidth(969))) int969; typedef int __attribute__ ((bitwidth(970))) int970; typedef int __attribute__ ((bitwidth(971))) int971; typedef int __attribute__ ((bitwidth(972))) int972; typedef int __attribute__ ((bitwidth(973))) int973; typedef int __attribute__ ((bitwidth(974))) int974; typedef int __attribute__ ((bitwidth(975))) int975; typedef int __attribute__ ((bitwidth(976))) int976; typedef int __attribute__ ((bitwidth(977))) int977; typedef int __attribute__ ((bitwidth(978))) int978; typedef int __attribute__ ((bitwidth(979))) int979; typedef int __attribute__ ((bitwidth(980))) int980; typedef int __attribute__ ((bitwidth(981))) int981; typedef int __attribute__ ((bitwidth(982))) int982; typedef int __attribute__ ((bitwidth(983))) int983; typedef int __attribute__ ((bitwidth(984))) int984; typedef int __attribute__ ((bitwidth(985))) int985; typedef int __attribute__ ((bitwidth(986))) int986; typedef int __attribute__ ((bitwidth(987))) int987; typedef int __attribute__ ((bitwidth(988))) int988; typedef int __attribute__ ((bitwidth(989))) int989; typedef int __attribute__ ((bitwidth(990))) int990; typedef int __attribute__ ((bitwidth(991))) int991; typedef int __attribute__ ((bitwidth(992))) int992; typedef int __attribute__ ((bitwidth(993))) int993; typedef int __attribute__ ((bitwidth(994))) int994; typedef int __attribute__ ((bitwidth(995))) int995; typedef int __attribute__ ((bitwidth(996))) int996; typedef int __attribute__ ((bitwidth(997))) int997; typedef int __attribute__ ((bitwidth(998))) int998; typedef int __attribute__ ((bitwidth(999))) int999; typedef int __attribute__ ((bitwidth(1000))) int1000; typedef int __attribute__ ((bitwidth(1001))) int1001; typedef int __attribute__ ((bitwidth(1002))) int1002; typedef int __attribute__ ((bitwidth(1003))) int1003; typedef int __attribute__ ((bitwidth(1004))) int1004; typedef int __attribute__ ((bitwidth(1005))) int1005; typedef int __attribute__ ((bitwidth(1006))) int1006; typedef int __attribute__ ((bitwidth(1007))) int1007; typedef int __attribute__ ((bitwidth(1008))) int1008; typedef int __attribute__ ((bitwidth(1009))) int1009; typedef int __attribute__ ((bitwidth(1010))) int1010; typedef int __attribute__ ((bitwidth(1011))) int1011; typedef int __attribute__ ((bitwidth(1012))) int1012; typedef int __attribute__ ((bitwidth(1013))) int1013; typedef int __attribute__ ((bitwidth(1014))) int1014; typedef int __attribute__ ((bitwidth(1015))) int1015; typedef int __attribute__ ((bitwidth(1016))) int1016; typedef int __attribute__ ((bitwidth(1017))) int1017; typedef int __attribute__ ((bitwidth(1018))) int1018; typedef int __attribute__ ((bitwidth(1019))) int1019; typedef int __attribute__ ((bitwidth(1020))) int1020; typedef int __attribute__ ((bitwidth(1021))) int1021; typedef int __attribute__ ((bitwidth(1022))) int1022; typedef int __attribute__ ((bitwidth(1023))) int1023; typedef int __attribute__ ((bitwidth(1024))) int1024; #pragma line 98 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt_ext.def" 1 #pragma empty_line #pragma empty_line typedef int __attribute__ ((bitwidth(1025))) int1025; typedef int __attribute__ ((bitwidth(1026))) int1026; typedef int __attribute__ ((bitwidth(1027))) int1027; typedef int __attribute__ ((bitwidth(1028))) int1028; typedef int __attribute__ ((bitwidth(1029))) int1029; typedef int __attribute__ ((bitwidth(1030))) int1030; typedef int __attribute__ ((bitwidth(1031))) int1031; typedef int __attribute__ ((bitwidth(1032))) int1032; typedef int __attribute__ ((bitwidth(1033))) int1033; typedef int __attribute__ ((bitwidth(1034))) int1034; typedef int __attribute__ ((bitwidth(1035))) int1035; typedef int __attribute__ ((bitwidth(1036))) int1036; typedef int __attribute__ ((bitwidth(1037))) int1037; typedef int __attribute__ ((bitwidth(1038))) int1038; typedef int __attribute__ ((bitwidth(1039))) int1039; typedef int __attribute__ ((bitwidth(1040))) int1040; typedef int __attribute__ ((bitwidth(1041))) int1041; typedef int __attribute__ ((bitwidth(1042))) int1042; typedef int __attribute__ ((bitwidth(1043))) int1043; typedef int __attribute__ ((bitwidth(1044))) int1044; typedef int __attribute__ ((bitwidth(1045))) int1045; typedef int __attribute__ ((bitwidth(1046))) int1046; typedef int __attribute__ ((bitwidth(1047))) int1047; typedef int __attribute__ ((bitwidth(1048))) int1048; typedef int __attribute__ ((bitwidth(1049))) int1049; typedef int __attribute__ ((bitwidth(1050))) int1050; typedef int __attribute__ ((bitwidth(1051))) int1051; typedef int __attribute__ ((bitwidth(1052))) int1052; typedef int __attribute__ ((bitwidth(1053))) int1053; typedef int __attribute__ ((bitwidth(1054))) int1054; typedef int __attribute__ ((bitwidth(1055))) int1055; typedef int __attribute__ ((bitwidth(1056))) int1056; typedef int __attribute__ ((bitwidth(1057))) int1057; typedef int __attribute__ ((bitwidth(1058))) int1058; typedef int __attribute__ ((bitwidth(1059))) int1059; typedef int __attribute__ ((bitwidth(1060))) int1060; typedef int __attribute__ ((bitwidth(1061))) int1061; typedef int __attribute__ ((bitwidth(1062))) int1062; typedef int __attribute__ ((bitwidth(1063))) int1063; typedef int __attribute__ ((bitwidth(1064))) int1064; typedef int __attribute__ ((bitwidth(1065))) int1065; typedef int __attribute__ ((bitwidth(1066))) int1066; typedef int __attribute__ ((bitwidth(1067))) int1067; typedef int __attribute__ ((bitwidth(1068))) int1068; typedef int __attribute__ ((bitwidth(1069))) int1069; typedef int __attribute__ ((bitwidth(1070))) int1070; typedef int __attribute__ ((bitwidth(1071))) int1071; typedef int __attribute__ ((bitwidth(1072))) int1072; typedef int __attribute__ ((bitwidth(1073))) int1073; typedef int __attribute__ ((bitwidth(1074))) int1074; typedef int __attribute__ ((bitwidth(1075))) int1075; typedef int __attribute__ ((bitwidth(1076))) int1076; typedef int __attribute__ ((bitwidth(1077))) int1077; typedef int __attribute__ ((bitwidth(1078))) int1078; typedef int __attribute__ ((bitwidth(1079))) int1079; typedef int __attribute__ ((bitwidth(1080))) int1080; typedef int __attribute__ ((bitwidth(1081))) int1081; typedef int __attribute__ ((bitwidth(1082))) int1082; typedef int __attribute__ ((bitwidth(1083))) int1083; typedef int __attribute__ ((bitwidth(1084))) int1084; typedef int __attribute__ ((bitwidth(1085))) int1085; typedef int __attribute__ ((bitwidth(1086))) int1086; typedef int __attribute__ ((bitwidth(1087))) int1087; typedef int __attribute__ ((bitwidth(1088))) int1088; typedef int __attribute__ ((bitwidth(1089))) int1089; typedef int __attribute__ ((bitwidth(1090))) int1090; typedef int __attribute__ ((bitwidth(1091))) int1091; typedef int __attribute__ ((bitwidth(1092))) int1092; typedef int __attribute__ ((bitwidth(1093))) int1093; typedef int __attribute__ ((bitwidth(1094))) int1094; typedef int __attribute__ ((bitwidth(1095))) int1095; typedef int __attribute__ ((bitwidth(1096))) int1096; typedef int __attribute__ ((bitwidth(1097))) int1097; typedef int __attribute__ ((bitwidth(1098))) int1098; typedef int __attribute__ ((bitwidth(1099))) int1099; typedef int __attribute__ ((bitwidth(1100))) int1100; typedef int __attribute__ ((bitwidth(1101))) int1101; typedef int __attribute__ ((bitwidth(1102))) int1102; typedef int __attribute__ ((bitwidth(1103))) int1103; typedef int __attribute__ ((bitwidth(1104))) int1104; typedef int __attribute__ ((bitwidth(1105))) int1105; typedef int __attribute__ ((bitwidth(1106))) int1106; typedef int __attribute__ ((bitwidth(1107))) int1107; typedef int __attribute__ ((bitwidth(1108))) int1108; typedef int __attribute__ ((bitwidth(1109))) int1109; typedef int __attribute__ ((bitwidth(1110))) int1110; typedef int __attribute__ ((bitwidth(1111))) int1111; typedef int __attribute__ ((bitwidth(1112))) int1112; typedef int __attribute__ ((bitwidth(1113))) int1113; typedef int __attribute__ ((bitwidth(1114))) int1114; typedef int __attribute__ ((bitwidth(1115))) int1115; typedef int __attribute__ ((bitwidth(1116))) int1116; typedef int __attribute__ ((bitwidth(1117))) int1117; typedef int __attribute__ ((bitwidth(1118))) int1118; typedef int __attribute__ ((bitwidth(1119))) int1119; typedef int __attribute__ ((bitwidth(1120))) int1120; typedef int __attribute__ ((bitwidth(1121))) int1121; typedef int __attribute__ ((bitwidth(1122))) int1122; typedef int __attribute__ ((bitwidth(1123))) int1123; typedef int __attribute__ ((bitwidth(1124))) int1124; typedef int __attribute__ ((bitwidth(1125))) int1125; typedef int __attribute__ ((bitwidth(1126))) int1126; typedef int __attribute__ ((bitwidth(1127))) int1127; typedef int __attribute__ ((bitwidth(1128))) int1128; typedef int __attribute__ ((bitwidth(1129))) int1129; typedef int __attribute__ ((bitwidth(1130))) int1130; typedef int __attribute__ ((bitwidth(1131))) int1131; typedef int __attribute__ ((bitwidth(1132))) int1132; typedef int __attribute__ ((bitwidth(1133))) int1133; typedef int __attribute__ ((bitwidth(1134))) int1134; typedef int __attribute__ ((bitwidth(1135))) int1135; typedef int __attribute__ ((bitwidth(1136))) int1136; typedef int __attribute__ ((bitwidth(1137))) int1137; typedef int __attribute__ ((bitwidth(1138))) int1138; typedef int __attribute__ ((bitwidth(1139))) int1139; typedef int __attribute__ ((bitwidth(1140))) int1140; typedef int __attribute__ ((bitwidth(1141))) int1141; typedef int __attribute__ ((bitwidth(1142))) int1142; typedef int __attribute__ ((bitwidth(1143))) int1143; typedef int __attribute__ ((bitwidth(1144))) int1144; typedef int __attribute__ ((bitwidth(1145))) int1145; typedef int __attribute__ ((bitwidth(1146))) int1146; typedef int __attribute__ ((bitwidth(1147))) int1147; typedef int __attribute__ ((bitwidth(1148))) int1148; typedef int __attribute__ ((bitwidth(1149))) int1149; typedef int __attribute__ ((bitwidth(1150))) int1150; typedef int __attribute__ ((bitwidth(1151))) int1151; typedef int __attribute__ ((bitwidth(1152))) int1152; typedef int __attribute__ ((bitwidth(1153))) int1153; typedef int __attribute__ ((bitwidth(1154))) int1154; typedef int __attribute__ ((bitwidth(1155))) int1155; typedef int __attribute__ ((bitwidth(1156))) int1156; typedef int __attribute__ ((bitwidth(1157))) int1157; typedef int __attribute__ ((bitwidth(1158))) int1158; typedef int __attribute__ ((bitwidth(1159))) int1159; typedef int __attribute__ ((bitwidth(1160))) int1160; typedef int __attribute__ ((bitwidth(1161))) int1161; typedef int __attribute__ ((bitwidth(1162))) int1162; typedef int __attribute__ ((bitwidth(1163))) int1163; typedef int __attribute__ ((bitwidth(1164))) int1164; typedef int __attribute__ ((bitwidth(1165))) int1165; typedef int __attribute__ ((bitwidth(1166))) int1166; typedef int __attribute__ ((bitwidth(1167))) int1167; typedef int __attribute__ ((bitwidth(1168))) int1168; typedef int __attribute__ ((bitwidth(1169))) int1169; typedef int __attribute__ ((bitwidth(1170))) int1170; typedef int __attribute__ ((bitwidth(1171))) int1171; typedef int __attribute__ ((bitwidth(1172))) int1172; typedef int __attribute__ ((bitwidth(1173))) int1173; typedef int __attribute__ ((bitwidth(1174))) int1174; typedef int __attribute__ ((bitwidth(1175))) int1175; typedef int __attribute__ ((bitwidth(1176))) int1176; typedef int __attribute__ ((bitwidth(1177))) int1177; typedef int __attribute__ ((bitwidth(1178))) int1178; typedef int __attribute__ ((bitwidth(1179))) int1179; typedef int __attribute__ ((bitwidth(1180))) int1180; typedef int __attribute__ ((bitwidth(1181))) int1181; typedef int __attribute__ ((bitwidth(1182))) int1182; typedef int __attribute__ ((bitwidth(1183))) int1183; typedef int __attribute__ ((bitwidth(1184))) int1184; typedef int __attribute__ ((bitwidth(1185))) int1185; typedef int __attribute__ ((bitwidth(1186))) int1186; typedef int __attribute__ ((bitwidth(1187))) int1187; typedef int __attribute__ ((bitwidth(1188))) int1188; typedef int __attribute__ ((bitwidth(1189))) int1189; typedef int __attribute__ ((bitwidth(1190))) int1190; typedef int __attribute__ ((bitwidth(1191))) int1191; typedef int __attribute__ ((bitwidth(1192))) int1192; typedef int __attribute__ ((bitwidth(1193))) int1193; typedef int __attribute__ ((bitwidth(1194))) int1194; typedef int __attribute__ ((bitwidth(1195))) int1195; typedef int __attribute__ ((bitwidth(1196))) int1196; typedef int __attribute__ ((bitwidth(1197))) int1197; typedef int __attribute__ ((bitwidth(1198))) int1198; typedef int __attribute__ ((bitwidth(1199))) int1199; typedef int __attribute__ ((bitwidth(1200))) int1200; typedef int __attribute__ ((bitwidth(1201))) int1201; typedef int __attribute__ ((bitwidth(1202))) int1202; typedef int __attribute__ ((bitwidth(1203))) int1203; typedef int __attribute__ ((bitwidth(1204))) int1204; typedef int __attribute__ ((bitwidth(1205))) int1205; typedef int __attribute__ ((bitwidth(1206))) int1206; typedef int __attribute__ ((bitwidth(1207))) int1207; typedef int __attribute__ ((bitwidth(1208))) int1208; typedef int __attribute__ ((bitwidth(1209))) int1209; typedef int __attribute__ ((bitwidth(1210))) int1210; typedef int __attribute__ ((bitwidth(1211))) int1211; typedef int __attribute__ ((bitwidth(1212))) int1212; typedef int __attribute__ ((bitwidth(1213))) int1213; typedef int __attribute__ ((bitwidth(1214))) int1214; typedef int __attribute__ ((bitwidth(1215))) int1215; typedef int __attribute__ ((bitwidth(1216))) int1216; typedef int __attribute__ ((bitwidth(1217))) int1217; typedef int __attribute__ ((bitwidth(1218))) int1218; typedef int __attribute__ ((bitwidth(1219))) int1219; typedef int __attribute__ ((bitwidth(1220))) int1220; typedef int __attribute__ ((bitwidth(1221))) int1221; typedef int __attribute__ ((bitwidth(1222))) int1222; typedef int __attribute__ ((bitwidth(1223))) int1223; typedef int __attribute__ ((bitwidth(1224))) int1224; typedef int __attribute__ ((bitwidth(1225))) int1225; typedef int __attribute__ ((bitwidth(1226))) int1226; typedef int __attribute__ ((bitwidth(1227))) int1227; typedef int __attribute__ ((bitwidth(1228))) int1228; typedef int __attribute__ ((bitwidth(1229))) int1229; typedef int __attribute__ ((bitwidth(1230))) int1230; typedef int __attribute__ ((bitwidth(1231))) int1231; typedef int __attribute__ ((bitwidth(1232))) int1232; typedef int __attribute__ ((bitwidth(1233))) int1233; typedef int __attribute__ ((bitwidth(1234))) int1234; typedef int __attribute__ ((bitwidth(1235))) int1235; typedef int __attribute__ ((bitwidth(1236))) int1236; typedef int __attribute__ ((bitwidth(1237))) int1237; typedef int __attribute__ ((bitwidth(1238))) int1238; typedef int __attribute__ ((bitwidth(1239))) int1239; typedef int __attribute__ ((bitwidth(1240))) int1240; typedef int __attribute__ ((bitwidth(1241))) int1241; typedef int __attribute__ ((bitwidth(1242))) int1242; typedef int __attribute__ ((bitwidth(1243))) int1243; typedef int __attribute__ ((bitwidth(1244))) int1244; typedef int __attribute__ ((bitwidth(1245))) int1245; typedef int __attribute__ ((bitwidth(1246))) int1246; typedef int __attribute__ ((bitwidth(1247))) int1247; typedef int __attribute__ ((bitwidth(1248))) int1248; typedef int __attribute__ ((bitwidth(1249))) int1249; typedef int __attribute__ ((bitwidth(1250))) int1250; typedef int __attribute__ ((bitwidth(1251))) int1251; typedef int __attribute__ ((bitwidth(1252))) int1252; typedef int __attribute__ ((bitwidth(1253))) int1253; typedef int __attribute__ ((bitwidth(1254))) int1254; typedef int __attribute__ ((bitwidth(1255))) int1255; typedef int __attribute__ ((bitwidth(1256))) int1256; typedef int __attribute__ ((bitwidth(1257))) int1257; typedef int __attribute__ ((bitwidth(1258))) int1258; typedef int __attribute__ ((bitwidth(1259))) int1259; typedef int __attribute__ ((bitwidth(1260))) int1260; typedef int __attribute__ ((bitwidth(1261))) int1261; typedef int __attribute__ ((bitwidth(1262))) int1262; typedef int __attribute__ ((bitwidth(1263))) int1263; typedef int __attribute__ ((bitwidth(1264))) int1264; typedef int __attribute__ ((bitwidth(1265))) int1265; typedef int __attribute__ ((bitwidth(1266))) int1266; typedef int __attribute__ ((bitwidth(1267))) int1267; typedef int __attribute__ ((bitwidth(1268))) int1268; typedef int __attribute__ ((bitwidth(1269))) int1269; typedef int __attribute__ ((bitwidth(1270))) int1270; typedef int __attribute__ ((bitwidth(1271))) int1271; typedef int __attribute__ ((bitwidth(1272))) int1272; typedef int __attribute__ ((bitwidth(1273))) int1273; typedef int __attribute__ ((bitwidth(1274))) int1274; typedef int __attribute__ ((bitwidth(1275))) int1275; typedef int __attribute__ ((bitwidth(1276))) int1276; typedef int __attribute__ ((bitwidth(1277))) int1277; typedef int __attribute__ ((bitwidth(1278))) int1278; typedef int __attribute__ ((bitwidth(1279))) int1279; typedef int __attribute__ ((bitwidth(1280))) int1280; typedef int __attribute__ ((bitwidth(1281))) int1281; typedef int __attribute__ ((bitwidth(1282))) int1282; typedef int __attribute__ ((bitwidth(1283))) int1283; typedef int __attribute__ ((bitwidth(1284))) int1284; typedef int __attribute__ ((bitwidth(1285))) int1285; typedef int __attribute__ ((bitwidth(1286))) int1286; typedef int __attribute__ ((bitwidth(1287))) int1287; typedef int __attribute__ ((bitwidth(1288))) int1288; typedef int __attribute__ ((bitwidth(1289))) int1289; typedef int __attribute__ ((bitwidth(1290))) int1290; typedef int __attribute__ ((bitwidth(1291))) int1291; typedef int __attribute__ ((bitwidth(1292))) int1292; typedef int __attribute__ ((bitwidth(1293))) int1293; typedef int __attribute__ ((bitwidth(1294))) int1294; typedef int __attribute__ ((bitwidth(1295))) int1295; typedef int __attribute__ ((bitwidth(1296))) int1296; typedef int __attribute__ ((bitwidth(1297))) int1297; typedef int __attribute__ ((bitwidth(1298))) int1298; typedef int __attribute__ ((bitwidth(1299))) int1299; typedef int __attribute__ ((bitwidth(1300))) int1300; typedef int __attribute__ ((bitwidth(1301))) int1301; typedef int __attribute__ ((bitwidth(1302))) int1302; typedef int __attribute__ ((bitwidth(1303))) int1303; typedef int __attribute__ ((bitwidth(1304))) int1304; typedef int __attribute__ ((bitwidth(1305))) int1305; typedef int __attribute__ ((bitwidth(1306))) int1306; typedef int __attribute__ ((bitwidth(1307))) int1307; typedef int __attribute__ ((bitwidth(1308))) int1308; typedef int __attribute__ ((bitwidth(1309))) int1309; typedef int __attribute__ ((bitwidth(1310))) int1310; typedef int __attribute__ ((bitwidth(1311))) int1311; typedef int __attribute__ ((bitwidth(1312))) int1312; typedef int __attribute__ ((bitwidth(1313))) int1313; typedef int __attribute__ ((bitwidth(1314))) int1314; typedef int __attribute__ ((bitwidth(1315))) int1315; typedef int __attribute__ ((bitwidth(1316))) int1316; typedef int __attribute__ ((bitwidth(1317))) int1317; typedef int __attribute__ ((bitwidth(1318))) int1318; typedef int __attribute__ ((bitwidth(1319))) int1319; typedef int __attribute__ ((bitwidth(1320))) int1320; typedef int __attribute__ ((bitwidth(1321))) int1321; typedef int __attribute__ ((bitwidth(1322))) int1322; typedef int __attribute__ ((bitwidth(1323))) int1323; typedef int __attribute__ ((bitwidth(1324))) int1324; typedef int __attribute__ ((bitwidth(1325))) int1325; typedef int __attribute__ ((bitwidth(1326))) int1326; typedef int __attribute__ ((bitwidth(1327))) int1327; typedef int __attribute__ ((bitwidth(1328))) int1328; typedef int __attribute__ ((bitwidth(1329))) int1329; typedef int __attribute__ ((bitwidth(1330))) int1330; typedef int __attribute__ ((bitwidth(1331))) int1331; typedef int __attribute__ ((bitwidth(1332))) int1332; typedef int __attribute__ ((bitwidth(1333))) int1333; typedef int __attribute__ ((bitwidth(1334))) int1334; typedef int __attribute__ ((bitwidth(1335))) int1335; typedef int __attribute__ ((bitwidth(1336))) int1336; typedef int __attribute__ ((bitwidth(1337))) int1337; typedef int __attribute__ ((bitwidth(1338))) int1338; typedef int __attribute__ ((bitwidth(1339))) int1339; typedef int __attribute__ ((bitwidth(1340))) int1340; typedef int __attribute__ ((bitwidth(1341))) int1341; typedef int __attribute__ ((bitwidth(1342))) int1342; typedef int __attribute__ ((bitwidth(1343))) int1343; typedef int __attribute__ ((bitwidth(1344))) int1344; typedef int __attribute__ ((bitwidth(1345))) int1345; typedef int __attribute__ ((bitwidth(1346))) int1346; typedef int __attribute__ ((bitwidth(1347))) int1347; typedef int __attribute__ ((bitwidth(1348))) int1348; typedef int __attribute__ ((bitwidth(1349))) int1349; typedef int __attribute__ ((bitwidth(1350))) int1350; typedef int __attribute__ ((bitwidth(1351))) int1351; typedef int __attribute__ ((bitwidth(1352))) int1352; typedef int __attribute__ ((bitwidth(1353))) int1353; typedef int __attribute__ ((bitwidth(1354))) int1354; typedef int __attribute__ ((bitwidth(1355))) int1355; typedef int __attribute__ ((bitwidth(1356))) int1356; typedef int __attribute__ ((bitwidth(1357))) int1357; typedef int __attribute__ ((bitwidth(1358))) int1358; typedef int __attribute__ ((bitwidth(1359))) int1359; typedef int __attribute__ ((bitwidth(1360))) int1360; typedef int __attribute__ ((bitwidth(1361))) int1361; typedef int __attribute__ ((bitwidth(1362))) int1362; typedef int __attribute__ ((bitwidth(1363))) int1363; typedef int __attribute__ ((bitwidth(1364))) int1364; typedef int __attribute__ ((bitwidth(1365))) int1365; typedef int __attribute__ ((bitwidth(1366))) int1366; typedef int __attribute__ ((bitwidth(1367))) int1367; typedef int __attribute__ ((bitwidth(1368))) int1368; typedef int __attribute__ ((bitwidth(1369))) int1369; typedef int __attribute__ ((bitwidth(1370))) int1370; typedef int __attribute__ ((bitwidth(1371))) int1371; typedef int __attribute__ ((bitwidth(1372))) int1372; typedef int __attribute__ ((bitwidth(1373))) int1373; typedef int __attribute__ ((bitwidth(1374))) int1374; typedef int __attribute__ ((bitwidth(1375))) int1375; typedef int __attribute__ ((bitwidth(1376))) int1376; typedef int __attribute__ ((bitwidth(1377))) int1377; typedef int __attribute__ ((bitwidth(1378))) int1378; typedef int __attribute__ ((bitwidth(1379))) int1379; typedef int __attribute__ ((bitwidth(1380))) int1380; typedef int __attribute__ ((bitwidth(1381))) int1381; typedef int __attribute__ ((bitwidth(1382))) int1382; typedef int __attribute__ ((bitwidth(1383))) int1383; typedef int __attribute__ ((bitwidth(1384))) int1384; typedef int __attribute__ ((bitwidth(1385))) int1385; typedef int __attribute__ ((bitwidth(1386))) int1386; typedef int __attribute__ ((bitwidth(1387))) int1387; typedef int __attribute__ ((bitwidth(1388))) int1388; typedef int __attribute__ ((bitwidth(1389))) int1389; typedef int __attribute__ ((bitwidth(1390))) int1390; typedef int __attribute__ ((bitwidth(1391))) int1391; typedef int __attribute__ ((bitwidth(1392))) int1392; typedef int __attribute__ ((bitwidth(1393))) int1393; typedef int __attribute__ ((bitwidth(1394))) int1394; typedef int __attribute__ ((bitwidth(1395))) int1395; typedef int __attribute__ ((bitwidth(1396))) int1396; typedef int __attribute__ ((bitwidth(1397))) int1397; typedef int __attribute__ ((bitwidth(1398))) int1398; typedef int __attribute__ ((bitwidth(1399))) int1399; typedef int __attribute__ ((bitwidth(1400))) int1400; typedef int __attribute__ ((bitwidth(1401))) int1401; typedef int __attribute__ ((bitwidth(1402))) int1402; typedef int __attribute__ ((bitwidth(1403))) int1403; typedef int __attribute__ ((bitwidth(1404))) int1404; typedef int __attribute__ ((bitwidth(1405))) int1405; typedef int __attribute__ ((bitwidth(1406))) int1406; typedef int __attribute__ ((bitwidth(1407))) int1407; typedef int __attribute__ ((bitwidth(1408))) int1408; typedef int __attribute__ ((bitwidth(1409))) int1409; typedef int __attribute__ ((bitwidth(1410))) int1410; typedef int __attribute__ ((bitwidth(1411))) int1411; typedef int __attribute__ ((bitwidth(1412))) int1412; typedef int __attribute__ ((bitwidth(1413))) int1413; typedef int __attribute__ ((bitwidth(1414))) int1414; typedef int __attribute__ ((bitwidth(1415))) int1415; typedef int __attribute__ ((bitwidth(1416))) int1416; typedef int __attribute__ ((bitwidth(1417))) int1417; typedef int __attribute__ ((bitwidth(1418))) int1418; typedef int __attribute__ ((bitwidth(1419))) int1419; typedef int __attribute__ ((bitwidth(1420))) int1420; typedef int __attribute__ ((bitwidth(1421))) int1421; typedef int __attribute__ ((bitwidth(1422))) int1422; typedef int __attribute__ ((bitwidth(1423))) int1423; typedef int __attribute__ ((bitwidth(1424))) int1424; typedef int __attribute__ ((bitwidth(1425))) int1425; typedef int __attribute__ ((bitwidth(1426))) int1426; typedef int __attribute__ ((bitwidth(1427))) int1427; typedef int __attribute__ ((bitwidth(1428))) int1428; typedef int __attribute__ ((bitwidth(1429))) int1429; typedef int __attribute__ ((bitwidth(1430))) int1430; typedef int __attribute__ ((bitwidth(1431))) int1431; typedef int __attribute__ ((bitwidth(1432))) int1432; typedef int __attribute__ ((bitwidth(1433))) int1433; typedef int __attribute__ ((bitwidth(1434))) int1434; typedef int __attribute__ ((bitwidth(1435))) int1435; typedef int __attribute__ ((bitwidth(1436))) int1436; typedef int __attribute__ ((bitwidth(1437))) int1437; typedef int __attribute__ ((bitwidth(1438))) int1438; typedef int __attribute__ ((bitwidth(1439))) int1439; typedef int __attribute__ ((bitwidth(1440))) int1440; typedef int __attribute__ ((bitwidth(1441))) int1441; typedef int __attribute__ ((bitwidth(1442))) int1442; typedef int __attribute__ ((bitwidth(1443))) int1443; typedef int __attribute__ ((bitwidth(1444))) int1444; typedef int __attribute__ ((bitwidth(1445))) int1445; typedef int __attribute__ ((bitwidth(1446))) int1446; typedef int __attribute__ ((bitwidth(1447))) int1447; typedef int __attribute__ ((bitwidth(1448))) int1448; typedef int __attribute__ ((bitwidth(1449))) int1449; typedef int __attribute__ ((bitwidth(1450))) int1450; typedef int __attribute__ ((bitwidth(1451))) int1451; typedef int __attribute__ ((bitwidth(1452))) int1452; typedef int __attribute__ ((bitwidth(1453))) int1453; typedef int __attribute__ ((bitwidth(1454))) int1454; typedef int __attribute__ ((bitwidth(1455))) int1455; typedef int __attribute__ ((bitwidth(1456))) int1456; typedef int __attribute__ ((bitwidth(1457))) int1457; typedef int __attribute__ ((bitwidth(1458))) int1458; typedef int __attribute__ ((bitwidth(1459))) int1459; typedef int __attribute__ ((bitwidth(1460))) int1460; typedef int __attribute__ ((bitwidth(1461))) int1461; typedef int __attribute__ ((bitwidth(1462))) int1462; typedef int __attribute__ ((bitwidth(1463))) int1463; typedef int __attribute__ ((bitwidth(1464))) int1464; typedef int __attribute__ ((bitwidth(1465))) int1465; typedef int __attribute__ ((bitwidth(1466))) int1466; typedef int __attribute__ ((bitwidth(1467))) int1467; typedef int __attribute__ ((bitwidth(1468))) int1468; typedef int __attribute__ ((bitwidth(1469))) int1469; typedef int __attribute__ ((bitwidth(1470))) int1470; typedef int __attribute__ ((bitwidth(1471))) int1471; typedef int __attribute__ ((bitwidth(1472))) int1472; typedef int __attribute__ ((bitwidth(1473))) int1473; typedef int __attribute__ ((bitwidth(1474))) int1474; typedef int __attribute__ ((bitwidth(1475))) int1475; typedef int __attribute__ ((bitwidth(1476))) int1476; typedef int __attribute__ ((bitwidth(1477))) int1477; typedef int __attribute__ ((bitwidth(1478))) int1478; typedef int __attribute__ ((bitwidth(1479))) int1479; typedef int __attribute__ ((bitwidth(1480))) int1480; typedef int __attribute__ ((bitwidth(1481))) int1481; typedef int __attribute__ ((bitwidth(1482))) int1482; typedef int __attribute__ ((bitwidth(1483))) int1483; typedef int __attribute__ ((bitwidth(1484))) int1484; typedef int __attribute__ ((bitwidth(1485))) int1485; typedef int __attribute__ ((bitwidth(1486))) int1486; typedef int __attribute__ ((bitwidth(1487))) int1487; typedef int __attribute__ ((bitwidth(1488))) int1488; typedef int __attribute__ ((bitwidth(1489))) int1489; typedef int __attribute__ ((bitwidth(1490))) int1490; typedef int __attribute__ ((bitwidth(1491))) int1491; typedef int __attribute__ ((bitwidth(1492))) int1492; typedef int __attribute__ ((bitwidth(1493))) int1493; typedef int __attribute__ ((bitwidth(1494))) int1494; typedef int __attribute__ ((bitwidth(1495))) int1495; typedef int __attribute__ ((bitwidth(1496))) int1496; typedef int __attribute__ ((bitwidth(1497))) int1497; typedef int __attribute__ ((bitwidth(1498))) int1498; typedef int __attribute__ ((bitwidth(1499))) int1499; typedef int __attribute__ ((bitwidth(1500))) int1500; typedef int __attribute__ ((bitwidth(1501))) int1501; typedef int __attribute__ ((bitwidth(1502))) int1502; typedef int __attribute__ ((bitwidth(1503))) int1503; typedef int __attribute__ ((bitwidth(1504))) int1504; typedef int __attribute__ ((bitwidth(1505))) int1505; typedef int __attribute__ ((bitwidth(1506))) int1506; typedef int __attribute__ ((bitwidth(1507))) int1507; typedef int __attribute__ ((bitwidth(1508))) int1508; typedef int __attribute__ ((bitwidth(1509))) int1509; typedef int __attribute__ ((bitwidth(1510))) int1510; typedef int __attribute__ ((bitwidth(1511))) int1511; typedef int __attribute__ ((bitwidth(1512))) int1512; typedef int __attribute__ ((bitwidth(1513))) int1513; typedef int __attribute__ ((bitwidth(1514))) int1514; typedef int __attribute__ ((bitwidth(1515))) int1515; typedef int __attribute__ ((bitwidth(1516))) int1516; typedef int __attribute__ ((bitwidth(1517))) int1517; typedef int __attribute__ ((bitwidth(1518))) int1518; typedef int __attribute__ ((bitwidth(1519))) int1519; typedef int __attribute__ ((bitwidth(1520))) int1520; typedef int __attribute__ ((bitwidth(1521))) int1521; typedef int __attribute__ ((bitwidth(1522))) int1522; typedef int __attribute__ ((bitwidth(1523))) int1523; typedef int __attribute__ ((bitwidth(1524))) int1524; typedef int __attribute__ ((bitwidth(1525))) int1525; typedef int __attribute__ ((bitwidth(1526))) int1526; typedef int __attribute__ ((bitwidth(1527))) int1527; typedef int __attribute__ ((bitwidth(1528))) int1528; typedef int __attribute__ ((bitwidth(1529))) int1529; typedef int __attribute__ ((bitwidth(1530))) int1530; typedef int __attribute__ ((bitwidth(1531))) int1531; typedef int __attribute__ ((bitwidth(1532))) int1532; typedef int __attribute__ ((bitwidth(1533))) int1533; typedef int __attribute__ ((bitwidth(1534))) int1534; typedef int __attribute__ ((bitwidth(1535))) int1535; typedef int __attribute__ ((bitwidth(1536))) int1536; typedef int __attribute__ ((bitwidth(1537))) int1537; typedef int __attribute__ ((bitwidth(1538))) int1538; typedef int __attribute__ ((bitwidth(1539))) int1539; typedef int __attribute__ ((bitwidth(1540))) int1540; typedef int __attribute__ ((bitwidth(1541))) int1541; typedef int __attribute__ ((bitwidth(1542))) int1542; typedef int __attribute__ ((bitwidth(1543))) int1543; typedef int __attribute__ ((bitwidth(1544))) int1544; typedef int __attribute__ ((bitwidth(1545))) int1545; typedef int __attribute__ ((bitwidth(1546))) int1546; typedef int __attribute__ ((bitwidth(1547))) int1547; typedef int __attribute__ ((bitwidth(1548))) int1548; typedef int __attribute__ ((bitwidth(1549))) int1549; typedef int __attribute__ ((bitwidth(1550))) int1550; typedef int __attribute__ ((bitwidth(1551))) int1551; typedef int __attribute__ ((bitwidth(1552))) int1552; typedef int __attribute__ ((bitwidth(1553))) int1553; typedef int __attribute__ ((bitwidth(1554))) int1554; typedef int __attribute__ ((bitwidth(1555))) int1555; typedef int __attribute__ ((bitwidth(1556))) int1556; typedef int __attribute__ ((bitwidth(1557))) int1557; typedef int __attribute__ ((bitwidth(1558))) int1558; typedef int __attribute__ ((bitwidth(1559))) int1559; typedef int __attribute__ ((bitwidth(1560))) int1560; typedef int __attribute__ ((bitwidth(1561))) int1561; typedef int __attribute__ ((bitwidth(1562))) int1562; typedef int __attribute__ ((bitwidth(1563))) int1563; typedef int __attribute__ ((bitwidth(1564))) int1564; typedef int __attribute__ ((bitwidth(1565))) int1565; typedef int __attribute__ ((bitwidth(1566))) int1566; typedef int __attribute__ ((bitwidth(1567))) int1567; typedef int __attribute__ ((bitwidth(1568))) int1568; typedef int __attribute__ ((bitwidth(1569))) int1569; typedef int __attribute__ ((bitwidth(1570))) int1570; typedef int __attribute__ ((bitwidth(1571))) int1571; typedef int __attribute__ ((bitwidth(1572))) int1572; typedef int __attribute__ ((bitwidth(1573))) int1573; typedef int __attribute__ ((bitwidth(1574))) int1574; typedef int __attribute__ ((bitwidth(1575))) int1575; typedef int __attribute__ ((bitwidth(1576))) int1576; typedef int __attribute__ ((bitwidth(1577))) int1577; typedef int __attribute__ ((bitwidth(1578))) int1578; typedef int __attribute__ ((bitwidth(1579))) int1579; typedef int __attribute__ ((bitwidth(1580))) int1580; typedef int __attribute__ ((bitwidth(1581))) int1581; typedef int __attribute__ ((bitwidth(1582))) int1582; typedef int __attribute__ ((bitwidth(1583))) int1583; typedef int __attribute__ ((bitwidth(1584))) int1584; typedef int __attribute__ ((bitwidth(1585))) int1585; typedef int __attribute__ ((bitwidth(1586))) int1586; typedef int __attribute__ ((bitwidth(1587))) int1587; typedef int __attribute__ ((bitwidth(1588))) int1588; typedef int __attribute__ ((bitwidth(1589))) int1589; typedef int __attribute__ ((bitwidth(1590))) int1590; typedef int __attribute__ ((bitwidth(1591))) int1591; typedef int __attribute__ ((bitwidth(1592))) int1592; typedef int __attribute__ ((bitwidth(1593))) int1593; typedef int __attribute__ ((bitwidth(1594))) int1594; typedef int __attribute__ ((bitwidth(1595))) int1595; typedef int __attribute__ ((bitwidth(1596))) int1596; typedef int __attribute__ ((bitwidth(1597))) int1597; typedef int __attribute__ ((bitwidth(1598))) int1598; typedef int __attribute__ ((bitwidth(1599))) int1599; typedef int __attribute__ ((bitwidth(1600))) int1600; typedef int __attribute__ ((bitwidth(1601))) int1601; typedef int __attribute__ ((bitwidth(1602))) int1602; typedef int __attribute__ ((bitwidth(1603))) int1603; typedef int __attribute__ ((bitwidth(1604))) int1604; typedef int __attribute__ ((bitwidth(1605))) int1605; typedef int __attribute__ ((bitwidth(1606))) int1606; typedef int __attribute__ ((bitwidth(1607))) int1607; typedef int __attribute__ ((bitwidth(1608))) int1608; typedef int __attribute__ ((bitwidth(1609))) int1609; typedef int __attribute__ ((bitwidth(1610))) int1610; typedef int __attribute__ ((bitwidth(1611))) int1611; typedef int __attribute__ ((bitwidth(1612))) int1612; typedef int __attribute__ ((bitwidth(1613))) int1613; typedef int __attribute__ ((bitwidth(1614))) int1614; typedef int __attribute__ ((bitwidth(1615))) int1615; typedef int __attribute__ ((bitwidth(1616))) int1616; typedef int __attribute__ ((bitwidth(1617))) int1617; typedef int __attribute__ ((bitwidth(1618))) int1618; typedef int __attribute__ ((bitwidth(1619))) int1619; typedef int __attribute__ ((bitwidth(1620))) int1620; typedef int __attribute__ ((bitwidth(1621))) int1621; typedef int __attribute__ ((bitwidth(1622))) int1622; typedef int __attribute__ ((bitwidth(1623))) int1623; typedef int __attribute__ ((bitwidth(1624))) int1624; typedef int __attribute__ ((bitwidth(1625))) int1625; typedef int __attribute__ ((bitwidth(1626))) int1626; typedef int __attribute__ ((bitwidth(1627))) int1627; typedef int __attribute__ ((bitwidth(1628))) int1628; typedef int __attribute__ ((bitwidth(1629))) int1629; typedef int __attribute__ ((bitwidth(1630))) int1630; typedef int __attribute__ ((bitwidth(1631))) int1631; typedef int __attribute__ ((bitwidth(1632))) int1632; typedef int __attribute__ ((bitwidth(1633))) int1633; typedef int __attribute__ ((bitwidth(1634))) int1634; typedef int __attribute__ ((bitwidth(1635))) int1635; typedef int __attribute__ ((bitwidth(1636))) int1636; typedef int __attribute__ ((bitwidth(1637))) int1637; typedef int __attribute__ ((bitwidth(1638))) int1638; typedef int __attribute__ ((bitwidth(1639))) int1639; typedef int __attribute__ ((bitwidth(1640))) int1640; typedef int __attribute__ ((bitwidth(1641))) int1641; typedef int __attribute__ ((bitwidth(1642))) int1642; typedef int __attribute__ ((bitwidth(1643))) int1643; typedef int __attribute__ ((bitwidth(1644))) int1644; typedef int __attribute__ ((bitwidth(1645))) int1645; typedef int __attribute__ ((bitwidth(1646))) int1646; typedef int __attribute__ ((bitwidth(1647))) int1647; typedef int __attribute__ ((bitwidth(1648))) int1648; typedef int __attribute__ ((bitwidth(1649))) int1649; typedef int __attribute__ ((bitwidth(1650))) int1650; typedef int __attribute__ ((bitwidth(1651))) int1651; typedef int __attribute__ ((bitwidth(1652))) int1652; typedef int __attribute__ ((bitwidth(1653))) int1653; typedef int __attribute__ ((bitwidth(1654))) int1654; typedef int __attribute__ ((bitwidth(1655))) int1655; typedef int __attribute__ ((bitwidth(1656))) int1656; typedef int __attribute__ ((bitwidth(1657))) int1657; typedef int __attribute__ ((bitwidth(1658))) int1658; typedef int __attribute__ ((bitwidth(1659))) int1659; typedef int __attribute__ ((bitwidth(1660))) int1660; typedef int __attribute__ ((bitwidth(1661))) int1661; typedef int __attribute__ ((bitwidth(1662))) int1662; typedef int __attribute__ ((bitwidth(1663))) int1663; typedef int __attribute__ ((bitwidth(1664))) int1664; typedef int __attribute__ ((bitwidth(1665))) int1665; typedef int __attribute__ ((bitwidth(1666))) int1666; typedef int __attribute__ ((bitwidth(1667))) int1667; typedef int __attribute__ ((bitwidth(1668))) int1668; typedef int __attribute__ ((bitwidth(1669))) int1669; typedef int __attribute__ ((bitwidth(1670))) int1670; typedef int __attribute__ ((bitwidth(1671))) int1671; typedef int __attribute__ ((bitwidth(1672))) int1672; typedef int __attribute__ ((bitwidth(1673))) int1673; typedef int __attribute__ ((bitwidth(1674))) int1674; typedef int __attribute__ ((bitwidth(1675))) int1675; typedef int __attribute__ ((bitwidth(1676))) int1676; typedef int __attribute__ ((bitwidth(1677))) int1677; typedef int __attribute__ ((bitwidth(1678))) int1678; typedef int __attribute__ ((bitwidth(1679))) int1679; typedef int __attribute__ ((bitwidth(1680))) int1680; typedef int __attribute__ ((bitwidth(1681))) int1681; typedef int __attribute__ ((bitwidth(1682))) int1682; typedef int __attribute__ ((bitwidth(1683))) int1683; typedef int __attribute__ ((bitwidth(1684))) int1684; typedef int __attribute__ ((bitwidth(1685))) int1685; typedef int __attribute__ ((bitwidth(1686))) int1686; typedef int __attribute__ ((bitwidth(1687))) int1687; typedef int __attribute__ ((bitwidth(1688))) int1688; typedef int __attribute__ ((bitwidth(1689))) int1689; typedef int __attribute__ ((bitwidth(1690))) int1690; typedef int __attribute__ ((bitwidth(1691))) int1691; typedef int __attribute__ ((bitwidth(1692))) int1692; typedef int __attribute__ ((bitwidth(1693))) int1693; typedef int __attribute__ ((bitwidth(1694))) int1694; typedef int __attribute__ ((bitwidth(1695))) int1695; typedef int __attribute__ ((bitwidth(1696))) int1696; typedef int __attribute__ ((bitwidth(1697))) int1697; typedef int __attribute__ ((bitwidth(1698))) int1698; typedef int __attribute__ ((bitwidth(1699))) int1699; typedef int __attribute__ ((bitwidth(1700))) int1700; typedef int __attribute__ ((bitwidth(1701))) int1701; typedef int __attribute__ ((bitwidth(1702))) int1702; typedef int __attribute__ ((bitwidth(1703))) int1703; typedef int __attribute__ ((bitwidth(1704))) int1704; typedef int __attribute__ ((bitwidth(1705))) int1705; typedef int __attribute__ ((bitwidth(1706))) int1706; typedef int __attribute__ ((bitwidth(1707))) int1707; typedef int __attribute__ ((bitwidth(1708))) int1708; typedef int __attribute__ ((bitwidth(1709))) int1709; typedef int __attribute__ ((bitwidth(1710))) int1710; typedef int __attribute__ ((bitwidth(1711))) int1711; typedef int __attribute__ ((bitwidth(1712))) int1712; typedef int __attribute__ ((bitwidth(1713))) int1713; typedef int __attribute__ ((bitwidth(1714))) int1714; typedef int __attribute__ ((bitwidth(1715))) int1715; typedef int __attribute__ ((bitwidth(1716))) int1716; typedef int __attribute__ ((bitwidth(1717))) int1717; typedef int __attribute__ ((bitwidth(1718))) int1718; typedef int __attribute__ ((bitwidth(1719))) int1719; typedef int __attribute__ ((bitwidth(1720))) int1720; typedef int __attribute__ ((bitwidth(1721))) int1721; typedef int __attribute__ ((bitwidth(1722))) int1722; typedef int __attribute__ ((bitwidth(1723))) int1723; typedef int __attribute__ ((bitwidth(1724))) int1724; typedef int __attribute__ ((bitwidth(1725))) int1725; typedef int __attribute__ ((bitwidth(1726))) int1726; typedef int __attribute__ ((bitwidth(1727))) int1727; typedef int __attribute__ ((bitwidth(1728))) int1728; typedef int __attribute__ ((bitwidth(1729))) int1729; typedef int __attribute__ ((bitwidth(1730))) int1730; typedef int __attribute__ ((bitwidth(1731))) int1731; typedef int __attribute__ ((bitwidth(1732))) int1732; typedef int __attribute__ ((bitwidth(1733))) int1733; typedef int __attribute__ ((bitwidth(1734))) int1734; typedef int __attribute__ ((bitwidth(1735))) int1735; typedef int __attribute__ ((bitwidth(1736))) int1736; typedef int __attribute__ ((bitwidth(1737))) int1737; typedef int __attribute__ ((bitwidth(1738))) int1738; typedef int __attribute__ ((bitwidth(1739))) int1739; typedef int __attribute__ ((bitwidth(1740))) int1740; typedef int __attribute__ ((bitwidth(1741))) int1741; typedef int __attribute__ ((bitwidth(1742))) int1742; typedef int __attribute__ ((bitwidth(1743))) int1743; typedef int __attribute__ ((bitwidth(1744))) int1744; typedef int __attribute__ ((bitwidth(1745))) int1745; typedef int __attribute__ ((bitwidth(1746))) int1746; typedef int __attribute__ ((bitwidth(1747))) int1747; typedef int __attribute__ ((bitwidth(1748))) int1748; typedef int __attribute__ ((bitwidth(1749))) int1749; typedef int __attribute__ ((bitwidth(1750))) int1750; typedef int __attribute__ ((bitwidth(1751))) int1751; typedef int __attribute__ ((bitwidth(1752))) int1752; typedef int __attribute__ ((bitwidth(1753))) int1753; typedef int __attribute__ ((bitwidth(1754))) int1754; typedef int __attribute__ ((bitwidth(1755))) int1755; typedef int __attribute__ ((bitwidth(1756))) int1756; typedef int __attribute__ ((bitwidth(1757))) int1757; typedef int __attribute__ ((bitwidth(1758))) int1758; typedef int __attribute__ ((bitwidth(1759))) int1759; typedef int __attribute__ ((bitwidth(1760))) int1760; typedef int __attribute__ ((bitwidth(1761))) int1761; typedef int __attribute__ ((bitwidth(1762))) int1762; typedef int __attribute__ ((bitwidth(1763))) int1763; typedef int __attribute__ ((bitwidth(1764))) int1764; typedef int __attribute__ ((bitwidth(1765))) int1765; typedef int __attribute__ ((bitwidth(1766))) int1766; typedef int __attribute__ ((bitwidth(1767))) int1767; typedef int __attribute__ ((bitwidth(1768))) int1768; typedef int __attribute__ ((bitwidth(1769))) int1769; typedef int __attribute__ ((bitwidth(1770))) int1770; typedef int __attribute__ ((bitwidth(1771))) int1771; typedef int __attribute__ ((bitwidth(1772))) int1772; typedef int __attribute__ ((bitwidth(1773))) int1773; typedef int __attribute__ ((bitwidth(1774))) int1774; typedef int __attribute__ ((bitwidth(1775))) int1775; typedef int __attribute__ ((bitwidth(1776))) int1776; typedef int __attribute__ ((bitwidth(1777))) int1777; typedef int __attribute__ ((bitwidth(1778))) int1778; typedef int __attribute__ ((bitwidth(1779))) int1779; typedef int __attribute__ ((bitwidth(1780))) int1780; typedef int __attribute__ ((bitwidth(1781))) int1781; typedef int __attribute__ ((bitwidth(1782))) int1782; typedef int __attribute__ ((bitwidth(1783))) int1783; typedef int __attribute__ ((bitwidth(1784))) int1784; typedef int __attribute__ ((bitwidth(1785))) int1785; typedef int __attribute__ ((bitwidth(1786))) int1786; typedef int __attribute__ ((bitwidth(1787))) int1787; typedef int __attribute__ ((bitwidth(1788))) int1788; typedef int __attribute__ ((bitwidth(1789))) int1789; typedef int __attribute__ ((bitwidth(1790))) int1790; typedef int __attribute__ ((bitwidth(1791))) int1791; typedef int __attribute__ ((bitwidth(1792))) int1792; typedef int __attribute__ ((bitwidth(1793))) int1793; typedef int __attribute__ ((bitwidth(1794))) int1794; typedef int __attribute__ ((bitwidth(1795))) int1795; typedef int __attribute__ ((bitwidth(1796))) int1796; typedef int __attribute__ ((bitwidth(1797))) int1797; typedef int __attribute__ ((bitwidth(1798))) int1798; typedef int __attribute__ ((bitwidth(1799))) int1799; typedef int __attribute__ ((bitwidth(1800))) int1800; typedef int __attribute__ ((bitwidth(1801))) int1801; typedef int __attribute__ ((bitwidth(1802))) int1802; typedef int __attribute__ ((bitwidth(1803))) int1803; typedef int __attribute__ ((bitwidth(1804))) int1804; typedef int __attribute__ ((bitwidth(1805))) int1805; typedef int __attribute__ ((bitwidth(1806))) int1806; typedef int __attribute__ ((bitwidth(1807))) int1807; typedef int __attribute__ ((bitwidth(1808))) int1808; typedef int __attribute__ ((bitwidth(1809))) int1809; typedef int __attribute__ ((bitwidth(1810))) int1810; typedef int __attribute__ ((bitwidth(1811))) int1811; typedef int __attribute__ ((bitwidth(1812))) int1812; typedef int __attribute__ ((bitwidth(1813))) int1813; typedef int __attribute__ ((bitwidth(1814))) int1814; typedef int __attribute__ ((bitwidth(1815))) int1815; typedef int __attribute__ ((bitwidth(1816))) int1816; typedef int __attribute__ ((bitwidth(1817))) int1817; typedef int __attribute__ ((bitwidth(1818))) int1818; typedef int __attribute__ ((bitwidth(1819))) int1819; typedef int __attribute__ ((bitwidth(1820))) int1820; typedef int __attribute__ ((bitwidth(1821))) int1821; typedef int __attribute__ ((bitwidth(1822))) int1822; typedef int __attribute__ ((bitwidth(1823))) int1823; typedef int __attribute__ ((bitwidth(1824))) int1824; typedef int __attribute__ ((bitwidth(1825))) int1825; typedef int __attribute__ ((bitwidth(1826))) int1826; typedef int __attribute__ ((bitwidth(1827))) int1827; typedef int __attribute__ ((bitwidth(1828))) int1828; typedef int __attribute__ ((bitwidth(1829))) int1829; typedef int __attribute__ ((bitwidth(1830))) int1830; typedef int __attribute__ ((bitwidth(1831))) int1831; typedef int __attribute__ ((bitwidth(1832))) int1832; typedef int __attribute__ ((bitwidth(1833))) int1833; typedef int __attribute__ ((bitwidth(1834))) int1834; typedef int __attribute__ ((bitwidth(1835))) int1835; typedef int __attribute__ ((bitwidth(1836))) int1836; typedef int __attribute__ ((bitwidth(1837))) int1837; typedef int __attribute__ ((bitwidth(1838))) int1838; typedef int __attribute__ ((bitwidth(1839))) int1839; typedef int __attribute__ ((bitwidth(1840))) int1840; typedef int __attribute__ ((bitwidth(1841))) int1841; typedef int __attribute__ ((bitwidth(1842))) int1842; typedef int __attribute__ ((bitwidth(1843))) int1843; typedef int __attribute__ ((bitwidth(1844))) int1844; typedef int __attribute__ ((bitwidth(1845))) int1845; typedef int __attribute__ ((bitwidth(1846))) int1846; typedef int __attribute__ ((bitwidth(1847))) int1847; typedef int __attribute__ ((bitwidth(1848))) int1848; typedef int __attribute__ ((bitwidth(1849))) int1849; typedef int __attribute__ ((bitwidth(1850))) int1850; typedef int __attribute__ ((bitwidth(1851))) int1851; typedef int __attribute__ ((bitwidth(1852))) int1852; typedef int __attribute__ ((bitwidth(1853))) int1853; typedef int __attribute__ ((bitwidth(1854))) int1854; typedef int __attribute__ ((bitwidth(1855))) int1855; typedef int __attribute__ ((bitwidth(1856))) int1856; typedef int __attribute__ ((bitwidth(1857))) int1857; typedef int __attribute__ ((bitwidth(1858))) int1858; typedef int __attribute__ ((bitwidth(1859))) int1859; typedef int __attribute__ ((bitwidth(1860))) int1860; typedef int __attribute__ ((bitwidth(1861))) int1861; typedef int __attribute__ ((bitwidth(1862))) int1862; typedef int __attribute__ ((bitwidth(1863))) int1863; typedef int __attribute__ ((bitwidth(1864))) int1864; typedef int __attribute__ ((bitwidth(1865))) int1865; typedef int __attribute__ ((bitwidth(1866))) int1866; typedef int __attribute__ ((bitwidth(1867))) int1867; typedef int __attribute__ ((bitwidth(1868))) int1868; typedef int __attribute__ ((bitwidth(1869))) int1869; typedef int __attribute__ ((bitwidth(1870))) int1870; typedef int __attribute__ ((bitwidth(1871))) int1871; typedef int __attribute__ ((bitwidth(1872))) int1872; typedef int __attribute__ ((bitwidth(1873))) int1873; typedef int __attribute__ ((bitwidth(1874))) int1874; typedef int __attribute__ ((bitwidth(1875))) int1875; typedef int __attribute__ ((bitwidth(1876))) int1876; typedef int __attribute__ ((bitwidth(1877))) int1877; typedef int __attribute__ ((bitwidth(1878))) int1878; typedef int __attribute__ ((bitwidth(1879))) int1879; typedef int __attribute__ ((bitwidth(1880))) int1880; typedef int __attribute__ ((bitwidth(1881))) int1881; typedef int __attribute__ ((bitwidth(1882))) int1882; typedef int __attribute__ ((bitwidth(1883))) int1883; typedef int __attribute__ ((bitwidth(1884))) int1884; typedef int __attribute__ ((bitwidth(1885))) int1885; typedef int __attribute__ ((bitwidth(1886))) int1886; typedef int __attribute__ ((bitwidth(1887))) int1887; typedef int __attribute__ ((bitwidth(1888))) int1888; typedef int __attribute__ ((bitwidth(1889))) int1889; typedef int __attribute__ ((bitwidth(1890))) int1890; typedef int __attribute__ ((bitwidth(1891))) int1891; typedef int __attribute__ ((bitwidth(1892))) int1892; typedef int __attribute__ ((bitwidth(1893))) int1893; typedef int __attribute__ ((bitwidth(1894))) int1894; typedef int __attribute__ ((bitwidth(1895))) int1895; typedef int __attribute__ ((bitwidth(1896))) int1896; typedef int __attribute__ ((bitwidth(1897))) int1897; typedef int __attribute__ ((bitwidth(1898))) int1898; typedef int __attribute__ ((bitwidth(1899))) int1899; typedef int __attribute__ ((bitwidth(1900))) int1900; typedef int __attribute__ ((bitwidth(1901))) int1901; typedef int __attribute__ ((bitwidth(1902))) int1902; typedef int __attribute__ ((bitwidth(1903))) int1903; typedef int __attribute__ ((bitwidth(1904))) int1904; typedef int __attribute__ ((bitwidth(1905))) int1905; typedef int __attribute__ ((bitwidth(1906))) int1906; typedef int __attribute__ ((bitwidth(1907))) int1907; typedef int __attribute__ ((bitwidth(1908))) int1908; typedef int __attribute__ ((bitwidth(1909))) int1909; typedef int __attribute__ ((bitwidth(1910))) int1910; typedef int __attribute__ ((bitwidth(1911))) int1911; typedef int __attribute__ ((bitwidth(1912))) int1912; typedef int __attribute__ ((bitwidth(1913))) int1913; typedef int __attribute__ ((bitwidth(1914))) int1914; typedef int __attribute__ ((bitwidth(1915))) int1915; typedef int __attribute__ ((bitwidth(1916))) int1916; typedef int __attribute__ ((bitwidth(1917))) int1917; typedef int __attribute__ ((bitwidth(1918))) int1918; typedef int __attribute__ ((bitwidth(1919))) int1919; typedef int __attribute__ ((bitwidth(1920))) int1920; typedef int __attribute__ ((bitwidth(1921))) int1921; typedef int __attribute__ ((bitwidth(1922))) int1922; typedef int __attribute__ ((bitwidth(1923))) int1923; typedef int __attribute__ ((bitwidth(1924))) int1924; typedef int __attribute__ ((bitwidth(1925))) int1925; typedef int __attribute__ ((bitwidth(1926))) int1926; typedef int __attribute__ ((bitwidth(1927))) int1927; typedef int __attribute__ ((bitwidth(1928))) int1928; typedef int __attribute__ ((bitwidth(1929))) int1929; typedef int __attribute__ ((bitwidth(1930))) int1930; typedef int __attribute__ ((bitwidth(1931))) int1931; typedef int __attribute__ ((bitwidth(1932))) int1932; typedef int __attribute__ ((bitwidth(1933))) int1933; typedef int __attribute__ ((bitwidth(1934))) int1934; typedef int __attribute__ ((bitwidth(1935))) int1935; typedef int __attribute__ ((bitwidth(1936))) int1936; typedef int __attribute__ ((bitwidth(1937))) int1937; typedef int __attribute__ ((bitwidth(1938))) int1938; typedef int __attribute__ ((bitwidth(1939))) int1939; typedef int __attribute__ ((bitwidth(1940))) int1940; typedef int __attribute__ ((bitwidth(1941))) int1941; typedef int __attribute__ ((bitwidth(1942))) int1942; typedef int __attribute__ ((bitwidth(1943))) int1943; typedef int __attribute__ ((bitwidth(1944))) int1944; typedef int __attribute__ ((bitwidth(1945))) int1945; typedef int __attribute__ ((bitwidth(1946))) int1946; typedef int __attribute__ ((bitwidth(1947))) int1947; typedef int __attribute__ ((bitwidth(1948))) int1948; typedef int __attribute__ ((bitwidth(1949))) int1949; typedef int __attribute__ ((bitwidth(1950))) int1950; typedef int __attribute__ ((bitwidth(1951))) int1951; typedef int __attribute__ ((bitwidth(1952))) int1952; typedef int __attribute__ ((bitwidth(1953))) int1953; typedef int __attribute__ ((bitwidth(1954))) int1954; typedef int __attribute__ ((bitwidth(1955))) int1955; typedef int __attribute__ ((bitwidth(1956))) int1956; typedef int __attribute__ ((bitwidth(1957))) int1957; typedef int __attribute__ ((bitwidth(1958))) int1958; typedef int __attribute__ ((bitwidth(1959))) int1959; typedef int __attribute__ ((bitwidth(1960))) int1960; typedef int __attribute__ ((bitwidth(1961))) int1961; typedef int __attribute__ ((bitwidth(1962))) int1962; typedef int __attribute__ ((bitwidth(1963))) int1963; typedef int __attribute__ ((bitwidth(1964))) int1964; typedef int __attribute__ ((bitwidth(1965))) int1965; typedef int __attribute__ ((bitwidth(1966))) int1966; typedef int __attribute__ ((bitwidth(1967))) int1967; typedef int __attribute__ ((bitwidth(1968))) int1968; typedef int __attribute__ ((bitwidth(1969))) int1969; typedef int __attribute__ ((bitwidth(1970))) int1970; typedef int __attribute__ ((bitwidth(1971))) int1971; typedef int __attribute__ ((bitwidth(1972))) int1972; typedef int __attribute__ ((bitwidth(1973))) int1973; typedef int __attribute__ ((bitwidth(1974))) int1974; typedef int __attribute__ ((bitwidth(1975))) int1975; typedef int __attribute__ ((bitwidth(1976))) int1976; typedef int __attribute__ ((bitwidth(1977))) int1977; typedef int __attribute__ ((bitwidth(1978))) int1978; typedef int __attribute__ ((bitwidth(1979))) int1979; typedef int __attribute__ ((bitwidth(1980))) int1980; typedef int __attribute__ ((bitwidth(1981))) int1981; typedef int __attribute__ ((bitwidth(1982))) int1982; typedef int __attribute__ ((bitwidth(1983))) int1983; typedef int __attribute__ ((bitwidth(1984))) int1984; typedef int __attribute__ ((bitwidth(1985))) int1985; typedef int __attribute__ ((bitwidth(1986))) int1986; typedef int __attribute__ ((bitwidth(1987))) int1987; typedef int __attribute__ ((bitwidth(1988))) int1988; typedef int __attribute__ ((bitwidth(1989))) int1989; typedef int __attribute__ ((bitwidth(1990))) int1990; typedef int __attribute__ ((bitwidth(1991))) int1991; typedef int __attribute__ ((bitwidth(1992))) int1992; typedef int __attribute__ ((bitwidth(1993))) int1993; typedef int __attribute__ ((bitwidth(1994))) int1994; typedef int __attribute__ ((bitwidth(1995))) int1995; typedef int __attribute__ ((bitwidth(1996))) int1996; typedef int __attribute__ ((bitwidth(1997))) int1997; typedef int __attribute__ ((bitwidth(1998))) int1998; typedef int __attribute__ ((bitwidth(1999))) int1999; typedef int __attribute__ ((bitwidth(2000))) int2000; typedef int __attribute__ ((bitwidth(2001))) int2001; typedef int __attribute__ ((bitwidth(2002))) int2002; typedef int __attribute__ ((bitwidth(2003))) int2003; typedef int __attribute__ ((bitwidth(2004))) int2004; typedef int __attribute__ ((bitwidth(2005))) int2005; typedef int __attribute__ ((bitwidth(2006))) int2006; typedef int __attribute__ ((bitwidth(2007))) int2007; typedef int __attribute__ ((bitwidth(2008))) int2008; typedef int __attribute__ ((bitwidth(2009))) int2009; typedef int __attribute__ ((bitwidth(2010))) int2010; typedef int __attribute__ ((bitwidth(2011))) int2011; typedef int __attribute__ ((bitwidth(2012))) int2012; typedef int __attribute__ ((bitwidth(2013))) int2013; typedef int __attribute__ ((bitwidth(2014))) int2014; typedef int __attribute__ ((bitwidth(2015))) int2015; typedef int __attribute__ ((bitwidth(2016))) int2016; typedef int __attribute__ ((bitwidth(2017))) int2017; typedef int __attribute__ ((bitwidth(2018))) int2018; typedef int __attribute__ ((bitwidth(2019))) int2019; typedef int __attribute__ ((bitwidth(2020))) int2020; typedef int __attribute__ ((bitwidth(2021))) int2021; typedef int __attribute__ ((bitwidth(2022))) int2022; typedef int __attribute__ ((bitwidth(2023))) int2023; typedef int __attribute__ ((bitwidth(2024))) int2024; typedef int __attribute__ ((bitwidth(2025))) int2025; typedef int __attribute__ ((bitwidth(2026))) int2026; typedef int __attribute__ ((bitwidth(2027))) int2027; typedef int __attribute__ ((bitwidth(2028))) int2028; typedef int __attribute__ ((bitwidth(2029))) int2029; typedef int __attribute__ ((bitwidth(2030))) int2030; typedef int __attribute__ ((bitwidth(2031))) int2031; typedef int __attribute__ ((bitwidth(2032))) int2032; typedef int __attribute__ ((bitwidth(2033))) int2033; typedef int __attribute__ ((bitwidth(2034))) int2034; typedef int __attribute__ ((bitwidth(2035))) int2035; typedef int __attribute__ ((bitwidth(2036))) int2036; typedef int __attribute__ ((bitwidth(2037))) int2037; typedef int __attribute__ ((bitwidth(2038))) int2038; typedef int __attribute__ ((bitwidth(2039))) int2039; typedef int __attribute__ ((bitwidth(2040))) int2040; typedef int __attribute__ ((bitwidth(2041))) int2041; typedef int __attribute__ ((bitwidth(2042))) int2042; typedef int __attribute__ ((bitwidth(2043))) int2043; typedef int __attribute__ ((bitwidth(2044))) int2044; typedef int __attribute__ ((bitwidth(2045))) int2045; typedef int __attribute__ ((bitwidth(2046))) int2046; typedef int __attribute__ ((bitwidth(2047))) int2047; typedef int __attribute__ ((bitwidth(2048))) int2048; #pragma line 99 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 #pragma line 108 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.def" 1 #pragma empty_line #pragma empty_line typedef unsigned int __attribute__ ((bitwidth(1))) uint1; typedef unsigned int __attribute__ ((bitwidth(2))) uint2; typedef unsigned int __attribute__ ((bitwidth(3))) uint3; typedef unsigned int __attribute__ ((bitwidth(4))) uint4; typedef unsigned int __attribute__ ((bitwidth(5))) uint5; typedef unsigned int __attribute__ ((bitwidth(6))) uint6; typedef unsigned int __attribute__ ((bitwidth(7))) uint7; typedef unsigned int __attribute__ ((bitwidth(8))) uint8; typedef unsigned int __attribute__ ((bitwidth(9))) uint9; typedef unsigned int __attribute__ ((bitwidth(10))) uint10; typedef unsigned int __attribute__ ((bitwidth(11))) uint11; typedef unsigned int __attribute__ ((bitwidth(12))) uint12; typedef unsigned int __attribute__ ((bitwidth(13))) uint13; typedef unsigned int __attribute__ ((bitwidth(14))) uint14; typedef unsigned int __attribute__ ((bitwidth(15))) uint15; typedef unsigned int __attribute__ ((bitwidth(16))) uint16; typedef unsigned int __attribute__ ((bitwidth(17))) uint17; typedef unsigned int __attribute__ ((bitwidth(18))) uint18; typedef unsigned int __attribute__ ((bitwidth(19))) uint19; typedef unsigned int __attribute__ ((bitwidth(20))) uint20; typedef unsigned int __attribute__ ((bitwidth(21))) uint21; typedef unsigned int __attribute__ ((bitwidth(22))) uint22; typedef unsigned int __attribute__ ((bitwidth(23))) uint23; typedef unsigned int __attribute__ ((bitwidth(24))) uint24; typedef unsigned int __attribute__ ((bitwidth(25))) uint25; typedef unsigned int __attribute__ ((bitwidth(26))) uint26; typedef unsigned int __attribute__ ((bitwidth(27))) uint27; typedef unsigned int __attribute__ ((bitwidth(28))) uint28; typedef unsigned int __attribute__ ((bitwidth(29))) uint29; typedef unsigned int __attribute__ ((bitwidth(30))) uint30; typedef unsigned int __attribute__ ((bitwidth(31))) uint31; typedef unsigned int __attribute__ ((bitwidth(32))) uint32; typedef unsigned int __attribute__ ((bitwidth(33))) uint33; typedef unsigned int __attribute__ ((bitwidth(34))) uint34; typedef unsigned int __attribute__ ((bitwidth(35))) uint35; typedef unsigned int __attribute__ ((bitwidth(36))) uint36; typedef unsigned int __attribute__ ((bitwidth(37))) uint37; typedef unsigned int __attribute__ ((bitwidth(38))) uint38; typedef unsigned int __attribute__ ((bitwidth(39))) uint39; typedef unsigned int __attribute__ ((bitwidth(40))) uint40; typedef unsigned int __attribute__ ((bitwidth(41))) uint41; typedef unsigned int __attribute__ ((bitwidth(42))) uint42; typedef unsigned int __attribute__ ((bitwidth(43))) uint43; typedef unsigned int __attribute__ ((bitwidth(44))) uint44; typedef unsigned int __attribute__ ((bitwidth(45))) uint45; typedef unsigned int __attribute__ ((bitwidth(46))) uint46; typedef unsigned int __attribute__ ((bitwidth(47))) uint47; typedef unsigned int __attribute__ ((bitwidth(48))) uint48; typedef unsigned int __attribute__ ((bitwidth(49))) uint49; typedef unsigned int __attribute__ ((bitwidth(50))) uint50; typedef unsigned int __attribute__ ((bitwidth(51))) uint51; typedef unsigned int __attribute__ ((bitwidth(52))) uint52; typedef unsigned int __attribute__ ((bitwidth(53))) uint53; typedef unsigned int __attribute__ ((bitwidth(54))) uint54; typedef unsigned int __attribute__ ((bitwidth(55))) uint55; typedef unsigned int __attribute__ ((bitwidth(56))) uint56; typedef unsigned int __attribute__ ((bitwidth(57))) uint57; typedef unsigned int __attribute__ ((bitwidth(58))) uint58; typedef unsigned int __attribute__ ((bitwidth(59))) uint59; typedef unsigned int __attribute__ ((bitwidth(60))) uint60; typedef unsigned int __attribute__ ((bitwidth(61))) uint61; typedef unsigned int __attribute__ ((bitwidth(62))) uint62; typedef unsigned int __attribute__ ((bitwidth(63))) uint63; #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line #pragma empty_line /*#if AUTOPILOT_VERSION >= 1 */ #pragma empty_line typedef unsigned int __attribute__ ((bitwidth(65))) uint65; typedef unsigned int __attribute__ ((bitwidth(66))) uint66; typedef unsigned int __attribute__ ((bitwidth(67))) uint67; typedef unsigned int __attribute__ ((bitwidth(68))) uint68; typedef unsigned int __attribute__ ((bitwidth(69))) uint69; typedef unsigned int __attribute__ ((bitwidth(70))) uint70; typedef unsigned int __attribute__ ((bitwidth(71))) uint71; typedef unsigned int __attribute__ ((bitwidth(72))) uint72; typedef unsigned int __attribute__ ((bitwidth(73))) uint73; typedef unsigned int __attribute__ ((bitwidth(74))) uint74; typedef unsigned int __attribute__ ((bitwidth(75))) uint75; typedef unsigned int __attribute__ ((bitwidth(76))) uint76; typedef unsigned int __attribute__ ((bitwidth(77))) uint77; typedef unsigned int __attribute__ ((bitwidth(78))) uint78; typedef unsigned int __attribute__ ((bitwidth(79))) uint79; typedef unsigned int __attribute__ ((bitwidth(80))) uint80; typedef unsigned int __attribute__ ((bitwidth(81))) uint81; typedef unsigned int __attribute__ ((bitwidth(82))) uint82; typedef unsigned int __attribute__ ((bitwidth(83))) uint83; typedef unsigned int __attribute__ ((bitwidth(84))) uint84; typedef unsigned int __attribute__ ((bitwidth(85))) uint85; typedef unsigned int __attribute__ ((bitwidth(86))) uint86; typedef unsigned int __attribute__ ((bitwidth(87))) uint87; typedef unsigned int __attribute__ ((bitwidth(88))) uint88; typedef unsigned int __attribute__ ((bitwidth(89))) uint89; typedef unsigned int __attribute__ ((bitwidth(90))) uint90; typedef unsigned int __attribute__ ((bitwidth(91))) uint91; typedef unsigned int __attribute__ ((bitwidth(92))) uint92; typedef unsigned int __attribute__ ((bitwidth(93))) uint93; typedef unsigned int __attribute__ ((bitwidth(94))) uint94; typedef unsigned int __attribute__ ((bitwidth(95))) uint95; typedef unsigned int __attribute__ ((bitwidth(96))) uint96; typedef unsigned int __attribute__ ((bitwidth(97))) uint97; typedef unsigned int __attribute__ ((bitwidth(98))) uint98; typedef unsigned int __attribute__ ((bitwidth(99))) uint99; typedef unsigned int __attribute__ ((bitwidth(100))) uint100; typedef unsigned int __attribute__ ((bitwidth(101))) uint101; typedef unsigned int __attribute__ ((bitwidth(102))) uint102; typedef unsigned int __attribute__ ((bitwidth(103))) uint103; typedef unsigned int __attribute__ ((bitwidth(104))) uint104; typedef unsigned int __attribute__ ((bitwidth(105))) uint105; typedef unsigned int __attribute__ ((bitwidth(106))) uint106; typedef unsigned int __attribute__ ((bitwidth(107))) uint107; typedef unsigned int __attribute__ ((bitwidth(108))) uint108; typedef unsigned int __attribute__ ((bitwidth(109))) uint109; typedef unsigned int __attribute__ ((bitwidth(110))) uint110; typedef unsigned int __attribute__ ((bitwidth(111))) uint111; typedef unsigned int __attribute__ ((bitwidth(112))) uint112; typedef unsigned int __attribute__ ((bitwidth(113))) uint113; typedef unsigned int __attribute__ ((bitwidth(114))) uint114; typedef unsigned int __attribute__ ((bitwidth(115))) uint115; typedef unsigned int __attribute__ ((bitwidth(116))) uint116; typedef unsigned int __attribute__ ((bitwidth(117))) uint117; typedef unsigned int __attribute__ ((bitwidth(118))) uint118; typedef unsigned int __attribute__ ((bitwidth(119))) uint119; typedef unsigned int __attribute__ ((bitwidth(120))) uint120; typedef unsigned int __attribute__ ((bitwidth(121))) uint121; typedef unsigned int __attribute__ ((bitwidth(122))) uint122; typedef unsigned int __attribute__ ((bitwidth(123))) uint123; typedef unsigned int __attribute__ ((bitwidth(124))) uint124; typedef unsigned int __attribute__ ((bitwidth(125))) uint125; typedef unsigned int __attribute__ ((bitwidth(126))) uint126; typedef unsigned int __attribute__ ((bitwidth(127))) uint127; typedef unsigned int __attribute__ ((bitwidth(128))) uint128; #pragma empty_line /*#endif*/ #pragma empty_line #pragma empty_line /*#ifdef EXTENDED_GCC*/ #pragma empty_line typedef unsigned int __attribute__ ((bitwidth(129))) uint129; typedef unsigned int __attribute__ ((bitwidth(130))) uint130; typedef unsigned int __attribute__ ((bitwidth(131))) uint131; typedef unsigned int __attribute__ ((bitwidth(132))) uint132; typedef unsigned int __attribute__ ((bitwidth(133))) uint133; typedef unsigned int __attribute__ ((bitwidth(134))) uint134; typedef unsigned int __attribute__ ((bitwidth(135))) uint135; typedef unsigned int __attribute__ ((bitwidth(136))) uint136; typedef unsigned int __attribute__ ((bitwidth(137))) uint137; typedef unsigned int __attribute__ ((bitwidth(138))) uint138; typedef unsigned int __attribute__ ((bitwidth(139))) uint139; typedef unsigned int __attribute__ ((bitwidth(140))) uint140; typedef unsigned int __attribute__ ((bitwidth(141))) uint141; typedef unsigned int __attribute__ ((bitwidth(142))) uint142; typedef unsigned int __attribute__ ((bitwidth(143))) uint143; typedef unsigned int __attribute__ ((bitwidth(144))) uint144; typedef unsigned int __attribute__ ((bitwidth(145))) uint145; typedef unsigned int __attribute__ ((bitwidth(146))) uint146; typedef unsigned int __attribute__ ((bitwidth(147))) uint147; typedef unsigned int __attribute__ ((bitwidth(148))) uint148; typedef unsigned int __attribute__ ((bitwidth(149))) uint149; typedef unsigned int __attribute__ ((bitwidth(150))) uint150; typedef unsigned int __attribute__ ((bitwidth(151))) uint151; typedef unsigned int __attribute__ ((bitwidth(152))) uint152; typedef unsigned int __attribute__ ((bitwidth(153))) uint153; typedef unsigned int __attribute__ ((bitwidth(154))) uint154; typedef unsigned int __attribute__ ((bitwidth(155))) uint155; typedef unsigned int __attribute__ ((bitwidth(156))) uint156; typedef unsigned int __attribute__ ((bitwidth(157))) uint157; typedef unsigned int __attribute__ ((bitwidth(158))) uint158; typedef unsigned int __attribute__ ((bitwidth(159))) uint159; typedef unsigned int __attribute__ ((bitwidth(160))) uint160; typedef unsigned int __attribute__ ((bitwidth(161))) uint161; typedef unsigned int __attribute__ ((bitwidth(162))) uint162; typedef unsigned int __attribute__ ((bitwidth(163))) uint163; typedef unsigned int __attribute__ ((bitwidth(164))) uint164; typedef unsigned int __attribute__ ((bitwidth(165))) uint165; typedef unsigned int __attribute__ ((bitwidth(166))) uint166; typedef unsigned int __attribute__ ((bitwidth(167))) uint167; typedef unsigned int __attribute__ ((bitwidth(168))) uint168; typedef unsigned int __attribute__ ((bitwidth(169))) uint169; typedef unsigned int __attribute__ ((bitwidth(170))) uint170; typedef unsigned int __attribute__ ((bitwidth(171))) uint171; typedef unsigned int __attribute__ ((bitwidth(172))) uint172; typedef unsigned int __attribute__ ((bitwidth(173))) uint173; typedef unsigned int __attribute__ ((bitwidth(174))) uint174; typedef unsigned int __attribute__ ((bitwidth(175))) uint175; typedef unsigned int __attribute__ ((bitwidth(176))) uint176; typedef unsigned int __attribute__ ((bitwidth(177))) uint177; typedef unsigned int __attribute__ ((bitwidth(178))) uint178; typedef unsigned int __attribute__ ((bitwidth(179))) uint179; typedef unsigned int __attribute__ ((bitwidth(180))) uint180; typedef unsigned int __attribute__ ((bitwidth(181))) uint181; typedef unsigned int __attribute__ ((bitwidth(182))) uint182; typedef unsigned int __attribute__ ((bitwidth(183))) uint183; typedef unsigned int __attribute__ ((bitwidth(184))) uint184; typedef unsigned int __attribute__ ((bitwidth(185))) uint185; typedef unsigned int __attribute__ ((bitwidth(186))) uint186; typedef unsigned int __attribute__ ((bitwidth(187))) uint187; typedef unsigned int __attribute__ ((bitwidth(188))) uint188; typedef unsigned int __attribute__ ((bitwidth(189))) uint189; typedef unsigned int __attribute__ ((bitwidth(190))) uint190; typedef unsigned int __attribute__ ((bitwidth(191))) uint191; typedef unsigned int __attribute__ ((bitwidth(192))) uint192; typedef unsigned int __attribute__ ((bitwidth(193))) uint193; typedef unsigned int __attribute__ ((bitwidth(194))) uint194; typedef unsigned int __attribute__ ((bitwidth(195))) uint195; typedef unsigned int __attribute__ ((bitwidth(196))) uint196; typedef unsigned int __attribute__ ((bitwidth(197))) uint197; typedef unsigned int __attribute__ ((bitwidth(198))) uint198; typedef unsigned int __attribute__ ((bitwidth(199))) uint199; typedef unsigned int __attribute__ ((bitwidth(200))) uint200; typedef unsigned int __attribute__ ((bitwidth(201))) uint201; typedef unsigned int __attribute__ ((bitwidth(202))) uint202; typedef unsigned int __attribute__ ((bitwidth(203))) uint203; typedef unsigned int __attribute__ ((bitwidth(204))) uint204; typedef unsigned int __attribute__ ((bitwidth(205))) uint205; typedef unsigned int __attribute__ ((bitwidth(206))) uint206; typedef unsigned int __attribute__ ((bitwidth(207))) uint207; typedef unsigned int __attribute__ ((bitwidth(208))) uint208; typedef unsigned int __attribute__ ((bitwidth(209))) uint209; typedef unsigned int __attribute__ ((bitwidth(210))) uint210; typedef unsigned int __attribute__ ((bitwidth(211))) uint211; typedef unsigned int __attribute__ ((bitwidth(212))) uint212; typedef unsigned int __attribute__ ((bitwidth(213))) uint213; typedef unsigned int __attribute__ ((bitwidth(214))) uint214; typedef unsigned int __attribute__ ((bitwidth(215))) uint215; typedef unsigned int __attribute__ ((bitwidth(216))) uint216; typedef unsigned int __attribute__ ((bitwidth(217))) uint217; typedef unsigned int __attribute__ ((bitwidth(218))) uint218; typedef unsigned int __attribute__ ((bitwidth(219))) uint219; typedef unsigned int __attribute__ ((bitwidth(220))) uint220; typedef unsigned int __attribute__ ((bitwidth(221))) uint221; typedef unsigned int __attribute__ ((bitwidth(222))) uint222; typedef unsigned int __attribute__ ((bitwidth(223))) uint223; typedef unsigned int __attribute__ ((bitwidth(224))) uint224; typedef unsigned int __attribute__ ((bitwidth(225))) uint225; typedef unsigned int __attribute__ ((bitwidth(226))) uint226; typedef unsigned int __attribute__ ((bitwidth(227))) uint227; typedef unsigned int __attribute__ ((bitwidth(228))) uint228; typedef unsigned int __attribute__ ((bitwidth(229))) uint229; typedef unsigned int __attribute__ ((bitwidth(230))) uint230; typedef unsigned int __attribute__ ((bitwidth(231))) uint231; typedef unsigned int __attribute__ ((bitwidth(232))) uint232; typedef unsigned int __attribute__ ((bitwidth(233))) uint233; typedef unsigned int __attribute__ ((bitwidth(234))) uint234; typedef unsigned int __attribute__ ((bitwidth(235))) uint235; typedef unsigned int __attribute__ ((bitwidth(236))) uint236; typedef unsigned int __attribute__ ((bitwidth(237))) uint237; typedef unsigned int __attribute__ ((bitwidth(238))) uint238; typedef unsigned int __attribute__ ((bitwidth(239))) uint239; typedef unsigned int __attribute__ ((bitwidth(240))) uint240; typedef unsigned int __attribute__ ((bitwidth(241))) uint241; typedef unsigned int __attribute__ ((bitwidth(242))) uint242; typedef unsigned int __attribute__ ((bitwidth(243))) uint243; typedef unsigned int __attribute__ ((bitwidth(244))) uint244; typedef unsigned int __attribute__ ((bitwidth(245))) uint245; typedef unsigned int __attribute__ ((bitwidth(246))) uint246; typedef unsigned int __attribute__ ((bitwidth(247))) uint247; typedef unsigned int __attribute__ ((bitwidth(248))) uint248; typedef unsigned int __attribute__ ((bitwidth(249))) uint249; typedef unsigned int __attribute__ ((bitwidth(250))) uint250; typedef unsigned int __attribute__ ((bitwidth(251))) uint251; typedef unsigned int __attribute__ ((bitwidth(252))) uint252; typedef unsigned int __attribute__ ((bitwidth(253))) uint253; typedef unsigned int __attribute__ ((bitwidth(254))) uint254; typedef unsigned int __attribute__ ((bitwidth(255))) uint255; typedef unsigned int __attribute__ ((bitwidth(256))) uint256; typedef unsigned int __attribute__ ((bitwidth(257))) uint257; typedef unsigned int __attribute__ ((bitwidth(258))) uint258; typedef unsigned int __attribute__ ((bitwidth(259))) uint259; typedef unsigned int __attribute__ ((bitwidth(260))) uint260; typedef unsigned int __attribute__ ((bitwidth(261))) uint261; typedef unsigned int __attribute__ ((bitwidth(262))) uint262; typedef unsigned int __attribute__ ((bitwidth(263))) uint263; typedef unsigned int __attribute__ ((bitwidth(264))) uint264; typedef unsigned int __attribute__ ((bitwidth(265))) uint265; typedef unsigned int __attribute__ ((bitwidth(266))) uint266; typedef unsigned int __attribute__ ((bitwidth(267))) uint267; typedef unsigned int __attribute__ ((bitwidth(268))) uint268; typedef unsigned int __attribute__ ((bitwidth(269))) uint269; typedef unsigned int __attribute__ ((bitwidth(270))) uint270; typedef unsigned int __attribute__ ((bitwidth(271))) uint271; typedef unsigned int __attribute__ ((bitwidth(272))) uint272; typedef unsigned int __attribute__ ((bitwidth(273))) uint273; typedef unsigned int __attribute__ ((bitwidth(274))) uint274; typedef unsigned int __attribute__ ((bitwidth(275))) uint275; typedef unsigned int __attribute__ ((bitwidth(276))) uint276; typedef unsigned int __attribute__ ((bitwidth(277))) uint277; typedef unsigned int __attribute__ ((bitwidth(278))) uint278; typedef unsigned int __attribute__ ((bitwidth(279))) uint279; typedef unsigned int __attribute__ ((bitwidth(280))) uint280; typedef unsigned int __attribute__ ((bitwidth(281))) uint281; typedef unsigned int __attribute__ ((bitwidth(282))) uint282; typedef unsigned int __attribute__ ((bitwidth(283))) uint283; typedef unsigned int __attribute__ ((bitwidth(284))) uint284; typedef unsigned int __attribute__ ((bitwidth(285))) uint285; typedef unsigned int __attribute__ ((bitwidth(286))) uint286; typedef unsigned int __attribute__ ((bitwidth(287))) uint287; typedef unsigned int __attribute__ ((bitwidth(288))) uint288; typedef unsigned int __attribute__ ((bitwidth(289))) uint289; typedef unsigned int __attribute__ ((bitwidth(290))) uint290; typedef unsigned int __attribute__ ((bitwidth(291))) uint291; typedef unsigned int __attribute__ ((bitwidth(292))) uint292; typedef unsigned int __attribute__ ((bitwidth(293))) uint293; typedef unsigned int __attribute__ ((bitwidth(294))) uint294; typedef unsigned int __attribute__ ((bitwidth(295))) uint295; typedef unsigned int __attribute__ ((bitwidth(296))) uint296; typedef unsigned int __attribute__ ((bitwidth(297))) uint297; typedef unsigned int __attribute__ ((bitwidth(298))) uint298; typedef unsigned int __attribute__ ((bitwidth(299))) uint299; typedef unsigned int __attribute__ ((bitwidth(300))) uint300; typedef unsigned int __attribute__ ((bitwidth(301))) uint301; typedef unsigned int __attribute__ ((bitwidth(302))) uint302; typedef unsigned int __attribute__ ((bitwidth(303))) uint303; typedef unsigned int __attribute__ ((bitwidth(304))) uint304; typedef unsigned int __attribute__ ((bitwidth(305))) uint305; typedef unsigned int __attribute__ ((bitwidth(306))) uint306; typedef unsigned int __attribute__ ((bitwidth(307))) uint307; typedef unsigned int __attribute__ ((bitwidth(308))) uint308; typedef unsigned int __attribute__ ((bitwidth(309))) uint309; typedef unsigned int __attribute__ ((bitwidth(310))) uint310; typedef unsigned int __attribute__ ((bitwidth(311))) uint311; typedef unsigned int __attribute__ ((bitwidth(312))) uint312; typedef unsigned int __attribute__ ((bitwidth(313))) uint313; typedef unsigned int __attribute__ ((bitwidth(314))) uint314; typedef unsigned int __attribute__ ((bitwidth(315))) uint315; typedef unsigned int __attribute__ ((bitwidth(316))) uint316; typedef unsigned int __attribute__ ((bitwidth(317))) uint317; typedef unsigned int __attribute__ ((bitwidth(318))) uint318; typedef unsigned int __attribute__ ((bitwidth(319))) uint319; typedef unsigned int __attribute__ ((bitwidth(320))) uint320; typedef unsigned int __attribute__ ((bitwidth(321))) uint321; typedef unsigned int __attribute__ ((bitwidth(322))) uint322; typedef unsigned int __attribute__ ((bitwidth(323))) uint323; typedef unsigned int __attribute__ ((bitwidth(324))) uint324; typedef unsigned int __attribute__ ((bitwidth(325))) uint325; typedef unsigned int __attribute__ ((bitwidth(326))) uint326; typedef unsigned int __attribute__ ((bitwidth(327))) uint327; typedef unsigned int __attribute__ ((bitwidth(328))) uint328; typedef unsigned int __attribute__ ((bitwidth(329))) uint329; typedef unsigned int __attribute__ ((bitwidth(330))) uint330; typedef unsigned int __attribute__ ((bitwidth(331))) uint331; typedef unsigned int __attribute__ ((bitwidth(332))) uint332; typedef unsigned int __attribute__ ((bitwidth(333))) uint333; typedef unsigned int __attribute__ ((bitwidth(334))) uint334; typedef unsigned int __attribute__ ((bitwidth(335))) uint335; typedef unsigned int __attribute__ ((bitwidth(336))) uint336; typedef unsigned int __attribute__ ((bitwidth(337))) uint337; typedef unsigned int __attribute__ ((bitwidth(338))) uint338; typedef unsigned int __attribute__ ((bitwidth(339))) uint339; typedef unsigned int __attribute__ ((bitwidth(340))) uint340; typedef unsigned int __attribute__ ((bitwidth(341))) uint341; typedef unsigned int __attribute__ ((bitwidth(342))) uint342; typedef unsigned int __attribute__ ((bitwidth(343))) uint343; typedef unsigned int __attribute__ ((bitwidth(344))) uint344; typedef unsigned int __attribute__ ((bitwidth(345))) uint345; typedef unsigned int __attribute__ ((bitwidth(346))) uint346; typedef unsigned int __attribute__ ((bitwidth(347))) uint347; typedef unsigned int __attribute__ ((bitwidth(348))) uint348; typedef unsigned int __attribute__ ((bitwidth(349))) uint349; typedef unsigned int __attribute__ ((bitwidth(350))) uint350; typedef unsigned int __attribute__ ((bitwidth(351))) uint351; typedef unsigned int __attribute__ ((bitwidth(352))) uint352; typedef unsigned int __attribute__ ((bitwidth(353))) uint353; typedef unsigned int __attribute__ ((bitwidth(354))) uint354; typedef unsigned int __attribute__ ((bitwidth(355))) uint355; typedef unsigned int __attribute__ ((bitwidth(356))) uint356; typedef unsigned int __attribute__ ((bitwidth(357))) uint357; typedef unsigned int __attribute__ ((bitwidth(358))) uint358; typedef unsigned int __attribute__ ((bitwidth(359))) uint359; typedef unsigned int __attribute__ ((bitwidth(360))) uint360; typedef unsigned int __attribute__ ((bitwidth(361))) uint361; typedef unsigned int __attribute__ ((bitwidth(362))) uint362; typedef unsigned int __attribute__ ((bitwidth(363))) uint363; typedef unsigned int __attribute__ ((bitwidth(364))) uint364; typedef unsigned int __attribute__ ((bitwidth(365))) uint365; typedef unsigned int __attribute__ ((bitwidth(366))) uint366; typedef unsigned int __attribute__ ((bitwidth(367))) uint367; typedef unsigned int __attribute__ ((bitwidth(368))) uint368; typedef unsigned int __attribute__ ((bitwidth(369))) uint369; typedef unsigned int __attribute__ ((bitwidth(370))) uint370; typedef unsigned int __attribute__ ((bitwidth(371))) uint371; typedef unsigned int __attribute__ ((bitwidth(372))) uint372; typedef unsigned int __attribute__ ((bitwidth(373))) uint373; typedef unsigned int __attribute__ ((bitwidth(374))) uint374; typedef unsigned int __attribute__ ((bitwidth(375))) uint375; typedef unsigned int __attribute__ ((bitwidth(376))) uint376; typedef unsigned int __attribute__ ((bitwidth(377))) uint377; typedef unsigned int __attribute__ ((bitwidth(378))) uint378; typedef unsigned int __attribute__ ((bitwidth(379))) uint379; typedef unsigned int __attribute__ ((bitwidth(380))) uint380; typedef unsigned int __attribute__ ((bitwidth(381))) uint381; typedef unsigned int __attribute__ ((bitwidth(382))) uint382; typedef unsigned int __attribute__ ((bitwidth(383))) uint383; typedef unsigned int __attribute__ ((bitwidth(384))) uint384; typedef unsigned int __attribute__ ((bitwidth(385))) uint385; typedef unsigned int __attribute__ ((bitwidth(386))) uint386; typedef unsigned int __attribute__ ((bitwidth(387))) uint387; typedef unsigned int __attribute__ ((bitwidth(388))) uint388; typedef unsigned int __attribute__ ((bitwidth(389))) uint389; typedef unsigned int __attribute__ ((bitwidth(390))) uint390; typedef unsigned int __attribute__ ((bitwidth(391))) uint391; typedef unsigned int __attribute__ ((bitwidth(392))) uint392; typedef unsigned int __attribute__ ((bitwidth(393))) uint393; typedef unsigned int __attribute__ ((bitwidth(394))) uint394; typedef unsigned int __attribute__ ((bitwidth(395))) uint395; typedef unsigned int __attribute__ ((bitwidth(396))) uint396; typedef unsigned int __attribute__ ((bitwidth(397))) uint397; typedef unsigned int __attribute__ ((bitwidth(398))) uint398; typedef unsigned int __attribute__ ((bitwidth(399))) uint399; typedef unsigned int __attribute__ ((bitwidth(400))) uint400; typedef unsigned int __attribute__ ((bitwidth(401))) uint401; typedef unsigned int __attribute__ ((bitwidth(402))) uint402; typedef unsigned int __attribute__ ((bitwidth(403))) uint403; typedef unsigned int __attribute__ ((bitwidth(404))) uint404; typedef unsigned int __attribute__ ((bitwidth(405))) uint405; typedef unsigned int __attribute__ ((bitwidth(406))) uint406; typedef unsigned int __attribute__ ((bitwidth(407))) uint407; typedef unsigned int __attribute__ ((bitwidth(408))) uint408; typedef unsigned int __attribute__ ((bitwidth(409))) uint409; typedef unsigned int __attribute__ ((bitwidth(410))) uint410; typedef unsigned int __attribute__ ((bitwidth(411))) uint411; typedef unsigned int __attribute__ ((bitwidth(412))) uint412; typedef unsigned int __attribute__ ((bitwidth(413))) uint413; typedef unsigned int __attribute__ ((bitwidth(414))) uint414; typedef unsigned int __attribute__ ((bitwidth(415))) uint415; typedef unsigned int __attribute__ ((bitwidth(416))) uint416; typedef unsigned int __attribute__ ((bitwidth(417))) uint417; typedef unsigned int __attribute__ ((bitwidth(418))) uint418; typedef unsigned int __attribute__ ((bitwidth(419))) uint419; typedef unsigned int __attribute__ ((bitwidth(420))) uint420; typedef unsigned int __attribute__ ((bitwidth(421))) uint421; typedef unsigned int __attribute__ ((bitwidth(422))) uint422; typedef unsigned int __attribute__ ((bitwidth(423))) uint423; typedef unsigned int __attribute__ ((bitwidth(424))) uint424; typedef unsigned int __attribute__ ((bitwidth(425))) uint425; typedef unsigned int __attribute__ ((bitwidth(426))) uint426; typedef unsigned int __attribute__ ((bitwidth(427))) uint427; typedef unsigned int __attribute__ ((bitwidth(428))) uint428; typedef unsigned int __attribute__ ((bitwidth(429))) uint429; typedef unsigned int __attribute__ ((bitwidth(430))) uint430; typedef unsigned int __attribute__ ((bitwidth(431))) uint431; typedef unsigned int __attribute__ ((bitwidth(432))) uint432; typedef unsigned int __attribute__ ((bitwidth(433))) uint433; typedef unsigned int __attribute__ ((bitwidth(434))) uint434; typedef unsigned int __attribute__ ((bitwidth(435))) uint435; typedef unsigned int __attribute__ ((bitwidth(436))) uint436; typedef unsigned int __attribute__ ((bitwidth(437))) uint437; typedef unsigned int __attribute__ ((bitwidth(438))) uint438; typedef unsigned int __attribute__ ((bitwidth(439))) uint439; typedef unsigned int __attribute__ ((bitwidth(440))) uint440; typedef unsigned int __attribute__ ((bitwidth(441))) uint441; typedef unsigned int __attribute__ ((bitwidth(442))) uint442; typedef unsigned int __attribute__ ((bitwidth(443))) uint443; typedef unsigned int __attribute__ ((bitwidth(444))) uint444; typedef unsigned int __attribute__ ((bitwidth(445))) uint445; typedef unsigned int __attribute__ ((bitwidth(446))) uint446; typedef unsigned int __attribute__ ((bitwidth(447))) uint447; typedef unsigned int __attribute__ ((bitwidth(448))) uint448; typedef unsigned int __attribute__ ((bitwidth(449))) uint449; typedef unsigned int __attribute__ ((bitwidth(450))) uint450; typedef unsigned int __attribute__ ((bitwidth(451))) uint451; typedef unsigned int __attribute__ ((bitwidth(452))) uint452; typedef unsigned int __attribute__ ((bitwidth(453))) uint453; typedef unsigned int __attribute__ ((bitwidth(454))) uint454; typedef unsigned int __attribute__ ((bitwidth(455))) uint455; typedef unsigned int __attribute__ ((bitwidth(456))) uint456; typedef unsigned int __attribute__ ((bitwidth(457))) uint457; typedef unsigned int __attribute__ ((bitwidth(458))) uint458; typedef unsigned int __attribute__ ((bitwidth(459))) uint459; typedef unsigned int __attribute__ ((bitwidth(460))) uint460; typedef unsigned int __attribute__ ((bitwidth(461))) uint461; typedef unsigned int __attribute__ ((bitwidth(462))) uint462; typedef unsigned int __attribute__ ((bitwidth(463))) uint463; typedef unsigned int __attribute__ ((bitwidth(464))) uint464; typedef unsigned int __attribute__ ((bitwidth(465))) uint465; typedef unsigned int __attribute__ ((bitwidth(466))) uint466; typedef unsigned int __attribute__ ((bitwidth(467))) uint467; typedef unsigned int __attribute__ ((bitwidth(468))) uint468; typedef unsigned int __attribute__ ((bitwidth(469))) uint469; typedef unsigned int __attribute__ ((bitwidth(470))) uint470; typedef unsigned int __attribute__ ((bitwidth(471))) uint471; typedef unsigned int __attribute__ ((bitwidth(472))) uint472; typedef unsigned int __attribute__ ((bitwidth(473))) uint473; typedef unsigned int __attribute__ ((bitwidth(474))) uint474; typedef unsigned int __attribute__ ((bitwidth(475))) uint475; typedef unsigned int __attribute__ ((bitwidth(476))) uint476; typedef unsigned int __attribute__ ((bitwidth(477))) uint477; typedef unsigned int __attribute__ ((bitwidth(478))) uint478; typedef unsigned int __attribute__ ((bitwidth(479))) uint479; typedef unsigned int __attribute__ ((bitwidth(480))) uint480; typedef unsigned int __attribute__ ((bitwidth(481))) uint481; typedef unsigned int __attribute__ ((bitwidth(482))) uint482; typedef unsigned int __attribute__ ((bitwidth(483))) uint483; typedef unsigned int __attribute__ ((bitwidth(484))) uint484; typedef unsigned int __attribute__ ((bitwidth(485))) uint485; typedef unsigned int __attribute__ ((bitwidth(486))) uint486; typedef unsigned int __attribute__ ((bitwidth(487))) uint487; typedef unsigned int __attribute__ ((bitwidth(488))) uint488; typedef unsigned int __attribute__ ((bitwidth(489))) uint489; typedef unsigned int __attribute__ ((bitwidth(490))) uint490; typedef unsigned int __attribute__ ((bitwidth(491))) uint491; typedef unsigned int __attribute__ ((bitwidth(492))) uint492; typedef unsigned int __attribute__ ((bitwidth(493))) uint493; typedef unsigned int __attribute__ ((bitwidth(494))) uint494; typedef unsigned int __attribute__ ((bitwidth(495))) uint495; typedef unsigned int __attribute__ ((bitwidth(496))) uint496; typedef unsigned int __attribute__ ((bitwidth(497))) uint497; typedef unsigned int __attribute__ ((bitwidth(498))) uint498; typedef unsigned int __attribute__ ((bitwidth(499))) uint499; typedef unsigned int __attribute__ ((bitwidth(500))) uint500; typedef unsigned int __attribute__ ((bitwidth(501))) uint501; typedef unsigned int __attribute__ ((bitwidth(502))) uint502; typedef unsigned int __attribute__ ((bitwidth(503))) uint503; typedef unsigned int __attribute__ ((bitwidth(504))) uint504; typedef unsigned int __attribute__ ((bitwidth(505))) uint505; typedef unsigned int __attribute__ ((bitwidth(506))) uint506; typedef unsigned int __attribute__ ((bitwidth(507))) uint507; typedef unsigned int __attribute__ ((bitwidth(508))) uint508; typedef unsigned int __attribute__ ((bitwidth(509))) uint509; typedef unsigned int __attribute__ ((bitwidth(510))) uint510; typedef unsigned int __attribute__ ((bitwidth(511))) uint511; typedef unsigned int __attribute__ ((bitwidth(512))) uint512; typedef unsigned int __attribute__ ((bitwidth(513))) uint513; typedef unsigned int __attribute__ ((bitwidth(514))) uint514; typedef unsigned int __attribute__ ((bitwidth(515))) uint515; typedef unsigned int __attribute__ ((bitwidth(516))) uint516; typedef unsigned int __attribute__ ((bitwidth(517))) uint517; typedef unsigned int __attribute__ ((bitwidth(518))) uint518; typedef unsigned int __attribute__ ((bitwidth(519))) uint519; typedef unsigned int __attribute__ ((bitwidth(520))) uint520; typedef unsigned int __attribute__ ((bitwidth(521))) uint521; typedef unsigned int __attribute__ ((bitwidth(522))) uint522; typedef unsigned int __attribute__ ((bitwidth(523))) uint523; typedef unsigned int __attribute__ ((bitwidth(524))) uint524; typedef unsigned int __attribute__ ((bitwidth(525))) uint525; typedef unsigned int __attribute__ ((bitwidth(526))) uint526; typedef unsigned int __attribute__ ((bitwidth(527))) uint527; typedef unsigned int __attribute__ ((bitwidth(528))) uint528; typedef unsigned int __attribute__ ((bitwidth(529))) uint529; typedef unsigned int __attribute__ ((bitwidth(530))) uint530; typedef unsigned int __attribute__ ((bitwidth(531))) uint531; typedef unsigned int __attribute__ ((bitwidth(532))) uint532; typedef unsigned int __attribute__ ((bitwidth(533))) uint533; typedef unsigned int __attribute__ ((bitwidth(534))) uint534; typedef unsigned int __attribute__ ((bitwidth(535))) uint535; typedef unsigned int __attribute__ ((bitwidth(536))) uint536; typedef unsigned int __attribute__ ((bitwidth(537))) uint537; typedef unsigned int __attribute__ ((bitwidth(538))) uint538; typedef unsigned int __attribute__ ((bitwidth(539))) uint539; typedef unsigned int __attribute__ ((bitwidth(540))) uint540; typedef unsigned int __attribute__ ((bitwidth(541))) uint541; typedef unsigned int __attribute__ ((bitwidth(542))) uint542; typedef unsigned int __attribute__ ((bitwidth(543))) uint543; typedef unsigned int __attribute__ ((bitwidth(544))) uint544; typedef unsigned int __attribute__ ((bitwidth(545))) uint545; typedef unsigned int __attribute__ ((bitwidth(546))) uint546; typedef unsigned int __attribute__ ((bitwidth(547))) uint547; typedef unsigned int __attribute__ ((bitwidth(548))) uint548; typedef unsigned int __attribute__ ((bitwidth(549))) uint549; typedef unsigned int __attribute__ ((bitwidth(550))) uint550; typedef unsigned int __attribute__ ((bitwidth(551))) uint551; typedef unsigned int __attribute__ ((bitwidth(552))) uint552; typedef unsigned int __attribute__ ((bitwidth(553))) uint553; typedef unsigned int __attribute__ ((bitwidth(554))) uint554; typedef unsigned int __attribute__ ((bitwidth(555))) uint555; typedef unsigned int __attribute__ ((bitwidth(556))) uint556; typedef unsigned int __attribute__ ((bitwidth(557))) uint557; typedef unsigned int __attribute__ ((bitwidth(558))) uint558; typedef unsigned int __attribute__ ((bitwidth(559))) uint559; typedef unsigned int __attribute__ ((bitwidth(560))) uint560; typedef unsigned int __attribute__ ((bitwidth(561))) uint561; typedef unsigned int __attribute__ ((bitwidth(562))) uint562; typedef unsigned int __attribute__ ((bitwidth(563))) uint563; typedef unsigned int __attribute__ ((bitwidth(564))) uint564; typedef unsigned int __attribute__ ((bitwidth(565))) uint565; typedef unsigned int __attribute__ ((bitwidth(566))) uint566; typedef unsigned int __attribute__ ((bitwidth(567))) uint567; typedef unsigned int __attribute__ ((bitwidth(568))) uint568; typedef unsigned int __attribute__ ((bitwidth(569))) uint569; typedef unsigned int __attribute__ ((bitwidth(570))) uint570; typedef unsigned int __attribute__ ((bitwidth(571))) uint571; typedef unsigned int __attribute__ ((bitwidth(572))) uint572; typedef unsigned int __attribute__ ((bitwidth(573))) uint573; typedef unsigned int __attribute__ ((bitwidth(574))) uint574; typedef unsigned int __attribute__ ((bitwidth(575))) uint575; typedef unsigned int __attribute__ ((bitwidth(576))) uint576; typedef unsigned int __attribute__ ((bitwidth(577))) uint577; typedef unsigned int __attribute__ ((bitwidth(578))) uint578; typedef unsigned int __attribute__ ((bitwidth(579))) uint579; typedef unsigned int __attribute__ ((bitwidth(580))) uint580; typedef unsigned int __attribute__ ((bitwidth(581))) uint581; typedef unsigned int __attribute__ ((bitwidth(582))) uint582; typedef unsigned int __attribute__ ((bitwidth(583))) uint583; typedef unsigned int __attribute__ ((bitwidth(584))) uint584; typedef unsigned int __attribute__ ((bitwidth(585))) uint585; typedef unsigned int __attribute__ ((bitwidth(586))) uint586; typedef unsigned int __attribute__ ((bitwidth(587))) uint587; typedef unsigned int __attribute__ ((bitwidth(588))) uint588; typedef unsigned int __attribute__ ((bitwidth(589))) uint589; typedef unsigned int __attribute__ ((bitwidth(590))) uint590; typedef unsigned int __attribute__ ((bitwidth(591))) uint591; typedef unsigned int __attribute__ ((bitwidth(592))) uint592; typedef unsigned int __attribute__ ((bitwidth(593))) uint593; typedef unsigned int __attribute__ ((bitwidth(594))) uint594; typedef unsigned int __attribute__ ((bitwidth(595))) uint595; typedef unsigned int __attribute__ ((bitwidth(596))) uint596; typedef unsigned int __attribute__ ((bitwidth(597))) uint597; typedef unsigned int __attribute__ ((bitwidth(598))) uint598; typedef unsigned int __attribute__ ((bitwidth(599))) uint599; typedef unsigned int __attribute__ ((bitwidth(600))) uint600; typedef unsigned int __attribute__ ((bitwidth(601))) uint601; typedef unsigned int __attribute__ ((bitwidth(602))) uint602; typedef unsigned int __attribute__ ((bitwidth(603))) uint603; typedef unsigned int __attribute__ ((bitwidth(604))) uint604; typedef unsigned int __attribute__ ((bitwidth(605))) uint605; typedef unsigned int __attribute__ ((bitwidth(606))) uint606; typedef unsigned int __attribute__ ((bitwidth(607))) uint607; typedef unsigned int __attribute__ ((bitwidth(608))) uint608; typedef unsigned int __attribute__ ((bitwidth(609))) uint609; typedef unsigned int __attribute__ ((bitwidth(610))) uint610; typedef unsigned int __attribute__ ((bitwidth(611))) uint611; typedef unsigned int __attribute__ ((bitwidth(612))) uint612; typedef unsigned int __attribute__ ((bitwidth(613))) uint613; typedef unsigned int __attribute__ ((bitwidth(614))) uint614; typedef unsigned int __attribute__ ((bitwidth(615))) uint615; typedef unsigned int __attribute__ ((bitwidth(616))) uint616; typedef unsigned int __attribute__ ((bitwidth(617))) uint617; typedef unsigned int __attribute__ ((bitwidth(618))) uint618; typedef unsigned int __attribute__ ((bitwidth(619))) uint619; typedef unsigned int __attribute__ ((bitwidth(620))) uint620; typedef unsigned int __attribute__ ((bitwidth(621))) uint621; typedef unsigned int __attribute__ ((bitwidth(622))) uint622; typedef unsigned int __attribute__ ((bitwidth(623))) uint623; typedef unsigned int __attribute__ ((bitwidth(624))) uint624; typedef unsigned int __attribute__ ((bitwidth(625))) uint625; typedef unsigned int __attribute__ ((bitwidth(626))) uint626; typedef unsigned int __attribute__ ((bitwidth(627))) uint627; typedef unsigned int __attribute__ ((bitwidth(628))) uint628; typedef unsigned int __attribute__ ((bitwidth(629))) uint629; typedef unsigned int __attribute__ ((bitwidth(630))) uint630; typedef unsigned int __attribute__ ((bitwidth(631))) uint631; typedef unsigned int __attribute__ ((bitwidth(632))) uint632; typedef unsigned int __attribute__ ((bitwidth(633))) uint633; typedef unsigned int __attribute__ ((bitwidth(634))) uint634; typedef unsigned int __attribute__ ((bitwidth(635))) uint635; typedef unsigned int __attribute__ ((bitwidth(636))) uint636; typedef unsigned int __attribute__ ((bitwidth(637))) uint637; typedef unsigned int __attribute__ ((bitwidth(638))) uint638; typedef unsigned int __attribute__ ((bitwidth(639))) uint639; typedef unsigned int __attribute__ ((bitwidth(640))) uint640; typedef unsigned int __attribute__ ((bitwidth(641))) uint641; typedef unsigned int __attribute__ ((bitwidth(642))) uint642; typedef unsigned int __attribute__ ((bitwidth(643))) uint643; typedef unsigned int __attribute__ ((bitwidth(644))) uint644; typedef unsigned int __attribute__ ((bitwidth(645))) uint645; typedef unsigned int __attribute__ ((bitwidth(646))) uint646; typedef unsigned int __attribute__ ((bitwidth(647))) uint647; typedef unsigned int __attribute__ ((bitwidth(648))) uint648; typedef unsigned int __attribute__ ((bitwidth(649))) uint649; typedef unsigned int __attribute__ ((bitwidth(650))) uint650; typedef unsigned int __attribute__ ((bitwidth(651))) uint651; typedef unsigned int __attribute__ ((bitwidth(652))) uint652; typedef unsigned int __attribute__ ((bitwidth(653))) uint653; typedef unsigned int __attribute__ ((bitwidth(654))) uint654; typedef unsigned int __attribute__ ((bitwidth(655))) uint655; typedef unsigned int __attribute__ ((bitwidth(656))) uint656; typedef unsigned int __attribute__ ((bitwidth(657))) uint657; typedef unsigned int __attribute__ ((bitwidth(658))) uint658; typedef unsigned int __attribute__ ((bitwidth(659))) uint659; typedef unsigned int __attribute__ ((bitwidth(660))) uint660; typedef unsigned int __attribute__ ((bitwidth(661))) uint661; typedef unsigned int __attribute__ ((bitwidth(662))) uint662; typedef unsigned int __attribute__ ((bitwidth(663))) uint663; typedef unsigned int __attribute__ ((bitwidth(664))) uint664; typedef unsigned int __attribute__ ((bitwidth(665))) uint665; typedef unsigned int __attribute__ ((bitwidth(666))) uint666; typedef unsigned int __attribute__ ((bitwidth(667))) uint667; typedef unsigned int __attribute__ ((bitwidth(668))) uint668; typedef unsigned int __attribute__ ((bitwidth(669))) uint669; typedef unsigned int __attribute__ ((bitwidth(670))) uint670; typedef unsigned int __attribute__ ((bitwidth(671))) uint671; typedef unsigned int __attribute__ ((bitwidth(672))) uint672; typedef unsigned int __attribute__ ((bitwidth(673))) uint673; typedef unsigned int __attribute__ ((bitwidth(674))) uint674; typedef unsigned int __attribute__ ((bitwidth(675))) uint675; typedef unsigned int __attribute__ ((bitwidth(676))) uint676; typedef unsigned int __attribute__ ((bitwidth(677))) uint677; typedef unsigned int __attribute__ ((bitwidth(678))) uint678; typedef unsigned int __attribute__ ((bitwidth(679))) uint679; typedef unsigned int __attribute__ ((bitwidth(680))) uint680; typedef unsigned int __attribute__ ((bitwidth(681))) uint681; typedef unsigned int __attribute__ ((bitwidth(682))) uint682; typedef unsigned int __attribute__ ((bitwidth(683))) uint683; typedef unsigned int __attribute__ ((bitwidth(684))) uint684; typedef unsigned int __attribute__ ((bitwidth(685))) uint685; typedef unsigned int __attribute__ ((bitwidth(686))) uint686; typedef unsigned int __attribute__ ((bitwidth(687))) uint687; typedef unsigned int __attribute__ ((bitwidth(688))) uint688; typedef unsigned int __attribute__ ((bitwidth(689))) uint689; typedef unsigned int __attribute__ ((bitwidth(690))) uint690; typedef unsigned int __attribute__ ((bitwidth(691))) uint691; typedef unsigned int __attribute__ ((bitwidth(692))) uint692; typedef unsigned int __attribute__ ((bitwidth(693))) uint693; typedef unsigned int __attribute__ ((bitwidth(694))) uint694; typedef unsigned int __attribute__ ((bitwidth(695))) uint695; typedef unsigned int __attribute__ ((bitwidth(696))) uint696; typedef unsigned int __attribute__ ((bitwidth(697))) uint697; typedef unsigned int __attribute__ ((bitwidth(698))) uint698; typedef unsigned int __attribute__ ((bitwidth(699))) uint699; typedef unsigned int __attribute__ ((bitwidth(700))) uint700; typedef unsigned int __attribute__ ((bitwidth(701))) uint701; typedef unsigned int __attribute__ ((bitwidth(702))) uint702; typedef unsigned int __attribute__ ((bitwidth(703))) uint703; typedef unsigned int __attribute__ ((bitwidth(704))) uint704; typedef unsigned int __attribute__ ((bitwidth(705))) uint705; typedef unsigned int __attribute__ ((bitwidth(706))) uint706; typedef unsigned int __attribute__ ((bitwidth(707))) uint707; typedef unsigned int __attribute__ ((bitwidth(708))) uint708; typedef unsigned int __attribute__ ((bitwidth(709))) uint709; typedef unsigned int __attribute__ ((bitwidth(710))) uint710; typedef unsigned int __attribute__ ((bitwidth(711))) uint711; typedef unsigned int __attribute__ ((bitwidth(712))) uint712; typedef unsigned int __attribute__ ((bitwidth(713))) uint713; typedef unsigned int __attribute__ ((bitwidth(714))) uint714; typedef unsigned int __attribute__ ((bitwidth(715))) uint715; typedef unsigned int __attribute__ ((bitwidth(716))) uint716; typedef unsigned int __attribute__ ((bitwidth(717))) uint717; typedef unsigned int __attribute__ ((bitwidth(718))) uint718; typedef unsigned int __attribute__ ((bitwidth(719))) uint719; typedef unsigned int __attribute__ ((bitwidth(720))) uint720; typedef unsigned int __attribute__ ((bitwidth(721))) uint721; typedef unsigned int __attribute__ ((bitwidth(722))) uint722; typedef unsigned int __attribute__ ((bitwidth(723))) uint723; typedef unsigned int __attribute__ ((bitwidth(724))) uint724; typedef unsigned int __attribute__ ((bitwidth(725))) uint725; typedef unsigned int __attribute__ ((bitwidth(726))) uint726; typedef unsigned int __attribute__ ((bitwidth(727))) uint727; typedef unsigned int __attribute__ ((bitwidth(728))) uint728; typedef unsigned int __attribute__ ((bitwidth(729))) uint729; typedef unsigned int __attribute__ ((bitwidth(730))) uint730; typedef unsigned int __attribute__ ((bitwidth(731))) uint731; typedef unsigned int __attribute__ ((bitwidth(732))) uint732; typedef unsigned int __attribute__ ((bitwidth(733))) uint733; typedef unsigned int __attribute__ ((bitwidth(734))) uint734; typedef unsigned int __attribute__ ((bitwidth(735))) uint735; typedef unsigned int __attribute__ ((bitwidth(736))) uint736; typedef unsigned int __attribute__ ((bitwidth(737))) uint737; typedef unsigned int __attribute__ ((bitwidth(738))) uint738; typedef unsigned int __attribute__ ((bitwidth(739))) uint739; typedef unsigned int __attribute__ ((bitwidth(740))) uint740; typedef unsigned int __attribute__ ((bitwidth(741))) uint741; typedef unsigned int __attribute__ ((bitwidth(742))) uint742; typedef unsigned int __attribute__ ((bitwidth(743))) uint743; typedef unsigned int __attribute__ ((bitwidth(744))) uint744; typedef unsigned int __attribute__ ((bitwidth(745))) uint745; typedef unsigned int __attribute__ ((bitwidth(746))) uint746; typedef unsigned int __attribute__ ((bitwidth(747))) uint747; typedef unsigned int __attribute__ ((bitwidth(748))) uint748; typedef unsigned int __attribute__ ((bitwidth(749))) uint749; typedef unsigned int __attribute__ ((bitwidth(750))) uint750; typedef unsigned int __attribute__ ((bitwidth(751))) uint751; typedef unsigned int __attribute__ ((bitwidth(752))) uint752; typedef unsigned int __attribute__ ((bitwidth(753))) uint753; typedef unsigned int __attribute__ ((bitwidth(754))) uint754; typedef unsigned int __attribute__ ((bitwidth(755))) uint755; typedef unsigned int __attribute__ ((bitwidth(756))) uint756; typedef unsigned int __attribute__ ((bitwidth(757))) uint757; typedef unsigned int __attribute__ ((bitwidth(758))) uint758; typedef unsigned int __attribute__ ((bitwidth(759))) uint759; typedef unsigned int __attribute__ ((bitwidth(760))) uint760; typedef unsigned int __attribute__ ((bitwidth(761))) uint761; typedef unsigned int __attribute__ ((bitwidth(762))) uint762; typedef unsigned int __attribute__ ((bitwidth(763))) uint763; typedef unsigned int __attribute__ ((bitwidth(764))) uint764; typedef unsigned int __attribute__ ((bitwidth(765))) uint765; typedef unsigned int __attribute__ ((bitwidth(766))) uint766; typedef unsigned int __attribute__ ((bitwidth(767))) uint767; typedef unsigned int __attribute__ ((bitwidth(768))) uint768; typedef unsigned int __attribute__ ((bitwidth(769))) uint769; typedef unsigned int __attribute__ ((bitwidth(770))) uint770; typedef unsigned int __attribute__ ((bitwidth(771))) uint771; typedef unsigned int __attribute__ ((bitwidth(772))) uint772; typedef unsigned int __attribute__ ((bitwidth(773))) uint773; typedef unsigned int __attribute__ ((bitwidth(774))) uint774; typedef unsigned int __attribute__ ((bitwidth(775))) uint775; typedef unsigned int __attribute__ ((bitwidth(776))) uint776; typedef unsigned int __attribute__ ((bitwidth(777))) uint777; typedef unsigned int __attribute__ ((bitwidth(778))) uint778; typedef unsigned int __attribute__ ((bitwidth(779))) uint779; typedef unsigned int __attribute__ ((bitwidth(780))) uint780; typedef unsigned int __attribute__ ((bitwidth(781))) uint781; typedef unsigned int __attribute__ ((bitwidth(782))) uint782; typedef unsigned int __attribute__ ((bitwidth(783))) uint783; typedef unsigned int __attribute__ ((bitwidth(784))) uint784; typedef unsigned int __attribute__ ((bitwidth(785))) uint785; typedef unsigned int __attribute__ ((bitwidth(786))) uint786; typedef unsigned int __attribute__ ((bitwidth(787))) uint787; typedef unsigned int __attribute__ ((bitwidth(788))) uint788; typedef unsigned int __attribute__ ((bitwidth(789))) uint789; typedef unsigned int __attribute__ ((bitwidth(790))) uint790; typedef unsigned int __attribute__ ((bitwidth(791))) uint791; typedef unsigned int __attribute__ ((bitwidth(792))) uint792; typedef unsigned int __attribute__ ((bitwidth(793))) uint793; typedef unsigned int __attribute__ ((bitwidth(794))) uint794; typedef unsigned int __attribute__ ((bitwidth(795))) uint795; typedef unsigned int __attribute__ ((bitwidth(796))) uint796; typedef unsigned int __attribute__ ((bitwidth(797))) uint797; typedef unsigned int __attribute__ ((bitwidth(798))) uint798; typedef unsigned int __attribute__ ((bitwidth(799))) uint799; typedef unsigned int __attribute__ ((bitwidth(800))) uint800; typedef unsigned int __attribute__ ((bitwidth(801))) uint801; typedef unsigned int __attribute__ ((bitwidth(802))) uint802; typedef unsigned int __attribute__ ((bitwidth(803))) uint803; typedef unsigned int __attribute__ ((bitwidth(804))) uint804; typedef unsigned int __attribute__ ((bitwidth(805))) uint805; typedef unsigned int __attribute__ ((bitwidth(806))) uint806; typedef unsigned int __attribute__ ((bitwidth(807))) uint807; typedef unsigned int __attribute__ ((bitwidth(808))) uint808; typedef unsigned int __attribute__ ((bitwidth(809))) uint809; typedef unsigned int __attribute__ ((bitwidth(810))) uint810; typedef unsigned int __attribute__ ((bitwidth(811))) uint811; typedef unsigned int __attribute__ ((bitwidth(812))) uint812; typedef unsigned int __attribute__ ((bitwidth(813))) uint813; typedef unsigned int __attribute__ ((bitwidth(814))) uint814; typedef unsigned int __attribute__ ((bitwidth(815))) uint815; typedef unsigned int __attribute__ ((bitwidth(816))) uint816; typedef unsigned int __attribute__ ((bitwidth(817))) uint817; typedef unsigned int __attribute__ ((bitwidth(818))) uint818; typedef unsigned int __attribute__ ((bitwidth(819))) uint819; typedef unsigned int __attribute__ ((bitwidth(820))) uint820; typedef unsigned int __attribute__ ((bitwidth(821))) uint821; typedef unsigned int __attribute__ ((bitwidth(822))) uint822; typedef unsigned int __attribute__ ((bitwidth(823))) uint823; typedef unsigned int __attribute__ ((bitwidth(824))) uint824; typedef unsigned int __attribute__ ((bitwidth(825))) uint825; typedef unsigned int __attribute__ ((bitwidth(826))) uint826; typedef unsigned int __attribute__ ((bitwidth(827))) uint827; typedef unsigned int __attribute__ ((bitwidth(828))) uint828; typedef unsigned int __attribute__ ((bitwidth(829))) uint829; typedef unsigned int __attribute__ ((bitwidth(830))) uint830; typedef unsigned int __attribute__ ((bitwidth(831))) uint831; typedef unsigned int __attribute__ ((bitwidth(832))) uint832; typedef unsigned int __attribute__ ((bitwidth(833))) uint833; typedef unsigned int __attribute__ ((bitwidth(834))) uint834; typedef unsigned int __attribute__ ((bitwidth(835))) uint835; typedef unsigned int __attribute__ ((bitwidth(836))) uint836; typedef unsigned int __attribute__ ((bitwidth(837))) uint837; typedef unsigned int __attribute__ ((bitwidth(838))) uint838; typedef unsigned int __attribute__ ((bitwidth(839))) uint839; typedef unsigned int __attribute__ ((bitwidth(840))) uint840; typedef unsigned int __attribute__ ((bitwidth(841))) uint841; typedef unsigned int __attribute__ ((bitwidth(842))) uint842; typedef unsigned int __attribute__ ((bitwidth(843))) uint843; typedef unsigned int __attribute__ ((bitwidth(844))) uint844; typedef unsigned int __attribute__ ((bitwidth(845))) uint845; typedef unsigned int __attribute__ ((bitwidth(846))) uint846; typedef unsigned int __attribute__ ((bitwidth(847))) uint847; typedef unsigned int __attribute__ ((bitwidth(848))) uint848; typedef unsigned int __attribute__ ((bitwidth(849))) uint849; typedef unsigned int __attribute__ ((bitwidth(850))) uint850; typedef unsigned int __attribute__ ((bitwidth(851))) uint851; typedef unsigned int __attribute__ ((bitwidth(852))) uint852; typedef unsigned int __attribute__ ((bitwidth(853))) uint853; typedef unsigned int __attribute__ ((bitwidth(854))) uint854; typedef unsigned int __attribute__ ((bitwidth(855))) uint855; typedef unsigned int __attribute__ ((bitwidth(856))) uint856; typedef unsigned int __attribute__ ((bitwidth(857))) uint857; typedef unsigned int __attribute__ ((bitwidth(858))) uint858; typedef unsigned int __attribute__ ((bitwidth(859))) uint859; typedef unsigned int __attribute__ ((bitwidth(860))) uint860; typedef unsigned int __attribute__ ((bitwidth(861))) uint861; typedef unsigned int __attribute__ ((bitwidth(862))) uint862; typedef unsigned int __attribute__ ((bitwidth(863))) uint863; typedef unsigned int __attribute__ ((bitwidth(864))) uint864; typedef unsigned int __attribute__ ((bitwidth(865))) uint865; typedef unsigned int __attribute__ ((bitwidth(866))) uint866; typedef unsigned int __attribute__ ((bitwidth(867))) uint867; typedef unsigned int __attribute__ ((bitwidth(868))) uint868; typedef unsigned int __attribute__ ((bitwidth(869))) uint869; typedef unsigned int __attribute__ ((bitwidth(870))) uint870; typedef unsigned int __attribute__ ((bitwidth(871))) uint871; typedef unsigned int __attribute__ ((bitwidth(872))) uint872; typedef unsigned int __attribute__ ((bitwidth(873))) uint873; typedef unsigned int __attribute__ ((bitwidth(874))) uint874; typedef unsigned int __attribute__ ((bitwidth(875))) uint875; typedef unsigned int __attribute__ ((bitwidth(876))) uint876; typedef unsigned int __attribute__ ((bitwidth(877))) uint877; typedef unsigned int __attribute__ ((bitwidth(878))) uint878; typedef unsigned int __attribute__ ((bitwidth(879))) uint879; typedef unsigned int __attribute__ ((bitwidth(880))) uint880; typedef unsigned int __attribute__ ((bitwidth(881))) uint881; typedef unsigned int __attribute__ ((bitwidth(882))) uint882; typedef unsigned int __attribute__ ((bitwidth(883))) uint883; typedef unsigned int __attribute__ ((bitwidth(884))) uint884; typedef unsigned int __attribute__ ((bitwidth(885))) uint885; typedef unsigned int __attribute__ ((bitwidth(886))) uint886; typedef unsigned int __attribute__ ((bitwidth(887))) uint887; typedef unsigned int __attribute__ ((bitwidth(888))) uint888; typedef unsigned int __attribute__ ((bitwidth(889))) uint889; typedef unsigned int __attribute__ ((bitwidth(890))) uint890; typedef unsigned int __attribute__ ((bitwidth(891))) uint891; typedef unsigned int __attribute__ ((bitwidth(892))) uint892; typedef unsigned int __attribute__ ((bitwidth(893))) uint893; typedef unsigned int __attribute__ ((bitwidth(894))) uint894; typedef unsigned int __attribute__ ((bitwidth(895))) uint895; typedef unsigned int __attribute__ ((bitwidth(896))) uint896; typedef unsigned int __attribute__ ((bitwidth(897))) uint897; typedef unsigned int __attribute__ ((bitwidth(898))) uint898; typedef unsigned int __attribute__ ((bitwidth(899))) uint899; typedef unsigned int __attribute__ ((bitwidth(900))) uint900; typedef unsigned int __attribute__ ((bitwidth(901))) uint901; typedef unsigned int __attribute__ ((bitwidth(902))) uint902; typedef unsigned int __attribute__ ((bitwidth(903))) uint903; typedef unsigned int __attribute__ ((bitwidth(904))) uint904; typedef unsigned int __attribute__ ((bitwidth(905))) uint905; typedef unsigned int __attribute__ ((bitwidth(906))) uint906; typedef unsigned int __attribute__ ((bitwidth(907))) uint907; typedef unsigned int __attribute__ ((bitwidth(908))) uint908; typedef unsigned int __attribute__ ((bitwidth(909))) uint909; typedef unsigned int __attribute__ ((bitwidth(910))) uint910; typedef unsigned int __attribute__ ((bitwidth(911))) uint911; typedef unsigned int __attribute__ ((bitwidth(912))) uint912; typedef unsigned int __attribute__ ((bitwidth(913))) uint913; typedef unsigned int __attribute__ ((bitwidth(914))) uint914; typedef unsigned int __attribute__ ((bitwidth(915))) uint915; typedef unsigned int __attribute__ ((bitwidth(916))) uint916; typedef unsigned int __attribute__ ((bitwidth(917))) uint917; typedef unsigned int __attribute__ ((bitwidth(918))) uint918; typedef unsigned int __attribute__ ((bitwidth(919))) uint919; typedef unsigned int __attribute__ ((bitwidth(920))) uint920; typedef unsigned int __attribute__ ((bitwidth(921))) uint921; typedef unsigned int __attribute__ ((bitwidth(922))) uint922; typedef unsigned int __attribute__ ((bitwidth(923))) uint923; typedef unsigned int __attribute__ ((bitwidth(924))) uint924; typedef unsigned int __attribute__ ((bitwidth(925))) uint925; typedef unsigned int __attribute__ ((bitwidth(926))) uint926; typedef unsigned int __attribute__ ((bitwidth(927))) uint927; typedef unsigned int __attribute__ ((bitwidth(928))) uint928; typedef unsigned int __attribute__ ((bitwidth(929))) uint929; typedef unsigned int __attribute__ ((bitwidth(930))) uint930; typedef unsigned int __attribute__ ((bitwidth(931))) uint931; typedef unsigned int __attribute__ ((bitwidth(932))) uint932; typedef unsigned int __attribute__ ((bitwidth(933))) uint933; typedef unsigned int __attribute__ ((bitwidth(934))) uint934; typedef unsigned int __attribute__ ((bitwidth(935))) uint935; typedef unsigned int __attribute__ ((bitwidth(936))) uint936; typedef unsigned int __attribute__ ((bitwidth(937))) uint937; typedef unsigned int __attribute__ ((bitwidth(938))) uint938; typedef unsigned int __attribute__ ((bitwidth(939))) uint939; typedef unsigned int __attribute__ ((bitwidth(940))) uint940; typedef unsigned int __attribute__ ((bitwidth(941))) uint941; typedef unsigned int __attribute__ ((bitwidth(942))) uint942; typedef unsigned int __attribute__ ((bitwidth(943))) uint943; typedef unsigned int __attribute__ ((bitwidth(944))) uint944; typedef unsigned int __attribute__ ((bitwidth(945))) uint945; typedef unsigned int __attribute__ ((bitwidth(946))) uint946; typedef unsigned int __attribute__ ((bitwidth(947))) uint947; typedef unsigned int __attribute__ ((bitwidth(948))) uint948; typedef unsigned int __attribute__ ((bitwidth(949))) uint949; typedef unsigned int __attribute__ ((bitwidth(950))) uint950; typedef unsigned int __attribute__ ((bitwidth(951))) uint951; typedef unsigned int __attribute__ ((bitwidth(952))) uint952; typedef unsigned int __attribute__ ((bitwidth(953))) uint953; typedef unsigned int __attribute__ ((bitwidth(954))) uint954; typedef unsigned int __attribute__ ((bitwidth(955))) uint955; typedef unsigned int __attribute__ ((bitwidth(956))) uint956; typedef unsigned int __attribute__ ((bitwidth(957))) uint957; typedef unsigned int __attribute__ ((bitwidth(958))) uint958; typedef unsigned int __attribute__ ((bitwidth(959))) uint959; typedef unsigned int __attribute__ ((bitwidth(960))) uint960; typedef unsigned int __attribute__ ((bitwidth(961))) uint961; typedef unsigned int __attribute__ ((bitwidth(962))) uint962; typedef unsigned int __attribute__ ((bitwidth(963))) uint963; typedef unsigned int __attribute__ ((bitwidth(964))) uint964; typedef unsigned int __attribute__ ((bitwidth(965))) uint965; typedef unsigned int __attribute__ ((bitwidth(966))) uint966; typedef unsigned int __attribute__ ((bitwidth(967))) uint967; typedef unsigned int __attribute__ ((bitwidth(968))) uint968; typedef unsigned int __attribute__ ((bitwidth(969))) uint969; typedef unsigned int __attribute__ ((bitwidth(970))) uint970; typedef unsigned int __attribute__ ((bitwidth(971))) uint971; typedef unsigned int __attribute__ ((bitwidth(972))) uint972; typedef unsigned int __attribute__ ((bitwidth(973))) uint973; typedef unsigned int __attribute__ ((bitwidth(974))) uint974; typedef unsigned int __attribute__ ((bitwidth(975))) uint975; typedef unsigned int __attribute__ ((bitwidth(976))) uint976; typedef unsigned int __attribute__ ((bitwidth(977))) uint977; typedef unsigned int __attribute__ ((bitwidth(978))) uint978; typedef unsigned int __attribute__ ((bitwidth(979))) uint979; typedef unsigned int __attribute__ ((bitwidth(980))) uint980; typedef unsigned int __attribute__ ((bitwidth(981))) uint981; typedef unsigned int __attribute__ ((bitwidth(982))) uint982; typedef unsigned int __attribute__ ((bitwidth(983))) uint983; typedef unsigned int __attribute__ ((bitwidth(984))) uint984; typedef unsigned int __attribute__ ((bitwidth(985))) uint985; typedef unsigned int __attribute__ ((bitwidth(986))) uint986; typedef unsigned int __attribute__ ((bitwidth(987))) uint987; typedef unsigned int __attribute__ ((bitwidth(988))) uint988; typedef unsigned int __attribute__ ((bitwidth(989))) uint989; typedef unsigned int __attribute__ ((bitwidth(990))) uint990; typedef unsigned int __attribute__ ((bitwidth(991))) uint991; typedef unsigned int __attribute__ ((bitwidth(992))) uint992; typedef unsigned int __attribute__ ((bitwidth(993))) uint993; typedef unsigned int __attribute__ ((bitwidth(994))) uint994; typedef unsigned int __attribute__ ((bitwidth(995))) uint995; typedef unsigned int __attribute__ ((bitwidth(996))) uint996; typedef unsigned int __attribute__ ((bitwidth(997))) uint997; typedef unsigned int __attribute__ ((bitwidth(998))) uint998; typedef unsigned int __attribute__ ((bitwidth(999))) uint999; typedef unsigned int __attribute__ ((bitwidth(1000))) uint1000; typedef unsigned int __attribute__ ((bitwidth(1001))) uint1001; typedef unsigned int __attribute__ ((bitwidth(1002))) uint1002; typedef unsigned int __attribute__ ((bitwidth(1003))) uint1003; typedef unsigned int __attribute__ ((bitwidth(1004))) uint1004; typedef unsigned int __attribute__ ((bitwidth(1005))) uint1005; typedef unsigned int __attribute__ ((bitwidth(1006))) uint1006; typedef unsigned int __attribute__ ((bitwidth(1007))) uint1007; typedef unsigned int __attribute__ ((bitwidth(1008))) uint1008; typedef unsigned int __attribute__ ((bitwidth(1009))) uint1009; typedef unsigned int __attribute__ ((bitwidth(1010))) uint1010; typedef unsigned int __attribute__ ((bitwidth(1011))) uint1011; typedef unsigned int __attribute__ ((bitwidth(1012))) uint1012; typedef unsigned int __attribute__ ((bitwidth(1013))) uint1013; typedef unsigned int __attribute__ ((bitwidth(1014))) uint1014; typedef unsigned int __attribute__ ((bitwidth(1015))) uint1015; typedef unsigned int __attribute__ ((bitwidth(1016))) uint1016; typedef unsigned int __attribute__ ((bitwidth(1017))) uint1017; typedef unsigned int __attribute__ ((bitwidth(1018))) uint1018; typedef unsigned int __attribute__ ((bitwidth(1019))) uint1019; typedef unsigned int __attribute__ ((bitwidth(1020))) uint1020; typedef unsigned int __attribute__ ((bitwidth(1021))) uint1021; typedef unsigned int __attribute__ ((bitwidth(1022))) uint1022; typedef unsigned int __attribute__ ((bitwidth(1023))) uint1023; typedef unsigned int __attribute__ ((bitwidth(1024))) uint1024; #pragma line 109 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt_ext.def" 1 #pragma empty_line #pragma empty_line typedef unsigned int __attribute__ ((bitwidth(1025))) uint1025; typedef unsigned int __attribute__ ((bitwidth(1026))) uint1026; typedef unsigned int __attribute__ ((bitwidth(1027))) uint1027; typedef unsigned int __attribute__ ((bitwidth(1028))) uint1028; typedef unsigned int __attribute__ ((bitwidth(1029))) uint1029; typedef unsigned int __attribute__ ((bitwidth(1030))) uint1030; typedef unsigned int __attribute__ ((bitwidth(1031))) uint1031; typedef unsigned int __attribute__ ((bitwidth(1032))) uint1032; typedef unsigned int __attribute__ ((bitwidth(1033))) uint1033; typedef unsigned int __attribute__ ((bitwidth(1034))) uint1034; typedef unsigned int __attribute__ ((bitwidth(1035))) uint1035; typedef unsigned int __attribute__ ((bitwidth(1036))) uint1036; typedef unsigned int __attribute__ ((bitwidth(1037))) uint1037; typedef unsigned int __attribute__ ((bitwidth(1038))) uint1038; typedef unsigned int __attribute__ ((bitwidth(1039))) uint1039; typedef unsigned int __attribute__ ((bitwidth(1040))) uint1040; typedef unsigned int __attribute__ ((bitwidth(1041))) uint1041; typedef unsigned int __attribute__ ((bitwidth(1042))) uint1042; typedef unsigned int __attribute__ ((bitwidth(1043))) uint1043; typedef unsigned int __attribute__ ((bitwidth(1044))) uint1044; typedef unsigned int __attribute__ ((bitwidth(1045))) uint1045; typedef unsigned int __attribute__ ((bitwidth(1046))) uint1046; typedef unsigned int __attribute__ ((bitwidth(1047))) uint1047; typedef unsigned int __attribute__ ((bitwidth(1048))) uint1048; typedef unsigned int __attribute__ ((bitwidth(1049))) uint1049; typedef unsigned int __attribute__ ((bitwidth(1050))) uint1050; typedef unsigned int __attribute__ ((bitwidth(1051))) uint1051; typedef unsigned int __attribute__ ((bitwidth(1052))) uint1052; typedef unsigned int __attribute__ ((bitwidth(1053))) uint1053; typedef unsigned int __attribute__ ((bitwidth(1054))) uint1054; typedef unsigned int __attribute__ ((bitwidth(1055))) uint1055; typedef unsigned int __attribute__ ((bitwidth(1056))) uint1056; typedef unsigned int __attribute__ ((bitwidth(1057))) uint1057; typedef unsigned int __attribute__ ((bitwidth(1058))) uint1058; typedef unsigned int __attribute__ ((bitwidth(1059))) uint1059; typedef unsigned int __attribute__ ((bitwidth(1060))) uint1060; typedef unsigned int __attribute__ ((bitwidth(1061))) uint1061; typedef unsigned int __attribute__ ((bitwidth(1062))) uint1062; typedef unsigned int __attribute__ ((bitwidth(1063))) uint1063; typedef unsigned int __attribute__ ((bitwidth(1064))) uint1064; typedef unsigned int __attribute__ ((bitwidth(1065))) uint1065; typedef unsigned int __attribute__ ((bitwidth(1066))) uint1066; typedef unsigned int __attribute__ ((bitwidth(1067))) uint1067; typedef unsigned int __attribute__ ((bitwidth(1068))) uint1068; typedef unsigned int __attribute__ ((bitwidth(1069))) uint1069; typedef unsigned int __attribute__ ((bitwidth(1070))) uint1070; typedef unsigned int __attribute__ ((bitwidth(1071))) uint1071; typedef unsigned int __attribute__ ((bitwidth(1072))) uint1072; typedef unsigned int __attribute__ ((bitwidth(1073))) uint1073; typedef unsigned int __attribute__ ((bitwidth(1074))) uint1074; typedef unsigned int __attribute__ ((bitwidth(1075))) uint1075; typedef unsigned int __attribute__ ((bitwidth(1076))) uint1076; typedef unsigned int __attribute__ ((bitwidth(1077))) uint1077; typedef unsigned int __attribute__ ((bitwidth(1078))) uint1078; typedef unsigned int __attribute__ ((bitwidth(1079))) uint1079; typedef unsigned int __attribute__ ((bitwidth(1080))) uint1080; typedef unsigned int __attribute__ ((bitwidth(1081))) uint1081; typedef unsigned int __attribute__ ((bitwidth(1082))) uint1082; typedef unsigned int __attribute__ ((bitwidth(1083))) uint1083; typedef unsigned int __attribute__ ((bitwidth(1084))) uint1084; typedef unsigned int __attribute__ ((bitwidth(1085))) uint1085; typedef unsigned int __attribute__ ((bitwidth(1086))) uint1086; typedef unsigned int __attribute__ ((bitwidth(1087))) uint1087; typedef unsigned int __attribute__ ((bitwidth(1088))) uint1088; typedef unsigned int __attribute__ ((bitwidth(1089))) uint1089; typedef unsigned int __attribute__ ((bitwidth(1090))) uint1090; typedef unsigned int __attribute__ ((bitwidth(1091))) uint1091; typedef unsigned int __attribute__ ((bitwidth(1092))) uint1092; typedef unsigned int __attribute__ ((bitwidth(1093))) uint1093; typedef unsigned int __attribute__ ((bitwidth(1094))) uint1094; typedef unsigned int __attribute__ ((bitwidth(1095))) uint1095; typedef unsigned int __attribute__ ((bitwidth(1096))) uint1096; typedef unsigned int __attribute__ ((bitwidth(1097))) uint1097; typedef unsigned int __attribute__ ((bitwidth(1098))) uint1098; typedef unsigned int __attribute__ ((bitwidth(1099))) uint1099; typedef unsigned int __attribute__ ((bitwidth(1100))) uint1100; typedef unsigned int __attribute__ ((bitwidth(1101))) uint1101; typedef unsigned int __attribute__ ((bitwidth(1102))) uint1102; typedef unsigned int __attribute__ ((bitwidth(1103))) uint1103; typedef unsigned int __attribute__ ((bitwidth(1104))) uint1104; typedef unsigned int __attribute__ ((bitwidth(1105))) uint1105; typedef unsigned int __attribute__ ((bitwidth(1106))) uint1106; typedef unsigned int __attribute__ ((bitwidth(1107))) uint1107; typedef unsigned int __attribute__ ((bitwidth(1108))) uint1108; typedef unsigned int __attribute__ ((bitwidth(1109))) uint1109; typedef unsigned int __attribute__ ((bitwidth(1110))) uint1110; typedef unsigned int __attribute__ ((bitwidth(1111))) uint1111; typedef unsigned int __attribute__ ((bitwidth(1112))) uint1112; typedef unsigned int __attribute__ ((bitwidth(1113))) uint1113; typedef unsigned int __attribute__ ((bitwidth(1114))) uint1114; typedef unsigned int __attribute__ ((bitwidth(1115))) uint1115; typedef unsigned int __attribute__ ((bitwidth(1116))) uint1116; typedef unsigned int __attribute__ ((bitwidth(1117))) uint1117; typedef unsigned int __attribute__ ((bitwidth(1118))) uint1118; typedef unsigned int __attribute__ ((bitwidth(1119))) uint1119; typedef unsigned int __attribute__ ((bitwidth(1120))) uint1120; typedef unsigned int __attribute__ ((bitwidth(1121))) uint1121; typedef unsigned int __attribute__ ((bitwidth(1122))) uint1122; typedef unsigned int __attribute__ ((bitwidth(1123))) uint1123; typedef unsigned int __attribute__ ((bitwidth(1124))) uint1124; typedef unsigned int __attribute__ ((bitwidth(1125))) uint1125; typedef unsigned int __attribute__ ((bitwidth(1126))) uint1126; typedef unsigned int __attribute__ ((bitwidth(1127))) uint1127; typedef unsigned int __attribute__ ((bitwidth(1128))) uint1128; typedef unsigned int __attribute__ ((bitwidth(1129))) uint1129; typedef unsigned int __attribute__ ((bitwidth(1130))) uint1130; typedef unsigned int __attribute__ ((bitwidth(1131))) uint1131; typedef unsigned int __attribute__ ((bitwidth(1132))) uint1132; typedef unsigned int __attribute__ ((bitwidth(1133))) uint1133; typedef unsigned int __attribute__ ((bitwidth(1134))) uint1134; typedef unsigned int __attribute__ ((bitwidth(1135))) uint1135; typedef unsigned int __attribute__ ((bitwidth(1136))) uint1136; typedef unsigned int __attribute__ ((bitwidth(1137))) uint1137; typedef unsigned int __attribute__ ((bitwidth(1138))) uint1138; typedef unsigned int __attribute__ ((bitwidth(1139))) uint1139; typedef unsigned int __attribute__ ((bitwidth(1140))) uint1140; typedef unsigned int __attribute__ ((bitwidth(1141))) uint1141; typedef unsigned int __attribute__ ((bitwidth(1142))) uint1142; typedef unsigned int __attribute__ ((bitwidth(1143))) uint1143; typedef unsigned int __attribute__ ((bitwidth(1144))) uint1144; typedef unsigned int __attribute__ ((bitwidth(1145))) uint1145; typedef unsigned int __attribute__ ((bitwidth(1146))) uint1146; typedef unsigned int __attribute__ ((bitwidth(1147))) uint1147; typedef unsigned int __attribute__ ((bitwidth(1148))) uint1148; typedef unsigned int __attribute__ ((bitwidth(1149))) uint1149; typedef unsigned int __attribute__ ((bitwidth(1150))) uint1150; typedef unsigned int __attribute__ ((bitwidth(1151))) uint1151; typedef unsigned int __attribute__ ((bitwidth(1152))) uint1152; typedef unsigned int __attribute__ ((bitwidth(1153))) uint1153; typedef unsigned int __attribute__ ((bitwidth(1154))) uint1154; typedef unsigned int __attribute__ ((bitwidth(1155))) uint1155; typedef unsigned int __attribute__ ((bitwidth(1156))) uint1156; typedef unsigned int __attribute__ ((bitwidth(1157))) uint1157; typedef unsigned int __attribute__ ((bitwidth(1158))) uint1158; typedef unsigned int __attribute__ ((bitwidth(1159))) uint1159; typedef unsigned int __attribute__ ((bitwidth(1160))) uint1160; typedef unsigned int __attribute__ ((bitwidth(1161))) uint1161; typedef unsigned int __attribute__ ((bitwidth(1162))) uint1162; typedef unsigned int __attribute__ ((bitwidth(1163))) uint1163; typedef unsigned int __attribute__ ((bitwidth(1164))) uint1164; typedef unsigned int __attribute__ ((bitwidth(1165))) uint1165; typedef unsigned int __attribute__ ((bitwidth(1166))) uint1166; typedef unsigned int __attribute__ ((bitwidth(1167))) uint1167; typedef unsigned int __attribute__ ((bitwidth(1168))) uint1168; typedef unsigned int __attribute__ ((bitwidth(1169))) uint1169; typedef unsigned int __attribute__ ((bitwidth(1170))) uint1170; typedef unsigned int __attribute__ ((bitwidth(1171))) uint1171; typedef unsigned int __attribute__ ((bitwidth(1172))) uint1172; typedef unsigned int __attribute__ ((bitwidth(1173))) uint1173; typedef unsigned int __attribute__ ((bitwidth(1174))) uint1174; typedef unsigned int __attribute__ ((bitwidth(1175))) uint1175; typedef unsigned int __attribute__ ((bitwidth(1176))) uint1176; typedef unsigned int __attribute__ ((bitwidth(1177))) uint1177; typedef unsigned int __attribute__ ((bitwidth(1178))) uint1178; typedef unsigned int __attribute__ ((bitwidth(1179))) uint1179; typedef unsigned int __attribute__ ((bitwidth(1180))) uint1180; typedef unsigned int __attribute__ ((bitwidth(1181))) uint1181; typedef unsigned int __attribute__ ((bitwidth(1182))) uint1182; typedef unsigned int __attribute__ ((bitwidth(1183))) uint1183; typedef unsigned int __attribute__ ((bitwidth(1184))) uint1184; typedef unsigned int __attribute__ ((bitwidth(1185))) uint1185; typedef unsigned int __attribute__ ((bitwidth(1186))) uint1186; typedef unsigned int __attribute__ ((bitwidth(1187))) uint1187; typedef unsigned int __attribute__ ((bitwidth(1188))) uint1188; typedef unsigned int __attribute__ ((bitwidth(1189))) uint1189; typedef unsigned int __attribute__ ((bitwidth(1190))) uint1190; typedef unsigned int __attribute__ ((bitwidth(1191))) uint1191; typedef unsigned int __attribute__ ((bitwidth(1192))) uint1192; typedef unsigned int __attribute__ ((bitwidth(1193))) uint1193; typedef unsigned int __attribute__ ((bitwidth(1194))) uint1194; typedef unsigned int __attribute__ ((bitwidth(1195))) uint1195; typedef unsigned int __attribute__ ((bitwidth(1196))) uint1196; typedef unsigned int __attribute__ ((bitwidth(1197))) uint1197; typedef unsigned int __attribute__ ((bitwidth(1198))) uint1198; typedef unsigned int __attribute__ ((bitwidth(1199))) uint1199; typedef unsigned int __attribute__ ((bitwidth(1200))) uint1200; typedef unsigned int __attribute__ ((bitwidth(1201))) uint1201; typedef unsigned int __attribute__ ((bitwidth(1202))) uint1202; typedef unsigned int __attribute__ ((bitwidth(1203))) uint1203; typedef unsigned int __attribute__ ((bitwidth(1204))) uint1204; typedef unsigned int __attribute__ ((bitwidth(1205))) uint1205; typedef unsigned int __attribute__ ((bitwidth(1206))) uint1206; typedef unsigned int __attribute__ ((bitwidth(1207))) uint1207; typedef unsigned int __attribute__ ((bitwidth(1208))) uint1208; typedef unsigned int __attribute__ ((bitwidth(1209))) uint1209; typedef unsigned int __attribute__ ((bitwidth(1210))) uint1210; typedef unsigned int __attribute__ ((bitwidth(1211))) uint1211; typedef unsigned int __attribute__ ((bitwidth(1212))) uint1212; typedef unsigned int __attribute__ ((bitwidth(1213))) uint1213; typedef unsigned int __attribute__ ((bitwidth(1214))) uint1214; typedef unsigned int __attribute__ ((bitwidth(1215))) uint1215; typedef unsigned int __attribute__ ((bitwidth(1216))) uint1216; typedef unsigned int __attribute__ ((bitwidth(1217))) uint1217; typedef unsigned int __attribute__ ((bitwidth(1218))) uint1218; typedef unsigned int __attribute__ ((bitwidth(1219))) uint1219; typedef unsigned int __attribute__ ((bitwidth(1220))) uint1220; typedef unsigned int __attribute__ ((bitwidth(1221))) uint1221; typedef unsigned int __attribute__ ((bitwidth(1222))) uint1222; typedef unsigned int __attribute__ ((bitwidth(1223))) uint1223; typedef unsigned int __attribute__ ((bitwidth(1224))) uint1224; typedef unsigned int __attribute__ ((bitwidth(1225))) uint1225; typedef unsigned int __attribute__ ((bitwidth(1226))) uint1226; typedef unsigned int __attribute__ ((bitwidth(1227))) uint1227; typedef unsigned int __attribute__ ((bitwidth(1228))) uint1228; typedef unsigned int __attribute__ ((bitwidth(1229))) uint1229; typedef unsigned int __attribute__ ((bitwidth(1230))) uint1230; typedef unsigned int __attribute__ ((bitwidth(1231))) uint1231; typedef unsigned int __attribute__ ((bitwidth(1232))) uint1232; typedef unsigned int __attribute__ ((bitwidth(1233))) uint1233; typedef unsigned int __attribute__ ((bitwidth(1234))) uint1234; typedef unsigned int __attribute__ ((bitwidth(1235))) uint1235; typedef unsigned int __attribute__ ((bitwidth(1236))) uint1236; typedef unsigned int __attribute__ ((bitwidth(1237))) uint1237; typedef unsigned int __attribute__ ((bitwidth(1238))) uint1238; typedef unsigned int __attribute__ ((bitwidth(1239))) uint1239; typedef unsigned int __attribute__ ((bitwidth(1240))) uint1240; typedef unsigned int __attribute__ ((bitwidth(1241))) uint1241; typedef unsigned int __attribute__ ((bitwidth(1242))) uint1242; typedef unsigned int __attribute__ ((bitwidth(1243))) uint1243; typedef unsigned int __attribute__ ((bitwidth(1244))) uint1244; typedef unsigned int __attribute__ ((bitwidth(1245))) uint1245; typedef unsigned int __attribute__ ((bitwidth(1246))) uint1246; typedef unsigned int __attribute__ ((bitwidth(1247))) uint1247; typedef unsigned int __attribute__ ((bitwidth(1248))) uint1248; typedef unsigned int __attribute__ ((bitwidth(1249))) uint1249; typedef unsigned int __attribute__ ((bitwidth(1250))) uint1250; typedef unsigned int __attribute__ ((bitwidth(1251))) uint1251; typedef unsigned int __attribute__ ((bitwidth(1252))) uint1252; typedef unsigned int __attribute__ ((bitwidth(1253))) uint1253; typedef unsigned int __attribute__ ((bitwidth(1254))) uint1254; typedef unsigned int __attribute__ ((bitwidth(1255))) uint1255; typedef unsigned int __attribute__ ((bitwidth(1256))) uint1256; typedef unsigned int __attribute__ ((bitwidth(1257))) uint1257; typedef unsigned int __attribute__ ((bitwidth(1258))) uint1258; typedef unsigned int __attribute__ ((bitwidth(1259))) uint1259; typedef unsigned int __attribute__ ((bitwidth(1260))) uint1260; typedef unsigned int __attribute__ ((bitwidth(1261))) uint1261; typedef unsigned int __attribute__ ((bitwidth(1262))) uint1262; typedef unsigned int __attribute__ ((bitwidth(1263))) uint1263; typedef unsigned int __attribute__ ((bitwidth(1264))) uint1264; typedef unsigned int __attribute__ ((bitwidth(1265))) uint1265; typedef unsigned int __attribute__ ((bitwidth(1266))) uint1266; typedef unsigned int __attribute__ ((bitwidth(1267))) uint1267; typedef unsigned int __attribute__ ((bitwidth(1268))) uint1268; typedef unsigned int __attribute__ ((bitwidth(1269))) uint1269; typedef unsigned int __attribute__ ((bitwidth(1270))) uint1270; typedef unsigned int __attribute__ ((bitwidth(1271))) uint1271; typedef unsigned int __attribute__ ((bitwidth(1272))) uint1272; typedef unsigned int __attribute__ ((bitwidth(1273))) uint1273; typedef unsigned int __attribute__ ((bitwidth(1274))) uint1274; typedef unsigned int __attribute__ ((bitwidth(1275))) uint1275; typedef unsigned int __attribute__ ((bitwidth(1276))) uint1276; typedef unsigned int __attribute__ ((bitwidth(1277))) uint1277; typedef unsigned int __attribute__ ((bitwidth(1278))) uint1278; typedef unsigned int __attribute__ ((bitwidth(1279))) uint1279; typedef unsigned int __attribute__ ((bitwidth(1280))) uint1280; typedef unsigned int __attribute__ ((bitwidth(1281))) uint1281; typedef unsigned int __attribute__ ((bitwidth(1282))) uint1282; typedef unsigned int __attribute__ ((bitwidth(1283))) uint1283; typedef unsigned int __attribute__ ((bitwidth(1284))) uint1284; typedef unsigned int __attribute__ ((bitwidth(1285))) uint1285; typedef unsigned int __attribute__ ((bitwidth(1286))) uint1286; typedef unsigned int __attribute__ ((bitwidth(1287))) uint1287; typedef unsigned int __attribute__ ((bitwidth(1288))) uint1288; typedef unsigned int __attribute__ ((bitwidth(1289))) uint1289; typedef unsigned int __attribute__ ((bitwidth(1290))) uint1290; typedef unsigned int __attribute__ ((bitwidth(1291))) uint1291; typedef unsigned int __attribute__ ((bitwidth(1292))) uint1292; typedef unsigned int __attribute__ ((bitwidth(1293))) uint1293; typedef unsigned int __attribute__ ((bitwidth(1294))) uint1294; typedef unsigned int __attribute__ ((bitwidth(1295))) uint1295; typedef unsigned int __attribute__ ((bitwidth(1296))) uint1296; typedef unsigned int __attribute__ ((bitwidth(1297))) uint1297; typedef unsigned int __attribute__ ((bitwidth(1298))) uint1298; typedef unsigned int __attribute__ ((bitwidth(1299))) uint1299; typedef unsigned int __attribute__ ((bitwidth(1300))) uint1300; typedef unsigned int __attribute__ ((bitwidth(1301))) uint1301; typedef unsigned int __attribute__ ((bitwidth(1302))) uint1302; typedef unsigned int __attribute__ ((bitwidth(1303))) uint1303; typedef unsigned int __attribute__ ((bitwidth(1304))) uint1304; typedef unsigned int __attribute__ ((bitwidth(1305))) uint1305; typedef unsigned int __attribute__ ((bitwidth(1306))) uint1306; typedef unsigned int __attribute__ ((bitwidth(1307))) uint1307; typedef unsigned int __attribute__ ((bitwidth(1308))) uint1308; typedef unsigned int __attribute__ ((bitwidth(1309))) uint1309; typedef unsigned int __attribute__ ((bitwidth(1310))) uint1310; typedef unsigned int __attribute__ ((bitwidth(1311))) uint1311; typedef unsigned int __attribute__ ((bitwidth(1312))) uint1312; typedef unsigned int __attribute__ ((bitwidth(1313))) uint1313; typedef unsigned int __attribute__ ((bitwidth(1314))) uint1314; typedef unsigned int __attribute__ ((bitwidth(1315))) uint1315; typedef unsigned int __attribute__ ((bitwidth(1316))) uint1316; typedef unsigned int __attribute__ ((bitwidth(1317))) uint1317; typedef unsigned int __attribute__ ((bitwidth(1318))) uint1318; typedef unsigned int __attribute__ ((bitwidth(1319))) uint1319; typedef unsigned int __attribute__ ((bitwidth(1320))) uint1320; typedef unsigned int __attribute__ ((bitwidth(1321))) uint1321; typedef unsigned int __attribute__ ((bitwidth(1322))) uint1322; typedef unsigned int __attribute__ ((bitwidth(1323))) uint1323; typedef unsigned int __attribute__ ((bitwidth(1324))) uint1324; typedef unsigned int __attribute__ ((bitwidth(1325))) uint1325; typedef unsigned int __attribute__ ((bitwidth(1326))) uint1326; typedef unsigned int __attribute__ ((bitwidth(1327))) uint1327; typedef unsigned int __attribute__ ((bitwidth(1328))) uint1328; typedef unsigned int __attribute__ ((bitwidth(1329))) uint1329; typedef unsigned int __attribute__ ((bitwidth(1330))) uint1330; typedef unsigned int __attribute__ ((bitwidth(1331))) uint1331; typedef unsigned int __attribute__ ((bitwidth(1332))) uint1332; typedef unsigned int __attribute__ ((bitwidth(1333))) uint1333; typedef unsigned int __attribute__ ((bitwidth(1334))) uint1334; typedef unsigned int __attribute__ ((bitwidth(1335))) uint1335; typedef unsigned int __attribute__ ((bitwidth(1336))) uint1336; typedef unsigned int __attribute__ ((bitwidth(1337))) uint1337; typedef unsigned int __attribute__ ((bitwidth(1338))) uint1338; typedef unsigned int __attribute__ ((bitwidth(1339))) uint1339; typedef unsigned int __attribute__ ((bitwidth(1340))) uint1340; typedef unsigned int __attribute__ ((bitwidth(1341))) uint1341; typedef unsigned int __attribute__ ((bitwidth(1342))) uint1342; typedef unsigned int __attribute__ ((bitwidth(1343))) uint1343; typedef unsigned int __attribute__ ((bitwidth(1344))) uint1344; typedef unsigned int __attribute__ ((bitwidth(1345))) uint1345; typedef unsigned int __attribute__ ((bitwidth(1346))) uint1346; typedef unsigned int __attribute__ ((bitwidth(1347))) uint1347; typedef unsigned int __attribute__ ((bitwidth(1348))) uint1348; typedef unsigned int __attribute__ ((bitwidth(1349))) uint1349; typedef unsigned int __attribute__ ((bitwidth(1350))) uint1350; typedef unsigned int __attribute__ ((bitwidth(1351))) uint1351; typedef unsigned int __attribute__ ((bitwidth(1352))) uint1352; typedef unsigned int __attribute__ ((bitwidth(1353))) uint1353; typedef unsigned int __attribute__ ((bitwidth(1354))) uint1354; typedef unsigned int __attribute__ ((bitwidth(1355))) uint1355; typedef unsigned int __attribute__ ((bitwidth(1356))) uint1356; typedef unsigned int __attribute__ ((bitwidth(1357))) uint1357; typedef unsigned int __attribute__ ((bitwidth(1358))) uint1358; typedef unsigned int __attribute__ ((bitwidth(1359))) uint1359; typedef unsigned int __attribute__ ((bitwidth(1360))) uint1360; typedef unsigned int __attribute__ ((bitwidth(1361))) uint1361; typedef unsigned int __attribute__ ((bitwidth(1362))) uint1362; typedef unsigned int __attribute__ ((bitwidth(1363))) uint1363; typedef unsigned int __attribute__ ((bitwidth(1364))) uint1364; typedef unsigned int __attribute__ ((bitwidth(1365))) uint1365; typedef unsigned int __attribute__ ((bitwidth(1366))) uint1366; typedef unsigned int __attribute__ ((bitwidth(1367))) uint1367; typedef unsigned int __attribute__ ((bitwidth(1368))) uint1368; typedef unsigned int __attribute__ ((bitwidth(1369))) uint1369; typedef unsigned int __attribute__ ((bitwidth(1370))) uint1370; typedef unsigned int __attribute__ ((bitwidth(1371))) uint1371; typedef unsigned int __attribute__ ((bitwidth(1372))) uint1372; typedef unsigned int __attribute__ ((bitwidth(1373))) uint1373; typedef unsigned int __attribute__ ((bitwidth(1374))) uint1374; typedef unsigned int __attribute__ ((bitwidth(1375))) uint1375; typedef unsigned int __attribute__ ((bitwidth(1376))) uint1376; typedef unsigned int __attribute__ ((bitwidth(1377))) uint1377; typedef unsigned int __attribute__ ((bitwidth(1378))) uint1378; typedef unsigned int __attribute__ ((bitwidth(1379))) uint1379; typedef unsigned int __attribute__ ((bitwidth(1380))) uint1380; typedef unsigned int __attribute__ ((bitwidth(1381))) uint1381; typedef unsigned int __attribute__ ((bitwidth(1382))) uint1382; typedef unsigned int __attribute__ ((bitwidth(1383))) uint1383; typedef unsigned int __attribute__ ((bitwidth(1384))) uint1384; typedef unsigned int __attribute__ ((bitwidth(1385))) uint1385; typedef unsigned int __attribute__ ((bitwidth(1386))) uint1386; typedef unsigned int __attribute__ ((bitwidth(1387))) uint1387; typedef unsigned int __attribute__ ((bitwidth(1388))) uint1388; typedef unsigned int __attribute__ ((bitwidth(1389))) uint1389; typedef unsigned int __attribute__ ((bitwidth(1390))) uint1390; typedef unsigned int __attribute__ ((bitwidth(1391))) uint1391; typedef unsigned int __attribute__ ((bitwidth(1392))) uint1392; typedef unsigned int __attribute__ ((bitwidth(1393))) uint1393; typedef unsigned int __attribute__ ((bitwidth(1394))) uint1394; typedef unsigned int __attribute__ ((bitwidth(1395))) uint1395; typedef unsigned int __attribute__ ((bitwidth(1396))) uint1396; typedef unsigned int __attribute__ ((bitwidth(1397))) uint1397; typedef unsigned int __attribute__ ((bitwidth(1398))) uint1398; typedef unsigned int __attribute__ ((bitwidth(1399))) uint1399; typedef unsigned int __attribute__ ((bitwidth(1400))) uint1400; typedef unsigned int __attribute__ ((bitwidth(1401))) uint1401; typedef unsigned int __attribute__ ((bitwidth(1402))) uint1402; typedef unsigned int __attribute__ ((bitwidth(1403))) uint1403; typedef unsigned int __attribute__ ((bitwidth(1404))) uint1404; typedef unsigned int __attribute__ ((bitwidth(1405))) uint1405; typedef unsigned int __attribute__ ((bitwidth(1406))) uint1406; typedef unsigned int __attribute__ ((bitwidth(1407))) uint1407; typedef unsigned int __attribute__ ((bitwidth(1408))) uint1408; typedef unsigned int __attribute__ ((bitwidth(1409))) uint1409; typedef unsigned int __attribute__ ((bitwidth(1410))) uint1410; typedef unsigned int __attribute__ ((bitwidth(1411))) uint1411; typedef unsigned int __attribute__ ((bitwidth(1412))) uint1412; typedef unsigned int __attribute__ ((bitwidth(1413))) uint1413; typedef unsigned int __attribute__ ((bitwidth(1414))) uint1414; typedef unsigned int __attribute__ ((bitwidth(1415))) uint1415; typedef unsigned int __attribute__ ((bitwidth(1416))) uint1416; typedef unsigned int __attribute__ ((bitwidth(1417))) uint1417; typedef unsigned int __attribute__ ((bitwidth(1418))) uint1418; typedef unsigned int __attribute__ ((bitwidth(1419))) uint1419; typedef unsigned int __attribute__ ((bitwidth(1420))) uint1420; typedef unsigned int __attribute__ ((bitwidth(1421))) uint1421; typedef unsigned int __attribute__ ((bitwidth(1422))) uint1422; typedef unsigned int __attribute__ ((bitwidth(1423))) uint1423; typedef unsigned int __attribute__ ((bitwidth(1424))) uint1424; typedef unsigned int __attribute__ ((bitwidth(1425))) uint1425; typedef unsigned int __attribute__ ((bitwidth(1426))) uint1426; typedef unsigned int __attribute__ ((bitwidth(1427))) uint1427; typedef unsigned int __attribute__ ((bitwidth(1428))) uint1428; typedef unsigned int __attribute__ ((bitwidth(1429))) uint1429; typedef unsigned int __attribute__ ((bitwidth(1430))) uint1430; typedef unsigned int __attribute__ ((bitwidth(1431))) uint1431; typedef unsigned int __attribute__ ((bitwidth(1432))) uint1432; typedef unsigned int __attribute__ ((bitwidth(1433))) uint1433; typedef unsigned int __attribute__ ((bitwidth(1434))) uint1434; typedef unsigned int __attribute__ ((bitwidth(1435))) uint1435; typedef unsigned int __attribute__ ((bitwidth(1436))) uint1436; typedef unsigned int __attribute__ ((bitwidth(1437))) uint1437; typedef unsigned int __attribute__ ((bitwidth(1438))) uint1438; typedef unsigned int __attribute__ ((bitwidth(1439))) uint1439; typedef unsigned int __attribute__ ((bitwidth(1440))) uint1440; typedef unsigned int __attribute__ ((bitwidth(1441))) uint1441; typedef unsigned int __attribute__ ((bitwidth(1442))) uint1442; typedef unsigned int __attribute__ ((bitwidth(1443))) uint1443; typedef unsigned int __attribute__ ((bitwidth(1444))) uint1444; typedef unsigned int __attribute__ ((bitwidth(1445))) uint1445; typedef unsigned int __attribute__ ((bitwidth(1446))) uint1446; typedef unsigned int __attribute__ ((bitwidth(1447))) uint1447; typedef unsigned int __attribute__ ((bitwidth(1448))) uint1448; typedef unsigned int __attribute__ ((bitwidth(1449))) uint1449; typedef unsigned int __attribute__ ((bitwidth(1450))) uint1450; typedef unsigned int __attribute__ ((bitwidth(1451))) uint1451; typedef unsigned int __attribute__ ((bitwidth(1452))) uint1452; typedef unsigned int __attribute__ ((bitwidth(1453))) uint1453; typedef unsigned int __attribute__ ((bitwidth(1454))) uint1454; typedef unsigned int __attribute__ ((bitwidth(1455))) uint1455; typedef unsigned int __attribute__ ((bitwidth(1456))) uint1456; typedef unsigned int __attribute__ ((bitwidth(1457))) uint1457; typedef unsigned int __attribute__ ((bitwidth(1458))) uint1458; typedef unsigned int __attribute__ ((bitwidth(1459))) uint1459; typedef unsigned int __attribute__ ((bitwidth(1460))) uint1460; typedef unsigned int __attribute__ ((bitwidth(1461))) uint1461; typedef unsigned int __attribute__ ((bitwidth(1462))) uint1462; typedef unsigned int __attribute__ ((bitwidth(1463))) uint1463; typedef unsigned int __attribute__ ((bitwidth(1464))) uint1464; typedef unsigned int __attribute__ ((bitwidth(1465))) uint1465; typedef unsigned int __attribute__ ((bitwidth(1466))) uint1466; typedef unsigned int __attribute__ ((bitwidth(1467))) uint1467; typedef unsigned int __attribute__ ((bitwidth(1468))) uint1468; typedef unsigned int __attribute__ ((bitwidth(1469))) uint1469; typedef unsigned int __attribute__ ((bitwidth(1470))) uint1470; typedef unsigned int __attribute__ ((bitwidth(1471))) uint1471; typedef unsigned int __attribute__ ((bitwidth(1472))) uint1472; typedef unsigned int __attribute__ ((bitwidth(1473))) uint1473; typedef unsigned int __attribute__ ((bitwidth(1474))) uint1474; typedef unsigned int __attribute__ ((bitwidth(1475))) uint1475; typedef unsigned int __attribute__ ((bitwidth(1476))) uint1476; typedef unsigned int __attribute__ ((bitwidth(1477))) uint1477; typedef unsigned int __attribute__ ((bitwidth(1478))) uint1478; typedef unsigned int __attribute__ ((bitwidth(1479))) uint1479; typedef unsigned int __attribute__ ((bitwidth(1480))) uint1480; typedef unsigned int __attribute__ ((bitwidth(1481))) uint1481; typedef unsigned int __attribute__ ((bitwidth(1482))) uint1482; typedef unsigned int __attribute__ ((bitwidth(1483))) uint1483; typedef unsigned int __attribute__ ((bitwidth(1484))) uint1484; typedef unsigned int __attribute__ ((bitwidth(1485))) uint1485; typedef unsigned int __attribute__ ((bitwidth(1486))) uint1486; typedef unsigned int __attribute__ ((bitwidth(1487))) uint1487; typedef unsigned int __attribute__ ((bitwidth(1488))) uint1488; typedef unsigned int __attribute__ ((bitwidth(1489))) uint1489; typedef unsigned int __attribute__ ((bitwidth(1490))) uint1490; typedef unsigned int __attribute__ ((bitwidth(1491))) uint1491; typedef unsigned int __attribute__ ((bitwidth(1492))) uint1492; typedef unsigned int __attribute__ ((bitwidth(1493))) uint1493; typedef unsigned int __attribute__ ((bitwidth(1494))) uint1494; typedef unsigned int __attribute__ ((bitwidth(1495))) uint1495; typedef unsigned int __attribute__ ((bitwidth(1496))) uint1496; typedef unsigned int __attribute__ ((bitwidth(1497))) uint1497; typedef unsigned int __attribute__ ((bitwidth(1498))) uint1498; typedef unsigned int __attribute__ ((bitwidth(1499))) uint1499; typedef unsigned int __attribute__ ((bitwidth(1500))) uint1500; typedef unsigned int __attribute__ ((bitwidth(1501))) uint1501; typedef unsigned int __attribute__ ((bitwidth(1502))) uint1502; typedef unsigned int __attribute__ ((bitwidth(1503))) uint1503; typedef unsigned int __attribute__ ((bitwidth(1504))) uint1504; typedef unsigned int __attribute__ ((bitwidth(1505))) uint1505; typedef unsigned int __attribute__ ((bitwidth(1506))) uint1506; typedef unsigned int __attribute__ ((bitwidth(1507))) uint1507; typedef unsigned int __attribute__ ((bitwidth(1508))) uint1508; typedef unsigned int __attribute__ ((bitwidth(1509))) uint1509; typedef unsigned int __attribute__ ((bitwidth(1510))) uint1510; typedef unsigned int __attribute__ ((bitwidth(1511))) uint1511; typedef unsigned int __attribute__ ((bitwidth(1512))) uint1512; typedef unsigned int __attribute__ ((bitwidth(1513))) uint1513; typedef unsigned int __attribute__ ((bitwidth(1514))) uint1514; typedef unsigned int __attribute__ ((bitwidth(1515))) uint1515; typedef unsigned int __attribute__ ((bitwidth(1516))) uint1516; typedef unsigned int __attribute__ ((bitwidth(1517))) uint1517; typedef unsigned int __attribute__ ((bitwidth(1518))) uint1518; typedef unsigned int __attribute__ ((bitwidth(1519))) uint1519; typedef unsigned int __attribute__ ((bitwidth(1520))) uint1520; typedef unsigned int __attribute__ ((bitwidth(1521))) uint1521; typedef unsigned int __attribute__ ((bitwidth(1522))) uint1522; typedef unsigned int __attribute__ ((bitwidth(1523))) uint1523; typedef unsigned int __attribute__ ((bitwidth(1524))) uint1524; typedef unsigned int __attribute__ ((bitwidth(1525))) uint1525; typedef unsigned int __attribute__ ((bitwidth(1526))) uint1526; typedef unsigned int __attribute__ ((bitwidth(1527))) uint1527; typedef unsigned int __attribute__ ((bitwidth(1528))) uint1528; typedef unsigned int __attribute__ ((bitwidth(1529))) uint1529; typedef unsigned int __attribute__ ((bitwidth(1530))) uint1530; typedef unsigned int __attribute__ ((bitwidth(1531))) uint1531; typedef unsigned int __attribute__ ((bitwidth(1532))) uint1532; typedef unsigned int __attribute__ ((bitwidth(1533))) uint1533; typedef unsigned int __attribute__ ((bitwidth(1534))) uint1534; typedef unsigned int __attribute__ ((bitwidth(1535))) uint1535; typedef unsigned int __attribute__ ((bitwidth(1536))) uint1536; typedef unsigned int __attribute__ ((bitwidth(1537))) uint1537; typedef unsigned int __attribute__ ((bitwidth(1538))) uint1538; typedef unsigned int __attribute__ ((bitwidth(1539))) uint1539; typedef unsigned int __attribute__ ((bitwidth(1540))) uint1540; typedef unsigned int __attribute__ ((bitwidth(1541))) uint1541; typedef unsigned int __attribute__ ((bitwidth(1542))) uint1542; typedef unsigned int __attribute__ ((bitwidth(1543))) uint1543; typedef unsigned int __attribute__ ((bitwidth(1544))) uint1544; typedef unsigned int __attribute__ ((bitwidth(1545))) uint1545; typedef unsigned int __attribute__ ((bitwidth(1546))) uint1546; typedef unsigned int __attribute__ ((bitwidth(1547))) uint1547; typedef unsigned int __attribute__ ((bitwidth(1548))) uint1548; typedef unsigned int __attribute__ ((bitwidth(1549))) uint1549; typedef unsigned int __attribute__ ((bitwidth(1550))) uint1550; typedef unsigned int __attribute__ ((bitwidth(1551))) uint1551; typedef unsigned int __attribute__ ((bitwidth(1552))) uint1552; typedef unsigned int __attribute__ ((bitwidth(1553))) uint1553; typedef unsigned int __attribute__ ((bitwidth(1554))) uint1554; typedef unsigned int __attribute__ ((bitwidth(1555))) uint1555; typedef unsigned int __attribute__ ((bitwidth(1556))) uint1556; typedef unsigned int __attribute__ ((bitwidth(1557))) uint1557; typedef unsigned int __attribute__ ((bitwidth(1558))) uint1558; typedef unsigned int __attribute__ ((bitwidth(1559))) uint1559; typedef unsigned int __attribute__ ((bitwidth(1560))) uint1560; typedef unsigned int __attribute__ ((bitwidth(1561))) uint1561; typedef unsigned int __attribute__ ((bitwidth(1562))) uint1562; typedef unsigned int __attribute__ ((bitwidth(1563))) uint1563; typedef unsigned int __attribute__ ((bitwidth(1564))) uint1564; typedef unsigned int __attribute__ ((bitwidth(1565))) uint1565; typedef unsigned int __attribute__ ((bitwidth(1566))) uint1566; typedef unsigned int __attribute__ ((bitwidth(1567))) uint1567; typedef unsigned int __attribute__ ((bitwidth(1568))) uint1568; typedef unsigned int __attribute__ ((bitwidth(1569))) uint1569; typedef unsigned int __attribute__ ((bitwidth(1570))) uint1570; typedef unsigned int __attribute__ ((bitwidth(1571))) uint1571; typedef unsigned int __attribute__ ((bitwidth(1572))) uint1572; typedef unsigned int __attribute__ ((bitwidth(1573))) uint1573; typedef unsigned int __attribute__ ((bitwidth(1574))) uint1574; typedef unsigned int __attribute__ ((bitwidth(1575))) uint1575; typedef unsigned int __attribute__ ((bitwidth(1576))) uint1576; typedef unsigned int __attribute__ ((bitwidth(1577))) uint1577; typedef unsigned int __attribute__ ((bitwidth(1578))) uint1578; typedef unsigned int __attribute__ ((bitwidth(1579))) uint1579; typedef unsigned int __attribute__ ((bitwidth(1580))) uint1580; typedef unsigned int __attribute__ ((bitwidth(1581))) uint1581; typedef unsigned int __attribute__ ((bitwidth(1582))) uint1582; typedef unsigned int __attribute__ ((bitwidth(1583))) uint1583; typedef unsigned int __attribute__ ((bitwidth(1584))) uint1584; typedef unsigned int __attribute__ ((bitwidth(1585))) uint1585; typedef unsigned int __attribute__ ((bitwidth(1586))) uint1586; typedef unsigned int __attribute__ ((bitwidth(1587))) uint1587; typedef unsigned int __attribute__ ((bitwidth(1588))) uint1588; typedef unsigned int __attribute__ ((bitwidth(1589))) uint1589; typedef unsigned int __attribute__ ((bitwidth(1590))) uint1590; typedef unsigned int __attribute__ ((bitwidth(1591))) uint1591; typedef unsigned int __attribute__ ((bitwidth(1592))) uint1592; typedef unsigned int __attribute__ ((bitwidth(1593))) uint1593; typedef unsigned int __attribute__ ((bitwidth(1594))) uint1594; typedef unsigned int __attribute__ ((bitwidth(1595))) uint1595; typedef unsigned int __attribute__ ((bitwidth(1596))) uint1596; typedef unsigned int __attribute__ ((bitwidth(1597))) uint1597; typedef unsigned int __attribute__ ((bitwidth(1598))) uint1598; typedef unsigned int __attribute__ ((bitwidth(1599))) uint1599; typedef unsigned int __attribute__ ((bitwidth(1600))) uint1600; typedef unsigned int __attribute__ ((bitwidth(1601))) uint1601; typedef unsigned int __attribute__ ((bitwidth(1602))) uint1602; typedef unsigned int __attribute__ ((bitwidth(1603))) uint1603; typedef unsigned int __attribute__ ((bitwidth(1604))) uint1604; typedef unsigned int __attribute__ ((bitwidth(1605))) uint1605; typedef unsigned int __attribute__ ((bitwidth(1606))) uint1606; typedef unsigned int __attribute__ ((bitwidth(1607))) uint1607; typedef unsigned int __attribute__ ((bitwidth(1608))) uint1608; typedef unsigned int __attribute__ ((bitwidth(1609))) uint1609; typedef unsigned int __attribute__ ((bitwidth(1610))) uint1610; typedef unsigned int __attribute__ ((bitwidth(1611))) uint1611; typedef unsigned int __attribute__ ((bitwidth(1612))) uint1612; typedef unsigned int __attribute__ ((bitwidth(1613))) uint1613; typedef unsigned int __attribute__ ((bitwidth(1614))) uint1614; typedef unsigned int __attribute__ ((bitwidth(1615))) uint1615; typedef unsigned int __attribute__ ((bitwidth(1616))) uint1616; typedef unsigned int __attribute__ ((bitwidth(1617))) uint1617; typedef unsigned int __attribute__ ((bitwidth(1618))) uint1618; typedef unsigned int __attribute__ ((bitwidth(1619))) uint1619; typedef unsigned int __attribute__ ((bitwidth(1620))) uint1620; typedef unsigned int __attribute__ ((bitwidth(1621))) uint1621; typedef unsigned int __attribute__ ((bitwidth(1622))) uint1622; typedef unsigned int __attribute__ ((bitwidth(1623))) uint1623; typedef unsigned int __attribute__ ((bitwidth(1624))) uint1624; typedef unsigned int __attribute__ ((bitwidth(1625))) uint1625; typedef unsigned int __attribute__ ((bitwidth(1626))) uint1626; typedef unsigned int __attribute__ ((bitwidth(1627))) uint1627; typedef unsigned int __attribute__ ((bitwidth(1628))) uint1628; typedef unsigned int __attribute__ ((bitwidth(1629))) uint1629; typedef unsigned int __attribute__ ((bitwidth(1630))) uint1630; typedef unsigned int __attribute__ ((bitwidth(1631))) uint1631; typedef unsigned int __attribute__ ((bitwidth(1632))) uint1632; typedef unsigned int __attribute__ ((bitwidth(1633))) uint1633; typedef unsigned int __attribute__ ((bitwidth(1634))) uint1634; typedef unsigned int __attribute__ ((bitwidth(1635))) uint1635; typedef unsigned int __attribute__ ((bitwidth(1636))) uint1636; typedef unsigned int __attribute__ ((bitwidth(1637))) uint1637; typedef unsigned int __attribute__ ((bitwidth(1638))) uint1638; typedef unsigned int __attribute__ ((bitwidth(1639))) uint1639; typedef unsigned int __attribute__ ((bitwidth(1640))) uint1640; typedef unsigned int __attribute__ ((bitwidth(1641))) uint1641; typedef unsigned int __attribute__ ((bitwidth(1642))) uint1642; typedef unsigned int __attribute__ ((bitwidth(1643))) uint1643; typedef unsigned int __attribute__ ((bitwidth(1644))) uint1644; typedef unsigned int __attribute__ ((bitwidth(1645))) uint1645; typedef unsigned int __attribute__ ((bitwidth(1646))) uint1646; typedef unsigned int __attribute__ ((bitwidth(1647))) uint1647; typedef unsigned int __attribute__ ((bitwidth(1648))) uint1648; typedef unsigned int __attribute__ ((bitwidth(1649))) uint1649; typedef unsigned int __attribute__ ((bitwidth(1650))) uint1650; typedef unsigned int __attribute__ ((bitwidth(1651))) uint1651; typedef unsigned int __attribute__ ((bitwidth(1652))) uint1652; typedef unsigned int __attribute__ ((bitwidth(1653))) uint1653; typedef unsigned int __attribute__ ((bitwidth(1654))) uint1654; typedef unsigned int __attribute__ ((bitwidth(1655))) uint1655; typedef unsigned int __attribute__ ((bitwidth(1656))) uint1656; typedef unsigned int __attribute__ ((bitwidth(1657))) uint1657; typedef unsigned int __attribute__ ((bitwidth(1658))) uint1658; typedef unsigned int __attribute__ ((bitwidth(1659))) uint1659; typedef unsigned int __attribute__ ((bitwidth(1660))) uint1660; typedef unsigned int __attribute__ ((bitwidth(1661))) uint1661; typedef unsigned int __attribute__ ((bitwidth(1662))) uint1662; typedef unsigned int __attribute__ ((bitwidth(1663))) uint1663; typedef unsigned int __attribute__ ((bitwidth(1664))) uint1664; typedef unsigned int __attribute__ ((bitwidth(1665))) uint1665; typedef unsigned int __attribute__ ((bitwidth(1666))) uint1666; typedef unsigned int __attribute__ ((bitwidth(1667))) uint1667; typedef unsigned int __attribute__ ((bitwidth(1668))) uint1668; typedef unsigned int __attribute__ ((bitwidth(1669))) uint1669; typedef unsigned int __attribute__ ((bitwidth(1670))) uint1670; typedef unsigned int __attribute__ ((bitwidth(1671))) uint1671; typedef unsigned int __attribute__ ((bitwidth(1672))) uint1672; typedef unsigned int __attribute__ ((bitwidth(1673))) uint1673; typedef unsigned int __attribute__ ((bitwidth(1674))) uint1674; typedef unsigned int __attribute__ ((bitwidth(1675))) uint1675; typedef unsigned int __attribute__ ((bitwidth(1676))) uint1676; typedef unsigned int __attribute__ ((bitwidth(1677))) uint1677; typedef unsigned int __attribute__ ((bitwidth(1678))) uint1678; typedef unsigned int __attribute__ ((bitwidth(1679))) uint1679; typedef unsigned int __attribute__ ((bitwidth(1680))) uint1680; typedef unsigned int __attribute__ ((bitwidth(1681))) uint1681; typedef unsigned int __attribute__ ((bitwidth(1682))) uint1682; typedef unsigned int __attribute__ ((bitwidth(1683))) uint1683; typedef unsigned int __attribute__ ((bitwidth(1684))) uint1684; typedef unsigned int __attribute__ ((bitwidth(1685))) uint1685; typedef unsigned int __attribute__ ((bitwidth(1686))) uint1686; typedef unsigned int __attribute__ ((bitwidth(1687))) uint1687; typedef unsigned int __attribute__ ((bitwidth(1688))) uint1688; typedef unsigned int __attribute__ ((bitwidth(1689))) uint1689; typedef unsigned int __attribute__ ((bitwidth(1690))) uint1690; typedef unsigned int __attribute__ ((bitwidth(1691))) uint1691; typedef unsigned int __attribute__ ((bitwidth(1692))) uint1692; typedef unsigned int __attribute__ ((bitwidth(1693))) uint1693; typedef unsigned int __attribute__ ((bitwidth(1694))) uint1694; typedef unsigned int __attribute__ ((bitwidth(1695))) uint1695; typedef unsigned int __attribute__ ((bitwidth(1696))) uint1696; typedef unsigned int __attribute__ ((bitwidth(1697))) uint1697; typedef unsigned int __attribute__ ((bitwidth(1698))) uint1698; typedef unsigned int __attribute__ ((bitwidth(1699))) uint1699; typedef unsigned int __attribute__ ((bitwidth(1700))) uint1700; typedef unsigned int __attribute__ ((bitwidth(1701))) uint1701; typedef unsigned int __attribute__ ((bitwidth(1702))) uint1702; typedef unsigned int __attribute__ ((bitwidth(1703))) uint1703; typedef unsigned int __attribute__ ((bitwidth(1704))) uint1704; typedef unsigned int __attribute__ ((bitwidth(1705))) uint1705; typedef unsigned int __attribute__ ((bitwidth(1706))) uint1706; typedef unsigned int __attribute__ ((bitwidth(1707))) uint1707; typedef unsigned int __attribute__ ((bitwidth(1708))) uint1708; typedef unsigned int __attribute__ ((bitwidth(1709))) uint1709; typedef unsigned int __attribute__ ((bitwidth(1710))) uint1710; typedef unsigned int __attribute__ ((bitwidth(1711))) uint1711; typedef unsigned int __attribute__ ((bitwidth(1712))) uint1712; typedef unsigned int __attribute__ ((bitwidth(1713))) uint1713; typedef unsigned int __attribute__ ((bitwidth(1714))) uint1714; typedef unsigned int __attribute__ ((bitwidth(1715))) uint1715; typedef unsigned int __attribute__ ((bitwidth(1716))) uint1716; typedef unsigned int __attribute__ ((bitwidth(1717))) uint1717; typedef unsigned int __attribute__ ((bitwidth(1718))) uint1718; typedef unsigned int __attribute__ ((bitwidth(1719))) uint1719; typedef unsigned int __attribute__ ((bitwidth(1720))) uint1720; typedef unsigned int __attribute__ ((bitwidth(1721))) uint1721; typedef unsigned int __attribute__ ((bitwidth(1722))) uint1722; typedef unsigned int __attribute__ ((bitwidth(1723))) uint1723; typedef unsigned int __attribute__ ((bitwidth(1724))) uint1724; typedef unsigned int __attribute__ ((bitwidth(1725))) uint1725; typedef unsigned int __attribute__ ((bitwidth(1726))) uint1726; typedef unsigned int __attribute__ ((bitwidth(1727))) uint1727; typedef unsigned int __attribute__ ((bitwidth(1728))) uint1728; typedef unsigned int __attribute__ ((bitwidth(1729))) uint1729; typedef unsigned int __attribute__ ((bitwidth(1730))) uint1730; typedef unsigned int __attribute__ ((bitwidth(1731))) uint1731; typedef unsigned int __attribute__ ((bitwidth(1732))) uint1732; typedef unsigned int __attribute__ ((bitwidth(1733))) uint1733; typedef unsigned int __attribute__ ((bitwidth(1734))) uint1734; typedef unsigned int __attribute__ ((bitwidth(1735))) uint1735; typedef unsigned int __attribute__ ((bitwidth(1736))) uint1736; typedef unsigned int __attribute__ ((bitwidth(1737))) uint1737; typedef unsigned int __attribute__ ((bitwidth(1738))) uint1738; typedef unsigned int __attribute__ ((bitwidth(1739))) uint1739; typedef unsigned int __attribute__ ((bitwidth(1740))) uint1740; typedef unsigned int __attribute__ ((bitwidth(1741))) uint1741; typedef unsigned int __attribute__ ((bitwidth(1742))) uint1742; typedef unsigned int __attribute__ ((bitwidth(1743))) uint1743; typedef unsigned int __attribute__ ((bitwidth(1744))) uint1744; typedef unsigned int __attribute__ ((bitwidth(1745))) uint1745; typedef unsigned int __attribute__ ((bitwidth(1746))) uint1746; typedef unsigned int __attribute__ ((bitwidth(1747))) uint1747; typedef unsigned int __attribute__ ((bitwidth(1748))) uint1748; typedef unsigned int __attribute__ ((bitwidth(1749))) uint1749; typedef unsigned int __attribute__ ((bitwidth(1750))) uint1750; typedef unsigned int __attribute__ ((bitwidth(1751))) uint1751; typedef unsigned int __attribute__ ((bitwidth(1752))) uint1752; typedef unsigned int __attribute__ ((bitwidth(1753))) uint1753; typedef unsigned int __attribute__ ((bitwidth(1754))) uint1754; typedef unsigned int __attribute__ ((bitwidth(1755))) uint1755; typedef unsigned int __attribute__ ((bitwidth(1756))) uint1756; typedef unsigned int __attribute__ ((bitwidth(1757))) uint1757; typedef unsigned int __attribute__ ((bitwidth(1758))) uint1758; typedef unsigned int __attribute__ ((bitwidth(1759))) uint1759; typedef unsigned int __attribute__ ((bitwidth(1760))) uint1760; typedef unsigned int __attribute__ ((bitwidth(1761))) uint1761; typedef unsigned int __attribute__ ((bitwidth(1762))) uint1762; typedef unsigned int __attribute__ ((bitwidth(1763))) uint1763; typedef unsigned int __attribute__ ((bitwidth(1764))) uint1764; typedef unsigned int __attribute__ ((bitwidth(1765))) uint1765; typedef unsigned int __attribute__ ((bitwidth(1766))) uint1766; typedef unsigned int __attribute__ ((bitwidth(1767))) uint1767; typedef unsigned int __attribute__ ((bitwidth(1768))) uint1768; typedef unsigned int __attribute__ ((bitwidth(1769))) uint1769; typedef unsigned int __attribute__ ((bitwidth(1770))) uint1770; typedef unsigned int __attribute__ ((bitwidth(1771))) uint1771; typedef unsigned int __attribute__ ((bitwidth(1772))) uint1772; typedef unsigned int __attribute__ ((bitwidth(1773))) uint1773; typedef unsigned int __attribute__ ((bitwidth(1774))) uint1774; typedef unsigned int __attribute__ ((bitwidth(1775))) uint1775; typedef unsigned int __attribute__ ((bitwidth(1776))) uint1776; typedef unsigned int __attribute__ ((bitwidth(1777))) uint1777; typedef unsigned int __attribute__ ((bitwidth(1778))) uint1778; typedef unsigned int __attribute__ ((bitwidth(1779))) uint1779; typedef unsigned int __attribute__ ((bitwidth(1780))) uint1780; typedef unsigned int __attribute__ ((bitwidth(1781))) uint1781; typedef unsigned int __attribute__ ((bitwidth(1782))) uint1782; typedef unsigned int __attribute__ ((bitwidth(1783))) uint1783; typedef unsigned int __attribute__ ((bitwidth(1784))) uint1784; typedef unsigned int __attribute__ ((bitwidth(1785))) uint1785; typedef unsigned int __attribute__ ((bitwidth(1786))) uint1786; typedef unsigned int __attribute__ ((bitwidth(1787))) uint1787; typedef unsigned int __attribute__ ((bitwidth(1788))) uint1788; typedef unsigned int __attribute__ ((bitwidth(1789))) uint1789; typedef unsigned int __attribute__ ((bitwidth(1790))) uint1790; typedef unsigned int __attribute__ ((bitwidth(1791))) uint1791; typedef unsigned int __attribute__ ((bitwidth(1792))) uint1792; typedef unsigned int __attribute__ ((bitwidth(1793))) uint1793; typedef unsigned int __attribute__ ((bitwidth(1794))) uint1794; typedef unsigned int __attribute__ ((bitwidth(1795))) uint1795; typedef unsigned int __attribute__ ((bitwidth(1796))) uint1796; typedef unsigned int __attribute__ ((bitwidth(1797))) uint1797; typedef unsigned int __attribute__ ((bitwidth(1798))) uint1798; typedef unsigned int __attribute__ ((bitwidth(1799))) uint1799; typedef unsigned int __attribute__ ((bitwidth(1800))) uint1800; typedef unsigned int __attribute__ ((bitwidth(1801))) uint1801; typedef unsigned int __attribute__ ((bitwidth(1802))) uint1802; typedef unsigned int __attribute__ ((bitwidth(1803))) uint1803; typedef unsigned int __attribute__ ((bitwidth(1804))) uint1804; typedef unsigned int __attribute__ ((bitwidth(1805))) uint1805; typedef unsigned int __attribute__ ((bitwidth(1806))) uint1806; typedef unsigned int __attribute__ ((bitwidth(1807))) uint1807; typedef unsigned int __attribute__ ((bitwidth(1808))) uint1808; typedef unsigned int __attribute__ ((bitwidth(1809))) uint1809; typedef unsigned int __attribute__ ((bitwidth(1810))) uint1810; typedef unsigned int __attribute__ ((bitwidth(1811))) uint1811; typedef unsigned int __attribute__ ((bitwidth(1812))) uint1812; typedef unsigned int __attribute__ ((bitwidth(1813))) uint1813; typedef unsigned int __attribute__ ((bitwidth(1814))) uint1814; typedef unsigned int __attribute__ ((bitwidth(1815))) uint1815; typedef unsigned int __attribute__ ((bitwidth(1816))) uint1816; typedef unsigned int __attribute__ ((bitwidth(1817))) uint1817; typedef unsigned int __attribute__ ((bitwidth(1818))) uint1818; typedef unsigned int __attribute__ ((bitwidth(1819))) uint1819; typedef unsigned int __attribute__ ((bitwidth(1820))) uint1820; typedef unsigned int __attribute__ ((bitwidth(1821))) uint1821; typedef unsigned int __attribute__ ((bitwidth(1822))) uint1822; typedef unsigned int __attribute__ ((bitwidth(1823))) uint1823; typedef unsigned int __attribute__ ((bitwidth(1824))) uint1824; typedef unsigned int __attribute__ ((bitwidth(1825))) uint1825; typedef unsigned int __attribute__ ((bitwidth(1826))) uint1826; typedef unsigned int __attribute__ ((bitwidth(1827))) uint1827; typedef unsigned int __attribute__ ((bitwidth(1828))) uint1828; typedef unsigned int __attribute__ ((bitwidth(1829))) uint1829; typedef unsigned int __attribute__ ((bitwidth(1830))) uint1830; typedef unsigned int __attribute__ ((bitwidth(1831))) uint1831; typedef unsigned int __attribute__ ((bitwidth(1832))) uint1832; typedef unsigned int __attribute__ ((bitwidth(1833))) uint1833; typedef unsigned int __attribute__ ((bitwidth(1834))) uint1834; typedef unsigned int __attribute__ ((bitwidth(1835))) uint1835; typedef unsigned int __attribute__ ((bitwidth(1836))) uint1836; typedef unsigned int __attribute__ ((bitwidth(1837))) uint1837; typedef unsigned int __attribute__ ((bitwidth(1838))) uint1838; typedef unsigned int __attribute__ ((bitwidth(1839))) uint1839; typedef unsigned int __attribute__ ((bitwidth(1840))) uint1840; typedef unsigned int __attribute__ ((bitwidth(1841))) uint1841; typedef unsigned int __attribute__ ((bitwidth(1842))) uint1842; typedef unsigned int __attribute__ ((bitwidth(1843))) uint1843; typedef unsigned int __attribute__ ((bitwidth(1844))) uint1844; typedef unsigned int __attribute__ ((bitwidth(1845))) uint1845; typedef unsigned int __attribute__ ((bitwidth(1846))) uint1846; typedef unsigned int __attribute__ ((bitwidth(1847))) uint1847; typedef unsigned int __attribute__ ((bitwidth(1848))) uint1848; typedef unsigned int __attribute__ ((bitwidth(1849))) uint1849; typedef unsigned int __attribute__ ((bitwidth(1850))) uint1850; typedef unsigned int __attribute__ ((bitwidth(1851))) uint1851; typedef unsigned int __attribute__ ((bitwidth(1852))) uint1852; typedef unsigned int __attribute__ ((bitwidth(1853))) uint1853; typedef unsigned int __attribute__ ((bitwidth(1854))) uint1854; typedef unsigned int __attribute__ ((bitwidth(1855))) uint1855; typedef unsigned int __attribute__ ((bitwidth(1856))) uint1856; typedef unsigned int __attribute__ ((bitwidth(1857))) uint1857; typedef unsigned int __attribute__ ((bitwidth(1858))) uint1858; typedef unsigned int __attribute__ ((bitwidth(1859))) uint1859; typedef unsigned int __attribute__ ((bitwidth(1860))) uint1860; typedef unsigned int __attribute__ ((bitwidth(1861))) uint1861; typedef unsigned int __attribute__ ((bitwidth(1862))) uint1862; typedef unsigned int __attribute__ ((bitwidth(1863))) uint1863; typedef unsigned int __attribute__ ((bitwidth(1864))) uint1864; typedef unsigned int __attribute__ ((bitwidth(1865))) uint1865; typedef unsigned int __attribute__ ((bitwidth(1866))) uint1866; typedef unsigned int __attribute__ ((bitwidth(1867))) uint1867; typedef unsigned int __attribute__ ((bitwidth(1868))) uint1868; typedef unsigned int __attribute__ ((bitwidth(1869))) uint1869; typedef unsigned int __attribute__ ((bitwidth(1870))) uint1870; typedef unsigned int __attribute__ ((bitwidth(1871))) uint1871; typedef unsigned int __attribute__ ((bitwidth(1872))) uint1872; typedef unsigned int __attribute__ ((bitwidth(1873))) uint1873; typedef unsigned int __attribute__ ((bitwidth(1874))) uint1874; typedef unsigned int __attribute__ ((bitwidth(1875))) uint1875; typedef unsigned int __attribute__ ((bitwidth(1876))) uint1876; typedef unsigned int __attribute__ ((bitwidth(1877))) uint1877; typedef unsigned int __attribute__ ((bitwidth(1878))) uint1878; typedef unsigned int __attribute__ ((bitwidth(1879))) uint1879; typedef unsigned int __attribute__ ((bitwidth(1880))) uint1880; typedef unsigned int __attribute__ ((bitwidth(1881))) uint1881; typedef unsigned int __attribute__ ((bitwidth(1882))) uint1882; typedef unsigned int __attribute__ ((bitwidth(1883))) uint1883; typedef unsigned int __attribute__ ((bitwidth(1884))) uint1884; typedef unsigned int __attribute__ ((bitwidth(1885))) uint1885; typedef unsigned int __attribute__ ((bitwidth(1886))) uint1886; typedef unsigned int __attribute__ ((bitwidth(1887))) uint1887; typedef unsigned int __attribute__ ((bitwidth(1888))) uint1888; typedef unsigned int __attribute__ ((bitwidth(1889))) uint1889; typedef unsigned int __attribute__ ((bitwidth(1890))) uint1890; typedef unsigned int __attribute__ ((bitwidth(1891))) uint1891; typedef unsigned int __attribute__ ((bitwidth(1892))) uint1892; typedef unsigned int __attribute__ ((bitwidth(1893))) uint1893; typedef unsigned int __attribute__ ((bitwidth(1894))) uint1894; typedef unsigned int __attribute__ ((bitwidth(1895))) uint1895; typedef unsigned int __attribute__ ((bitwidth(1896))) uint1896; typedef unsigned int __attribute__ ((bitwidth(1897))) uint1897; typedef unsigned int __attribute__ ((bitwidth(1898))) uint1898; typedef unsigned int __attribute__ ((bitwidth(1899))) uint1899; typedef unsigned int __attribute__ ((bitwidth(1900))) uint1900; typedef unsigned int __attribute__ ((bitwidth(1901))) uint1901; typedef unsigned int __attribute__ ((bitwidth(1902))) uint1902; typedef unsigned int __attribute__ ((bitwidth(1903))) uint1903; typedef unsigned int __attribute__ ((bitwidth(1904))) uint1904; typedef unsigned int __attribute__ ((bitwidth(1905))) uint1905; typedef unsigned int __attribute__ ((bitwidth(1906))) uint1906; typedef unsigned int __attribute__ ((bitwidth(1907))) uint1907; typedef unsigned int __attribute__ ((bitwidth(1908))) uint1908; typedef unsigned int __attribute__ ((bitwidth(1909))) uint1909; typedef unsigned int __attribute__ ((bitwidth(1910))) uint1910; typedef unsigned int __attribute__ ((bitwidth(1911))) uint1911; typedef unsigned int __attribute__ ((bitwidth(1912))) uint1912; typedef unsigned int __attribute__ ((bitwidth(1913))) uint1913; typedef unsigned int __attribute__ ((bitwidth(1914))) uint1914; typedef unsigned int __attribute__ ((bitwidth(1915))) uint1915; typedef unsigned int __attribute__ ((bitwidth(1916))) uint1916; typedef unsigned int __attribute__ ((bitwidth(1917))) uint1917; typedef unsigned int __attribute__ ((bitwidth(1918))) uint1918; typedef unsigned int __attribute__ ((bitwidth(1919))) uint1919; typedef unsigned int __attribute__ ((bitwidth(1920))) uint1920; typedef unsigned int __attribute__ ((bitwidth(1921))) uint1921; typedef unsigned int __attribute__ ((bitwidth(1922))) uint1922; typedef unsigned int __attribute__ ((bitwidth(1923))) uint1923; typedef unsigned int __attribute__ ((bitwidth(1924))) uint1924; typedef unsigned int __attribute__ ((bitwidth(1925))) uint1925; typedef unsigned int __attribute__ ((bitwidth(1926))) uint1926; typedef unsigned int __attribute__ ((bitwidth(1927))) uint1927; typedef unsigned int __attribute__ ((bitwidth(1928))) uint1928; typedef unsigned int __attribute__ ((bitwidth(1929))) uint1929; typedef unsigned int __attribute__ ((bitwidth(1930))) uint1930; typedef unsigned int __attribute__ ((bitwidth(1931))) uint1931; typedef unsigned int __attribute__ ((bitwidth(1932))) uint1932; typedef unsigned int __attribute__ ((bitwidth(1933))) uint1933; typedef unsigned int __attribute__ ((bitwidth(1934))) uint1934; typedef unsigned int __attribute__ ((bitwidth(1935))) uint1935; typedef unsigned int __attribute__ ((bitwidth(1936))) uint1936; typedef unsigned int __attribute__ ((bitwidth(1937))) uint1937; typedef unsigned int __attribute__ ((bitwidth(1938))) uint1938; typedef unsigned int __attribute__ ((bitwidth(1939))) uint1939; typedef unsigned int __attribute__ ((bitwidth(1940))) uint1940; typedef unsigned int __attribute__ ((bitwidth(1941))) uint1941; typedef unsigned int __attribute__ ((bitwidth(1942))) uint1942; typedef unsigned int __attribute__ ((bitwidth(1943))) uint1943; typedef unsigned int __attribute__ ((bitwidth(1944))) uint1944; typedef unsigned int __attribute__ ((bitwidth(1945))) uint1945; typedef unsigned int __attribute__ ((bitwidth(1946))) uint1946; typedef unsigned int __attribute__ ((bitwidth(1947))) uint1947; typedef unsigned int __attribute__ ((bitwidth(1948))) uint1948; typedef unsigned int __attribute__ ((bitwidth(1949))) uint1949; typedef unsigned int __attribute__ ((bitwidth(1950))) uint1950; typedef unsigned int __attribute__ ((bitwidth(1951))) uint1951; typedef unsigned int __attribute__ ((bitwidth(1952))) uint1952; typedef unsigned int __attribute__ ((bitwidth(1953))) uint1953; typedef unsigned int __attribute__ ((bitwidth(1954))) uint1954; typedef unsigned int __attribute__ ((bitwidth(1955))) uint1955; typedef unsigned int __attribute__ ((bitwidth(1956))) uint1956; typedef unsigned int __attribute__ ((bitwidth(1957))) uint1957; typedef unsigned int __attribute__ ((bitwidth(1958))) uint1958; typedef unsigned int __attribute__ ((bitwidth(1959))) uint1959; typedef unsigned int __attribute__ ((bitwidth(1960))) uint1960; typedef unsigned int __attribute__ ((bitwidth(1961))) uint1961; typedef unsigned int __attribute__ ((bitwidth(1962))) uint1962; typedef unsigned int __attribute__ ((bitwidth(1963))) uint1963; typedef unsigned int __attribute__ ((bitwidth(1964))) uint1964; typedef unsigned int __attribute__ ((bitwidth(1965))) uint1965; typedef unsigned int __attribute__ ((bitwidth(1966))) uint1966; typedef unsigned int __attribute__ ((bitwidth(1967))) uint1967; typedef unsigned int __attribute__ ((bitwidth(1968))) uint1968; typedef unsigned int __attribute__ ((bitwidth(1969))) uint1969; typedef unsigned int __attribute__ ((bitwidth(1970))) uint1970; typedef unsigned int __attribute__ ((bitwidth(1971))) uint1971; typedef unsigned int __attribute__ ((bitwidth(1972))) uint1972; typedef unsigned int __attribute__ ((bitwidth(1973))) uint1973; typedef unsigned int __attribute__ ((bitwidth(1974))) uint1974; typedef unsigned int __attribute__ ((bitwidth(1975))) uint1975; typedef unsigned int __attribute__ ((bitwidth(1976))) uint1976; typedef unsigned int __attribute__ ((bitwidth(1977))) uint1977; typedef unsigned int __attribute__ ((bitwidth(1978))) uint1978; typedef unsigned int __attribute__ ((bitwidth(1979))) uint1979; typedef unsigned int __attribute__ ((bitwidth(1980))) uint1980; typedef unsigned int __attribute__ ((bitwidth(1981))) uint1981; typedef unsigned int __attribute__ ((bitwidth(1982))) uint1982; typedef unsigned int __attribute__ ((bitwidth(1983))) uint1983; typedef unsigned int __attribute__ ((bitwidth(1984))) uint1984; typedef unsigned int __attribute__ ((bitwidth(1985))) uint1985; typedef unsigned int __attribute__ ((bitwidth(1986))) uint1986; typedef unsigned int __attribute__ ((bitwidth(1987))) uint1987; typedef unsigned int __attribute__ ((bitwidth(1988))) uint1988; typedef unsigned int __attribute__ ((bitwidth(1989))) uint1989; typedef unsigned int __attribute__ ((bitwidth(1990))) uint1990; typedef unsigned int __attribute__ ((bitwidth(1991))) uint1991; typedef unsigned int __attribute__ ((bitwidth(1992))) uint1992; typedef unsigned int __attribute__ ((bitwidth(1993))) uint1993; typedef unsigned int __attribute__ ((bitwidth(1994))) uint1994; typedef unsigned int __attribute__ ((bitwidth(1995))) uint1995; typedef unsigned int __attribute__ ((bitwidth(1996))) uint1996; typedef unsigned int __attribute__ ((bitwidth(1997))) uint1997; typedef unsigned int __attribute__ ((bitwidth(1998))) uint1998; typedef unsigned int __attribute__ ((bitwidth(1999))) uint1999; typedef unsigned int __attribute__ ((bitwidth(2000))) uint2000; typedef unsigned int __attribute__ ((bitwidth(2001))) uint2001; typedef unsigned int __attribute__ ((bitwidth(2002))) uint2002; typedef unsigned int __attribute__ ((bitwidth(2003))) uint2003; typedef unsigned int __attribute__ ((bitwidth(2004))) uint2004; typedef unsigned int __attribute__ ((bitwidth(2005))) uint2005; typedef unsigned int __attribute__ ((bitwidth(2006))) uint2006; typedef unsigned int __attribute__ ((bitwidth(2007))) uint2007; typedef unsigned int __attribute__ ((bitwidth(2008))) uint2008; typedef unsigned int __attribute__ ((bitwidth(2009))) uint2009; typedef unsigned int __attribute__ ((bitwidth(2010))) uint2010; typedef unsigned int __attribute__ ((bitwidth(2011))) uint2011; typedef unsigned int __attribute__ ((bitwidth(2012))) uint2012; typedef unsigned int __attribute__ ((bitwidth(2013))) uint2013; typedef unsigned int __attribute__ ((bitwidth(2014))) uint2014; typedef unsigned int __attribute__ ((bitwidth(2015))) uint2015; typedef unsigned int __attribute__ ((bitwidth(2016))) uint2016; typedef unsigned int __attribute__ ((bitwidth(2017))) uint2017; typedef unsigned int __attribute__ ((bitwidth(2018))) uint2018; typedef unsigned int __attribute__ ((bitwidth(2019))) uint2019; typedef unsigned int __attribute__ ((bitwidth(2020))) uint2020; typedef unsigned int __attribute__ ((bitwidth(2021))) uint2021; typedef unsigned int __attribute__ ((bitwidth(2022))) uint2022; typedef unsigned int __attribute__ ((bitwidth(2023))) uint2023; typedef unsigned int __attribute__ ((bitwidth(2024))) uint2024; typedef unsigned int __attribute__ ((bitwidth(2025))) uint2025; typedef unsigned int __attribute__ ((bitwidth(2026))) uint2026; typedef unsigned int __attribute__ ((bitwidth(2027))) uint2027; typedef unsigned int __attribute__ ((bitwidth(2028))) uint2028; typedef unsigned int __attribute__ ((bitwidth(2029))) uint2029; typedef unsigned int __attribute__ ((bitwidth(2030))) uint2030; typedef unsigned int __attribute__ ((bitwidth(2031))) uint2031; typedef unsigned int __attribute__ ((bitwidth(2032))) uint2032; typedef unsigned int __attribute__ ((bitwidth(2033))) uint2033; typedef unsigned int __attribute__ ((bitwidth(2034))) uint2034; typedef unsigned int __attribute__ ((bitwidth(2035))) uint2035; typedef unsigned int __attribute__ ((bitwidth(2036))) uint2036; typedef unsigned int __attribute__ ((bitwidth(2037))) uint2037; typedef unsigned int __attribute__ ((bitwidth(2038))) uint2038; typedef unsigned int __attribute__ ((bitwidth(2039))) uint2039; typedef unsigned int __attribute__ ((bitwidth(2040))) uint2040; typedef unsigned int __attribute__ ((bitwidth(2041))) uint2041; typedef unsigned int __attribute__ ((bitwidth(2042))) uint2042; typedef unsigned int __attribute__ ((bitwidth(2043))) uint2043; typedef unsigned int __attribute__ ((bitwidth(2044))) uint2044; typedef unsigned int __attribute__ ((bitwidth(2045))) uint2045; typedef unsigned int __attribute__ ((bitwidth(2046))) uint2046; typedef unsigned int __attribute__ ((bitwidth(2047))) uint2047; typedef unsigned int __attribute__ ((bitwidth(2048))) uint2048; #pragma line 110 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" 2 #pragma line 131 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" typedef int __attribute__ ((bitwidth(64))) int64; typedef unsigned int __attribute__ ((bitwidth(64))) uint64; #pragma line 147 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_dt.h" // 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 #pragma line 58 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot/etc/autopilot_apint.h" 2 #pragma line 1 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" 1 /* autopilot_ssdm_bits.h */ /* #- (c) Copyright 2011-2017 Xilinx, Inc. All rights reserved. #- #- This file contains confidential and proprietary information #- of Xilinx, Inc. and is protected under U.S. and #- international copyright and other intellectual property #- laws. #- #- DISCLAIMER #- This disclaimer is not a license and does not grant any #- rights to the materials distributed herewith. Except as #- otherwise provided in a valid license issued to you by #- Xilinx, and to the maximum extent permitted by applicable #- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND #- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES #- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING #- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- #- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and #- (2) Xilinx shall not be liable (whether in contract or tort, #- including negligence, or under any other theory of #- liability) for any loss or damage of any kind or nature #- related to, arising under or in connection with these #- materials, including for any direct, or any indirect, #- special, incidental, or consequential loss or damage #- (including loss of data, profits, goodwill, or any type of #- loss or damage suffered as a result of any action brought #- by a third party) even if such damage or loss was #- reasonably foreseeable or Xilinx had been advised of the #- possibility of the same. #- #- CRITICAL APPLICATIONS #- Xilinx products are not designed or intended to be fail- #- safe, or for use in any application requiring fail-safe #- performance, such as life-support or safety devices or #- systems, Class III medical devices, nuclear facilities, #- applications related to the deployment of airbags, or any #- other applications that could lead to death, personal #- injury, or severe property or environmental damage #- (individually and collectively, "Critical #- Applications"). Customer assumes the sole risk and #- liability of any use of Xilinx products in Critical #- Applications, subject only to applicable laws and #- regulations governing limitations on product liability. #- #- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS #- PART OF THIS FILE AT ALL TIMES. #- ************************************************************************ #pragma empty_line * * $Id$ */ #pragma line 98 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Concatination ----------------*/ #pragma line 108 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Bit get/set ----------------*/ #pragma line 129 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Part get/set ----------------*/ #pragma empty_line /* GetRange: Notice that the order of the range indices comply with SystemC standards. */ #pragma line 143 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* SetRange: Notice that the order of the range indices comply with SystemC standards. */ #pragma line 156 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- Reduce operations ----------------*/ #pragma line 192 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" /* -- String-Integer conversions ----------------*/ #pragma line 358 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\etc/autopilot_ssdm_bits.h" // 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 #pragma line 59 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot/etc/autopilot_apint.h" 2 #pragma line 85 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot/etc/autopilot_apint.h" /************************************************/ #pragma line 114 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot/etc/autopilot_apint.h" // 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 #pragma line 78 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" 2 #pragma line 88 "C:/Xilinx/Vivado_HLS/2017.2/common/technology/autopilot\\ap_cint.h" // 67d7842dbbe25473c3c32b93c0da8047785f30d78e8a024de1b57352245f9689 #pragma line 3 "./fir.h" 2 #pragma empty_line #pragma empty_line #pragma empty_line typedef short coef_t; typedef short data_t; typedef int38 acc_t; #pragma line 2 "fir.c" 2 #pragma empty_line void fir ( data_t *y, data_t x ) { #pragma HLS INTERFACE s_axilite port=return bundle=fir_io #pragma line 6 "fir.c" #pragma HLS INTERFACE s_axilite port=y bundle=fir_io #pragma line 6 "fir.c" #pragma HLS INTERFACE s_axilite port=x bundle=fir_io #pragma line 6 "fir.c" const coef_t c[58 +1]={ #pragma empty_line #pragma line 1 "./fir_coef.dat" 1 -378, -73, 27, 170, 298, 352, 302, 168, 14, -80, -64, 53, 186, 216, 40, -356, -867, -1283, -1366, -954, -51, 1132, 2227, 2829, 2647, 1633, 25, -1712, -3042, 29229, -3042, -1712, 25, 1633, 2647, 2829, 2227, 1132, -51, -954, -1366, -1283, -867, -356, 40, 216, 186, 53, -64, -80, 14, 168, 302, 352, 298, 170, 27, -73, -378 #pragma line 9 "fir.c" 2 }; _ssdm_SpecConstant(c); #pragma line 9 "fir.c" #pragma empty_line #pragma empty_line static data_t shift_reg[58]; acc_t acc; int i; #pragma empty_line acc=(acc_t)shift_reg[58 -1]*(acc_t)c[58]; loop: for (i=58 -1;i!=0;i--) { #pragma HLS PIPELINE #pragma line 17 "fir.c" acc+=(acc_t)shift_reg[i-1]*(acc_t)c[i]; shift_reg[i]=shift_reg[i-1]; } acc+=(acc_t)x*(acc_t)c[0]; shift_reg[0]=x; *y = acc>>15; }
the_stack_data/5911.c
#include <stdio.h> int main() { unsigned short n; scanf("%hhu", &n); printf("Dc"); for(unsigned char i = 0; i < n; i++) printf("o"); printf("der"); return 0; }
the_stack_data/87638631.c
/* An example to demonstrate that Blast traverses a larger tree than tracer. The results are so far inconclusive. */ void main() { int w, x, y, z, v; int a, b, a1, a2, a3, a4, a5, a6, a7, a8, a9; int a10, x101; x=0; y=0; z=0; w=0; v=0; a=0; while (a<100) { if (a1<0) b++; else b+=2; if (a2<0) b++; else b+=2; if (a3<0) b++; else b+=2; if (a4<0) b++; else b+=2; if (a5<0) b++; else b+=2; if (a6<0) b++; else b+=2; if (a7<0) b++; else b+=2; if (a8<0) b++; else b+=2; if (a9<0) b++; else b+=2; if (a10<0) b++; else b+=2; a++; if (x>0) { ERROR: goto ERROR; } } /* if (y>0) { */ /* goto ERROR; */ /* } */ /* if (w>0) { */ /* goto ERROR; */ /* } */ /* if (v>0) { */ /* goto ERROR; */ /* } */ if (z>0) { goto ERROR; } }
the_stack_data/1232019.c
#include <stdio.h> int cat(int); int main(int argc, char * argv[]) { int x, i; do { scanf("%d", &x); } while(x<0); for(i=0; i<x; i++) { printf("C(%d) = %d\n", i, cat(i)); } printf("End.\n"); return 0; } int cat(int n) { int i, c; if(n == 0) c = 1; else { c = 0; for(i=0; i<=(n-1); i++) { c += (cat(i) * cat(n-i-1)); } // Piu ottimizzato: // for(i=0; i<n/2; i++) // cn *= cat(i) * cat(n-i-1); // cn *= 2; // if(n%2 != 0) // cn += cat(n/2) * cat(n-(n/2)-1); } return c; }
the_stack_data/57948972.c
/* * ferror .c - test if an error on a stream occurred */ /* $Header: /cvsup/minix/src/lib/stdio/ferror.c,v 1.1.1.1 2005/04/21 14:56:35 beng Exp $ */ #include <stdio.h> int (ferror)(FILE *stream) { return ferror(stream); }
the_stack_data/231393077.c
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <unistd.h> #define MQCONVSRV_QUEUE_KEY 10020 #define LOGIN_REQ 0 #define LOGOUT_REQ 1 #define SEND_MENSAGE_REQ 2 #define LIST_MENSAGE_REQ 3 #define POST_MENSAGE_REQ 4 #define SHOW_POST_REQ 5 #define DEL_MENSAGE_REQ 6 #define DEL_POST_REQ 7 #define DEL_POSTS_REQ 8 #define SHOW_USERS_REQ 9 #define SHOW_ID_REQ 10 #define STOP_SERVER_REQ 99 #define OK_RESP 0 #define ERROR_RESP 1 #define ALREADY_LOG_RESP 2 #define CANNOT_LOG_RESP 3 #define INVALID_REQ_RESP 4 #define MAXSIZE_MSGDATA 200 #define SERVER_ID 1 #define MAXSIZE_USERNAME 20 #define MAX_USERS 100 struct request_msg { long server_id; long client_id; int request; char requestdata[MAXSIZE_MSGDATA+1]; char client_name[MAXSIZE_USERNAME+1]; long index; }; struct response_msg { long client_id; int response; char responsedata[MAXSIZE_MSGDATA+1]; }; struct special_response_msg { long client_id; int response; char responsedata[2048]; }; struct user_record { long id; char name[MAXSIZE_USERNAME+1]; }; struct special_response_msg spc; /****************************************************************** * * Declarações de funções * *******************************************************************/ void main_screen(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void saida_cliente(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void send_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void list_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void post_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void list_posts(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void delete_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void delete_post(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void delete_all_posts(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void list_users(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void show_id(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); void help_menu(); void stop_all(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid); char *safegets(char *buffer, int buffersize); /****************************************************************** * * Rotinas Principal do Cliente * *******************************************************************/ void main() { int mqid; struct request_msg req_msg; struct response_msg resp_msg; struct user_record user_info; char tmp; mqid = msgget(MQCONVSRV_QUEUE_KEY, 0777); if (mqid == -1) { printf("msgget() falhou, fila nao existe, servidor nao inicializado\n"); exit(1); } // Faz o login no servidor printf("CentralSeccion\n"); printf("Entre com o nome de usuario:"); safegets(user_info.name,MAXSIZE_USERNAME); user_info.id = getpid(); // Prepara requisicao de login req_msg.request=LOGIN_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; strncpy(req_msg.requestdata,user_info.name,MAXSIZE_USERNAME); // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); // Espera pela mensagem de resposta especifica para este cliente // usando o PID do processo cliente como tipo de mensagem if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto da resposta printf("%s\n",resp_msg.responsedata); // Se nao aceitou login, sai do cliente if (resp_msg.response!=OK_RESP) exit(1); main_screen(req_msg, resp_msg, user_info, mqid); exit(0); } /****************************************************************** * * Tela Principal * *******************************************************************/ void main_screen(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ int opt; int stop_client; char tmp; // Laco de interface com o usuario stop_client=0; while(!stop_client) { system("clear"); printf("Qual opcao?\n"); printf(" 0: Sai do cliente;\n"); printf(" 1: Send <Usuario> <Texto>;\n"); printf(" 2: Msgs;\n"); printf(" 3: Post <mensagem>;\n"); printf(" 4: Show;\n"); printf(" 5: Del Msgs;\n"); printf(" 6: Del Post <Numero>;\n"); printf(" 7: Del Posts;\n"); printf(" 8: Users;\n"); printf(" 9: MyId;\n"); printf(" 10: Help;\n"); printf(" 11: Para o servidor e sai do cliente;\n"); printf("----------------------------------------\n"); printf("%s:", user_info.name); scanf("%d",&opt); scanf("%c",&tmp); // Necessario por problema na scanf() que retorna newline extra switch(opt){ //Client exit case 0: stop_client = 1; saida_cliente(req_msg, resp_msg, user_info, mqid); break; //send mensage case 1: send_mensage(req_msg, resp_msg, user_info, mqid); break; //List mensages case 2: list_mensage(req_msg, resp_msg, user_info, mqid); break; //Post a mensage case 3: post_mensage(req_msg, resp_msg, user_info, mqid); break; //List all posts case 4: list_posts(req_msg, resp_msg, user_info, mqid); break; //delete all mensages case 5: delete_mensage(req_msg, resp_msg, user_info, mqid); break; //Delete 1 post case 6: delete_post(req_msg, resp_msg, user_info, mqid); break; //Delete all posts case 7: delete_all_posts(req_msg, resp_msg, user_info, mqid); break; //Users case 8: list_users(req_msg, resp_msg, user_info, mqid); break; //ShowID case 9: show_id(req_msg, resp_msg, user_info, mqid); break; //Menu case 10: help_menu(); break; //Stop server and client case 11: stop_client = 1; stop_all(req_msg, resp_msg, user_info, mqid); break; default: printf("Opcao invalida\n"); break; } } } /****************************************************************** * * Funções de envio para servidor * *******************************************************************/ void saida_cliente(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ // Prepara requisicao de logout req_msg.request=LOGOUT_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; strncpy(req_msg.requestdata,user_info.name,MAXSIZE_USERNAME); // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); // usando o PID do processo cliente como tipo de mensagem if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } //Apresenta o texto de resposta printf("%s\n", resp_msg.responsedata); } void send_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ //Seleciona Usuario a ser enviado printf("Qual usuario será enviado a mensagem:"); safegets(req_msg.client_name,MAXSIZE_USERNAME); // Prepara envio printf("Entre com o texto a ser enviado:\n"); safegets(req_msg.requestdata,MAXSIZE_MSGDATA); req_msg.request=SEND_MENSAGE_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens':\n"); printf("%s\n",resp_msg.responsedata); sleep(5); } void list_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ req_msg.request=LIST_MENSAGE_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens':\n"); printf("%s\n",spc.responsedata); sleep(5); } void post_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ // Prepara envio printf("Entre com o texto a ser enviado:\n"); safegets(req_msg.requestdata,MAXSIZE_MSGDATA); req_msg.request=POST_MENSAGE_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens':\n"); printf("%s\n",resp_msg.responsedata); sleep(2); } void list_posts(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ req_msg.request=SHOW_POST_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&spc,sizeof(struct special_response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens:\n"); printf("%s\n",spc.responsedata); sleep(5); } void delete_mensage(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ req_msg.request=DEL_MENSAGE_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; } void delete_post(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ printf("Qual o indice do post que deve ser excluido:"); safegets(req_msg.requestdata,MAXSIZE_USERNAME); req_msg.request=DEL_POST_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens':\n"); printf("%s\n",resp_msg.responsedata); sleep(2);} void delete_all_posts(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ req_msg.request=DEL_POSTS_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens':\n"); printf("%s\n",resp_msg.responsedata); sleep(2); } void list_users(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ req_msg.request=SHOW_USERS_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&spc,sizeof(struct special_response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens:\n"); printf("%s\n",spc.responsedata); sleep(5); } void show_id(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ req_msg.request=SHOW_ID_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; strncpy(req_msg.requestdata,user_info.name,MAXSIZE_USERNAME); msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto convertido printf("Mensagens:\n"); printf("Nome = %s\n",resp_msg.responsedata); printf("ID = %d\n",resp_msg.client_id); sleep(5); } void help_menu(){ system("clear"); printf("HELP\n"); printf(" 0: Sai do cliente (Fecha janela cliente);\n"); printf(" 1: Send <Usuario> <Texto> (Envia mensagem para usuario definido);\n"); printf(" 2: Msgs (Lista todas as mensagens recebidas);\n"); printf(" 3: Post <mensagem> (Posta uma mensagem no forum comunitario);\n"); printf(" 4: Show (Mostra mensagens do forum comunitario);\n"); printf(" 5: Del Msgs (Deleta todas as mensagens enviadas ao usuario)\n"); printf(" 6: Del Post <Numero> (Deleta post com numero definido pelo usuario);\n"); printf(" 7: Del Posts (Deleta todos os posts do forum);\n"); printf(" 8: Users (Lista todos os usuarios logados)\n"); printf(" 9: MyId (Mostra ID do usuario);\n"); printf(" 10: Help (Menu de ajuda)\n"); printf(" 11: Para o servidor e sai do cliente (Parada Total do servidor e saida do cliente);\n"); sleep(5); } void stop_all(struct request_msg req_msg, struct response_msg resp_msg, struct user_record user_info, int mqid){ // Prepara requisicao de parada de servidor req_msg.request = STOP_SERVER_REQ; req_msg.server_id = SERVER_ID; req_msg.client_id = user_info.id; // Envia requisicao ao servidor msgsnd(mqid,&req_msg,sizeof(struct request_msg)-sizeof(long),0); // usando o PID do processo cliente como tipo de mensagem if (msgrcv(mqid,&resp_msg,sizeof(struct response_msg)-sizeof(long),user_info.id,0) < 0) { printf("msgrcv() falhou\n"); exit(1); } // Apresenta o texto da resposta printf("%s\n",resp_msg.responsedata); } /****************************************************************** * * Rotinas Utilitarias * *******************************************************************/ char *safegets(char *buffer, int buffersize) { char *str; int slen; str = fgets(buffer,buffersize,stdin); if (str!=NULL) { slen = strlen(str); if (slen>0) str[slen-1] = '\0'; } return str; }
the_stack_data/104267.c
#include <stdio.h> int main () { printf("start testing FS prefix ..\n"); fflush(stdout); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x19, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1d, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1e, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x40, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x44, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x80, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x84, 0x0, 0x0, 0x0, 0x0, 0x0" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x5A, 0x22" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x9C, 0x1D, 0x11, 0x22, 0x33, 0x44" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0x04, 0x60" :::"cc","memory"); __asm__ __volatile__ (".byte 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0x66, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf2, 0x66, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); __asm__ __volatile__ (".byte 0xf3, 0x66, 0x64, 0x0f, 0x1f, 0xff" :::"cc","memory"); printf ("done\n"); return 0; }
the_stack_data/192329401.c
#include <stdio.h> void print_simple(int *board) { for (int i = 0; i < 81; i++) printf("%1d", board[i]); putchar('\n'); } void print_pretty(int *board) { putchar('\n'); for (int i = 0; i < 9; i++) { if (!(i % 3) && i) putchar('\n'); for (int k = 9 * i; k < 9 * (i+1); k++) { if (!(k % 3)) putchar(' '); if (board[k]) printf("%2i", board[k]); else printf(" ."); } putchar('\n'); } putchar('\n'); }
the_stack_data/123521.c
#include <stdio.h> #include <stdlib.h> #define MAX_INPUT_LENGTH 100 extern char *sub_string(char *, int, int); int main() { int start_index, end_index; char *in_string = (char *)malloc(MAX_INPUT_LENGTH * sizeof(char)); char *out_string; scanf("%s\n%d\n%d", in_string, &start_index, &end_index); out_string = (char *)sub_string(in_string, start_index, end_index); printf("%s", out_string); return 0; }
the_stack_data/165765329.c
#include <sys/syscall.h> /* This is a version (aka dlmalloc) of malloc/free/realloc written by Doug Lea and released to the public domain, as explained at http://creativecommons.org/publicdomain/zero/1.0/ Send questions, comments, complaints, performance data, etc to [email protected] * Version 2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea Note: There may be an updated version of this malloc obtainable at ftp://gee.cs.oswego.edu/pub/misc/malloc.c Check before installing! * Quickstart This library is all in one file to simplify the most common usage: ftp it, compile it (-O3), and link it into another program. All of the compile-time options default to reasonable values for use on most platforms. You might later want to step through various compile-time and dynamic tuning options. For convenience, an include file for code using this malloc is at: ftp://gee.cs.oswego.edu/pub/misc/malloc-2.8.6.h You don't really need this .h file unless you call functions not defined in your system include files. The .h file contains only the excerpts from this file needed for using this malloc on ANSI C/C++ systems, so long as you haven't changed compile-time options about naming and tuning parameters. If you do, then you can create your own malloc.h that does include all settings by cutting at the point indicated below. Note that you may already by default be using a C library containing a malloc that is based on some version of this malloc (for example in linux). You might still want to use the one in this file to customize settings or to avoid overheads associated with library versions. * Vital statistics: Supported pointer/size_t representation: 4 or 8 bytes size_t MUST be an unsigned type of the same width as pointers. (If you are using an ancient system that declares size_t as a signed type, or need it to be a different width than pointers, you can use a previous release of this malloc (e.g. 2.7.2) supporting these.) Alignment: 8 bytes (minimum) This suffices for nearly all current machines and C compilers. However, you can define MALLOC_ALIGNMENT to be wider than this if necessary (up to 128bytes), at the expense of using more space. Minimum overhead per allocated chunk: 4 or 8 bytes (if 4byte sizes) 8 or 16 bytes (if 8byte sizes) Each malloced chunk has a hidden word of overhead holding size and status information, and additional cross-check word if FOOTERS is defined. Minimum allocated size: 4-byte ptrs: 16 bytes (including overhead) 8-byte ptrs: 32 bytes (including overhead) Even a request for zero bytes (i.e., malloc(0)) returns a pointer to something of the minimum allocatable size. The maximum overhead wastage (i.e., number of extra bytes allocated than were requested in malloc) is less than or equal to the minimum size, except for requests >= mmap_threshold that are serviced via mmap(), where the worst case wastage is about 32 bytes plus the remainder from a system page (the minimal mmap unit); typically 4096 or 8192 bytes. Security: static-safe; optionally more or less The "security" of malloc refers to the ability of malicious code to accentuate the effects of errors (for example, freeing space that is not currently malloc'ed or overwriting past the ends of chunks) in code that calls malloc. This malloc guarantees not to modify any memory locations below the base of heap, i.e., static variables, even in the presence of usage errors. The routines additionally detect most improper frees and reallocs. All this holds as long as the static bookkeeping for malloc itself is not corrupted by some other means. This is only one aspect of security -- these checks do not, and cannot, detect all possible programming errors. If FOOTERS is defined nonzero, then each allocated chunk carries an additional check word to verify that it was malloced from its space. These check words are the same within each execution of a program using malloc, but differ across executions, so externally crafted fake chunks cannot be freed. This improves security by rejecting frees/reallocs that could corrupt heap memory, in addition to the checks preventing writes to statics that are always on. This may further improve security at the expense of time and space overhead. (Note that FOOTERS may also be worth using with MSPACES.) By default detected errors cause the program to abort (calling "abort()"). You can override this to instead proceed past errors by defining PROCEED_ON_ERROR. In this case, a bad free has no effect, and a malloc that encounters a bad address caused by user overwrites will ignore the bad address by dropping pointers and indices to all known memory. This may be appropriate for programs that should continue if at all possible in the face of programming errors, although they may run out of memory because dropped memory is never reclaimed. If you don't like either of these options, you can define CORRUPTION_ERROR_ACTION and USAGE_ERROR_ACTION to do anything else. And if if you are sure that your program using malloc has no errors or vulnerabilities, you can define INSECURE to 1, which might (or might not) provide a small performance improvement. It is also possible to limit the maximum total allocatable space, using malloc_set_footprint_limit. This is not designed as a security feature in itself (calls to set limits are not screened or privileged), but may be useful as one aspect of a secure implementation. Thread-safety: NOT thread-safe unless USE_LOCKS defined non-zero When USE_LOCKS is defined, each public call to malloc, free, etc is surrounded with a lock. By default, this uses a plain pthread mutex, win32 critical section, or a spin-lock if if available for the platform and not disabled by setting USE_SPIN_LOCKS=0. However, if USE_RECURSIVE_LOCKS is defined, recursive versions are used instead (which are not required for base functionality but may be needed in layered extensions). Using a global lock is not especially fast, and can be a major bottleneck. It is designed only to provide minimal protection in concurrent environments, and to provide a basis for extensions. If you are using malloc in a concurrent program, consider instead using nedmalloc (http://www.nedprod.com/programs/portable/nedmalloc/) or ptmalloc (See http://www.malloc.de), which are derived from versions of this malloc. System requirements: Any combination of MORECORE and/or MMAP/MUNMAP This malloc can use unix sbrk or any emulation (invoked using the CALL_MORECORE macro) and/or mmap/munmap or any emulation (invoked using CALL_MMAP/CALL_MUNMAP) to get and release system memory. On most unix systems, it tends to work best if both MORECORE and MMAP are enabled. On Win32, it uses emulations based on VirtualAlloc. It also uses common C library functions like memset. Compliance: I believe it is compliant with the Single Unix Specification (See http://www.unix.org). Also SVID/XPG, ANSI C, and probably others as well. * Overview of algorithms This is not the fastest, most space-conserving, most portable, or most tunable malloc ever written. However it is among the fastest while also being among the most space-conserving, portable and tunable. Consistent balance across these factors results in a good general-purpose allocator for malloc-intensive programs. In most ways, this malloc is a best-fit allocator. Generally, it chooses the best-fitting existing chunk for a request, with ties broken in approximately least-recently-used order. (This strategy normally maintains low fragmentation.) However, for requests less than 256bytes, it deviates from best-fit when there is not an exactly fitting available chunk by preferring to use space adjacent to that used for the previous small request, as well as by breaking ties in approximately most-recently-used order. (These enhance locality of series of small allocations.) And for very large requests (>= 256Kb by default), it relies on system memory mapping facilities, if supported. (This helps avoid carrying around and possibly fragmenting memory used only for large chunks.) All operations (except malloc_stats and mallinfo) have execution times that are bounded by a constant factor of the number of bits in a size_t, not counting any clearing in calloc or copying in realloc, or actions surrounding MORECORE and MMAP that have times proportional to the number of non-contiguous regions returned by system allocation routines, which is often just 1. In real-time applications, you can optionally suppress segment traversals using NO_SEGMENT_TRAVERSAL, which assures bounded execution even when system allocators return non-contiguous spaces, at the typical expense of carrying around more memory and increased fragmentation. The implementation is not very modular and seriously overuses macros. Perhaps someday all C compilers will do as good a job inlining modular code as can now be done by brute-force expansion, but now, enough of them seem not to. Some compilers issue a lot of warnings about code that is dead/unreachable only on some platforms, and also about intentional uses of negation on unsigned types. All known cases of each can be ignored. For a longer but out of date high-level description, see http://gee.cs.oswego.edu/dl/html/malloc.html * MSPACES If MSPACES is defined, then in addition to malloc, free, etc., this file also defines mspace_malloc, mspace_free, etc. These are versions of malloc routines that take an "mspace" argument obtained using create_mspace, to control all internal bookkeeping. If ONLY_MSPACES is defined, only these versions are compiled. So if you would like to use this allocator for only some allocations, and your system malloc for others, you can compile with ONLY_MSPACES and then do something like... static mspace mymspace = create_mspace(0,0); // for example #define mymalloc(bytes) mspace_malloc(mymspace, bytes) (Note: If you only need one instance of an mspace, you can instead use "USE_DL_PREFIX" to relabel the global malloc.) You can similarly create thread-local allocators by storing mspaces as thread-locals. For example: static __thread mspace tlms = 0; void* tlmalloc(size_t bytes) { if (tlms == 0) tlms = create_mspace(0, 0); return mspace_malloc(tlms, bytes); } void tlfree(void* mem) { mspace_free(tlms, mem); } Unless FOOTERS is defined, each mspace is completely independent. You cannot allocate from one and free to another (although conformance is only weakly checked, so usage errors are not always caught). If FOOTERS is defined, then each chunk carries around a tag indicating its originating mspace, and frees are directed to their originating spaces. Normally, this requires use of locks. ------------------------- Compile-time options --------------------------- Be careful in setting #define values for numerical constants of type size_t. On some systems, literal values are not automatically extended to size_t precision unless they are explicitly casted. You can also use the symbolic values MAX_SIZE_T, SIZE_T_ONE, etc below. WIN32 default: defined if _WIN32 defined Defining WIN32 sets up defaults for MS environment and compilers. Otherwise defaults are for unix. Beware that there seem to be some cases where this malloc might not be a pure drop-in replacement for Win32 malloc: Random-looking failures from Win32 GDI API's (eg; SetDIBits()) may be due to bugs in some video driver implementations when pixel buffers are malloc()ed, and the region spans more than one VirtualAlloc()ed region. Because dlmalloc uses a small (64Kb) default granularity, pixel buffers may straddle virtual allocation regions more often than when using the Microsoft allocator. You can avoid this by using VirtualAlloc() and VirtualFree() for all pixel buffers rather than using malloc(). If this is not possible, recompile this malloc with a larger DEFAULT_GRANULARITY. Note: in cases where MSC and gcc (cygwin) are known to differ on WIN32, conditions use _MSC_VER to distinguish them. DLMALLOC_EXPORT default: extern Defines how public APIs are declared. If you want to export via a Windows DLL, you might define this as #define DLMALLOC_EXPORT extern __declspec(dllexport) If you want a POSIX ELF shared object, you might use #define DLMALLOC_EXPORT extern __attribute__((visibility("default"))) MALLOC_ALIGNMENT default: (size_t)(2 * sizeof(void *)) Controls the minimum alignment for malloc'ed chunks. It must be a power of two and at least 8, even on machines for which smaller alignments would suffice. It may be defined as larger than this though. Note however that code and data structures are optimized for the case of 8-byte alignment. MSPACES default: 0 (false) If true, compile in support for independent allocation spaces. This is only supported if HAVE_MMAP is true. ONLY_MSPACES default: 0 (false) If true, only compile in mspace versions, not regular versions. USE_LOCKS default: 0 (false) Causes each call to each public routine to be surrounded with pthread or WIN32 mutex lock/unlock. (If set true, this can be overridden on a per-mspace basis for mspace versions.) If set to a non-zero value other than 1, locks are used, but their implementation is left out, so lock functions must be supplied manually, as described below. USE_SPIN_LOCKS default: 1 iff USE_LOCKS and spin locks available If true, uses custom spin locks for locking. This is currently supported only gcc >= 4.1, older gccs on x86 platforms, and recent MS compilers. Otherwise, posix locks or win32 critical sections are used. USE_RECURSIVE_LOCKS default: not defined If defined nonzero, uses recursive (aka reentrant) locks, otherwise uses plain mutexes. This is not required for malloc proper, but may be needed for layered allocators such as nedmalloc. LOCK_AT_FORK default: not defined If defined nonzero, performs pthread_atfork upon initialization to initialize child lock while holding parent lock. The implementation assumes that pthread locks (not custom locks) are being used. In other cases, you may need to customize the implementation. FOOTERS default: 0 If true, provide extra checking and dispatching by placing information in the footers of allocated chunks. This adds space and time overhead. INSECURE default: 0 If true, omit checks for usage errors and heap space overwrites. USE_DL_PREFIX default: NOT defined Causes compiler to prefix all public routines with the string 'dl'. This can be useful when you only want to use this malloc in one part of a program, using your regular system malloc elsewhere. MALLOC_INSPECT_ALL default: NOT defined If defined, compiles malloc_inspect_all and mspace_inspect_all, that perform traversal of all heap space. Unless access to these functions is otherwise restricted, you probably do not want to include them in secure implementations. ABORT default: defined as abort() Defines how to abort on failed checks. On most systems, a failed check cannot die with an "assert" or even print an informative message, because the underlying print routines in turn call malloc, which will fail again. Generally, the best policy is to simply call abort(). It's not very useful to do more than this because many errors due to overwriting will show up as address faults (null, odd addresses etc) rather than malloc-triggered checks, so will also abort. Also, most compilers know that abort() does not return, so can better optimize code conditionally calling it. PROCEED_ON_ERROR default: defined as 0 (false) Controls whether detected bad addresses cause them to bypassed rather than aborting. If set, detected bad arguments to free and realloc are ignored. And all bookkeeping information is zeroed out upon a detected overwrite of freed heap space, thus losing the ability to ever return it from malloc again, but enabling the application to proceed. If PROCEED_ON_ERROR is defined, the static variable malloc_corruption_error_count is compiled in and can be examined to see if errors have occurred. This option generates slower code than the default abort policy. DEBUG default: NOT defined The DEBUG setting is mainly intended for people trying to modify this code or diagnose problems when porting to new platforms. However, it may also be able to better isolate user errors than just using runtime checks. The assertions in the check routines spell out in more detail the assumptions and invariants underlying the algorithms. The checking is fairly extensive, and will slow down execution noticeably. Calling malloc_stats or mallinfo with DEBUG set will attempt to check every non-mmapped allocated and free chunk in the course of computing the summaries. ABORT_ON_ASSERT_FAILURE default: defined as 1 (true) Debugging assertion failures can be nearly impossible if your version of the assert macro causes malloc to be called, which will lead to a cascade of further failures, blowing the runtime stack. ABORT_ON_ASSERT_FAILURE cause assertions failures to call abort(), which will usually make debugging easier. MALLOC_FAILURE_ACTION default: sets errno to ENOMEM, or no-op on win32 The action to take before "return 0" when malloc fails to be able to return memory because there is none available. HAVE_MORECORE default: 1 (true) unless win32 or ONLY_MSPACES True if this system supports sbrk or an emulation of it. MORECORE default: sbrk The name of the sbrk-style system routine to call to obtain more memory. See below for guidance on writing custom MORECORE functions. The type of the argument to sbrk/MORECORE varies across systems. It cannot be size_t, because it supports negative arguments, so it is normally the signed type of the same width as size_t (sometimes declared as "intptr_t"). It doesn't much matter though. Internally, we only call it with arguments less than half the max value of a size_t, which should work across all reasonable possibilities, although sometimes generating compiler warnings. MORECORE_CONTIGUOUS default: 1 (true) if HAVE_MORECORE If true, take advantage of fact that consecutive calls to MORECORE with positive arguments always return contiguous increasing addresses. This is true of unix sbrk. It does not hurt too much to set it true anyway, since malloc copes with non-contiguities. Setting it false when definitely non-contiguous saves time and possibly wasted space it would take to discover this though. MORECORE_CANNOT_TRIM default: NOT defined True if MORECORE cannot release space back to the system when given negative arguments. This is generally necessary only if you are using a hand-crafted MORECORE function that cannot handle negative arguments. NO_SEGMENT_TRAVERSAL default: 0 If non-zero, suppresses traversals of memory segments returned by either MORECORE or CALL_MMAP. This disables merging of segments that are contiguous, and selectively releasing them to the OS if unused, but bounds execution times. HAVE_MMAP default: 1 (true) True if this system supports mmap or an emulation of it. If so, and HAVE_MORECORE is not true, MMAP is used for all system allocation. If set and HAVE_MORECORE is true as well, MMAP is primarily used to directly allocate very large blocks. It is also used as a backup strategy in cases where MORECORE fails to provide space from system. Note: A single call to MUNMAP is assumed to be able to unmap memory that may have be allocated using multiple calls to MMAP, so long as they are adjacent. HAVE_MREMAP default: 1 on linux, else 0 If true realloc() uses mremap() to re-allocate large blocks and extend or shrink allocation spaces. MMAP_CLEARS default: 1 except on WINCE. True if mmap clears memory so calloc doesn't need to. This is true for standard unix mmap using /dev/zero and on WIN32 except for WINCE. USE_BUILTIN_FFS default: 0 (i.e., not used) Causes malloc to use the builtin ffs() function to compute indices. Some compilers may recognize and intrinsify ffs to be faster than the supplied C version. Also, the case of x86 using gcc is special-cased to an asm instruction, so is already as fast as it can be, and so this setting has no effect. Similarly for Win32 under recent MS compilers. (On most x86s, the asm version is only slightly faster than the C version.) malloc_getpagesize default: derive from system includes, or 4096. The system page size. To the extent possible, this malloc manages memory from the system in page-size units. This may be (and usually is) a function rather than a constant. This is ignored if WIN32, where page size is determined using getSystemInfo during initialization. USE_DEV_RANDOM default: 0 (i.e., not used) Causes malloc to use /dev/random to initialize secure magic seed for stamping footers. Otherwise, the current time is used. NO_MALLINFO default: 0 If defined, don't compile "mallinfo". This can be a simple way of dealing with mismatches between system declarations and those in this file. MALLINFO_FIELD_TYPE default: size_t The type of the fields in the mallinfo struct. This was originally defined as "int" in SVID etc, but is more usefully defined as size_t. The value is used only if HAVE_USR_INCLUDE_MALLOC_H is not set NO_MALLOC_STATS default: 0 If defined, don't compile "malloc_stats". This avoids calls to fprintf and bringing in stdio dependencies you might not want. REALLOC_ZERO_BYTES_FREES default: not defined This should be set if a call to realloc with zero bytes should be the same as a call to free. Some people think it should. Otherwise, since this malloc returns a unique pointer for malloc(0), so does realloc(p, 0). LACKS_UNISTD_H, LACKS_FCNTL_H, LACKS_SYS_PARAM_H, LACKS_SYS_MMAN_H LACKS_STRINGS_H, LACKS_STRING_H, LACKS_SYS_TYPES_H, LACKS_ERRNO_H LACKS_STDLIB_H LACKS_SCHED_H LACKS_TIME_H default: NOT defined unless on WIN32 Define these if your system does not have these header files. You might need to manually insert some of the declarations they provide. DEFAULT_GRANULARITY default: page size if MORECORE_CONTIGUOUS, system_info.dwAllocationGranularity in WIN32, otherwise 64K. Also settable using mallopt(M_GRANULARITY, x) The unit for allocating and deallocating memory from the system. On most systems with contiguous MORECORE, there is no reason to make this more than a page. However, systems with MMAP tend to either require or encourage larger granularities. You can increase this value to prevent system allocation functions to be called so often, especially if they are slow. The value must be at least one page and must be a power of two. Setting to 0 causes initialization to either page size or win32 region size. (Note: In previous versions of malloc, the equivalent of this option was called "TOP_PAD") DEFAULT_TRIM_THRESHOLD default: 2MB Also settable using mallopt(M_TRIM_THRESHOLD, x) The maximum amount of unused top-most memory to keep before releasing via malloc_trim in free(). Automatic trimming is mainly useful in long-lived programs using contiguous MORECORE. Because trimming via sbrk can be slow on some systems, and can sometimes be wasteful (in cases where programs immediately afterward allocate more large chunks) the value should be high enough so that your overall system performance would improve by releasing this much memory. As a rough guide, you might set to a value close to the average size of a process (program) running on your system. Releasing this much memory would allow such a process to run in memory. Generally, it is worth tuning trim thresholds when a program undergoes phases where several large chunks are allocated and released in ways that can reuse each other's storage, perhaps mixed with phases where there are no such chunks at all. The trim value must be greater than page size to have any useful effect. To disable trimming completely, you can set to MAX_SIZE_T. Note that the trick some people use of mallocing a huge space and then freeing it at program startup, in an attempt to reserve system memory, doesn't have the intended effect under automatic trimming, since that memory will immediately be returned to the system. DEFAULT_MMAP_THRESHOLD default: 256K Also settable using mallopt(M_MMAP_THRESHOLD, x) The request size threshold for using MMAP to directly service a request. Requests of at least this size that cannot be allocated using already-existing space will be serviced via mmap. (If enough normal freed space already exists it is used instead.) Using mmap segregates relatively large chunks of memory so that they can be individually obtained and released from the host system. A request serviced through mmap is never reused by any other request (at least not directly; the system may just so happen to remap successive requests to the same locations). Segregating space in this way has the benefits that: Mmapped space can always be individually released back to the system, which helps keep the system level memory demands of a long-lived program low. Also, mapped memory doesn't become `locked' between other chunks, as can happen with normally allocated chunks, which means that even trimming via malloc_trim would not release them. However, it has the disadvantage that the space cannot be reclaimed, consolidated, and then used to service later requests, as happens with normal chunks. The advantages of mmap nearly always outweigh disadvantages for "large" chunks, but the value of "large" may vary across systems. The default is an empirically derived value that works well in most systems. You can disable mmap by setting to MAX_SIZE_T. MAX_RELEASE_CHECK_RATE default: 4095 unless not HAVE_MMAP The number of consolidated frees between checks to release unused segments when freeing. When using non-contiguous segments, especially with multiple mspaces, checking only for topmost space doesn't always suffice to trigger trimming. To compensate for this, free() will, with a period of MAX_RELEASE_CHECK_RATE (or the current number of segments, if greater) try to release unused segments to the OS when freeing chunks that result in consolidation. The best value for this parameter is a compromise between slowing down frees with relatively costly checks that rarely trigger versus holding on to unused memory. To effectively disable, set to MAX_SIZE_T. This may lead to a very slight speed improvement at the expense of carrying around more memory. */ /* Version identifier to allow people to support multiple versions */ #ifndef DLMALLOC_VERSION #define DLMALLOC_VERSION 20806 #endif /* DLMALLOC_VERSION */ #ifndef DLMALLOC_EXPORT #define DLMALLOC_EXPORT extern #endif #ifndef WIN32 #ifdef _WIN32 #define WIN32 1 #endif /* _WIN32 */ #ifdef _WIN32_WCE #define LACKS_FCNTL_H #define WIN32 1 #endif /* _WIN32_WCE */ #endif /* WIN32 */ #ifdef WIN32 #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <tchar.h> #define HAVE_MMAP 1 #define HAVE_MORECORE 0 #define LACKS_UNISTD_H #define LACKS_SYS_PARAM_H #define LACKS_SYS_MMAN_H #define LACKS_STRING_H #define LACKS_STRINGS_H #define LACKS_SYS_TYPES_H #define LACKS_ERRNO_H #define LACKS_SCHED_H #ifndef MALLOC_FAILURE_ACTION #define MALLOC_FAILURE_ACTION #endif /* MALLOC_FAILURE_ACTION */ #ifndef MMAP_CLEARS #ifdef _WIN32_WCE /* WINCE reportedly does not clear */ #define MMAP_CLEARS 0 #else #define MMAP_CLEARS 1 #endif /* _WIN32_WCE */ #endif /*MMAP_CLEARS */ #endif /* WIN32 */ #if defined(DARWIN) || defined(_DARWIN) /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */ #ifndef HAVE_MORECORE #define HAVE_MORECORE 0 #define HAVE_MMAP 1 /* OSX allocators provide 16 byte alignment */ #ifndef MALLOC_ALIGNMENT #define MALLOC_ALIGNMENT ((size_t)16U) #endif #endif /* HAVE_MORECORE */ #endif /* DARWIN */ #ifndef LACKS_SYS_TYPES_H #include <sys/types.h> /* For size_t */ #endif /* LACKS_SYS_TYPES_H */ /* The maximum possible size_t value has all bits set */ #define MAX_SIZE_T (~(size_t)0) #ifndef USE_LOCKS /* ensure true if spin or recursive locks set */ #define USE_LOCKS ((defined(USE_SPIN_LOCKS) && USE_SPIN_LOCKS != 0) || \ (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0)) #endif /* USE_LOCKS */ #if USE_LOCKS /* Spin locks for gcc >= 4.1, older gcc on x86, MSC >= 1310 */ #if ((defined(__GNUC__) && \ ((__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) || \ defined(__i386__) || defined(__x86_64__))) || \ (defined(_MSC_VER) && _MSC_VER>=1310)) #ifndef USE_SPIN_LOCKS #define USE_SPIN_LOCKS 1 #endif /* USE_SPIN_LOCKS */ #elif USE_SPIN_LOCKS #error "USE_SPIN_LOCKS defined without implementation" #endif /* ... locks available... */ #elif !defined(USE_SPIN_LOCKS) #define USE_SPIN_LOCKS 0 #endif /* USE_LOCKS */ #ifndef ONLY_MSPACES #define ONLY_MSPACES 0 #endif /* ONLY_MSPACES */ #ifndef MSPACES #if ONLY_MSPACES #define MSPACES 1 #else /* ONLY_MSPACES */ #define MSPACES 0 #endif /* ONLY_MSPACES */ #endif /* MSPACES */ #ifndef MALLOC_ALIGNMENT #define MALLOC_ALIGNMENT ((size_t)(2 * sizeof(void *))) #endif /* MALLOC_ALIGNMENT */ #ifndef FOOTERS #define FOOTERS 0 #endif /* FOOTERS */ #ifndef ABORT #define ABORT abort() #endif /* ABORT */ #ifndef ABORT_ON_ASSERT_FAILURE #define ABORT_ON_ASSERT_FAILURE 1 #endif /* ABORT_ON_ASSERT_FAILURE */ #ifndef PROCEED_ON_ERROR #define PROCEED_ON_ERROR 0 #endif /* PROCEED_ON_ERROR */ #ifndef INSECURE #define INSECURE 0 #endif /* INSECURE */ #ifndef MALLOC_INSPECT_ALL #define MALLOC_INSPECT_ALL 0 #endif /* MALLOC_INSPECT_ALL */ #ifndef HAVE_MMAP #define HAVE_MMAP 1 #endif /* HAVE_MMAP */ #ifndef MMAP_CLEARS #define MMAP_CLEARS 1 #endif /* MMAP_CLEARS */ #ifndef HAVE_MREMAP #ifdef linux #define HAVE_MREMAP 1 #define _GNU_SOURCE /* Turns on mremap() definition */ #else /* linux */ #define HAVE_MREMAP 0 #endif /* linux */ #endif /* HAVE_MREMAP */ #ifndef MALLOC_FAILURE_ACTION #define MALLOC_FAILURE_ACTION errno = ENOMEM; #endif /* MALLOC_FAILURE_ACTION */ #ifndef HAVE_MORECORE #if ONLY_MSPACES #define HAVE_MORECORE 0 #else /* ONLY_MSPACES */ #define HAVE_MORECORE 1 #endif /* ONLY_MSPACES */ #endif /* HAVE_MORECORE */ #if !HAVE_MORECORE #define MORECORE_CONTIGUOUS 0 #else /* !HAVE_MORECORE */ #define MORECORE_DEFAULT sbrk #ifndef MORECORE_CONTIGUOUS #define MORECORE_CONTIGUOUS 1 #endif /* MORECORE_CONTIGUOUS */ #endif /* HAVE_MORECORE */ #ifndef DEFAULT_GRANULARITY #if (MORECORE_CONTIGUOUS || defined(WIN32)) #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ #else /* MORECORE_CONTIGUOUS */ #define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U) #endif /* MORECORE_CONTIGUOUS */ #endif /* DEFAULT_GRANULARITY */ #ifndef DEFAULT_TRIM_THRESHOLD #ifndef MORECORE_CANNOT_TRIM #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) #else /* MORECORE_CANNOT_TRIM */ #define DEFAULT_TRIM_THRESHOLD MAX_SIZE_T #endif /* MORECORE_CANNOT_TRIM */ #endif /* DEFAULT_TRIM_THRESHOLD */ #ifndef DEFAULT_MMAP_THRESHOLD #if HAVE_MMAP #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) #else /* HAVE_MMAP */ #define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T #endif /* HAVE_MMAP */ #endif /* DEFAULT_MMAP_THRESHOLD */ #ifndef MAX_RELEASE_CHECK_RATE #if HAVE_MMAP #define MAX_RELEASE_CHECK_RATE 4095 #else #define MAX_RELEASE_CHECK_RATE MAX_SIZE_T #endif /* HAVE_MMAP */ #endif /* MAX_RELEASE_CHECK_RATE */ #ifndef USE_BUILTIN_FFS #define USE_BUILTIN_FFS 0 #endif /* USE_BUILTIN_FFS */ #ifndef USE_DEV_RANDOM #define USE_DEV_RANDOM 0 #endif /* USE_DEV_RANDOM */ #ifndef NO_MALLINFO #define NO_MALLINFO 0 #endif /* NO_MALLINFO */ #ifndef MALLINFO_FIELD_TYPE #define MALLINFO_FIELD_TYPE size_t #endif /* MALLINFO_FIELD_TYPE */ #ifndef NO_MALLOC_STATS #define NO_MALLOC_STATS 0 #endif /* NO_MALLOC_STATS */ #ifndef NO_SEGMENT_TRAVERSAL #define NO_SEGMENT_TRAVERSAL 0 #endif /* NO_SEGMENT_TRAVERSAL */ /* mallopt tuning options. SVID/XPG defines four standard parameter numbers for mallopt, normally defined in malloc.h. None of these are used in this malloc, so setting them has no effect. But this malloc does support the following options. */ #define M_TRIM_THRESHOLD (-1) #define M_GRANULARITY (-2) #define M_MMAP_THRESHOLD (-3) /* ------------------------ Mallinfo declarations ------------------------ */ #if !NO_MALLINFO /* This version of malloc supports the standard SVID/XPG mallinfo routine that returns a struct containing usage properties and statistics. It should work on any system that has a /usr/include/malloc.h defining struct mallinfo. The main declaration needed is the mallinfo struct that is returned (by-copy) by mallinfo(). The malloinfo struct contains a bunch of fields that are not even meaningful in this version of malloc. These fields are are instead filled by mallinfo() with other numbers that might be of interest. HAVE_USR_INCLUDE_MALLOC_H should be set if you have a /usr/include/malloc.h file that includes a declaration of struct mallinfo. If so, it is included; else a compliant version is declared below. These must be precisely the same for mallinfo() to work. The original SVID version of this struct, defined on most systems with mallinfo, declares all fields as ints. But some others define as unsigned long. If your system defines the fields using a type of different width than listed here, you MUST #include your system version and #define HAVE_USR_INCLUDE_MALLOC_H. */ /* #define HAVE_USR_INCLUDE_MALLOC_H */ #ifdef HAVE_USR_INCLUDE_MALLOC_H #include "/usr/include/malloc.h" #else /* HAVE_USR_INCLUDE_MALLOC_H */ #ifndef STRUCT_MALLINFO_DECLARED /* HP-UX (and others?) redefines mallinfo unless _STRUCT_MALLINFO is defined */ #define _STRUCT_MALLINFO #define STRUCT_MALLINFO_DECLARED 1 struct mallinfo { MALLINFO_FIELD_TYPE arena; /* non-mmapped space allocated from system */ MALLINFO_FIELD_TYPE ordblks; /* number of free chunks */ MALLINFO_FIELD_TYPE smblks; /* always 0 */ MALLINFO_FIELD_TYPE hblks; /* always 0 */ MALLINFO_FIELD_TYPE hblkhd; /* space in mmapped regions */ MALLINFO_FIELD_TYPE usmblks; /* maximum total allocated space */ MALLINFO_FIELD_TYPE fsmblks; /* always 0 */ MALLINFO_FIELD_TYPE uordblks; /* total allocated space */ MALLINFO_FIELD_TYPE fordblks; /* total free space */ MALLINFO_FIELD_TYPE keepcost; /* releasable (via malloc_trim) space */ }; #endif /* STRUCT_MALLINFO_DECLARED */ #endif /* HAVE_USR_INCLUDE_MALLOC_H */ #endif /* NO_MALLINFO */ /* Try to persuade compilers to inline. The most critical functions for inlining are defined as macros, so these aren't used for them. */ #ifndef FORCEINLINE #if defined(__GNUC__) #define FORCEINLINE __inline __attribute__ ((always_inline)) #elif defined(_MSC_VER) #define FORCEINLINE __forceinline #endif #endif #ifndef NOINLINE #if defined(__GNUC__) #define NOINLINE __attribute__ ((noinline)) #elif defined(_MSC_VER) #define NOINLINE __declspec(noinline) #else #define NOINLINE #endif #endif #ifdef __cplusplus extern "C" { #ifndef FORCEINLINE #define FORCEINLINE inline #endif #endif /* __cplusplus */ #ifndef FORCEINLINE #define FORCEINLINE #endif #if !ONLY_MSPACES /* ------------------- Declarations of public routines ------------------- */ #ifndef USE_DL_PREFIX #define dlcalloc calloc #define dlfree free #define dlmalloc malloc #define dlmemalign memalign #define dlposix_memalign posix_memalign #define dlrealloc realloc #define dlrealloc_in_place realloc_in_place #define dlvalloc valloc #define dlpvalloc pvalloc #define dlmallinfo mallinfo #define dlmallopt mallopt #define dlmalloc_trim malloc_trim #define dlmalloc_stats malloc_stats #define dlmalloc_usable_size malloc_usable_size #define dlmalloc_footprint malloc_footprint #define dlmalloc_max_footprint malloc_max_footprint #define dlmalloc_footprint_limit malloc_footprint_limit #define dlmalloc_set_footprint_limit malloc_set_footprint_limit #define dlmalloc_inspect_all malloc_inspect_all #define dlindependent_calloc independent_calloc #define dlindependent_comalloc independent_comalloc #define dlbulk_free bulk_free #endif /* USE_DL_PREFIX */ /* malloc(size_t n) Returns a pointer to a newly allocated chunk of at least n bytes, or null if no space is available, in which case errno is set to ENOMEM on ANSI C systems. If n is zero, malloc returns a minimum-sized chunk. (The minimum size is 16 bytes on most 32bit systems, and 32 bytes on 64bit systems.) Note that size_t is an unsigned type, so calls with arguments that would be negative if signed are interpreted as requests for huge amounts of space, which will often fail. The maximum supported value of n differs across systems, but is in all cases less than the maximum representable value of a size_t. */ DLMALLOC_EXPORT void* dlmalloc(size_t); /* free(void* p) Releases the chunk of memory pointed to by p, that had been previously allocated using malloc or a related routine such as realloc. It has no effect if p is null. If p was not malloced or already freed, free(p) will by default cause the current program to abort. */ DLMALLOC_EXPORT void dlfree(void*); /* calloc(size_t n_elements, size_t element_size); Returns a pointer to n_elements * element_size bytes, with all locations set to zero. */ DLMALLOC_EXPORT void* dlcalloc(size_t, size_t); /* realloc(void* p, size_t n) Returns a pointer to a chunk of size n that contains the same data as does chunk p up to the minimum of (n, p's size) bytes, or null if no space is available. The returned pointer may or may not be the same as p. The algorithm prefers extending p in most cases when possible, otherwise it employs the equivalent of a malloc-copy-free sequence. If p is null, realloc is equivalent to malloc. If space is not available, realloc returns null, errno is set (if on ANSI) and p is NOT freed. if n is for fewer bytes than already held by p, the newly unused space is lopped off and freed if possible. realloc with a size argument of zero (re)allocates a minimum-sized chunk. The old unix realloc convention of allowing the last-free'd chunk to be used as an argument to realloc is not supported. */ DLMALLOC_EXPORT void* dlrealloc(void*, size_t); /* realloc_in_place(void* p, size_t n) Resizes the space allocated for p to size n, only if this can be done without moving p (i.e., only if there is adjacent space available if n is greater than p's current allocated size, or n is less than or equal to p's size). This may be used instead of plain realloc if an alternative allocation strategy is needed upon failure to expand space; for example, reallocation of a buffer that must be memory-aligned or cleared. You can use realloc_in_place to trigger these alternatives only when needed. Returns p if successful; otherwise null. */ DLMALLOC_EXPORT void* dlrealloc_in_place(void*, size_t); /* memalign(size_t alignment, size_t n); Returns a pointer to a newly allocated chunk of n bytes, aligned in accord with the alignment argument. The alignment argument should be a power of two. If the argument is not a power of two, the nearest greater power is used. 8-byte alignment is guaranteed by normal malloc calls, so don't bother calling memalign with an argument of 8 or less. Overreliance on memalign is a sure way to fragment space. */ DLMALLOC_EXPORT void* dlmemalign(size_t, size_t); /* int posix_memalign(void** pp, size_t alignment, size_t n); Allocates a chunk of n bytes, aligned in accord with the alignment argument. Differs from memalign only in that it (1) assigns the allocated memory to *pp rather than returning it, (2) fails and returns EINVAL if the alignment is not a power of two (3) fails and returns ENOMEM if memory cannot be allocated. */ DLMALLOC_EXPORT int dlposix_memalign(void**, size_t, size_t); /* valloc(size_t n); Equivalent to memalign(pagesize, n), where pagesize is the page size of the system. If the pagesize is unknown, 4096 is used. */ DLMALLOC_EXPORT void* dlvalloc(size_t); /* mallopt(int parameter_number, int parameter_value) Sets tunable parameters The format is to provide a (parameter-number, parameter-value) pair. mallopt then sets the corresponding parameter to the argument value if it can (i.e., so long as the value is meaningful), and returns 1 if successful else 0. To workaround the fact that mallopt is specified to use int, not size_t parameters, the value -1 is specially treated as the maximum unsigned size_t value. SVID/XPG/ANSI defines four standard param numbers for mallopt, normally defined in malloc.h. None of these are use in this malloc, so setting them has no effect. But this malloc also supports other options in mallopt. See below for details. Briefly, supported parameters are as follows (listed defaults are for "typical" configurations). Symbol param # default allowed param values M_TRIM_THRESHOLD -1 2*1024*1024 any (-1 disables) M_GRANULARITY -2 page size any power of 2 >= page size M_MMAP_THRESHOLD -3 256*1024 any (or 0 if no MMAP support) */ DLMALLOC_EXPORT int dlmallopt(int, int); /* malloc_footprint(); Returns the number of bytes obtained from the system. The total number of bytes allocated by malloc, realloc etc., is less than this value. Unlike mallinfo, this function returns only a precomputed result, so can be called frequently to monitor memory consumption. Even if locks are otherwise defined, this function does not use them, so results might not be up to date. */ DLMALLOC_EXPORT size_t dlmalloc_footprint(void); /* malloc_max_footprint(); Returns the maximum number of bytes obtained from the system. This value will be greater than current footprint if deallocated space has been reclaimed by the system. The peak number of bytes allocated by malloc, realloc etc., is less than this value. Unlike mallinfo, this function returns only a precomputed result, so can be called frequently to monitor memory consumption. Even if locks are otherwise defined, this function does not use them, so results might not be up to date. */ DLMALLOC_EXPORT size_t dlmalloc_max_footprint(void); /* malloc_footprint_limit(); Returns the number of bytes that the heap is allowed to obtain from the system, returning the last value returned by malloc_set_footprint_limit, or the maximum size_t value if never set. The returned value reflects a permission. There is no guarantee that this number of bytes can actually be obtained from the system. */ DLMALLOC_EXPORT size_t dlmalloc_footprint_limit(); /* malloc_set_footprint_limit(); Sets the maximum number of bytes to obtain from the system, causing failure returns from malloc and related functions upon attempts to exceed this value. The argument value may be subject to page rounding to an enforceable limit; this actual value is returned. Using an argument of the maximum possible size_t effectively disables checks. If the argument is less than or equal to the current malloc_footprint, then all future allocations that require additional system memory will fail. However, invocation cannot retroactively deallocate existing used memory. */ DLMALLOC_EXPORT size_t dlmalloc_set_footprint_limit(size_t bytes); #if MALLOC_INSPECT_ALL /* malloc_inspect_all(void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg); Traverses the heap and calls the given handler for each managed region, skipping all bytes that are (or may be) used for bookkeeping purposes. Traversal does not include include chunks that have been directly memory mapped. Each reported region begins at the start address, and continues up to but not including the end address. The first used_bytes of the region contain allocated data. If used_bytes is zero, the region is unallocated. The handler is invoked with the given callback argument. If locks are defined, they are held during the entire traversal. It is a bad idea to invoke other malloc functions from within the handler. For example, to count the number of in-use chunks with size greater than 1000, you could write: static int count = 0; void count_chunks(void* start, void* end, size_t used, void* arg) { if (used >= 1000) ++count; } then: malloc_inspect_all(count_chunks, NULL); malloc_inspect_all is compiled only if MALLOC_INSPECT_ALL is defined. */ DLMALLOC_EXPORT void dlmalloc_inspect_all(void(*handler)(void*, void *, size_t, void*), void* arg); #endif /* MALLOC_INSPECT_ALL */ #if !NO_MALLINFO /* mallinfo() Returns (by copy) a struct containing various summary statistics: arena: current total non-mmapped bytes allocated from system ordblks: the number of free chunks smblks: always zero. hblks: current number of mmapped regions hblkhd: total bytes held in mmapped regions usmblks: the maximum total allocated space. This will be greater than current total if trimming has occurred. fsmblks: always zero uordblks: current total allocated space (normal or mmapped) fordblks: total free space keepcost: the maximum number of bytes that could ideally be released back to system via malloc_trim. ("ideally" means that it ignores page restrictions etc.) Because these fields are ints, but internal bookkeeping may be kept as longs, the reported values may wrap around zero and thus be inaccurate. */ DLMALLOC_EXPORT struct mallinfo dlmallinfo(void); #endif /* NO_MALLINFO */ /* independent_calloc(size_t n_elements, size_t element_size, void* chunks[]); independent_calloc is similar to calloc, but instead of returning a single cleared space, it returns an array of pointers to n_elements independent elements that can hold contents of size elem_size, each of which starts out cleared, and can be independently freed, realloc'ed etc. The elements are guaranteed to be adjacently allocated (this is not guaranteed to occur with multiple callocs or mallocs), which may also improve cache locality in some applications. The "chunks" argument is optional (i.e., may be null, which is probably the most typical usage). If it is null, the returned array is itself dynamically allocated and should also be freed when it is no longer needed. Otherwise, the chunks array must be of at least n_elements in length. It is filled in with the pointers to the chunks. In either case, independent_calloc returns this pointer array, or null if the allocation failed. If n_elements is zero and "chunks" is null, it returns a chunk representing an array with zero elements (which should be freed if not wanted). Each element must be freed when it is no longer needed. This can be done all at once using bulk_free. independent_calloc simplifies and speeds up implementations of many kinds of pools. It may also be useful when constructing large data structures that initially have a fixed number of fixed-sized nodes, but the number is not known at compile time, and some of the nodes may later need to be freed. For example: struct Node { int item; struct Node* next; }; struct Node* build_list() { struct Node** pool; int n = read_number_of_nodes_needed(); if (n <= 0) return 0; pool = (struct Node**)(independent_calloc(n, sizeof(struct Node), 0); if (pool == 0) die(); // organize into a linked list... struct Node* first = pool[0]; for (i = 0; i < n-1; ++i) pool[i]->next = pool[i+1]; free(pool); // Can now free the array (or not, if it is needed later) return first; } */ DLMALLOC_EXPORT void** dlindependent_calloc(size_t, size_t, void**); /* independent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]); independent_comalloc allocates, all at once, a set of n_elements chunks with sizes indicated in the "sizes" array. It returns an array of pointers to these elements, each of which can be independently freed, realloc'ed etc. The elements are guaranteed to be adjacently allocated (this is not guaranteed to occur with multiple callocs or mallocs), which may also improve cache locality in some applications. The "chunks" argument is optional (i.e., may be null). If it is null the returned array is itself dynamically allocated and should also be freed when it is no longer needed. Otherwise, the chunks array must be of at least n_elements in length. It is filled in with the pointers to the chunks. In either case, independent_comalloc returns this pointer array, or null if the allocation failed. If n_elements is zero and chunks is null, it returns a chunk representing an array with zero elements (which should be freed if not wanted). Each element must be freed when it is no longer needed. This can be done all at once using bulk_free. independent_comallac differs from independent_calloc in that each element may have a different size, and also that it does not automatically clear elements. independent_comalloc can be used to speed up allocation in cases where several structs or objects must always be allocated at the same time. For example: struct Head { ... } struct Foot { ... } void send_message(char* msg) { int msglen = strlen(msg); size_t sizes[3] = { sizeof(struct Head), msglen, sizeof(struct Foot) }; void* chunks[3]; if (independent_comalloc(3, sizes, chunks) == 0) die(); struct Head* head = (struct Head*)(chunks[0]); char* body = (char*)(chunks[1]); struct Foot* foot = (struct Foot*)(chunks[2]); // ... } In general though, independent_comalloc is worth using only for larger values of n_elements. For small values, you probably won't detect enough difference from series of malloc calls to bother. Overuse of independent_comalloc can increase overall memory usage, since it cannot reuse existing noncontiguous small chunks that might be available for some of the elements. */ DLMALLOC_EXPORT void** dlindependent_comalloc(size_t, size_t*, void**); /* bulk_free(void* array[], size_t n_elements) Frees and clears (sets to null) each non-null pointer in the given array. This is likely to be faster than freeing them one-by-one. If footers are used, pointers that have been allocated in different mspaces are not freed or cleared, and the count of all such pointers is returned. For large arrays of pointers with poor locality, it may be worthwhile to sort this array before calling bulk_free. */ DLMALLOC_EXPORT size_t dlbulk_free(void**, size_t n_elements); /* pvalloc(size_t n); Equivalent to valloc(minimum-page-that-holds(n)), that is, round up n to nearest pagesize. */ DLMALLOC_EXPORT void* dlpvalloc(size_t); /* malloc_trim(size_t pad); If possible, gives memory back to the system (via negative arguments to sbrk) if there is unused memory at the `high' end of the malloc pool or in unused MMAP segments. You can call this after freeing large blocks of memory to potentially reduce the system-level memory requirements of a program. However, it cannot guarantee to reduce memory. Under some allocation patterns, some large free blocks of memory will be locked between two used chunks, so they cannot be given back to the system. The `pad' argument to malloc_trim represents the amount of free trailing space to leave untrimmed. If this argument is zero, only the minimum amount of memory to maintain internal data structures will be left. Non-zero arguments can be supplied to maintain enough trailing space to service future expected allocations without having to re-obtain memory from the system. Malloc_trim returns 1 if it actually released any memory, else 0. */ DLMALLOC_EXPORT int dlmalloc_trim(size_t); /* malloc_stats(); Prints on stderr the amount of space obtained from the system (both via sbrk and mmap), the maximum amount (which may be more than current if malloc_trim and/or munmap got called), and the current number of bytes allocated via malloc (or realloc, etc) but not yet freed. Note that this is the number of bytes allocated, not the number requested. It will be larger than the number requested because of alignment and bookkeeping overhead. Because it includes alignment wastage as being in use, this figure may be greater than zero even when no user-level chunks are allocated. The reported current and maximum system memory can be inaccurate if a program makes other calls to system memory allocation functions (normally sbrk) outside of malloc. malloc_stats prints only the most commonly interesting statistics. More information can be obtained by calling mallinfo. */ DLMALLOC_EXPORT void dlmalloc_stats(void); /* malloc_usable_size(void* p); Returns the number of bytes you can actually use in an allocated chunk, which may be more than you requested (although often not) due to alignment and minimum size constraints. You can use this many bytes without worrying about overwriting other allocated objects. This is not a particularly great programming practice. malloc_usable_size can be more useful in debugging and assertions, for example: p = malloc(n); assert(malloc_usable_size(p) >= 256); */ size_t dlmalloc_usable_size(void*); #endif /* ONLY_MSPACES */ #if MSPACES /* mspace is an opaque type representing an independent region of space that supports mspace_malloc, etc. */ typedef void* mspace; /* create_mspace creates and returns a new independent space with the given initial capacity, or, if 0, the default granularity size. It returns null if there is no system memory available to create the space. If argument locked is non-zero, the space uses a separate lock to control access. The capacity of the space will grow dynamically as needed to service mspace_malloc requests. You can control the sizes of incremental increases of this space by compiling with a different DEFAULT_GRANULARITY or dynamically setting with mallopt(M_GRANULARITY, value). */ DLMALLOC_EXPORT mspace create_mspace(size_t capacity, int locked); /* destroy_mspace destroys the given space, and attempts to return all of its memory back to the system, returning the total number of bytes freed. After destruction, the results of access to all memory used by the space become undefined. */ DLMALLOC_EXPORT size_t destroy_mspace(mspace msp); /* create_mspace_with_base uses the memory supplied as the initial base of a new mspace. Part (less than 128*sizeof(size_t) bytes) of this space is used for bookkeeping, so the capacity must be at least this large. (Otherwise 0 is returned.) When this initial space is exhausted, additional memory will be obtained from the system. Destroying this space will deallocate all additionally allocated space (if possible) but not the initial base. */ DLMALLOC_EXPORT mspace create_mspace_with_base(void* base, size_t capacity, int locked); /* mspace_track_large_chunks controls whether requests for large chunks are allocated in their own untracked mmapped regions, separate from others in this mspace. By default large chunks are not tracked, which reduces fragmentation. However, such chunks are not necessarily released to the system upon destroy_mspace. Enabling tracking by setting to true may increase fragmentation, but avoids leakage when relying on destroy_mspace to release all memory allocated using this space. The function returns the previous setting. */ DLMALLOC_EXPORT int mspace_track_large_chunks(mspace msp, int enable); /* mspace_malloc behaves as malloc, but operates within the given space. */ DLMALLOC_EXPORT void* mspace_malloc(mspace msp, size_t bytes); /* mspace_free behaves as free, but operates within the given space. If compiled with FOOTERS==1, mspace_free is not actually needed. free may be called instead of mspace_free because freed chunks from any space are handled by their originating spaces. */ DLMALLOC_EXPORT void mspace_free(mspace msp, void* mem); /* mspace_realloc behaves as realloc, but operates within the given space. If compiled with FOOTERS==1, mspace_realloc is not actually needed. realloc may be called instead of mspace_realloc because realloced chunks from any space are handled by their originating spaces. */ DLMALLOC_EXPORT void* mspace_realloc(mspace msp, void* mem, size_t newsize); /* mspace_calloc behaves as calloc, but operates within the given space. */ DLMALLOC_EXPORT void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size); /* mspace_memalign behaves as memalign, but operates within the given space. */ DLMALLOC_EXPORT void* mspace_memalign(mspace msp, size_t alignment, size_t bytes); /* mspace_independent_calloc behaves as independent_calloc, but operates within the given space. */ DLMALLOC_EXPORT void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]); /* mspace_independent_comalloc behaves as independent_comalloc, but operates within the given space. */ DLMALLOC_EXPORT void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]); /* mspace_footprint() returns the number of bytes obtained from the system for this space. */ DLMALLOC_EXPORT size_t mspace_footprint(mspace msp); /* mspace_max_footprint() returns the peak number of bytes obtained from the system for this space. */ DLMALLOC_EXPORT size_t mspace_max_footprint(mspace msp); #if !NO_MALLINFO /* mspace_mallinfo behaves as mallinfo, but reports properties of the given space. */ DLMALLOC_EXPORT struct mallinfo mspace_mallinfo(mspace msp); #endif /* NO_MALLINFO */ /* malloc_usable_size(void* p) behaves the same as malloc_usable_size; */ DLMALLOC_EXPORT size_t mspace_usable_size(const void* mem); /* mspace_malloc_stats behaves as malloc_stats, but reports properties of the given space. */ DLMALLOC_EXPORT void mspace_malloc_stats(mspace msp); /* mspace_trim behaves as malloc_trim, but operates within the given space. */ DLMALLOC_EXPORT int mspace_trim(mspace msp, size_t pad); /* An alias for mallopt. */ DLMALLOC_EXPORT int mspace_mallopt(int, int); #endif /* MSPACES */ #ifdef __cplusplus } /* end of extern "C" */ #endif /* __cplusplus */ /* ======================================================================== To make a fully customizable malloc.h header file, cut everything above this line, put into file malloc.h, edit to suit, and #include it on the next line, as well as in programs that use this malloc. ======================================================================== */ /* #include "malloc.h" */ /*------------------------------ internal #includes ---------------------- */ #ifdef _MSC_VER #pragma warning( disable : 4146 ) /* no "unsigned" warnings */ #endif /* _MSC_VER */ #if !NO_MALLOC_STATS #include <stdio.h> /* for printing in malloc_stats */ #endif /* NO_MALLOC_STATS */ #ifndef LACKS_ERRNO_H #include <errno.h> /* for MALLOC_FAILURE_ACTION */ #endif /* LACKS_ERRNO_H */ #ifdef DEBUG #if ABORT_ON_ASSERT_FAILURE #undef assert #define assert(x) if(!(x)) ABORT #else /* ABORT_ON_ASSERT_FAILURE */ #include <assert.h> #endif /* ABORT_ON_ASSERT_FAILURE */ #else /* DEBUG */ #ifndef assert #define assert(x) #endif #define DEBUG 0 #endif /* DEBUG */ #if !defined(WIN32) && !defined(LACKS_TIME_H) #include <time.h> /* for magic initialization */ #endif /* WIN32 */ #ifndef LACKS_STDLIB_H #include <stdlib.h> /* for abort() */ #endif /* LACKS_STDLIB_H */ #ifndef LACKS_STRING_H #include <string.h> /* for memset etc */ #endif /* LACKS_STRING_H */ #if USE_BUILTIN_FFS #ifndef LACKS_STRINGS_H #include <strings.h> /* for ffs */ #endif /* LACKS_STRINGS_H */ #endif /* USE_BUILTIN_FFS */ #if HAVE_MMAP #ifndef LACKS_SYS_MMAN_H /* On some versions of linux, mremap decl in mman.h needs __USE_GNU set */ #if (defined(linux) && !defined(__USE_GNU)) #define __USE_GNU 1 #include <sys/mman.h> /* for mmap */ #undef __USE_GNU #else #include <sys/mman.h> /* for mmap */ #endif /* linux */ #endif /* LACKS_SYS_MMAN_H */ #ifndef LACKS_FCNTL_H #include <fcntl.h> #endif /* LACKS_FCNTL_H */ #endif /* HAVE_MMAP */ #ifndef LACKS_UNISTD_H #include <unistd.h> /* for sbrk, sysconf */ #else /* LACKS_UNISTD_H */ #if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) extern void* sbrk(ptrdiff_t); #endif /* FreeBSD etc */ #endif /* LACKS_UNISTD_H */ /* Declarations for locking */ #if USE_LOCKS #ifndef WIN32 #if defined (__SVR4) && defined (__sun) /* solaris */ #include <thread.h> #elif !defined(LACKS_SCHED_H) #include <sched.h> #endif /* solaris or LACKS_SCHED_H */ #if (defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0) || !USE_SPIN_LOCKS #include <pthread.h> #endif /* USE_RECURSIVE_LOCKS ... */ #elif defined(_MSC_VER) #ifndef _M_AMD64 /* These are already defined on AMD64 builds */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ LONG __cdecl _InterlockedCompareExchange(LONG volatile *Dest, LONG Exchange, LONG Comp); LONG __cdecl _InterlockedExchange(LONG volatile *Target, LONG Value); #ifdef __cplusplus } #endif /* __cplusplus */ #endif /* _M_AMD64 */ #pragma intrinsic (_InterlockedCompareExchange) #pragma intrinsic (_InterlockedExchange) #define interlockedcompareexchange _InterlockedCompareExchange #define interlockedexchange _InterlockedExchange #elif defined(WIN32) && defined(__GNUC__) #define interlockedcompareexchange(a, b, c) __sync_val_compare_and_swap(a, c, b) #define interlockedexchange __sync_lock_test_and_set #endif /* Win32 */ #else /* USE_LOCKS */ #endif /* USE_LOCKS */ #ifndef LOCK_AT_FORK #define LOCK_AT_FORK 0 #endif /* Declarations for bit scanning on win32 */ #if defined(_MSC_VER) && _MSC_VER>=1300 #ifndef BitScanForward /* Try to avoid pulling in WinNT.h */ #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ unsigned char _BitScanForward(unsigned long *index, unsigned long mask); unsigned char _BitScanReverse(unsigned long *index, unsigned long mask); #ifdef __cplusplus } #endif /* __cplusplus */ #define BitScanForward _BitScanForward #define BitScanReverse _BitScanReverse #pragma intrinsic(_BitScanForward) #pragma intrinsic(_BitScanReverse) #endif /* BitScanForward */ #endif /* defined(_MSC_VER) && _MSC_VER>=1300 */ #ifndef WIN32 #ifndef malloc_getpagesize # ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */ # ifndef _SC_PAGE_SIZE # define _SC_PAGE_SIZE _SC_PAGESIZE # endif # endif # ifdef _SC_PAGE_SIZE # define malloc_getpagesize sysconf(_SC_PAGE_SIZE) # else # if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE) extern size_t getpagesize(); # define malloc_getpagesize getpagesize() # else # ifdef WIN32 /* use supplied emulation of getpagesize */ # define malloc_getpagesize getpagesize() # else # ifndef LACKS_SYS_PARAM_H # include <sys/param.h> # endif # ifdef EXEC_PAGESIZE # define malloc_getpagesize EXEC_PAGESIZE # else # ifdef NBPG # ifndef CLSIZE # define malloc_getpagesize NBPG # else # define malloc_getpagesize (NBPG * CLSIZE) # endif # else # ifdef NBPC # define malloc_getpagesize NBPC # else # ifdef PAGESIZE # define malloc_getpagesize PAGESIZE # else /* just guess */ # define malloc_getpagesize ((size_t)4096U) # endif # endif # endif # endif # endif # endif # endif #endif #endif /* ------------------- size_t and alignment properties -------------------- */ /* The byte and bit size of a size_t */ #define SIZE_T_SIZE (sizeof(size_t)) #define SIZE_T_BITSIZE (sizeof(size_t) << 3) /* Some constants coerced to size_t */ /* Annoying but necessary to avoid errors on some platforms */ #define SIZE_T_ZERO ((size_t)0) #define SIZE_T_ONE ((size_t)1) #define SIZE_T_TWO ((size_t)2) #define SIZE_T_FOUR ((size_t)4) #define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) #define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) #define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) #define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) /* The bit mask value corresponding to MALLOC_ALIGNMENT */ #define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) /* True if address a has acceptable alignment */ #define is_aligned(A) (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) /* the number of bytes to offset an address to align it */ #define align_offset(A)\ ((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\ ((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK)) /* -------------------------- MMAP preliminaries ------------------------- */ /* If HAVE_MORECORE or HAVE_MMAP are false, we just define calls and checks to fail so compiler optimizer can delete code rather than using so many "#if"s. */ /* MORECORE and MMAP must return MFAIL on failure */ #define MFAIL ((void*)(MAX_SIZE_T)) #define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ #if HAVE_MMAP #ifndef WIN32 #define MUNMAP_DEFAULT(a, s) munmap((a), (s)) #define MMAP_PROT (PROT_READ|PROT_WRITE) #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON) #define MAP_ANONYMOUS MAP_ANON #endif /* MAP_ANON */ #ifdef MAP_ANONYMOUS #define MMAP_FLAGS (MAP_PRIVATE|MAP_ANONYMOUS) #define MMAP_DEFAULT(s) mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0) #else /* MAP_ANONYMOUS */ /* Nearly all versions of mmap support MAP_ANONYMOUS, so the following is unlikely to be needed, but is supplied just in case. */ #define MMAP_FLAGS (MAP_PRIVATE) static int dev_zero_fd = -1; /* Cached file descriptor for /dev/zero. */ #define MMAP_DEFAULT(s) ((dev_zero_fd < 0) ? \ (dev_zero_fd = open("/dev/zero", O_RDWR), \ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) : \ mmap(0, (s), MMAP_PROT, MMAP_FLAGS, dev_zero_fd, 0)) #endif /* MAP_ANONYMOUS */ #define DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) #else /* WIN32 */ /* Win32 MMAP via VirtualAlloc */ static FORCEINLINE void* win32mmap(size_t size) { void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT, PAGE_READWRITE); return (ptr != 0)? ptr: MFAIL; } /* For direct MMAP, use MEM_TOP_DOWN to minimize interference */ static FORCEINLINE void* win32direct_mmap(size_t size) { void* ptr = VirtualAlloc(0, size, MEM_RESERVE|MEM_COMMIT|MEM_TOP_DOWN, PAGE_READWRITE); return (ptr != 0)? ptr: MFAIL; } /* This function supports releasing coalesed segments */ static FORCEINLINE int win32munmap(void* ptr, size_t size) { MEMORY_BASIC_INFORMATION minfo; char* cptr = (char*)ptr; while (size) { if (VirtualQuery(cptr, &minfo, sizeof(minfo)) == 0) return -1; if (minfo.BaseAddress != cptr || minfo.AllocationBase != cptr || minfo.State != MEM_COMMIT || minfo.RegionSize > size) return -1; if (VirtualFree(cptr, 0, MEM_RELEASE) == 0) return -1; cptr += minfo.RegionSize; size -= minfo.RegionSize; } return 0; } #define MMAP_DEFAULT(s) win32mmap(s) #define MUNMAP_DEFAULT(a, s) win32munmap((a), (s)) #define DIRECT_MMAP_DEFAULT(s) win32direct_mmap(s) #endif /* WIN32 */ #endif /* HAVE_MMAP */ #if HAVE_MREMAP #ifndef WIN32 #define MREMAP_DEFAULT(addr, osz, nsz, mv) mremap((addr), (osz), (nsz), (mv)) #endif /* WIN32 */ #endif /* HAVE_MREMAP */ /** * Define CALL_MORECORE */ #if HAVE_MORECORE #ifdef MORECORE #define CALL_MORECORE(S) MORECORE(S) #else /* MORECORE */ #define CALL_MORECORE(S) MORECORE_DEFAULT(S) #endif /* MORECORE */ #else /* HAVE_MORECORE */ #define CALL_MORECORE(S) MFAIL #endif /* HAVE_MORECORE */ /** * Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP */ #if HAVE_MMAP #define USE_MMAP_BIT (SIZE_T_ONE) #ifdef MMAP #define CALL_MMAP(s) MMAP(s) #else /* MMAP */ #define CALL_MMAP(s) MMAP_DEFAULT(s) #endif /* MMAP */ #ifdef MUNMAP #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) #else /* MUNMAP */ #define CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) #endif /* MUNMAP */ #ifdef DIRECT_MMAP #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) #else /* DIRECT_MMAP */ #define CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) #endif /* DIRECT_MMAP */ #else /* HAVE_MMAP */ #define USE_MMAP_BIT (SIZE_T_ZERO) #define MMAP(s) MFAIL #define MUNMAP(a, s) (-1) #define DIRECT_MMAP(s) MFAIL #define CALL_DIRECT_MMAP(s) DIRECT_MMAP(s) #define CALL_MMAP(s) MMAP(s) #define CALL_MUNMAP(a, s) MUNMAP((a), (s)) #endif /* HAVE_MMAP */ /** * Define CALL_MREMAP */ #if HAVE_MMAP && HAVE_MREMAP #ifdef MREMAP #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP((addr), (osz), (nsz), (mv)) #else /* MREMAP */ #define CALL_MREMAP(addr, osz, nsz, mv) MREMAP_DEFAULT((addr), (osz), (nsz), (mv)) #endif /* MREMAP */ #else /* HAVE_MMAP && HAVE_MREMAP */ #define CALL_MREMAP(addr, osz, nsz, mv) MFAIL #endif /* HAVE_MMAP && HAVE_MREMAP */ /* mstate bit set if continguous morecore disabled or failed */ #define USE_NONCONTIGUOUS_BIT (4U) /* segment bit set in create_mspace_with_base */ #define EXTERN_BIT (8U) /* --------------------------- Lock preliminaries ------------------------ */ /* When locks are defined, there is one global lock, plus one per-mspace lock. The global lock_ensures that mparams.magic and other unique mparams values are initialized only once. It also protects sequences of calls to MORECORE. In many cases sys_alloc requires two calls, that should not be interleaved with calls by other threads. This does not protect against direct calls to MORECORE by other threads not using this lock, so there is still code to cope the best we can on interference. Per-mspace locks surround calls to malloc, free, etc. By default, locks are simple non-reentrant mutexes. Because lock-protected regions generally have bounded times, it is OK to use the supplied simple spinlocks. Spinlocks are likely to improve performance for lightly contended applications, but worsen performance under heavy contention. If USE_LOCKS is > 1, the definitions of lock routines here are bypassed, in which case you will need to define the type MLOCK_T, and at least INITIAL_LOCK, DESTROY_LOCK, ACQUIRE_LOCK, RELEASE_LOCK and TRY_LOCK. You must also declare a static MLOCK_T malloc_global_mutex = { initialization values };. */ #if !USE_LOCKS #define USE_LOCK_BIT (0U) #define INITIAL_LOCK(l) (0) #define DESTROY_LOCK(l) (0) #define ACQUIRE_MALLOC_GLOBAL_LOCK() #define RELEASE_MALLOC_GLOBAL_LOCK() #else #if USE_LOCKS > 1 /* ----------------------- User-defined locks ------------------------ */ /* Define your own lock implementation here */ /* #define INITIAL_LOCK(lk) ... */ /* #define DESTROY_LOCK(lk) ... */ /* #define ACQUIRE_LOCK(lk) ... */ /* #define RELEASE_LOCK(lk) ... */ /* #define TRY_LOCK(lk) ... */ /* static MLOCK_T malloc_global_mutex = ... */ #elif USE_SPIN_LOCKS /* First, define CAS_LOCK and CLEAR_LOCK on ints */ /* Note CAS_LOCK defined to return 0 on success */ #if defined(__GNUC__)&& (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) #define CAS_LOCK(sl) __sync_lock_test_and_set(sl, 1) #define CLEAR_LOCK(sl) __sync_lock_release(sl) #elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) /* Custom spin locks for older gcc on x86 */ static FORCEINLINE int x86_cas_lock(int *sl) { int ret; int val = 1; int cmp = 0; __asm__ __volatile__ ("lock; cmpxchgl %1, %2" : "=a" (ret) : "r" (val), "m" (*(sl)), "0"(cmp) : "memory", "cc"); return ret; } static FORCEINLINE void x86_clear_lock(int* sl) { assert(*sl != 0); int prev = 0; int ret; __asm__ __volatile__ ("lock; xchgl %0, %1" : "=r" (ret) : "m" (*(sl)), "0"(prev) : "memory"); } #define CAS_LOCK(sl) x86_cas_lock(sl) #define CLEAR_LOCK(sl) x86_clear_lock(sl) #else /* Win32 MSC */ #define CAS_LOCK(sl) interlockedexchange(sl, (LONG)1) #define CLEAR_LOCK(sl) interlockedexchange (sl, (LONG)0) #endif /* ... gcc spins locks ... */ /* How to yield for a spin lock */ #define SPINS_PER_YIELD 63 #if defined(_MSC_VER) #define SLEEP_EX_DURATION 50 /* delay for yield/sleep */ #define SPIN_LOCK_YIELD SleepEx(SLEEP_EX_DURATION, FALSE) #elif defined (__SVR4) && defined (__sun) /* solaris */ #define SPIN_LOCK_YIELD thr_yield(); #elif !defined(LACKS_SCHED_H) #define SPIN_LOCK_YIELD sched_yield(); #else #define SPIN_LOCK_YIELD #endif /* ... yield ... */ #if !defined(USE_RECURSIVE_LOCKS) || USE_RECURSIVE_LOCKS == 0 /* Plain spin locks use single word (embedded in malloc_states) */ static int spin_acquire_lock(int *sl) { int spins = 0; while (*(volatile int *)sl != 0 || CAS_LOCK(sl)) { if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } } return 0; } #define MLOCK_T int #define TRY_LOCK(sl) !CAS_LOCK(sl) #define RELEASE_LOCK(sl) CLEAR_LOCK(sl) #define ACQUIRE_LOCK(sl) (CAS_LOCK(sl)? spin_acquire_lock(sl) : 0) #define INITIAL_LOCK(sl) (*sl = 0) #define DESTROY_LOCK(sl) (0) static MLOCK_T malloc_global_mutex = 0; #else /* USE_RECURSIVE_LOCKS */ /* types for lock owners */ #ifdef WIN32 #define THREAD_ID_T DWORD #define CURRENT_THREAD GetCurrentThreadId() #define EQ_OWNER(X,Y) ((X) == (Y)) #else /* Note: the following assume that pthread_t is a type that can be initialized to (casted) zero. If this is not the case, you will need to somehow redefine these or not use spin locks. */ #define THREAD_ID_T pthread_t #define CURRENT_THREAD pthread_self() #define EQ_OWNER(X,Y) pthread_equal(X, Y) #endif struct malloc_recursive_lock { int sl; unsigned int c; THREAD_ID_T threadid; }; #define MLOCK_T struct malloc_recursive_lock static MLOCK_T malloc_global_mutex = { 0, 0, (THREAD_ID_T)0}; static FORCEINLINE void recursive_release_lock(MLOCK_T *lk) { assert(lk->sl != 0); if (--lk->c == 0) { CLEAR_LOCK(&lk->sl); } } static FORCEINLINE int recursive_acquire_lock(MLOCK_T *lk) { THREAD_ID_T mythreadid = CURRENT_THREAD; int spins = 0; for (;;) { if (*((volatile int *)(&lk->sl)) == 0) { if (!CAS_LOCK(&lk->sl)) { lk->threadid = mythreadid; lk->c = 1; return 0; } } else if (EQ_OWNER(lk->threadid, mythreadid)) { ++lk->c; return 0; } if ((++spins & SPINS_PER_YIELD) == 0) { SPIN_LOCK_YIELD; } } } static FORCEINLINE int recursive_try_lock(MLOCK_T *lk) { THREAD_ID_T mythreadid = CURRENT_THREAD; if (*((volatile int *)(&lk->sl)) == 0) { if (!CAS_LOCK(&lk->sl)) { lk->threadid = mythreadid; lk->c = 1; return 1; } } else if (EQ_OWNER(lk->threadid, mythreadid)) { ++lk->c; return 1; } return 0; } #define RELEASE_LOCK(lk) recursive_release_lock(lk) #define TRY_LOCK(lk) recursive_try_lock(lk) #define ACQUIRE_LOCK(lk) recursive_acquire_lock(lk) #define INITIAL_LOCK(lk) ((lk)->threadid = (THREAD_ID_T)0, (lk)->sl = 0, (lk)->c = 0) #define DESTROY_LOCK(lk) (0) #endif /* USE_RECURSIVE_LOCKS */ #elif defined(WIN32) /* Win32 critical sections */ #define MLOCK_T CRITICAL_SECTION #define ACQUIRE_LOCK(lk) (EnterCriticalSection(lk), 0) #define RELEASE_LOCK(lk) LeaveCriticalSection(lk) #define TRY_LOCK(lk) TryEnterCriticalSection(lk) #define INITIAL_LOCK(lk) (!InitializeCriticalSectionAndSpinCount((lk), 0x80000000|4000)) #define DESTROY_LOCK(lk) (DeleteCriticalSection(lk), 0) #define NEED_GLOBAL_LOCK_INIT static MLOCK_T malloc_global_mutex; static volatile LONG malloc_global_mutex_status; /* Use spin loop to initialize global lock */ static void init_malloc_global_mutex() { for (;;) { long stat = malloc_global_mutex_status; if (stat > 0) return; /* transition to < 0 while initializing, then to > 0) */ if (stat == 0 && interlockedcompareexchange(&malloc_global_mutex_status, (LONG)-1, (LONG)0) == 0) { InitializeCriticalSection(&malloc_global_mutex); interlockedexchange(&malloc_global_mutex_status, (LONG)1); return; } SleepEx(0, FALSE); } } #else /* pthreads-based locks */ #define MLOCK_T pthread_mutex_t #define ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) #define RELEASE_LOCK(lk) pthread_mutex_unlock(lk) #define TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) #define INITIAL_LOCK(lk) pthread_init_lock(lk) #define DESTROY_LOCK(lk) pthread_mutex_destroy(lk) #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 && defined(linux) && !defined(PTHREAD_MUTEX_RECURSIVE) /* Cope with old-style linux recursive lock initialization by adding */ /* skipped internal declaration from pthread.h */ extern int pthread_mutexattr_setkind_np __P ((pthread_mutexattr_t *__attr, int __kind)); #define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP #define pthread_mutexattr_settype(x,y) pthread_mutexattr_setkind_np(x,y) #endif /* USE_RECURSIVE_LOCKS ... */ static MLOCK_T malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER; static int pthread_init_lock (MLOCK_T *lk) { pthread_mutexattr_t attr; if (pthread_mutexattr_init(&attr)) return 1; #if defined(USE_RECURSIVE_LOCKS) && USE_RECURSIVE_LOCKS != 0 if (pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE)) return 1; #endif if (pthread_mutex_init(lk, &attr)) return 1; if (pthread_mutexattr_destroy(&attr)) return 1; return 0; } #endif /* ... lock types ... */ /* Common code for all lock types */ #define USE_LOCK_BIT (2U) #ifndef ACQUIRE_MALLOC_GLOBAL_LOCK #define ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); #endif #ifndef RELEASE_MALLOC_GLOBAL_LOCK #define RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_mutex); #endif #endif /* USE_LOCKS */ /* ----------------------- Chunk representations ------------------------ */ /* (The following includes lightly edited explanations by Colin Plumb.) The malloc_chunk declaration below is misleading (but accurate and necessary). It declares a "view" into memory allowing access to necessary fields at known offsets from a given base. Chunks of memory are maintained using a `boundary tag' method as originally described by Knuth. (See the paper by Paul Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a survey of such techniques.) Sizes of free chunks are stored both in the front of each chunk and at the end. This makes consolidating fragmented chunks into bigger chunks fast. The head fields also hold bits representing whether chunks are free or in use. Here are some pictures to make it clearer. They are "exploded" to show that the state of a chunk can be thought of as extending from the high 31 bits of the head field of its header through the prev_foot and PINUSE_BIT bit of the following chunk header. A chunk that's in use looks like: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk (if P = 0) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| | Size of this chunk 1| +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +- -+ | | +- -+ | : +- size - sizeof(size_t) available payload bytes -+ : | chunk-> +- -+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |1| | Size of next chunk (may or may not be in use) | +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ And if it's free, it looks like this: chunk-> +- -+ | User payload (must be in use, or we would have merged!) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |P| | Size of this chunk 0| +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Prev pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | : +- size - sizeof(struct chunk) unused bytes -+ : | chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of this chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| | Size of next chunk (must be in use, or we would have merged)| +-+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | : +- User payload -+ : | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0| +-+ Note that since we always merge adjacent free chunks, the chunks adjacent to a free chunk must be in use. Given a pointer to a chunk (which can be derived trivially from the payload pointer) we can, in O(1) time, find out whether the adjacent chunks are free, and if so, unlink them from the lists that they are on and merge them with the current chunk. Chunks always begin on even word boundaries, so the mem portion (which is returned to the user) is also on an even word boundary, and thus at least double-word aligned. The P (PINUSE_BIT) bit, stored in the unused low-order bit of the chunk size (which is always a multiple of two words), is an in-use bit for the *previous* chunk. If that bit is *clear*, then the word before the current chunk size contains the previous chunk size, and can be used to find the front of the previous chunk. The very first chunk allocated always has this bit set, preventing access to non-existent (or non-owned) memory. If pinuse is set for any given chunk, then you CANNOT determine the size of the previous chunk, and might even get a memory addressing fault when trying to do so. The C (CINUSE_BIT) bit, stored in the unused second-lowest bit of the chunk size redundantly records whether the current chunk is inuse (unless the chunk is mmapped). This redundancy enables usage checks within free and realloc, and reduces indirection when freeing and consolidating chunks. Each freshly allocated chunk must have both cinuse and pinuse set. That is, each allocated chunk borders either a previously allocated and still in-use chunk, or the base of its memory arena. This is ensured by making all allocations from the `lowest' part of any found chunk. Further, no free chunk physically borders another one, so each free chunk is known to be preceded and followed by either inuse chunks or the ends of memory. Note that the `foot' of the current chunk is actually represented as the prev_foot of the NEXT chunk. This makes it easier to deal with alignments etc but can be very confusing when trying to extend or adapt this code. The exceptions to all this are 1. The special chunk `top' is the top-most available chunk (i.e., the one bordering the end of available memory). It is treated specially. Top is never included in any bin, is used only if no other chunk is available, and is released back to the system if it is very large (see M_TRIM_THRESHOLD). In effect, the top chunk is treated as larger (and thus less well fitting) than any other available chunk. The top chunk doesn't update its trailing size field since there is no next contiguous chunk that would have to index off it. However, space is still allocated for it (TOP_FOOT_SIZE) to enable separation or merging when space is extended. 3. Chunks allocated via mmap, have both cinuse and pinuse bits cleared in their head fields. Because they are allocated one-by-one, each must carry its own prev_foot field, which is also used to hold the offset this chunk has within its mmapped region, which is needed to preserve alignment. Each mmapped chunk is trailed by the first two fields of a fake next-chunk for sake of usage checks. */ struct malloc_chunk { size_t prev_foot; /* Size of previous chunk (if free). */ size_t head; /* Size and inuse bits. */ struct malloc_chunk* fd; /* double links -- used only if free. */ struct malloc_chunk* bk; }; typedef struct malloc_chunk mchunk; typedef struct malloc_chunk* mchunkptr; typedef struct malloc_chunk* sbinptr; /* The type of bins of chunks */ typedef unsigned int bindex_t; /* Described below */ typedef unsigned int binmap_t; /* Described below */ typedef unsigned int flag_t; /* The type of various bit flag sets */ /* ------------------- Chunks sizes and alignments ----------------------- */ #define MCHUNK_SIZE (sizeof(mchunk)) #if FOOTERS #define CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) #else /* FOOTERS */ #define CHUNK_OVERHEAD (SIZE_T_SIZE) #endif /* FOOTERS */ /* MMapped chunks need a second word of overhead ... */ #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) /* ... and additional padding for fake next-chunk at foot */ #define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) /* The smallest size we can malloc is an aligned minimal chunk */ #define MIN_CHUNK_SIZE\ ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* conversion from malloc headers to user pointers, and back */ #define chunk2mem(p) ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) #define mem2chunk(mem) ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) /* chunk associated with aligned address A */ #define align_as_chunk(A) (mchunkptr)((A) + align_offset(chunk2mem(A))) /* Bounds on request (not chunk) sizes. */ #define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) #define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) /* pad request bytes into a usable size */ #define pad_request(req) \ (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) /* pad request, checking for minimum (but not maximum) */ #define request2size(req) \ (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) /* ------------------ Operations on head and foot fields ----------------- */ /* The head field of a chunk is or'ed with PINUSE_BIT when previous adjacent chunk in use, and or'ed with CINUSE_BIT if this chunk is in use, unless mmapped, in which case both bits are cleared. FLAG4_BIT is not used by this malloc, but might be useful in extensions. */ #define PINUSE_BIT (SIZE_T_ONE) #define CINUSE_BIT (SIZE_T_TWO) #define FLAG4_BIT (SIZE_T_FOUR) #define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) #define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) /* Head value for fenceposts */ #define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) /* extraction of fields from head words */ #define cinuse(p) ((p)->head & CINUSE_BIT) #define pinuse(p) ((p)->head & PINUSE_BIT) #define flag4inuse(p) ((p)->head & FLAG4_BIT) #define is_inuse(p) (((p)->head & INUSE_BITS) != PINUSE_BIT) #define is_mmapped(p) (((p)->head & INUSE_BITS) == 0) #define chunksize(p) ((p)->head & ~(FLAG_BITS)) #define clear_pinuse(p) ((p)->head &= ~PINUSE_BIT) #define set_flag4(p) ((p)->head |= FLAG4_BIT) #define clear_flag4(p) ((p)->head &= ~FLAG4_BIT) /* Treat space at ptr +/- offset as a chunk */ #define chunk_plus_offset(p, s) ((mchunkptr)(((char*)(p)) + (s))) #define chunk_minus_offset(p, s) ((mchunkptr)(((char*)(p)) - (s))) /* Ptr to next or previous physical malloc_chunk. */ #define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS))) #define prev_chunk(p) ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) /* extract next chunk's pinuse bit */ #define next_pinuse(p) ((next_chunk(p)->head) & PINUSE_BIT) /* Get/set size at footer */ #define get_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot) #define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) /* Set size, pinuse bit, and foot */ #define set_size_and_pinuse_of_free_chunk(p, s)\ ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) /* Set size, pinuse bit, foot, and clear next pinuse */ #define set_free_with_pinuse(p, s, n)\ (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) /* Get the internal overhead associated with chunk p */ #define overhead_for(p)\ (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) /* Return true if malloced space is not necessarily cleared */ #if MMAP_CLEARS #define calloc_must_clear(p) (!is_mmapped(p)) #else /* MMAP_CLEARS */ #define calloc_must_clear(p) (1) #endif /* MMAP_CLEARS */ /* ---------------------- Overlaid data structures ----------------------- */ /* When chunks are not in use, they are treated as nodes of either lists or trees. "Small" chunks are stored in circular doubly-linked lists, and look like this: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `head:' | Size of chunk, in bytes |P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Forward pointer to next chunk in list | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Back pointer to previous chunk in list | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Unused space (may be 0 bytes long) . . . . | nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `foot:' | Size of chunk, in bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Larger chunks are kept in a form of bitwise digital trees (aka tries) keyed on chunksizes. Because malloc_tree_chunks are only for free chunks greater than 256 bytes, their size doesn't impose any constraints on user chunk sizes. Each node looks like: chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Size of previous chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `head:' | Size of chunk, in bytes |P| mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Forward pointer to next chunk of same size | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Back pointer to previous chunk of same size | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer to left child (child[0]) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer to right child (child[1]) | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Pointer to parent | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | bin index of this chunk | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Unused space . . | nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ `foot:' | Size of chunk, in bytes | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Each tree holding treenodes is a tree of unique chunk sizes. Chunks of the same size are arranged in a circularly-linked list, with only the oldest chunk (the next to be used, in our FIFO ordering) actually in the tree. (Tree members are distinguished by a non-null parent pointer.) If a chunk with the same size an an existing node is inserted, it is linked off the existing node using pointers that work in the same way as fd/bk pointers of small chunks. Each tree contains a power of 2 sized range of chunk sizes (the smallest is 0x100 <= x < 0x180), which is is divided in half at each tree level, with the chunks in the smaller half of the range (0x100 <= x < 0x140 for the top nose) in the left subtree and the larger half (0x140 <= x < 0x180) in the right subtree. This is, of course, done by inspecting individual bits. Using these rules, each node's left subtree contains all smaller sizes than its right subtree. However, the node at the root of each subtree has no particular ordering relationship to either. (The dividing line between the subtree sizes is based on trie relation.) If we remove the last chunk of a given size from the interior of the tree, we need to replace it with a leaf node. The tree ordering rules permit a node to be replaced by any leaf below it. The smallest chunk in a tree (a common operation in a best-fit allocator) can be found by walking a path to the leftmost leaf in the tree. Unlike a usual binary tree, where we follow left child pointers until we reach a null, here we follow the right child pointer any time the left one is null, until we reach a leaf with both child pointers null. The smallest chunk in the tree will be somewhere along that path. The worst case number of steps to add, find, or remove a node is bounded by the number of bits differentiating chunks within bins. Under current bin calculations, this ranges from 6 up to 21 (for 32 bit sizes) or up to 53 (for 64 bit sizes). The typical case is of course much better. */ struct malloc_tree_chunk { /* The first four fields must be compatible with malloc_chunk */ size_t prev_foot; size_t head; struct malloc_tree_chunk* fd; struct malloc_tree_chunk* bk; struct malloc_tree_chunk* child[2]; struct malloc_tree_chunk* parent; bindex_t index; }; typedef struct malloc_tree_chunk tchunk; typedef struct malloc_tree_chunk* tchunkptr; typedef struct malloc_tree_chunk* tbinptr; /* The type of bins of trees */ /* A little helper macro for trees */ #define leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) /* ----------------------------- Segments -------------------------------- */ /* Each malloc space may include non-contiguous segments, held in a list headed by an embedded malloc_segment record representing the top-most space. Segments also include flags holding properties of the space. Large chunks that are directly allocated by mmap are not included in this list. They are instead independently created and destroyed without otherwise keeping track of them. Segment management mainly comes into play for spaces allocated by MMAP. Any call to MMAP might or might not return memory that is adjacent to an existing segment. MORECORE normally contiguously extends the current space, so this space is almost always adjacent, which is simpler and faster to deal with. (This is why MORECORE is used preferentially to MMAP when both are available -- see sys_alloc.) When allocating using MMAP, we don't use any of the hinting mechanisms (inconsistently) supported in various implementations of unix mmap, or distinguish reserving from committing memory. Instead, we just ask for space, and exploit contiguity when we get it. It is probably possible to do better than this on some systems, but no general scheme seems to be significantly better. Management entails a simpler variant of the consolidation scheme used for chunks to reduce fragmentation -- new adjacent memory is normally prepended or appended to an existing segment. However, there are limitations compared to chunk consolidation that mostly reflect the fact that segment processing is relatively infrequent (occurring only when getting memory from system) and that we don't expect to have huge numbers of segments: * Segments are not indexed, so traversal requires linear scans. (It would be possible to index these, but is not worth the extra overhead and complexity for most programs on most platforms.) * New segments are only appended to old ones when holding top-most memory; if they cannot be prepended to others, they are held in different segments. Except for the top-most segment of an mstate, each segment record is kept at the tail of its segment. Segments are added by pushing segment records onto the list headed by &mstate.seg for the containing mstate. Segment flags control allocation/merge/deallocation policies: * If EXTERN_BIT set, then we did not allocate this segment, and so should not try to deallocate or merge with others. (This currently holds only for the initial segment passed into create_mspace_with_base.) * If USE_MMAP_BIT set, the segment may be merged with other surrounding mmapped segments and trimmed/de-allocated using munmap. * If neither bit is set, then the segment was obtained using MORECORE so can be merged with surrounding MORECORE'd segments and deallocated/trimmed using MORECORE with negative arguments. */ struct malloc_segment { char* base; /* base address */ size_t size; /* allocated size */ struct malloc_segment* next; /* ptr to next segment */ flag_t sflags; /* mmap and extern flag */ }; #define is_mmapped_segment(S) ((S)->sflags & USE_MMAP_BIT) #define is_extern_segment(S) ((S)->sflags & EXTERN_BIT) typedef struct malloc_segment msegment; typedef struct malloc_segment* msegmentptr; /* ---------------------------- malloc_state ----------------------------- */ /* A malloc_state holds all of the bookkeeping for a space. The main fields are: Top The topmost chunk of the currently active segment. Its size is cached in topsize. The actual size of topmost space is topsize+TOP_FOOT_SIZE, which includes space reserved for adding fenceposts and segment records if necessary when getting more space from the system. The size at which to autotrim top is cached from mparams in trim_check, except that it is disabled if an autotrim fails. Designated victim (dv) This is the preferred chunk for servicing small requests that don't have exact fits. It is normally the chunk split off most recently to service another small request. Its size is cached in dvsize. The link fields of this chunk are not maintained since it is not kept in a bin. SmallBins An array of bin headers for free chunks. These bins hold chunks with sizes less than MIN_LARGE_SIZE bytes. Each bin contains chunks of all the same size, spaced 8 bytes apart. To simplify use in double-linked lists, each bin header acts as a malloc_chunk pointing to the real first node, if it exists (else pointing to itself). This avoids special-casing for headers. But to avoid waste, we allocate only the fd/bk pointers of bins, and then use repositioning tricks to treat these as the fields of a chunk. TreeBins Treebins are pointers to the roots of trees holding a range of sizes. There are 2 equally spaced treebins for each power of two from TREE_SHIFT to TREE_SHIFT+16. The last bin holds anything larger. Bin maps There is one bit map for small bins ("smallmap") and one for treebins ("treemap). Each bin sets its bit when non-empty, and clears the bit when empty. Bit operations are then used to avoid bin-by-bin searching -- nearly all "search" is done without ever looking at bins that won't be selected. The bit maps conservatively use 32 bits per map word, even if on 64bit system. For a good description of some of the bit-based techniques used here, see Henry S. Warren Jr's book "Hacker's Delight" (and supplement at http://hackersdelight.org/). Many of these are intended to reduce the branchiness of paths through malloc etc, as well as to reduce the number of memory locations read or written. Segments A list of segments headed by an embedded malloc_segment record representing the initial space. Address check support The least_addr field is the least address ever obtained from MORECORE or MMAP. Attempted frees and reallocs of any address less than this are trapped (unless INSECURE is defined). Magic tag A cross-check field that should always hold same value as mparams.magic. Max allowed footprint The maximum allowed bytes to allocate from system (zero means no limit) Flags Bits recording whether to use MMAP, locks, or contiguous MORECORE Statistics Each space keeps track of current and maximum system memory obtained via MORECORE or MMAP. Trim support Fields holding the amount of unused topmost memory that should trigger trimming, and a counter to force periodic scanning to release unused non-topmost segments. Locking If USE_LOCKS is defined, the "mutex" lock is acquired and released around every public call using this mspace. Extension support A void* pointer and a size_t field that can be used to help implement extensions to this malloc. */ /* Bin types, widths and sizes */ #define NSMALLBINS (32U) #define NTREEBINS (32U) #define SMALLBIN_SHIFT (3U) #define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) #define TREEBIN_SHIFT (8U) #define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) #define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) struct malloc_state { binmap_t smallmap; binmap_t treemap; size_t dvsize; size_t topsize; char* least_addr; mchunkptr dv; mchunkptr top; size_t trim_check; size_t release_checks; size_t magic; mchunkptr smallbins[(NSMALLBINS+1)*2]; tbinptr treebins[NTREEBINS]; size_t footprint; size_t max_footprint; size_t footprint_limit; /* zero means no limit */ flag_t mflags; #if USE_LOCKS MLOCK_T mutex; /* locate lock among fields that rarely change */ #endif /* USE_LOCKS */ msegment seg; void* extp; /* Unused but available for extensions */ size_t exts; }; typedef struct malloc_state* mstate; /* ------------- Global malloc_state and malloc_params ------------------- */ /* malloc_params holds global properties, including those that can be dynamically set using mallopt. There is a single instance, mparams, initialized in init_mparams. Note that the non-zeroness of "magic" also serves as an initialization flag. */ struct malloc_params { size_t magic; size_t page_size; size_t granularity; size_t mmap_threshold; size_t trim_threshold; flag_t default_mflags; }; static struct malloc_params mparams; /* Ensure mparams initialized */ #define ensure_initialization() (void)(mparams.magic != 0 || init_mparams()) #if !ONLY_MSPACES /* The global malloc_state used for all non-"mspace" calls */ static struct malloc_state _gm_; #define gm (&_gm_) #define is_global(M) ((M) == &_gm_) #endif /* !ONLY_MSPACES */ #define is_initialized(M) ((M)->top != 0) /* -------------------------- system alloc setup ------------------------- */ /* Operations on mflags */ #define use_lock(M) ((M)->mflags & USE_LOCK_BIT) #define enable_lock(M) ((M)->mflags |= USE_LOCK_BIT) #if USE_LOCKS #define disable_lock(M) ((M)->mflags &= ~USE_LOCK_BIT) #else #define disable_lock(M) #endif #define use_mmap(M) ((M)->mflags & USE_MMAP_BIT) #define enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT) #if HAVE_MMAP #define disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT) #else #define disable_mmap(M) #endif #define use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT) #define disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT) #define set_lock(M,L)\ ((M)->mflags = (L)?\ ((M)->mflags | USE_LOCK_BIT) :\ ((M)->mflags & ~USE_LOCK_BIT)) /* page-align a size */ #define page_align(S)\ (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) /* granularity-align a size */ #define granularity_align(S)\ (((S) + (mparams.granularity - SIZE_T_ONE))\ & ~(mparams.granularity - SIZE_T_ONE)) /* For mmap, use granularity alignment on windows, else page-align */ #ifdef WIN32 #define mmap_align(S) granularity_align(S) #else #define mmap_align(S) page_align(S) #endif /* For sys_alloc, enough padding to ensure can malloc request on success */ #define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) #define is_page_aligned(S)\ (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) #define is_granularity_aligned(S)\ (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) /* True if segment S holds address A */ #define segment_holds(S, A)\ ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) /* Return segment holding given address */ static msegmentptr segment_holding(mstate m, char* addr) { msegmentptr sp = &m->seg; for (;;) { if (addr >= sp->base && addr < sp->base + sp->size) return sp; if ((sp = sp->next) == 0) return 0; } } /* Return true if segment contains a segment link */ static int has_segment_link(mstate m, msegmentptr ss) { msegmentptr sp = &m->seg; for (;;) { if ((char*)sp >= ss->base && (char*)sp < ss->base + ss->size) return 1; if ((sp = sp->next) == 0) return 0; } } #ifndef MORECORE_CANNOT_TRIM #define should_trim(M,s) ((s) > (M)->trim_check) #else /* MORECORE_CANNOT_TRIM */ #define should_trim(M,s) (0) #endif /* MORECORE_CANNOT_TRIM */ /* TOP_FOOT_SIZE is padding at the end of a segment, including space that may be needed to place segment records and fenceposts when new noncontiguous segments are added. */ #define TOP_FOOT_SIZE\ (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) /* ------------------------------- Hooks -------------------------------- */ /* PREACTION should be defined to return 0 on success, and nonzero on failure. If you are not using locking, you can redefine these to do anything you like. */ #if USE_LOCKS #define PREACTION(M) ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) #define POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } #else /* USE_LOCKS */ #ifndef PREACTION #define PREACTION(M) (0) #endif /* PREACTION */ #ifndef POSTACTION #define POSTACTION(M) #endif /* POSTACTION */ #endif /* USE_LOCKS */ /* CORRUPTION_ERROR_ACTION is triggered upon detected bad addresses. USAGE_ERROR_ACTION is triggered on detected bad frees and reallocs. The argument p is an address that might have triggered the fault. It is ignored by the two predefined actions, but might be useful in custom actions that try to help diagnose errors. */ #if PROCEED_ON_ERROR /* A count of the number of corruption errors causing resets */ int malloc_corruption_error_count; /* default corruption action */ static void reset_on_error(mstate m); #define CORRUPTION_ERROR_ACTION(m) reset_on_error(m) #define USAGE_ERROR_ACTION(m, p) #else /* PROCEED_ON_ERROR */ #ifndef CORRUPTION_ERROR_ACTION #define CORRUPTION_ERROR_ACTION(m) ABORT #endif /* CORRUPTION_ERROR_ACTION */ #ifndef USAGE_ERROR_ACTION #define USAGE_ERROR_ACTION(m,p) ABORT #endif /* USAGE_ERROR_ACTION */ #endif /* PROCEED_ON_ERROR */ /* -------------------------- Debugging setup ---------------------------- */ #if ! DEBUG #define check_free_chunk(M,P) #define check_inuse_chunk(M,P) #define check_malloced_chunk(M,P,N) #define check_mmapped_chunk(M,P) #define check_malloc_state(M) #define check_top_chunk(M,P) #else /* DEBUG */ #define check_free_chunk(M,P) do_check_free_chunk(M,P) #define check_inuse_chunk(M,P) do_check_inuse_chunk(M,P) #define check_top_chunk(M,P) do_check_top_chunk(M,P) #define check_malloced_chunk(M,P,N) do_check_malloced_chunk(M,P,N) #define check_mmapped_chunk(M,P) do_check_mmapped_chunk(M,P) #define check_malloc_state(M) do_check_malloc_state(M) static void do_check_any_chunk(mstate m, mchunkptr p); static void do_check_top_chunk(mstate m, mchunkptr p); static void do_check_mmapped_chunk(mstate m, mchunkptr p); static void do_check_inuse_chunk(mstate m, mchunkptr p); static void do_check_free_chunk(mstate m, mchunkptr p); static void do_check_malloced_chunk(mstate m, void* mem, size_t s); static void do_check_tree(mstate m, tchunkptr t); static void do_check_treebin(mstate m, bindex_t i); static void do_check_smallbin(mstate m, bindex_t i); static void do_check_malloc_state(mstate m); static int bin_find(mstate m, mchunkptr x); static size_t traverse_and_check(mstate m); #endif /* DEBUG */ /* ---------------------------- Indexing Bins ---------------------------- */ #define is_small(s) (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) #define small_index(s) (bindex_t)((s) >> SMALLBIN_SHIFT) #define small_index2size(i) ((i) << SMALLBIN_SHIFT) #define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) /* addressing by index. See above about smallbin repositioning */ #define smallbin_at(M, i) ((sbinptr)((char*)&((M)->smallbins[(i)<<1]))) #define treebin_at(M,i) (&((M)->treebins[i])) /* assign tree index for size S to variable I. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #define compute_tree_index(S, I)\ {\ unsigned int X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int K = (unsigned) sizeof(X)*__CHAR_BIT__ - 1 - (unsigned) __builtin_clz(X); \ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } #elif defined (__INTEL_COMPILER) #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int K = _bit_scan_reverse (X); \ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } #elif defined(_MSC_VER) && _MSC_VER>=1300 #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int K;\ _BitScanReverse((DWORD *) &K, (DWORD) X);\ I = (bindex_t)((K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1)));\ }\ } #else /* GNUC */ #define compute_tree_index(S, I)\ {\ size_t X = S >> TREEBIN_SHIFT;\ if (X == 0)\ I = 0;\ else if (X > 0xFFFF)\ I = NTREEBINS-1;\ else {\ unsigned int Y = (unsigned int)X;\ unsigned int N = ((Y - 0x100) >> 16) & 8;\ unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\ N += K;\ N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\ K = 14 - N + ((Y <<= K) >> 15);\ I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\ }\ } #endif /* GNUC */ /* Bit representing maximum resolved size in a treebin at i */ #define bit_for_tree_index(i) \ (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) /* Shift placing maximum resolved bit in a treebin at i as sign bit */ #define leftshift_for_tree_index(i) \ ((i == NTREEBINS-1)? 0 : \ ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2))) /* The size of the smallest chunk held in bin with index i */ #define minsize_for_tree_index(i) \ ((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \ (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1))) /* ------------------------ Operations on bin maps ----------------------- */ /* bit corresponding to given index */ #define idx2bit(i) ((binmap_t)(1) << (i)) /* Mark/Clear bits with given index */ #define mark_smallmap(M,i) ((M)->smallmap |= idx2bit(i)) #define clear_smallmap(M,i) ((M)->smallmap &= ~idx2bit(i)) #define smallmap_is_marked(M,i) ((M)->smallmap & idx2bit(i)) #define mark_treemap(M,i) ((M)->treemap |= idx2bit(i)) #define clear_treemap(M,i) ((M)->treemap &= ~idx2bit(i)) #define treemap_is_marked(M,i) ((M)->treemap & idx2bit(i)) /* isolate the least set bit of a bitmap */ #define least_bit(x) ((x) & -(x)) /* mask with all bits to left of least bit of x on */ #define left_bits(x) ((x<<1) | -(x<<1)) /* mask with all bits to left of or equal to least bit of x on */ #define same_or_left_bits(x) ((x) | -(x)) /* index corresponding to given bit. Use x86 asm if possible */ #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #define compute_bit2idx(X, I)\ {\ unsigned int J;\ J = __builtin_ctz(X); \ I = (bindex_t)J;\ } #elif defined (__INTEL_COMPILER) #define compute_bit2idx(X, I)\ {\ unsigned int J;\ J = _bit_scan_forward (X); \ I = (bindex_t)J;\ } #elif defined(_MSC_VER) && _MSC_VER>=1300 #define compute_bit2idx(X, I)\ {\ unsigned int J;\ _BitScanForward((DWORD *) &J, X);\ I = (bindex_t)J;\ } #elif USE_BUILTIN_FFS #define compute_bit2idx(X, I) I = ffs(X)-1 #else #define compute_bit2idx(X, I)\ {\ unsigned int Y = X - 1;\ unsigned int K = Y >> (16-4) & 16;\ unsigned int N = K; Y >>= K;\ N += K = Y >> (8-3) & 8; Y >>= K;\ N += K = Y >> (4-2) & 4; Y >>= K;\ N += K = Y >> (2-1) & 2; Y >>= K;\ N += K = Y >> (1-0) & 1; Y >>= K;\ I = (bindex_t)(N + Y);\ } #endif /* GNUC */ /* ----------------------- Runtime Check Support ------------------------- */ /* For security, the main invariant is that malloc/free/etc never writes to a static address other than malloc_state, unless static malloc_state itself has been corrupted, which cannot occur via malloc (because of these checks). In essence this means that we believe all pointers, sizes, maps etc held in malloc_state, but check all of those linked or offsetted from other embedded data structures. These checks are interspersed with main code in a way that tends to minimize their run-time cost. When FOOTERS is defined, in addition to range checking, we also verify footer fields of inuse chunks, which can be used guarantee that the mstate controlling malloc/free is intact. This is a streamlined version of the approach described by William Robertson et al in "Run-time Detection of Heap-based Overflows" LISA'03 http://www.usenix.org/events/lisa03/tech/robertson.html The footer of an inuse chunk holds the xor of its mstate and a random seed, that is checked upon calls to free() and realloc(). This is (probabalistically) unguessable from outside the program, but can be computed by any code successfully malloc'ing any chunk, so does not itself provide protection against code that has already broken security through some other means. Unlike Robertson et al, we always dynamically check addresses of all offset chunks (previous, next, etc). This turns out to be cheaper than relying on hashes. */ #if !INSECURE /* Check if address a is at least as high as any from MORECORE or MMAP */ #define ok_address(M, a) ((char*)(a) >= (M)->least_addr) /* Check if address of next chunk n is higher than base chunk p */ #define ok_next(p, n) ((char*)(p) < (char*)(n)) /* Check if p has inuse status */ #define ok_inuse(p) is_inuse(p) /* Check if p has its pinuse bit on */ #define ok_pinuse(p) pinuse(p) #else /* !INSECURE */ #define ok_address(M, a) (1) #define ok_next(b, n) (1) #define ok_inuse(p) (1) #define ok_pinuse(p) (1) #endif /* !INSECURE */ #if (FOOTERS && !INSECURE) /* Check if (alleged) mstate m has expected magic field */ #define ok_magic(M) ((M)->magic == mparams.magic) #else /* (FOOTERS && !INSECURE) */ #define ok_magic(M) (1) #endif /* (FOOTERS && !INSECURE) */ /* In gcc, use __builtin_expect to minimize impact of checks */ #if !INSECURE #if defined(__GNUC__) && __GNUC__ >= 3 #define RTCHECK(e) __builtin_expect(e, 1) #else /* GNUC */ #define RTCHECK(e) (e) #endif /* GNUC */ #else /* !INSECURE */ #define RTCHECK(e) (1) #endif /* !INSECURE */ /* macros to set up inuse chunks with or without footers */ #if !FOOTERS #define mark_inuse_foot(M,p,s) /* Macros for setting head/foot of non-mmapped chunks */ /* Set cinuse bit and pinuse bit of next chunk */ #define set_inuse(M,p,s)\ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) /* Set cinuse and pinuse of this chunk and pinuse of next chunk */ #define set_inuse_and_pinuse(M,p,s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT) /* Set size, cinuse and pinuse bit of this chunk */ #define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) #else /* FOOTERS */ /* Set foot of inuse chunk to be xor of mstate and seed */ #define mark_inuse_foot(M,p,s)\ (((mchunkptr)((char*)(p) + (s)))->prev_foot = ((size_t)(M) ^ mparams.magic)) #define get_mstate_for(p)\ ((mstate)(((mchunkptr)((char*)(p) +\ (chunksize(p))))->prev_foot ^ mparams.magic)) #define set_inuse(M,p,s)\ ((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\ (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT), \ mark_inuse_foot(M,p,s)) #define set_inuse_and_pinuse(M,p,s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ (((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT),\ mark_inuse_foot(M,p,s)) #define set_size_and_pinuse_of_inuse_chunk(M, p, s)\ ((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\ mark_inuse_foot(M, p, s)) #endif /* !FOOTERS */ /* ---------------------------- setting mparams -------------------------- */ #if LOCK_AT_FORK static void pre_fork(void) { ACQUIRE_LOCK(&(gm)->mutex); } static void post_fork_parent(void) { RELEASE_LOCK(&(gm)->mutex); } static void post_fork_child(void) { INITIAL_LOCK(&(gm)->mutex); } #endif /* LOCK_AT_FORK */ /* Initialize mparams */ static int init_mparams(void) { #ifdef NEED_GLOBAL_LOCK_INIT if (malloc_global_mutex_status <= 0) init_malloc_global_mutex(); #endif ACQUIRE_MALLOC_GLOBAL_LOCK(); if (mparams.magic == 0) { size_t magic; size_t psize; size_t gsize; #ifndef WIN32 psize = malloc_getpagesize; gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : psize); #else /* WIN32 */ { SYSTEM_INFO system_info; GetSystemInfo(&system_info); psize = system_info.dwPageSize; gsize = ((DEFAULT_GRANULARITY != 0)? DEFAULT_GRANULARITY : system_info.dwAllocationGranularity); } #endif /* WIN32 */ /* Sanity-check configuration: size_t must be unsigned and as wide as pointer type. ints must be at least 4 bytes. alignment must be at least 8. Alignment, min chunk size, and page size must all be powers of 2. */ if ((sizeof(size_t) != sizeof(char*)) || (MAX_SIZE_T < MIN_CHUNK_SIZE) || (sizeof(int) < 4) || (MALLOC_ALIGNMENT < (size_t)8U) || ((MALLOC_ALIGNMENT & (MALLOC_ALIGNMENT-SIZE_T_ONE)) != 0) || ((MCHUNK_SIZE & (MCHUNK_SIZE-SIZE_T_ONE)) != 0) || ((gsize & (gsize-SIZE_T_ONE)) != 0) || ((psize & (psize-SIZE_T_ONE)) != 0)) ABORT; mparams.granularity = gsize; mparams.page_size = psize; mparams.mmap_threshold = DEFAULT_MMAP_THRESHOLD; mparams.trim_threshold = DEFAULT_TRIM_THRESHOLD; #if MORECORE_CONTIGUOUS mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT; #else /* MORECORE_CONTIGUOUS */ mparams.default_mflags = USE_LOCK_BIT|USE_MMAP_BIT|USE_NONCONTIGUOUS_BIT; #endif /* MORECORE_CONTIGUOUS */ #if !ONLY_MSPACES /* Set up lock for main malloc area */ gm->mflags = mparams.default_mflags; (void)INITIAL_LOCK(&gm->mutex); #endif #if LOCK_AT_FORK pthread_atfork(&pre_fork, &post_fork_parent, &post_fork_child); #endif { #if USE_DEV_RANDOM int fd; unsigned char buf[sizeof(size_t)]; /* Try to use /dev/urandom, else fall back on using time */ if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 && read(fd, buf, sizeof(buf)) == sizeof(buf)) { magic = *((size_t *) buf); close(fd); } else #endif /* USE_DEV_RANDOM */ #ifdef WIN32 magic = (size_t)(GetTickCount() ^ (size_t)0x55555555U); #elif defined(LACKS_TIME_H) magic = (size_t)&magic ^ (size_t)0x55555555U; #else magic = (size_t)(time(0) ^ (size_t)0x55555555U); #endif magic |= (size_t)8U; /* ensure nonzero */ magic &= ~(size_t)7U; /* improve chances of fault for bad values */ /* Until memory modes commonly available, use volatile-write */ (*(volatile size_t *)(&(mparams.magic))) = magic; } } RELEASE_MALLOC_GLOBAL_LOCK(); return 1; } /* support for mallopt */ static int change_mparam(int param_number, int value) { size_t val; ensure_initialization(); val = (value == -1)? MAX_SIZE_T : (size_t)value; switch(param_number) { case M_TRIM_THRESHOLD: mparams.trim_threshold = val; return 1; case M_GRANULARITY: if (val >= mparams.page_size && ((val & (val-1)) == 0)) { mparams.granularity = val; return 1; } else return 0; case M_MMAP_THRESHOLD: mparams.mmap_threshold = val; return 1; default: return 0; } } #if DEBUG /* ------------------------- Debugging Support --------------------------- */ /* Check properties of any chunk, whether free, inuse, mmapped etc */ static void do_check_any_chunk(mstate m, mchunkptr p) { assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); } /* Check properties of top chunk */ static void do_check_top_chunk(mstate m, mchunkptr p) { msegmentptr sp = segment_holding(m, (char*)p); size_t sz = p->head & ~INUSE_BITS; /* third-lowest bit can be set! */ assert(sp != 0); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(sz == m->topsize); assert(sz > 0); assert(sz == ((sp->base + sp->size) - (char*)p) - TOP_FOOT_SIZE); assert(pinuse(p)); assert(!pinuse(chunk_plus_offset(p, sz))); } /* Check properties of (inuse) mmapped chunks */ static void do_check_mmapped_chunk(mstate m, mchunkptr p) { size_t sz = chunksize(p); size_t len = (sz + (p->prev_foot) + MMAP_FOOT_PAD); assert(is_mmapped(p)); assert(use_mmap(m)); assert((is_aligned(chunk2mem(p))) || (p->head == FENCEPOST_HEAD)); assert(ok_address(m, p)); assert(!is_small(sz)); assert((len & (mparams.page_size-SIZE_T_ONE)) == 0); assert(chunk_plus_offset(p, sz)->head == FENCEPOST_HEAD); assert(chunk_plus_offset(p, sz+SIZE_T_SIZE)->head == 0); } /* Check properties of inuse chunks */ static void do_check_inuse_chunk(mstate m, mchunkptr p) { do_check_any_chunk(m, p); assert(is_inuse(p)); assert(next_pinuse(p)); /* If not pinuse and not mmapped, previous chunk has OK offset */ assert(is_mmapped(p) || pinuse(p) || next_chunk(prev_chunk(p)) == p); if (is_mmapped(p)) do_check_mmapped_chunk(m, p); } /* Check properties of free chunks */ static void do_check_free_chunk(mstate m, mchunkptr p) { size_t sz = chunksize(p); mchunkptr next = chunk_plus_offset(p, sz); do_check_any_chunk(m, p); assert(!is_inuse(p)); assert(!next_pinuse(p)); assert (!is_mmapped(p)); if (p != m->dv && p != m->top) { if (sz >= MIN_CHUNK_SIZE) { assert((sz & CHUNK_ALIGN_MASK) == 0); assert(is_aligned(chunk2mem(p))); assert(next->prev_foot == sz); assert(pinuse(p)); assert (next == m->top || is_inuse(next)); assert(p->fd->bk == p); assert(p->bk->fd == p); } else /* markers are always of size SIZE_T_SIZE */ assert(sz == SIZE_T_SIZE); } } /* Check properties of malloced chunks at the point they are malloced */ static void do_check_malloced_chunk(mstate m, void* mem, size_t s) { if (mem != 0) { mchunkptr p = mem2chunk(mem); size_t sz = p->head & ~INUSE_BITS; do_check_inuse_chunk(m, p); assert((sz & CHUNK_ALIGN_MASK) == 0); assert(sz >= MIN_CHUNK_SIZE); assert(sz >= s); /* unless mmapped, size is less than MIN_CHUNK_SIZE more than request */ assert(is_mmapped(p) || sz < (s + MIN_CHUNK_SIZE)); } } /* Check a tree and its subtrees. */ static void do_check_tree(mstate m, tchunkptr t) { tchunkptr head = 0; tchunkptr u = t; bindex_t tindex = t->index; size_t tsize = chunksize(t); bindex_t idx; compute_tree_index(tsize, idx); assert(tindex == idx); assert(tsize >= MIN_LARGE_SIZE); assert(tsize >= minsize_for_tree_index(idx)); assert((idx == NTREEBINS-1) || (tsize < minsize_for_tree_index((idx+1)))); do { /* traverse through chain of same-sized nodes */ do_check_any_chunk(m, ((mchunkptr)u)); assert(u->index == tindex); assert(chunksize(u) == tsize); assert(!is_inuse(u)); assert(!next_pinuse(u)); assert(u->fd->bk == u); assert(u->bk->fd == u); if (u->parent == 0) { assert(u->child[0] == 0); assert(u->child[1] == 0); } else { assert(head == 0); /* only one node on chain has parent */ head = u; assert(u->parent != u); assert (u->parent->child[0] == u || u->parent->child[1] == u || *((tbinptr*)(u->parent)) == u); if (u->child[0] != 0) { assert(u->child[0]->parent == u); assert(u->child[0] != u); do_check_tree(m, u->child[0]); } if (u->child[1] != 0) { assert(u->child[1]->parent == u); assert(u->child[1] != u); do_check_tree(m, u->child[1]); } if (u->child[0] != 0 && u->child[1] != 0) { assert(chunksize(u->child[0]) < chunksize(u->child[1])); } } u = u->fd; } while (u != t); assert(head != 0); } /* Check all the chunks in a treebin. */ static void do_check_treebin(mstate m, bindex_t i) { tbinptr* tb = treebin_at(m, i); tchunkptr t = *tb; int empty = (m->treemap & (1U << i)) == 0; if (t == 0) assert(empty); if (!empty) do_check_tree(m, t); } /* Check all the chunks in a smallbin. */ static void do_check_smallbin(mstate m, bindex_t i) { sbinptr b = smallbin_at(m, i); mchunkptr p = b->bk; unsigned int empty = (m->smallmap & (1U << i)) == 0; if (p == b) assert(empty); if (!empty) { for (; p != b; p = p->bk) { size_t size = chunksize(p); mchunkptr q; /* each chunk claims to be free */ do_check_free_chunk(m, p); /* chunk belongs in bin */ assert(small_index(size) == i); assert(p->bk == b || chunksize(p->bk) == chunksize(p)); /* chunk is followed by an inuse chunk */ q = next_chunk(p); if (q->head != FENCEPOST_HEAD) do_check_inuse_chunk(m, q); } } } /* Find x in a bin. Used in other check functions. */ static int bin_find(mstate m, mchunkptr x) { size_t size = chunksize(x); if (is_small(size)) { bindex_t sidx = small_index(size); sbinptr b = smallbin_at(m, sidx); if (smallmap_is_marked(m, sidx)) { mchunkptr p = b; do { if (p == x) return 1; } while ((p = p->fd) != b); } } else { bindex_t tidx; compute_tree_index(size, tidx); if (treemap_is_marked(m, tidx)) { tchunkptr t = *treebin_at(m, tidx); size_t sizebits = size << leftshift_for_tree_index(tidx); while (t != 0 && chunksize(t) != size) { t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; sizebits <<= 1; } if (t != 0) { tchunkptr u = t; do { if (u == (tchunkptr)x) return 1; } while ((u = u->fd) != t); } } } return 0; } /* Traverse each chunk and check it; return total */ static size_t traverse_and_check(mstate m) { size_t sum = 0; if (is_initialized(m)) { msegmentptr s = &m->seg; sum += m->topsize + TOP_FOOT_SIZE; while (s != 0) { mchunkptr q = align_as_chunk(s->base); mchunkptr lastq = 0; assert(pinuse(q)); while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { sum += chunksize(q); if (is_inuse(q)) { assert(!bin_find(m, q)); do_check_inuse_chunk(m, q); } else { assert(q == m->dv || bin_find(m, q)); assert(lastq == 0 || is_inuse(lastq)); /* Not 2 consecutive free */ do_check_free_chunk(m, q); } lastq = q; q = next_chunk(q); } s = s->next; } } return sum; } /* Check all properties of malloc_state. */ static void do_check_malloc_state(mstate m) { bindex_t i; size_t total; /* check bins */ for (i = 0; i < NSMALLBINS; ++i) do_check_smallbin(m, i); for (i = 0; i < NTREEBINS; ++i) do_check_treebin(m, i); if (m->dvsize != 0) { /* check dv chunk */ do_check_any_chunk(m, m->dv); assert(m->dvsize == chunksize(m->dv)); assert(m->dvsize >= MIN_CHUNK_SIZE); assert(bin_find(m, m->dv) == 0); } if (m->top != 0) { /* check top chunk */ do_check_top_chunk(m, m->top); /*assert(m->topsize == chunksize(m->top)); redundant */ assert(m->topsize > 0); assert(bin_find(m, m->top) == 0); } total = traverse_and_check(m); assert(total <= m->footprint); assert(m->footprint <= m->max_footprint); } #endif /* DEBUG */ /* ----------------------------- statistics ------------------------------ */ #if !NO_MALLINFO static struct mallinfo internal_mallinfo(mstate m) { struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ensure_initialization(); if (!PREACTION(m)) { check_malloc_state(m); if (is_initialized(m)) { size_t nfree = SIZE_T_ONE; /* top always free */ size_t mfree = m->topsize + TOP_FOOT_SIZE; size_t sum = mfree; msegmentptr s = &m->seg; while (s != 0) { mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { size_t sz = chunksize(q); sum += sz; if (!is_inuse(q)) { mfree += sz; ++nfree; } q = next_chunk(q); } s = s->next; } nm.arena = sum; nm.ordblks = nfree; nm.hblkhd = m->footprint - sum; nm.usmblks = m->max_footprint; nm.uordblks = m->footprint - mfree; nm.fordblks = mfree; nm.keepcost = m->topsize; } POSTACTION(m); } return nm; } #endif /* !NO_MALLINFO */ #if !NO_MALLOC_STATS static void internal_malloc_stats(mstate m) { ensure_initialization(); if (!PREACTION(m)) { size_t maxfp = 0; size_t fp = 0; size_t used = 0; check_malloc_state(m); if (is_initialized(m)) { msegmentptr s = &m->seg; maxfp = m->max_footprint; fp = m->footprint; used = fp - (m->topsize + TOP_FOOT_SIZE); while (s != 0) { mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q != m->top && q->head != FENCEPOST_HEAD) { if (!is_inuse(q)) used -= chunksize(q); q = next_chunk(q); } s = s->next; } } POSTACTION(m); /* drop lock */ fprintf(stderr, "max system bytes = %10lu\n", (unsigned long)(maxfp)); fprintf(stderr, "system bytes = %10lu\n", (unsigned long)(fp)); fprintf(stderr, "in use bytes = %10lu\n", (unsigned long)(used)); } } #endif /* NO_MALLOC_STATS */ /* ----------------------- Operations on smallbins ----------------------- */ /* Various forms of linking and unlinking are defined as macros. Even the ones for trees, which are very long but have very short typical paths. This is ugly but reduces reliance on inlining support of compilers. */ /* Link a free chunk into a smallbin */ #define insert_small_chunk(M, P, S) {\ bindex_t I = small_index(S);\ mchunkptr B = smallbin_at(M, I);\ mchunkptr F = B;\ assert(S >= MIN_CHUNK_SIZE);\ if (!smallmap_is_marked(M, I))\ mark_smallmap(M, I);\ else if (RTCHECK(ok_address(M, B->fd)))\ F = B->fd;\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ B->fd = P;\ F->bk = P;\ P->fd = F;\ P->bk = B;\ } /* Unlink a chunk from a smallbin */ #define unlink_small_chunk(M, P, S) {\ mchunkptr F = P->fd;\ mchunkptr B = P->bk;\ bindex_t I = small_index(S);\ assert(P != B);\ assert(P != F);\ assert(chunksize(P) == small_index2size(I));\ if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \ if (B == F) {\ clear_smallmap(M, I);\ }\ else if (RTCHECK(B == smallbin_at(M,I) ||\ (ok_address(M, B) && B->fd == P))) {\ F->bk = B;\ B->fd = F;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ } /* Unlink the first chunk from a smallbin */ #define unlink_first_small_chunk(M, B, P, I) {\ mchunkptr F = P->fd;\ assert(P != B);\ assert(P != F);\ assert(chunksize(P) == small_index2size(I));\ if (B == F) {\ clear_smallmap(M, I);\ }\ else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\ F->bk = B;\ B->fd = F;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ } /* Replace dv node, binning the old one */ /* Used only when dvsize known to be small */ #define replace_dv(M, P, S) {\ size_t DVS = M->dvsize;\ assert(is_small(DVS));\ if (DVS != 0) {\ mchunkptr DV = M->dv;\ insert_small_chunk(M, DV, DVS);\ }\ M->dvsize = S;\ M->dv = P;\ } /* ------------------------- Operations on trees ------------------------- */ /* Insert chunk into tree */ #define insert_large_chunk(M, X, S) {\ tbinptr* H;\ bindex_t I;\ compute_tree_index(S, I);\ H = treebin_at(M, I);\ X->index = I;\ X->child[0] = X->child[1] = 0;\ if (!treemap_is_marked(M, I)) {\ mark_treemap(M, I);\ *H = X;\ X->parent = (tchunkptr)H;\ X->fd = X->bk = X;\ }\ else {\ tchunkptr T = *H;\ size_t K = S << leftshift_for_tree_index(I);\ for (;;) {\ if (chunksize(T) != S) {\ tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\ K <<= 1;\ if (*C != 0)\ T = *C;\ else if (RTCHECK(ok_address(M, C))) {\ *C = X;\ X->parent = T;\ X->fd = X->bk = X;\ break;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ break;\ }\ }\ else {\ tchunkptr F = T->fd;\ if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\ T->fd = F->bk = X;\ X->fd = F;\ X->bk = T;\ X->parent = 0;\ break;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ break;\ }\ }\ }\ }\ } /* Unlink steps: 1. If x is a chained node, unlink it from its same-sized fd/bk links and choose its bk node as its replacement. 2. If x was the last node of its size, but not a leaf node, it must be replaced with a leaf node (not merely one with an open left or right), to make sure that lefts and rights of descendents correspond properly to bit masks. We use the rightmost descendent of x. We could use any other leaf, but this is easy to locate and tends to counteract removal of leftmosts elsewhere, and so keeps paths shorter than minimally guaranteed. This doesn't loop much because on average a node in a tree is near the bottom. 3. If x is the base of a chain (i.e., has parent links) relink x's parent and children to x's replacement (or null if none). */ #define unlink_large_chunk(M, X) {\ tchunkptr XP = X->parent;\ tchunkptr R;\ if (X->bk != X) {\ tchunkptr F = X->fd;\ R = X->bk;\ if (RTCHECK(ok_address(M, F) && F->bk == X && R->fd == X)) {\ F->bk = R;\ R->fd = F;\ }\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ else {\ tchunkptr* RP;\ if (((R = *(RP = &(X->child[1]))) != 0) ||\ ((R = *(RP = &(X->child[0]))) != 0)) {\ tchunkptr* CP;\ while ((*(CP = &(R->child[1])) != 0) ||\ (*(CP = &(R->child[0])) != 0)) {\ R = *(RP = CP);\ }\ if (RTCHECK(ok_address(M, RP)))\ *RP = 0;\ else {\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ }\ if (XP != 0) {\ tbinptr* H = treebin_at(M, X->index);\ if (X == *H) {\ if ((*H = R) == 0) \ clear_treemap(M, X->index);\ }\ else if (RTCHECK(ok_address(M, XP))) {\ if (XP->child[0] == X) \ XP->child[0] = R;\ else \ XP->child[1] = R;\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ if (R != 0) {\ if (RTCHECK(ok_address(M, R))) {\ tchunkptr C0, C1;\ R->parent = XP;\ if ((C0 = X->child[0]) != 0) {\ if (RTCHECK(ok_address(M, C0))) {\ R->child[0] = C0;\ C0->parent = R;\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ }\ if ((C1 = X->child[1]) != 0) {\ if (RTCHECK(ok_address(M, C1))) {\ R->child[1] = C1;\ C1->parent = R;\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ else\ CORRUPTION_ERROR_ACTION(M);\ }\ }\ } /* Relays to large vs small bin operations */ #define insert_chunk(M, P, S)\ if (is_small(S)) insert_small_chunk(M, P, S)\ else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); } #define unlink_chunk(M, P, S)\ if (is_small(S)) unlink_small_chunk(M, P, S)\ else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); } /* Relays to internal calls to malloc/free from realloc, memalign etc */ #if ONLY_MSPACES #define internal_malloc(m, b) mspace_malloc(m, b) #define internal_free(m, mem) mspace_free(m,mem); #else /* ONLY_MSPACES */ #if MSPACES #define internal_malloc(m, b)\ ((m == gm)? dlmalloc(b) : mspace_malloc(m, b)) #define internal_free(m, mem)\ if (m == gm) dlfree(mem); else mspace_free(m,mem); #else /* MSPACES */ #define internal_malloc(m, b) dlmalloc(b) #define internal_free(m, mem) dlfree(mem) #endif /* MSPACES */ #endif /* ONLY_MSPACES */ /* ----------------------- Direct-mmapping chunks ----------------------- */ /* Directly mmapped chunks are set up with an offset to the start of the mmapped region stored in the prev_foot field of the chunk. This allows reconstruction of the required argument to MUNMAP when freed, and also allows adjustment of the returned chunk to meet alignment requirements (especially in memalign). */ /* Malloc using mmap */ static void* mmap_alloc(mstate m, size_t nb) { size_t mmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); if (m->footprint_limit != 0) { size_t fp = m->footprint + mmsize; if (fp <= m->footprint || fp > m->footprint_limit) return 0; } if (mmsize > nb) { /* Check for wrap around 0 */ char* mm = (char*)(CALL_DIRECT_MMAP(mmsize)); if (mm != CMFAIL) { size_t offset = align_offset(chunk2mem(mm)); size_t psize = mmsize - offset - MMAP_FOOT_PAD; mchunkptr p = (mchunkptr)(mm + offset); p->prev_foot = offset; p->head = psize; mark_inuse_foot(m, p, psize); chunk_plus_offset(p, psize)->head = FENCEPOST_HEAD; chunk_plus_offset(p, psize+SIZE_T_SIZE)->head = 0; if (m->least_addr == 0 || mm < m->least_addr) m->least_addr = mm; if ((m->footprint += mmsize) > m->max_footprint) m->max_footprint = m->footprint; assert(is_aligned(chunk2mem(p))); check_mmapped_chunk(m, p); return chunk2mem(p); } } return 0; } /* Realloc using mmap */ static mchunkptr mmap_resize(mstate m, mchunkptr oldp, size_t nb, int flags) { size_t oldsize = chunksize(oldp); (void)flags; /* placate people compiling -Wunused */ if (is_small(nb)) /* Can't shrink mmap regions below small size */ return 0; /* Keep old chunk if big enough but not too big */ if (oldsize >= nb + SIZE_T_SIZE && (oldsize - nb) <= (mparams.granularity << 1)) return oldp; else { size_t offset = oldp->prev_foot; size_t oldmmsize = oldsize + offset + MMAP_FOOT_PAD; size_t newmmsize = mmap_align(nb + SIX_SIZE_T_SIZES + CHUNK_ALIGN_MASK); char* cp = (char*)CALL_MREMAP((char*)oldp - offset, oldmmsize, newmmsize, flags); if (cp != CMFAIL) { mchunkptr newp = (mchunkptr)(cp + offset); size_t psize = newmmsize - offset - MMAP_FOOT_PAD; newp->head = psize; mark_inuse_foot(m, newp, psize); chunk_plus_offset(newp, psize)->head = FENCEPOST_HEAD; chunk_plus_offset(newp, psize+SIZE_T_SIZE)->head = 0; if (cp < m->least_addr) m->least_addr = cp; if ((m->footprint += newmmsize - oldmmsize) > m->max_footprint) m->max_footprint = m->footprint; check_mmapped_chunk(m, newp); return newp; } } return 0; } /* -------------------------- mspace management -------------------------- */ /* Initialize top chunk and its size */ static void init_top(mstate m, mchunkptr p, size_t psize) { /* Ensure alignment */ size_t offset = align_offset(chunk2mem(p)); p = (mchunkptr)((char*)p + offset); psize -= offset; m->top = p; m->topsize = psize; p->head = psize | PINUSE_BIT; /* set size of fake trailing chunk holding overhead space only once */ chunk_plus_offset(p, psize)->head = TOP_FOOT_SIZE; m->trim_check = mparams.trim_threshold; /* reset on each update */ } /* Initialize bins for a new mstate that is otherwise zeroed out */ static void init_bins(mstate m) { /* Establish circular links for smallbins */ bindex_t i; for (i = 0; i < NSMALLBINS; ++i) { sbinptr bin = smallbin_at(m,i); bin->fd = bin->bk = bin; } } #if PROCEED_ON_ERROR /* default corruption action */ static void reset_on_error(mstate m) { int i; ++malloc_corruption_error_count; /* Reinitialize fields to forget about all memory */ m->smallmap = m->treemap = 0; m->dvsize = m->topsize = 0; m->seg.base = 0; m->seg.size = 0; m->seg.next = 0; m->top = m->dv = 0; for (i = 0; i < NTREEBINS; ++i) *treebin_at(m, i) = 0; init_bins(m); } #endif /* PROCEED_ON_ERROR */ /* Allocate chunk and prepend remainder with chunk in successor base. */ static void* prepend_alloc(mstate m, char* newbase, char* oldbase, size_t nb) { mchunkptr p = align_as_chunk(newbase); mchunkptr oldfirst = align_as_chunk(oldbase); size_t psize = (char*)oldfirst - (char*)p; mchunkptr q = chunk_plus_offset(p, nb); size_t qsize = psize - nb; set_size_and_pinuse_of_inuse_chunk(m, p, nb); assert((char*)oldfirst > (char*)q); assert(pinuse(oldfirst)); assert(qsize >= MIN_CHUNK_SIZE); /* consolidate remainder with first chunk of old base */ if (oldfirst == m->top) { size_t tsize = m->topsize += qsize; m->top = q; q->head = tsize | PINUSE_BIT; check_top_chunk(m, q); } else if (oldfirst == m->dv) { size_t dsize = m->dvsize += qsize; m->dv = q; set_size_and_pinuse_of_free_chunk(q, dsize); } else { if (!is_inuse(oldfirst)) { size_t nsize = chunksize(oldfirst); unlink_chunk(m, oldfirst, nsize); oldfirst = chunk_plus_offset(oldfirst, nsize); qsize += nsize; } set_free_with_pinuse(q, qsize, oldfirst); insert_chunk(m, q, qsize); check_free_chunk(m, q); } check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); } /* Add a segment to hold a new noncontiguous region */ static void add_segment(mstate m, char* tbase, size_t tsize, flag_t mmapped) { /* Determine locations and sizes of segment, fenceposts, old top */ char* old_top = (char*)m->top; msegmentptr oldsp = segment_holding(m, old_top); char* old_end = oldsp->base + oldsp->size; size_t ssize = pad_request(sizeof(struct malloc_segment)); char* rawsp = old_end - (ssize + FOUR_SIZE_T_SIZES + CHUNK_ALIGN_MASK); size_t offset = align_offset(chunk2mem(rawsp)); char* asp = rawsp + offset; char* csp = (asp < (old_top + MIN_CHUNK_SIZE))? old_top : asp; mchunkptr sp = (mchunkptr)csp; msegmentptr ss = (msegmentptr)(chunk2mem(sp)); mchunkptr tnext = chunk_plus_offset(sp, ssize); mchunkptr p = tnext; int nfences = 0; /* reset top to new space */ init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); /* Set up segment record */ assert(is_aligned(ss)); set_size_and_pinuse_of_inuse_chunk(m, sp, ssize); *ss = m->seg; /* Push current record */ m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmapped; m->seg.next = ss; /* Insert trailing fenceposts */ for (;;) { mchunkptr nextp = chunk_plus_offset(p, SIZE_T_SIZE); p->head = FENCEPOST_HEAD; ++nfences; if ((char*)(&(nextp->head)) < old_end) p = nextp; else break; } assert(nfences >= 2); /* Insert the rest of old top into a bin as an ordinary free chunk */ if (csp != old_top) { mchunkptr q = (mchunkptr)old_top; size_t psize = csp - old_top; mchunkptr tn = chunk_plus_offset(q, psize); set_free_with_pinuse(q, psize, tn); insert_chunk(m, q, psize); } check_top_chunk(m, m->top); } /* -------------------------- System allocation -------------------------- */ /* Get memory from system using MORECORE or MMAP */ static void* sys_alloc(mstate m, size_t nb) { char* tbase = CMFAIL; size_t tsize = 0; flag_t mmap_flag = 0; size_t asize; /* allocation size */ ensure_initialization(); /* Directly map large chunks, but only if already initialized */ if (use_mmap(m) && nb >= mparams.mmap_threshold && m->topsize != 0) { void* mem = mmap_alloc(m, nb); if (mem != 0) return mem; } asize = granularity_align(nb + SYS_ALLOC_PADDING); if (asize <= nb) return 0; /* wraparound */ if (m->footprint_limit != 0) { size_t fp = m->footprint + asize; if (fp <= m->footprint || fp > m->footprint_limit) return 0; } /* Try getting memory in any of three ways (in most-preferred to least-preferred order): 1. A call to MORECORE that can normally contiguously extend memory. (disabled if not MORECORE_CONTIGUOUS or not HAVE_MORECORE or or main space is mmapped or a previous contiguous call failed) 2. A call to MMAP new space (disabled if not HAVE_MMAP). Note that under the default settings, if MORECORE is unable to fulfill a request, and HAVE_MMAP is true, then mmap is used as a noncontiguous system allocator. This is a useful backup strategy for systems with holes in address spaces -- in this case sbrk cannot contiguously expand the heap, but mmap may be able to find space. 3. A call to MORECORE that cannot usually contiguously extend memory. (disabled if not HAVE_MORECORE) In all cases, we need to request enough bytes from system to ensure we can malloc nb bytes upon success, so pad with enough space for top_foot, plus alignment-pad to make sure we don't lose bytes if not on boundary, and round this up to a granularity unit. */ if (MORECORE_CONTIGUOUS && !use_noncontiguous(m)) { char* br = CMFAIL; size_t ssize = asize; /* sbrk call size */ msegmentptr ss = (m->top == 0)? 0 : segment_holding(m, (char*)m->top); ACQUIRE_MALLOC_GLOBAL_LOCK(); if (ss == 0) { /* First time through or recovery */ char* base = (char*)CALL_MORECORE(0); if (base != CMFAIL) { size_t fp; /* Adjust to end on a page boundary */ if (!is_page_aligned(base)) ssize += (page_align((size_t)base) - (size_t)base); fp = m->footprint + ssize; /* recheck limits */ if (ssize > nb && ssize < HALF_MAX_SIZE_T && (m->footprint_limit == 0 || (fp > m->footprint && fp <= m->footprint_limit)) && (br = (char*)(CALL_MORECORE(ssize))) == base) { tbase = base; tsize = ssize; } } } else { /* Subtract out existing available top space from MORECORE request. */ ssize = granularity_align(nb - m->topsize + SYS_ALLOC_PADDING); /* Use mem here only if it did continuously extend old space */ if (ssize < HALF_MAX_SIZE_T && (br = (char*)(CALL_MORECORE(ssize))) == ss->base+ss->size) { tbase = br; tsize = ssize; } } if (tbase == CMFAIL) { /* Cope with partial failure */ if (br != CMFAIL) { /* Try to use/extend the space we did get */ if (ssize < HALF_MAX_SIZE_T && ssize < nb + SYS_ALLOC_PADDING) { size_t esize = granularity_align(nb + SYS_ALLOC_PADDING - ssize); if (esize < HALF_MAX_SIZE_T) { char* end = (char*)CALL_MORECORE(esize); if (end != CMFAIL) ssize += esize; else { /* Can't use; try to release */ (void) CALL_MORECORE(-ssize); br = CMFAIL; } } } } if (br != CMFAIL) { /* Use the space we did get */ tbase = br; tsize = ssize; } else disable_contiguous(m); /* Don't try contiguous path in the future */ } RELEASE_MALLOC_GLOBAL_LOCK(); } if (HAVE_MMAP && tbase == CMFAIL) { /* Try MMAP */ char* mp = (char*)(CALL_MMAP(asize)); if (mp != CMFAIL) { tbase = mp; tsize = asize; mmap_flag = USE_MMAP_BIT; } } if (HAVE_MORECORE && tbase == CMFAIL) { /* Try noncontiguous MORECORE */ if (asize < HALF_MAX_SIZE_T) { char* br = CMFAIL; char* end = CMFAIL; ACQUIRE_MALLOC_GLOBAL_LOCK(); br = (char*)(CALL_MORECORE(asize)); end = (char*)(CALL_MORECORE(0)); RELEASE_MALLOC_GLOBAL_LOCK(); if (br != CMFAIL && end != CMFAIL && br < end) { size_t ssize = end - br; if (ssize > nb + TOP_FOOT_SIZE) { tbase = br; tsize = ssize; } } } } if (tbase != CMFAIL) { if ((m->footprint += tsize) > m->max_footprint) m->max_footprint = m->footprint; if (!is_initialized(m)) { /* first-time initialization */ if (m->least_addr == 0 || tbase < m->least_addr) m->least_addr = tbase; m->seg.base = tbase; m->seg.size = tsize; m->seg.sflags = mmap_flag; m->magic = mparams.magic; m->release_checks = MAX_RELEASE_CHECK_RATE; init_bins(m); #if !ONLY_MSPACES if (is_global(m)) init_top(m, (mchunkptr)tbase, tsize - TOP_FOOT_SIZE); else #endif { /* Offset top by embedded malloc_state */ mchunkptr mn = next_chunk(mem2chunk(m)); init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) -TOP_FOOT_SIZE); } } else { /* Try to merge with an existing segment */ msegmentptr sp = &m->seg; /* Only consider most recent segment if traversal suppressed */ while (sp != 0 && tbase != sp->base + sp->size) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag && segment_holds(sp, m->top)) { /* append */ sp->size += tsize; init_top(m, m->top, m->topsize + tsize); } else { if (tbase < m->least_addr) m->least_addr = tbase; sp = &m->seg; while (sp != 0 && sp->base != tbase + tsize) sp = (NO_SEGMENT_TRAVERSAL) ? 0 : sp->next; if (sp != 0 && !is_extern_segment(sp) && (sp->sflags & USE_MMAP_BIT) == mmap_flag) { char* oldbase = sp->base; sp->base = tbase; sp->size += tsize; return prepend_alloc(m, tbase, oldbase, nb); } else add_segment(m, tbase, tsize, mmap_flag); } } if (nb < m->topsize) { /* Allocate from new or extended top space */ size_t rsize = m->topsize -= nb; mchunkptr p = m->top; mchunkptr r = m->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(m, p, nb); check_top_chunk(m, m->top); check_malloced_chunk(m, chunk2mem(p), nb); return chunk2mem(p); } } MALLOC_FAILURE_ACTION; return 0; } /* ----------------------- system deallocation -------------------------- */ /* Unmap and unlink any mmapped segments that don't contain used chunks */ static size_t release_unused_segments(mstate m) { size_t released = 0; int nsegs = 0; msegmentptr pred = &m->seg; msegmentptr sp = pred->next; while (sp != 0) { char* base = sp->base; size_t size = sp->size; msegmentptr next = sp->next; ++nsegs; if (is_mmapped_segment(sp) && !is_extern_segment(sp)) { mchunkptr p = align_as_chunk(base); size_t psize = chunksize(p); /* Can unmap if first chunk holds entire segment and not pinned */ if (!is_inuse(p) && (char*)p + psize >= base + size - TOP_FOOT_SIZE) { tchunkptr tp = (tchunkptr)p; assert(segment_holds(sp, (char*)sp)); if (p == m->dv) { m->dv = 0; m->dvsize = 0; } else { unlink_large_chunk(m, tp); } if (CALL_MUNMAP(base, size) == 0) { released += size; m->footprint -= size; /* unlink obsoleted record */ sp = pred; sp->next = next; } else { /* back out if cannot unmap */ insert_large_chunk(m, tp, psize); } } } if (NO_SEGMENT_TRAVERSAL) /* scan only first segment */ break; pred = sp; sp = next; } /* Reset check counter */ m->release_checks = (((size_t) nsegs > (size_t) MAX_RELEASE_CHECK_RATE)? (size_t) nsegs : (size_t) MAX_RELEASE_CHECK_RATE); return released; } static int sys_trim(mstate m, size_t pad) { size_t released = 0; ensure_initialization(); if (pad < MAX_REQUEST && is_initialized(m)) { pad += TOP_FOOT_SIZE; /* ensure enough room for segment overhead */ if (m->topsize > pad) { /* Shrink top space in granularity-size units, keeping at least one */ size_t unit = mparams.granularity; size_t extra = ((m->topsize - pad + (unit - SIZE_T_ONE)) / unit - SIZE_T_ONE) * unit; msegmentptr sp = segment_holding(m, (char*)m->top); if (!is_extern_segment(sp)) { if (is_mmapped_segment(sp)) { if (HAVE_MMAP && sp->size >= extra && !has_segment_link(m, sp)) { /* can't shrink if pinned */ size_t newsize = sp->size - extra; (void)newsize; /* placate people compiling -Wunused-variable */ /* Prefer mremap, fall back to munmap */ if ((CALL_MREMAP(sp->base, sp->size, newsize, 0) != MFAIL) || (CALL_MUNMAP(sp->base + newsize, extra) == 0)) { released = extra; } } } else if (HAVE_MORECORE) { if (extra >= HALF_MAX_SIZE_T) /* Avoid wrapping negative */ extra = (HALF_MAX_SIZE_T) + SIZE_T_ONE - unit; ACQUIRE_MALLOC_GLOBAL_LOCK(); { /* Make sure end of memory is where we last set it. */ char* old_br = (char*)(CALL_MORECORE(0)); if (old_br == sp->base + sp->size) { char* rel_br = (char*)(CALL_MORECORE(-extra)); char* new_br = (char*)(CALL_MORECORE(0)); if (rel_br != CMFAIL && new_br < old_br) released = old_br - new_br; } } RELEASE_MALLOC_GLOBAL_LOCK(); } } if (released != 0) { sp->size -= released; m->footprint -= released; init_top(m, m->top, m->topsize - released); check_top_chunk(m, m->top); } } /* Unmap any unused mmapped segments */ if (HAVE_MMAP) released += release_unused_segments(m); /* On failure, disable autotrim to avoid repeated failed future calls */ if (released == 0 && m->topsize > m->trim_check) m->trim_check = MAX_SIZE_T; } return (released != 0)? 1 : 0; } /* Consolidate and bin a chunk. Differs from exported versions of free mainly in that the chunk need not be marked as inuse. */ static void dispose_chunk(mstate m, mchunkptr p, size_t psize) { mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { mchunkptr prev; size_t prevsize = p->prev_foot; if (is_mmapped(p)) { psize += prevsize + MMAP_FOOT_PAD; if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) m->footprint -= psize; return; } prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; if (RTCHECK(ok_address(m, prev))) { /* consolidate backward */ if (p != m->dv) { unlink_chunk(m, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { m->dvsize = psize; set_free_with_pinuse(p, psize, next); return; } } else { CORRUPTION_ERROR_ACTION(m); return; } } if (RTCHECK(ok_address(m, next))) { if (!cinuse(next)) { /* consolidate forward */ if (next == m->top) { size_t tsize = m->topsize += psize; m->top = p; p->head = tsize | PINUSE_BIT; if (p == m->dv) { m->dv = 0; m->dvsize = 0; } return; } else if (next == m->dv) { size_t dsize = m->dvsize += psize; m->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); return; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(m, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == m->dv) { m->dvsize = psize; return; } } } else { set_free_with_pinuse(p, psize, next); } insert_chunk(m, p, psize); } else { CORRUPTION_ERROR_ACTION(m); } } /* ---------------------------- malloc --------------------------- */ /* allocate a large request from the best fitting chunk in a treebin */ static void* tmalloc_large(mstate m, size_t nb) { tchunkptr v = 0; size_t rsize = -nb; /* Unsigned negation */ tchunkptr t; bindex_t idx; compute_tree_index(nb, idx); if ((t = *treebin_at(m, idx)) != 0) { /* Traverse tree for this bin looking for node with size == nb */ size_t sizebits = nb << leftshift_for_tree_index(idx); tchunkptr rst = 0; /* The deepest untaken right subtree */ for (;;) { tchunkptr rt; size_t trem = chunksize(t) - nb; if (trem < rsize) { v = t; if ((rsize = trem) == 0) break; } rt = t->child[1]; t = t->child[(sizebits >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]; if (rt != 0 && rt != t) rst = rt; if (t == 0) { t = rst; /* set t to least subtree holding sizes > nb */ break; } sizebits <<= 1; } } if (t == 0 && v == 0) { /* set t to root of next non-empty treebin */ binmap_t leftbits = left_bits(idx2bit(idx)) & m->treemap; if (leftbits != 0) { bindex_t i; binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); t = *treebin_at(m, i); } } while (t != 0) { /* find smallest of tree or subtree */ size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } t = leftmost_child(t); } /* If dv is a better fit, return 0 so malloc will use it */ if (v != 0 && rsize < (size_t)(m->dvsize - nb)) { if (RTCHECK(ok_address(m, v))) { /* split */ mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); insert_chunk(m, r, rsize); } return chunk2mem(v); } } CORRUPTION_ERROR_ACTION(m); } return 0; } /* allocate a small request from the best fitting chunk in a treebin */ static void* tmalloc_small(mstate m, size_t nb) { tchunkptr t, v; size_t rsize; bindex_t i; binmap_t leastbit = least_bit(m->treemap); compute_bit2idx(leastbit, i); v = t = *treebin_at(m, i); rsize = chunksize(t) - nb; while ((t = leftmost_child(t)) != 0) { size_t trem = chunksize(t) - nb; if (trem < rsize) { rsize = trem; v = t; } } if (RTCHECK(ok_address(m, v))) { mchunkptr r = chunk_plus_offset(v, nb); assert(chunksize(v) == rsize + nb); if (RTCHECK(ok_next(v, r))) { unlink_large_chunk(m, v); if (rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(m, v, (rsize + nb)); else { set_size_and_pinuse_of_inuse_chunk(m, v, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(m, r, rsize); } return chunk2mem(v); } } CORRUPTION_ERROR_ACTION(m); return 0; } #if !ONLY_MSPACES void* dlmalloc(size_t bytes) { /* Basic algorithm: If a small request (< 256 bytes minus per-chunk overhead): 1. If one exists, use a remainderless chunk in associated smallbin. (Remainderless means that there are too few excess bytes to represent as a chunk.) 2. If it is big enough, use the dv chunk, which is normally the chunk adjacent to the one used for the most recent small request. 3. If one exists, split the smallest available chunk in a bin, saving remainder in dv. 4. If it is big enough, use the top chunk. 5. If available, get memory from system and use it Otherwise, for a large request: 1. Find the smallest available binned chunk that fits, and use it if it is better fitting than dv chunk, splitting if necessary. 2. If better fitting than any binned chunk, use the dv chunk. 3. If it is big enough, use the top chunk. 4. If request size >= mmap threshold, try to directly mmap this chunk. 5. If available, get memory from system and use it The ugly goto's here ensure that postaction occurs along all paths. */ #if USE_LOCKS ensure_initialization(); /* initialize in sys_alloc if not using locks */ #endif if (!PREACTION(gm)) { void* mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = gm->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(gm, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); unlink_first_small_chunk(gm, b, p, idx); set_inuse_and_pinuse(gm, p, small_index2size(idx)); mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; } else if (nb > gm->dvsize) { if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; size_t rsize; bindex_t i; binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(gm, i); p = b->fd; assert(chunksize(p) == small_index2size(i)); unlink_first_small_chunk(gm, b, p, i); rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(gm, p, small_index2size(i)); else { set_size_and_pinuse_of_inuse_chunk(gm, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(gm, r, rsize); } mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; } else if (gm->treemap != 0 && (mem = tmalloc_small(gm, nb)) != 0) { check_malloced_chunk(gm, mem, nb); goto postaction; } } } else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { nb = pad_request(bytes); if (gm->treemap != 0 && (mem = tmalloc_large(gm, nb)) != 0) { check_malloced_chunk(gm, mem, nb); goto postaction; } } if (nb <= gm->dvsize) { size_t rsize = gm->dvsize - nb; mchunkptr p = gm->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = gm->dv = chunk_plus_offset(p, nb); gm->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(gm, p, nb); } else { /* exhaust dv */ size_t dvs = gm->dvsize; gm->dvsize = 0; gm->dv = 0; set_inuse_and_pinuse(gm, p, dvs); } mem = chunk2mem(p); check_malloced_chunk(gm, mem, nb); goto postaction; } else if (nb < gm->topsize) { /* Split top */ size_t rsize = gm->topsize -= nb; mchunkptr p = gm->top; mchunkptr r = gm->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(gm, p, nb); mem = chunk2mem(p); check_top_chunk(gm, gm->top); check_malloced_chunk(gm, mem, nb); goto postaction; } mem = sys_alloc(gm, nb); postaction: POSTACTION(gm); return mem; } return 0; } /* ---------------------------- free --------------------------- */ void dlfree(void* mem) { /* Consolidate freed chunks with preceeding or succeeding bordering free chunks, if they exist, and then place in a bin. Intermixed with special cases for top, dv, mmapped chunks, and usage errors. */ /*char szBuf[56]; sprintf(szBuf, "free(%p)\n", mem);*/ if (mem != 0) { //syscall( SYS_write, 2, "free\n", strlen("free\n")); mchunkptr p = mem2chunk(mem); #if FOOTERS mstate fm = get_mstate_for(p); if (!ok_magic(fm)) { USAGE_ERROR_ACTION(fm, p); return; } #else /* FOOTERS */ #define fm gm #endif /* FOOTERS */ if (!PREACTION(fm)) { check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { size_t prevsize = p->prev_foot; if (is_mmapped(p)) { psize += prevsize + MMAP_FOOT_PAD; if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; } else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; } } else goto erroraction; } } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { fm->dv = 0; fm->dvsize = 0; } if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; goto postaction; } } } else set_free_with_pinuse(p, psize, next); if (is_small(psize)) { insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); } else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); if (--fm->release_checks == 0) release_unused_segments(fm); } goto postaction; } } erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); } } #if !FOOTERS #undef fm #endif /* FOOTERS */ } void* dlcalloc(size_t n_elements, size_t elem_size) { void* mem; size_t req = 0; if (n_elements != 0) { req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) req = MAX_SIZE_T; /* force downstream failure on overflow */ } mem = dlmalloc(req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) memset(mem, 0, req); return mem; } #endif /* !ONLY_MSPACES */ /* ------------ Internal support for realloc, memalign, etc -------------- */ /* Try to realloc; only in-place unless can_move true */ static mchunkptr try_realloc_chunk(mstate m, mchunkptr p, size_t nb, int can_move) { mchunkptr newp = 0; size_t oldsize = chunksize(p); mchunkptr next = chunk_plus_offset(p, oldsize); if (RTCHECK(ok_address(m, p) && ok_inuse(p) && ok_next(p, next) && ok_pinuse(next))) { if (is_mmapped(p)) { newp = mmap_resize(m, p, nb, can_move); } else if (oldsize >= nb) { /* already big enough */ size_t rsize = oldsize - nb; if (rsize >= MIN_CHUNK_SIZE) { /* split off remainder */ mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); } newp = p; } else if (next == m->top) { /* extend into top */ if (oldsize + m->topsize > nb) { size_t newsize = oldsize + m->topsize; size_t newtopsize = newsize - nb; mchunkptr newtop = chunk_plus_offset(p, nb); set_inuse(m, p, nb); newtop->head = newtopsize |PINUSE_BIT; m->top = newtop; m->topsize = newtopsize; newp = p; } } else if (next == m->dv) { /* extend into dv */ size_t dvs = m->dvsize; if (oldsize + dvs >= nb) { size_t dsize = oldsize + dvs - nb; if (dsize >= MIN_CHUNK_SIZE) { mchunkptr r = chunk_plus_offset(p, nb); mchunkptr n = chunk_plus_offset(r, dsize); set_inuse(m, p, nb); set_size_and_pinuse_of_free_chunk(r, dsize); clear_pinuse(n); m->dvsize = dsize; m->dv = r; } else { /* exhaust dv */ size_t newsize = oldsize + dvs; set_inuse(m, p, newsize); m->dvsize = 0; m->dv = 0; } newp = p; } } else if (!cinuse(next)) { /* extend into next free chunk */ size_t nextsize = chunksize(next); if (oldsize + nextsize >= nb) { size_t rsize = oldsize + nextsize - nb; unlink_chunk(m, next, nextsize); if (rsize < MIN_CHUNK_SIZE) { size_t newsize = oldsize + nextsize; set_inuse(m, p, newsize); } else { mchunkptr r = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, r, rsize); dispose_chunk(m, r, rsize); } newp = p; } } } else { USAGE_ERROR_ACTION(m, chunk2mem(p)); } return newp; } static void* internal_memalign(mstate m, size_t alignment, size_t bytes) { void* mem = 0; if (alignment < MIN_CHUNK_SIZE) /* must be at least a minimum chunk size */ alignment = MIN_CHUNK_SIZE; if ((alignment & (alignment-SIZE_T_ONE)) != 0) {/* Ensure a power of 2 */ size_t a = MALLOC_ALIGNMENT << 1; while (a < alignment) a <<= 1; alignment = a; } if (bytes >= MAX_REQUEST - alignment) { if (m != 0) { /* Test isn't needed but avoids compiler warning */ MALLOC_FAILURE_ACTION; } } else { size_t nb = request2size(bytes); size_t req = nb + alignment + MIN_CHUNK_SIZE - CHUNK_OVERHEAD; mem = internal_malloc(m, req); if (mem != 0) { mchunkptr p = mem2chunk(mem); if (PREACTION(m)) return 0; if ((((size_t)(mem)) & (alignment - 1)) != 0) { /* misaligned */ /* Find an aligned spot inside chunk. Since we need to give back leading space in a chunk of at least MIN_CHUNK_SIZE, if the first calculation places us at a spot with less than MIN_CHUNK_SIZE leader, we can move to the next aligned spot. We've allocated enough total room so that this is always possible. */ char* br = (char*)mem2chunk((size_t)(((size_t)((char*)mem + alignment - SIZE_T_ONE)) & -alignment)); char* pos = ((size_t)(br - (char*)(p)) >= MIN_CHUNK_SIZE)? br : br+alignment; mchunkptr newp = (mchunkptr)pos; size_t leadsize = pos - (char*)(p); size_t newsize = chunksize(p) - leadsize; if (is_mmapped(p)) { /* For mmapped chunks, just adjust offset */ newp->prev_foot = p->prev_foot + leadsize; newp->head = newsize; } else { /* Otherwise, give back leader, use the rest */ set_inuse(m, newp, newsize); set_inuse(m, p, leadsize); dispose_chunk(m, p, leadsize); } p = newp; } /* Give back spare room at the end */ if (!is_mmapped(p)) { size_t size = chunksize(p); if (size > nb + MIN_CHUNK_SIZE) { size_t remainder_size = size - nb; mchunkptr remainder = chunk_plus_offset(p, nb); set_inuse(m, p, nb); set_inuse(m, remainder, remainder_size); dispose_chunk(m, remainder, remainder_size); } } mem = chunk2mem(p); assert (chunksize(p) >= nb); assert(((size_t)mem & (alignment - 1)) == 0); check_inuse_chunk(m, p); POSTACTION(m); } } return mem; } /* Common support for independent_X routines, handling all of the combinations that can result. The opts arg has: bit 0 set if all elements are same size (using sizes[0]) bit 1 set if elements should be zeroed */ static void** ialloc(mstate m, size_t n_elements, size_t* sizes, int opts, void* chunks[]) { size_t element_size; /* chunksize of each element, if all same */ size_t contents_size; /* total size of elements */ size_t array_size; /* request size of pointer array */ void* mem; /* malloced aggregate space */ mchunkptr p; /* corresponding chunk */ size_t remainder_size; /* remaining bytes while splitting */ void** marray; /* either "chunks" or malloced ptr array */ mchunkptr array_chunk; /* chunk for malloced ptr array */ flag_t was_enabled; /* to disable mmap */ size_t size; size_t i; ensure_initialization(); /* compute array length, if needed */ if (chunks != 0) { if (n_elements == 0) return chunks; /* nothing to do */ marray = chunks; array_size = 0; } else { /* if empty req, must still return chunk representing empty array */ if (n_elements == 0) return (void**)internal_malloc(m, 0); marray = 0; array_size = request2size(n_elements * (sizeof(void*))); } /* compute total element size */ if (opts & 0x1) { /* all-same-size */ element_size = request2size(*sizes); contents_size = n_elements * element_size; } else { /* add up all the sizes */ element_size = 0; contents_size = 0; for (i = 0; i != n_elements; ++i) contents_size += request2size(sizes[i]); } size = contents_size + array_size; /* Allocate the aggregate chunk. First disable direct-mmapping so malloc won't use it, since we would not be able to later free/realloc space internal to a segregated mmap region. */ was_enabled = use_mmap(m); disable_mmap(m); mem = internal_malloc(m, size - CHUNK_OVERHEAD); if (was_enabled) enable_mmap(m); if (mem == 0) return 0; if (PREACTION(m)) return 0; p = mem2chunk(mem); remainder_size = chunksize(p); assert(!is_mmapped(p)); if (opts & 0x2) { /* optionally clear the elements */ memset((size_t*)mem, 0, remainder_size - SIZE_T_SIZE - array_size); } /* If not provided, allocate the pointer array as final part of chunk */ if (marray == 0) { size_t array_chunk_size; array_chunk = chunk_plus_offset(p, contents_size); array_chunk_size = remainder_size - contents_size; marray = (void**) (chunk2mem(array_chunk)); set_size_and_pinuse_of_inuse_chunk(m, array_chunk, array_chunk_size); remainder_size = contents_size; } /* split out elements */ for (i = 0; ; ++i) { marray[i] = chunk2mem(p); if (i != n_elements-1) { if (element_size != 0) size = element_size; else size = request2size(sizes[i]); remainder_size -= size; set_size_and_pinuse_of_inuse_chunk(m, p, size); p = chunk_plus_offset(p, size); } else { /* the final element absorbs any overallocation slop */ set_size_and_pinuse_of_inuse_chunk(m, p, remainder_size); break; } } #if DEBUG if (marray != chunks) { /* final element must have exactly exhausted chunk */ if (element_size != 0) { assert(remainder_size == element_size); } else { assert(remainder_size == request2size(sizes[i])); } check_inuse_chunk(m, mem2chunk(marray)); } for (i = 0; i != n_elements; ++i) check_inuse_chunk(m, mem2chunk(marray[i])); #endif /* DEBUG */ POSTACTION(m); return marray; } /* Try to free all pointers in the given array. Note: this could be made faster, by delaying consolidation, at the price of disabling some user integrity checks, We still optimize some consolidations by combining adjacent chunks before freeing, which will occur often if allocated with ialloc or the array is sorted. */ static size_t internal_bulk_free(mstate m, void* array[], size_t nelem) { size_t unfreed = 0; if (!PREACTION(m)) { void** a; void** fence = &(array[nelem]); for (a = array; a != fence; ++a) { void* mem = *a; if (mem != 0) { mchunkptr p = mem2chunk(mem); size_t psize = chunksize(p); #if FOOTERS if (get_mstate_for(p) != m) { ++unfreed; continue; } #endif check_inuse_chunk(m, p); *a = 0; if (RTCHECK(ok_address(m, p) && ok_inuse(p))) { void ** b = a + 1; /* try to merge with next chunk */ mchunkptr next = next_chunk(p); if (b != fence && *b == chunk2mem(next)) { size_t newsize = chunksize(next) + psize; set_inuse(m, p, newsize); *b = chunk2mem(p); } else dispose_chunk(m, p, psize); } else { CORRUPTION_ERROR_ACTION(m); break; } } } if (should_trim(m, m->topsize)) sys_trim(m, 0); POSTACTION(m); } return unfreed; } /* Traversal */ #if MALLOC_INSPECT_ALL static void internal_inspect_all(mstate m, void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg) { if (is_initialized(m)) { mchunkptr top = m->top; msegmentptr s; for (s = &m->seg; s != 0; s = s->next) { mchunkptr q = align_as_chunk(s->base); while (segment_holds(s, q) && q->head != FENCEPOST_HEAD) { mchunkptr next = next_chunk(q); size_t sz = chunksize(q); size_t used; void* start; if (is_inuse(q)) { used = sz - CHUNK_OVERHEAD; /* must not be mmapped */ start = chunk2mem(q); } else { used = 0; if (is_small(sz)) { /* offset by possible bookkeeping */ start = (void*)((char*)q + sizeof(struct malloc_chunk)); } else { start = (void*)((char*)q + sizeof(struct malloc_tree_chunk)); } } if (start < (void*)next) /* skip if all space is bookkeeping */ handler(start, next, used, arg); if (q == top) break; q = next; } } } } #endif /* MALLOC_INSPECT_ALL */ /* ------------------ Exported realloc, memalign, etc -------------------- */ #if !ONLY_MSPACES void* dlrealloc(void* oldmem, size_t bytes) { void* mem = 0; if (oldmem == 0) { mem = dlmalloc(bytes); } else if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { dlfree(oldmem); } #endif /* REALLOC_ZERO_BYTES_FREES */ else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = gm; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { check_inuse_chunk(m, newp); mem = chunk2mem(newp); } else { mem = internal_malloc(m, bytes); if (mem != 0) { size_t oc = chunksize(oldp) - overhead_for(oldp); memcpy(mem, oldmem, (oc < bytes)? oc : bytes); internal_free(m, oldmem); } } } } return mem; } void* dlrealloc_in_place(void* oldmem, size_t bytes) { void* mem = 0; if (oldmem != 0) { if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = gm; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { check_inuse_chunk(m, newp); mem = oldmem; } } } } return mem; } void* dlmemalign(size_t alignment, size_t bytes) { if (alignment <= MALLOC_ALIGNMENT) { return dlmalloc(bytes); } return internal_memalign(gm, alignment, bytes); } int dlposix_memalign(void** pp, size_t alignment, size_t bytes) { void* mem = 0; if (alignment == MALLOC_ALIGNMENT) mem = dlmalloc(bytes); else { size_t d = alignment / sizeof(void*); size_t r = alignment % sizeof(void*); if (r != 0 || d == 0 || (d & (d-SIZE_T_ONE)) != 0) return EINVAL; else if (bytes <= MAX_REQUEST - alignment) { if (alignment < MIN_CHUNK_SIZE) alignment = MIN_CHUNK_SIZE; mem = internal_memalign(gm, alignment, bytes); } } if (mem == 0) return ENOMEM; else { *pp = mem; return 0; } } void* dlvalloc(size_t bytes) { size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, bytes); } void* dlpvalloc(size_t bytes) { size_t pagesz; ensure_initialization(); pagesz = mparams.page_size; return dlmemalign(pagesz, (bytes + pagesz - SIZE_T_ONE) & ~(pagesz - SIZE_T_ONE)); } void** dlindependent_calloc(size_t n_elements, size_t elem_size, void* chunks[]) { size_t sz = elem_size; /* serves as 1-element array */ return ialloc(gm, n_elements, &sz, 3, chunks); } void** dlindependent_comalloc(size_t n_elements, size_t sizes[], void* chunks[]) { return ialloc(gm, n_elements, sizes, 0, chunks); } size_t dlbulk_free(void* array[], size_t nelem) { return internal_bulk_free(gm, array, nelem); } #if MALLOC_INSPECT_ALL void dlmalloc_inspect_all(void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg) { ensure_initialization(); if (!PREACTION(gm)) { internal_inspect_all(gm, handler, arg); POSTACTION(gm); } } #endif /* MALLOC_INSPECT_ALL */ int dlmalloc_trim(size_t pad) { int result = 0; ensure_initialization(); if (!PREACTION(gm)) { result = sys_trim(gm, pad); POSTACTION(gm); } return result; } size_t dlmalloc_footprint(void) { return gm->footprint; } size_t dlmalloc_max_footprint(void) { return gm->max_footprint; } size_t dlmalloc_footprint_limit(void) { size_t maf = gm->footprint_limit; return maf == 0 ? MAX_SIZE_T : maf; } size_t dlmalloc_set_footprint_limit(size_t bytes) { size_t result; /* invert sense of 0 */ if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) result = 0; /* disable */ else result = granularity_align(bytes); return gm->footprint_limit = result; } #if !NO_MALLINFO struct mallinfo dlmallinfo(void) { return internal_mallinfo(gm); } #endif /* NO_MALLINFO */ #if !NO_MALLOC_STATS void dlmalloc_stats() { internal_malloc_stats(gm); } #endif /* NO_MALLOC_STATS */ int dlmallopt(int param_number, int value) { return change_mparam(param_number, value); } size_t dlmalloc_usable_size(void* mem) { if (mem != 0) { mchunkptr p = mem2chunk(mem); if (is_inuse(p)) return chunksize(p) - overhead_for(p); } return 0; } #endif /* !ONLY_MSPACES */ /* ----------------------------- user mspaces ---------------------------- */ #if MSPACES static mstate init_user_mstate(char* tbase, size_t tsize) { size_t msize = pad_request(sizeof(struct malloc_state)); mchunkptr mn; mchunkptr msp = align_as_chunk(tbase); mstate m = (mstate)(chunk2mem(msp)); memset(m, 0, msize); (void)INITIAL_LOCK(&m->mutex); msp->head = (msize|INUSE_BITS); m->seg.base = m->least_addr = tbase; m->seg.size = m->footprint = m->max_footprint = tsize; m->magic = mparams.magic; m->release_checks = MAX_RELEASE_CHECK_RATE; m->mflags = mparams.default_mflags; m->extp = 0; m->exts = 0; disable_contiguous(m); init_bins(m); mn = next_chunk(mem2chunk(m)); init_top(m, mn, (size_t)((tbase + tsize) - (char*)mn) - TOP_FOOT_SIZE); check_top_chunk(m, m->top); return m; } mspace create_mspace(size_t capacity, int locked) { mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { size_t rs = ((capacity == 0)? mparams.granularity : (capacity + TOP_FOOT_SIZE + msize)); size_t tsize = granularity_align(rs); char* tbase = (char*)(CALL_MMAP(tsize)); if (tbase != CMFAIL) { m = init_user_mstate(tbase, tsize); m->seg.sflags = USE_MMAP_BIT; set_lock(m, locked); } } return (mspace)m; } mspace create_mspace_with_base(void* base, size_t capacity, int locked) { mstate m = 0; size_t msize; ensure_initialization(); msize = pad_request(sizeof(struct malloc_state)); if (capacity > msize + TOP_FOOT_SIZE && capacity < (size_t) -(msize + TOP_FOOT_SIZE + mparams.page_size)) { m = init_user_mstate((char*)base, capacity); m->seg.sflags = EXTERN_BIT; set_lock(m, locked); } return (mspace)m; } int mspace_track_large_chunks(mspace msp, int enable) { int ret = 0; mstate ms = (mstate)msp; if (!PREACTION(ms)) { if (!use_mmap(ms)) { ret = 1; } if (!enable) { enable_mmap(ms); } else { disable_mmap(ms); } POSTACTION(ms); } return ret; } size_t destroy_mspace(mspace msp) { size_t freed = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { msegmentptr sp = &ms->seg; (void)DESTROY_LOCK(&ms->mutex); /* destroy before unmapped */ while (sp != 0) { char* base = sp->base; size_t size = sp->size; flag_t flag = sp->sflags; (void)base; /* placate people compiling -Wunused-variable */ sp = sp->next; if ((flag & USE_MMAP_BIT) && !(flag & EXTERN_BIT) && CALL_MUNMAP(base, size) == 0) freed += size; } } else { USAGE_ERROR_ACTION(ms,ms); } return freed; } /* mspace versions of routines are near-clones of the global versions. This is not so nice but better than the alternatives. */ void* mspace_malloc(mspace msp, size_t bytes) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } if (!PREACTION(ms)) { void* mem; size_t nb; if (bytes <= MAX_SMALL_REQUEST) { bindex_t idx; binmap_t smallbits; nb = (bytes < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(bytes); idx = small_index(nb); smallbits = ms->smallmap >> idx; if ((smallbits & 0x3U) != 0) { /* Remainderless fit to a smallbin. */ mchunkptr b, p; idx += ~smallbits & 1; /* Uses next bin if idx empty */ b = smallbin_at(ms, idx); p = b->fd; assert(chunksize(p) == small_index2size(idx)); unlink_first_small_chunk(ms, b, p, idx); set_inuse_and_pinuse(ms, p, small_index2size(idx)); mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; } else if (nb > ms->dvsize) { if (smallbits != 0) { /* Use chunk in next nonempty smallbin */ mchunkptr b, p, r; size_t rsize; bindex_t i; binmap_t leftbits = (smallbits << idx) & left_bits(idx2bit(idx)); binmap_t leastbit = least_bit(leftbits); compute_bit2idx(leastbit, i); b = smallbin_at(ms, i); p = b->fd; assert(chunksize(p) == small_index2size(i)); unlink_first_small_chunk(ms, b, p, i); rsize = small_index2size(i) - nb; /* Fit here cannot be remainderless if 4byte sizes */ if (SIZE_T_SIZE != 4 && rsize < MIN_CHUNK_SIZE) set_inuse_and_pinuse(ms, p, small_index2size(i)); else { set_size_and_pinuse_of_inuse_chunk(ms, p, nb); r = chunk_plus_offset(p, nb); set_size_and_pinuse_of_free_chunk(r, rsize); replace_dv(ms, r, rsize); } mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; } else if (ms->treemap != 0 && (mem = tmalloc_small(ms, nb)) != 0) { check_malloced_chunk(ms, mem, nb); goto postaction; } } } else if (bytes >= MAX_REQUEST) nb = MAX_SIZE_T; /* Too big to allocate. Force failure (in sys alloc) */ else { nb = pad_request(bytes); if (ms->treemap != 0 && (mem = tmalloc_large(ms, nb)) != 0) { check_malloced_chunk(ms, mem, nb); goto postaction; } } if (nb <= ms->dvsize) { size_t rsize = ms->dvsize - nb; mchunkptr p = ms->dv; if (rsize >= MIN_CHUNK_SIZE) { /* split dv */ mchunkptr r = ms->dv = chunk_plus_offset(p, nb); ms->dvsize = rsize; set_size_and_pinuse_of_free_chunk(r, rsize); set_size_and_pinuse_of_inuse_chunk(ms, p, nb); } else { /* exhaust dv */ size_t dvs = ms->dvsize; ms->dvsize = 0; ms->dv = 0; set_inuse_and_pinuse(ms, p, dvs); } mem = chunk2mem(p); check_malloced_chunk(ms, mem, nb); goto postaction; } else if (nb < ms->topsize) { /* Split top */ size_t rsize = ms->topsize -= nb; mchunkptr p = ms->top; mchunkptr r = ms->top = chunk_plus_offset(p, nb); r->head = rsize | PINUSE_BIT; set_size_and_pinuse_of_inuse_chunk(ms, p, nb); mem = chunk2mem(p); check_top_chunk(ms, ms->top); check_malloced_chunk(ms, mem, nb); goto postaction; } mem = sys_alloc(ms, nb); postaction: POSTACTION(ms); return mem; } return 0; } void mspace_free(mspace msp, void* mem) { if (mem != 0) { mchunkptr p = mem2chunk(mem); #if FOOTERS mstate fm = get_mstate_for(p); (void)msp; /* placate people compiling -Wunused */ #else /* FOOTERS */ mstate fm = (mstate)msp; #endif /* FOOTERS */ if (!ok_magic(fm)) { USAGE_ERROR_ACTION(fm, p); return; } if (!PREACTION(fm)) { check_inuse_chunk(fm, p); if (RTCHECK(ok_address(fm, p) && ok_inuse(p))) { size_t psize = chunksize(p); mchunkptr next = chunk_plus_offset(p, psize); if (!pinuse(p)) { size_t prevsize = p->prev_foot; if (is_mmapped(p)) { psize += prevsize + MMAP_FOOT_PAD; if (CALL_MUNMAP((char*)p - prevsize, psize) == 0) fm->footprint -= psize; goto postaction; } else { mchunkptr prev = chunk_minus_offset(p, prevsize); psize += prevsize; p = prev; if (RTCHECK(ok_address(fm, prev))) { /* consolidate backward */ if (p != fm->dv) { unlink_chunk(fm, p, prevsize); } else if ((next->head & INUSE_BITS) == INUSE_BITS) { fm->dvsize = psize; set_free_with_pinuse(p, psize, next); goto postaction; } } else goto erroraction; } } if (RTCHECK(ok_next(p, next) && ok_pinuse(next))) { if (!cinuse(next)) { /* consolidate forward */ if (next == fm->top) { size_t tsize = fm->topsize += psize; fm->top = p; p->head = tsize | PINUSE_BIT; if (p == fm->dv) { fm->dv = 0; fm->dvsize = 0; } if (should_trim(fm, tsize)) sys_trim(fm, 0); goto postaction; } else if (next == fm->dv) { size_t dsize = fm->dvsize += psize; fm->dv = p; set_size_and_pinuse_of_free_chunk(p, dsize); goto postaction; } else { size_t nsize = chunksize(next); psize += nsize; unlink_chunk(fm, next, nsize); set_size_and_pinuse_of_free_chunk(p, psize); if (p == fm->dv) { fm->dvsize = psize; goto postaction; } } } else set_free_with_pinuse(p, psize, next); if (is_small(psize)) { insert_small_chunk(fm, p, psize); check_free_chunk(fm, p); } else { tchunkptr tp = (tchunkptr)p; insert_large_chunk(fm, tp, psize); check_free_chunk(fm, p); if (--fm->release_checks == 0) release_unused_segments(fm); } goto postaction; } } erroraction: USAGE_ERROR_ACTION(fm, p); postaction: POSTACTION(fm); } } } void* mspace_calloc(mspace msp, size_t n_elements, size_t elem_size) { void* mem; size_t req = 0; mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } if (n_elements != 0) { req = n_elements * elem_size; if (((n_elements | elem_size) & ~(size_t)0xffff) && (req / n_elements != elem_size)) req = MAX_SIZE_T; /* force downstream failure on overflow */ } mem = internal_malloc(ms, req); if (mem != 0 && calloc_must_clear(mem2chunk(mem))) memset(mem, 0, req); return mem; } void* mspace_realloc(mspace msp, void* oldmem, size_t bytes) { void* mem = 0; if (oldmem == 0) { mem = mspace_malloc(msp, bytes); } else if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } #ifdef REALLOC_ZERO_BYTES_FREES else if (bytes == 0) { mspace_free(msp, oldmem); } #endif /* REALLOC_ZERO_BYTES_FREES */ else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = (mstate)msp; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 1); POSTACTION(m); if (newp != 0) { check_inuse_chunk(m, newp); mem = chunk2mem(newp); } else { mem = mspace_malloc(m, bytes); if (mem != 0) { size_t oc = chunksize(oldp) - overhead_for(oldp); memcpy(mem, oldmem, (oc < bytes)? oc : bytes); mspace_free(m, oldmem); } } } } return mem; } void* mspace_realloc_in_place(mspace msp, void* oldmem, size_t bytes) { void* mem = 0; if (oldmem != 0) { if (bytes >= MAX_REQUEST) { MALLOC_FAILURE_ACTION; } else { size_t nb = request2size(bytes); mchunkptr oldp = mem2chunk(oldmem); #if ! FOOTERS mstate m = (mstate)msp; #else /* FOOTERS */ mstate m = get_mstate_for(oldp); (void)msp; /* placate people compiling -Wunused */ if (!ok_magic(m)) { USAGE_ERROR_ACTION(m, oldmem); return 0; } #endif /* FOOTERS */ if (!PREACTION(m)) { mchunkptr newp = try_realloc_chunk(m, oldp, nb, 0); POSTACTION(m); if (newp == oldp) { check_inuse_chunk(m, newp); mem = oldmem; } } } } return mem; } void* mspace_memalign(mspace msp, size_t alignment, size_t bytes) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } if (alignment <= MALLOC_ALIGNMENT) return mspace_malloc(msp, bytes); return internal_memalign(ms, alignment, bytes); } void** mspace_independent_calloc(mspace msp, size_t n_elements, size_t elem_size, void* chunks[]) { size_t sz = elem_size; /* serves as 1-element array */ mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } return ialloc(ms, n_elements, &sz, 3, chunks); } void** mspace_independent_comalloc(mspace msp, size_t n_elements, size_t sizes[], void* chunks[]) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); return 0; } return ialloc(ms, n_elements, sizes, 0, chunks); } size_t mspace_bulk_free(mspace msp, void* array[], size_t nelem) { return internal_bulk_free((mstate)msp, array, nelem); } #if MALLOC_INSPECT_ALL void mspace_inspect_all(mspace msp, void(*handler)(void *start, void *end, size_t used_bytes, void* callback_arg), void* arg) { mstate ms = (mstate)msp; if (ok_magic(ms)) { if (!PREACTION(ms)) { internal_inspect_all(ms, handler, arg); POSTACTION(ms); } } else { USAGE_ERROR_ACTION(ms,ms); } } #endif /* MALLOC_INSPECT_ALL */ int mspace_trim(mspace msp, size_t pad) { int result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { if (!PREACTION(ms)) { result = sys_trim(ms, pad); POSTACTION(ms); } } else { USAGE_ERROR_ACTION(ms,ms); } return result; } #if !NO_MALLOC_STATS void mspace_malloc_stats(mspace msp) { mstate ms = (mstate)msp; if (ok_magic(ms)) { internal_malloc_stats(ms); } else { USAGE_ERROR_ACTION(ms,ms); } } #endif /* NO_MALLOC_STATS */ size_t mspace_footprint(mspace msp) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { result = ms->footprint; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } size_t mspace_max_footprint(mspace msp) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { result = ms->max_footprint; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } size_t mspace_footprint_limit(mspace msp) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { size_t maf = ms->footprint_limit; result = (maf == 0) ? MAX_SIZE_T : maf; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { size_t result = 0; mstate ms = (mstate)msp; if (ok_magic(ms)) { if (bytes == 0) result = granularity_align(1); /* Use minimal size */ if (bytes == MAX_SIZE_T) result = 0; /* disable */ else result = granularity_align(bytes); ms->footprint_limit = result; } else { USAGE_ERROR_ACTION(ms,ms); } return result; } #if !NO_MALLINFO struct mallinfo mspace_mallinfo(mspace msp) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms); } return internal_mallinfo(ms); } #endif /* NO_MALLINFO */ size_t mspace_usable_size(const void* mem) { if (mem != 0) { mchunkptr p = mem2chunk(mem); if (is_inuse(p)) return chunksize(p) - overhead_for(p); } return 0; } int mspace_mallopt(int param_number, int value) { return change_mparam(param_number, value); } #endif /* MSPACES */ /* -------------------- Alternative MORECORE functions ------------------- */ /* Guidelines for creating a custom version of MORECORE: * For best performance, MORECORE should allocate in multiples of pagesize. * MORECORE may allocate more memory than requested. (Or even less, but this will usually result in a malloc failure.) * MORECORE must not allocate memory when given argument zero, but instead return one past the end address of memory from previous nonzero call. * For best performance, consecutive calls to MORECORE with positive arguments should return increasing addresses, indicating that space has been contiguously extended. * Even though consecutive calls to MORECORE need not return contiguous addresses, it must be OK for malloc'ed chunks to span multiple regions in those cases where they do happen to be contiguous. * MORECORE need not handle negative arguments -- it may instead just return MFAIL when given negative arguments. Negative arguments are always multiples of pagesize. MORECORE must not misinterpret negative args as large positive unsigned args. You can suppress all such calls from even occurring by defining MORECORE_CANNOT_TRIM, As an example alternative MORECORE, here is a custom allocator kindly contributed for pre-OSX macOS. It uses virtually but not necessarily physically contiguous non-paged memory (locked in, present and won't get swapped out). You can use it by uncommenting this section, adding some #includes, and setting up the appropriate defines above: #define MORECORE osMoreCore There is also a shutdown routine that should somehow be called for cleanup upon program exit. #define MAX_POOL_ENTRIES 100 #define MINIMUM_MORECORE_SIZE (64 * 1024U) static int next_os_pool; void *our_os_pools[MAX_POOL_ENTRIES]; void *osMoreCore(int size) { void *ptr = 0; static void *sbrk_top = 0; if (size > 0) { if (size < MINIMUM_MORECORE_SIZE) size = MINIMUM_MORECORE_SIZE; if (CurrentExecutionLevel() == kTaskLevel) ptr = PoolAllocateResident(size + RM_PAGE_SIZE, 0); if (ptr == 0) { return (void *) MFAIL; } // save ptrs so they can be freed during cleanup our_os_pools[next_os_pool] = ptr; next_os_pool++; ptr = (void *) ((((size_t) ptr) + RM_PAGE_MASK) & ~RM_PAGE_MASK); sbrk_top = (char *) ptr + size; return ptr; } else if (size < 0) { // we don't currently support shrink behavior return (void *) MFAIL; } else { return sbrk_top; } } // cleanup any allocated memory pools // called as last thing before shutting down driver void osCleanupMem(void) { void **ptr; for (ptr = our_os_pools; ptr < &our_os_pools[MAX_POOL_ENTRIES]; ptr++) if (*ptr) { PoolDeallocate(*ptr); *ptr = 0; } } */ /* ----------------------------------------------------------------------- History: v2.8.6 Wed Aug 29 06:57:58 2012 Doug Lea * fix bad comparison in dlposix_memalign * don't reuse adjusted asize in sys_alloc * add LOCK_AT_FORK -- thanks to Kirill Artamonov for the suggestion * reduce compiler warnings -- thanks to all who reported/suggested these v2.8.5 Sun May 22 10:26:02 2011 Doug Lea (dl at gee) * Always perform unlink checks unless INSECURE * Add posix_memalign. * Improve realloc to expand in more cases; expose realloc_in_place. Thanks to Peter Buhr for the suggestion. * Add footprint_limit, inspect_all, bulk_free. Thanks to Barry Hayes and others for the suggestions. * Internal refactorings to avoid calls while holding locks * Use non-reentrant locks by default. Thanks to Roland McGrath for the suggestion. * Small fixes to mspace_destroy, reset_on_error. * Various configuration extensions/changes. Thanks to all who contributed these. V2.8.4a Thu Apr 28 14:39:43 2011 (dl at gee.cs.oswego.edu) * Update Creative Commons URL V2.8.4 Wed May 27 09:56:23 2009 Doug Lea (dl at gee) * Use zeros instead of prev foot for is_mmapped * Add mspace_track_large_chunks; thanks to Jean Brouwers * Fix set_inuse in internal_realloc; thanks to Jean Brouwers * Fix insufficient sys_alloc padding when using 16byte alignment * Fix bad error check in mspace_footprint * Adaptations for ptmalloc; thanks to Wolfram Gloger. * Reentrant spin locks; thanks to Earl Chew and others * Win32 improvements; thanks to Niall Douglas and Earl Chew * Add NO_SEGMENT_TRAVERSAL and MAX_RELEASE_CHECK_RATE options * Extension hook in malloc_state * Various small adjustments to reduce warnings on some compilers * Various configuration extensions/changes for more platforms. Thanks to all who contributed these. V2.8.3 Thu Sep 22 11:16:32 2005 Doug Lea (dl at gee) * Add max_footprint functions * Ensure all appropriate literals are size_t * Fix conditional compilation problem for some #define settings * Avoid concatenating segments with the one provided in create_mspace_with_base * Rename some variables to avoid compiler shadowing warnings * Use explicit lock initialization. * Better handling of sbrk interference. * Simplify and fix segment insertion, trimming and mspace_destroy * Reinstate REALLOC_ZERO_BYTES_FREES option from 2.7.x * Thanks especially to Dennis Flanagan for help on these. V2.8.2 Sun Jun 12 16:01:10 2005 Doug Lea (dl at gee) * Fix memalign brace error. V2.8.1 Wed Jun 8 16:11:46 2005 Doug Lea (dl at gee) * Fix improper #endif nesting in C++ * Add explicit casts needed for C++ V2.8.0 Mon May 30 14:09:02 2005 Doug Lea (dl at gee) * Use trees for large bins * Support mspaces * Use segments to unify sbrk-based and mmap-based system allocation, removing need for emulation on most platforms without sbrk. * Default safety checks * Optional footer checks. Thanks to William Robertson for the idea. * Internal code refactoring * Incorporate suggestions and platform-specific changes. Thanks to Dennis Flanagan, Colin Plumb, Niall Douglas, Aaron Bachmann, Emery Berger, and others. * Speed up non-fastbin processing enough to remove fastbins. * Remove useless cfree() to avoid conflicts with other apps. * Remove internal memcpy, memset. Compilers handle builtins better. * Remove some options that no one ever used and rename others. V2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee) * Fix malloc_state bitmap array misdeclaration V2.7.1 Thu Jul 25 10:58:03 2002 Doug Lea (dl at gee) * Allow tuning of FIRST_SORTED_BIN_SIZE * Use PTR_UINT as type for all ptr->int casts. Thanks to John Belmonte. * Better detection and support for non-contiguousness of MORECORE. Thanks to Andreas Mueller, Conal Walsh, and Wolfram Gloger * Bypass most of malloc if no frees. Thanks To Emery Berger. * Fix freeing of old top non-contiguous chunk im sysmalloc. * Raised default trim and map thresholds to 256K. * Fix mmap-related #defines. Thanks to Lubos Lunak. * Fix copy macros; added LACKS_FCNTL_H. Thanks to Neal Walfield. * Branch-free bin calculation * Default trim and mmap thresholds now 256K. V2.7.0 Sun Mar 11 14:14:06 2001 Doug Lea (dl at gee) * Introduce independent_comalloc and independent_calloc. Thanks to Michael Pachos for motivation and help. * Make optional .h file available * Allow > 2GB requests on 32bit systems. * new WIN32 sbrk, mmap, munmap, lock code from <[email protected]>. Thanks also to Andreas Mueller <a.mueller at paradatec.de>, and Anonymous. * Allow override of MALLOC_ALIGNMENT (Thanks to Ruud Waij for helping test this.) * memalign: check alignment arg * realloc: don't try to shift chunks backwards, since this leads to more fragmentation in some programs and doesn't seem to help in any others. * Collect all cases in malloc requiring system memory into sysmalloc * Use mmap as backup to sbrk * Place all internal state in malloc_state * Introduce fastbins (although similar to 2.5.1) * Many minor tunings and cosmetic improvements * Introduce USE_PUBLIC_MALLOC_WRAPPERS, USE_MALLOC_LOCK * Introduce MALLOC_FAILURE_ACTION, MORECORE_CONTIGUOUS Thanks to Tony E. Bennett <[email protected]> and others. * Include errno.h to support default failure action. V2.6.6 Sun Dec 5 07:42:19 1999 Doug Lea (dl at gee) * return null for negative arguments * Added Several WIN32 cleanups from Martin C. Fong <mcfong at yahoo.com> * Add 'LACKS_SYS_PARAM_H' for those systems without 'sys/param.h' (e.g. WIN32 platforms) * Cleanup header file inclusion for WIN32 platforms * Cleanup code to avoid Microsoft Visual C++ compiler complaints * Add 'USE_DL_PREFIX' to quickly allow co-existence with existing memory allocation routines * Set 'malloc_getpagesize' for WIN32 platforms (needs more work) * Use 'assert' rather than 'ASSERT' in WIN32 code to conform to usage of 'assert' in non-WIN32 code * Improve WIN32 'sbrk()' emulation's 'findRegion()' routine to avoid infinite loop * Always call 'fREe()' rather than 'free()' V2.6.5 Wed Jun 17 15:57:31 1998 Doug Lea (dl at gee) * Fixed ordering problem with boundary-stamping V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee) * Added pvalloc, as recommended by H.J. Liu * Added 64bit pointer support mainly from Wolfram Gloger * Added anonymously donated WIN32 sbrk emulation * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen * malloc_extend_top: fix mask error that caused wastage after foreign sbrks * Add linux mremap support code from HJ Liu V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee) * Integrated most documentation with the code. * Add support for mmap, with help from Wolfram Gloger ([email protected]). * Use last_remainder in more cases. * Pack bins using idea from [email protected] * Use ordered bins instead of best-fit threshhold * Eliminate block-local decls to simplify tracing and debugging. * Support another case of realloc via move into top * Fix error occuring when initial sbrk_base not word-aligned. * Rely on page size for units instead of SBRK_UNIT to avoid surprises about sbrk alignment conventions. * Add mallinfo, mallopt. Thanks to Raymond Nijssen ([email protected]) for the suggestion. * Add `pad' argument to malloc_trim and top_pad mallopt parameter. * More precautions for cases where other routines call sbrk, courtesy of Wolfram Gloger ([email protected]). * Added macros etc., allowing use in linux libc from H.J. Lu ([email protected]) * Inverted this history list V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee) * Re-tuned and fixed to behave more nicely with V2.6.0 changes. * Removed all preallocation code since under current scheme the work required to undo bad preallocations exceeds the work saved in good cases for most test programs. * No longer use return list or unconsolidated bins since no scheme using them consistently outperforms those that don't given above changes. * Use best fit for very large chunks to prevent some worst-cases. * Added some support for debugging V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee) * Removed footers when chunks are in use. Thanks to Paul Wilson ([email protected]) for the suggestion. V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee) * Added malloc_trim, with help from Wolfram Gloger ([email protected]). V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g) V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g) * realloc: try to expand in both directions * malloc: swap order of clean-bin strategy; * realloc: only conditionally expand backwards * Try not to scavenge used bins * Use bin counts as a guide to preallocation * Occasionally bin return list chunks in first scan * Add a few optimizations from [email protected] V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g) * faster bin computation & slightly different binning * merged all consolidations to one part of malloc proper (eliminating old malloc_find_space & malloc_clean_bin) * Scan 2 returns chunks (not just 1) * Propagate failure in realloc if malloc returns 0 * Add stuff to allow compilation on non-ANSI compilers from [email protected] V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu) * removed potential for odd address access in prev_chunk * removed dependency on getpagesize.h * misc cosmetics and a bit more internal documentation * anticosmetics: mangled names in macros to evade debugger strangeness * tested on sparc, hp-700, dec-mips, rs6000 with gcc & native cc (hp, dec only) allowing Detlefs & Zorn comparison study (in SIGPLAN Notices.) Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu) * Based loosely on libg++-1.2X malloc. (It retains some of the overall structure of old version, but most details differ.) */
the_stack_data/168892304.c
#include<stdio.h> char name[40],address[50],cindate[10],coutdate[10];//global vairables float rent,laundry_bill=0,res_bill=0,game_bill=0;//global vairables void inputdata() { printf("Enter your Name: "); scanf("%s",name); printf("Enter your Address: "); scanf("%s",address); printf("Enter Check in Date: "); scanf("%s",cindate); printf("Enter Check out Date: "); scanf("%s",coutdate); } void roomrent() { int x,n; printf("***We have the following types of rooms***\n"); printf("1. Master Suite Rs. 8000 per night\n"); printf("2. Mini-Suite Rs. 7000 per night\n"); printf("3. Double Rs. 5000 per night\n"); printf("4. Single Rs. 4000 per night\n"); printf("Enter your choice: "); scanf("%d",&x); printf("No. of Nights: "); scanf("%d",&n); if(x==1){ printf("You have opted Master Suite\n"); rent=n*8000; } else if(x==2){ printf("You have opted Mini-Suite\n"); rent=n*7000; } else if(x==3){ printf("You have opted Double\n"); rent=n*5000; } else { printf("You have opted Single\n"); rent=n*4000; } printf("Your Room rent = %.2f\n",rent); } void restaurent() { int c,d; printf("#############RESTAURENT MENU#############\n"); printf("1.Water Rs. 50\n"); printf("2.Tea/Coffee Rs. 90\n"); printf("3.Special Breakfast combo Rs. 200\n"); printf("4.Special Lunch combo Rs. 300\n"); printf("5.Special Dinner combo Rs. 250\n"); printf("6.Exit\n"); while(1) { printf("Enter Choice: "); scanf("%d",&c); if (c==1){ printf("Enter quantity: "); scanf("%d",&d); res_bill+=50*d; } else if (c==2){ printf("Enter quantity: "); scanf("%d",&d); res_bill+=90*d; } else if (c==3){ printf("Enter quantity: "); scanf("%d",&d); res_bill+=200*d; } else if (c==4){ printf("Enter quantity: "); scanf("%d",&d); res_bill+=300*d; } else if (c==5){ printf("Enter quantity: "); scanf("%d",&d); res_bill+=250*d; } else if (c==6) break; else printf("Enter Valid option\n"); } printf("Total Food Cost is %.2f\n",res_bill); } void laundry() { int e,f; printf("#############LAUNDARY MENU#############\n"); printf("1.Shorts Rs. 5\n"); printf("2.Trousers Rs. 10\n"); printf("3.Shirt Rs. 15\n"); printf("4.T-shirt Rs. 10\n"); printf("5.Jeans Rs. 20\n"); printf("6.Exit\n"); while(1) { printf("Enter Choice: "); scanf("%d",&e); if (e==1){ printf("Enter quantity: "); scanf("%d",&f); laundry_bill+=5*f; } else if (e==2){ printf("Enter quantity: "); scanf("%d",&f); laundry_bill+=10*f; } else if (e==3){ printf("Enter quantity: "); scanf("%d",&f); laundry_bill+=15*f; } else if (e==4){ printf("Enter quantity: "); scanf("%d",&f); laundry_bill+=10*f; } else if (e==5){ printf("Enter quantity: "); scanf("%d",&f); laundry_bill+=20*f; } else if (e==6) break; else printf("Enter Valid option\n"); } printf("Total Laundary Cost is %.2f\n",laundry_bill); } void game() { int g,p; printf("#############GAME MENU#############\n"); printf("1.Bowling Rs. 150\n"); printf("2.Cricket Rs. 120\n"); printf("3.Table-Tennis Rs. 100\n"); printf("4.Swimming Rs. 80\n"); printf("5.Video Games Rs. 110\n"); printf("6.Exit\n"); while(1) { printf("Enter Choice: "); scanf("%d",&g); if (g==1){ printf("Enter no. of Hrs: "); scanf("%d",&p); game_bill+=150*p; } else if (g==2){ printf("Enter no. of Hrs: "); scanf("%d",&p); game_bill+=120*p; } else if (g==3){ printf("Enter no. of Hrs: "); scanf("%d",&p); game_bill+=100*p; } else if (g==4){ printf("Enter no. of Hrs: "); scanf("%d",&p); game_bill+=80*p; } else if (g==5){ printf("Enter no. of Hrs: "); scanf("%d",&p); game_bill+=110*p; } else if (g==6) break; else printf("Enter Valid option\n"); } printf("Total Laundary Cost is %.2f\n",game_bill); } void display() { float sub = rent + res_bill + laundry_bill + game_bill; printf("#############Aparna Hotel#############\n"); printf("COUSTEMER DETAILS: \n"); printf("Name : %s\n",name); printf("Address : %s\n",address); printf("Check in date : %s\n",cindate); printf("Check in date : %s\n",coutdate); printf("Room Rent : Rs. %.2f\n",rent); printf("Food Rent : Rs. %.2f\n",res_bill); printf("Laundary Rent : Rs. %.2f\n",laundry_bill); printf("Game Rent : Rs. %.2f\n",game_bill); printf("Sub total bill : Rs. %.2f\n",sub); printf("Tax : Rs. %.2f\n",1800.0); printf("Grand total bill : Rs. %.2f\n",sub+1800.0); } int main() { int choice; while(1) { printf("#############Aparna Hotel#############\n"); printf("1.Enter Customer Data\n"); printf("2.Room Rent\n"); printf("3.Restaurent Bill\n"); printf("4.Laundary Bill\n"); printf("5.Game Bill\n"); printf("6.Display Total Bill\n"); printf("7.EXIT\n"); printf("Enter your option: "); scanf("%d",&choice); if (choice==7) break; else{ switch(choice) { case 1:inputdata(); break; case 2:roomrent(); break; case 3:restaurent(); break; case 4:laundry(); break; case 5:game(); break; case 6:display(); break; default:printf("Enter valid option☠!\n"); } } } return 0; }
the_stack_data/121939.c
/* AUTHOR: FABER BERNARDO JUNIOR DATE: 11/30/2021 PROGRAM SYNOPSIS: Compute the imput at two values and make a calc with them ENTRY DATA: number1, number2 OUTPUT DATA: number1+number2 */ #include <stdio.h> int main(void) { float number1, number2; char operator; printf("available operations\n"); printf("'+' : addition\n"); printf("'-' : subtraction\n"); printf("'*' : multiplication\n"); printf("'/' : division\n"); printf("'%%' : rest of division\n"); printf("\nEnter the expression of the form: number1 operator number2!\n"); printf("Example: 1 + 1 , 2.1 * 3.1.\n"); scanf("%f", &number1); scanf(" %c", &operator); scanf("%f", &number2); printf("Calculating: %.2f %c %.2f = \n", number1, operator, number2); switch (operator) { case '+': printf("%.2f\n\n", number1 + number2); break; case '-': printf("%.2f\n\n", number1 - number2); break; case '*': printf("%.2f\n\n", number1 * number2); break; case '/': if (number2 != 0) printf("%.2f\n\n", number1 / number2); else printf("There is no division by 0\n\n"); break; case '%': printf("%d\n\n", (int)number1 % (int)number2); break; default: printf("Wrong imput!\n"); printf("Error!\n"); printf("Close Calc!\n "); } return 0; }
the_stack_data/95448931.c
// C11 standard // created by cicek on 18.03.2019 11:09 #include <stdio.h> #include <stdlib.h> #include <ctype.h> /* sözlük analizcisi değişken adları ve sayıların operand olduğu aritmetik işlemler değişken adları ve alfanümerik karakterler ile başlasın | -> harf */ int charClass; char lexeme[100]; char nextChar; int lexLen; int token; int nextToken; FILE *in_fp; void addChar(); void getChar(); void getNoneBlank(); int lex(); int lookUp(char); // char classes #define LETTER 0 #define DIGIT 1 #define UNKNOWN 99 // token codes #define INT_LIT 10 #define IDENT 11 #define ASSIGN_OP 20 #define ADD_OP 21 #define SUB_OP 22 #define MULT_OP 23 #define DIV_OP 24 #define LEFT_PAREN 25 #define RIGHT_PAREN 26 int main() { if ((in_fp = fopen("/home/cicek/Desktop/a.txt", "r")) == NULL) printf("ERROR cannot open file"); else { getChar(); do{ lex(); }while (nextToken != EOF); } return 0; } int lookup(char ch) { // tokenları ayırdığımız yer switch (ch) { case '(': addChar(); // lexeme dizisine karakter ekleyacek nextToken = LEFT_PAREN; break; case ')': addChar(); // lexeme dizisine karakter ekleyacek nextToken = RIGHT_PAREN; break; case '-': addChar(); // lexeme dizisine karakter ekleyacek nextToken = SUB_OP; break; case '+': addChar(); // lexeme dizisine karakter ekleyacek nextToken = ADD_OP; break; case '*': addChar(); // lexeme dizisine karakter ekleyacek nextToken = MULT_OP; break; case '/': addChar(); // lexeme dizisine karakter ekleyacek nextToken = DIV_OP; break; case '=': addChar(); // lexeme dizisine karakter ekleyacek nextToken = ASSIGN_OP; break; default: addChar(); nextToken = EOF; break; } return nextToken; } void addChar() { if (lexLen <= 98) { lexeme[lexLen++] = nextChar; lexeme[lexLen] = 0; } else { printf("ERRROR lexeme is too long"); } } // digit mi alfanümerik mi void getChar() { if ((nextChar = getc(in_fp)) != EOF) { // EOF end of file if (isalpha(nextChar)) { // alfanümerik karakter mi (hazır sınıf) charClass = LETTER; } else if (isdigit(nextChar)) { charClass = DIGIT; } else { charClass = UNKNOWN; } } else { charClass = EOF; } } void getNoneBlank() { while (isspace(nextChar)) { getChar(); // bizim yazdığımız get char. getchar() ile karışmasın } } int lex() { // asıl sözcük analizcisi lexLen = 0; getNoneBlank(); // kontrol switch (charClass) { case LETTER: addChar(); getChar(); // 1 karakter daha oku while (charClass == LETTER || charClass == DIGIT) { addChar(); getChar(); } // ident oluştu nextToken = IDENT; break; case DIGIT: addChar(); getChar(); while (charClass == DIGIT){ addChar(); getChar(); } nextToken = INT_LIT; // sayılar için tanımladığımız token break; case UNKNOWN: lookup(nextChar); // lookup fonksiyonu ile uyuşuyor mu getChar(); break; case EOF: nextToken = EOF; lexeme[0] = 'E'; lexeme[1] = 'O'; lexeme[2] = 'F'; lexeme[3] = 0; break; } printf("Next token : %d Next lexeme : %s\n ", nextToken, lexeme); // return nextToken; // global değilkeni return etmeye gerek yok } /* * * Next token : 11 Next lexeme : count Next token : 20 Next lexeme : = Next token : 25 Next lexeme : ( Next token : 11 Next lexeme : total Next token : 21 Next lexeme : + Next token : 11 Next lexeme : count Next token : 26 Next lexeme : ) Next token : 24 Next lexeme : / Next token : 10 Next lexeme : 25 Next token : -1 Next lexeme : EOF Process finished with exit code 0 */
the_stack_data/67204.c
#include<stdio.h> #include<string.h> #include<stdlib.h> int returnRecursion(int a); int main(int argc, char** argv) { int a = atoi(argv[1]); int output = returnRecursion(a); printf("return:%d\n", output); return 1; } int returnRecursion(int a) { if(a == 0) return 1; if(a == 1) return 2; return returnRecursion(a - 1) + returnRecursion(a - 2); }
the_stack_data/40542.c
#include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <string.h> #include <errno.h> int main( int argc, char **argv ) { if ( argc < 3 ) { fprintf(stderr,"usage: anivtrim <outfile> <infile1>" " [infile2 ...]\n"); return 1; } FILE *fin, *fout; if ( !(fin = fopen(argv[2],"rb")) ) { fprintf(stderr,"Couldn't open '%s': %s\n",argv[2], strerror(errno)); return 2; } uint16_t nframes, fsize; fread(&nframes,2,1,fin); fread(&fsize,2,1,fin); uint8_t *framedata = malloc(nframes*fsize); fread(framedata,1,nframes*fsize,fin); fclose(fin); for ( int i=3; i<argc; i++ ) { if ( !(fin = fopen(argv[i],"rb")) ) { fprintf(stderr,"Couldn't open '%s': %s\n",argv[i], strerror(errno)); free(framedata); return 2; } uint16_t nframes2, fsize2; fread(&nframes2,2,1,fin); fread(&fsize2,2,1,fin); if ( fsize2 != fsize ) { fprintf(stderr,"Cannot merge: '%s' has a different frame" " size than '%s' (%hu != %hu).\n", argv[i],argv[2],fsize2,fsize); fclose(fin); free(framedata); return 4; } framedata = realloc(framedata,(nframes+nframes2)*fsize); fread(framedata+nframes*fsize,1,nframes2*fsize,fin); fclose(fin); nframes += nframes2; } if ( !(fout = fopen(argv[1],"wb")) ) { fprintf(stderr,"Couldn't open '%s': %s\n",argv[1], strerror(errno)); free(framedata); return 2; } fwrite(&nframes,2,1,fout); fwrite(&fsize,2,1,fout); fwrite(framedata,1,nframes*fsize,fout); free(framedata); return 0; }
the_stack_data/1111464.c
#include <stdlib.h> #include <unistd.h> static char **tokenize(const char *s) { int len = 1; const char *bt, *et; char *to, **a = 0; while(*s) { while(*s && (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r')) s++; if(*s) s++; bt = s; while(*s) { if(*s == '\'') { if(s[1] == '\'') s++; else break; } s++; } et = s; if(*s) s++; a = realloc(a, sizeof(*a) * ++len); to = malloc(et - bt); a[len - 2] = to; while(bt != et) { if(*bt == '\'') bt++; *to++ = *bt++; } *to = '\0'; } a[len - 1] = 0; return a; } int main(int, char **); extern char **environ; void _YALCmain(const char *argv, const char *envp) { char **pargv = tokenize(argv); environ = tokenize(envp); int argc; for(argc = 0; pargv[argc]; argc++) {} main(argc, pargv); }
the_stack_data/87742.c
#include <stdio.h> #include <string.h> typedef struct cliente { char nome[100]; int codigo; } cliente; void escrever(char*); void ler(char*); void main(int argc, char** argv){ escrever("teste.txt"); ler("teste.txt"); } void escrever(char* nomeArq){ cliente c1, c2; strcat(c1.nome, "Ze da Silva"); c1.codigo = 1; strcat(c2.nome, "Lele da Cuca"); c2.codigo = 11; FILE *p = fopen(nomeArq, "ab"); fwrite(&c1, sizeof(cliente), 1, p); fwrite(&c2, sizeof(cliente), 1, p); fclose(p); } void ler(char* nomeArq){ cliente c1, c2; FILE *p = fopen(nomeArq, "rb"); fread(&c1, sizeof(cliente), 1, p); fread(&c2, sizeof(cliente), 1, p); fclose(p); printf("%s -- %d\n", c1.nome, c1.codigo); printf("%s -- %d\n", c2.nome, c2.codigo); }
the_stack_data/776187.c
#include <stdio.h> #include <stdlib.h> /* * This stores the total number of books in each shelf. */ int* total_number_of_books; /* * This stores the total number of pages in each book of each shelf. * The rows represent the shelves and the columns represent the books. */ int** total_number_of_pages; int main() { int total_number_of_shelves; scanf("%d", &total_number_of_shelves); int total_number_of_queries; scanf("%d", &total_number_of_queries); total_number_of_books=(int*)malloc(sizeof(int)*total_number_of_shelves); total_number_of_pages=(int**)malloc(sizeof(int*)*total_number_of_shelves); for(int i=0; i<total_number_of_shelves; i++){ total_number_of_books[i]=0; total_number_of_pages[i]=(int*)malloc(sizeof(int)); } while (total_number_of_queries--) { int type_of_query; scanf("%d", &type_of_query); if (type_of_query == 1) { int x, y; scanf("%d %d", &x, &y); *(total_number_of_books+x)+=1; *(total_number_of_pages+x)=realloc(*(total_number_of_pages+x), *(total_number_of_books+x)*sizeof(int)); *(*(total_number_of_pages+x)+*(total_number_of_books+x)-1)=y; } else if (type_of_query == 2) { int x, y; scanf("%d %d", &x, &y); printf("%d\n", *(*(total_number_of_pages + x) + y)); } else { int x; scanf("%d", &x); printf("%d\n", *(total_number_of_books + x)); } } if (total_number_of_books) { free(total_number_of_books); } for (int i = 0; i < total_number_of_shelves; i++) { if (*(total_number_of_pages + i)) { free(*(total_number_of_pages + i)); } } if (total_number_of_pages) { free(total_number_of_pages); } return 0; }
the_stack_data/154828014.c
/** * add - a function that adds two numbers. * @m: int to add * @n: int to add * Return: an int **/ int add(int m, int n) { int result; result = m + n; return (result); }
the_stack_data/7509.c
#include <stdio.h> int main() { FILE *archivo; archivo = fopen("texto.txt", "w"); fputs("Hola", archivo); fclose(archivo); printf("\n\n"); return 0; }
the_stack_data/3263019.c
/*ask the user his name age and reddit username.*/ #include <stdio.h> #include <stdlib.h> int main() {float n,b,times,i; float total,a; int d,c; printf("What is the principle amount"); scanf("%f",&a); printf("Type the interest rate and on how many months\nInterest Rate:"); scanf("%f",&b); printf("\nNo. of Months:"); scanf("%d",&c); printf("After how many months do you want to calculate the total amount"); scanf("%d",&d); times=d/c; printf("What do you want to calculate?\n 1.Simple Interest\n 2.Compound Interest"); scanf("%f",&n); if(n==1){ total= a+(b/100)*a*times; } else if(n==2){ total=a; for(i=1;i<=times;i++){ total=total+(total*(b/100)); } } else{ printf("Invalid Entry"); } printf("The amount you have to pay after %d months is %f",d,total); return 0; }
the_stack_data/99586.c
#include <stdio.h> #include <omp.h> int num_steps = 400000000; int main() { int i; double x, step, sum = 0.0; step = 1.0 / (double)num_steps; #pragma omp parallel num_threads(4) #pragma omp for private(x) reduction(+:sum) for (i = 0; i < num_steps; i++) { x = (i + 0.5) * step; sum += 4.0 / (1.0 + x * x); } printf("pi = %.8f (sum = %.8f)\n", step * sum, sum); return 0; }
the_stack_data/62638375.c
/* RETRO ------------------------------------------------------ A personal, minimalistic forth Copyright (c) 2016 - 2019 Charles Childers This loads an image file and generates a C formatted output suitable for being linked into the virtual machine. It's used to create the `image.c` that gets linked into `retro`. ---------------------------------------------------------- */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdint.h> #ifndef BIT64 #define CELL int32_t #define CELL_MIN INT_MIN + 1 #define CELL_MAX INT_MAX - 1 #else #define CELL int64_t #define CELL_MIN LLONG_MIN + 1 #define CELL_MAX LLONG_MAX - 1 #endif CELL memory[512*1024]; CELL ngaLoadImage(char *imageFile) { FILE *fp; CELL imageSize; long fileLen; if ((fp = fopen(imageFile, "rb")) != NULL) { /* Determine length (in cells) */ fseek(fp, 0, SEEK_END); fileLen = ftell(fp) / sizeof(CELL); rewind(fp); /* Read the file into memory */ imageSize = fread(&memory, sizeof(CELL), fileLen, fp); fclose(fp); } else { printf("Unable to find the ngaImage!\n"); exit(1); } return imageSize; } void output_header(int size) { printf("#include <stdint.h>\n"); printf("#ifndef CELL\n"); printf("#ifndef BIT64\n"); printf("#define CELL int32_t\n"); printf("#define CELL_MIN INT_MIN + 1\n"); printf("#define CELL_MAX INT_MAX - 1\n"); printf("#else\n"); printf("#define CELL int64_t\n"); printf("#define CELL_MIN LLONG_MIN + 1\n"); printf("#define CELL_MAX LLONG_MAX - 1\n"); printf("#endif\n"); printf("#endif\n"); printf("CELL ngaImageCells = %lld;\n", (long long)size); printf("CELL ngaImage[] = { "); } int main(int argc, char **argv) { int32_t size = 0; int32_t i; int32_t n; if (argc == 2) size = ngaLoadImage(argv[1]); else size = ngaLoadImage("ngaImage"); output_header(size); i = 0; n = 0; while (i < size) { n++; if (n == 20) { printf("\n "); n = 0; } if (i+1 < size) printf("%lld,", (long long)memory[i]); else printf("%lld };\n", (long long)memory[i]); i++; } exit(0); }
the_stack_data/78348.c
// File name: ExtremeC_examples_chapter10_1.c // Description: Start a thread which performs a simple task! #include <stdio.h> #include <stdlib.h> #include <pthread.h> // The POSIX standard header for using pthread library // This function contains the logic which should be run as the body of // a separate thread void* thread_body(void* arg) { printf("Hello from first thread!\n"); return NULL; } int main(int argc, char** argv) { // The thread handler pthread_t thread; // Create a new thread int result = pthread_create(&thread, NULL, thread_body, NULL); // If the thread creation did not succeed if (result) { printf("Thread could not be created. Error number: %d\n", result); exit(1); } // Wait for the created thread to finish result = pthread_join(thread, NULL); // If joining the thread did not succeed if (result) { printf("The thread could not be joined. Error number: %d\n", result); exit(2); } return 0; }
the_stack_data/3262391.c
/* * Copyright (c) 2017, 2018, Oracle and/or its affiliates. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, are * permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this list of * conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other materials provided * with the distribution. * * 3. Neither the name of the copyright holder nor the names of its contributors may be used to * endorse or promote products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ int main() { volatile long a = 0x0000000000000000; if (__builtin_popcountl(a) != 0) { return 1; } volatile long b = 0x0000000012345678; if (__builtin_popcountl(b) != 13) { return 1; } volatile long c = 0x00000000FFFFFFFF; if (__builtin_popcountl(c) != 32) { return 1; } volatile long d = 0x0123456789ABCDEF; if (__builtin_popcountl(d) != 32) { return 1; } volatile long e = 0xFFFFFFFFFFFFFFFF; if (__builtin_popcountl(e) != 64) { return 1; } return 0; }
the_stack_data/6681.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() { float distance, amount; printf("Distance the van travelled: "); scanf("%f",&distance); if(distance<30) { amount = distance * 50; } else if(distance>30) { amount = 30 * 50 + (distance-30) * 40; } printf("The Amount:%.2f ",amount); return 0; }
the_stack_data/34097.c
#include <stdio.h> int main() { int matriz[4][4]; int cont, lin, col; for (lin = 0; lin < 4; lin++) { for (col = 0; col < 4; col++) { printf("\nDigite os valores (%d,%d): ", lin, col); scanf("%d", &matriz[lin][col]); } } for (lin = 0; lin < 4; lin++) { for (col = 0; col < 4; col++) { printf("%d ", matriz[lin][col]); } printf("\n"); } for (lin = 0; lin < 4; lin++) { for (col = 0; col < 4; col++) { if (matriz[lin][col] % 2 == 0) { printf("(%d,%d) ", lin, col); } } printf("\n"); } return 0; }
the_stack_data/12459.c
/* ** 2015-08-12 ** ** 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. ** ****************************************************************************** ** ** This SQLite extension implements JSON functions. The interface is ** modeled after MySQL JSON functions: ** ** https://dev.mysql.com/doc/refman/5.7/en/json.html ** ** For the time being, all JSON is stored as pure text. (We might add ** a JSONB type in the future which stores a binary encoding of JSON in ** a BLOB, but there is no support for JSONB in the current implementation. ** This implementation parses JSON text at 250 MB/s, so it is hard to see ** how JSONB might improve on that.) */ #if !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) #if !defined(SQLITEINT_H) #include "sqlite3ext.h" #endif SQLITE_EXTENSION_INIT1 #include <assert.h> #include <string.h> #include <stdlib.h> #include <stdarg.h> /* Mark a function parameter as unused, to suppress nuisance compiler ** warnings. */ #ifndef UNUSED_PARAM # define UNUSED_PARAM(X) (void)(X) #endif #ifndef LARGEST_INT64 # define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) # define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) #endif /* ** Versions of isspace(), isalnum() and isdigit() to which it is safe ** to pass signed char values. */ #ifdef sqlite3Isdigit /* Use the SQLite core versions if this routine is part of the ** SQLite amalgamation */ # define safe_isdigit(x) sqlite3Isdigit(x) # define safe_isalnum(x) sqlite3Isalnum(x) # define safe_isxdigit(x) sqlite3Isxdigit(x) #else /* Use the standard library for separate compilation */ #include <ctype.h> /* amalgamator: keep */ # define safe_isdigit(x) isdigit((unsigned char)(x)) # define safe_isalnum(x) isalnum((unsigned char)(x)) # define safe_isxdigit(x) isxdigit((unsigned char)(x)) #endif /* ** Growing our own isspace() routine this way is twice as fast as ** the library isspace() function, resulting in a 7% overall performance ** increase for the parser. (Ubuntu14.10 gcc 4.8.4 x64 with -Os). */ static const char jsonIsSpace[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; #define safe_isspace(x) (jsonIsSpace[(unsigned char)x]) #ifndef SQLITE_AMALGAMATION /* Unsigned integer types. These are already defined in the sqliteInt.h, ** but the definitions need to be repeated for separate compilation. */ typedef sqlite3_uint64 u64; typedef unsigned int u32; typedef unsigned short int u16; typedef unsigned char u8; #endif /* Objects */ typedef struct JsonString JsonString; typedef struct JsonNode JsonNode; typedef struct JsonParse JsonParse; /* An instance of this object represents a JSON string ** under construction. Really, this is a generic string accumulator ** that can be and is used to create strings other than JSON. */ struct JsonString { sqlite3_context *pCtx; /* Function context - put error messages here */ char *zBuf; /* Append JSON content here */ u64 nAlloc; /* Bytes of storage available in zBuf[] */ u64 nUsed; /* Bytes of zBuf[] currently used */ u8 bStatic; /* True if zBuf is static space */ u8 bErr; /* True if an error has been encountered */ char zSpace[100]; /* Initial static space */ }; /* JSON type values */ #define JSON_NULL 0 #define JSON_TRUE 1 #define JSON_FALSE 2 #define JSON_INT 3 #define JSON_REAL 4 #define JSON_STRING 5 #define JSON_ARRAY 6 #define JSON_OBJECT 7 /* The "subtype" set for JSON values */ #define JSON_SUBTYPE 74 /* Ascii for "J" */ /* ** Names of the various JSON types: */ static const char * const jsonType[] = { "null", "true", "false", "integer", "real", "text", "array", "object" }; /* Bit values for the JsonNode.jnFlag field */ #define JNODE_RAW 0x01 /* Content is raw, not JSON encoded */ #define JNODE_ESCAPE 0x02 /* Content is text with \ escapes */ #define JNODE_REMOVE 0x04 /* Do not output */ #define JNODE_REPLACE 0x08 /* Replace with JsonNode.u.iReplace */ #define JNODE_PATCH 0x10 /* Patch with JsonNode.u.pPatch */ #define JNODE_APPEND 0x20 /* More ARRAY/OBJECT entries at u.iAppend */ #define JNODE_LABEL 0x40 /* Is a label of an object */ /* A single node of parsed JSON */ struct JsonNode { u8 eType; /* One of the JSON_ type values */ u8 jnFlags; /* JNODE flags */ u32 n; /* Bytes of content, or number of sub-nodes */ union { const char *zJContent; /* Content for INT, REAL, and STRING */ u32 iAppend; /* More terms for ARRAY and OBJECT */ u32 iKey; /* Key for ARRAY objects in json_tree() */ u32 iReplace; /* Replacement content for JNODE_REPLACE */ JsonNode *pPatch; /* Node chain of patch for JNODE_PATCH */ } u; }; /* A completely parsed JSON string */ struct JsonParse { u32 nNode; /* Number of slots of aNode[] used */ u32 nAlloc; /* Number of slots of aNode[] allocated */ JsonNode *aNode; /* Array of nodes containing the parse */ const char *zJson; /* Original JSON string */ u32 *aUp; /* Index of parent of each node */ u8 oom; /* Set to true if out of memory */ u8 nErr; /* Number of errors seen */ u16 iDepth; /* Nesting depth */ int nJson; /* Length of the zJson string in bytes */ u32 iHold; /* Replace cache line with the lowest iHold value */ }; /* ** Maximum nesting depth of JSON for this implementation. ** ** This limit is needed to avoid a stack overflow in the recursive ** descent parser. A depth of 2000 is far deeper than any sane JSON ** should go. */ #define JSON_MAX_DEPTH 2000 /************************************************************************** ** Utility routines for dealing with JsonString objects **************************************************************************/ /* Set the JsonString object to an empty string */ static void jsonZero(JsonString *p){ p->zBuf = p->zSpace; p->nAlloc = sizeof(p->zSpace); p->nUsed = 0; p->bStatic = 1; } /* Initialize the JsonString object */ static void jsonInit(JsonString *p, sqlite3_context *pCtx){ p->pCtx = pCtx; p->bErr = 0; jsonZero(p); } /* Free all allocated memory and reset the JsonString object back to its ** initial state. */ static void jsonReset(JsonString *p){ if( !p->bStatic ) sqlite3_free(p->zBuf); jsonZero(p); } /* Report an out-of-memory (OOM) condition */ static void jsonOom(JsonString *p){ p->bErr = 1; sqlite3_result_error_nomem(p->pCtx); jsonReset(p); } /* Enlarge pJson->zBuf so that it can hold at least N more bytes. ** Return zero on success. Return non-zero on an OOM error */ static int jsonGrow(JsonString *p, u32 N){ u64 nTotal = N<p->nAlloc ? p->nAlloc*2 : p->nAlloc+N+10; char *zNew; if( p->bStatic ){ if( p->bErr ) return 1; zNew = sqlite3_malloc64(nTotal); if( zNew==0 ){ jsonOom(p); return SQLITE_NOMEM; } memcpy(zNew, p->zBuf, (size_t)p->nUsed); p->zBuf = zNew; p->bStatic = 0; }else{ zNew = sqlite3_realloc64(p->zBuf, nTotal); if( zNew==0 ){ jsonOom(p); return SQLITE_NOMEM; } p->zBuf = zNew; } p->nAlloc = nTotal; return SQLITE_OK; } /* Append N bytes from zIn onto the end of the JsonString string. */ static void jsonAppendRaw(JsonString *p, const char *zIn, u32 N){ if( (N+p->nUsed >= p->nAlloc) && jsonGrow(p,N)!=0 ) return; memcpy(p->zBuf+p->nUsed, zIn, N); p->nUsed += N; } /* Append formatted text (not to exceed N bytes) to the JsonString. */ static void jsonPrintf(int N, JsonString *p, const char *zFormat, ...){ va_list ap; if( (p->nUsed + N >= p->nAlloc) && jsonGrow(p, N) ) return; va_start(ap, zFormat); sqlite3_vsnprintf(N, p->zBuf+p->nUsed, zFormat, ap); va_end(ap); p->nUsed += (int)strlen(p->zBuf+p->nUsed); } /* Append a single character */ static void jsonAppendChar(JsonString *p, char c){ if( p->nUsed>=p->nAlloc && jsonGrow(p,1)!=0 ) return; p->zBuf[p->nUsed++] = c; } /* Append a comma separator to the output buffer, if the previous ** character is not '[' or '{'. */ static void jsonAppendSeparator(JsonString *p){ char c; if( p->nUsed==0 ) return; c = p->zBuf[p->nUsed-1]; if( c!='[' && c!='{' ) jsonAppendChar(p, ','); } /* Append the N-byte string in zIn to the end of the JsonString string ** under construction. Enclose the string in "..." and escape ** any double-quotes or backslash characters contained within the ** string. */ static void jsonAppendString(JsonString *p, const char *zIn, u32 N){ u32 i; if( (N+p->nUsed+2 >= p->nAlloc) && jsonGrow(p,N+2)!=0 ) return; p->zBuf[p->nUsed++] = '"'; for(i=0; i<N; i++){ unsigned char c = ((unsigned const char*)zIn)[i]; if( c=='"' || c=='\\' ){ json_simple_escape: if( (p->nUsed+N+3-i > p->nAlloc) && jsonGrow(p,N+3-i)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; }else if( c<=0x1f ){ static const char aSpecial[] = { 0, 0, 0, 0, 0, 0, 0, 0, 'b', 't', 'n', 0, 'f', 'r', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; assert( sizeof(aSpecial)==32 ); assert( aSpecial['\b']=='b' ); assert( aSpecial['\f']=='f' ); assert( aSpecial['\n']=='n' ); assert( aSpecial['\r']=='r' ); assert( aSpecial['\t']=='t' ); if( aSpecial[c] ){ c = aSpecial[c]; goto json_simple_escape; } if( (p->nUsed+N+7+i > p->nAlloc) && jsonGrow(p,N+7-i)!=0 ) return; p->zBuf[p->nUsed++] = '\\'; p->zBuf[p->nUsed++] = 'u'; p->zBuf[p->nUsed++] = '0'; p->zBuf[p->nUsed++] = '0'; p->zBuf[p->nUsed++] = '0' + (c>>4); c = "0123456789abcdef"[c&0xf]; } p->zBuf[p->nUsed++] = c; } p->zBuf[p->nUsed++] = '"'; assert( p->nUsed<p->nAlloc ); } /* ** Append a function parameter value to the JSON string under ** construction. */ static void jsonAppendValue( JsonString *p, /* Append to this JSON string */ sqlite3_value *pValue /* Value to append */ ){ switch( sqlite3_value_type(pValue) ){ case SQLITE_NULL: { jsonAppendRaw(p, "null", 4); break; } case SQLITE_INTEGER: case SQLITE_FLOAT: { const char *z = (const char*)sqlite3_value_text(pValue); u32 n = (u32)sqlite3_value_bytes(pValue); jsonAppendRaw(p, z, n); break; } case SQLITE_TEXT: { const char *z = (const char*)sqlite3_value_text(pValue); u32 n = (u32)sqlite3_value_bytes(pValue); if( sqlite3_value_subtype(pValue)==JSON_SUBTYPE ){ jsonAppendRaw(p, z, n); }else{ jsonAppendString(p, z, n); } break; } default: { if( p->bErr==0 ){ sqlite3_result_error(p->pCtx, "JSON cannot hold BLOB values", -1); p->bErr = 2; jsonReset(p); } break; } } } /* Make the JSON in p the result of the SQL function. */ static void jsonResult(JsonString *p){ if( p->bErr==0 ){ sqlite3_result_text64(p->pCtx, p->zBuf, p->nUsed, p->bStatic ? SQLITE_TRANSIENT : sqlite3_free, SQLITE_UTF8); jsonZero(p); } assert( p->bStatic ); } /************************************************************************** ** Utility routines for dealing with JsonNode and JsonParse objects **************************************************************************/ /* ** Return the number of consecutive JsonNode slots need to represent ** the parsed JSON at pNode. The minimum answer is 1. For ARRAY and ** OBJECT types, the number might be larger. ** ** Appended elements are not counted. The value returned is the number ** by which the JsonNode counter should increment in order to go to the ** next peer value. */ static u32 jsonNodeSize(JsonNode *pNode){ return pNode->eType>=JSON_ARRAY ? pNode->n+1 : 1; } /* ** Reclaim all memory allocated by a JsonParse object. But do not ** delete the JsonParse object itself. */ static void jsonParseReset(JsonParse *pParse){ sqlite3_free(pParse->aNode); pParse->aNode = 0; pParse->nNode = 0; pParse->nAlloc = 0; sqlite3_free(pParse->aUp); pParse->aUp = 0; } /* ** Free a JsonParse object that was obtained from sqlite3_malloc(). */ static void jsonParseFree(JsonParse *pParse){ jsonParseReset(pParse); sqlite3_free(pParse); } /* ** Convert the JsonNode pNode into a pure JSON string and ** append to pOut. Subsubstructure is also included. Return ** the number of JsonNode objects that are encoded. */ static void jsonRenderNode( JsonNode *pNode, /* The node to render */ JsonString *pOut, /* Write JSON here */ sqlite3_value **aReplace /* Replacement values */ ){ if( pNode->jnFlags & (JNODE_REPLACE|JNODE_PATCH) ){ if( pNode->jnFlags & JNODE_REPLACE ){ jsonAppendValue(pOut, aReplace[pNode->u.iReplace]); return; } pNode = pNode->u.pPatch; } switch( pNode->eType ){ default: { assert( pNode->eType==JSON_NULL ); jsonAppendRaw(pOut, "null", 4); break; } case JSON_TRUE: { jsonAppendRaw(pOut, "true", 4); break; } case JSON_FALSE: { jsonAppendRaw(pOut, "false", 5); break; } case JSON_STRING: { if( pNode->jnFlags & JNODE_RAW ){ jsonAppendString(pOut, pNode->u.zJContent, pNode->n); break; } /* Fall through into the next case */ } case JSON_REAL: case JSON_INT: { jsonAppendRaw(pOut, pNode->u.zJContent, pNode->n); break; } case JSON_ARRAY: { u32 j = 1; jsonAppendChar(pOut, '['); for(;;){ while( j<=pNode->n ){ if( (pNode[j].jnFlags & JNODE_REMOVE)==0 ){ jsonAppendSeparator(pOut); jsonRenderNode(&pNode[j], pOut, aReplace); } j += jsonNodeSize(&pNode[j]); } if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; pNode = &pNode[pNode->u.iAppend]; j = 1; } jsonAppendChar(pOut, ']'); break; } case JSON_OBJECT: { u32 j = 1; jsonAppendChar(pOut, '{'); for(;;){ while( j<=pNode->n ){ if( (pNode[j+1].jnFlags & JNODE_REMOVE)==0 ){ jsonAppendSeparator(pOut); jsonRenderNode(&pNode[j], pOut, aReplace); jsonAppendChar(pOut, ':'); jsonRenderNode(&pNode[j+1], pOut, aReplace); } j += 1 + jsonNodeSize(&pNode[j+1]); } if( (pNode->jnFlags & JNODE_APPEND)==0 ) break; pNode = &pNode[pNode->u.iAppend]; j = 1; } jsonAppendChar(pOut, '}'); break; } } } /* ** Return a JsonNode and all its descendents as a JSON string. */ static void jsonReturnJson( JsonNode *pNode, /* Node to return */ sqlite3_context *pCtx, /* Return value for this function */ sqlite3_value **aReplace /* Array of replacement values */ ){ JsonString s; jsonInit(&s, pCtx); jsonRenderNode(pNode, &s, aReplace); jsonResult(&s); sqlite3_result_subtype(pCtx, JSON_SUBTYPE); } /* ** Make the JsonNode the return value of the function. */ static void jsonReturn( JsonNode *pNode, /* Node to return */ sqlite3_context *pCtx, /* Return value for this function */ sqlite3_value **aReplace /* Array of replacement values */ ){ switch( pNode->eType ){ default: { assert( pNode->eType==JSON_NULL ); sqlite3_result_null(pCtx); break; } case JSON_TRUE: { sqlite3_result_int(pCtx, 1); break; } case JSON_FALSE: { sqlite3_result_int(pCtx, 0); break; } case JSON_INT: { sqlite3_int64 i = 0; const char *z = pNode->u.zJContent; if( z[0]=='-' ){ z++; } while( z[0]>='0' && z[0]<='9' ){ unsigned v = *(z++) - '0'; if( i>=LARGEST_INT64/10 ){ if( i>LARGEST_INT64/10 ) goto int_as_real; if( z[0]>='0' && z[0]<='9' ) goto int_as_real; if( v==9 ) goto int_as_real; if( v==8 ){ if( pNode->u.zJContent[0]=='-' ){ sqlite3_result_int64(pCtx, SMALLEST_INT64); goto int_done; }else{ goto int_as_real; } } } i = i*10 + v; } if( pNode->u.zJContent[0]=='-' ){ i = -i; } sqlite3_result_int64(pCtx, i); int_done: break; int_as_real: /* fall through to real */; } case JSON_REAL: { double r; #ifdef SQLITE_AMALGAMATION const char *z = pNode->u.zJContent; sqlite3AtoF(z, &r, sqlite3Strlen30(z), SQLITE_UTF8); #else r = strtod(pNode->u.zJContent, 0); #endif sqlite3_result_double(pCtx, r); break; } case JSON_STRING: { #if 0 /* Never happens because JNODE_RAW is only set by json_set(), ** json_insert() and json_replace() and those routines do not ** call jsonReturn() */ if( pNode->jnFlags & JNODE_RAW ){ sqlite3_result_text(pCtx, pNode->u.zJContent, pNode->n, SQLITE_TRANSIENT); }else #endif assert( (pNode->jnFlags & JNODE_RAW)==0 ); if( (pNode->jnFlags & JNODE_ESCAPE)==0 ){ /* JSON formatted without any backslash-escapes */ sqlite3_result_text(pCtx, pNode->u.zJContent+1, pNode->n-2, SQLITE_TRANSIENT); }else{ /* Translate JSON formatted string into raw text */ u32 i; u32 n = pNode->n; const char *z = pNode->u.zJContent; char *zOut; u32 j; zOut = sqlite3_malloc( n+1 ); if( zOut==0 ){ sqlite3_result_error_nomem(pCtx); break; } for(i=1, j=0; i<n-1; i++){ char c = z[i]; if( c!='\\' ){ zOut[j++] = c; }else{ c = z[++i]; if( c=='u' ){ u32 v = 0, k; for(k=0; k<4; i++, k++){ assert( i<n-2 ); c = z[i+1]; assert( safe_isxdigit(c) ); if( c<='9' ) v = v*16 + c - '0'; else if( c<='F' ) v = v*16 + c - 'A' + 10; else v = v*16 + c - 'a' + 10; } if( v==0 ) break; if( v<=0x7f ){ zOut[j++] = (char)v; }else if( v<=0x7ff ){ zOut[j++] = (char)(0xc0 | (v>>6)); zOut[j++] = 0x80 | (v&0x3f); }else{ zOut[j++] = (char)(0xe0 | (v>>12)); zOut[j++] = 0x80 | ((v>>6)&0x3f); zOut[j++] = 0x80 | (v&0x3f); } }else{ if( c=='b' ){ c = '\b'; }else if( c=='f' ){ c = '\f'; }else if( c=='n' ){ c = '\n'; }else if( c=='r' ){ c = '\r'; }else if( c=='t' ){ c = '\t'; } zOut[j++] = c; } } } zOut[j] = 0; sqlite3_result_text(pCtx, zOut, j, sqlite3_free); } break; } case JSON_ARRAY: case JSON_OBJECT: { jsonReturnJson(pNode, pCtx, aReplace); break; } } } /* Forward reference */ static int jsonParseAddNode(JsonParse*,u32,u32,const char*); /* ** A macro to hint to the compiler that a function should not be ** inlined. */ #if defined(__GNUC__) # define JSON_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) && _MSC_VER>=1310 # define JSON_NOINLINE __declspec(noinline) #else # define JSON_NOINLINE #endif static JSON_NOINLINE int jsonParseAddNodeExpand( JsonParse *pParse, /* Append the node to this object */ u32 eType, /* Node type */ u32 n, /* Content size or sub-node count */ const char *zContent /* Content */ ){ u32 nNew; JsonNode *pNew; assert( pParse->nNode>=pParse->nAlloc ); if( pParse->oom ) return -1; nNew = pParse->nAlloc*2 + 10; pNew = sqlite3_realloc64(pParse->aNode, sizeof(JsonNode)*nNew); if( pNew==0 ){ pParse->oom = 1; return -1; } pParse->nAlloc = nNew; pParse->aNode = pNew; assert( pParse->nNode<pParse->nAlloc ); return jsonParseAddNode(pParse, eType, n, zContent); } /* ** Create a new JsonNode instance based on the arguments and append that ** instance to the JsonParse. Return the index in pParse->aNode[] of the ** new node, or -1 if a memory allocation fails. */ static int jsonParseAddNode( JsonParse *pParse, /* Append the node to this object */ u32 eType, /* Node type */ u32 n, /* Content size or sub-node count */ const char *zContent /* Content */ ){ JsonNode *p; if( pParse->nNode>=pParse->nAlloc ){ return jsonParseAddNodeExpand(pParse, eType, n, zContent); } p = &pParse->aNode[pParse->nNode]; p->eType = (u8)eType; p->jnFlags = 0; p->n = n; p->u.zJContent = zContent; return pParse->nNode++; } /* ** Return true if z[] begins with 4 (or more) hexadecimal digits */ static int jsonIs4Hex(const char *z){ int i; for(i=0; i<4; i++) if( !safe_isxdigit(z[i]) ) return 0; return 1; } /* ** Parse a single JSON value which begins at pParse->zJson[i]. Return the ** index of the first character past the end of the value parsed. ** ** Return negative for a syntax error. Special cases: return -2 if the ** first non-whitespace character is '}' and return -3 if the first ** non-whitespace character is ']'. */ static int jsonParseValue(JsonParse *pParse, u32 i){ char c; u32 j; int iThis; int x; JsonNode *pNode; const char *z = pParse->zJson; while( safe_isspace(z[i]) ){ i++; } if( (c = z[i])=='{' ){ /* Parse object */ iThis = jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); if( iThis<0 ) return -1; for(j=i+1;;j++){ while( safe_isspace(z[j]) ){ j++; } if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; x = jsonParseValue(pParse, j); if( x<0 ){ pParse->iDepth--; if( x==(-2) && pParse->nNode==(u32)iThis+1 ) return j+1; return -1; } if( pParse->oom ) return -1; pNode = &pParse->aNode[pParse->nNode-1]; if( pNode->eType!=JSON_STRING ) return -1; pNode->jnFlags |= JNODE_LABEL; j = x; while( safe_isspace(z[j]) ){ j++; } if( z[j]!=':' ) return -1; j++; x = jsonParseValue(pParse, j); pParse->iDepth--; if( x<0 ) return -1; j = x; while( safe_isspace(z[j]) ){ j++; } c = z[j]; if( c==',' ) continue; if( c!='}' ) return -1; break; } pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; return j+1; }else if( c=='[' ){ /* Parse array */ iThis = jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); if( iThis<0 ) return -1; for(j=i+1;;j++){ while( safe_isspace(z[j]) ){ j++; } if( ++pParse->iDepth > JSON_MAX_DEPTH ) return -1; x = jsonParseValue(pParse, j); pParse->iDepth--; if( x<0 ){ if( x==(-3) && pParse->nNode==(u32)iThis+1 ) return j+1; return -1; } j = x; while( safe_isspace(z[j]) ){ j++; } c = z[j]; if( c==',' ) continue; if( c!=']' ) return -1; break; } pParse->aNode[iThis].n = pParse->nNode - (u32)iThis - 1; return j+1; }else if( c=='"' ){ /* Parse string */ u8 jnFlags = 0; j = i+1; for(;;){ c = z[j]; if( (c & ~0x1f)==0 ){ /* Control characters are not allowed in strings */ return -1; } if( c=='\\' ){ c = z[++j]; if( c=='"' || c=='\\' || c=='/' || c=='b' || c=='f' || c=='n' || c=='r' || c=='t' || (c=='u' && jsonIs4Hex(z+j+1)) ){ jnFlags = JNODE_ESCAPE; }else{ return -1; } }else if( c=='"' ){ break; } j++; } jsonParseAddNode(pParse, JSON_STRING, j+1-i, &z[i]); if( !pParse->oom ) pParse->aNode[pParse->nNode-1].jnFlags = jnFlags; return j+1; }else if( c=='n' && strncmp(z+i,"null",4)==0 && !safe_isalnum(z[i+4]) ){ jsonParseAddNode(pParse, JSON_NULL, 0, 0); return i+4; }else if( c=='t' && strncmp(z+i,"true",4)==0 && !safe_isalnum(z[i+4]) ){ jsonParseAddNode(pParse, JSON_TRUE, 0, 0); return i+4; }else if( c=='f' && strncmp(z+i,"false",5)==0 && !safe_isalnum(z[i+5]) ){ jsonParseAddNode(pParse, JSON_FALSE, 0, 0); return i+5; }else if( c=='-' || (c>='0' && c<='9') ){ /* Parse number */ u8 seenDP = 0; u8 seenE = 0; assert( '-' < '0' ); if( c<='0' ){ j = c=='-' ? i+1 : i; if( z[j]=='0' && z[j+1]>='0' && z[j+1]<='9' ) return -1; } j = i+1; for(;; j++){ c = z[j]; if( c>='0' && c<='9' ) continue; if( c=='.' ){ if( z[j-1]=='-' ) return -1; if( seenDP ) return -1; seenDP = 1; continue; } if( c=='e' || c=='E' ){ if( z[j-1]<'0' ) return -1; if( seenE ) return -1; seenDP = seenE = 1; c = z[j+1]; if( c=='+' || c=='-' ){ j++; c = z[j+1]; } if( c<'0' || c>'9' ) return -1; continue; } break; } if( z[j-1]<'0' ) return -1; jsonParseAddNode(pParse, seenDP ? JSON_REAL : JSON_INT, j - i, &z[i]); return j; }else if( c=='}' ){ return -2; /* End of {...} */ }else if( c==']' ){ return -3; /* End of [...] */ }else if( c==0 ){ return 0; /* End of file */ }else{ return -1; /* Syntax error */ } } /* ** Parse a complete JSON string. Return 0 on success or non-zero if there ** are any errors. If an error occurs, free all memory associated with ** pParse. ** ** pParse is uninitialized when this routine is called. */ static int jsonParse( JsonParse *pParse, /* Initialize and fill this JsonParse object */ sqlite3_context *pCtx, /* Report errors here */ const char *zJson /* Input JSON text to be parsed */ ){ int i; memset(pParse, 0, sizeof(*pParse)); if( zJson==0 ) return 1; pParse->zJson = zJson; i = jsonParseValue(pParse, 0); if( pParse->oom ) i = -1; if( i>0 ){ assert( pParse->iDepth==0 ); while( safe_isspace(zJson[i]) ) i++; if( zJson[i] ) i = -1; } if( i<=0 ){ if( pCtx!=0 ){ if( pParse->oom ){ sqlite3_result_error_nomem(pCtx); }else{ sqlite3_result_error(pCtx, "malformed JSON", -1); } } jsonParseReset(pParse); return 1; } return 0; } /* Mark node i of pParse as being a child of iParent. Call recursively ** to fill in all the descendants of node i. */ static void jsonParseFillInParentage(JsonParse *pParse, u32 i, u32 iParent){ JsonNode *pNode = &pParse->aNode[i]; u32 j; pParse->aUp[i] = iParent; switch( pNode->eType ){ case JSON_ARRAY: { for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j)){ jsonParseFillInParentage(pParse, i+j, i); } break; } case JSON_OBJECT: { for(j=1; j<=pNode->n; j += jsonNodeSize(pNode+j+1)+1){ pParse->aUp[i+j] = i; jsonParseFillInParentage(pParse, i+j+1, i); } break; } default: { break; } } } /* ** Compute the parentage of all nodes in a completed parse. */ static int jsonParseFindParents(JsonParse *pParse){ u32 *aUp; assert( pParse->aUp==0 ); aUp = pParse->aUp = sqlite3_malloc64( sizeof(u32)*pParse->nNode ); if( aUp==0 ){ pParse->oom = 1; return SQLITE_NOMEM; } jsonParseFillInParentage(pParse, 0, 0); return SQLITE_OK; } /* ** Magic number used for the JSON parse cache in sqlite3_get_auxdata() */ #define JSON_CACHE_ID (-429938) /* First cache entry */ #define JSON_CACHE_SZ 4 /* Max number of cache entries */ /* ** Obtain a complete parse of the JSON found in the first argument ** of the argv array. Use the sqlite3_get_auxdata() cache for this ** parse if it is available. If the cache is not available or if it ** is no longer valid, parse the JSON again and return the new parse, ** and also register the new parse so that it will be available for ** future sqlite3_get_auxdata() calls. */ static JsonParse *jsonParseCached( sqlite3_context *pCtx, sqlite3_value **argv, sqlite3_context *pErrCtx ){ const char *zJson = (const char*)sqlite3_value_text(argv[0]); int nJson = sqlite3_value_bytes(argv[0]); JsonParse *p; JsonParse *pMatch = 0; int iKey; int iMinKey = 0; u32 iMinHold = 0xffffffff; u32 iMaxHold = 0; if( zJson==0 ) return 0; for(iKey=0; iKey<JSON_CACHE_SZ; iKey++){ p = (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID+iKey); if( p==0 ){ iMinKey = iKey; break; } if( pMatch==0 && p->nJson==nJson && memcmp(p->zJson,zJson,nJson)==0 ){ p->nErr = 0; pMatch = p; }else if( p->iHold<iMinHold ){ iMinHold = p->iHold; iMinKey = iKey; } if( p->iHold>iMaxHold ){ iMaxHold = p->iHold; } } if( pMatch ){ pMatch->nErr = 0; pMatch->iHold = iMaxHold+1; return pMatch; } p = sqlite3_malloc64( sizeof(*p) + nJson + 1 ); if( p==0 ){ sqlite3_result_error_nomem(pCtx); return 0; } memset(p, 0, sizeof(*p)); p->zJson = (char*)&p[1]; memcpy((char*)p->zJson, zJson, nJson+1); if( jsonParse(p, pErrCtx, p->zJson) ){ sqlite3_free(p); return 0; } p->nJson = nJson; p->iHold = iMaxHold+1; sqlite3_set_auxdata(pCtx, JSON_CACHE_ID+iMinKey, p, (void(*)(void*))jsonParseFree); return (JsonParse*)sqlite3_get_auxdata(pCtx, JSON_CACHE_ID+iMinKey); } /* ** Compare the OBJECT label at pNode against zKey,nKey. Return true on ** a match. */ static int jsonLabelCompare(JsonNode *pNode, const char *zKey, u32 nKey){ if( pNode->jnFlags & JNODE_RAW ){ if( pNode->n!=nKey ) return 0; return strncmp(pNode->u.zJContent, zKey, nKey)==0; }else{ if( pNode->n!=nKey+2 ) return 0; return strncmp(pNode->u.zJContent+1, zKey, nKey)==0; } } /* forward declaration */ static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*,const char**); /* ** Search along zPath to find the node specified. Return a pointer ** to that node, or NULL if zPath is malformed or if there is no such ** node. ** ** If pApnd!=0, then try to append new nodes to complete zPath if it is ** possible to do so and if no existing node corresponds to zPath. If ** new nodes are appended *pApnd is set to 1. */ static JsonNode *jsonLookupStep( JsonParse *pParse, /* The JSON to search */ u32 iRoot, /* Begin the search at this node */ const char *zPath, /* The path to search */ int *pApnd, /* Append nodes to complete path if not NULL */ const char **pzErr /* Make *pzErr point to any syntax error in zPath */ ){ u32 i, j, nKey; const char *zKey; JsonNode *pRoot = &pParse->aNode[iRoot]; if( zPath[0]==0 ) return pRoot; if( pRoot->jnFlags & JNODE_REPLACE ) return 0; if( zPath[0]=='.' ){ if( pRoot->eType!=JSON_OBJECT ) return 0; zPath++; if( zPath[0]=='"' ){ zKey = zPath + 1; for(i=1; zPath[i] && zPath[i]!='"'; i++){} nKey = i-1; if( zPath[i] ){ i++; }else{ *pzErr = zPath; return 0; } }else{ zKey = zPath; for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} nKey = i; } if( nKey==0 ){ *pzErr = zPath; return 0; } j = 1; for(;;){ while( j<=pRoot->n ){ if( jsonLabelCompare(pRoot+j, zKey, nKey) ){ return jsonLookupStep(pParse, iRoot+j+1, &zPath[i], pApnd, pzErr); } j++; j += jsonNodeSize(&pRoot[j]); } if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; iRoot += pRoot->u.iAppend; pRoot = &pParse->aNode[iRoot]; j = 1; } if( pApnd ){ u32 iStart, iLabel; JsonNode *pNode; iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0); iLabel = jsonParseAddNode(pParse, JSON_STRING, nKey, zKey); zPath += i; pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); if( pParse->oom ) return 0; if( pNode ){ pRoot = &pParse->aNode[iRoot]; pRoot->u.iAppend = iStart - iRoot; pRoot->jnFlags |= JNODE_APPEND; pParse->aNode[iLabel].jnFlags |= JNODE_RAW; } return pNode; } }else if( zPath[0]=='[' && safe_isdigit(zPath[1]) ){ if( pRoot->eType!=JSON_ARRAY ) return 0; i = 0; j = 1; while( safe_isdigit(zPath[j]) ){ i = i*10 + zPath[j] - '0'; j++; } if( zPath[j]!=']' ){ *pzErr = zPath; return 0; } zPath += j + 1; j = 1; for(;;){ while( j<=pRoot->n && (i>0 || (pRoot[j].jnFlags & JNODE_REMOVE)!=0) ){ if( (pRoot[j].jnFlags & JNODE_REMOVE)==0 ) i--; j += jsonNodeSize(&pRoot[j]); } if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; iRoot += pRoot->u.iAppend; pRoot = &pParse->aNode[iRoot]; j = 1; } if( j<=pRoot->n ){ return jsonLookupStep(pParse, iRoot+j, zPath, pApnd, pzErr); } if( i==0 && pApnd ){ u32 iStart; JsonNode *pNode; iStart = jsonParseAddNode(pParse, JSON_ARRAY, 1, 0); pNode = jsonLookupAppend(pParse, zPath, pApnd, pzErr); if( pParse->oom ) return 0; if( pNode ){ pRoot = &pParse->aNode[iRoot]; pRoot->u.iAppend = iStart - iRoot; pRoot->jnFlags |= JNODE_APPEND; } return pNode; } }else{ *pzErr = zPath; } return 0; } /* ** Append content to pParse that will complete zPath. Return a pointer ** to the inserted node, or return NULL if the append fails. */ static JsonNode *jsonLookupAppend( JsonParse *pParse, /* Append content to the JSON parse */ const char *zPath, /* Description of content to append */ int *pApnd, /* Set this flag to 1 */ const char **pzErr /* Make this point to any syntax error */ ){ *pApnd = 1; if( zPath[0]==0 ){ jsonParseAddNode(pParse, JSON_NULL, 0, 0); return pParse->oom ? 0 : &pParse->aNode[pParse->nNode-1]; } if( zPath[0]=='.' ){ jsonParseAddNode(pParse, JSON_OBJECT, 0, 0); }else if( strncmp(zPath,"[0]",3)==0 ){ jsonParseAddNode(pParse, JSON_ARRAY, 0, 0); }else{ return 0; } if( pParse->oom ) return 0; return jsonLookupStep(pParse, pParse->nNode-1, zPath, pApnd, pzErr); } /* ** Return the text of a syntax error message on a JSON path. Space is ** obtained from sqlite3_malloc(). */ static char *jsonPathSyntaxError(const char *zErr){ return sqlite3_mprintf("JSON path error near '%q'", zErr); } /* ** Do a node lookup using zPath. Return a pointer to the node on success. ** Return NULL if not found or if there is an error. ** ** On an error, write an error message into pCtx and increment the ** pParse->nErr counter. ** ** If pApnd!=NULL then try to append missing nodes and set *pApnd = 1 if ** nodes are appended. */ static JsonNode *jsonLookup( JsonParse *pParse, /* The JSON to search */ const char *zPath, /* The path to search */ int *pApnd, /* Append nodes to complete path if not NULL */ sqlite3_context *pCtx /* Report errors here, if not NULL */ ){ const char *zErr = 0; JsonNode *pNode = 0; char *zMsg; if( zPath==0 ) return 0; if( zPath[0]!='$' ){ zErr = zPath; goto lookup_err; } zPath++; pNode = jsonLookupStep(pParse, 0, zPath, pApnd, &zErr); if( zErr==0 ) return pNode; lookup_err: pParse->nErr++; assert( zErr!=0 && pCtx!=0 ); zMsg = jsonPathSyntaxError(zErr); if( zMsg ){ sqlite3_result_error(pCtx, zMsg, -1); sqlite3_free(zMsg); }else{ sqlite3_result_error_nomem(pCtx); } return 0; } /* ** Report the wrong number of arguments for json_insert(), json_replace() ** or json_set(). */ static void jsonWrongNumArgs( sqlite3_context *pCtx, const char *zFuncName ){ char *zMsg = sqlite3_mprintf("json_%s() needs an odd number of arguments", zFuncName); sqlite3_result_error(pCtx, zMsg, -1); sqlite3_free(zMsg); } /* ** Mark all NULL entries in the Object passed in as JNODE_REMOVE. */ static void jsonRemoveAllNulls(JsonNode *pNode){ int i, n; assert( pNode->eType==JSON_OBJECT ); n = pNode->n; for(i=2; i<=n; i += jsonNodeSize(&pNode[i])+1){ switch( pNode[i].eType ){ case JSON_NULL: pNode[i].jnFlags |= JNODE_REMOVE; break; case JSON_OBJECT: jsonRemoveAllNulls(&pNode[i]); break; } } } /**************************************************************************** ** SQL functions used for testing and debugging ****************************************************************************/ #ifdef SQLITE_DEBUG /* ** The json_parse(JSON) function returns a string which describes ** a parse of the JSON provided. Or it returns NULL if JSON is not ** well-formed. */ static void jsonParseFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonString s; /* Output string - not real JSON */ JsonParse x; /* The parse */ u32 i; assert( argc==1 ); if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; jsonParseFindParents(&x); jsonInit(&s, ctx); for(i=0; i<x.nNode; i++){ const char *zType; if( x.aNode[i].jnFlags & JNODE_LABEL ){ assert( x.aNode[i].eType==JSON_STRING ); zType = "label"; }else{ zType = jsonType[x.aNode[i].eType]; } jsonPrintf(100, &s,"node %3u: %7s n=%-4d up=%-4d", i, zType, x.aNode[i].n, x.aUp[i]); if( x.aNode[i].u.zJContent!=0 ){ jsonAppendRaw(&s, " ", 1); jsonAppendRaw(&s, x.aNode[i].u.zJContent, x.aNode[i].n); } jsonAppendRaw(&s, "\n", 1); } jsonParseReset(&x); jsonResult(&s); } /* ** The json_test1(JSON) function return true (1) if the input is JSON ** text generated by another json function. It returns (0) if the input ** is not known to be JSON. */ static void jsonTest1Func( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ UNUSED_PARAM(argc); sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE); } #endif /* SQLITE_DEBUG */ /**************************************************************************** ** Scalar SQL function implementations ****************************************************************************/ /* ** Implementation of the json_QUOTE(VALUE) function. Return a JSON value ** corresponding to the SQL value input. Mostly this means putting ** double-quotes around strings and returning the unquoted string "null" ** when given a NULL input. */ static void jsonQuoteFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonString jx; UNUSED_PARAM(argc); jsonInit(&jx, ctx); jsonAppendValue(&jx, argv[0]); jsonResult(&jx); sqlite3_result_subtype(ctx, JSON_SUBTYPE); } /* ** Implementation of the json_array(VALUE,...) function. Return a JSON ** array that contains all values given in arguments. Or if any argument ** is a BLOB, throw an error. */ static void jsonArrayFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ int i; JsonString jx; jsonInit(&jx, ctx); jsonAppendChar(&jx, '['); for(i=0; i<argc; i++){ jsonAppendSeparator(&jx); jsonAppendValue(&jx, argv[i]); } jsonAppendChar(&jx, ']'); jsonResult(&jx); sqlite3_result_subtype(ctx, JSON_SUBTYPE); } /* ** json_array_length(JSON) ** json_array_length(JSON, PATH) ** ** Return the number of elements in the top-level JSON array. ** Return 0 if the input is not a well-formed JSON array. */ static void jsonArrayLengthFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse *p; /* The parse */ sqlite3_int64 n = 0; u32 i; JsonNode *pNode; p = jsonParseCached(ctx, argv, ctx); if( p==0 ) return; assert( p->nNode ); if( argc==2 ){ const char *zPath = (const char*)sqlite3_value_text(argv[1]); pNode = jsonLookup(p, zPath, 0, ctx); }else{ pNode = p->aNode; } if( pNode==0 ){ return; } if( pNode->eType==JSON_ARRAY ){ assert( (pNode->jnFlags & JNODE_APPEND)==0 ); for(i=1; i<=pNode->n; n++){ i += jsonNodeSize(&pNode[i]); } } sqlite3_result_int64(ctx, n); } /* ** json_extract(JSON, PATH, ...) ** ** Return the element described by PATH. Return NULL if there is no ** PATH element. If there are multiple PATHs, then return a JSON array ** with the result from each path. Throw an error if the JSON or any PATH ** is malformed. */ static void jsonExtractFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse *p; /* The parse */ JsonNode *pNode; const char *zPath; JsonString jx; int i; if( argc<2 ) return; p = jsonParseCached(ctx, argv, ctx); if( p==0 ) return; jsonInit(&jx, ctx); jsonAppendChar(&jx, '['); for(i=1; i<argc; i++){ zPath = (const char*)sqlite3_value_text(argv[i]); pNode = jsonLookup(p, zPath, 0, ctx); if( p->nErr ) break; if( argc>2 ){ jsonAppendSeparator(&jx); if( pNode ){ jsonRenderNode(pNode, &jx, 0); }else{ jsonAppendRaw(&jx, "null", 4); } }else if( pNode ){ jsonReturn(pNode, ctx, 0); } } if( argc>2 && i==argc ){ jsonAppendChar(&jx, ']'); jsonResult(&jx); sqlite3_result_subtype(ctx, JSON_SUBTYPE); } jsonReset(&jx); } /* This is the RFC 7396 MergePatch algorithm. */ static JsonNode *jsonMergePatch( JsonParse *pParse, /* The JSON parser that contains the TARGET */ u32 iTarget, /* Node of the TARGET in pParse */ JsonNode *pPatch /* The PATCH */ ){ u32 i, j; u32 iRoot; JsonNode *pTarget; if( pPatch->eType!=JSON_OBJECT ){ return pPatch; } assert( iTarget>=0 && iTarget<pParse->nNode ); pTarget = &pParse->aNode[iTarget]; assert( (pPatch->jnFlags & JNODE_APPEND)==0 ); if( pTarget->eType!=JSON_OBJECT ){ jsonRemoveAllNulls(pPatch); return pPatch; } iRoot = iTarget; for(i=1; i<pPatch->n; i += jsonNodeSize(&pPatch[i+1])+1){ u32 nKey; const char *zKey; assert( pPatch[i].eType==JSON_STRING ); assert( pPatch[i].jnFlags & JNODE_LABEL ); nKey = pPatch[i].n; zKey = pPatch[i].u.zJContent; assert( (pPatch[i].jnFlags & JNODE_RAW)==0 ); for(j=1; j<pTarget->n; j += jsonNodeSize(&pTarget[j+1])+1 ){ assert( pTarget[j].eType==JSON_STRING ); assert( pTarget[j].jnFlags & JNODE_LABEL ); assert( (pPatch[i].jnFlags & JNODE_RAW)==0 ); if( pTarget[j].n==nKey && strncmp(pTarget[j].u.zJContent,zKey,nKey)==0 ){ if( pTarget[j+1].jnFlags & (JNODE_REMOVE|JNODE_PATCH) ) break; if( pPatch[i+1].eType==JSON_NULL ){ pTarget[j+1].jnFlags |= JNODE_REMOVE; }else{ JsonNode *pNew = jsonMergePatch(pParse, iTarget+j+1, &pPatch[i+1]); if( pNew==0 ) return 0; pTarget = &pParse->aNode[iTarget]; if( pNew!=&pTarget[j+1] ){ pTarget[j+1].u.pPatch = pNew; pTarget[j+1].jnFlags |= JNODE_PATCH; } } break; } } if( j>=pTarget->n && pPatch[i+1].eType!=JSON_NULL ){ int iStart, iPatch; iStart = jsonParseAddNode(pParse, JSON_OBJECT, 2, 0); jsonParseAddNode(pParse, JSON_STRING, nKey, zKey); iPatch = jsonParseAddNode(pParse, JSON_TRUE, 0, 0); if( pParse->oom ) return 0; jsonRemoveAllNulls(pPatch); pTarget = &pParse->aNode[iTarget]; pParse->aNode[iRoot].jnFlags |= JNODE_APPEND; pParse->aNode[iRoot].u.iAppend = iStart - iRoot; iRoot = iStart; pParse->aNode[iPatch].jnFlags |= JNODE_PATCH; pParse->aNode[iPatch].u.pPatch = &pPatch[i+1]; } } return pTarget; } /* ** Implementation of the json_mergepatch(JSON1,JSON2) function. Return a JSON ** object that is the result of running the RFC 7396 MergePatch() algorithm ** on the two arguments. */ static void jsonPatchFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse x; /* The JSON that is being patched */ JsonParse y; /* The patch */ JsonNode *pResult; /* The result of the merge */ UNUSED_PARAM(argc); if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; if( jsonParse(&y, ctx, (const char*)sqlite3_value_text(argv[1])) ){ jsonParseReset(&x); return; } pResult = jsonMergePatch(&x, 0, y.aNode); assert( pResult!=0 || x.oom ); if( pResult ){ jsonReturnJson(pResult, ctx, 0); }else{ sqlite3_result_error_nomem(ctx); } jsonParseReset(&x); jsonParseReset(&y); } /* ** Implementation of the json_object(NAME,VALUE,...) function. Return a JSON ** object that contains all name/value given in arguments. Or if any name ** is not a string or if any value is a BLOB, throw an error. */ static void jsonObjectFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ int i; JsonString jx; const char *z; u32 n; if( argc&1 ){ sqlite3_result_error(ctx, "json_object() requires an even number " "of arguments", -1); return; } jsonInit(&jx, ctx); jsonAppendChar(&jx, '{'); for(i=0; i<argc; i+=2){ if( sqlite3_value_type(argv[i])!=SQLITE_TEXT ){ sqlite3_result_error(ctx, "json_object() labels must be TEXT", -1); jsonReset(&jx); return; } jsonAppendSeparator(&jx); z = (const char*)sqlite3_value_text(argv[i]); n = (u32)sqlite3_value_bytes(argv[i]); jsonAppendString(&jx, z, n); jsonAppendChar(&jx, ':'); jsonAppendValue(&jx, argv[i+1]); } jsonAppendChar(&jx, '}'); jsonResult(&jx); sqlite3_result_subtype(ctx, JSON_SUBTYPE); } /* ** json_remove(JSON, PATH, ...) ** ** Remove the named elements from JSON and return the result. malformed ** JSON or PATH arguments result in an error. */ static void jsonRemoveFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse x; /* The parse */ JsonNode *pNode; const char *zPath; u32 i; if( argc<1 ) return; if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; assert( x.nNode ); for(i=1; i<(u32)argc; i++){ zPath = (const char*)sqlite3_value_text(argv[i]); if( zPath==0 ) goto remove_done; pNode = jsonLookup(&x, zPath, 0, ctx); if( x.nErr ) goto remove_done; if( pNode ) pNode->jnFlags |= JNODE_REMOVE; } if( (x.aNode[0].jnFlags & JNODE_REMOVE)==0 ){ jsonReturnJson(x.aNode, ctx, 0); } remove_done: jsonParseReset(&x); } /* ** json_replace(JSON, PATH, VALUE, ...) ** ** Replace the value at PATH with VALUE. If PATH does not already exist, ** this routine is a no-op. If JSON or PATH is malformed, throw an error. */ static void jsonReplaceFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse x; /* The parse */ JsonNode *pNode; const char *zPath; u32 i; if( argc<1 ) return; if( (argc&1)==0 ) { jsonWrongNumArgs(ctx, "replace"); return; } if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; assert( x.nNode ); for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); pNode = jsonLookup(&x, zPath, 0, ctx); if( x.nErr ) goto replace_err; if( pNode ){ pNode->jnFlags |= (u8)JNODE_REPLACE; pNode->u.iReplace = i + 1; } } if( x.aNode[0].jnFlags & JNODE_REPLACE ){ sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); }else{ jsonReturnJson(x.aNode, ctx, argv); } replace_err: jsonParseReset(&x); } /* ** json_set(JSON, PATH, VALUE, ...) ** ** Set the value at PATH to VALUE. Create the PATH if it does not already ** exist. Overwrite existing values that do exist. ** If JSON or PATH is malformed, throw an error. ** ** json_insert(JSON, PATH, VALUE, ...) ** ** Create PATH and initialize it to VALUE. If PATH already exists, this ** routine is a no-op. If JSON or PATH is malformed, throw an error. */ static void jsonSetFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse x; /* The parse */ JsonNode *pNode; const char *zPath; u32 i; int bApnd; int bIsSet = *(int*)sqlite3_user_data(ctx); if( argc<1 ) return; if( (argc&1)==0 ) { jsonWrongNumArgs(ctx, bIsSet ? "set" : "insert"); return; } if( jsonParse(&x, ctx, (const char*)sqlite3_value_text(argv[0])) ) return; assert( x.nNode ); for(i=1; i<(u32)argc; i+=2){ zPath = (const char*)sqlite3_value_text(argv[i]); bApnd = 0; pNode = jsonLookup(&x, zPath, &bApnd, ctx); if( x.oom ){ sqlite3_result_error_nomem(ctx); goto jsonSetDone; }else if( x.nErr ){ goto jsonSetDone; }else if( pNode && (bApnd || bIsSet) ){ pNode->jnFlags |= (u8)JNODE_REPLACE; pNode->u.iReplace = i + 1; } } if( x.aNode[0].jnFlags & JNODE_REPLACE ){ sqlite3_result_value(ctx, argv[x.aNode[0].u.iReplace]); }else{ jsonReturnJson(x.aNode, ctx, argv); } jsonSetDone: jsonParseReset(&x); } /* ** json_type(JSON) ** json_type(JSON, PATH) ** ** Return the top-level "type" of a JSON string. Throw an error if ** either the JSON or PATH inputs are not well-formed. */ static void jsonTypeFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse *p; /* The parse */ const char *zPath; JsonNode *pNode; p = jsonParseCached(ctx, argv, ctx); if( p==0 ) return; if( argc==2 ){ zPath = (const char*)sqlite3_value_text(argv[1]); pNode = jsonLookup(p, zPath, 0, ctx); }else{ pNode = p->aNode; } if( pNode ){ sqlite3_result_text(ctx, jsonType[pNode->eType], -1, SQLITE_STATIC); } } /* ** json_valid(JSON) ** ** Return 1 if JSON is a well-formed JSON string according to RFC-7159. ** Return 0 otherwise. */ static void jsonValidFunc( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonParse *p; /* The parse */ UNUSED_PARAM(argc); p = jsonParseCached(ctx, argv, 0); sqlite3_result_int(ctx, p!=0); } /**************************************************************************** ** Aggregate SQL function implementations ****************************************************************************/ /* ** json_group_array(VALUE) ** ** Return a JSON array composed of all values in the aggregate. */ static void jsonArrayStep( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonString *pStr; UNUSED_PARAM(argc); pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); if( pStr ){ if( pStr->zBuf==0 ){ jsonInit(pStr, ctx); jsonAppendChar(pStr, '['); }else if( pStr->nUsed>1 ){ jsonAppendChar(pStr, ','); pStr->pCtx = ctx; } jsonAppendValue(pStr, argv[0]); } } static void jsonArrayCompute(sqlite3_context *ctx, int isFinal){ JsonString *pStr; pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); if( pStr ){ pStr->pCtx = ctx; jsonAppendChar(pStr, ']'); if( pStr->bErr ){ if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); assert( pStr->bStatic ); }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); pStr->nUsed--; } }else{ sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC); } sqlite3_result_subtype(ctx, JSON_SUBTYPE); } static void jsonArrayValue(sqlite3_context *ctx){ jsonArrayCompute(ctx, 0); } static void jsonArrayFinal(sqlite3_context *ctx){ jsonArrayCompute(ctx, 1); } #ifndef SQLITE_OMIT_WINDOWFUNC /* ** This method works for both json_group_array() and json_group_object(). ** It works by removing the first element of the group by searching forward ** to the first comma (",") that is not within a string and deleting all ** text through that comma. */ static void jsonGroupInverse( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ int i; int inStr = 0; int nNest = 0; char *z; char c; JsonString *pStr; UNUSED_PARAM(argc); UNUSED_PARAM(argv); pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); #ifdef NEVER /* pStr is always non-NULL since jsonArrayStep() or jsonObjectStep() will ** always have been called to initalize it */ if( NEVER(!pStr) ) return; #endif z = pStr->zBuf; for(i=1; (c = z[i])!=',' || inStr || nNest; i++){ if( i>=pStr->nUsed ){ pStr->nUsed = 1; return; } if( c=='"' ){ inStr = !inStr; }else if( c=='\\' ){ i++; }else if( !inStr ){ if( c=='{' || c=='[' ) nNest++; if( c=='}' || c==']' ) nNest--; } } pStr->nUsed -= i; memmove(&z[1], &z[i+1], (size_t)pStr->nUsed-1); } #else # define jsonGroupInverse 0 #endif /* ** json_group_obj(NAME,VALUE) ** ** Return a JSON object composed of all names and values in the aggregate. */ static void jsonObjectStep( sqlite3_context *ctx, int argc, sqlite3_value **argv ){ JsonString *pStr; const char *z; u32 n; UNUSED_PARAM(argc); pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr)); if( pStr ){ if( pStr->zBuf==0 ){ jsonInit(pStr, ctx); jsonAppendChar(pStr, '{'); }else if( pStr->nUsed>1 ){ jsonAppendChar(pStr, ','); pStr->pCtx = ctx; } z = (const char*)sqlite3_value_text(argv[0]); n = (u32)sqlite3_value_bytes(argv[0]); jsonAppendString(pStr, z, n); jsonAppendChar(pStr, ':'); jsonAppendValue(pStr, argv[1]); } } static void jsonObjectCompute(sqlite3_context *ctx, int isFinal){ JsonString *pStr; pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0); if( pStr ){ jsonAppendChar(pStr, '}'); if( pStr->bErr ){ if( pStr->bErr==1 ) sqlite3_result_error_nomem(ctx); assert( pStr->bStatic ); }else if( isFinal ){ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free); pStr->bStatic = 1; }else{ sqlite3_result_text(ctx, pStr->zBuf, (int)pStr->nUsed, SQLITE_TRANSIENT); pStr->nUsed--; } }else{ sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC); } sqlite3_result_subtype(ctx, JSON_SUBTYPE); } static void jsonObjectValue(sqlite3_context *ctx){ jsonObjectCompute(ctx, 0); } static void jsonObjectFinal(sqlite3_context *ctx){ jsonObjectCompute(ctx, 1); } #ifndef SQLITE_OMIT_VIRTUALTABLE /**************************************************************************** ** The json_each virtual table ****************************************************************************/ typedef struct JsonEachCursor JsonEachCursor; struct JsonEachCursor { sqlite3_vtab_cursor base; /* Base class - must be first */ u32 iRowid; /* The rowid */ u32 iBegin; /* The first node of the scan */ u32 i; /* Index in sParse.aNode[] of current row */ u32 iEnd; /* EOF when i equals or exceeds this value */ u8 eType; /* Type of top-level element */ u8 bRecursive; /* True for json_tree(). False for json_each() */ char *zJson; /* Input JSON */ char *zRoot; /* Path by which to filter zJson */ JsonParse sParse; /* Parse of the input JSON */ }; /* Constructor for the json_each virtual table */ static int jsonEachConnect( sqlite3 *db, void *pAux, int argc, const char *const*argv, sqlite3_vtab **ppVtab, char **pzErr ){ sqlite3_vtab *pNew; int rc; /* Column numbers */ #define JEACH_KEY 0 #define JEACH_VALUE 1 #define JEACH_TYPE 2 #define JEACH_ATOM 3 #define JEACH_ID 4 #define JEACH_PARENT 5 #define JEACH_FULLKEY 6 #define JEACH_PATH 7 /* The xBestIndex method assumes that the JSON and ROOT columns are ** the last two columns in the table. Should this ever changes, be ** sure to update the xBestIndex method. */ #define JEACH_JSON 8 #define JEACH_ROOT 9 UNUSED_PARAM(pzErr); UNUSED_PARAM(argv); UNUSED_PARAM(argc); UNUSED_PARAM(pAux); rc = sqlite3_declare_vtab(db, "CREATE TABLE x(key,value,type,atom,id,parent,fullkey,path," "json HIDDEN,root HIDDEN)"); if( rc==SQLITE_OK ){ pNew = *ppVtab = sqlite3_malloc( sizeof(*pNew) ); if( pNew==0 ) return SQLITE_NOMEM; memset(pNew, 0, sizeof(*pNew)); } return rc; } /* destructor for json_each virtual table */ static int jsonEachDisconnect(sqlite3_vtab *pVtab){ sqlite3_free(pVtab); return SQLITE_OK; } /* constructor for a JsonEachCursor object for json_each(). */ static int jsonEachOpenEach(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ JsonEachCursor *pCur; UNUSED_PARAM(p); pCur = sqlite3_malloc( sizeof(*pCur) ); if( pCur==0 ) return SQLITE_NOMEM; memset(pCur, 0, sizeof(*pCur)); *ppCursor = &pCur->base; return SQLITE_OK; } /* constructor for a JsonEachCursor object for json_tree(). */ static int jsonEachOpenTree(sqlite3_vtab *p, sqlite3_vtab_cursor **ppCursor){ int rc = jsonEachOpenEach(p, ppCursor); if( rc==SQLITE_OK ){ JsonEachCursor *pCur = (JsonEachCursor*)*ppCursor; pCur->bRecursive = 1; } return rc; } /* Reset a JsonEachCursor back to its original state. Free any memory ** held. */ static void jsonEachCursorReset(JsonEachCursor *p){ sqlite3_free(p->zJson); sqlite3_free(p->zRoot); jsonParseReset(&p->sParse); p->iRowid = 0; p->i = 0; p->iEnd = 0; p->eType = 0; p->zJson = 0; p->zRoot = 0; } /* Destructor for a jsonEachCursor object */ static int jsonEachClose(sqlite3_vtab_cursor *cur){ JsonEachCursor *p = (JsonEachCursor*)cur; jsonEachCursorReset(p); sqlite3_free(cur); return SQLITE_OK; } /* Return TRUE if the jsonEachCursor object has been advanced off the end ** of the JSON object */ static int jsonEachEof(sqlite3_vtab_cursor *cur){ JsonEachCursor *p = (JsonEachCursor*)cur; return p->i >= p->iEnd; } /* Advance the cursor to the next element for json_tree() */ static int jsonEachNext(sqlite3_vtab_cursor *cur){ JsonEachCursor *p = (JsonEachCursor*)cur; if( p->bRecursive ){ if( p->sParse.aNode[p->i].jnFlags & JNODE_LABEL ) p->i++; p->i++; p->iRowid++; if( p->i<p->iEnd ){ u32 iUp = p->sParse.aUp[p->i]; JsonNode *pUp = &p->sParse.aNode[iUp]; p->eType = pUp->eType; if( pUp->eType==JSON_ARRAY ){ if( iUp==p->i-1 ){ pUp->u.iKey = 0; }else{ pUp->u.iKey++; } } } }else{ switch( p->eType ){ case JSON_ARRAY: { p->i += jsonNodeSize(&p->sParse.aNode[p->i]); p->iRowid++; break; } case JSON_OBJECT: { p->i += 1 + jsonNodeSize(&p->sParse.aNode[p->i+1]); p->iRowid++; break; } default: { p->i = p->iEnd; break; } } } return SQLITE_OK; } /* Append the name of the path for element i to pStr */ static void jsonEachComputePath( JsonEachCursor *p, /* The cursor */ JsonString *pStr, /* Write the path here */ u32 i /* Path to this element */ ){ JsonNode *pNode, *pUp; u32 iUp; if( i==0 ){ jsonAppendChar(pStr, '$'); return; } iUp = p->sParse.aUp[i]; jsonEachComputePath(p, pStr, iUp); pNode = &p->sParse.aNode[i]; pUp = &p->sParse.aNode[iUp]; if( pUp->eType==JSON_ARRAY ){ jsonPrintf(30, pStr, "[%d]", pUp->u.iKey); }else{ assert( pUp->eType==JSON_OBJECT ); if( (pNode->jnFlags & JNODE_LABEL)==0 ) pNode--; assert( pNode->eType==JSON_STRING ); assert( pNode->jnFlags & JNODE_LABEL ); jsonPrintf(pNode->n+1, pStr, ".%.*s", pNode->n-2, pNode->u.zJContent+1); } } /* Return the value of a column */ static int jsonEachColumn( sqlite3_vtab_cursor *cur, /* The cursor */ sqlite3_context *ctx, /* First argument to sqlite3_result_...() */ int i /* Which column to return */ ){ JsonEachCursor *p = (JsonEachCursor*)cur; JsonNode *pThis = &p->sParse.aNode[p->i]; switch( i ){ case JEACH_KEY: { if( p->i==0 ) break; if( p->eType==JSON_OBJECT ){ jsonReturn(pThis, ctx, 0); }else if( p->eType==JSON_ARRAY ){ u32 iKey; if( p->bRecursive ){ if( p->iRowid==0 ) break; iKey = p->sParse.aNode[p->sParse.aUp[p->i]].u.iKey; }else{ iKey = p->iRowid; } sqlite3_result_int64(ctx, (sqlite3_int64)iKey); } break; } case JEACH_VALUE: { if( pThis->jnFlags & JNODE_LABEL ) pThis++; jsonReturn(pThis, ctx, 0); break; } case JEACH_TYPE: { if( pThis->jnFlags & JNODE_LABEL ) pThis++; sqlite3_result_text(ctx, jsonType[pThis->eType], -1, SQLITE_STATIC); break; } case JEACH_ATOM: { if( pThis->jnFlags & JNODE_LABEL ) pThis++; if( pThis->eType>=JSON_ARRAY ) break; jsonReturn(pThis, ctx, 0); break; } case JEACH_ID: { sqlite3_result_int64(ctx, (sqlite3_int64)p->i + ((pThis->jnFlags & JNODE_LABEL)!=0)); break; } case JEACH_PARENT: { if( p->i>p->iBegin && p->bRecursive ){ sqlite3_result_int64(ctx, (sqlite3_int64)p->sParse.aUp[p->i]); } break; } case JEACH_FULLKEY: { JsonString x; jsonInit(&x, ctx); if( p->bRecursive ){ jsonEachComputePath(p, &x, p->i); }else{ if( p->zRoot ){ jsonAppendRaw(&x, p->zRoot, (int)strlen(p->zRoot)); }else{ jsonAppendChar(&x, '$'); } if( p->eType==JSON_ARRAY ){ jsonPrintf(30, &x, "[%d]", p->iRowid); }else if( p->eType==JSON_OBJECT ){ jsonPrintf(pThis->n, &x, ".%.*s", pThis->n-2, pThis->u.zJContent+1); } } jsonResult(&x); break; } case JEACH_PATH: { if( p->bRecursive ){ JsonString x; jsonInit(&x, ctx); jsonEachComputePath(p, &x, p->sParse.aUp[p->i]); jsonResult(&x); break; } /* For json_each() path and root are the same so fall through ** into the root case */ } default: { const char *zRoot = p->zRoot; if( zRoot==0 ) zRoot = "$"; sqlite3_result_text(ctx, zRoot, -1, SQLITE_STATIC); break; } case JEACH_JSON: { assert( i==JEACH_JSON ); sqlite3_result_text(ctx, p->sParse.zJson, -1, SQLITE_STATIC); break; } } return SQLITE_OK; } /* Return the current rowid value */ static int jsonEachRowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ JsonEachCursor *p = (JsonEachCursor*)cur; *pRowid = p->iRowid; return SQLITE_OK; } /* The query strategy is to look for an equality constraint on the json ** column. Without such a constraint, the table cannot operate. idxNum is ** 1 if the constraint is found, 3 if the constraint and zRoot are found, ** and 0 otherwise. */ static int jsonEachBestIndex( sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo ){ int i; /* Loop counter or computed array index */ int aIdx[2]; /* Index of constraints for JSON and ROOT */ int unusableMask = 0; /* Mask of unusable JSON and ROOT constraints */ int idxMask = 0; /* Mask of usable == constraints JSON and ROOT */ const struct sqlite3_index_constraint *pConstraint; /* This implementation assumes that JSON and ROOT are the last two ** columns in the table */ assert( JEACH_ROOT == JEACH_JSON+1 ); UNUSED_PARAM(tab); aIdx[0] = aIdx[1] = -1; pConstraint = pIdxInfo->aConstraint; for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){ int iCol; int iMask; if( pConstraint->iColumn < JEACH_JSON ) continue; iCol = pConstraint->iColumn - JEACH_JSON; assert( iCol==0 || iCol==1 ); iMask = 1 << iCol; if( pConstraint->usable==0 ){ unusableMask |= iMask; }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){ aIdx[iCol] = i; idxMask |= iMask; } } if( (unusableMask & ~idxMask)!=0 ){ /* If there are any unusable constraints on JSON or ROOT, then reject ** this entire plan */ return SQLITE_CONSTRAINT; } if( aIdx[0]<0 ){ /* No JSON input. Leave estimatedCost at the huge value that it was ** initialized to to discourage the query planner from selecting this ** plan. */ pIdxInfo->idxNum = 0; }else{ pIdxInfo->estimatedCost = 1.0; i = aIdx[0]; pIdxInfo->aConstraintUsage[i].argvIndex = 1; pIdxInfo->aConstraintUsage[i].omit = 1; if( aIdx[1]<0 ){ pIdxInfo->idxNum = 1; /* Only JSON supplied. Plan 1 */ }else{ i = aIdx[1]; pIdxInfo->aConstraintUsage[i].argvIndex = 2; pIdxInfo->aConstraintUsage[i].omit = 1; pIdxInfo->idxNum = 3; /* Both JSON and ROOT are supplied. Plan 3 */ } } return SQLITE_OK; } /* Start a search on a new JSON string */ static int jsonEachFilter( sqlite3_vtab_cursor *cur, int idxNum, const char *idxStr, int argc, sqlite3_value **argv ){ JsonEachCursor *p = (JsonEachCursor*)cur; const char *z; const char *zRoot = 0; sqlite3_int64 n; UNUSED_PARAM(idxStr); UNUSED_PARAM(argc); jsonEachCursorReset(p); if( idxNum==0 ) return SQLITE_OK; z = (const char*)sqlite3_value_text(argv[0]); if( z==0 ) return SQLITE_OK; n = sqlite3_value_bytes(argv[0]); p->zJson = sqlite3_malloc64( n+1 ); if( p->zJson==0 ) return SQLITE_NOMEM; memcpy(p->zJson, z, (size_t)n+1); if( jsonParse(&p->sParse, 0, p->zJson) ){ int rc = SQLITE_NOMEM; if( p->sParse.oom==0 ){ sqlite3_free(cur->pVtab->zErrMsg); cur->pVtab->zErrMsg = sqlite3_mprintf("malformed JSON"); if( cur->pVtab->zErrMsg ) rc = SQLITE_ERROR; } jsonEachCursorReset(p); return rc; }else if( p->bRecursive && jsonParseFindParents(&p->sParse) ){ jsonEachCursorReset(p); return SQLITE_NOMEM; }else{ JsonNode *pNode = 0; if( idxNum==3 ){ const char *zErr = 0; zRoot = (const char*)sqlite3_value_text(argv[1]); if( zRoot==0 ) return SQLITE_OK; n = sqlite3_value_bytes(argv[1]); p->zRoot = sqlite3_malloc64( n+1 ); if( p->zRoot==0 ) return SQLITE_NOMEM; memcpy(p->zRoot, zRoot, (size_t)n+1); if( zRoot[0]!='$' ){ zErr = zRoot; }else{ pNode = jsonLookupStep(&p->sParse, 0, p->zRoot+1, 0, &zErr); } if( zErr ){ sqlite3_free(cur->pVtab->zErrMsg); cur->pVtab->zErrMsg = jsonPathSyntaxError(zErr); jsonEachCursorReset(p); return cur->pVtab->zErrMsg ? SQLITE_ERROR : SQLITE_NOMEM; }else if( pNode==0 ){ return SQLITE_OK; } }else{ pNode = p->sParse.aNode; } p->iBegin = p->i = (int)(pNode - p->sParse.aNode); p->eType = pNode->eType; if( p->eType>=JSON_ARRAY ){ pNode->u.iKey = 0; p->iEnd = p->i + pNode->n + 1; if( p->bRecursive ){ p->eType = p->sParse.aNode[p->sParse.aUp[p->i]].eType; if( p->i>0 && (p->sParse.aNode[p->i-1].jnFlags & JNODE_LABEL)!=0 ){ p->i--; } }else{ p->i++; } }else{ p->iEnd = p->i+1; } } return SQLITE_OK; } /* The methods of the json_each virtual table */ static sqlite3_module jsonEachModule = { 0, /* iVersion */ 0, /* xCreate */ jsonEachConnect, /* xConnect */ jsonEachBestIndex, /* xBestIndex */ jsonEachDisconnect, /* xDisconnect */ 0, /* xDestroy */ jsonEachOpenEach, /* xOpen - open a cursor */ jsonEachClose, /* xClose - close a cursor */ jsonEachFilter, /* xFilter - configure scan constraints */ jsonEachNext, /* xNext - advance a cursor */ jsonEachEof, /* xEof - check for end of scan */ jsonEachColumn, /* xColumn - read data */ jsonEachRowid, /* xRowid - read data */ 0, /* xUpdate */ 0, /* xBegin */ 0, /* xSync */ 0, /* xCommit */ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ 0 /* xShadowName */ }; /* The methods of the json_tree virtual table. */ static sqlite3_module jsonTreeModule = { 0, /* iVersion */ 0, /* xCreate */ jsonEachConnect, /* xConnect */ jsonEachBestIndex, /* xBestIndex */ jsonEachDisconnect, /* xDisconnect */ 0, /* xDestroy */ jsonEachOpenTree, /* xOpen - open a cursor */ jsonEachClose, /* xClose - close a cursor */ jsonEachFilter, /* xFilter - configure scan constraints */ jsonEachNext, /* xNext - advance a cursor */ jsonEachEof, /* xEof - check for end of scan */ jsonEachColumn, /* xColumn - read data */ jsonEachRowid, /* xRowid - read data */ 0, /* xUpdate */ 0, /* xBegin */ 0, /* xSync */ 0, /* xCommit */ 0, /* xRollback */ 0, /* xFindMethod */ 0, /* xRename */ 0, /* xSavepoint */ 0, /* xRelease */ 0, /* xRollbackTo */ 0 /* xShadowName */ }; #endif /* SQLITE_OMIT_VIRTUALTABLE */ /**************************************************************************** ** The following routines are the only publically visible identifiers in this ** file. Call the following routines in order to register the various SQL ** functions and the virtual table implemented by this file. ****************************************************************************/ int sqlite3Json1Init(sqlite3 *db){ int rc = SQLITE_OK; unsigned int i; static const struct { const char *zName; int nArg; int flag; void (*xFunc)(sqlite3_context*,int,sqlite3_value**); } aFunc[] = { { "json", 1, 0, jsonRemoveFunc }, { "json_array", -1, 0, jsonArrayFunc }, { "json_array_length", 1, 0, jsonArrayLengthFunc }, { "json_array_length", 2, 0, jsonArrayLengthFunc }, { "json_extract", -1, 0, jsonExtractFunc }, { "json_insert", -1, 0, jsonSetFunc }, { "json_object", -1, 0, jsonObjectFunc }, { "json_patch", 2, 0, jsonPatchFunc }, { "json_quote", 1, 0, jsonQuoteFunc }, { "json_remove", -1, 0, jsonRemoveFunc }, { "json_replace", -1, 0, jsonReplaceFunc }, { "json_set", -1, 1, jsonSetFunc }, { "json_type", 1, 0, jsonTypeFunc }, { "json_type", 2, 0, jsonTypeFunc }, { "json_valid", 1, 0, jsonValidFunc }, #if SQLITE_DEBUG /* DEBUG and TESTING functions */ { "json_parse", 1, 0, jsonParseFunc }, { "json_test1", 1, 0, jsonTest1Func }, #endif }; static const struct { const char *zName; int nArg; void (*xStep)(sqlite3_context*,int,sqlite3_value**); void (*xFinal)(sqlite3_context*); void (*xValue)(sqlite3_context*); } aAgg[] = { { "json_group_array", 1, jsonArrayStep, jsonArrayFinal, jsonArrayValue }, { "json_group_object", 2, jsonObjectStep, jsonObjectFinal, jsonObjectValue }, }; #ifndef SQLITE_OMIT_VIRTUALTABLE static const struct { const char *zName; sqlite3_module *pModule; } aMod[] = { { "json_each", &jsonEachModule }, { "json_tree", &jsonTreeModule }, }; #endif for(i=0; i<sizeof(aFunc)/sizeof(aFunc[0]) && rc==SQLITE_OK; i++){ rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg, SQLITE_UTF8 | SQLITE_DETERMINISTIC, (void*)&aFunc[i].flag, aFunc[i].xFunc, 0, 0); } #ifndef SQLITE_OMIT_WINDOWFUNC for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){ rc = sqlite3_create_window_function(db, aAgg[i].zName, aAgg[i].nArg, SQLITE_SUBTYPE | SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0, aAgg[i].xStep, aAgg[i].xFinal, aAgg[i].xValue, jsonGroupInverse, 0); } #endif #ifndef SQLITE_OMIT_VIRTUALTABLE for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){ rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0); } #endif return rc; } #ifndef SQLITE_CORE #ifdef _WIN32 __declspec(dllexport) #endif int sqlite3_json_init( sqlite3 *db, char **pzErrMsg, const sqlite3_api_routines *pApi ){ SQLITE_EXTENSION_INIT2(pApi); (void)pzErrMsg; /* Unused parameter */ return sqlite3Json1Init(db); } #endif #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_JSON1) */
the_stack_data/6386682.c
/* C r23 is internally replaced with r11 C and r46 is replaced with r22 for single precision */ #if defined(USE_POW) #define r23 pow(0.5f, 11.0f) #define r46 (r23*r23) #define t23 pow(2.0f, 11.0f) #define t46 (t23*t23) #else #define r23 (0.5f*0.5f*0.5f*0.5f*0.5f*0.5f*0.5f*0.5f*0.5f*0.5f*0.5f) #define r46 (r23*r23) #define t23 (2.0f*2.0f*2.0f*2.0f*2.0f*2.0f*2.0f*2.0f*2.0f*2.0f*2.0f) #define t46 (t23*t23) #endif /*c--------------------------------------------------------------------- c---------------------------------------------------------------------*/ float randlc (float *x, float a) { /*c--------------------------------------------------------------------- c---------------------------------------------------------------------*/ /*c--------------------------------------------------------------------- c c This routine returns a uniform pseudorandom double precision number in the c range (0, 1) by using the linear congruential generator c c x_{k+1} = a x_k (mod 2^46) c c where 0 < x_k < 2^46 and 0 < a < 2^46. This scheme generates 2^44 numbers c before repeating. The argument A is the same as 'a' in the above formula, c and X is the same as x_0. A and X must be odd double precision integers c in the range (1, 2^46). The returned value RANDLC is normalized to be c between 0 and 1, i.e. RANDLC = 2^(-46) * x_1. X is updated to contain c the new seed x_1, so that subsequent calls to RANDLC using the same c arguments will generate a continuous sequence. c c This routine should produce the same results on any computer with at least c 48 mantissa bits in double precision floating point data. On 64 bit c systems, double precision should be disabled. c c David H. Bailey October 26, 1990 c c---------------------------------------------------------------------*/ float t1,t2,t3,t4,a1,a2,x1,x2,z; /*c--------------------------------------------------------------------- c Break A into two parts such that A = 2^23 * A1 + A2. c---------------------------------------------------------------------*/ t1 = r23 * a; a1 = (int)t1; a2 = a - t23 * a1; /*c--------------------------------------------------------------------- c Break X into two parts such that X = 2^23 * X1 + X2, compute c Z = A1 * X2 + A2 * X1 (mod 2^23), and then c X = 2^23 * Z + A2 * X2 (mod 2^46). c---------------------------------------------------------------------*/ t1 = r23 * (*x); x1 = (int)t1; x2 = (*x) - t23 * x1; t1 = a1 * x2 + a2 * x1; t2 = (int)(r23 * t1); z = t1 - t23 * t2; t3 = t23 * z + a2 * x2; t4 = (int)(r46 * t3); (*x) = t3 - t46 * t4; return (r46 * (*x)); } /*c--------------------------------------------------------------------- c---------------------------------------------------------------------*/ void vranlc (int n, float *x_seed, float a, float y[]) { /*c--------------------------------------------------------------------- c---------------------------------------------------------------------*/ /*c--------------------------------------------------------------------- c c This routine generates N uniform pseudorandom double precision numbers in c the range (0, 1) by using the linear congruential generator c c x_{k+1} = a x_k (mod 2^46) c c where 0 < x_k < 2^46 and 0 < a < 2^46. This scheme generates 2^44 numbers c before repeating. The argument A is the same as 'a' in the above formula, c and X is the same as x_0. A and X must be odd double precision integers c in the range (1, 2^46). The N results are placed in Y and are normalized c to be between 0 and 1. X is updated to contain the new seed, so that c subsequent calls to VRANLC using the same arguments will generate a c continuous sequence. If N is zero, only initialization is performed, and c the variables X, A and Y are ignored. c c This routine is the standard version designed for scalar or RISC systems. c However, it should produce the same results on any single processor c computer with at least 48 mantissa bits in double precision floating point c data. On 64 bit systems, double precision should be disabled. c c---------------------------------------------------------------------*/ int i; float x,t1,t2,t3,t4,a1,a2,x1,x2,z; /*c--------------------------------------------------------------------- c Break A into two parts such that A = 2^23 * A1 + A2. c---------------------------------------------------------------------*/ t1 = r23 * a; a1 = (int)t1; a2 = a - t23 * a1; x = *x_seed; /*c--------------------------------------------------------------------- c Generate N results. This loop is not vectorizable. c---------------------------------------------------------------------*/ for (i = 1; i <= n; i++) { /*c--------------------------------------------------------------------- c Break X into two parts such that X = 2^23 * X1 + X2, compute c Z = A1 * X2 + A2 * X1 (mod 2^23), and then c X = 2^23 * Z + A2 * X2 (mod 2^46). c---------------------------------------------------------------------*/ t1 = r23 * x; x1 = (int)t1; x2 = x - t23 * x1; t1 = a1 * x2 + a2 * x1; t2 = (int)(r23 * t1); z = t1 - t23 * t2; t3 = t23 * z + a2 * x2; t4 = (int)(r46 * t3); x = t3 - t46 * t4; y[i] = r46 * x; } *x_seed = x; }
the_stack_data/42811.c
#include <stdio.h> #include <stdlib.h> /* * This the program entry function. The parameters provide a means to access the * command line arguments. * argc - The number of command line arguments * argv - A pointer to the first argument (text string) */ int main (int argc, const char* argv[]) { // Make sure the number of arguments are correct if (argc != 4) { printf("Wrong usage\n"); return 0; } // Store the input arguments in appropriate primitives const char *name = argv[1]; int age = atoi(argv[2]); float height = atof(argv[3]); printf("Name: %s Age: %d Height: %f\n", name, age, height); return 0; }
the_stack_data/48574277.c
//--------------------------- // UCL-CEREM-MBS // // @version MBsysLab_s 1.7.a // // Creation : 2006 // Last update : 01/10/2008 //--------------------------- #include <math.h> double norm_vector(double *v, int n) { double norm = 0.0; int i; for(i=1;i<=n;i++) norm += v[i]*v[i]; return sqrt(norm); } double norminf_vector(double *v, int n) { double norm = 0.0; int i; for(i=1;i<=n;i++) if (fabs(v[i]) > norm) norm = fabs(v[i]); return norm; }
the_stack_data/84999.c
int func4() { return 4; }
the_stack_data/584788.c
/* * Problem 102: Triangle containment. * * https://projecteuler.net/problem=102 */ #include <stdio.h> #define VERBOSE 0 //Tells whether a one dimensional point is inside a segment int is_point_in_segment(int point, int s1, int s2){ if (s1 < s2){ return point >= s1 && point <= s2; } else{ return point >= s2 && point <= s1; } } //Tells whether a two dimensional segment intersects the x axis in (-inf, 0] int intersects_x(int x1, int y1, int x2, int y2){ //In the case of a horizontal segment intersection occurs only when they overlap if (y1 == y2){ return y1 == 0; } //In any other case, calculate the segment and see if they cross if (x1 == x2){ if (x1 <= 0){ return is_point_in_segment(0, y1, y2); } return 0; } //In the case of a non vertical segment wee need to calculate the intersection point //In this program the point is calculated using the slope intercept formula float m = (y2-y1)/(float)(x2-x1); float b = y1 - m*x1; //m will never be 0 float x = -b/m; if (x <= 0){ return is_point_in_segment(x, x1, x2); } return 0; } //The only time a triangle contains the center is if a line along the x asis in (-infinity, 0] // intersects only one of the sides of the triangle int main(){ int x1, y1; int x2, y2; int x3, y3; int intersections, count = 0; //Read the file FILE *file = fopen("triangles.txt", "r"); if (file != NULL){ while (fscanf(file, "%d,%d,%d,%d,%d,%d", &x1, &y1, &x2, &y2, &x3, &y3) != EOF){ //Reset the intersection count and test all three sides intersections = 0; if (intersects_x(x1, y1, x2, y2)){ intersections++; } if (intersects_x(x1, y1, x3, y3)){ intersections++; } if (intersects_x(x2, y2, x3, y3)){ intersections++; } //If there is only one intersection, the triangle contains the center if (intersections == 1){ count++; } if (VERBOSE){ if (intersections == 1){ printf("(%d, %d), (%d, %d), (%d, %d) contains the center, 1 intersection\n", x1, y1, x2, y2, x3, y3); } else{ printf("(%d, %d), (%d, %d), (%d, %d) doesn't contain the center, %d intersections\n", x1, y1, x2, y2, x3, y3, intersections); } } } //Close, print the solution, and exit fclose(file); printf("\nThe number of triangles containing the center is %d\n\n", count); return 0; } else{ printf("Couldn't read the file...\n\n"); return 1; } }
the_stack_data/543588.c
#include <sys/time.h> #include <stdio.h> #include <pthread.h> #include <errno.h> main() { struct timeval start,end; long forktime; double avgtime; pthread_t last_thread; int i; int iters = 250; void *null_proc(); gettimeofday(&start,NULL); for (i = 0; i < iters - 1; i++) /* create (iters-1) threads */ pthread_create(&last_thread,NULL,null_proc,NULL); pthread_create(&last_thread,NULL,null_proc,NULL); /* create last thread */ gettimeofday(&end,NULL); pthread_join(last_thread, NULL); /* wait for last thread */ forktime = (end.tv_sec - start.tv_sec)*1000000 + (end.tv_usec - start.tv_usec); avgtime = (double)forktime/(double)iters; printf("Avg thr_create time = %f microsec\n", avgtime); } void *null_proc() { }
the_stack_data/810078.c
/* { dg-options "-fno-common isa_rev<=5 -mabi=n32 (REQUIRES_STDLIB)" } */ /* { dg-skip-if "code quality test" { *-*-* } { "-O0" "-Os"} { "" } } */ /* { dg-final { scan-assembler-not "\tmemcpy" } } */ /* { dg-final { scan-assembler-times "sdl" 4 } } */ /* { dg-final { scan-assembler-times "sdr" 4 } } */ /* Test that inline memcpy for hardware with sdl, sdr handles subword alignment and produces enough sdr/sdls on n32. */ #include <string.h> char c[40] __attribute__ ((aligned(2))); void f1 () { memcpy (c, "1234567890QWERTYUIOPASDFGHJKLZXCVBNM", 32); }
the_stack_data/11073982.c
_Bool nondet_bool(); _Bool LOCK = 0; _Bool lock() { if(nondet_bool()) { assert(!LOCK); LOCK=1; return 1; } return 0; } void unlock() { assert(LOCK); LOCK=0; } int main() { unsigned got_lock = 0; int times; while(times > 0) { if(lock()) { got_lock++; /* critical section */ } if(got_lock!=0) unlock(); got_lock--; times--; } }
the_stack_data/181394549.c
#include<stdio.h> #include<stdlib.h> struct trienode{ int nodekind;//0时对应枝干节点,1时对应叶子节点 char leafname[10]; int layer;//第几层 int maxlayer; struct trienode* ptr[27];//通向下层的指针 int num//多少个关键词经过这个节点 }; int numbersgetline(char s[]){ int c,i; int j = 0; int state = 1; int number = 0; for(i = 0;(c = getchar())!=EOF&&c!='\n'&&c!=';';){ s[j++] = c; } s[j] = '\0'; return j; } void Inittrietree(struct trienode*root,int h){ root->maxlayer = h; root->layer = 0; root->nodekind = 0; root->num = 0; for(int i = 0; i < 27; i++){ root -> ptr[i] = NULL; } } struct trienode* CreateEmptyTrieTree(int h){ int i; struct trienode* root = NULL; root = malloc(sizeof(struct trienode)); root -> layer = 0; root -> maxlayer = h; root ->nodekind = 0; for(i = 0; i < 27; i++){ root -> ptr[i] = NULL; root ->num = 0; } return root; } void insert(struct trienode*root,char*s){ struct trienode* p = NULL, *pre = NULL; int i = 0; p = root -> ptr[s[i++] - 'a' + 1]; pre = root; while(p){ if(p->nodekind == 1) break; pre = p; p ->num++; if(s[i]) p = p -> ptr[s[i++] - 'a' + 1]; else p = p -> ptr[s[i++]]; } i--; if(pre -> layer == root -> maxlayer + 1) return; while(pre -> layer < root -> maxlayer){ pre -> ptr[s[i] - 'a' + 1] = CreateEmptyTrieTree(root -> maxlayer); p = pre -> ptr[s[i++] - 'a' + 1]; p -> num++; p -> layer = pre -> layer + 1; p -> nodekind = 0; pre = p; } if(s[i]){ pre -> ptr[s[i] - 'a' + 1] = malloc(sizeof(struct trienode)); p = pre -> ptr[s[i]- 'a' + 1]; } else{ pre -> ptr[s[i]] = malloc(sizeof(struct trienode)); p = pre -> ptr[s[i]]; } p -> nodekind = 1; p -> layer = 4; for(int j = 0;s[j]!=0;j++) p -> leafname[j] = s[j]; return; } int tag = 1; void PreOrderTraverse(struct trienode* root){ if(root == NULL || root ->nodekind==1) return; if(root -> layer != 0){ if(tag){ printf("%d", root -> num); tag = 0; }else printf(",%d", root -> num); } for(int i = 0; i < 27; i++){ PreOrderTraverse(root -> ptr[i]); } } int main(){ char s[100] = {0}; struct trienode *root; root = malloc(sizeof(struct trienode)); int h; scanf("%d",&h); getchar(); Inittrietree(root,h); while(numbersgetline(s)!=0){ insert(root,s); } if(h==4){ for(int i = 2;i<27;i++){ root->ptr[i] = NULL; } } PreOrderTraverse(root); }
the_stack_data/25245.c
// general protection fault in smc_ioctl // https://syzkaller.appspot.com/bug?id=675043826ccef68f42159a20414bd877f98b66e5 // status:fixed // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include <endian.h> #include <stdint.h> #include <string.h> #include <sys/syscall.h> #include <unistd.h> uint64_t r[1] = {0xffffffffffffffff}; void loop() { long res = 0; res = syscall(__NR_socket, 0x2b, 1, 0); if (res != -1) r[0] = res; syscall(__NR_ioctl, r[0], 0x5411, 0x20000080); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }
the_stack_data/45450413.c
// RUN: rm -rf %t* // RUN: 3c -base-dir=%S -alltypes -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_ALL","CHECK" %s // RUN: 3c -base-dir=%S -addcr %s -- | FileCheck -match-full-lines -check-prefixes="CHECK_NOALL","CHECK" %s // RUN: 3c -base-dir=%S -addcr %s -- | %clang -c -fcheckedc-extension -x c -o /dev/null - // RUN: 3c -base-dir=%S -alltypes -output-dir=%t.checked %s -- // RUN: 3c -base-dir=%t.checked -alltypes %t.checked/arrstructprotocaller.c -- | diff %t.checked/arrstructprotocaller.c - /******************************************************************************/ /*This file tests three functions: two callers bar and foo, and a callee sus*/ /*In particular, this file tests: arrays and structs, specifically by using an array to traverse through the values of a struct*/ /*For robustness, this test is identical to arrstructcaller.c except in that a prototype for sus is available, and is called by foo and bar, while the definition for sus appears below them*/ /*In this test, foo and sus will treat their return values safely, but bar will not, through invalid pointer arithmetic, an unsafe cast, etc.*/ /******************************************************************************/ #include <stddef.h> #include <stdlib.h> #include <stdio.h> #include <string.h> struct general { int data; struct general *next; //CHECK: _Ptr<struct general> next; }; struct warr { int data1[5]; //CHECK_NOALL: int data1[5]; //CHECK_ALL: int data1 _Checked[5]; char *name; //CHECK: _Ptr<char> name; }; struct fptrarr { int *values; //CHECK: _Ptr<int> values; char *name; //CHECK: _Ptr<char> name; int (*mapper)(int); //CHECK: _Ptr<int (int)> mapper; }; struct fptr { int *value; //CHECK: _Ptr<int> value; int (*func)(int); //CHECK: _Ptr<int (int)> func; }; struct arrfptr { int args[5]; //CHECK_NOALL: int args[5]; //CHECK_ALL: int args _Checked[5]; int (*funcs[5])(int); //CHECK_NOALL: int (*funcs[5])(int); //CHECK_ALL: _Ptr<int (int)> funcs _Checked[5]; }; int add1(int x) { //CHECK: int add1(int x) _Checked { return x + 1; } int sub1(int x) { //CHECK: int sub1(int x) _Checked { return x - 1; } int fact(int n) { //CHECK: int fact(int n) _Checked { if (n == 0) { return 1; } return n * fact(n - 1); } int fib(int n) { //CHECK: int fib(int n) _Checked { if (n == 0) { return 0; } if (n == 1) { return 1; } return fib(n - 1) + fib(n - 2); } int zerohuh(int n) { //CHECK: int zerohuh(int n) _Checked { return !n; } int *mul2(int *x) { //CHECK: _Ptr<int> mul2(_Ptr<int> x) _Checked { *x *= 2; return x; } int *sus(struct general *, struct general *); //CHECK_NOALL: int *sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) : itype(_Ptr<int>); //CHECK_ALL: _Array_ptr<int> sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) : count(5); int *foo() { //CHECK_NOALL: _Ptr<int> foo(void) { //CHECK_ALL: _Array_ptr<int> foo(void) : count(5) { struct general *x = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> x = malloc<struct general>(sizeof(struct general)); struct general *y = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> y = malloc<struct general>(sizeof(struct general)); struct general *curr = y; //CHECK: _Ptr<struct general> curr = y; int i; for (i = 1; i < 5; i++, curr = curr->next) { curr->data = i; curr->next = malloc(sizeof(struct general)); curr->next->data = i + 1; } int *z = sus(x, y); //CHECK_NOALL: _Ptr<int> z = sus(x, y); //CHECK_ALL: _Array_ptr<int> z : count(5) = sus(x, y); return z; } int *bar() { //CHECK_NOALL: int *bar(void) : itype(_Ptr<int>) { //CHECK_ALL: _Array_ptr<int> bar(void) { struct general *x = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> x = malloc<struct general>(sizeof(struct general)); struct general *y = malloc(sizeof(struct general)); //CHECK: _Ptr<struct general> y = malloc<struct general>(sizeof(struct general)); struct general *curr = y; //CHECK: _Ptr<struct general> curr = y; int i; for (i = 1; i < 5; i++, curr = curr->next) { curr->data = i; curr->next = malloc(sizeof(struct general)); curr->next->data = i + 1; } int *z = sus(x, y); //CHECK_NOALL: int *z = sus(x, y); //CHECK_ALL: _Array_ptr<int> z = sus(x, y); z += 2; return z; } int *sus(struct general *x, struct general *y) { //CHECK_NOALL: int *sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) : itype(_Ptr<int>) { //CHECK_ALL: _Array_ptr<int> sus(struct general *x : itype(_Ptr<struct general>), _Ptr<struct general> y) : count(5) { x = (struct general *)5; //CHECK: x = (struct general *)5; int *z = calloc(5, sizeof(int)); //CHECK_NOALL: int *z = calloc<int>(5, sizeof(int)); //CHECK_ALL: _Array_ptr<int> z : count(5) = calloc<int>(5, sizeof(int)); struct general *p = y; //CHECK: _Ptr<struct general> p = y; int i; for (i = 0; i < 5; p = p->next, i++) { //CHECK_NOALL: for (i = 0; i < 5; p = p->next, i++) { //CHECK_ALL: for (i = 0; i < 5; p = p->next, i++) _Checked { z[i] = p->data; } return z; }
the_stack_data/827664.c
#include <stdio.h> #include <stdlib.h> int main() { int a, b, soma; printf("Informe o valor de a: "); scanf("%d",&a); printf("Informe o valor de b: "); scanf ("%d",&b); soma = a + b; printf("Resultado da soma: %d", soma); return (0); }
the_stack_data/713680.c
/* Convert string to maximal integer. Copyright (C) 1997-2020 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <[email protected]>, 1997. 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 <https://www.gnu.org/licenses/>. */ #include <inttypes.h> #include <stdlib.h> intmax_t strtoimax (const char *__restrict nptr, char **__restrict endptr, int base) { return __strtoll_internal (nptr, endptr, base, 0); }
the_stack_data/59512168.c
/* * Copyright (c) 2017, Linaro Limited * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT 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. */ void __aeabi_unwind_cpp_pr0(void); void __aeabi_unwind_cpp_pr0(void) { } void __aeabi_unwind_cpp_pr1(void); void __aeabi_unwind_cpp_pr1(void) { } void __aeabi_unwind_cpp_pr2(void); void __aeabi_unwind_cpp_pr2(void) { }
the_stack_data/132952181.c
main(int a, int b){ double d; int i; printf("%d %f %d %d\n", i, d, a, b); }
the_stack_data/156392941.c
extern const char *v4l2_type_names[]; const char *v4l2_type_names[] = { "test" }; extern const char *v4l2_type_names[]; static void test(void) { unsigned sz = sizeof(v4l2_type_names); } /* * check-name: duplicate extern array */
the_stack_data/114276.c
#include <stdio.h> #include <stdlib.h> int main() { printf("Ola Mundo!"); return 0; }
the_stack_data/133530.c
/* { dg-do compile } */ /* { dg-require-effective-target section_anchors } */ /* { dg-require-effective-target vect_int } */ /* Should not increase alignment of the struct because sizeof (A.e) < sizeof(corresponding vector type). */ #define N 3 static struct A { int p1, p2; int e[N]; } a, b, c; int foo(void) { for (int i = 0; i < N; i++) a.e[i] = b.e[i] + c.e[i]; return a.e[0]; } /* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target aarch64*-*-* } } } */ /* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target powerpc64*-*-* } } } */ /* { dg-final { scan-ipa-dump-times "Increasing alignment of decl" 0 "increase_alignment" { target arm*-*-* } } } */
the_stack_data/132953209.c
/* $Id$ */ char * memchr(s, c, n) char *s; register int n; { register unsigned char *s1 = (unsigned char *) s; c &= 0377; while (n-- > 0) { if (*s1 == c) return (char *) s1; s1++; } return 0; }
the_stack_data/150141623.c
#include <stdio.h> #include <string.h> char *stringInString(char *s1, char *s2) { char *p = s1; // char *endOfString = p + strlen(s1); // Alternatively, we can write the while loop as: // while (endOfString - p >= strlen(s2) && strncmp(p, s2, strlen(s2)) != 0) while (*p != '\0' && strncmp(p, s2, strlen(s2)) != 0) p++; // Alternatively, we can write: // if (endOfString - p < strlen(s2)) // return NULL; if (*p == '\0') return NULL; else return p; } int main(void) { char s[] = "This is a sample string"; printf("Looking for the string \"is\" in \"%s\"...\n", s); // Alternatively, we can also use the strstr() function // char *p = strstr(s, "is"); char *p = stringInString(s, "is"); while (p != NULL) { printf("Found at %ld\n", p - s); p = stringInString(p + 1, "is"); } return 0; }
the_stack_data/9697.c
#include <stdio.h> //#include "extern_hdr.h" //extern int arr_size; #define sss 5 extern int arr[sss]; //extern int arr_size; int main() { printf("\n hello\n"); printf("\n no of element in arr : %d \n", sizeof(arr)/sizeof(arr[0]) ); return 0; }
the_stack_data/97618.c
#include <stdio.h> int main(void) { int t[1000]; int i; int suma = 0; int suma_maxi = 0; int suma_mini = 0; float srednia = 0.0; int z = 0; printf("Podaj liczby: "); for (i = 0; i < 1000; i++) { int test = scanf("%i", &t[i]); if (!test) { printf("Incorrect input\n"); return 1; } if (t[i] == 0) { break; } suma += t[i]; z++; } srednia = (float)suma / (float)i; if(z == 0){ printf("Brak danych\n"); return 0; } for (i = 0; i < z; i++) { if (t[i] > srednia) { suma_maxi += t[i]; } if (t[i] < srednia) { suma_mini += t[i]; } } printf("%.2f\n", srednia); printf("%i\n", suma_maxi); printf("%i", suma_mini); return 0; }
the_stack_data/170452075.c
#include <stdio.h> int main() { int i = 0; while (i < 20) { i += 1; if (i % 2) continue; if (i == 16) break; printf("%d\n", i); } i = 0; while (i < 20) { i += 1; if (i % 2) continue; if (i == 16) break; printf("%d\n", i); int j = 20; while (j) { j -= 1; if (j % 2) continue; if (j == 4) break; printf("%d\n", j); } } for (int i=0, j=10; ; i+=1) { if (i % 2) continue; printf("%d\n", i); if (i == j) break; } printf("%d\n", i); return 0; }
the_stack_data/179832193.c
/* ** EPITECH PROJECT, 2017 ** my str is alpha ** File description: ** test if str is only alpha or not */ int my_str_isalpha(char const *str) { int i = 0; char *strtest; if (strtest == str) return (1); while (str[i] != '\0') { if ((str[i] > 'z') || (str[i] < 'a') && (str[i] > 'Z')) return (0); if (str[i] < 65) return (0); i++; } return (1); }