file
stringlengths
18
26
data
stringlengths
4
1.03M
the_stack_data/235293.c
/*- * Copyright (c) 1990, 1993 * The Regents of the University of California. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software * must display the following acknowledgement: * This product includes software developed by the University of * California, Berkeley and its contributors. * 4. Neither the name of the University 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 REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #if defined(LIBC_SCCS) && !defined(lint) static char rcsid[] = "$OpenBSD: ctermid.c,v 1.2 1996/08/19 08:22:03 tholo Exp $"; #endif /* LIBC_SCCS and not lint */ #include <stdio.h> #include <paths.h> #include <string.h> char * ctermid(s) char *s; { static char def[] = _PATH_TTY; if (s) { bcopy(def, s, sizeof(_PATH_TTY)); return(s); } return(def); }
the_stack_data/132952901.c
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> char **parse_args(char *line) { char **mem = calloc(sizeof(char **), 5); char *pline = line; char *s, count; for(; s = strsep(&pline, " "); mem[count++] = s); return mem; } int main() { char *inp; printf("please input your function and its arguments:\n"); scanf("%[^\n]%*c", inp); char **strmem = parse_args(inp); for(int i = 0; i < 5 && strmem[i]; i++) printf("Argument number %d: %s\n", i, strmem[i]); execvp(strmem[0], strmem); return 0; }
the_stack_data/1125423.c
#include <stdio.h> #include <stdlib.h> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include <pthread.h> //for threading #include <string.h> int sockfd; int clients = 0; typedef struct { int socket; } requestDataStruct; //the thread function void *connection_handler(void *); void close_sock(int sockfd) { printf("Server is closing\r\n"); while (clients !=0){ printf("Closing clients\r\n"); sleep(1); } printf("Server is closing\n"); shutdown(sockfd, SHUT_RDWR); close(sockfd); } void thread_close(int newsockfd){ printf("Thread closing\r\n"); shutdown(newsockfd, SHUT_RDWR); close(newsockfd); clients--; pthread_exit(NULL); } void thread_request(int socket){ requestDataStruct rds; pthread_t theThread; int status; rds.socket = socket; status = pthread_create(&theThread, NULL, connection_handler, (void*) &rds); if (status != 0) { printf("Can't create a thread with status: %d\n", status); exit(1); } } void *thread_control(void *args) { char n; do { n = getchar(); } while (n != 'q'); printf("Exiting...\n"); shutdown(sockfd, 2); close(sockfd); return 0; } int main(int argc, char *argv[]) { int sockfd, newsockfd, *new_sock; uint16_t portno; unsigned int clilen; char buffer[256]; struct sockaddr_in serv_addr, cli_addr; ssize_t n; int status; pthread_t controling; /* First call to socket() function */ sockfd = socket(AF_INET, SOCK_STREAM, 0); if (sockfd < 0) { perror("ERROR opening socket"); close_sock(sockfd); exit(1); } /* Initialize socket structure */ bzero((char *) &serv_addr, sizeof(serv_addr)); portno = 5001; serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = INADDR_ANY; serv_addr.sin_port = htons(portno); /* Now bind the host address using bind() call.*/ if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) { perror("ERROR on binding"); exit(1); } status = pthread_create(&controling, NULL, thread_control, NULL); if (status != 0) { printf("Cant create a control thread. Status: %d\n", status); exit(1); } /* Now start listening for the clients, here process will * go in sleep mode and will wait for the incoming connection */ listen(sockfd, 5); clilen = sizeof(cli_addr); while(1) { /* Accept actual connection from the client */ newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); if (newsockfd < 0) { perror("ERROR on accept"); close_sock(sockfd); exit(1); } thread_request(newsockfd); } /* If connection is established then start communicating bzero(buffer, 256); n = read(newsockfd, buffer, 255); // recv on Windows if (n < 0) { perror("ERROR reading from socket"); exit(1); } printf("Here is the message: %s\n", buffer); /* Write a response to the client n = write(newsockfd, "I got your message", 18); // send on Windows if (n < 0) { perror("ERROR writing to socket"); exit(1); } */ close_sock(sockfd); return 0; } void *connection_handler(void *sockfd) { //Get the socket descriptor int sock = *(int*)sockfd; int size; char buffer[256]; clients++; //Receive a message from client while( (size = read(sock , buffer , 256 )) > 0 ) { //Send the message back to client write(sock , buffer , strlen(buffer)); printf("%s\n",buffer); } if(size == 0) { puts("Client disconnected"); fflush(stdout); } else if(size == -1) { perror("Fail read"); } thread_close(sock); return 0; }
the_stack_data/94043.c
__thread int tls; int main(int argc, char** argv) { return 0; }
the_stack_data/218894499.c
#include <stdio.h> #include <stdlib.h> int main() { char action; int units; char directions[4] = {'N', 'E', 'S', 'W'}; int x = 0; // east/west moves int y = 0; // north/south moves int dir = 1; // start facing east while (scanf("%c%d\n", &action ,&units) == 2) { if (action == 'F') action = directions[dir]; switch(action) { case 'N': y -= units; break; case 'S': y += units; break; case 'E': x += units; break; case 'W': x -= units; break; case 'L': dir = (dir + 4 - units / 90) % 4; break; case 'R': dir = (dir + units / 90) % 4; break; default: fprintf(stderr, "something broke!\n"); exit(1); } } int total = abs(x)+abs(y); printf("part 1: %d\n", total); return 0; }
the_stack_data/220454662.c
// Copyright (c) 2015 RV-Match Team. All Rights Reserved. static int a = 1; int main () { extern int a; }
the_stack_data/161081401.c
#include <stdio.h> int main() { unsigned n; while (scanf("%u", &n)) { if (n == 0) break; switch (n) { case 561: case 1105: case 1729: case 2465: case 2821: case 6601: case 8911: case 10585: case 15841: case 29341: case 41041: case 46657: case 52633: case 62745: case 63973: printf("The number %u is a Carmichael number.\n", n); break; default: printf("%u is normal.\n", n); } } return 0; }
the_stack_data/156393249.c
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<omp.h> #define NUM_THREADS 4 int occ[256]; int* lastocc(char str[]) { int i; char a; for(i=0;i<128;i++) occ[i]=-1; int len=strlen(str); for(i=0;i<len-1;i++) { a=str[i]; occ[a]=i; } return occ; } void bmh(char *t,int start,int end,char *p) { int *locc; int i0,j,m,n; n=end-start+1; m=strlen(p); locc=lastocc(p); i0=start; while(i0<=end-m+1) { j=m-1; while(j>=0 && p[j]==t[i0+j]) j--; if(j<0) printf("Pattern found at %d\n",i0); i0+=m-1; i0-=locc[t[i0]]; } } int main() { char pat[10]; char *text; int n,m,i=0; size_t size = 0; /* Open your_file in read-only mode */ FILE *fp = fopen("gene.txt", "r"); /* Get the buffer size */ fseek(fp, 0, SEEK_END); /* Go to end of file */ size = ftell(fp); /* How many bytes did we pass ? */ /* Set position of stream to the beginning */ rewind(fp); /* Allocate the buffer (no need to initialize it with calloc) */ text = malloc((size + 1) * sizeof(*text)); /* size + 1 byte for the \0 */ /* Read the file into the buffer */ fread(text, size, 1, fp); /* Read 1 chunk of size bytes from fp into buffer */ /* NULL-terminate the buffer */ text[size] = '\0'; scanf("%s",pat); int lenp=strlen(pat); printf("Length of pattern: %d\n",lenp); printf("Length of pattern: %d\n",strlen(text)); int bs=strlen(text)/NUM_THREADS; int rem=strlen(text)%NUM_THREADS; printf("bs: %d rem: %d\n",bs,rem); printf("num of threads %d\n",NUM_THREADS); int tid,start,end; #pragma omp parallel num_threads(NUM_THREADS) private(tid,start,end) shared(text,pat,rem,bs,m) { tid=omp_get_thread_num(); printf("tid %d\n",tid); if(tid==0) { #pragma omp critical (part1) { start=tid; end=bs-1; printf("start: %d end: %d\n",start,end); printf("tid= %d text block : %d ... %d\n",tid,start,end); bmh(text,start,end,pat); } } else { #pragma omp critical (part2) { start=(tid*bs)-lenp; end=(tid*bs)+bs-1; printf("start: %d end: %d\n",start,end); printf("tid= %d text block : %d ... %d\n",tid,start,end); bmh(text,start,end,pat); } } } if(rem!=0) bmh(text,(NUM_THREADS+1)*bs,strlen(text),pat); return 0; }
the_stack_data/1222888.c
// essfunc.dll for Vulnserver // Visit my blog for more details: http://www.thegreycorner.com/ /* Copyright (c) 2010, Stephen Bradshaw All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <string.h> #define VERSION "1.00" void EssentialFunc1() { printf ("Called essential function dll version %s\n", VERSION); } void EssentialFunc2() { __asm__("jmp *%esp\n\t" "jmp *%eax\n\t" "pop %eax\n\t" "pop %eax\n\t" "ret"); } void EssentialFunc3() { __asm__("jmp *%esp\n\t" "jmp *%ecx\n\t" "pop %ebx\n\t" "pop %ebx\n\t" "ret"); } void EssentialFunc4() { __asm__("jmp *%esp\n\t" "jmp *%ebx\n\t" "pop %ebp\n\t" "pop %ebp\n\t" "ret"); } void EssentialFunc5() { __asm__("jmp *%esp\n\t" "jmp *%edi\n\t" "pop %ebx\n\t" "pop %ebx\n\t" "ret"); } void EssentialFunc6() { __asm__("jmp *%esp\n\t" "jmp *%edx\n\t" "pop %ecx\n\t" "pop %edx\n\t" "ret"); } void EssentialFunc7() { __asm__("jmp *%esp\n\t" "jmp *%esi\n\t" "pop %ecx\n\t" "pop %eax\n\t" "ret"); } void EssentialFunc8() { __asm__("jmp *%esp\n\t" "jmp *%ebp\n\t" "pop %eax\n\t" "pop %edx\n\t" "ret"); } void EssentialFunc9() { __asm__("jmp *%esp\n\t" "jmp *%esp\n\t" "jmp *-12(%esp)\n\t" "pop %ecx\n\t" "pop %ecx\n\t" "ret"); } void EssentialFunc10(char *Input) { char Buffer2S[140]; strcpy(Buffer2S, Input); } void EssentialFunc11(char *Input) { char Buffer2S[60]; strcpy(Buffer2S, Input); } void EssentialFunc12(char *Status, char *Input) { char Buffer2S[2000]; strcpy(Buffer2S, Input); printf("%s", Status); } void EssentialFunc13(char *Input) { char Buffer2S[2000]; strcpy(Buffer2S, Input); } void EssentialFunc14(char *Input) { char Buffer2S[1000]; strcpy(Buffer2S, Input); }
the_stack_data/72013206.c
/* <TAGS>filter dt.matrix</TAGS> DESCRIPTION: Downsize an input array representing a 2D matrix to a new width and heght Alters the input array NAN and INF values will be ignored This function has no memory overhead USES: - resampling an image or matrix to reduce resolution - modifying different matrices so they are all the same size DEPENDENCY TREE: No dependencies ARGUMENTS: double *matrix1 : input array long nx1 : width of input long ny1 : height of input long nx2 : desired width long ny2 : desired height char *message : array to hold error message RETURN VALUE: 0 on sucess, -1 on error SAMPLE CALL: */ #include <stdio.h> #include <stdlib.h> #include <math.h> int xf_matrixbin1_d(double *matrix1, long nx1, long ny1, long nx2, long ny2, char *message) { char *thisfunc="xf_matrixbin1_d\0"; long ii,jj,kk,x1,x2,y1,y2,nsums,xmax,ymax; double xbinsize,ybinsize,limit,sum; if(nx2>nx1) { sprintf(message,"%s [ERROR]: nx1 (%ld) must be >= nx2 (%ld)",thisfunc,nx1,nx2); return(1); } if(ny2>ny1) { sprintf(message,"%s [ERROR]: ny1 (%ld) must be >= ny2 (%ld)",thisfunc,ny1,ny2); return(1); } if(nx2==nx1 && ny2==ny1) { sprintf(message,"%s [Warning]: input and output matrices are the same size (no changes made)",thisfunc,ny1,ny2); return(0); } xmax=nx1-1; ymax=ny1-1; xbinsize=(double)(nx1)/(double)nx2; ybinsize=(double)ny1/(double)ny2; /* RESAMPLE EACH ROW */ if(nx2<nx1) { for(y1=0;y1<ny1;y1++) { /* set index jj to the beginning of current row, for reading the input */ /* kk is the initial pointer to the destination, which will be incremented */ jj=kk=y1*nx1; /* set initial limit for binning and initialize sum and nsums */ limit=xbinsize; sum=0.0; nsums=0; /* for each column, build the sum - calculate the mean if limit is exceeded */ for(x1=0;x1<nx1;x1++) { if(x1>=limit) { if(nsums>0) matrix1[kk]= sum/nsums; else matrix1[kk]=NAN; sum=0; nsums=0; limit+= xbinsize; kk++; } if(isfinite(matrix1[jj+x1])) { sum+= matrix1[jj+x1]; nsums++; } } /* process the last sample */ if(nsums>0) matrix1[kk]= sum/nsums; else matrix1[kk]=NAN; } //TEST: for(y1=0;y1<ny1;y1++) {for(x1=0;x1<nx1;x1++) printf("%.3f\t",matrix1[y1*nx1+x1]);printf("\n");} exit(0); } /* RESAMPLE EACH COLUMN - use the new range of columns */ if(ny2<ny1) { for(x1=0;x1<nx2;x1++) { /* set initial index to destination: this will be incremented by nx1 */ kk=x1; /* set initial limit for binning and initialize sum and nsums */ limit=ybinsize; sum=0.0; nsums=0; /* for each row, build the sum - calculate the mean if limit is exceeded */ for(y1=0;y1<ny1;y1++) { /* set jj to index for input */ jj=y1*nx1+x1; if(y1>=limit) { if(nsums>0) matrix1[kk]= sum/nsums; else matrix1[kk]=NAN; sum=0; nsums=0; limit+= ybinsize; kk+=nx1; } if(isfinite(matrix1[jj])) { sum+= matrix1[jj]; nsums++; } } /* process the last sample */ if(nsums>0) matrix1[kk]= sum/nsums; else matrix1[kk]=NAN; } //TEST: for(y1=0;y1<ny1;y1++) {for(x1=0;x1<nx1;x1++) printf("%.3f\t",matrix1[y1*nx1+x1]);printf("\n");} exit(0); } /* COMPRESS MATRIX */ kk=0; for(y2=0;y2<ny2;y2++){ jj=y2*nx1; for(x2=0;x2<nx2;x2++) { matrix1[kk++]=matrix1[jj+x2]; } } /* RETURN THE ERROR CODE */ return(0); }
the_stack_data/34817.c
int test357() {return 0;} //nfsjdgkssfdvc
the_stack_data/68886551.c
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1996, 2017 Oracle and/or its affiliates. All rights reserved. */ #include <sys/types.h> #include <ctype.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> typedef struct { char *name; /* API name */ u_int used_mask; /* Bits used. */ } API; API **api_list, **api_end; typedef struct { char *name; /* Flag name */ int api_cnt; /* APIs that use this flag. */ API **api, **api_end; u_int value; /* Bit value */ } FLAG; FLAG **flag_list, **flag_end; int verbose; char *progname; int add_entry(char *, char *); void define_print(char *, u_int); void dump_api(void); void dump_flags(void); int flag_cmp_alpha(const void *, const void *); int flag_cmp_api_cnt(const void *, const void *); int generate_flags(void); int parse(void); void print_api_mask(void); void print_api_remainder(void); void print_flag_value(void); int syserr(void); int usage(void); int main(int argc, char *argv[]) { enum { API_MASK, API_REMAINDER, FLAG_VALUE } output; int ch; if ((progname = strrchr(argv[0], '/')) == NULL) progname = argv[0]; else ++progname; output = FLAG_VALUE; while ((ch = getopt(argc, argv, "mrv")) != EOF) switch (ch) { case 'm': output = API_MASK; break; case 'r': output = API_REMAINDER; break; case 'v': verbose = 1; break; case '?': default: return (usage()); } argc -= optind; argv += optind; if (parse() || generate_flags()) return (EXIT_FAILURE); switch (output) { case API_MASK: print_api_mask(); break; case API_REMAINDER: print_api_remainder(); break; case FLAG_VALUE: print_flag_value(); break; } if (verbose) { dump_api(); dump_flags(); } return (EXIT_SUCCESS); } int parse() { int lc; char *p, *api, buf[256]; api = NULL; /* * Read the method name/flag pairs. */ for (lc = 1; fgets(buf, sizeof(buf), stdin) != NULL; ++lc) { if ((p = strchr(buf, '\n')) != NULL) *p = '\0'; else { fprintf( stderr, "%s: %d: line too long\n", progname, lc); return (1); } /* Ignore any empty line or hash mark. */ if (buf[0] == '\0' || buf[0] == '#') continue; /* * A line without leading whitespace is an API name, a line * with leading whitespace is a flag name. */ if (isspace(buf[0])) { if ((p = strtok(buf, " \t")) == NULL || *p == '#') continue; /* A flag without an API makes no sense. */ if (api == NULL) goto format; /* Enter the pair into the array. */ if (add_entry(api, p)) return (1); } else { if ((p = strtok(buf, " \t")) == NULL) continue; if (api != NULL) free(api); if ((api = strdup(p)) == NULL) return (syserr()); } if ((p = strtok(NULL, " \t")) != NULL && *p != '#') goto format; } return (0); format: fprintf(stderr, "%s: format error: line %d\n", progname, lc); return (1); } int add_entry(char *api_name, char *flag_name) { FLAG **fpp, *fp; API **app, *ap, **p; u_int cnt; /* Search for this api's API structure. */ for (app = api_list; app != NULL && *app != NULL && app < api_end; ++app) if (strcmp(api_name, (*app)->name) == 0) break; /* Allocate new space in the API array if necessary. */ if (app == NULL || app == api_end) { cnt = app == NULL ? 100 : (u_int)(api_end - api_list) + 100; if ((api_list = realloc(api_list, sizeof(API *) * cnt)) == NULL) return (syserr()); api_end = api_list + cnt; app = api_list + (cnt - 100); memset(app, 0, (u_int)(api_end - app) * sizeof(API *)); } /* Allocate a new API structure and fill in the name if necessary. */ if (*app == NULL && ((*app = calloc(sizeof(API), 1)) == NULL || ((*app)->name = strdup(api_name)) == NULL)) return (syserr()); ap = *app; /* * There's a special keyword, "__MASK=<value>" that sets the initial * flags value for an API, and so prevents those flag bits from being * chosen for that API's flags. */ if (strncmp(flag_name, "__MASK=", sizeof("__MASK=") - 1) == 0) { ap->used_mask |= strtoul(flag_name + sizeof("__MASK=") - 1, NULL, 0); return (0); } /* Search for this flag's FLAG structure. */ for (fpp = flag_list; fpp != NULL && *fpp != NULL && fpp < flag_end; ++fpp) if (strcmp(flag_name, (*fpp)->name) == 0) break; /* Realloc space in the FLAG array if necessary. */ if (fpp == NULL || fpp == flag_end) { cnt = fpp == NULL ? 100 : (u_int)(flag_end - flag_list) + 100; if ((flag_list = realloc(flag_list, sizeof(FLAG *) * cnt)) == NULL) return (syserr()); flag_end = flag_list + cnt; fpp = flag_list + (cnt - 100); memset(fpp, 0, (u_int)(flag_end - fpp) * sizeof(FLAG *)); } /* Allocate a new FLAG structure and fill in the name if necessary. */ if (*fpp == NULL && ((*fpp = calloc(sizeof(FLAG), 1)) == NULL || ((*fpp)->name = strdup(flag_name)) == NULL)) return (syserr()); fp = *fpp; ++fp->api_cnt; /* Check to see if this API is already listed for this flag. */ for (p = fp->api; p != NULL && *p != NULL && p < fp->api_end; ++p) if (strcmp(api_name, (*p)->name) == 0) { fprintf(stderr, "duplicate entry: %s / %s\n", api_name, flag_name); return (1); } /* Realloc space in the FLAG's API array if necessary. */ if (p == NULL || p == fp->api_end) { cnt = p == NULL ? 20 : (u_int)(fp->api_end - fp->api) + 20; if ((fp->api = realloc(fp->api, sizeof(API *) * cnt)) == NULL) return (syserr()); fp->api_end = fp->api + cnt; p = fp->api + (cnt - 20); memset(p, 0, (u_int)(fp->api_end - fp->api) * sizeof(API *)); } *p = ap; return (0); } void dump_api() { API **app; printf("=============================\nAPI:\n"); for (app = api_list; *app != NULL; ++app) printf("%s (%#x)\n", (*app)->name, (*app)->used_mask); } void dump_flags() { FLAG **fpp; API **api; char *sep; printf("=============================\nFLAGS:\n"); for (fpp = flag_list; *fpp != NULL; ++fpp) { printf("%s (%#x, %d): ", (*fpp)->name, (*fpp)->value, (*fpp)->api_cnt); sep = ""; for (api = (*fpp)->api; *api != NULL; ++api) { printf("%s%s", sep, (*api)->name); sep = ", "; } printf("\n"); } } int flag_cmp_api_cnt(const void *a, const void *b) { FLAG *af, *bf; af = *(FLAG **)a; bf = *(FLAG **)b; if (af == NULL) { if (bf == NULL) return (0); return (1); } if (bf == NULL) { if (af == NULL) return (0); return (-1); } if (af->api_cnt > bf->api_cnt) return (-1); if (af->api_cnt < bf->api_cnt) return (1); return (strcmp(af->name, bf->name)); } int generate_flags() { FLAG **fpp; API **api; u_int mask; /* Sort the FLAGS array by reference count, in reverse order. */ qsort(flag_list, (u_int)(flag_end - flag_list), sizeof(FLAG *), flag_cmp_api_cnt); /* * Here's the plan: walk the list of flags, allocating bits. For * each flag, we walk the list of APIs that use it and find a bit * none of them are using. That bit becomes the flag's value. */ for (fpp = flag_list; *fpp != NULL; ++fpp) { mask = 0xffffffff; /* Set to all 1's */ for (api = (*fpp)->api; *api != NULL; ++api) mask &= ~(*api)->used_mask; /* Clear API's bits */ if (mask == 0) { fprintf(stderr, "%s: ran out of bits at flag %s\n", progname, (*fpp)->name); return (1); } (*fpp)->value = mask = 1 << (ffs(mask) - 1); for (api = (*fpp)->api; *api != NULL; ++api) (*api)->used_mask |= mask; /* Set bit for API */ } return (0); } int flag_cmp_alpha(const void *a, const void *b) { FLAG *af, *bf; af = *(FLAG **)a; bf = *(FLAG **)b; if (af == NULL) { if (bf == NULL) return (0); return (1); } if (bf == NULL) { if (af == NULL) return (0); return (-1); } return (strcmp(af->name, bf->name)); } void print_api_mask() { API **app; char *p, buf[256]; /* Output a mask for the API. */ for (app = api_list; *app != NULL; ++app) { (void)snprintf( buf, sizeof(buf), "_%s_API_MASK", (*app)->name); for (p = buf; *p != '\0'; ++p) if (islower(*p)) *p = toupper(*p); else if (!isalpha(*p)) *p = '_'; define_print(buf, (*app)->used_mask); } } void print_api_remainder() { API **app; int unused, i; /* Output the bits remaining for the API. */ for (app = api_list; *app != NULL; ++app) { for (i = unused = 0; i < 32; ++i) if (!((*app)->used_mask & (1 << i))) ++unused; printf("%s: %d bits unused\n", (*app)->name, unused); } } void print_flag_value() { FLAG **fpp; /* Sort the FLAGS array in alphabetical order. */ qsort(flag_list, (u_int)(flag_end - flag_list), sizeof(FLAG *), flag_cmp_alpha); /* Output each flag's value. */ for (fpp = flag_list; *fpp != NULL; ++fpp) define_print((*fpp)->name, (*fpp)->value); } void define_print(char *name, u_int value) { char *sep; switch (strlen(name) / 8) { case 0: sep = "\t\t\t\t\t"; break; case 1: sep = "\t\t\t\t"; break; case 2: sep = "\t\t\t"; break; case 3: sep = "\t\t"; break; default: sep = "\t"; break; } printf("#define\t%s%s%#010x\n", name, sep, value); // DB_LOG_BLOB is an alias for DB_LOG_EXT_FILE if (strcmp("DB_LOG_EXT_FILE", name) == 0) printf("#define\t%s%s%#010x\n", "DB_LOG_BLOB", sep, value); } int syserr(void) { fprintf(stderr, "%s: %s\n", progname, strerror(errno)); return (1); } int usage() { (void)fprintf(stderr, "usage: %s [-mrv]\n", progname); return (EXIT_FAILURE); }
the_stack_data/193894459.c
// RUN: %clang_cc1 -fsyntax-only -fopenmp -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized // RUN: %clang_cc1 -fsyntax-only -fopenmp -verify=expected,omp50 %s -Wuninitialized // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -fopenmp-version=45 -verify=expected,omp45 %s -Wuninitialized // RUN: %clang_cc1 -fsyntax-only -fopenmp-simd -verify=expected,omp50 %s -Wuninitialized // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel for simd'}} #pragma omp parallel for simd // expected-error@+1 {{unexpected OpenMP directive '#pragma omp parallel for simd'}} #pragma omp parallel for simd foo void test_no_clause() { int i; #pragma omp parallel for simd for (i = 0; i < 16; ++i) ; // expected-error@+2 {{statement after '#pragma omp parallel for simd' must be a for loop}} #pragma omp parallel for simd ++i; } void test_branch_protected_scope() { int i = 0; L1: ++i; int x[24]; #pragma omp parallel #pragma omp parallel for simd for (i = 0; i < 16; ++i) { if (i == 5) goto L1; // expected-error {{use of undeclared label 'L1'}} else if (i == 6) return; // expected-error {{cannot return from OpenMP region}} else if (i == 7) goto L2; else if (i == 8) { L2: x[i]++; } } if (x[0] == 0) goto L2; // expected-error {{use of undeclared label 'L2'}} else if (x[1] == 1) goto L1; } void test_invalid_clause() { int i; #pragma omp parallel // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} #pragma omp parallel for simd foo bar for (i = 0; i < 16; ++i) ; } void test_non_identifiers() { int i, x; #pragma omp parallel // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} #pragma omp parallel for simd; for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} #pragma omp parallel for simd linear(x); for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} #pragma omp parallel for simd private(x); for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-warning@+1 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} #pragma omp parallel for simd, private(x); for (i = 0; i < 16; ++i) ; } extern int foo(); void test_safelen() { int i; // expected-error@+1 {{expected '('}} #pragma omp parallel for simd safelen for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen( for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd safelen() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(, for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(, ) for (i = 0; i < 16; ++i) ; // expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} // expected-error@+1 {{expected '('}} #pragma omp parallel for simd safelen 4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(4 for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(4, for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(4, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd safelen(4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(4 4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(4, , 4) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd safelen(4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd safelen(4, 8) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{integer constant expression}} #pragma omp parallel for simd safelen(2.5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{integer constant expression}} #pragma omp parallel for simd safelen(foo()) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} #pragma omp parallel for simd safelen(-5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} #pragma omp parallel for simd safelen(0) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'safelen' clause must be a strictly positive integer value}} #pragma omp parallel for simd safelen(5 - 5) for (i = 0; i < 16; ++i) ; } void test_simdlen() { int i; // expected-error@+1 {{expected '('}} #pragma omp parallel for simd simdlen for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen( for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd simdlen() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(, for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(, ) for (i = 0; i < 16; ++i) ; // expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} // expected-error@+1 {{expected '('}} #pragma omp parallel for simd simdlen 4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(4 for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(4, for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(4, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd simdlen(4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(4 4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(4, , 4) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd simdlen(4) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} #pragma omp parallel for simd simdlen(4, 8) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{integer constant expression}} #pragma omp parallel for simd simdlen(2.5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{integer constant expression}} #pragma omp parallel for simd simdlen(foo()) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} #pragma omp parallel for simd simdlen(-5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} #pragma omp parallel for simd simdlen(0) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument to 'simdlen' clause must be a strictly positive integer value}} #pragma omp parallel for simd simdlen(5 - 5) for (i = 0; i < 16; ++i) ; } void test_safelen_simdlen() { int i; // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} #pragma omp parallel for simd simdlen(6) safelen(5) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{the value of 'simdlen' parameter must be less than or equal to the value of the 'safelen' parameter}} #pragma omp parallel for simd safelen(5) simdlen(6) for (i = 0; i < 16; ++i) ; } void test_collapse() { int i; #pragma omp parallel // expected-error@+1 {{expected '('}} #pragma omp parallel for simd collapse for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd collapse( for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd collapse() for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd collapse(, for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd collapse(, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-warning@+2 {{extra tokens at the end of '#pragma omp parallel for simd' are ignored}} // expected-error@+1 {{expected '('}} #pragma omp parallel for simd collapse 4) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4 for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4, for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4, ) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel // expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4 4) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4, , 4) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel #pragma omp parallel for simd collapse(4) for (int i1 = 0; i1 < 16; ++i1) for (int i2 = 0; i2 < 16; ++i2) for (int i3 = 0; i3 < 16; ++i3) for (int i4 = 0; i4 < 16; ++i4) foo(); #pragma omp parallel // expected-error@+2 {{expected ')'}} // expected-note@+1 {{to match this '('}} expected-note@+1 {{as specified in 'collapse' clause}} #pragma omp parallel for simd collapse(4, 8) for (i = 0; i < 16; ++i) ; // expected-error {{expected 4 for loops after '#pragma omp parallel for simd', but found only 1}} #pragma omp parallel // expected-error@+1 {{integer constant expression}} #pragma omp parallel for simd collapse(2.5) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{integer constant expression}} #pragma omp parallel for simd collapse(foo()) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp parallel for simd collapse(-5) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp parallel for simd collapse(0) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{argument to 'collapse' clause must be a strictly positive integer value}} #pragma omp parallel for simd collapse(5 - 5) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd collapse(2) for (i = 0; i < 16; ++i) for (int j = 0; j < 16; ++j) // expected-error@+1 {{OpenMP constructs may not be nested inside a simd region}} #pragma omp parallel for simd reduction(+ : i, j) for (int k = 0; k < 16; ++k) i += j; } void test_linear() { int i; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd linear( for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected expression}} // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd linear(, for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected expression}} // expected-error@+1 {{expected expression}} #pragma omp parallel for simd linear(, ) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd linear() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd linear(int) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected variable name}} #pragma omp parallel for simd linear(0) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{use of undeclared identifier 'x'}} #pragma omp parallel for simd linear(x) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{use of undeclared identifier 'x'}} // expected-error@+1 {{use of undeclared identifier 'y'}} #pragma omp parallel for simd linear(x, y) for (i = 0; i < 16; ++i) ; // expected-error@+3 {{use of undeclared identifier 'x'}} // expected-error@+2 {{use of undeclared identifier 'y'}} // expected-error@+1 {{use of undeclared identifier 'z'}} #pragma omp parallel for simd linear(x, y, z) for (i = 0; i < 16; ++i) ; int x, y; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd linear(x :) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd linear(x :, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd linear(x : 1) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd linear(x : 2 * 2) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd linear(x : 1, y) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd linear(x : 1, y, z : 1) for (i = 0; i < 16; ++i) ; // expected-note@+2 {{defined as linear}} // expected-error@+1 {{linear variable cannot be linear}} #pragma omp parallel for simd linear(x) linear(x) for (i = 0; i < 16; ++i) ; // expected-note@+2 {{defined as private}} // expected-error@+1 {{private variable cannot be linear}} #pragma omp parallel for simd private(x) linear(x) for (i = 0; i < 16; ++i) ; // expected-note@+2 {{defined as linear}} // expected-error@+1 {{linear variable cannot be private}} #pragma omp parallel for simd linear(x) private(x) for (i = 0; i < 16; ++i) ; // expected-warning@+1 {{zero linear step (x and other variables in clause should probably be const)}} #pragma omp parallel for simd linear(x, y : 0) for (i = 0; i < 16; ++i) ; // expected-note@+2 {{defined as linear}} // expected-error@+1 {{linear variable cannot be lastprivate}} #pragma omp parallel for simd linear(x) lastprivate(x) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-note@+2 {{defined as lastprivate}} // expected-error@+1 {{lastprivate variable cannot be linear}} #pragma omp parallel for simd lastprivate(x) linear(x) for (i = 0; i < 16; ++i) ; } void test_aligned() { int i; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd aligned( for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected expression}} // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd aligned(, for (i = 0; i < 16; ++i) ; // expected-error@+2 {{expected expression}} // expected-error@+1 {{expected expression}} #pragma omp parallel for simd aligned(, ) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd aligned() for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd aligned(int) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected variable name}} #pragma omp parallel for simd aligned(0) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{use of undeclared identifier 'x'}} #pragma omp parallel for simd aligned(x) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{use of undeclared identifier 'x'}} // expected-error@+1 {{use of undeclared identifier 'y'}} #pragma omp parallel for simd aligned(x, y) for (i = 0; i < 16; ++i) ; // expected-error@+3 {{use of undeclared identifier 'x'}} // expected-error@+2 {{use of undeclared identifier 'y'}} // expected-error@+1 {{use of undeclared identifier 'z'}} #pragma omp parallel for simd aligned(x, y, z) for (i = 0; i < 16; ++i) ; int *x, y, z[25]; // expected-note 4 {{'y' defined here}} #pragma omp parallel for simd aligned(x) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd aligned(z) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} #pragma omp parallel for simd aligned(x :) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd aligned(x :, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd aligned(x : 1) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd aligned(x : 2 * 2) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd aligned(x : 1, y) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd aligned(x : 1, y, z : 1) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}} #pragma omp parallel for simd aligned(x, y) for (i = 0; i < 16; ++i) ; // expected-error@+1 {{argument of aligned clause should be array or pointer, not 'int'}} #pragma omp parallel for simd aligned(x, y, z) for (i = 0; i < 16; ++i) ; // expected-note@+2 {{defined as aligned}} // expected-error@+1 {{a variable cannot appear in more than one aligned clause}} #pragma omp parallel for simd aligned(x) aligned(z, x) for (i = 0; i < 16; ++i) ; // expected-note@+3 {{defined as aligned}} // expected-error@+2 {{a variable cannot appear in more than one aligned clause}} // expected-error@+1 2 {{argument of aligned clause should be array or pointer, not 'int'}} #pragma omp parallel for simd aligned(x, y, z) aligned(y, z) for (i = 0; i < 16; ++i) ; } void test_private() { int i; #pragma omp parallel // expected-error@+2 {{expected expression}} // expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd private( for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd private(, for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd private(, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd private() for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd private(int) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected variable name}} #pragma omp parallel for simd private(0) for (i = 0; i < 16; ++i) ; int x, y, z; #pragma omp parallel #pragma omp parallel for simd private(x) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd private(x, y) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd private(x, y, z) for (i = 0; i < 16; ++i) { x = y * i + z; } } void test_lastprivate() { int i; #pragma omp parallel // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 {{expected expression}} #pragma omp parallel for simd lastprivate( for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd lastprivate(, for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd lastprivate(, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd lastprivate() for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd lastprivate(int) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected variable name}} #pragma omp parallel for simd lastprivate(0) for (i = 0; i < 16; ++i) ; int x, y, z; #pragma omp parallel #pragma omp parallel for simd lastprivate(x) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd lastprivate(x, y) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd lastprivate(x, y, z) for (i = 0; i < 16; ++i) ; } void test_firstprivate() { int i; #pragma omp parallel // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 {{expected expression}} #pragma omp parallel for simd firstprivate( for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+2 {{expected ')'}} expected-note@+2 {{to match this '('}} // expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd firstprivate(, for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd firstprivate(, ) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd firstprivate() for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected expression}} #pragma omp parallel for simd firstprivate(int) for (i = 0; i < 16; ++i) ; #pragma omp parallel // expected-error@+1 {{expected variable name}} #pragma omp parallel for simd firstprivate(0) for (i = 0; i < 16; ++i) ; int x, y, z; #pragma omp parallel #pragma omp parallel for simd lastprivate(x) firstprivate(x) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd lastprivate(x, y) firstprivate(x, y) for (i = 0; i < 16; ++i) ; #pragma omp parallel #pragma omp parallel for simd lastprivate(x, y, z) firstprivate(x, y, z) for (i = 0; i < 16; ++i) ; } void test_loop_messages() { float a[100], b[100], c[100]; #pragma omp parallel // expected-error@+2 {{variable must be of integer or pointer type}} #pragma omp parallel for simd for (float fi = 0; fi < 10.0; fi++) { c[(int)fi] = a[(int)fi] + b[(int)fi]; } #pragma omp parallel // expected-error@+2 {{variable must be of integer or pointer type}} #pragma omp parallel for simd for (double fi = 0; fi < 10.0; fi++) { c[(int)fi] = a[(int)fi] + b[(int)fi]; } } void test_nontemporal() { int i; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd nontemporal( for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 2 {{expected expression}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd nontemporal(, for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 2 {{expected expression}} #pragma omp parallel for simd nontemporal(, ) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{expected expression}} #pragma omp parallel for simd nontemporal() for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{expected expression}} #pragma omp parallel for simd nontemporal(int) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} omp50-error@+1 {{expected variable name}} #pragma omp parallel for simd nontemporal(0) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'x'}} #pragma omp parallel for simd nontemporal(x) for (i = 0; i < 16; ++i) ; // expected-error@+2 {{use of undeclared identifier 'x'}} // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'y'}} #pragma omp parallel for simd nontemporal(x, y) for (i = 0; i < 16; ++i) ; // expected-error@+3 {{use of undeclared identifier 'x'}} // expected-error@+2 {{use of undeclared identifier 'y'}} // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{use of undeclared identifier 'z'}} #pragma omp parallel for simd nontemporal(x, y, z) for (i = 0; i < 16; ++i) ; int x, y; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} #pragma omp parallel for simd nontemporal(x :) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-error@+1 {{expected ')'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} #pragma omp parallel for simd nontemporal(x :, ) for (i = 0; i < 16; ++i) ; // omp50-note@+2 {{defined as nontemporal}} // omp45-error@+1 2 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} omp50-error@+1 {{a variable cannot appear in more than one nontemporal clause}} #pragma omp parallel for simd nontemporal(x) nontemporal(x) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} #pragma omp parallel for simd private(x) nontemporal(x) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} #pragma omp parallel for simd nontemporal(x) private(x) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} expected-note@+1 {{to match this '('}} expected-error@+1 {{expected ',' or ')' in 'nontemporal' clause}} expected-error@+1 {{expected ')'}} #pragma omp parallel for simd nontemporal(x, y : 0) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} #pragma omp parallel for simd nontemporal(x) lastprivate(x) for (i = 0; i < 16; ++i) ; // omp45-error@+1 {{unexpected OpenMP clause 'nontemporal' in directive '#pragma omp parallel for simd'}} #pragma omp parallel for simd lastprivate(x) nontemporal(x) for (i = 0; i < 16; ++i) ; #pragma omp parallel for simd order // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for simd'}} expected-error {{expected '(' after 'order'}} for (int i = 0; i < 10; ++i) ; #pragma omp parallel for simd order( // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} for (int i = 0; i < 10; ++i) ; #pragma omp parallel for simd order(none // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp50-error {{expected 'concurrent' in OpenMP clause 'order'}} for (int i = 0; i < 10; ++i) ; #pragma omp parallel for simd order(concurrent // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for simd'}} expected-error {{expected ')'}} expected-note {{to match this '('}} for (int i = 0; i < 10; ++i) ; #pragma omp parallel for simd order(concurrent) // omp45-error {{unexpected OpenMP clause 'order' in directive '#pragma omp parallel for simd'}} for (int i = 0; i < 10; ++i) ; }
the_stack_data/632925.c
#include <stdio.h> #include <string.h> int rep(const char *p1, const char *p2){ int l, i, j, c=0; char *s1, *s2; if (strnlen(p1,50)>strnlen(p2,50)) l=strnlen(p2,50); else l=strnlen(p1,50); s1=malloc(l*sizeof(char)); s2=malloc(l*sizeof(char)); for (i=1; i<l && c==0 ; i++){ //strncpy(s1,p1+strnlen(p1,50)-l+i,50); for(j=0; j==0 || s1[j-1]!=0;j++){ s1[j]=p1[j+strnlen(p1,50)-l+i]; } strncpy(s2,p2,l-i); s2[l-i]=0; if (strcmp(s1,s2)==0) c=l-i; } free(s1); free(s2); return c; } void nu(int **mat, int n, int *max){ int i, j, u, a, b, m; for (i=0, m=0; i<n-1; i++){ for (j=0; j<n; j++){ for (u=0; u<n; u++){ if(mat[j][u]>m){ m=mat[j][u]; a=j; b=u; } } } for (j=0; j<n; j++){ mat[a][j]=0; mat[j][b]=0; } *max+=m; m=0; } return; } int main(){ int n, i, j, max, **mat; char **P; scanf("%d\n",&n); P=malloc(n*sizeof(char*)); for (i=0; i<n; i++) { P[i]=malloc(50*sizeof(char)); gets(P[i]); } mat=malloc(n*sizeof(int*)); for(i=0;i<n;i++) mat[i]=malloc(n*sizeof(int)); for(i=0;i<n;i++){ for(j=0;j<n;j++){ mat[i][j]=rep(P[i],P[j]); if(i==j) mat[i][j]=0; } } max=0; nu(mat,n,&max); max*=-1; for (i=0; i<n; i++) max+=strnlen(P[i],50); printf("%d\n",max); for (i=0; i<n; i++) free(P[i]); free(P); for (i=0; i<n; i++) free(mat[i]); free(mat); return 0; }
the_stack_data/4352.c
//Pamela M Nunes //IFSP-TADS #include <stdio.h> #include <stdlib.h> #include <unistd.h> //1) Desenvolva um programa que crie dois vetores A e B com 10 elementos. A partir deles crie um vetor C, que //receberá os elementos de A e B intercalados. void doisVetores(void) { //char a = 'a'; //char b = 'b'; int vetA[30]; //= {a,a,a,a,a,a,a,a,a,a}; int vetB[30]; //= {b,b,b,b,b,b,b,b,b,b}; int vetC[60]; int i = 0;// index = contador é a posição no vetor vetA[0] = "a" , vetA[1] = "b" while (i < 10) { printf("Insira um caractere para o Vetor A\n"); scanf(" %i", &vetA[i]); printf("Insira um caractere para o vetor B\n"); scanf(" %i", &vetB[i]); i++; } i = 0; int c = 0; int l = 0; for (int j = 0; j < 20; j++) { vetC[l] = vetA[i];// passando valor de A pra C l++; vetC[l] = vetB[c];//Passando valor de B pra C l++; i++; c++; } printf("Vetor C será impresso agora:\n"); for (int y = 0; y < 20; y++) { printf("%i,", vetC[y]); } printf("\n"); } //2) Elaborar um programa que leia 10 temperaturas em graus Farenheit, armazenando-as em um vetor. Em //seguida, transforme-as em graus Celsius e armazene os resultados em outro vetor. No final os dois vetores devem //ser apresentados lado a lado. A fórmula de conversão é C = 5/9 (F – 32). void farenheitToCeusius(void) { int farenheit[30]; int farenheitaux[30]; int ceusius[30]; int i = 0; while (i < 10) { printf("Qual a temperatura em Farenheit para armazenar?\n"); scanf(" %i", &farenheit[i]); i++; } //i = 0; for (int j = 0; j < 10; j++) { farenheitaux[j] = farenheit[j]; farenheit[j] = farenheit[j]-32; farenheit[j] = farenheit[j]/1.8; ceusius[j] = farenheit[j]; } printf("Temperatura em Farenheit:"); for (int j = 0; j < 10; j++) { printf("%i,", farenheitaux[j]); } printf("\n"); printf(" Temperatura em Ceusius:"); for (int j = 0; j < 10; j++) { printf("%i,", ceusius[j]); } printf("\n"); } //3) Crie um vetor para receber 10 notas de um aluno. Em seguida, devem ser exibidas as notas inseridas. Além //disso, deve ser calculada a média aritmética e exibido no final, o resultado: //Média >= 8 ➔ Plenamente Satisfatório (PS) //8 > Média >=6 ➔ Satisfatório (S) //6 > Média >= 4 ➔Regular (R) //Média < 4 ➔ Insatisfatório (I) void notasAlunos(void) { int notas[30]; int notasaux = 0; //int ceusius[30]; int i = 0; int countAlunos = 1; while (i < 10) { printf("Qual a nota do %i aluno para armazenar?\n", countAlunos); scanf(" %i", &notas[i]); notasaux = notasaux + notas[i]; countAlunos++; i++; } notasaux = notasaux /10; printf("Notas inseridas:"); for (int j = 0; j < 10; j++) { printf("%i,", notas[j]); } printf("\n"); printf("Resultado da Turma:%i\n", notasaux); if (notasaux >= 8) printf("Média >= 8 ➔ Plenamente Satisfatório (PS)\n"); else if (notasaux >= 6) printf("8 > Média >=6 ➔ Satisfatório (S)\n"); else if (notasaux >= 4) printf("6 > Média >= 4 ➔Regular (R)\n"); else printf("Média < 4 ➔ Insatisfatório (I)\n"); } //4) Crie uma matriz unidimensional A e uma B com 12 elementos cada. A deve aceitar apenas valores que sejam //divisíveis por 3 ou 7, enquanto B deve receber valores de A que não sejam múltiplos de 5 (as validações devem //ser feitas pelo programa e não pelo usuário). Crie uma matriz C com os elementos de A e B. No final devem ser //exibidas as três matrizes. void verificaVetores(void) { int aux[30]; int vetA[30]; int vetB[30]; int vetC[60]; int i = 0; int a = 0;//index dos vetor a int b = 0;//index dos vetor a while (i < 12) { printf("Insira um valor a ser inserido em um dos Vetores\n"); scanf(" %i", &aux[i]); i++; } aux[i] = '\0'; i = 0; while (aux[i] != '\0') { if ((aux[i] % 3 == 0) || (aux[i] % 7 == 0)) { vetA[a] = aux[i]; if (vetA[a]%5 != 0) { vetB[b]= vetA[a]; b++; } a++; } i++; } vetA[a] = '\0'; vetB[b] = '\0'; i = 0; printf("Matrix A:\n"); while (vetA[i] != '\0') { printf("%i,", vetA[i]); vetC[i] = vetA[i]; i++; } b = 0; printf("\n"); printf("Matrix B:\n"); while (vetB[b] != '\0') { printf("%i,", vetB[b]); vetC[i] = vetB[b]; i++; b++; } vetC[i] = '\0'; printf("\n"); printf("Matrix C:\n"); i = 0; while (vetC[i] != '\0') { printf("%i,", vetC[i]); i++; } printf("\n"); } //5) As Faculdades de Tecnologia Tabajara, desejam publicar o número de acertos de cada aluno em uma prova em //forma de testes. A prova consta de 10 questões, cada uma com cinco alternativas identificadas por A, B, C, D e E. //No final, devem ser mostrados os números dos alunos com as suas respectivas notas – cada acerto vale 1 ponto. //Dados de entrada necessários: //✓ o número de alunos da turma; //✓ o cartão de gabarito da prova; //✓ o cartão de respostas de cada aluno, contendo o seu número e suas respostas. void corection(void) { int nbrAlunos = 0; int indexalumni = 1; char gabarito[30]; int g = 0;// index gabarito char respostas[30]; int r = 0;// index respostas int alunos[30]; int pontos = 0; printf("Quantos alunos existem na sala?_\n"); scanf(" %i", &nbrAlunos); printf("Insira agora o gabarito da Prova\n"); int i = 0; while(i < 10)//pegar o gabarito da prova { printf("Questão %i\n", indexalumni); scanf(" %c", &gabarito[g]); g++; indexalumni++; i++; } indexalumni = 1; for (int i= 0; i < nbrAlunos; i++)//coletar os acertos dos alunos { printf("Insira as dados do aluno %i\n", i + 1); while (r < 10) { printf("Resposta nº:%i\n", r + 1); scanf(" %c", &respostas[r]); if (respostas[r] == gabarito[r])//confere resposta e atribui nota pontos++; r++; } alunos[i] = pontos; pontos = 0; r = 0; } for (int i= 0; i < nbrAlunos; i++)//imprime as notas dos alunos { printf("Aluno %i, Nota:%i\n", i + 1 , alunos[i]); } } int main() { //1 doisVetores(); //2 farenheitToCeusius(); //3 notasAlunos(); //4 verificaVetores(); //5 corection(); return(0); }
the_stack_data/42091.c
#ifdef HAVE_IO_U2F /* ******************************************************************************* * Portable FIDO U2F implementation * (c) 2016 Ledger * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ********************************************************************************/ #include <stdint.h> #include <string.h> #include "os.h" #include "os_io_seproxyhal.h" #include "cx.h" #include "u2f_service.h" #include "u2f_transport.h" #include "u2f_processing.h" #define INIT_U2F_VERSION 0x02 #define INIT_DEVICE_VERSION_MAJOR 0 #define INIT_DEVICE_VERSION_MINOR 1 #define INIT_BUILD_VERSION 0 #define INIT_CAPABILITIES 0x00 #define FIDO_CLA 0x00 #define FIDO_INS_ENROLL 0x01 #define FIDO_INS_SIGN 0x02 #define U2F_HANDLE_SIGN_HEADER_SIZE (32+32+1) #define FIDO_INS_GET_VERSION 0x03 #define FIDO_INS_PROP_GET_COUNTER 0xC0 // U2F_VENDOR_FIRST #define FIDO_INS_PROP_GET_INFO 0xC1 // grab the max message buffer size on 1 byte #define P1_SIGN_CHECK_ONLY 0x07 #define P1_SIGN_SIGN 0x03 #define U2F_ENROLL_RESERVED 0x05 #define SIGN_USER_PRESENCE_MASK 0x01 #define MAX_SEQ_TIMEOUT_MS 500 #define MAX_KEEPALIVE_TIMEOUT_MS 500 static const uint8_t SW_SUCCESS[] = {0x90, 0x00}; static const uint8_t SW_BUSY[] = {0x90, 0x01}; static const uint8_t SW_PROOF_OF_PRESENCE_REQUIRED[] = {0x69, 0x85}; static const uint8_t SW_BAD_KEY_HANDLE[] = {0x6A, 0x80}; static const uint8_t SW_INVALID_P1P2[] = {0x6B, 0x00}; static const uint8_t U2F_VERSION[] = {'U', '2', 'F', '_', 'V', '2', 0x90, 0x00}; static const uint8_t DUMMY_ZERO[] = {0x00}; static const uint8_t SW_UNKNOWN_INSTRUCTION[] = {0x6d, 0x00}; static const uint8_t SW_UNKNOWN_CLASS[] = {0x6e, 0x00}; static const uint8_t SW_WRONG_LENGTH[] = {0x67, 0x00}; static const uint8_t SW_INTERNAL[] = {0x6F, 0x00}; static const uint8_t NOTIFY_USER_PRESENCE_NEEDED[] = { KEEPALIVE_REASON_TUP_NEEDED}; static const uint8_t DUMMY_USER_PRESENCE[] = {SIGN_USER_PRESENCE_MASK}; // take into account max header (u2f usb) static const uint8_t INFO[] = {1 /*info format 1*/, (char)(IO_APDU_BUFFER_SIZE - U2F_HANDLE_SIGN_HEADER_SIZE - 3 - 4), 0x90, 0x00}; // proxy mode enroll issue an error void u2f_apdu_enroll(u2f_service_t *service, uint8_t p1, uint8_t p2, uint8_t *buffer, uint16_t length) { UNUSED(p1); UNUSED(p2); UNUSED(buffer); UNUSED(length); u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_INTERNAL, sizeof(SW_INTERNAL)); } void u2f_apdu_sign(u2f_service_t *service, uint8_t p1, uint8_t p2, uint8_t *buffer, uint16_t length) { UNUSED(p2); uint8_t keyHandleLength; uint8_t i; // can't process the apdu if another one is already scheduled in if (G_io_apdu_state != APDU_IDLE) { u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_BUSY, sizeof(SW_BUSY)); return; } if (length < U2F_HANDLE_SIGN_HEADER_SIZE + 5 /*at least an apdu header*/) { u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_WRONG_LENGTH, sizeof(SW_WRONG_LENGTH)); return; } // Confirm immediately if it's just a validation call if (p1 == P1_SIGN_CHECK_ONLY) { u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_PROOF_OF_PRESENCE_REQUIRED, sizeof(SW_PROOF_OF_PRESENCE_REQUIRED)); return; } // Unwrap magic keyHandleLength = buffer[U2F_HANDLE_SIGN_HEADER_SIZE-1]; // reply to the "get magic" question of the host if (keyHandleLength == 5) { // GET U2F PROXY PARAMETERS // this apdu is not subject to proxy magic masking // APDU is F1 D0 00 00 00 to get the magic proxy // RAPDU: <> if (os_memcmp(buffer+U2F_HANDLE_SIGN_HEADER_SIZE, "\xF1\xD0\x00\x00\x00", 5) == 0 ) { // U2F_PROXY_MAGIC is given as a 0 terminated string G_io_apdu_buffer[0] = sizeof(U2F_PROXY_MAGIC)-1; os_memmove(G_io_apdu_buffer+1, U2F_PROXY_MAGIC, sizeof(U2F_PROXY_MAGIC)-1); os_memmove(G_io_apdu_buffer+1+sizeof(U2F_PROXY_MAGIC)-1, "\x90\x00\x90\x00", 4); u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)G_io_apdu_buffer, G_io_apdu_buffer[0]+1+2+2); // processing finished. don't go further in the u2f msg processing return; } } for (i = 0; i < keyHandleLength; i++) { buffer[U2F_HANDLE_SIGN_HEADER_SIZE + i] ^= U2F_PROXY_MAGIC[i % (sizeof(U2F_PROXY_MAGIC)-1)]; } // Check that it looks like an APDU if (length != U2F_HANDLE_SIGN_HEADER_SIZE + 5 + buffer[U2F_HANDLE_SIGN_HEADER_SIZE + 4]) { u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_BAD_KEY_HANDLE, sizeof(SW_BAD_KEY_HANDLE)); return; } // make the apdu available to higher layers os_memmove(G_io_apdu_buffer, buffer + U2F_HANDLE_SIGN_HEADER_SIZE, keyHandleLength); G_io_apdu_length = keyHandleLength; G_io_apdu_media = IO_APDU_MEDIA_U2F; // the effective transport is managed by the U2F layer G_io_apdu_state = APDU_U2F; // don't reset the u2f processing command state, as we still await for the io_exchange caller to make the response call /* app_dispatch(); if ((btchip_context_D.io_flags & IO_ASYNCH_REPLY) == 0) { u2f_proxy_response(service, btchip_context_D.outLength); } */ } void u2f_apdu_get_version(u2f_service_t *service, uint8_t p1, uint8_t p2, uint8_t *buffer, uint16_t length) { // screen_printf("U2F version\n"); UNUSED(p1); UNUSED(p2); UNUSED(buffer); UNUSED(length); u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)U2F_VERSION, sizeof(U2F_VERSION)); } // Special command that returns the proxy void u2f_apdu_get_info(u2f_service_t *service, uint8_t p1, uint8_t p2, uint8_t *buffer, uint16_t length) { UNUSED(p1); UNUSED(p2); UNUSED(buffer); UNUSED(length); u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)INFO, sizeof(INFO)); } void u2f_handle_cmd_init(u2f_service_t *service, uint8_t *buffer, uint16_t length, uint8_t *channelInit) { // screen_printf("U2F init\n"); uint8_t channel[4]; (void)length; if (u2f_is_channel_broadcast(channelInit)) { cx_rng(channel, 4); } else { os_memmove(channel, channelInit, 4); } os_memmove(G_io_apdu_buffer, buffer, 8); os_memmove(G_io_apdu_buffer + 8, channel, 4); G_io_apdu_buffer[12] = INIT_U2F_VERSION; G_io_apdu_buffer[13] = INIT_DEVICE_VERSION_MAJOR; G_io_apdu_buffer[14] = INIT_DEVICE_VERSION_MINOR; G_io_apdu_buffer[15] = INIT_BUILD_VERSION; G_io_apdu_buffer[16] = INIT_CAPABILITIES; if (u2f_is_channel_broadcast(channelInit)) { os_memset(service->channel, 0xff, 4); } else { os_memmove(service->channel, channel, 4); } u2f_message_reply(service, U2F_CMD_INIT, G_io_apdu_buffer, 17); } void u2f_handle_cmd_ping(u2f_service_t *service, uint8_t *buffer, uint16_t length) { // screen_printf("U2F ping\n"); u2f_message_reply(service, U2F_CMD_PING, buffer, length); } void u2f_handle_cmd_msg(u2f_service_t *service, uint8_t *buffer, uint16_t length) { // screen_printf("U2F msg\n"); uint8_t cla = buffer[0]; uint8_t ins = buffer[1]; uint8_t p1 = buffer[2]; uint8_t p2 = buffer[3]; // in extended length buffer[4] must be 0 uint32_t dataLength = /*(buffer[4] << 16) |*/ (buffer[5] << 8) | (buffer[6]); if (dataLength == (uint16_t)(length - 9) || dataLength == (uint16_t)(length - 7)) { // Le is optional // nominal case from the specification } // circumvent google chrome extended length encoding done on the last byte only (module 256) but all data being transferred else if (dataLength == (uint16_t)(length - 9)%256) { dataLength = length - 9; } else if (dataLength == (uint16_t)(length - 7)%256) { dataLength = length - 7; } else { // invalid size u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_WRONG_LENGTH, sizeof(SW_WRONG_LENGTH)); return; } if (cla != FIDO_CLA) { u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_UNKNOWN_CLASS, sizeof(SW_UNKNOWN_CLASS)); return; } switch (ins) { case FIDO_INS_ENROLL: // screen_printf("enroll\n"); u2f_apdu_enroll(service, p1, p2, buffer + 7, dataLength); break; case FIDO_INS_SIGN: // screen_printf("sign\n"); u2f_apdu_sign(service, p1, p2, buffer + 7, dataLength); break; case FIDO_INS_GET_VERSION: // screen_printf("version\n"); u2f_apdu_get_version(service, p1, p2, buffer + 7, dataLength); break; // only support by case FIDO_INS_PROP_GET_INFO: u2f_apdu_get_info(service, p1, p2, buffer + 7, dataLength); break; default: // screen_printf("unsupported\n"); u2f_message_reply(service, U2F_CMD_MSG, (uint8_t *)SW_UNKNOWN_INSTRUCTION, sizeof(SW_UNKNOWN_INSTRUCTION)); return; } } void u2f_message_complete(u2f_service_t *service) { uint8_t cmd = service->transportBuffer[0]; uint16_t length = (service->transportBuffer[1] << 8) | (service->transportBuffer[2]); switch (cmd) { case U2F_CMD_INIT: u2f_handle_cmd_init(service, service->transportBuffer + 3, length, service->channel); break; case U2F_CMD_PING: u2f_handle_cmd_ping(service, service->transportBuffer + 3, length); break; case U2F_CMD_MSG: u2f_handle_cmd_msg(service, service->transportBuffer + 3, length); break; } } #endif
the_stack_data/84119.c
#include <stdlib.h> long long atoll(const char *s) { return(strtoll(s, (char **)0, 10)); }
the_stack_data/1135579.c
#include <stdio.h> #include <math.h> int main() { int t; scanf("%d", &t); while(t--) { int a, b, flag1 = 0, flag2 = 0; scanf("%d %d", &a, &b); int c = (int) sqrt(a); int d = (int) sqrt(b); if (c * c < a) { c++; flag1++; } if (d * d < b) { d++; flag2++; } if (0 == flag1 && 0 == flag2) { printf("%d\n", d - c + 1); } else if (0 == flag1 && 1 == flag2) { printf("%d\n", d - c); } else if (1 == flag1 && 0 == flag2) { printf("%d\n", d - c + 1); } else if (1 == flag1 && 1 == flag2) { printf("%d\n", d - c); } } return 0; }
the_stack_data/9511625.c
// © Guillaume COQUARD, April 2018 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <time.h> // CONSTANTS NEEDED #define TAILLE_MIN 10 #define SIZE_BUF 64 // FUNCTIONS NEEDED // - Occurences counter int count_occ(int *tab, int el, int a, int b); // - Tab Printer void print_tab(int *tab, int s); int main(int argc, char **argv) { int s,n,x,el,f_0[2],f_1[2]; pid_t pid_0 = 0, pid_1 = 0; char buf_0[SIZE_BUF],buf_1[SIZE_BUF]; // Use of pipes to communicate with 2 childs pipe(f_0); pipe(f_1); printf("Enter a tab size : \n"); scanf("%d", &s); printf("Enter a minimum : \n"); scanf("%d", &n); printf("Enter a maximum : \n"); scanf("%d", &x); printf("Tab filled with values in %d...%d interval.\n", (n<x?n:x),(n<x?x:n)); printf("Enter an element to find : \n"); scanf("%d", &el); while (el < n || el > x) { printf("This value is not allowed : %d \nPlease enter an other value : \n", el); scanf("%d", &el); } int tab[s]; srand(time(NULL)); for (int i = 0; i < s; i++) { tab[i] = rand()%(n<x?x:n)+(n<x?n:x); } print_tab(tab,s); if (s >= TAILLE_MIN) { if (getpid() == getpgid(getpid())) { pid_0 = fork(); } if (getpid() == getpgid(getpid())) { pid_1 = fork(); } if (pid_0 == 0) { char *occ_0 = malloc(SIZE_BUF+1); close(f_0[0]); snprintf(occ_0,SIZE_BUF,"%d",count_occ(tab,el,0,(s%2==0?s/2:s/2+1))); write(f_0[1],occ_0,SIZE_BUF+1); exit(EXIT_SUCCESS); } else if (pid_1 == 0) { char *occ_1 = malloc(SIZE_BUF+1); close(f_1[0]); snprintf(occ_1,SIZE_BUF,"%d",count_occ(tab,el,(s%2==0?s/2:s/2+1),s)); write(f_1[1],occ_1,SIZE_BUF+1); exit(EXIT_SUCCESS); } if (getpid() == getpgid(getpid())) { close(f_0[1]); close(f_1[1]); read(f_0[0],buf_0,SIZE_BUF); read(f_1[0],buf_1,SIZE_BUF); printf("Occurences of %d : %d + %d = %d\n",el,atoi(buf_0),atoi(buf_1),atoi(buf_0)+atoi(buf_1)); } } else { printf("Occurences of %d\n", count_occ(tab,el,0,s)); } return (0); } int count_occ(int *tab, int el, int a, int b) { int occ = 0; for (int i = 0; i < (b>a?b-a:a-b); i++) { if (tab[a+i]==el) { occ++; printf("Occ : %d : index %d\n", el, i+a); } } return occ; } void print_tab(int *tab, int s) { for (int i = 0; i < s; i++) { printf("%d", tab[i]); if (i < s-1) { printf(","); } } printf("\n"); }
the_stack_data/85291.c
#ifdef VISUAL_FORTRAN /* This file contains the MPI bindings that might take a string as argument. Since VF uses STDCALL namings and callee clears stack and additionaly inlines sting length parameters we can't just use the normal bindings and ignore the extra parameter */ #include "mpiimpl.h" #if defined(MPI_BUILD_PROFILING) /* Include mapping from MPI->PMPI */ #include "mpiprof.h" /* Insert the prototypes for the PMPI routines */ #undef __MPI_BINDINGS #include "binding.h" #define mpi_address_ __stdcall PMPI_ADDRESS #define mpi_allgather_ __stdcall PMPI_ALLGATHER #define mpi_allgatherv_ __stdcall PMPI_ALLGATHERV #define mpi_alltoall_ __stdcall PMPI_ALLTOALL #define mpi_alltoallv_ __stdcall PMPI_ALLTOALLV #define mpi_bcast_ __stdcall PMPI_BCAST #define mpi_bsend_init_ __stdcall PMPI_BSEND_INIT #define mpi_bsend_ __stdcall PMPI_BSEND #define mpi_buffer_attach_ __stdcall PMPI_BUFFER_ATTACH #define mpi_buffer_detach_ __stdcall PMPI_BUFFER_DETACH #define mpi_recv_init_ __stdcall PMPI_RECV_INIT #define mpi_send_init_ __stdcall PMPI_SEND_INIT #define mpi_gather_ __stdcall PMPI_GATHER #define mpi_gatherv_ __stdcall PMPI_GATHERV #define mpi_ibsend_ __stdcall PMPI_IBSEND #define mpi_irecv_ __stdcall PMPI_IRECV #define mpi_irsend_ __stdcall PMPI_IRSEND #define mpi_isend_ __stdcall PMPI_ISEND #define mpi_issend_ __stdcall PMPI_ISSEND #define mpi_recv_ __stdcall PMPI_RECV #define mpi_rsend_init_ __stdcall PMPI_RSEND_INIT #define mpi_rsend_ __stdcall PMPI_RSEND #define mpi_scatter_ __stdcall PMPI_SCATTER #define mpi_scatterv_ __stdcall PMPI_SCATTERV #define mpi_send_ __stdcall PMPI_SEND #define mpi_sendrecv_ __stdcall PMPI_SENDRECV #define mpi_sendrecv_replace_ __stdcall PMPI_SENDRECV_REPLACE #define mpi_ssend_init_ __stdcall PMPI_SSEND_INIT #define mpi_ssend_ __stdcall PMPI_SSEND #else #define mpi_address_ __stdcall MPI_ADDRESS #define mpi_allgather_ __stdcall MPI_ALLGATHER #define mpi_allgatherv_ __stdcall MPI_ALLGATHERV #define mpi_alltoall_ __stdcall MPI_ALLTOALL #define mpi_alltoallv_ __stdcall MPI_ALLTOALLV #define mpi_bcast_ __stdcall MPI_BCAST #define mpi_bsend_init_ __stdcall MPI_BSEND_INIT #define mpi_bsend_ __stdcall MPI_BSEND #define mpi_buffer_attach_ __stdcall MPI_BUFFER_ATTACH #define mpi_buffer_detach_ __stdcall MPI_BUFFER_DETACH #define mpi_recv_init_ __stdcall MPI_RECV_INIT #define mpi_send_init_ __stdcall MPI_SEND_INIT #define mpi_gather_ __stdcall MPI_GATHER #define mpi_gatherv_ __stdcall MPI_GATHERV #define mpi_ibsend_ __stdcall MPI_IBSEND #define mpi_irecv_ __stdcall MPI_IRECV #define mpi_irsend_ __stdcall MPI_IRSEND #define mpi_isend_ __stdcall MPI_ISEND #define mpi_issend_ __stdcall MPI_ISSEND #define mpi_recv_ __stdcall MPI_RECV #define mpi_rsend_init_ __stdcall MPI_RSEND_INIT #define mpi_rsend_ __stdcall MPI_RSEND #define mpi_scatter_ __stdcall MPI_SCATTER #define mpi_scatterv_ __stdcall MPI_SCATTERV #define mpi_send_ __stdcall MPI_SEND #define mpi_sendrecv_ __stdcall MPI_SENDRECV #define mpi_sendrecv_replace_ __stdcall MPI_SENDRECV_REPLACE #define mpi_ssend_init_ __stdcall MPI_SSEND_INIT #define mpi_ssend_ __stdcall MPI_SSEND #endif #define PAGE_READ_PRIV (PAGE_READONLY|PAGE_READWRITE|PAGE_WRITECOPY|\ PAGE_EXECUTE_READ|PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY) #define PAGE_WRITE_PRIV (PAGE_READWRITE|PAGE_WRITECOPY|\ PAGE_EXECUTE_READWRITE|PAGE_EXECUTE_WRITECOPY) #undef VF_TYPE_ERROR #define VF_TYPE_ERROR(func,arg,val) *__ierr=MPIR_ERROR(MPIR_COMM_WORLD,\ MPIR_Err_setmsg(MPI_ERR_ARG,MPIR_ERR_ARG_NAMED,func,"Invalid type","Arg %s invalid value %d",arg,val),\ func) #define VF_TYPE_ERROR1(func) VF_TYPE_ERROR(func,"sendtype",MPI_Type_f2c(*sendtype)) #define VF_TYPE_ERROR2(func) VF_TYPE_ERROR(func,"recvtype",MPI_Type_f2c(*recvtype)) #define BUF_TXT "Can't determine which of sendbuf/recvbuf is a character sting" #define VF_BUF_ERROR(func) *__ierr=MPIR_ERROR(MPIR_COMM_WORLD,MPIR_Err_setmsg(MPI_ERR_ARG,0,func,0,BUF_TXT),func) WINBASEAPI DWORD WINAPI MPIR_VirtualQuery( IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN DWORD dwLength ); void mpi_address_( void *location,int str_len, MPI_Fint *address, MPI_Fint *__ierr ) { MPI_Aint a, b; *__ierr = MPI_Address( location, &a ); if (*__ierr != MPI_SUCCESS) return; b = a - (MPI_Aint)MPIR_F_MPI_BOTTOM; *address = (int)( b ); if (((MPI_Aint)*address) - b != 0) { *__ierr = MPIR_ERROR( MPIR_COMM_WORLD, MPIR_ERRCLASS_TO_CODE(MPI_ERR_ARG,MPIR_ERR_FORTRAN_ADDRESS_RANGE), "MPI_ADDRESS" ); } } /* The version of MPI_ALLGATHER with only one string parameter. */ void mpi_allgather_ ( void *sendbuf,int len, MPI_Fint *sendcount, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; /* This is quite complicated. We know that we got one string. This might either be sendbuf or recvbuf. So we are not sure it the string length is behind the first or the second buffer. All we can do is to guess. We try to solve the problem by checking if slen is a valid pointer If it is, most likely recvbuf will be the string and the parameters are shifted Please note that we can not be sure if we guessed right. If the length of the string is a valid address (which is unlikely, but possible) we are doomed. */ MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { /* oops, both possible positions of len are invalid or valid addresses. This is not good, so we give up guessing and return an error*/ VF_BUF_ERROR("MPI_ALLGATHER" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_ALLGATHER"); return; } *__ierr = MPI_Allgather(MPIR_F_PTR(sendbuf), (int)*sendcount, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), (int)*recvcount, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm)); } else { /* Now we have a problem. The length parameter is behind the second, not behind the first buffer. So we have to shift the values... It looks like this: local name real value strlen --> sendcount, sendcount --> sendtype sendtype --> recvbuf recvbuf --> strlen */ if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_ALLGATHER"); return; } *__ierr = MPI_Allgather(MPIR_F_PTR(sendbuf), (int)*(MPI_Fint*)len, /*sendcount*/ MPI_Type_f2c(*sendcount),/*sendtype*/ MPIR_F_PTR((void*)sendtype), /*recvbuf*/ (int)*recvcount, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm)); } } void mpi_allgatherv_ ( void *sendbuf, int len,MPI_Fint *sendcount, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcounts, MPI_Fint *displs, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; /* This is quite complicated. We know that we got one string. This might either be sendbuf or recvbuf. So we are not sure it the string length is behind the first or the second buffer. All we can do is to guess. We try to solve the problem by checking if strlen is a valid pointer If it is, most likely recvbuf will be the string and the parameters are shifted Please note that we can not be sure if we guessed right. If the length of the string is a valid address (which is unlikely, but possible) we are doomed. */ MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { /* oops, both possible positions of strlen are invlid or valid addresses. This is not good, so we give up guessing and return an error*/ VF_BUF_ERROR("MPI_ALLGATHERV" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_ALLGATHERV"); return; } *__ierr = MPI_Allgatherv(MPIR_F_PTR(sendbuf), *sendcount, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), recvcounts, displs, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm)); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_ALLGATHERV"); return; } *__ierr = MPI_Allgatherv(MPIR_F_PTR(sendbuf), (int)*(MPI_Fint*)len, /*sendcount*/ MPI_Type_f2c(*sendcount),/*sendtype*/ MPIR_F_PTR((void*)sendtype), /*recvbuf*/ recvcounts,displs, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm)); } } void mpi_alltoall_( void *sendbuf, int len, MPI_Fint *sendcount, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcnt, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_ALLTOALL" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_ALLTOALL"); return; } *__ierr = MPI_Alltoall(MPIR_F_PTR(sendbuf), (int)*sendcount, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), (int)*recvcnt, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm) ); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_ALLTOALL"); return; } *__ierr = MPI_Alltoall(MPIR_F_PTR(sendbuf), (int)*(MPI_Fint*)len, /*sendcount*/ MPI_Type_f2c(*sendcount),/*sendtype*/ MPIR_F_PTR((void*)sendtype), /*recvbuf*/ (int)*recvcnt, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm) ); } } void mpi_alltoallv_ ( void *sendbuf,int len, MPI_Fint *sendcnts, MPI_Fint *sdispls, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcnts, MPI_Fint *rdispls, MPI_Fint *recvtype, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_ALLTOALLV" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_ALLTOALLV"); return; } *__ierr = MPI_Alltoallv(MPIR_F_PTR(sendbuf), sendcnts, sdispls, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), recvcnts, rdispls, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm) ); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_ALLTOALLV"); return; } *__ierr = MPI_Alltoallv(MPIR_F_PTR(sendbuf), (MPI_Fint*)len, /*sendcnts*/ sendcnts, /*sdispls*/ MPI_Type_f2c(*sdispls), /*sendtype*/ MPIR_F_PTR(sendtype), /*sendbuf*/ recvcnts, rdispls, MPI_Type_f2c(*recvtype), MPI_Comm_f2c(*comm) ); } } void mpi_bcast_ ( void *buffer,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *__ierr ) { *__ierr = MPI_Bcast(MPIR_F_PTR(buffer), (int)*count, MPI_Type_f2c(*datatype), (int)*root, MPI_Comm_f2c(*comm)); } void mpi_bsend_init_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Bsend_init(MPIR_F_PTR(buf),(int)*count, MPI_Type_f2c(*datatype), (int)*dest, (int)*tag,MPI_Comm_f2c(*comm), &lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_bsend_( void *buf, int len,MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *__ierr ) { *__ierr = MPI_Bsend(MPIR_F_PTR(buf),(int)*count,MPI_Type_f2c(*datatype), (int)*dest,(int)*tag,MPI_Comm_f2c(*comm) ); } void mpi_buffer_attach_( void *buffer,int len, MPI_Fint *size, MPI_Fint *__ierr ) { *__ierr = MPI_Buffer_attach(buffer,(int)*size); } void mpi_buffer_detach_( void **buffer,int len, MPI_Fint *size, MPI_Fint *__ierr ) { void *tmp = (void *)buffer; int lsize; *__ierr = MPI_Buffer_detach(&tmp,&lsize); *size = (MPI_Fint)lsize; } void mpi_recv_init_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Recv_init(MPIR_F_PTR(buf),(int)*count, MPI_Type_f2c(*datatype),(int)*source,(int)*tag, MPI_Comm_f2c(*comm),&lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_send_init_( void *buf, int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Send_init(MPIR_F_PTR(buf),(int)*count, MPI_Type_f2c(*datatype),(int)*dest,(int)*tag, MPI_Comm_f2c(*comm),&lrequest); *request = MPI_Request_c2f( lrequest ); } void mpi_gather_ ( void *sendbuf,int len, MPI_Fint *sendcnt, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_GATHER" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_GATHER"); return; } *__ierr = MPI_Gather(MPIR_F_PTR(sendbuf), (int)*sendcnt, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), (int)*recvcount, MPI_Type_f2c(*recvtype), (int)*root, MPI_Comm_f2c(*comm)); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_GATHER"); return; } *__ierr = MPI_Gather(MPIR_F_PTR(sendbuf), *(int*)len,MPI_Type_f2c(*sendcnt), MPIR_F_PTR(sendtype),(int)*recvcount, MPI_Type_f2c(*recvtype), (int)*root, MPI_Comm_f2c(*comm)); } } void mpi_gatherv_ ( void *sendbuf, int len, MPI_Fint *sendcnt, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcnts, MPI_Fint *displs, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_GATHERV" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_GATHERV"); return; } *__ierr = MPI_Gatherv(MPIR_F_PTR(sendbuf), *sendcnt, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), recvcnts, displs, MPI_Type_f2c(*recvtype), *root, MPI_Comm_f2c(*comm)); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_GATHERV"); return; } *__ierr = MPI_Gatherv(MPIR_F_PTR(sendbuf), *(int*)len,MPI_Type_f2c(*sendcnt), MPIR_F_PTR(sendtype), recvcnts, displs, MPI_Type_f2c(*recvtype), *root, MPI_Comm_f2c(*comm)); } } void mpi_ibsend_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Ibsend(MPIR_F_PTR(buf),(int)*count,MPI_Type_f2c(*datatype), (int)*dest,(int)*tag,MPI_Comm_f2c(*comm), &lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_irecv_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Irecv(MPIR_F_PTR(buf),(int)*count,MPI_Type_f2c(*datatype), (int)*source,(int)*tag, MPI_Comm_f2c(*comm),&lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_irsend_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Irsend(MPIR_F_PTR(buf),(int)*count,MPI_Type_f2c(*datatype), (int)*dest,(int)*tag, MPI_Comm_f2c(*comm),&lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_isend_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Isend(MPIR_F_PTR(buf),(int)*count,MPI_Type_f2c(*datatype), (int)*dest, (int)*tag,MPI_Comm_f2c(*comm), &lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_issend_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Issend(MPIR_F_PTR(buf),(int)*count,MPI_Type_f2c(*datatype), (int)*dest, (int)*tag, MPI_Comm_f2c(*comm), &lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_recv_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *source, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *__ierr ) { MPI_Status c_status; *__ierr = MPI_Recv(MPIR_F_PTR(buf), (int)*count,MPI_Type_f2c(*datatype), (int)*source, (int)*tag, MPI_Comm_f2c(*comm), &c_status); MPI_Status_c2f(&c_status, status); } void mpi_rsend_init_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Rsend_init(MPIR_F_PTR(buf), (int)*count, MPI_Type_f2c(*datatype), (int)*dest, (int)*tag, MPI_Comm_f2c(*comm), &lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_rsend_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *__ierr ) { *__ierr = MPI_Rsend(MPIR_F_PTR(buf), (int)*count,MPI_Type_f2c(*datatype), (int)*dest, (int)*tag, MPI_Comm_f2c(*comm)); } void mpi_scatter_ ( void *sendbuf,int len, MPI_Fint *sendcnt, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcnt, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_SCATTER" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_SCATTER" ); return; } *__ierr = MPI_Scatter(MPIR_F_PTR(sendbuf), (int)*sendcnt, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), (int)*recvcnt, MPI_Type_f2c(*recvtype), (int)*root, MPI_Comm_f2c(*comm)); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_SCATTER" ); return; } *__ierr = MPI_Scatter(MPIR_F_PTR(sendbuf), *(int*)len, MPI_Type_f2c(*sendcnt), MPIR_F_PTR(sendtype), (int)*recvcnt, MPI_Type_f2c(*recvtype), (int)*root, MPI_Comm_f2c(*comm)); } } void mpi_scatterv_ ( void *sendbuf,int len, MPI_Fint *sendcnts, MPI_Fint *displs, MPI_Fint *sendtype, void *recvbuf, MPI_Fint *recvcnt, MPI_Fint *recvtype, MPI_Fint *root, MPI_Fint *comm, MPI_Fint *__ierr ) { MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_SCATTERV" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_SCATTERV"); return; } *__ierr = MPI_Scatterv(MPIR_F_PTR(sendbuf), sendcnts, displs, MPI_Type_f2c(*sendtype), MPIR_F_PTR(recvbuf), *recvcnt, MPI_Type_f2c(*recvtype), *root, MPI_Comm_f2c(*comm) ); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_SCATTERV"); return; } *__ierr = MPI_Scatterv(MPIR_F_PTR(sendbuf), (MPI_Fint*)len, sendcnts, MPI_Type_f2c(*displs), MPIR_F_PTR(sendtype), *recvcnt, MPI_Type_f2c(*recvtype), *root, MPI_Comm_f2c(*comm) ); } } void mpi_send_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *__ierr ) { *__ierr = MPI_Send(MPIR_F_PTR(buf), (int)*count, MPI_Type_f2c(*datatype), (int)*dest, (int)*tag, MPI_Comm_f2c(*comm)); } void mpi_sendrecv_( void *sendbuf,int len, MPI_Fint *sendcount, MPI_Fint *sendtype, MPI_Fint *dest, MPI_Fint *sendtag, void *recvbuf, MPI_Fint *recvcount, MPI_Fint *recvtype, MPI_Fint *source, MPI_Fint *recvtag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *__ierr ) { MPI_Status c_status; MEMORY_BASIC_INFORMATION mem_info; BOOL first,second; MPIR_VirtualQuery((LPCVOID)len,&mem_info,sizeof(mem_info)); first = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_READ_PRIV)); MPIR_VirtualQuery((LPCVOID)recvbuf,&mem_info,sizeof(mem_info)); second = (mem_info.State != MEM_COMMIT || !(mem_info.Protect & PAGE_WRITE_PRIV)); if((first && second) || (!first && !second)) { VF_BUF_ERROR("MPI_SENDRECV" ); return; } if(first) { if(MPI_Type_f2c(*sendtype) != MPI_CHAR) { VF_TYPE_ERROR1("MPI_SENDRECV"); return; } *__ierr = MPI_Sendrecv(MPIR_F_PTR(sendbuf), (int)*sendcount, MPI_Type_f2c(*sendtype), (int)*dest, (int)*sendtag, MPIR_F_PTR(recvbuf), (int)*recvcount, MPI_Type_f2c(*recvtype), (int)*source, (int)*recvtag, MPI_Comm_f2c(*comm), &c_status); } else { if(MPI_Type_f2c(*recvtype) != MPI_CHAR) { VF_TYPE_ERROR2("MPI_SENDRECV"); return; } *__ierr = MPI_Sendrecv(MPIR_F_PTR(sendbuf), *(int*)len, MPI_Type_f2c(*sendcount), (int)*sendtype, (int)*dest, MPIR_F_PTR(sendtag), (int)*recvcount, MPI_Type_f2c(*recvtype), (int)*source, (int)*recvtag, MPI_Comm_f2c(*comm), &c_status); } MPI_Status_c2f(&c_status, status); } void mpi_sendrecv_replace_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *sendtag, MPI_Fint *source, MPI_Fint *recvtag, MPI_Fint *comm, MPI_Fint *status, MPI_Fint *__ierr ) { MPI_Status c_status; *__ierr = MPI_Sendrecv_replace(MPIR_F_PTR(buf), (int)*count, MPI_Type_f2c(*datatype), (int)*dest, (int)*sendtag, (int)*source, (int)*recvtag, MPI_Comm_f2c(*comm), &c_status ); MPI_Status_c2f(&c_status, status); } void mpi_ssend_init_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *request, MPI_Fint *__ierr ) { MPI_Request lrequest; *__ierr = MPI_Ssend_init(MPIR_F_PTR(buf), (int)*count, MPI_Type_f2c(*datatype), (int)*dest, (int)*tag, MPI_Comm_f2c(*comm), &lrequest); *request = MPI_Request_c2f(lrequest); } void mpi_ssend_( void *buf,int len, MPI_Fint *count, MPI_Fint *datatype, MPI_Fint *dest, MPI_Fint *tag, MPI_Fint *comm, MPI_Fint *__ierr ) { *__ierr = MPI_Ssend(MPIR_F_PTR(buf), (int)*count, MPI_Type_f2c(*datatype), (int)*dest, (int)*tag, MPI_Comm_f2c(*comm)); } #endif
the_stack_data/105824.c
void foo (int x, int c, char h); int f(void) { return 0; } int x = 3;