blob_id
stringlengths
40
40
directory_id
stringlengths
40
40
path
stringlengths
4
721
content_id
stringlengths
40
40
detected_licenses
listlengths
0
57
license_type
stringclasses
2 values
repo_name
stringlengths
5
91
snapshot_id
stringlengths
40
40
revision_id
stringlengths
40
40
branch_name
stringclasses
321 values
visit_date
timestamp[ns]date
2016-08-12 09:31:09
2023-09-06 10:45:07
revision_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
committer_date
timestamp[ns]date
2010-09-28 14:01:40
2023-09-06 06:22:19
github_id
int64
426
681M
star_events_count
int64
101
243k
fork_events_count
int64
0
110k
gha_license_id
stringclasses
23 values
gha_event_created_at
timestamp[ns]date
2012-06-28 18:51:49
2023-09-14 21:59:16
gha_created_at
timestamp[ns]date
2008-02-11 22:55:26
2023-08-10 11:14:58
gha_language
stringclasses
147 values
src_encoding
stringclasses
26 values
language
stringclasses
2 values
is_vendor
bool
2 classes
is_generated
bool
2 classes
length_bytes
int64
6
10.2M
extension
stringclasses
115 values
filename
stringlengths
3
113
content
stringlengths
6
10.2M
831f1215fdc0eac1b4c892167ab205cc8237eb85
89db60818afeb3dc7c3b7abe9ceae155f074f7f2
/src/lib9/mallocz.c
a3e91510b17797b6b4287f44a601d1fc43c6806d
[ "MIT", "bzip2-1.0.6", "LPL-1.02" ]
permissive
9fans/plan9port
63c3d01928c6f8a8617d3ea6ecc05bac72391132
65c090346a38a8c30cb242d345aa71060116340c
refs/heads/master
2023-08-25T17:14:26.233105
2023-08-23T13:21:37
2023-08-23T18:47:08
26,095,474
1,645
468
NOASSERTION
2023-09-05T16:55:41
2014-11-02T22:40:13
C
UTF-8
C
false
false
189
c
mallocz.c
#include <u.h> #include <unistd.h> #include <string.h> #include <libc.h> void* mallocz(unsigned long n, int clr) { void *v; v = malloc(n); if(clr && v) memset(v, 0, n); return v; }
5f2e1f5dbef9e22a2922b8d0d97c0ccbbb257dda
20433db17587a358853434e1f7618ff0bb834f7c
/src/wah.c
f9122fe2c56505f17ebe0b5a8f1fe7dfe0e1dcf6
[ "MIT" ]
permissive
ryanlayer/gqt
03927c103a52123b0821fc774e4a06b6e00b2278
9deb46196abc8bebe337d7516f46949d7aeab538
refs/heads/master
2021-06-09T13:35:07.313380
2019-11-21T19:48:37
2019-11-21T19:48:37
21,572,115
116
31
MIT
2021-03-29T08:30:27
2014-07-07T13:47:29
C
UTF-8
C
false
false
28,876
c
wah.c
/** * @file wah.c * @Author Ryan Layer (ryan.layer@gmail.com) * @date May, 2014 * @brief Functions for converting and opperation on WAH-encoded files */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/param.h> #include <math.h> #include <limits.h> #include <sysexits.h> #include "wah.h" #include "genotq.h" #if 0 //{{{ struct wah_file init_wah_file(char *file_name) struct wah_file init_wah_file(char *file_name) { struct wah_file wf; wf.file_name = strdup(file_name); wf.file = fopen(file_name, "rb"); if (!wf.file) err(EX_NOINPUT, "Cannot open file \"%s\"", file_name); // Jump to the begining of the file to grab the record size fseek(wf.file, 0, SEEK_SET); size_t fr = fread(&wf.num_fields,sizeof(uint32_t),1,wf.file); check_file_read(file_name, wf.file, 1, fr); fr = fread(&wf.num_records,sizeof(uint32_t),1,wf.file); check_file_read(file_name, wf.file, 1, fr); wf.record_offsets = (uint64_t *) malloc(sizeof (uint64_t)*wf.num_records); if (!wf.record_offsets) err(EX_OSERR, "malloc error"); uint32_t i; for (i = 0; i < wf.num_records; ++i) { fr = fread(&(wf.record_offsets[i]),sizeof(uint64_t),1,wf.file); check_file_read(file_name, wf.file, 1, fr); } wf.header_offset = ftell(wf.file); return wf; } //}}} //{{{void destroy_wah_file(struct wah_file *wf) void destroy_wah_file(struct wah_file *wf) { fclose(wf->file); free(wf->file_name); free(wf->record_offsets); } //}}} #endif //{{{ uint32_t wah_or_b(uint32_t *R, uint32_t wah_or_b(uint32_t *R, uint32_t *X, uint32_t len_X, uint32_t *Y, uint32_t len_Y) { uint32_t R_i = 0, X_i = 0, Y_i = 0; uint32_t x, y, x_size, y_size, r_size; x = X[X_i]; y = Y[X_i]; if (x >= 0x80000000) x_size = x & 0x3fffffff; else x_size = 1; if (y >= 0x80000000) y_size = y & 0x3fffffff; else y_size = 1; while (1) { r_size = MIN(x_size, y_size); R[R_i] = x || y; if (r_size > 1) R[R_i] = (1<<31) + ((x & 0x40000000) | (y & 0x40000000)) + r_size; else { if (x_size > 1) R[R_i] = ((x >> 30)&1)?0x7fffffff:y; else if (y_size > 1) R[R_i] = ((y >> 30)&1)?0x7fffffff:x; else R[R_i] = x | y; } x_size -= r_size; y_size -= r_size; R_i += 1; if (x_size == 0) { X_i += 1; if (X_i == len_X) break; x = X[X_i]; if (x >= 0x80000000) x_size = x & 0x3fffffff; else x_size = 1; } if (y_size == 0) { Y_i += 1; if (Y_i == len_Y) break; y = Y[Y_i]; if (y >= 0x80000000) y_size = y & 0x3fffffff; else y_size = 1; } } return R_i; #if 0 struct wah_run x = init_wah_run(X, len_X); struct wah_run y = init_wah_run(Y, len_Y); struct wah_active_word a; uint32_t num_words; uint32_t R_len = 0; //xrun.it = x.vec.begin(); xrun.decode(); wah_run_decode(&x); //yrun.it = y.vec.begin(); yrun.decode(); wah_run_decode(&y); // WHILE (x.vec and y.vec are not exhausted) while ( (x.word_i < x.len) && (y.word_i < y.len) ){ // IF (xrun.nWords == 0) ++xrun.it, xrun.decode(); if (x.num_words == 0) { x.word_i += 1; if (x.word_i < x.len) wah_run_decode(&x); } // IF (yrun.nWords == 0) ++yrun.it, yrun.decode(); if (y.num_words == 0) { y.word_i += 1; if (y.word_i < y.len) wah_run_decode(&y); } if ( (x.word_i >= x.len) && (y.word_i >= y.len) ) break; else if (x.word_i >= x.len) { fprintf(stderr, "X ended before Y\n"); abort(); } else if (y.word_i >= y.len) { fprintf(stderr, "Y ended before X\n"); abort(); } // IF (xrun.isFill) if (x.is_fill == 1) { // IF (yrun.isFill) if (y.is_fill == 1) { //fprintf(stderr,"X Fill\tY Fill\n"); //nWords = min(xrun.nWords, yrun.nWords) //z.appendFill(nWords, (*(xrun.it) ◦ *(yrun.it))), //xrun.nWords -= nWords, yrun.nWords -= nWords; num_words = MIN(x.num_words, y.num_words); R_len = append_fill_word_b(R, R_len, (x.fill_bit | y.fill_bit), num_words); x.num_words -= num_words; y.num_words -= num_words; // ELSE } else { //fprintf(stderr,"X Fill\tY Litt\n"); //z.active.value = xrun.fill ◦ *yrun.it //z.appendLiteral(), //-- xrun.nWords, yrun.nWords = 0; a.nbits = 31; a.value = y.words[y.word_i] | x.fill; R_len = append_active_word_b(R, R_len, a.value); x.num_words -= 1; y.num_words = 0; } //ELSEIF (yrun.isFill) } else if (y.is_fill == 1) { //fprintf(stderr,"X Litt\tY Fill\n"); //z.active.value = yrun.fill ◦ *xrun.it, //z.appendLiteral(), //-- yrun.nWords, xrun.nWords = 0; a.nbits = 31; a.value = x.words[x.word_i] | y.fill; R_len = append_active_word_b(R, R_len, a.value); y.num_words -= 1; x.num_words = 0; //ELSE } else { //fprintf(stderr,"X Litt\tY Litt\n"); a.nbits = 31; a.value = x.words[x.word_i] | y.words[y.word_i]; R_len = append_active_word_b(R, R_len, a.value); y.num_words = 0; x.num_words = 0; } } return R_len; #endif } //}}} // operate //{{{ void wah_or(struct wah_run *x, uint32_t wah_or(struct wah_run *x, struct wah_run *y, uint32_t **O) { struct wah_active_word a; uint32_t num_words; struct wah_ll *Z_head = NULL, *Z_tail = NULL; int Z_len = 0; //xrun.it = x.vec.begin(); xrun.decode(); wah_run_decode(x); //yrun.it = y.vec.begin(); yrun.decode(); wah_run_decode(y); // WHILE (x.vec and y.vec are not exhausted) while ( (x->word_i < x->len) && (y->word_i < y->len) ){ // IF (xrun.nWords == 0) ++xrun.it, xrun.decode(); if (x->num_words == 0) { x->word_i += 1; if (x->word_i < x->len) wah_run_decode(x); } // IF (yrun.nWords == 0) ++yrun.it, yrun.decode(); if (y->num_words == 0) { y->word_i += 1; if (y->word_i < y->len) wah_run_decode(y); } if ( (x->word_i >= x->len) && (y->word_i >= y->len) ) break; else if (x->word_i >= x->len) { fprintf(stderr, "X ended before Y\n"); abort(); } else if (y->word_i >= y->len) { fprintf(stderr, "Y ended before X\n"); abort(); } // IF (xrun.isFill) if (x->is_fill == 1) { // IF (yrun.isFill) if (y->is_fill == 1) { //fprintf(stderr,"X Fill\tY Fill\n"); //nWords = min(xrun.nWords, yrun.nWords) //z.appendFill(nWords, (*(xrun.it) ◦ *(yrun.it))), //xrun.nWords -= nWords, yrun.nWords -= nWords; num_words = MIN(x->num_words, y->num_words); Z_len += append_fill_word(&Z_head, &Z_tail, (x->fill_bit | y->fill_bit), num_words); x->num_words -= num_words; y->num_words -= num_words; // ELSE } else { //fprintf(stderr,"X Fill\tY Litt\n"); //z.active.value = xrun.fill ◦ *yrun.it //z.appendLiteral(), //-- xrun.nWords, yrun.nWords = 0; a.nbits = 31; a.value = y->words[y->word_i] | x->fill; Z_len += append_active_word(&Z_head, &Z_tail, a); x->num_words -= 1; y->num_words = 0; } //ELSEIF (yrun.isFill) } else if (y->is_fill == 1) { //fprintf(stderr,"X Litt\tY Fill\n"); //z.active.value = yrun.fill ◦ *xrun.it, //z.appendLiteral(), //-- yrun.nWords, xrun.nWords = 0; a.nbits = 31; a.value = x->words[x->word_i] | y->fill; Z_len += append_active_word(&Z_head, &Z_tail, a); y->num_words -= 1; x->num_words = 0; //ELSE } else { //fprintf(stderr,"X Litt\tY Litt\n"); a.nbits = 31; a.value = x->words[x->word_i] | y->words[y->word_i]; Z_len += append_active_word(&Z_head, &Z_tail, a); y->num_words = 0; x->num_words = 0; } } *O = (uint32_t *) malloc(Z_len * sizeof(uint32_t)); if (!*O) err(EX_OSERR, "malloc error"); struct wah_ll *Z_tmp, *Z_curr = Z_head; int i = 0; while (Z_curr != NULL) { (*O)[i] = Z_curr->value.value; i += 1; Z_tmp = Z_curr; Z_curr = Z_tmp->next; free(Z_tmp); } return Z_len; } //}}} //{{{ uint32_t wah_and(struct wah_run *x, uint32_t wah_and(struct wah_run *x, struct wah_run *y, uint32_t **O) { struct wah_active_word a; uint32_t num_words; struct wah_ll *Z_head = NULL, *Z_tail = NULL; int Z_len = 0; //xrun.it = x.vec.begin(); xrun.decode(); wah_run_decode(x); //yrun.it = y.vec.begin(); yrun.decode(); wah_run_decode(y); // WHILE (x.vec and y.vec are not exhausted) while ( (x->word_i < x->len) && (y->word_i < y->len) ){ // IF (xrun.nWords == 0) ++xrun.it, xrun.decode(); if (x->num_words == 0) { x->word_i += 1; if (x->word_i < x->len) wah_run_decode(x); } // IF (yrun.nWords == 0) ++yrun.it, yrun.decode(); if (y->num_words == 0) { y->word_i += 1; if (y->word_i < y->len) wah_run_decode(y); } if ( (x->word_i >= x->len) && (y->word_i >= y->len) ) break; else if (x->word_i >= x->len) { fprintf(stderr, "X ended before Y\n"); abort(); } else if (y->word_i >= y->len) { fprintf(stderr, "Y ended before X\n"); abort(); } // IF (xrun.isFill) if (x->is_fill == 1) { // IF (yrun.isFill) if (y->is_fill == 1) { //fprintf(stderr,"X Fill\tY Fill\n"); //nWords = min(xrun.nWords, yrun.nWords) //z.appendFill(nWords, (*(xrun.it) ◦ *(yrun.it))), //xrun.nWords -= nWords, yrun.nWords -= nWords; num_words = MIN(x->num_words, y->num_words); Z_len += append_fill_word(&Z_head, &Z_tail, (x->fill_bit & y->fill_bit), num_words); x->num_words -= num_words; y->num_words -= num_words; // ELSE } else { //fprintf(stderr,"X Fill\tY Litt\n"); //z.active.value = xrun.fill ◦ *yrun.it //z.appendLiteral(), //-- xrun.nWords, yrun.nWords = 0; a.nbits = 31; a.value = y->words[y->word_i] & x->fill; Z_len += append_active_word(&Z_head, &Z_tail, a); x->num_words -= 1; y->num_words = 0; } //ELSEIF (yrun.isFill) } else if (y->is_fill == 1) { //fprintf(stderr,"X Litt\tY Fill\n"); //z.active.value = yrun.fill ◦ *xrun.it, //z.appendLiteral(), //-- yrun.nWords, xrun.nWords = 0; a.nbits = 31; a.value = x->words[x->word_i] & y->fill; Z_len += append_active_word(&Z_head, &Z_tail, a); y->num_words -= 1; x->num_words = 0; //ELSE } else { //fprintf(stderr,"X Litt\tY Litt\n"); a.nbits = 31; a.value = x->words[x->word_i] & y->words[y->word_i]; Z_len += append_active_word(&Z_head, &Z_tail, a); y->num_words = 0; x->num_words = 0; } } *O = (uint32_t *) malloc(Z_len * sizeof(uint32_t)); if (!*O ) err(EX_OSERR, "malloc error"); struct wah_ll *Z_tmp, *Z_curr = Z_head; int i = 0; while (Z_curr != NULL) { (*O)[i] = Z_curr->value.value; i += 1; Z_tmp = Z_curr; Z_curr = Z_tmp->next; free(Z_tmp); } return Z_len; } //}}} //{{{ struct wah_run init_wah_run(uint32_t *words, struct wah_run init_wah_run(uint32_t *words, uint32_t len){ struct wah_run r; r.words = words; r.word_i = 0; r.len = len; r.fill = 0; r.num_words = 0; r.is_fill = 0; r.fill_bit = 0; return r; } //}}} //{{{ void wah_run_decode(struct wah_run *r) void wah_run_decode(struct wah_run *r) { if (r->words[r->word_i] > 0x7FFFFFFF) { r->fill = (r->words[r->word_i]>=0xC0000000?0x7FFFFFFF:0); r->num_words = r->words[r->word_i] & 0x3FFFFFFF; r->is_fill= 1; r->fill_bit = (r->words[r->word_i]>=0xC0000000?1:0); } else { r->num_words = 1; r->is_fill= 0; } } //}}} // compress //{{{ int ints_to_wah16(uint32_t *I, uint32_t ints_to_wah16(uint32_t *I, int I_len, uint32_t used_bits, uint16_t **W) { uint32_t W_len; uint16_t *O; // split the intput up int to 31-bit groups uint32_t O_len = map_from_32_bits_to_15_bits(I, I_len, used_bits, &O); // build the WAH list struct wah16_ll *A_head = NULL, *A_tail = NULL, *A_curr; int i,c = 0; struct wah16_active_word a; a.nbits=15; for (i = 0; i < O_len; ++i) { a.value = O[i]; c += append_active_16word(&A_head,&A_tail,a); } free(O); // Move the linked list to an array W_len = c; *W = (uint16_t *) malloc(W_len * sizeof(uint16_t)); if (!*W) err(EX_OSERR, "malloc error"); A_curr = A_head; struct wah16_ll *A_tmp; i = 0; while (A_curr != NULL) { (*W)[i] = A_curr->value.value; i += 1; A_tmp = A_curr; A_curr = A_tmp->next; free(A_tmp); } return W_len; } //}}} //{{{ int ints_to_wah(uint32_t *I, uint32_t ints_to_wah(uint32_t *I, int I_len, uint32_t used_bits, uint32_t **W) { uint32_t W_len; uint32_t *O; // split the intput up int to 31-bit groups uint32_t O_len = map_from_32_bits_to_31_bits(I, I_len, used_bits, &O); // build the WAH list struct wah_ll *A_head = NULL, *A_tail = NULL, *A_curr; int i,c = 0; struct wah_active_word a; a.nbits=31; for (i = 0; i < O_len; ++i) { a.value = O[i]; c += append_active_word(&A_head,&A_tail,a); } free(O); // Move the linked list to an array W_len = c; *W = (uint32_t *) malloc(W_len * sizeof(uint32_t)); if (!*W ) err(EX_OSERR, "malloc error"); A_curr = A_head; struct wah_ll *A_tmp; i = 0; while (A_curr != NULL) { (*W)[i] = A_curr->value.value; i += 1; A_tmp = A_curr; A_curr = A_tmp->next; free(A_tmp); } return W_len; } //}}} //{{{unsinged int map_from_32_bits_to_15_bits(uint32_t *I, uint32_t map_from_32_bits_to_15_bits(uint32_t *I, int I_len, uint32_t used_bits, uint16_t **O) { uint32_t int_i, bit_i, group_i, in_group_i; uint32_t O_len = (used_bits + 15 - 1)/ 15; //uint32_t O_len = (I_len*32 + 31 - 1)/ 31; *O = (uint16_t *) calloc(O_len, sizeof(uint16_t)); bit_i = 1; group_i = 0; in_group_i = 0; for (int_i = 0; int_i < I_len; ++int_i) { for ( ;bit_i<=32*(int_i+1); ++bit_i) { uint32_t bit = (I[int_i] >> (32 - (bit_i%32))) & 1; (*O)[group_i] = (*O)[group_i] + (bit << (14 - in_group_i)); in_group_i += 1; if (bit_i % 15 == 0) { in_group_i = 0; group_i += 1; } if (bit_i == used_bits) break; } if (bit_i == used_bits) break; } return O_len; } //}}} //{{{unsinged int map_from_32_bits_to_31_bits(uint32_t *I, /* * Take a list of 32 bit number and gives the list of 31-bit groups * (represented by 32-bit with left padding) ints * Returns the number of 31-bit groups in O */ uint32_t map_from_32_bits_to_31_bits(uint32_t *I, int I_len, uint32_t used_bits, uint32_t **O) { uint32_t int_i, bit_i, group_i, in_group_i; uint32_t O_len = (used_bits + 31 - 1)/ 31; //uint32_t O_len = (I_len*32 + 31 - 1)/ 31; *O = (uint32_t *) calloc(O_len, sizeof(uint32_t)); bit_i = 1; group_i = 0; in_group_i = 0; for (int_i = 0; int_i < I_len; ++int_i) { for ( ;bit_i<=32*(int_i+1); ++bit_i) { uint32_t bit = (I[int_i] >> (32 - (bit_i%32))) & 1; (*O)[group_i] = (*O)[group_i] + (bit << (30 - in_group_i)); in_group_i += 1; if (bit_i % 31 == 0) { in_group_i = 0; group_i += 1; } if (bit_i == used_bits) break; } if (bit_i == used_bits) break; } return O_len; } //}}} //{{{ int append_bit_to_active_word(struct wah_active_word *a, int b) int append_bit_to_active_word(struct wah_active_word *a, int b) { // if a litteral, just add the next bit if (a->nbits < 31){ a->value = (a->value<<1) + b; a->nbits += 1; // if a fill that isn't full, and value bit matches, add one //} else if ( (a->nbits > 31) && (((b<<30) & a->value) == b << 30)) { } else if ( (a->nbits > 31) && (((a->value >> 30) & 1) == b )) { if (a->nbits < pow(2,30) - 1) { a->nbits += 1; a->value += 1; } else { return 1; // can't add to current active } // if the litteral is full and they are all one value, make it a literal } else if ( (a->value == 0) || (a->value == pow(2,31) - 1)) { a->nbits = 32; a->value = ((2 + b) <<30) + 32; } else { return 1; // can't add to current active } return 0; // added to current active } //}}} //{{{ int append_active_16word(struct wah_ll **A_head, /* * This will return 1 if a new node is added to the active word linked list, * otherwise 0 */ int append_active_16word(struct wah16_ll **A_head, struct wah16_ll **A_tail, struct wah16_active_word a) { struct wah16_ll *n = (struct wah16_ll *) malloc(sizeof(struct wah16_ll)); if (!n) err(EX_OSERR, "malloc error"); n->value = a; n->next = NULL; if (*A_head == NULL) { *A_head = n; *A_tail = n; return 1; } else if (a.value == 0) { // all zeros // The value on the tail is a litteral with all zeros if ( (*A_tail)->value.value == 0 ) { (*A_tail)->value.value = 0x8002; //(*A_tail)->value.value = 0x80000002; free(n); return 0; // The value on the tail is a fill of all zeros that is not full } else if ( ((*A_tail)->value.value >= 0x8000) && ((*A_tail)->value.value < 0xC000) ) { (*A_tail)->value.value += 1; free(n); return 0; } else { // the zeros cannot be added to the last active word (*A_tail)->next = n; *A_tail = n; return 1; } } else if (a.value == 0x7FFF) { // all ones if ( (*A_tail)->value.value == a.value ) { (*A_tail)->value.value = 0xC002; free(n); return 0; } else if ( (*A_tail)->value.value >= 0xC000) { (*A_tail)->value.value += 1; free(n); return 0; } else { (*A_tail)->next = n; *A_tail = n; return 1; } } else { (*A_tail)->next = n; *A_tail = n; return 1; } } //}}} //{{{ int append_active_word(struct wah_ll **A_head, /* * This will return 1 if a new node is added to the active word linked list, * otherwise 0 */ int append_active_word(struct wah_ll **A_head, struct wah_ll **A_tail, struct wah_active_word a) { struct wah_ll *n = (struct wah_ll *) malloc(sizeof(struct wah_ll)); if (!n) err(EX_OSERR, "malloc error"); n->value = a; n->next = NULL; if (*A_head == NULL) { *A_head = n; *A_tail = n; return 1; } else if (a.value == 0) { // all zeros // The value on the tail is a litteral with all zeros if ( (*A_tail)->value.value == 0 ) { (*A_tail)->value.value = 0x80000002; free(n); return 0; // The value on the tail is a fill of all zeros that is not full } else if ( ((*A_tail)->value.value >= 0x80000000) && ((*A_tail)->value.value < 0xC0000000) ) { (*A_tail)->value.value += 1; free(n); return 0; } else { // the zeros cannot be added to the last active word (*A_tail)->next = n; *A_tail = n; return 1; } //} else if (a.value == (pow(2,31) - 1)) { // all ones } else if (a.value == 0x7FFFFFFF) { // all ones if ( (*A_tail)->value.value == a.value ) { (*A_tail)->value.value = 0xC0000002; free(n); return 0; } else if ( (*A_tail)->value.value >= 0xC0000000) { (*A_tail)->value.value += 1; free(n); return 0; } else { (*A_tail)->next = n; *A_tail = n; return 1; } } else { (*A_tail)->next = n; *A_tail = n; return 1; } } //}}} //{{{ int append_fill_word(struct wah_ll **A_head, /* * The fill_size is the number of words / 31*fill_size number of bits */ int append_fill_word(struct wah_ll **A_head, struct wah_ll **A_tail, int fill_bit, uint32_t fill_size) { // if it is a fill, the bit matches, and there is room if ( (*A_head != NULL) && ((*A_tail)->value.value >> 30 == 2 + fill_bit) &&//fill & bit match (((*A_tail)->value.value >> 2)+ fill_size < 0x3fffffff) ) {//room (*A_tail)->value.value += fill_size; return 0; } else { struct wah_ll *n = (struct wah_ll *) malloc(sizeof(struct wah_ll)); if (!n) err(EX_OSERR, "malloc error"); n->next = NULL; if (fill_size > 1) n->value.value = ((2 + fill_bit) << 30) + fill_size; else { n->value.nbits = 31; n->value.value = (fill_bit?0x7FFFFFFF:0); } if (*A_head == NULL) *A_head = n; else (*A_tail)->next = n; *A_tail = n; return 1; } return -1; } //}}} //{{{ int append_active_word_b(uint32_t *R, int append_active_word_b(uint32_t *R, uint32_t R_len, uint32_t value) { if (R_len == 0) { R[0] = value; return R_len + 1; } else if (value == 0) { // The value on the tail is a litteral with all zeros if (R[R_len - 1] == 0) { R[R_len - 1] = 0x80000002; return R_len; // The value on the tail is a fill of all zeros that is not full } else if ((R[R_len - 1] >= 0x80000000) && (R[R_len - 1] < 0xC0000000) ) { R[R_len - 1] += 1; return R_len; } else { // the zeros cannot be added to the last active word R[R_len] = 0; return R_len + 1; } } else if (value == 0x7FFFFFFF) { // all ones if ( R[R_len - 1] == value ) { R[R_len - 1] = 0xC0000002; return R_len; } else if (( R[R_len - 1] >= 0xC0000000 ) && ( R[R_len - 1] < 0xffffffff) ) { R[R_len - 1] += 1; return R_len; } else { R[R_len] = 0x7FFFFFFF; return R_len + 1; } } else { R[R_len] = value; return R_len + 1; } } //}}} //{{{ uint32_t append_fill_word_b(uint32_t *R, /* * The fill_size is the number of words / 31*fill_size number of bits */ uint32_t append_fill_word_b(uint32_t *R, uint32_t R_len, int fill_bit, uint32_t fill_size) { // if it is a fill, the bit matches, and there is room if ((R_len > 0) && (R[R_len - 1] >> 30 == 2 + fill_bit) &&//fill & bit match ((R[R_len - 1]>> 2) + fill_size < 0x3fffffff) ) {//room R[R_len - 1] += fill_size; return R_len; } else { if (fill_size > 1) { R[R_len] = ((2 + fill_bit) << 30) + fill_size; return R_len + 1; } else { R[R_len] = (fill_bit?0x7FFFFFFF:0); return R_len + 1; } } } //}}} // inflate //{{{ uint32_t wah_to_ints(uint32_t *W, uint32_t wah_to_ints(uint32_t *W, uint32_t W_len, uint32_t **O) { uint32_t wah_i; uint32_t num_bits = 0; for (wah_i = 0; wah_i < W_len; ++wah_i) { if (W[wah_i] >> 31 == 1) num_bits += 31 * (W[wah_i] & 0x3fffffff); // zero out the fill bits else num_bits += 31; } uint32_t num_ints = (num_bits + 32 - 1) / 32; *O = (uint32_t *) malloc (num_ints * sizeof(uint32_t)); if (!*O) err(EX_OSERR, "malloc error"); uint32_t num_words, word_i, fill_bit, bits, bit, bit_i, int_i, int_bit_i; int_bit_i = 1; int_i = 0; (*O)[int_i] = 0; for (wah_i = 0; wah_i < W_len; ++wah_i) { if (W[wah_i] >> 31 == 1) { num_words = (W[wah_i] & 0x3fffffff); fill_bit = (W[wah_i]>=0xC0000000?1:0); bits = (fill_bit?0x7FFFFFFF:0); } else { num_words = 1; bits = W[wah_i]; } for (word_i = 0; word_i < num_words; ++word_i) { for (bit_i = 0; bit_i < 31; ++bit_i) { bit = (bits >> (30 - bit_i)) & 1; //fprintf(stderr,"%u", bit); (*O)[int_i] += bit << (32 - int_bit_i); if (int_bit_i == 32) { //fprintf(stderr,"\n%u\n",(*O)[int_i]); int_i += 1; int_bit_i = 0; (*O)[int_i] = 0; } int_bit_i +=1; } } } return num_ints; } //}}}
c2cd2efde1c5da43effd1b062f45872533f115e8
3f308bd1e45dc44276d57c089e7698b4fcda79a4
/lib/btree/queue.h
9860495106729f85d617bf8fa273059e21e22489
[]
no_license
jhallen/joes-sandbox
b5b6d1acf3f66645c3a00757f217f7a8fe2cad27
0ec8c38756e4cdc40fc5f881b7c87e2628d15f24
refs/heads/master
2022-01-18T21:38:24.514745
2022-01-03T01:08:53
2022-01-03T01:08:53
25,269,713
760
42
null
2020-10-27T05:34:56
2014-10-15T19:21:16
C
UTF-8
C
false
false
3,473
h
queue.h
/* Doubly linked list primitives Copyright (C) 1992 Joseph H. Allen This file is part of JOE (Joe's Own Editor) JOE is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. JOE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with JOE; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _Iqueue #define _Iqueue 1 #include "config.h" extern void *ITEM; extern void *QUEUE; extern void *LAST; #define LINK(type) struct { type *next; type *prev; } #define izque(type,member,item) \ ( \ QUEUE=(void *)(item), \ ((type *)QUEUE)->member.prev=(type *)QUEUE, \ ((type *)QUEUE)->member.next=(type *)QUEUE, \ (type *)QUEUE \ ) #define deque(type,member,item) \ ( \ ITEM=(void *)(item), \ ((type *)ITEM)->member.prev->member.next=((type *)ITEM)->member.next, \ ((type *)ITEM)->member.next->member.prev=((type *)ITEM)->member.prev, \ (type *)ITEM \ ) #define qempty(type,member,item) \ ( \ QUEUE=(void *)(item), \ (type *)QUEUE==((type *)QUEUE)->member.next \ ) #define enquef(type,member,queue,item) \ ( \ ITEM=(void *)(item), \ QUEUE=(void *)(queue), \ ((type *)ITEM)->member.next=((type *)QUEUE)->member.next, \ ((type *)ITEM)->member.prev=(type *)QUEUE, \ ((type *)QUEUE)->member.next->member.prev=(type *)ITEM, \ ((type *)QUEUE)->member.next=(type *)ITEM, \ (type *)ITEM \ ) #define enqueb(type,member,queue,item) \ ( \ ITEM=(void *)(item), \ QUEUE=(void *)(queue), \ ((type *)ITEM)->member.next=(type *)QUEUE, \ ((type *)ITEM)->member.prev=((type *)QUEUE)->member.prev, \ ((type *)QUEUE)->member.prev->member.next=(type *)ITEM, \ ((type *)QUEUE)->member.prev=(type *)ITEM, \ (type *)ITEM \ ) #define promote(type,member,queue,item) \ ( \ enquef(type,member,(queue),deque(type,member,(item))) \ ) #define demote(type,member,queue,item) \ ( \ enqueb(type,member,(queue),deque(type,member,(item))) \ ) #define splicef(type,member,queue,chain) \ ( \ ITEM=(void *)(chain), \ LAST=(void *)((type *)ITEM)->member.prev, \ QUEUE=(void *)(queue), \ ((type *)LAST)->member.next=((type *)QUEUE)->member.next, \ ((type *)ITEM)->member.prev=(type *)QUEUE, \ ((type *)QUEUE)->member.next->member.prev=(type *)LAST, \ ((type *)QUEUE)->member.next=(type *)ITEM, \ (type *)ITEM \ ) #define spliceb(type,member,queue,chain) \ ( \ ITEM=(void *)(chain), \ LAST=(void *)((type *)ITEM)->member.prev, \ QUEUE=(void *)(queue), \ ((type *)LAST)->member.next=(type *)QUEUE, \ ((type *)ITEM)->member.prev=((type *)QUEUE)->member.prev, \ ((type *)QUEUE)->member.prev->member.next=(type *)ITEM, \ ((type *)QUEUE)->member.prev=(type *)LAST, \ (type *)ITEM \ ) #define snip(type,member,first,last) \ ( \ ITEM=(void *)(first), \ LAST=(void *)(last), \ ((type *)LAST)->member.next->member.prev=((type *)ITEM)->member.prev, \ ((type *)ITEM)->member.prev->member.next=((type *)LAST)->member.next, \ ((type *)ITEM)->member.prev=(type *)LAST, \ ((type *)LAST)->member.next=(type *)ITEM, \ (type *)ITEM \ ) void *alitem(); void frchn(); #endif
41168db2211a07d1f8bf3286d0cf7a3625194cf0
f79dec3c4033ca3cbb55d8a51a748cc7b8b6fbab
/devel/SDL2/patches/patch-src_audio_bsd_SDL__bsdaudio.c
94df7cbbcf05b840e2e2f7b563f52620d9037392
[]
no_license
jsonn/pkgsrc
fb34c4a6a2d350e8e415f3c4955d4989fcd86881
c1514b5f4a3726d90e30aa16b0c209adbc276d17
refs/heads/trunk
2021-01-24T09:10:01.038867
2017-07-07T15:49:43
2017-07-07T15:49:43
2,095,004
106
47
null
2016-09-19T09:26:01
2011-07-23T23:49:04
Makefile
UTF-8
C
false
false
2,150
c
patch-src_audio_bsd_SDL__bsdaudio.c
$NetBSD: patch-src_audio_bsd_SDL__bsdaudio.c,v 1.5 2017/01/26 03:46:20 nat Exp $ # Remove delay as there is already an inherent delay in writing audio. https://bugzilla.libsdl.org/show_bug.cgi?id=3177 # audio_prinfo needs 'struct' on NetBSD. # Use correct prinfo. # Inform upper layer of blocksize. --- src/audio/bsd/SDL_bsdaudio.c.orig 2016-10-20 03:56:26.000000000 +0000 +++ src/audio/bsd/SDL_bsdaudio.c @@ -62,14 +62,14 @@ BSDAUDIO_Status(_THIS) #ifdef DEBUG_AUDIO /* *INDENT-OFF* */ audio_info_t info; - const audio_prinfo *prinfo; + const struct audio_prinfo *prinfo; if (ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info) < 0) { fprintf(stderr, "AUDIO_GETINFO failed.\n"); return; } - prinfo = this->iscapture ? &info.play : &info.record; + prinfo = this->iscapture ? &info.record : &info.play; fprintf(stderr, "\n" "[%s info]\n" @@ -190,10 +190,6 @@ BSDAUDIO_PlayDevice(_THIS) fprintf(stderr, "Wrote %d bytes of audio data\n", written); #endif - if (p < this->hidden->mixlen - || ((written < 0) && ((errno == 0) || (errno == EAGAIN)))) { - SDL_Delay(1); /* Let a little CPU time go by */ - } } while (p < this->hidden->mixlen); /* If timer synchronization is enabled, set the next write frame */ @@ -280,7 +276,7 @@ BSDAUDIO_OpenDevice(_THIS, void *handle, const int flags = iscapture ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT; SDL_AudioFormat format = 0; audio_info_t info; - audio_prinfo *prinfo = iscapture ? &info.play : &info.record; + struct audio_prinfo *prinfo = iscapture ? &info.record : &info.play; /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ @@ -372,6 +368,7 @@ BSDAUDIO_OpenDevice(_THIS, void *handle, (void) ioctl(this->hidden->audio_fd, AUDIO_SETINFO, &info); (void) ioctl(this->hidden->audio_fd, AUDIO_GETINFO, &info); this->spec.freq = prinfo->sample_rate; + this->spec.size = info.blocksize; if (!iscapture) { /* Allocate mixing buffer */
1d201777ff5a09529acc060f368355e9d8fcb9a9
5ab69c8644a936a3d9dec1669a86c7369c911bf8
/os/net/ipv6/uip-ds6-nbr.h
571a424472e7021c87a3bbece6381cb588ca99f3
[ "BSD-3-Clause" ]
permissive
contiki-ng/contiki-ng
393d36f68b98f5ee3544ea32502cf662ffb2fe9f
31fcaadf7a0dc8ceea07f438cd69db73174879e6
refs/heads/develop
2023-09-01T20:10:30.000765
2023-09-01T14:37:12
2023-09-01T14:37:12
91,191,972
1,242
788
BSD-3-Clause
2023-09-14T19:08:35
2017-05-13T17:37:59
C
UTF-8
C
false
false
8,985
h
uip-ds6-nbr.h
/* * Copyright (c) 2013, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the Institute 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 INSTITUTE 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 INSTITUTE 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. * * */ /** * \addtogroup uip * @{ */ /** * \file * IPv6 Neighbor cache (link-layer/IPv6 address mapping) * \author Mathilde Durvy <mdurvy@cisco.com> * \author Julien Abeille <jabeille@cisco.com> * \author Simon Duquennoy <simonduq@sics.se> * */ #ifndef UIP_DS6_NEIGHBOR_H_ #define UIP_DS6_NEIGHBOR_H_ #include "contiki.h" #include "net/ipv6/uip.h" #include "net/ipv6/uip-nd6.h" #include "net/nbr-table.h" #include "sys/stimer.h" #if UIP_CONF_IPV6_QUEUE_PKT #include "net/ipv6/uip-packetqueue.h" #endif /*UIP_CONF_QUEUE_PKT */ #if UIP_DS6_NBR_CONF_MULTI_IPV6_ADDRS #include "lib/assert.h" #include "lib/list.h" #endif /*--------------------------------------------------*/ /** \brief Possible states for the nbr cache entries */ #define NBR_INCOMPLETE 0 #define NBR_REACHABLE 1 #define NBR_STALE 2 #define NBR_DELAY 3 #define NBR_PROBE 4 /** \brief Set non-zero (1) to enable multiple IPv6 addresses to be * associated with a link-layer address */ #ifdef UIP_DS6_NBR_CONF_MULTI_IPV6_ADDRS #define UIP_DS6_NBR_MULTI_IPV6_ADDRS UIP_DS6_NBR_CONF_MULTI_IPV6_ADDRS #else #define UIP_DS6_NBR_MULTI_IPV6_ADDRS 0 #endif /* UIP_DS6_NBR_CONF_MULTI_IPV6_ADDRS */ /** \brief Set the maximum number of IPv6 addresses per link-layer * address */ #ifdef UIP_DS6_NBR_CONF_MAX_6ADDRS_PER_NBR #define UIP_DS6_NBR_MAX_6ADDRS_PER_NBR UIP_DS6_NBR_CONF_MAX_6ADDRS_PER_NBR #else #define UIP_DS6_NBR_MAX_6ADDRS_PER_NBR 2 #endif /* UIP_DS6_NBR_CONF_MAX_6ADDRS_PER_NBR */ /** \brief Set the maximum number of neighbor cache entries */ #ifdef UIP_DS6_NBR_CONF_MAX_NEIGHBOR_CACHES #define UIP_DS6_NBR_MAX_NEIGHBOR_CACHES UIP_DS6_NBR_CONF_MAX_NEIGHBOR_CACHES #else #define UIP_DS6_NBR_MAX_NEIGHBOR_CACHES \ (NBR_TABLE_MAX_NEIGHBORS * UIP_DS6_NBR_MAX_6ADDRS_PER_NBR) #endif /* UIP_DS6_NBR_CONF_MAX_NEIGHBOR_CACHES */ #if UIP_DS6_NBR_MULTI_IPV6_ADDRS /** \brief nbr_table entry when UIP_DS6_NBR_MULTI_IPV6_ADDRS is * enabled. uip_ds6_nbrs is a list of uip_ds6_nbr_t objects */ typedef struct { LIST_STRUCT(uip_ds6_nbrs); } uip_ds6_nbr_entry_t; #endif /* UIP_DS6_NBR_MULTI_IPV6_ADDRS */ /** \brief The default nbr_table entry (when * UIP_DS6_NBR_MULTI_IPV6_ADDRS is disabled), that implements nbr * cache */ typedef struct uip_ds6_nbr { #if UIP_DS6_NBR_MULTI_IPV6_ADDRS struct uip_ds6_nbr *next; uip_ds6_nbr_entry_t *nbr_entry; #endif /* UIP_DS6_NBR_MULTI_IPV6_ADDRS */ uip_ipaddr_t ipaddr; uint8_t isrouter; uint8_t state; #if UIP_ND6_SEND_NS || UIP_ND6_SEND_RA struct stimer reachable; struct stimer sendns; uint8_t nscount; #endif /* UIP_ND6_SEND_NS || UIP_ND6_SEND_RA */ #if UIP_CONF_IPV6_QUEUE_PKT struct uip_packetqueue_handle packethandle; #define UIP_DS6_NBR_PACKET_LIFETIME CLOCK_SECOND * 4 #endif /*UIP_CONF_QUEUE_PKT */ } uip_ds6_nbr_t; void uip_ds6_neighbors_init(void); /** * Add a neighbor cache for a specified IPv6 address, which is * associated with a specified link-layer address * \param ipaddr IPv6 address of a neighbor to add * \param lladdr Link-layer address to associate with ipaddr * \param isrouter Set 1 if the neighbor is a router * \param state Set the initial neighbor cache state (e.g., * NBR_INCOMPLETE) * \param reason Set a reason of the addition (e.g., * NBR_TABLE_REASON_RPL_DIO) * \param data Set data associated with the nbr cache * \return the address of a newly added nbr cache on success, NULL on * failure */ uip_ds6_nbr_t *uip_ds6_nbr_add(const uip_ipaddr_t *ipaddr, const uip_lladdr_t *lladdr, uint8_t isrouter, uint8_t state, nbr_table_reason_t reason, void *data); /** * Remove a neighbor cache * \param nbr the address of a neighbor cache to remove * \return 1 on success, 0 on failure (nothing was removed) */ int uip_ds6_nbr_rm(uip_ds6_nbr_t *nbr); /** * Get the link-layer address associated with a specified nbr cache * \param nbr the address of a neighbor cache * \return pointer to the link-layer address on success, NULL on failure */ const uip_lladdr_t *uip_ds6_nbr_get_ll(const uip_ds6_nbr_t *nbr); /** * Get the link-layer address associated with a specified IPv6 address * \param ipaddr an IPv6 address used as a search key * \return the pointer to the link-layer address on success, NULL on failure */ const uip_lladdr_t *uip_ds6_nbr_lladdr_from_ipaddr(const uip_ipaddr_t *ipaddr); /** * Update the link-layer address associated with an IPv6 address * \param nbr the double pointer to a neighbor cache which has the * target IPv6 address * \param new_ll_addr the new link-layer address of the IPv6 address * return 0 on success, -1 on failure */ int uip_ds6_nbr_update_ll(uip_ds6_nbr_t **nbr, const uip_lladdr_t *new_ll_addr); /** * Get an IPv6 address of a neighbor cache * \param nbr the pointer to a neighbor cache * \return the pointer to an IPv6 address associated with the neighbor cache * \note This returns the first IPv6 address found in the neighbor * cache when UIP_DS6_NBR_MULTI_IPV6_ADDRS is enabled */ const uip_ipaddr_t *uip_ds6_nbr_get_ipaddr(const uip_ds6_nbr_t *nbr); /** * Get an IPv6 address associated with a specified link-layer address * \param lladdr a link-layer address used as a search key * \return the pointer to an IPv6 address associated with the neighbor cache * \note This returns the first IPv6 address found in the neighbor * cache when UIP_DS6_NBR_MULTI_IPV6_ADDRS is enabled */ uip_ipaddr_t *uip_ds6_nbr_ipaddr_from_lladdr(const uip_lladdr_t *lladdr); /** * Get the neighbor cache associated with a specified IPv6 address * \param ipaddr an IPv6 address used as a search key * \return the pointer to a neighbor cache on success, NULL on failure */ uip_ds6_nbr_t *uip_ds6_nbr_lookup(const uip_ipaddr_t *ipaddr); /** * Get the neighbor cache associated with a specified link-layer address * \param lladdr a link-layer address used as a search key * \return the pointer to a neighbor cache on success, NULL on failure */ uip_ds6_nbr_t *uip_ds6_nbr_ll_lookup(const uip_lladdr_t *lladdr); /** * Return the number of neighbor caches * \return the number of neighbor caches in use */ int uip_ds6_nbr_num(void); /** * Get the first neighbor cache in nbr_table * \return the pointer to the first neighbor cache entry */ uip_ds6_nbr_t *uip_ds6_nbr_head(void); /** * Get the next neighbor cache of a specified one * \param nbr the pointer to a neighbor cache * \return the pointer to the next one on success, NULL on failure */ uip_ds6_nbr_t *uip_ds6_nbr_next(uip_ds6_nbr_t *nbr); /** * The callback function to update link-layer stats in a neighbor * cache * \param status MAC return value defined in mac.h * \param numtx the number of transmissions happened for a packet */ void uip_ds6_link_callback(int status, int numtx); /** * The housekeeping function called periodically */ void uip_ds6_neighbor_periodic(void); #if UIP_ND6_SEND_NS /** * \brief Refresh the reachable state of a neighbor. This function * may be called when a node receives an IPv6 message that confirms the * reachability of a neighbor. * \param ipaddr pointer to the IPv6 address whose neighbor reachability state * should be refreshed. */ void uip_ds6_nbr_refresh_reachable_state(const uip_ipaddr_t *ipaddr); #endif /* UIP_ND6_SEND_NS */ #endif /* UIP_DS6_NEIGHBOR_H_ */ /** @} */
f4cfe1080a1c0c54035c4d76c382e78b627a0e26
79d343002bb63a44f8ab0dbac0c9f4ec54078c3a
/lib/libc/wasi/libc-top-half/musl/src/stdio/__stdio_write.c
753730493f4859678df106d9b775ab306bab2106
[ "BSD-3-Clause", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-musl-exception", "MIT", "LLVM-exception", "Apache-2.0", "NCSA" ]
permissive
ziglang/zig
4aa75d8d3bcc9e39bf61d265fd84b7f005623fc5
f4c9e19bc3213c2bc7e03d7b06d7129882f39f6c
refs/heads/master
2023-08-31T13:16:45.980913
2023-08-31T05:50:29
2023-08-31T05:50:29
40,276,274
25,560
2,399
MIT
2023-09-14T21:09:50
2015-08-06T00:51:28
Zig
UTF-8
C
false
false
934
c
__stdio_write.c
#include "stdio_impl.h" #include <sys/uio.h> size_t __stdio_write(FILE *f, const unsigned char *buf, size_t len) { struct iovec iovs[2] = { { .iov_base = f->wbase, .iov_len = f->wpos-f->wbase }, { .iov_base = (void *)buf, .iov_len = len } }; struct iovec *iov = iovs; size_t rem = iov[0].iov_len + iov[1].iov_len; int iovcnt = 2; ssize_t cnt; for (;;) { #ifdef __wasilibc_unmodified_upstream // WASI has no syscall cnt = syscall(SYS_writev, f->fd, iov, iovcnt); #else cnt = writev(f->fd, iov, iovcnt); #endif if (cnt == rem) { f->wend = f->buf + f->buf_size; f->wpos = f->wbase = f->buf; return len; } if (cnt < 0) { f->wpos = f->wbase = f->wend = 0; f->flags |= F_ERR; return iovcnt == 2 ? 0 : len-iov[0].iov_len; } rem -= cnt; if (cnt > iov[0].iov_len) { cnt -= iov[0].iov_len; iov++; iovcnt--; } iov[0].iov_base = (char *)iov[0].iov_base + cnt; iov[0].iov_len -= cnt; } }
8b286da24513e92c702be807ef3675e2dffb20a9
e57ee8514fc880f38ca8aa6e599e8b942dbc2c7e
/src/backend/paths.h
e26d04eca01adc1123b81762d6a6bcea8b33a39d
[ "Apache-2.0" ]
permissive
chiragsakhuja/lc3tools
4976c72084af496ffad7ad058117fa770b3c734b
74d5e971506716c0979e21c3a06d228fbb719a94
refs/heads/master
2022-10-26T11:28:05.483024
2022-02-27T00:02:36
2022-02-27T00:02:36
37,239,973
108
34
Apache-2.0
2022-10-10T17:53:35
2015-06-11T04:52:33
C++
UTF-8
C
false
false
276
h
paths.h
/* * Copyright 2020 McGraw-Hill Education. All rights reserved. No reproduction or distribution without the prior written consent of McGraw-Hill Education. */ #ifndef PATHS_H #define PATHS_H #define GLOBAL_RES_PATH "@ResPath@" #define GLOBAL_TEST_PATH "@TestPath@" #endif
24691252b1e0c2d6c3d7fef27ee6dd41741bf155
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/arm/mach-w90x900/include/mach/regs-gcr.h
6087abd93ef5fb52ccc7e55fc121837b1dba7087
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
1,141
h
regs-gcr.h
/* * arch/arm/mach-w90x900/include/mach/regs-gcr.h * * Copyright (c) 2010 Nuvoton technology corporation * All rights reserved. * * Wan ZongShun <mcuos.com@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ #ifndef __ASM_ARCH_REGS_GCR_H #define __ASM_ARCH_REGS_GCR_H /* Global control registers */ #define GCR_BA W90X900_VA_GCR #define REG_PDID (GCR_BA+0x000) #define REG_PWRON (GCR_BA+0x004) #define REG_ARBCON (GCR_BA+0x008) #define REG_MFSEL (GCR_BA+0x00C) #define REG_EBIDPE (GCR_BA+0x010) #define REG_LCDDPE (GCR_BA+0x014) #define REG_GPIOCPE (GCR_BA+0x018) #define REG_GPIODPE (GCR_BA+0x01C) #define REG_GPIOEPE (GCR_BA+0x020) #define REG_GPIOFPE (GCR_BA+0x024) #define REG_GPIOGPE (GCR_BA+0x028) #define REG_GPIOHPE (GCR_BA+0x02C) #define REG_GPIOIPE (GCR_BA+0x030) #define REG_GTMP1 (GCR_BA+0x034) #define REG_GTMP2 (GCR_BA+0x038) #define REG_GTMP3 (GCR_BA+0x03C) #endif /* __ASM_ARCH_REGS_GCR_H */
79331f25b08c6e9b4d2182ff11f6d4cc23e6837a
99bdb3251fecee538e0630f15f6574054dfc1468
/bsp/Infineon/libraries/IFX_PSOC6_HAL/mtb-pdl-cat1/drivers/include/cy_smartio.h
375b478e265c03c2a4162321e1d20e39ad122e35
[ "Apache-2.0", "Zlib", "LicenseRef-scancode-proprietary-license", "MIT", "BSD-3-Clause", "X11", "BSD-4-Clause-UC", "LicenseRef-scancode-unknown-license-reference", "LicenseRef-scancode-warranty-disclaimer", "GPL-1.0-or-later" ]
permissive
RT-Thread/rt-thread
03a7c52c2aeb1b06a544143b0e803d72f47d1ece
3602f891211904a27dcbd51e5ba72fefce7326b2
refs/heads/master
2023-09-01T04:10:20.295801
2023-08-31T16:20:55
2023-08-31T16:20:55
7,408,108
9,599
5,805
Apache-2.0
2023-09-14T13:37:26
2013-01-02T14:49:21
C
UTF-8
C
false
false
35,712
h
cy_smartio.h
/***************************************************************************//** * \file cy_smartio.h * \version 1.0.2 * * \brief * Provides an API declaration of the Smart I/O driver * ******************************************************************************** * \copyright * Copyright 2018-2020 Cypress Semiconductor Corporation * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *******************************************************************************/ /** * \addtogroup group_smartio * \{ * The Smart I/O driver provides an API to configure and access the Smart I/O hardware * present between the GPIOs (pins) and HSIOMs (pin muxes) on select device ports. * * The functions and other declarations used in this driver are in cy_smartio.h. * You can include cy_pdl.h to get access to all functions * and declarations in the PDL. * * It can be used to perform simple logic operations on peripheral and GPIO signals at * the GPIO port. Features include, * * 1. Purely combinatorial logic using 8 Look-Up Tables (LUT). * 2. Mixed sequential and combinatorial logic using 8 LUTs and 1 Data Unit (DU). * 3. Counters and shift registers using 8-bit multi-function DU (simplified ALU). * 4. Operational in device active, sleep and deep-sleep power modes. * * \section group_smartio_configuration Configuration Considerations * * \subsection group_smartio_routing_fabric Routing Fabric * * The Smart I/O routing fabric is divided into two portions, where each portion is capable * of accepting half of the data or GPIO signals. The LUTs have the following structure. * * - LUT 7...4 are capable of accepting signals from io/chip 7...4 as inputs. * - LUT 3...0 are capable of accepting signals from io/chip 3...0 as inputs. * - The LUTs can accept any LUT output as an input. * - Each LUT output is dedicated to the corresponding output io/chip terminal. For * example, LUT 0 can go to either io0 terminal output or chip0 terminal output or both. * * \subsection group_smartio_single_lut Single Source LUT Input * * If a LUT is used, all three inputs to the LUT must be designated. For example, even If a LUT is * used to accept a single source as its input, all three inputs must accept that same signal. The * lookup table should then be designed such that it only changes the output value when all * three inputs satisfy the same condition. For example, consider the case where the signal on * data0 must be inverted before being passed to io0. LUT0 accepts chip0 as input 0, 1 and 2. * The truth table is defined such that it outputs a logic 1 only when the inputs are all 0. * * \subsection group_smartio_clk_rst Clock and Reset Behavior * * The Smart I/O hardware drives its synchronous elements using a single clock source. * Depending on the clock source, the Smart I/O will have different reset behaviors, which * will reset all the flip-flops in the LUTs and synchronizers to logic 0. The configuration * registers will retain their values unless coming out of Power on Reset (POR). Notes: * * - If the block is only disabled, the values in the LUT flip-flips and I/O synchronizers are * held as long as the chip remains in a valid power mode. * - The selected clock for the fabric's synchronous logic is not phase aligned with other * synchronous logic on the chip operating on the same clock. Therefore, communication between * the Smart I/O and other synchronous logic should be treated as asynchronous (just as the * communication between I/O input signals and other synchronous logic should be treated as * asynchronous) * * <table class="doxtable"> * <tr> * <th>Clock Source</th> * <th>Reset Behavior</th> * <th>Enable Delay</th> * <th>Description</th> * </tr> * <tr> * <td>io/chip 7...0</td> * <td>Reset on POR</td> * <td>2 clock edges</td> * <td>If chosen as the clock source, that particular signal cannot also be used as an input * to a LUT as it may cause a race condition. The fabric will be enabled after 2 clock * edges of the signal on the gpio terminal.</td> * </tr> * <tr> * <td>Divided Clock (Active)</td> * <td>Reset when going to Deep Sleep, Hibernate or POR</td> * <td>2 clock edges</td> * <td>The fabric will be enabled after 2 clock edges of the divided clock. Any synchronous * logic in the LUTs will be reset to 0 when in chip deep-sleep or hibernate modes.</td> * </tr> * <tr> * <td>Divided Clock (Deep-Sleep)</td> * <td>Reset when going to Hibernate or POR</td> * <td>2 clock edges</td> * <td>The fabric will be enabled after 2 clock edges of the divided clock. Any synchronous * logic in the LUTs will be reset to 0 when in hibernate mode.</td> * </tr> * <tr> * <td>Divided Clock (Hibernate)</td> * <td>Reset on POR</td> * <td>2 clock edges</td> * <td>The fabric will be enabled after 2 clock edges of the divided clock.</td> * </tr> * <tr> * <td>LFCLK</td> * <td>Reset when going to Hibernate and POR</td> * <td>2 clock edges</td> * <td>The fabric will be enabled after 2 clock edges of the low frequency clock (LFCLK). * Any synchronous logic in the LUTs will be reset to 0 when in hibernate mode.</td> * </tr> * <tr> * <td>Asynchronous</td> * <td>Reset on POR</td> * <td>3 clock edges of SYSCLK</td> * <td>The fabric will be enabled after 3 clock edges of the clk_peri source.</td> * </tr> * </table> * * \subsection group_smartio_sync_req Signal Synchronization Requirement * * If any of the signals coming in through the Smart I/O terminals are meant to be used * in sequential elements in the LUTs, the terminal synchronizer must first be used to synchronize * that signal to the Component clock. For example, if the signal on io0 must be used in LUT0 in * Sequential output mode, the synchronization for io0 terminal should be enabled for reliable * operation. * * \subsection group_smartio_comb_feedback LUT Combinatorial Feedback * * Since the LUTs can be configured as purely (or partially) combinatorial elements and since they * can chain to each other in any fashion, combinatorial timing loops can occur. This causes * oscillations that burn power and create unpredictable behavior. If a feedback is required, the * signals should always go through a flip-flop before feeding back. For example, the following is a * potentially problematic design; LUT1 and LUT2 are configured in combinatorial mode, where their * respective outputs feed into the inputs of the other. This will result in oscillations. * To prevent it, one of the LUTs should be configured to Gated Output mode. * * \subsection group_smartio_lpm Low Power Mode * * The Smart I/O hardware is capable of operating during chip Deep-Sleep mode. The block has * the following requirements when operating in this mode: * * - All sequential elements must be clocked by a valid clock in these power domains. Refer to * \ref group_smartio_clk_rst for more details. * - All signals in the block (including the clock) must be less than 1 MHz when in Deep-Sleep * mode. * - The hold override functionality should be enabled when entering Deep-Sleep mode. * This functionality should then be disabled when the chip is not in this mode. * * \section group_smartio_more_information More Information * * Refer to the technical reference manual (TRM) and the device datasheet. * * \section group_smartio_changelog Changelog * <table class="doxtable"> * <tr><th>Version</th><th>Changes</th><th>Reason for Change</th></tr> * <tr> * <td>1.0.2</td> * <td>Documented MISRA 2012 violations.</td> * <td>MISRA 2012 compliance.</td> * </tr> * <tr> * <td>1.0.1</td> * <td>Minor documentation updates.</td> * <td>Documentation enhancement.</td> * </tr> * <tr> * <td>1.0</td> * <td>The initial version.</td> * <td></td> * </tr> * </table> * * \defgroup group_smartio_macros Macros * \defgroup group_smartio_functions Functions * \{ * \defgroup group_smartio_functions_init Initialization Functions * \defgroup group_smartio_functions_general General Functions * \defgroup group_smartio_functions_lut LUT Functions * \defgroup group_smartio_functions_du Data Unit Functions * \} * \defgroup group_smartio_data_structures Data Structures * \defgroup group_smartio_enums Enumerated Types */ #if !defined(CY_SMARTIO_H) #define CY_SMARTIO_H #include "cy_device.h" #if (defined (CY_IP_MXS40IOSS) || (defined(CY_IP_MXS40SIOSS) && defined(SMARTIO_BASE)) || defined(CY_IP_MXS22IOSS)) #include <stdbool.h> #include <stddef.h> #include "cy_syslib.h" #if defined(__cplusplus) extern "C" { #endif CY_MISRA_DEVIATE_BLOCK_START('MISRA C-2012 Rule 10.8', 12, \ 'Value extracted from _FLD2VAL macro will not exceed enum range.'); /** \addtogroup group_smartio_macros * \{ */ /** Driver major version */ #define CY_SMARTIO_DRV_VERSION_MAJOR 1 /** Driver minor version */ #define CY_SMARTIO_DRV_VERSION_MINOR 0 /** SmartIO driver ID */ #define CY_SMARTIO_ID CY_PDL_DRV_ID(0x42u) /** * \defgroup group_smartio_channels Smart I/O channel selection * \{ * Constants for selecting the Smart I/O channels */ #define CY_SMARTIO_CHANNEL_NONE 0x00u /**< No channels */ #define CY_SMARTIO_CHANNEL0 0x01u /**< Channel 0 (chip0 <-> io0) */ #define CY_SMARTIO_CHANNEL1 0x02u /**< Channel 1 (chip1 <-> io1) */ #define CY_SMARTIO_CHANNEL2 0x04u /**< Channel 2 (chip2 <-> io2) */ #define CY_SMARTIO_CHANNEL3 0x08u /**< Channel 3 (chip3 <-> io3) */ #define CY_SMARTIO_CHANNEL4 0x10u /**< Channel 4 (chip4 <-> io4) */ #define CY_SMARTIO_CHANNEL5 0x20u /**< Channel 5 (chip5 <-> io5) */ #define CY_SMARTIO_CHANNEL6 0x40u /**< Channel 6 (chip6 <-> io6) */ #define CY_SMARTIO_CHANNEL7 0x80u /**< Channel 7 (chip7 <-> io7) */ #define CY_SMARTIO_CHANNEL_ALL 0xffu /**< All channels */ /** \} */ /** \} group_smartio_macros */ /*************************************** * Constants ***************************************/ /** \cond INTERNAL */ #define CY_SMARTIO_ENABLE 1UL #define CY_SMARTIO_DISABLE 0UL #define CY_SMARTIO_DEINIT 0UL #define CY_SMARTIO_LUTMAX 8u /** \endcond */ /*************************************** * Enumerations ***************************************/ /** * \addtogroup group_smartio_enums * \{ */ /** * Smart I/O driver error codes */ typedef enum { CY_SMARTIO_SUCCESS = 0x00u, /**< Returned successful */ CY_SMARTIO_BAD_PARAM = CY_SMARTIO_ID | CY_PDL_STATUS_ERROR | 0x01u, /**< Bad parameter was passed */ CY_SMARTIO_LOCKED = CY_SMARTIO_ID | CY_PDL_STATUS_ERROR | 0x02u, /**< Smart I/O is not disabled */ } cy_en_smartio_status_t; /** * Smart I/O clock selection */ typedef enum { CY_SMARTIO_CLK_IO0 = 0, /**< Clock sourced from signal on io0 */ CY_SMARTIO_CLK_IO1 = 1, /**< Clock sourced from signal on io1 */ CY_SMARTIO_CLK_IO2 = 2, /**< Clock sourced from signal on io2 */ CY_SMARTIO_CLK_IO3 = 3, /**< Clock sourced from signal on io3 */ CY_SMARTIO_CLK_IO4 = 4, /**< Clock sourced from signal on io4 */ CY_SMARTIO_CLK_IO5 = 5, /**< Clock sourced from signal on io5 */ CY_SMARTIO_CLK_IO6 = 6, /**< Clock sourced from signal on io6 */ CY_SMARTIO_CLK_IO7 = 7, /**< Clock sourced from signal on io7 */ CY_SMARTIO_CLK_CHIP0 = 8, /**< Clock sourced from signal on chip0 */ CY_SMARTIO_CLK_CHIP1 = 9, /**< Clock sourced from signal on chip1 */ CY_SMARTIO_CLK_CHIP2 = 10, /**< Clock sourced from signal on chip2 */ CY_SMARTIO_CLK_CHIP3 = 11, /**< Clock sourced from signal on chip3 */ CY_SMARTIO_CLK_CHIP4 = 12, /**< Clock sourced from signal on chip4 */ CY_SMARTIO_CLK_CHIP5 = 13, /**< Clock sourced from signal on chip5 */ CY_SMARTIO_CLK_CHIP6 = 14, /**< Clock sourced from signal on chip6 */ CY_SMARTIO_CLK_CHIP7 = 15, /**< Clock sourced from signal on chip7 */ CY_SMARTIO_CLK_DIVACT = 16, /**< Clock sourced from a peripheral clock divider (Active) */ CY_SMARTIO_CLK_DIVDS = 17, /**< Clock sourced from a peripheral clock divider (Deep-Sleep) */ CY_SMARTIO_CLK_DIVHIB = 18, /**< Clock sourced from a peripheral clock divider (Hibernate) */ CY_SMARTIO_CLK_LFCLK = 19, /**< Clock sourced from LFCLK */ CY_SMARTIO_CLK_GATED = 20, /**< Disables the clock. Used when turning off the block */ CY_SMARTIO_CLK_ASYNC = 31, /**< Asynchronous operation (only allow combinatorial logic) */ }cy_en_smartio_clksrc_t; /** * Smart I/O LUT number */ typedef enum { CY_SMARTIO_LUT0 = 0, /**< Look-Up-Table #0 */ CY_SMARTIO_LUT1 = 1, /**< Look-Up-Table #1 */ CY_SMARTIO_LUT2 = 2, /**< Look-Up-Table #2 */ CY_SMARTIO_LUT3 = 3, /**< Look-Up-Table #3 */ CY_SMARTIO_LUT4 = 4, /**< Look-Up-Table #4 */ CY_SMARTIO_LUT5 = 5, /**< Look-Up-Table #5 */ CY_SMARTIO_LUT6 = 6, /**< Look-Up-Table #6 */ CY_SMARTIO_LUT7 = 7, /**< Look-Up-Table #7 */ }cy_en_smartio_lutnum_t; /** * Smart I/O input trigger number */ typedef enum { CY_SMARTIO_TR0 = 0, /**< Input trigger #0 */ CY_SMARTIO_TR1 = 1, /**< Input trigger #1 */ CY_SMARTIO_TR2 = 2, /**< Input trigger #2 */ }cy_en_smartio_trnum_t; /** * Smart I/O Data Unit's input "DATA" number */ typedef enum { CY_SMARTIO_DATA0 = 0, /**< Input DATA #0 */ CY_SMARTIO_DATA1 = 1, /**< Input DATA #1 */ }cy_en_smartio_datanum_t; /** * Smart I/O LUT input trigger source */ typedef enum { CY_SMARTIO_LUTTR_DU_OUT = 0, /**< Data Unit output */ CY_SMARTIO_LUTTR_LUT0_OUT = 0, /**< LUT0 output */ CY_SMARTIO_LUTTR_LUT1_OUT = 1, /**< LUT1 output */ CY_SMARTIO_LUTTR_LUT2_OUT = 2, /**< LUT2 output */ CY_SMARTIO_LUTTR_LUT3_OUT = 3, /**< LUT3 output */ CY_SMARTIO_LUTTR_LUT4_OUT = 4, /**< LUT4 output */ CY_SMARTIO_LUTTR_LUT5_OUT = 5, /**< LUT5 output */ CY_SMARTIO_LUTTR_LUT6_OUT = 6, /**< LUT6 output */ CY_SMARTIO_LUTTR_LUT7_OUT = 7, /**< LUT7 output */ CY_SMARTIO_LUTTR_CHIP0 = 8, /**< Chip signal 0 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_CHIP4 = 8, /**< Chip signal 4 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_CHIP1 = 9, /**< Chip signal 1 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_CHIP5 = 9, /**< Chip signal 5 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_CHIP2 = 10, /**< Chip signal 2 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_CHIP6 = 10, /**< Chip signal 6 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_CHIP3 = 11, /**< Chip signal 3 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_CHIP7 = 11, /**< Chip signal 7 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_IO0 = 12, /**< I/O signal 0 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_IO4 = 12, /**< I/O signal 4 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_IO1 = 13, /**< I/O signal 1 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_IO5 = 13, /**< I/O signal 5 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_IO2 = 14, /**< I/O signal 2 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_IO6 = 14, /**< I/O signal 6 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_IO3 = 15, /**< I/O signal 3 (for LUT 0,1,2,3) */ CY_SMARTIO_LUTTR_IO7 = 15, /**< I/O signal 7 (for LUT 4,5,6,7) */ CY_SMARTIO_LUTTR_INVALID = 255, /**< Invalid input trigger selection */ }cy_en_smartio_luttr_t; /** * Smart I/O LUT opcode */ typedef enum { CY_SMARTIO_LUTOPC_COMB = 0, /**< Combinatorial output */ CY_SMARTIO_LUTOPC_GATED_TR2 = 1, /**< TR2 gated, Combinatorial output */ CY_SMARTIO_LUTOPC_GATED_OUT = 2, /**< Sequential (gated) output */ CY_SMARTIO_LUTOPC_ASYNC_SR = 3, /**< Asynchronous Set/Reset mode */ }cy_en_smartio_lutopc_t; /** * Smart I/O Data Unit input trigger source */ typedef enum { CY_SMARTIO_DUTR_ZERO = 0, /**< Constant 0 */ CY_SMARTIO_DUTR_ONE = 1, /**< Constant 1 */ CY_SMARTIO_DUTR_DU_OUT = 2, /**< Data Unit output */ CY_SMARTIO_DUTR_LUT0_OUT = 3, /**< LUT0 output */ CY_SMARTIO_DUTR_LUT1_OUT = 4, /**< LUT1 output */ CY_SMARTIO_DUTR_LUT2_OUT = 5, /**< LUT2 output */ CY_SMARTIO_DUTR_LUT3_OUT = 6, /**< LUT3 output */ CY_SMARTIO_DUTR_LUT4_OUT = 7, /**< LUT4 output */ CY_SMARTIO_DUTR_LUT5_OUT = 8, /**< LUT5 output */ CY_SMARTIO_DUTR_LUT6_OUT = 9, /**< LUT6 output */ CY_SMARTIO_DUTR_LUT7_OUT = 10, /**< LUT7 output */ CY_SMARTIO_DUTR_INVALID = 255, /**< Invalid input trigger selected */ }cy_en_smartio_dutr_t; /** * Smart I/O Data Unit input "DATA" source */ typedef enum { CY_SMARTIO_DUDATA_ZERO = 0, /**< Constant 0 */ CY_SMARTIO_DUDATA_CHIP = 1, /**< Chip signal [7:0] */ CY_SMARTIO_DUDATA_IO = 2, /**< I/O signal [7:0] */ CY_SMARTIO_DUDATA_DATAREG = 3, /**< SMARTIO.DATA register */ }cy_en_smartio_dudata_t; /** * Smart I/O Data Unit opcode */ typedef enum { CY_SMARTIO_DUOPC_INCR = 1, /**< Increment (Count up) */ CY_SMARTIO_DUOPC_DECR = 2, /**< Decrement (Count down) */ CY_SMARTIO_DUOPC_INCR_WRAP = 3, /**< Increment and wrap-around (Count up and wrap) */ CY_SMARTIO_DUOPC_DECR_WRAP = 4, /**< Decrement and wrap-around (Count down and wrap) */ CY_SMARTIO_DUOPC_INCR_DECR = 5, /**< Increment or decrement (Count up/down) */ CY_SMARTIO_DUOPC_INCR_DECR_WRAP = 6, /**< Increment or decrement with wrap-around (Count up/down and wrap) */ CY_SMARTIO_DUOPC_ROR = 7, /**< Rotate right (shift right and wrap) */ CY_SMARTIO_DUOPC_SHR = 8, /**< Shift right and shift data in through MSB */ CY_SMARTIO_DUOPC_AND_OR = 9, /**< out = ((DATA0 & DATA1) == 0) ? 0 : 1 */ CY_SMARTIO_DUOPC_SHR_MAJ3 = 10, /**< Majority 3 (Check if 2 out of 3 LSB bits are logic 1) */ CY_SMARTIO_DUOPC_SHR_EQL = 11, /**< Check for equality against DATA1. Also perform Shift right */ }cy_en_smartio_duopc_t; /** * Smart I/O Data Unit operation bit size */ typedef enum { CY_SMARTIO_DUSIZE_1 = 0, /**< 1-bit size/width operand */ CY_SMARTIO_DUSIZE_2 = 1, /**< 2-bits size/width operand */ CY_SMARTIO_DUSIZE_3 = 2, /**< 3-bits size/width operand */ CY_SMARTIO_DUSIZE_4 = 3, /**< 4-bits size/width operand */ CY_SMARTIO_DUSIZE_5 = 4, /**< 5-bits size/width operand */ CY_SMARTIO_DUSIZE_6 = 5, /**< 6-bits size/width operand */ CY_SMARTIO_DUSIZE_7 = 6, /**< 7-bits size/width operand */ CY_SMARTIO_DUSIZE_8 = 7, /**< 8-bits size/width operand */ }cy_en_smartio_dusize_t; /** \} group_smartio_enums */ /*************************************** * Configuration Structures ***************************************/ /** * \addtogroup group_smartio_data_structures * \{ */ /** LUT configuration structure */ typedef struct { cy_en_smartio_luttr_t tr0; /**< LUT input trigger 0 source selection */ cy_en_smartio_luttr_t tr1; /**< LUT input trigger 1 source selection */ cy_en_smartio_luttr_t tr2; /**< LUT input trigger 2 source selection */ cy_en_smartio_lutopc_t opcode; /**< LUT Opcode */ uint8_t lutMap; /**< LUT output mapping */ }cy_stc_smartio_lutcfg_t; /** Data Unit (DU) configuration structure */ typedef struct { cy_en_smartio_dutr_t tr0; /**< DU input trigger 0 source selection */ cy_en_smartio_dutr_t tr1; /**< DU input trigger 1 source selection */ cy_en_smartio_dutr_t tr2; /**< DU input trigger 2 source selection */ cy_en_smartio_dudata_t data0; /**< DU input DATA0 source selection */ cy_en_smartio_dudata_t data1; /**< DU input DATA1 source selection */ cy_en_smartio_duopc_t opcode; /**< DU op-code */ cy_en_smartio_dusize_t size; /**< DU operation bit size */ uint8_t dataReg; /**< DU DATA register value */ }cy_stc_smartio_ducfg_t; /** Smart I/O configuration structure */ typedef struct { cy_en_smartio_clksrc_t clkSrc; /**< Smart I/O instance clock source */ uint8_t bypassMask; /**< Smart I/O io<->chip channel bypass mask */ uint8_t ioSyncEn; /**< Synchronization enable/disable for I/O terminals */ uint8_t chipSyncEn; /**< Synchronization enable/disable for Chip terminals */ const cy_stc_smartio_lutcfg_t* lutCfg0; /**< Pointer to LUT0 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg1; /**< Pointer to LUT1 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg2; /**< Pointer to LUT2 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg3; /**< Pointer to LUT3 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg4; /**< Pointer to LUT4 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg5; /**< Pointer to LUT5 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg6; /**< Pointer to LUT6 configuration (NULL if not used) */ const cy_stc_smartio_lutcfg_t* lutCfg7; /**< Pointer to LUT7 configuration (NULL if not used) */ const cy_stc_smartio_ducfg_t* duCfg; /**< Pointer to Data Unit configuration (NULL if not used) */ bool hldOvr; /**< Hold override enable (true) / disable (false) */ }cy_stc_smartio_config_t; /** \} group_smartio_data_structures */ /*************************************** * Function Prototypes ***************************************/ /** * \addtogroup group_smartio_functions * \{ */ /** * \addtogroup group_smartio_functions_init * \{ */ cy_en_smartio_status_t Cy_SmartIO_Init(SMARTIO_PRT_Type* base, const cy_stc_smartio_config_t* config); void Cy_SmartIO_Deinit(SMARTIO_PRT_Type* base); void Cy_SmartIO_Enable(SMARTIO_PRT_Type* base); void Cy_SmartIO_Disable(SMARTIO_PRT_Type* base); /** \} group_smartio_functions_init */ /** * \addtogroup group_smartio_functions_general * \{ */ __STATIC_INLINE uint8_t Cy_SmartIO_GetChBypass(SMARTIO_PRT_Type* base); cy_en_smartio_status_t Cy_SmartIO_SetChBypass(SMARTIO_PRT_Type* base, uint8_t bypassMask); __STATIC_INLINE cy_en_smartio_clksrc_t Cy_SmartIO_GetClock(SMARTIO_PRT_Type* base); cy_en_smartio_status_t Cy_SmartIO_SetClock(SMARTIO_PRT_Type* base, cy_en_smartio_clksrc_t clkSrc); __STATIC_INLINE uint8_t Cy_SmartIO_GetIoSync(SMARTIO_PRT_Type* base); cy_en_smartio_status_t Cy_SmartIO_SetIoSync(SMARTIO_PRT_Type* base, uint8_t ioSyncEn); __STATIC_INLINE uint8_t Cy_SmartIO_GetChipSync(SMARTIO_PRT_Type* base); cy_en_smartio_status_t Cy_SmartIO_SetChipSync(SMARTIO_PRT_Type* base, uint8_t chipSyncEn); cy_en_smartio_status_t Cy_SmartIO_HoldOverride(SMARTIO_PRT_Type* base, bool hldOvr); /** \} group_smartio_functions_general */ /** * \addtogroup group_smartio_functions_lut * \{ */ cy_en_smartio_luttr_t Cy_SmartIO_GetLutTr(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_trnum_t trNum); cy_en_smartio_status_t Cy_SmartIO_SetLutTr(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_trnum_t trNum, cy_en_smartio_luttr_t trSrc); cy_en_smartio_status_t Cy_SmartIO_SetLutTrAll(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_luttr_t trSrc); __STATIC_INLINE cy_en_smartio_lutopc_t Cy_SmartIO_GetLutOpcode(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum); cy_en_smartio_status_t Cy_SmartIO_SetLutOpcode(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, cy_en_smartio_lutopc_t opcode); __STATIC_INLINE uint8_t Cy_SmartIO_GetLutMap(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum); cy_en_smartio_status_t Cy_SmartIO_SetLutMap(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum, uint8_t lutMap); /** \} group_smartio_functions_lut */ /** * \addtogroup group_smartio_functions_du * \{ */ cy_en_smartio_dutr_t Cy_SmartIO_GetDuTr(SMARTIO_PRT_Type* base, cy_en_smartio_trnum_t trNum); cy_en_smartio_status_t Cy_SmartIO_SetDuTr(SMARTIO_PRT_Type* base, cy_en_smartio_trnum_t trNum, cy_en_smartio_dutr_t trSrc); cy_en_smartio_status_t Cy_SmartIO_SetDuTrAll(SMARTIO_PRT_Type* base, cy_en_smartio_dutr_t trSrc); __STATIC_INLINE cy_en_smartio_dudata_t Cy_SmartIO_GetDuData(SMARTIO_PRT_Type* base, cy_en_smartio_datanum_t dataNum); cy_en_smartio_status_t Cy_SmartIO_SetDuData(SMARTIO_PRT_Type* base, cy_en_smartio_datanum_t dataNum, cy_en_smartio_dudata_t dataSrc); __STATIC_INLINE cy_en_smartio_duopc_t Cy_SmartIO_GetDuOpc(SMARTIO_PRT_Type* base); __STATIC_INLINE cy_en_smartio_dusize_t Cy_SmartIO_GetDuSize(SMARTIO_PRT_Type* base); cy_en_smartio_status_t Cy_SmartIO_SetDuOperation(SMARTIO_PRT_Type* base, cy_en_smartio_duopc_t opcode, cy_en_smartio_dusize_t size); __STATIC_INLINE uint8_t Cy_SmartIO_GetDataReg(SMARTIO_PRT_Type* base); cy_en_smartio_status_t Cy_SmartIO_SetDataReg(SMARTIO_PRT_Type* base, uint8_t dataReg); /** \} group_smartio_functions_du */ /*************************************** * Functions ***************************************/ /** * \addtogroup group_smartio_functions_general * \{ */ /******************************************************************************* * Function Name: Cy_SmartIO_GetChBypass ****************************************************************************//** * * \brief Gets the bypass/route state of all 8 channels in the Smart I/O * * <table class="doxtable"> * <tr><th>Bypass bit</th><th> Channel </th></tr> * <tr><td> 0 </td><td> io0<->chip0 </td></tr> * <tr><td> 1 </td><td> io1<->chip1 </td></tr> * <tr><td> 2 </td><td> io2<->chip2 </td></tr> * <tr><td> 3 </td><td> io3<->chip3 </td></tr> * <tr><td> 4 </td><td> io4<->chip4 </td></tr> * <tr><td> 5 </td><td> io5<->chip5 </td></tr> * <tr><td> 6 </td><td> io6<->chip6 </td></tr> * <tr><td> 7 </td><td> io7<->chip7 </td></tr> * </table> * * \param base * Pointer to the Smart I/O base address * * \return * Bypass/Route state of 8 io<->chip channels (bits [7:0]): 1=bypass, 0=routed. * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetChBypass * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_SmartIO_GetChBypass(SMARTIO_PRT_Type* base) { return((uint8_t)_FLD2VAL(SMARTIO_PRT_CTL_BYPASS, SMARTIO_PRT_CTL(base))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetClock ****************************************************************************//** * * \brief Gets the clock source of the Smart I/O. * * \param base * Pointer to the Smart I/O base address * * \return * Clock source * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetClock * *******************************************************************************/ __STATIC_INLINE cy_en_smartio_clksrc_t Cy_SmartIO_GetClock(SMARTIO_PRT_Type* base) { return((cy_en_smartio_clksrc_t)_FLD2VAL(SMARTIO_PRT_CTL_CLOCK_SRC, SMARTIO_PRT_CTL(base))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetIoSync ****************************************************************************//** * * \brief Gets the synchronization mode of the 8 I/O terminals. * * <table class="doxtable"> * <tr><th> Sync bit </th><th> I/O terminal </th></tr> * <tr><td> 0 </td><td> io0 </td></tr> * <tr><td> 1 </td><td> io1 </td></tr> * <tr><td> 2 </td><td> io2 </td></tr> * <tr><td> 3 </td><td> io3 </td></tr> * <tr><td> 4 </td><td> io4 </td></tr> * <tr><td> 5 </td><td> io5 </td></tr> * <tr><td> 6 </td><td> io6 </td></tr> * <tr><td> 7 </td><td> io7 </td></tr> * </table> * * \param base * Pointer to the Smart I/O base address * * \return * Sync mode of 8 I/O terminals (bits [7:0]): 1=sync, 0=no sync. * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetIoSync * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_SmartIO_GetIoSync(SMARTIO_PRT_Type* base) { return((uint8_t)_FLD2VAL(SMARTIO_PRT_SYNC_CTL_IO_SYNC_EN, SMARTIO_PRT_SYNC_CTL(base))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetChipSync ****************************************************************************//** * * \brief Gets the synchronization mode of the 8 chip-side terminals. * * <table class="doxtable"> * <tr><th> Sync bit </th><th> chip terminal </th></tr> * <tr><td> 0 </td><td> chip0 </td></tr> * <tr><td> 1 </td><td> chip1 </td></tr> * <tr><td> 2 </td><td> chip2 </td></tr> * <tr><td> 3 </td><td> chip3 </td></tr> * <tr><td> 4 </td><td> chip4 </td></tr> * <tr><td> 5 </td><td> chip5 </td></tr> * <tr><td> 6 </td><td> chip6 </td></tr> * <tr><td> 7 </td><td> chip7 </td></tr> * </table> * * \param base * Pointer to the Smart I/O base address * * \return * Sync mode of 8 chip-side terminals (bits [7:0]): 1=sync, 0=no sync. * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetChipSync * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_SmartIO_GetChipSync(SMARTIO_PRT_Type* base) { return((uint8_t)_FLD2VAL(SMARTIO_PRT_SYNC_CTL_CHIP_SYNC_EN, SMARTIO_PRT_SYNC_CTL(base))); } /** \} group_smartio_functions_general */ /** * \addtogroup group_smartio_functions_lut * \{ */ /******************************************************************************* * Function Name: Cy_SmartIO_GetLutOpcode ****************************************************************************//** * * \brief Gets the opcode of the specified LUT. * * \param base * Pointer to the Smart I/O base address * * \param lutNum * LUT index number * * \return * LUT opcode * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetLutOpcode * *******************************************************************************/ __STATIC_INLINE cy_en_smartio_lutopc_t Cy_SmartIO_GetLutOpcode(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum) { return((cy_en_smartio_lutopc_t)(_FLD2VAL(SMARTIO_PRT_LUT_CTL_LUT_OPC, SMARTIO_PRT_LUT_CTL(base, lutNum)))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetLutMap ****************************************************************************//** * * \brief Gets the 3:1 truth table of the specified LUT. * * <table class="doxtable"> * <tr><th>tr2</th><th>tr1</th><th>tr0</th><th>lutNum</th></tr> * <tr><td> 0 </td><td> 0 </td><td> 0 </td><td> bit 0 </td></tr> * <tr><td> 0 </td><td> 0 </td><td> 1 </td><td> bit 1 </td></tr> * <tr><td> 0 </td><td> 1 </td><td> 0 </td><td> bit 2 </td></tr> * <tr><td> 0 </td><td> 1 </td><td> 1 </td><td> bit 3 </td></tr> * <tr><td> 1 </td><td> 0 </td><td> 0 </td><td> bit 4 </td></tr> * <tr><td> 1 </td><td> 0 </td><td> 1 </td><td> bit 5 </td></tr> * <tr><td> 1 </td><td> 1 </td><td> 0 </td><td> bit 6 </td></tr> * <tr><td> 1 </td><td> 1 </td><td> 1 </td><td> bit 7 </td></tr> * </table> * * \param base * Pointer to the Smart I/O base address * * \param lutNum * LUT index number * * \return * Bitfield [7:0] mapping of the 3:1 LUT * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetLutMap * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_SmartIO_GetLutMap(SMARTIO_PRT_Type* base, cy_en_smartio_lutnum_t lutNum) { return((uint8_t)(_FLD2VAL(SMARTIO_PRT_LUT_CTL_LUT, SMARTIO_PRT_LUT_CTL(base, lutNum)))); } /** \} group_smartio_functions_lut */ /** * \addtogroup group_smartio_functions_du * \{ */ /******************************************************************************* * Function Name: Cy_SmartIO_GetDuData ****************************************************************************//** * * \brief Gets the data unit's input "data" source. * * \param base * Pointer to the Smart I/O base address * * \param dataNum * Input data number * * \return * Data unit input trigger source * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetDuData * *******************************************************************************/ __STATIC_INLINE cy_en_smartio_dudata_t Cy_SmartIO_GetDuData(SMARTIO_PRT_Type* base, cy_en_smartio_datanum_t dataNum) { return ((dataNum == CY_SMARTIO_DATA0) ? (cy_en_smartio_dudata_t)_FLD2VAL(SMARTIO_PRT_DU_SEL_DU_DATA0_SEL, SMARTIO_PRT_DU_SEL(base)) : (cy_en_smartio_dudata_t)_FLD2VAL(SMARTIO_PRT_DU_SEL_DU_DATA1_SEL, SMARTIO_PRT_DU_SEL(base))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetDuOpc ****************************************************************************//** * * \brief Gets the data unit's opcode. * * \param base * Pointer to the Smart I/O base address * * \return * Data unit opcode * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetDuOpc * *******************************************************************************/ __STATIC_INLINE cy_en_smartio_duopc_t Cy_SmartIO_GetDuOpc(SMARTIO_PRT_Type* base) { return ((cy_en_smartio_duopc_t)_FLD2VAL(SMARTIO_PRT_DU_CTL_DU_OPC, SMARTIO_PRT_DU_CTL(base))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetDuSize ****************************************************************************//** * * \brief Gets the data unit's opcode operand bit-width. * * \param base * Pointer to the Smart I/O base address * * \return * Data unit operand bit-width * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetDuSize * *******************************************************************************/ __STATIC_INLINE cy_en_smartio_dusize_t Cy_SmartIO_GetDuSize(SMARTIO_PRT_Type* base) { return ((cy_en_smartio_dusize_t)_FLD2VAL(SMARTIO_PRT_DU_CTL_DU_SIZE, SMARTIO_PRT_DU_CTL(base))); } /******************************************************************************* * Function Name: Cy_SmartIO_GetDataReg ****************************************************************************//** * * \brief Gets the data unit's DATA register value. * * \param base * Pointer to the Smart I/O base address * * \return * DATA register value * * \funcusage * \snippet smartio/snippet/main.c snippet_Cy_SmartIO_GetDataReg * *******************************************************************************/ __STATIC_INLINE uint8_t Cy_SmartIO_GetDataReg(SMARTIO_PRT_Type* base) { return ((uint8_t)(SMARTIO_PRT_DATA(base))); } /** \} group_smartio_functions_du */ /** \} group_smartio_functions */ CY_MISRA_BLOCK_END('MISRA C-2012 Rule 10.8'); #if defined(__cplusplus) } #endif #endif /* CY_IP_MXS40IOSS */ #endif /* CY_SMARTIO_H */ /** \} group_smartio */ /* [] END OF FILE */
58476e3e7f8031d0d671860c6e8d7714227e80fa
0744dcc5394cebf57ebcba343747af6871b67017
/os/board/rtl8720e/src/component/mbed/hal_ext/efuse_api.h
4d69e42fdeb30e97cd07bac69a3ffe392f7b0481
[ "Apache-2.0", "GPL-1.0-or-later", "BSD-3-Clause", "ISC", "MIT", "LicenseRef-scancode-warranty-disclaimer", "LicenseRef-scancode-other-permissive" ]
permissive
Samsung/TizenRT
96abf62f1853f61fcf91ff14671a5e0c6ca48fdb
1a5c2e00a4b1bbf4c505bbf5cc6a8259e926f686
refs/heads/master
2023-08-31T08:59:33.327998
2023-08-08T06:09:20
2023-08-31T04:38:20
82,517,252
590
719
Apache-2.0
2023-09-14T06:54:49
2017-02-20T04:38:30
C
UTF-8
C
false
false
6,366
h
efuse_api.h
/** mbed Microcontroller Library ****************************************************************************** * @file efuse_api.h * @author * @version V1.0.0 * @brief This file provides mbed EFUSE API. ****************************************************************************** * @attention * * Copyright (c) 2015, Realtek Semiconductor Corp. * All rights reserved. * * This module is a confidential and proprietary property of RealTek and * possession or use of this module requires written permission of RealTek. ****************************************************************************** */ #ifndef MBED_EXT_EFUSE_API_EXT_H #define MBED_EXT_EFUSE_API_EXT_H #include "device.h" #ifdef __cplusplus extern "C" { #endif /** @addtogroup efuse EFUSE * @ingroup hal * @brief efuse functions * @{ */ ///@name Ameba Common ///@{ /** * @brief Get remaining efuse length * @retval : remaining efuse length */ int efuse_get_remaining_length(void); /** * @brief Read efuse contant of specified user * @param data: Specified the address to save the readback data. * @retval none */ void efuse_mtp_read(uint8_t *data); /** * @brief Write user's contant to efuse * @param data: Specified the data to be programmed. * @param len: Specifies the data length of programmed data. * @retval value: * - 0~32: Success * - -1: Failure */ int efuse_mtp_write(uint8_t *data, uint8_t len); /** * @brief Read efuse OTP contant * @param address: Specifies the offset of the OTP. * @param len: Specifies the length of readback data. * @param buf: Specified the address to save the readback data. * @retval 0: Success * @retval -1: Failure */ int efuse_otp_read(u8 address, u8 len, u8 *buf); /** * @brief Write user's contant to OTP efuse * @param address: Specifies the offset of the programmed OTP. * @param len: Specifies the data length of programmed data. * @param buf: Specified the data to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_otp_write(u8 address, u8 len, u8 *buf); /** * @brief ckeck user's contant to OTP efuse * @param buf: Specified the data to be programmed. * @param len: Specifies the data length of programmed data. * @retval 0: Success * @retval -1: Failure */ int efuse_otp_chk(u8 len, u8 *buf); /** * @brief Disable jtag * @retval 0: Success */ int efuse_disable_jtag(void); ///@} #if defined(CONFIG_PLATFORM_8195A) && (CONFIG_PLATFORM_8195A == 1) ///@name Ameba1 Only ///@{ /** * @brief Write key1 to efuse * @param address: Specifies the offset of the programmed efuse. * @param len: Specifies the data length of programmed data. * @param buf: Specified the data to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_key1_write(u8 address, u8 len, u8 *buf); /** * @brief Write key2 to efuse * @param address: Specifies the offset of the programmed efuse. * @param len: Specifies the data length of programmed data. * @param buf: Specified the data to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_key2_write(u8 address, u8 len, u8 *buf); ///@} #endif //CONFIG_PLATFORM_8195A #if defined(CONFIG_PLATFORM_8711B) && (CONFIG_PLATFORM_8711B == 1) ///@name AmebaZ Only ///@{ /** * @brief Set RDP Enable. * @param none * @note can not change or read back after write. */ void efuse_rdp_enable(void); /** * @brief Set 16B RDP key into EFUSE. * @param rdp_key: 16B EFUSE KEY * @note can not change or read back after write. */ void efuse_rdp_keyset(u8 *rdp_key); /** * @brief Set 16B OTF key into EFUSE. * @param OtfKey: 16B EFUSE KEY * @note can not change or read back after write. */ void efuse_otf_keyset(u8 *otf_key); ///@} #endif //CONFIG_PLATFORM_8711B #if defined(CONFIG_PLATFORM_8195BLP) && (CONFIG_PLATFORM_8195BLP == 1) ///@name AmebaPro Only ///@{ /** * @brief Disable LP jtag * @retval 0: Success */ int efuse_disable_lp_jtag(void); /** * @brief Disable HS secure jtag * @retval 0: Success */ int efuse_disable_sec_jtag(void); /** * @brief Disable HS nonsecure jtag * @retval 0: Success */ int efuse_disable_nonsec_jtag(void); ///@} #endif // end of "#if defined(CONFIG_PLATFORM_8195BLP)" #if defined(CONFIG_PLATFORM_8195BHP) && (CONFIG_PLATFORM_8195BHP == 1) ///@name AmebaPro Only ///@{ /** * @brief Write secure key to efuse * @param buf: Specified the 32-byte security key to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_sec_key_write(u8 *buf); /** * @brief Write super secure key to efuse * @param buf: Specified the 32-byte super security key to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_susec_key_write(u8 *buf); ///@} #endif // end of "#if defined(CONFIG_PLATFORM_8195BHP)" #if (defined(CONFIG_PLATFORM_8710C) && (CONFIG_PLATFORM_8710C == 1)) ///@name AmebaZII Only ///@{ /** * @brief Disable secure jtag * @retval 0: Success */ int efuse_disable_sec_jtag(void); /** * @brief Disable nonsecure jtag * @retval 0: Success */ int efuse_disable_nonsec_jtag(void); /** * @brief Write secure key to efuse * @param buf: Specified the 32-byte security key to be programmed. * @param key_num: select key number. * @retval 0: Success * @retval -1: Failure */ int efuse_sec_key_write(u8 *buf, u8 key_num); /** * @brief Write super secure key to efuse * @param buf: Specified the 32-byte super security key to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_susec_key_write(u8 *buf); /** * @brief Write secure j-tag key to efuse * @param buf: Specified the 32-byte security key to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_s_jtag_key_write(u8 *buf); /** * @brief Write non-secure j-tag key to efuse * @param buf: Specified the 32-byte security key to be programmed. * @retval 0: Success * @retval -1: Failure */ int efuse_ns_jtag_key_write(u8 *buf); /** * @brief lock super secure key * @retval 0: Success * @retval -1: Failure */ int efuse_lock_susec_key(void); ///@} #endif // end of "#if defined(CONFIG_PLATFORM_8710C)" /*\@}*/ #ifdef __cplusplus } #endif #endif // MBED_EXT_EFUSE_API_EXT_H
fdd3352fd8a83f06f97a697b244f348aaf226770
9de0cec678bc4a3bec2b4adabef9f39ff5b4afac
/PWGGA/PHOSTasks/PHOSCalib/macros/GetCorrectL1Phase.C
9adbbc8d8e520ddb93d94cd774915f5117502471
[]
permissive
alisw/AliPhysics
91bf1bd01ab2af656a25ff10b25e618a63667d3e
5df28b2b415e78e81273b0d9bf5c1b99feda3348
refs/heads/master
2023-08-31T20:41:44.927176
2023-08-31T14:51:12
2023-08-31T14:51:12
61,661,378
129
1,150
BSD-3-Clause
2023-09-14T18:48:45
2016-06-21T19:31:29
C++
UTF-8
C
false
false
1,888
c
GetCorrectL1Phase.C
#include <stdlib.h> #include <stdio.h> #include <iostream> #include <string.h> #include <math.h> #include <vector> #include <algorithm> #include <functional> #include <TH1.h> #include <TH2.h> #include <TH3.h> #include <TF1.h> #include <TF2.h> #include <TF3.h> #include <TTree.h> #include <TSpectrum.h> #include <TFile.h> #include <TString.h> #include <TList.h> using namespace std; void GetCorrectL1Phase(const Int_t runnumber, const TString trigger, Int_t *CorrectL1phase) { TString infile = Form("AnalysisResults_%d.root",runnumber); cout << "infile = " << infile << endl; TFile *rootfile = TFile::Open(infile,"READ"); if(!rootfile){ printf("rootfile : %s does not exist. retrun.\n",infile.Data()); return; } TString listname = Form("hist_%s",trigger.Data()); TList *list = (TList*)rootfile->Get(listname); if(!list){ printf("list : %s does not exist. retrun.\n",listname.Data()); return; } TFile *outfile = new TFile(Form("Timing_%d.root",runnumber),"RECREATE"); for(Int_t iddl=6;iddl<20;iddl++){ TString histname = Form("hBC4vsTimeDDL%d_HG_afterCorr",iddl); //TString histname = Form("hBC4vsTimeDDL%d_HG",iddl); TH2F *h2 = (TH2F*)list->FindObject(histname); h2->SetXTitle("Time_{cell} (ns)"); h2->SetYTitle("BC%4"); outfile->WriteTObject(h2); Double_t mean[4]={}; for(Int_t bc=0;bc<4;bc++){ TH1F *h1 = (TH1F*)h2->ProjectionX(Form("h%d_BC%d",iddl,bc),bc+1,bc+1,""); outfile->WriteTObject(h1); mean[bc] = h1->GetMean(); } Int_t index=-1; Double_t min=999; for(Int_t bc=0;bc<4;bc++){//find minimum value and index if(min>mean[bc]){ min = mean[bc]; index = bc; } } //cout << "DDL = " << iddl << " , index = " << index << " , min = " << min << endl; CorrectL1phase[iddl] = index; } rootfile->Close(); outfile->Close(); }
9d98288883c92c620623da349f84f05acf30e0fa
6923f79f1eaaba0ab28b25337ba6cb56be97d32d
/NumericalRecipes3/dftintegrate.h
bfb07d87f87ee06b02be9d6ac584fa2872480d78
[]
no_license
burakbayramli/books
9fe7ba0cabf06e113eb125d62fe16d4946f4a4f0
5e9a0e03aa7ddf5e5ddf89943ccc68d94b539e95
refs/heads/master
2023-08-17T05:31:08.885134
2023-08-14T10:05:37
2023-08-14T10:05:37
72,460,321
223
174
null
2022-10-24T12:15:06
2016-10-31T17:24:00
Jupyter Notebook
UTF-8
C
false
false
3,227
h
dftintegrate.h
void dftcor(const Doub w, const Doub delta, const Doub a, const Doub b, VecDoub_I &endpts, Doub &corre, Doub &corim, Doub &corfac) { Doub a0i,a0r,a1i,a1r,a2i,a2r,a3i,a3r,arg,c,cl,cr,s,sl,sr,t,t2,t4,t6, cth,ctth,spth2,sth,sth4i,stth,th,th2,th4,tmth2,tth4i; th=w*delta; if (a >= b || th < 0.0e0 || th > 3.1416e0) throw("bad arguments to dftcor"); if (abs(th) < 5.0e-2) { t=th; t2=t*t; t4=t2*t2; t6=t4*t2; corfac=1.0-(11.0/720.0)*t4+(23.0/15120.0)*t6; a0r=(-2.0/3.0)+t2/45.0+(103.0/15120.0)*t4-(169.0/226800.0)*t6; a1r=(7.0/24.0)-(7.0/180.0)*t2+(5.0/3456.0)*t4-(7.0/259200.0)*t6; a2r=(-1.0/6.0)+t2/45.0-(5.0/6048.0)*t4+t6/64800.0; a3r=(1.0/24.0)-t2/180.0+(5.0/24192.0)*t4-t6/259200.0; a0i=t*(2.0/45.0+(2.0/105.0)*t2-(8.0/2835.0)*t4+(86.0/467775.0)*t6); a1i=t*(7.0/72.0-t2/168.0+(11.0/72576.0)*t4-(13.0/5987520.0)*t6); a2i=t*(-7.0/90.0+t2/210.0-(11.0/90720.0)*t4+(13.0/7484400.0)*t6); a3i=t*(7.0/360.0-t2/840.0+(11.0/362880.0)*t4-(13.0/29937600.0)*t6); } else { cth=cos(th); sth=sin(th); ctth=cth*cth-sth*sth; stth=2.0e0*sth*cth; th2=th*th; th4=th2*th2; tmth2=3.0e0-th2; spth2=6.0e0+th2; sth4i=1.0/(6.0e0*th4); tth4i=2.0e0*sth4i; corfac=tth4i*spth2*(3.0e0-4.0e0*cth+ctth); a0r=sth4i*(-42.0e0+5.0e0*th2+spth2*(8.0e0*cth-ctth)); a0i=sth4i*(th*(-12.0e0+6.0e0*th2)+spth2*stth); a1r=sth4i*(14.0e0*tmth2-7.0e0*spth2*cth); a1i=sth4i*(30.0e0*th-5.0e0*spth2*sth); a2r=tth4i*(-4.0e0*tmth2+2.0e0*spth2*cth); a2i=tth4i*(-12.0e0*th+2.0e0*spth2*sth); a3r=sth4i*(2.0e0*tmth2-spth2*cth); a3i=sth4i*(6.0e0*th-spth2*sth); } cl=a0r*endpts[0]+a1r*endpts[1]+a2r*endpts[2]+a3r*endpts[3]; sl=a0i*endpts[0]+a1i*endpts[1]+a2i*endpts[2]+a3i*endpts[3]; cr=a0r*endpts[7]+a1r*endpts[6]+a2r*endpts[5]+a3r*endpts[4]; sr= -a0i*endpts[7]-a1i*endpts[6]-a2i*endpts[5]-a3i*endpts[4]; arg=w*(b-a); c=cos(arg); s=sin(arg); corre=cl+c*cr-s*sr; corim=sl+s*cr+c*sr; } void dftint(Doub func(const Doub), const Doub a, const Doub b, const Doub w, Doub &cosint, Doub &sinint) { static Int init=0; static Doub (*funcold)(const Doub); static Doub aold = -1.e30,bold = -1.e30,delta; const Int M=64,NDFT=1024,MPOL=6; const Doub TWOPI=6.283185307179586476; Int j,nn; Doub c,cdft,corfac,corim,corre,en,s,sdft; static VecDoub data(NDFT),endpts(8); VecDoub cpol(MPOL),spol(MPOL),xpol(MPOL); if (init != 1 || a != aold || b != bold || func != funcold) { init=1; aold=a; bold=b; funcold=func; delta=(b-a)/M; for (j=0;j<M+1;j++) data[j]=func(a+j*delta); for (j=M+1;j<NDFT;j++) data[j]=0.0; for (j=0;j<4;j++) { endpts[j]=data[j]; endpts[j+4]=data[M-3+j]; } realft(data,1); data[1]=0.0; } en=w*delta*NDFT/TWOPI+1.0; nn=MIN(MAX(Int(en-0.5*MPOL+1.0),1),NDFT/2-MPOL+1); for (j=0;j<MPOL;j++,nn++) { cpol[j]=data[2*nn-2]; spol[j]=data[2*nn-1]; xpol[j]=nn; } cdft = Poly_interp(xpol,cpol,MPOL).interp(en); sdft = Poly_interp(xpol,spol,MPOL).interp(en); dftcor(w,delta,a,b,endpts,corre,corim,corfac); cdft *= corfac; sdft *= corfac; cdft += corre; sdft += corim; c=delta*cos(w*a); s=delta*sin(w*a); cosint=c*cdft-s*sdft; sinint=s*cdft+c*sdft; }
9e6ad58d74a7c69b10179850e0f084dc7e97d7a8
fbdc48c28e54fb33ae4842ef95ff63893902c99a
/src/omv/ports/stm32/modules/py_tv.c
db1c739520adeda50e0ba7eba748392d09680bcc
[ "MIT" ]
permissive
openmv/openmv
44d4b79fc8693950a2e330e5e0fd95b5c36e230f
8a90e070a88b7fc14c87a00351b9c4a213278419
refs/heads/master
2023-08-30T20:59:57.227603
2023-08-23T16:50:55
2023-08-23T16:50:55
14,360,940
2,150
1,226
MIT
2023-09-14T07:18:15
2013-11-13T10:23:44
C
UTF-8
C
false
false
40,794
c
py_tv.c
/* * This file is part of the OpenMV project. * * Copyright (c) 2013-2020 Ibrahim Abdelkader <iabdalkader@openmv.io> * Copyright (c) 2013-2020 Kwabena W. Agyeman <kwagyeman@openmv.io> * Copyright (c) 2013-2020 Kaizhi Wong <kidswong999@gmail.com> * * This work is licensed under the MIT license, see the file LICENSE for details. * * TV Python module. */ #include "omv_boardconfig.h" #if MICROPY_PY_TV #include STM32_HAL_H #include "py/obj.h" #include "py/nlr.h" #include "py/runtime.h" #include "spi.h" #include "py_helper.h" #include "py_image.h" #include "omv_gpio.h" #define TV_WIDTH 352 #define TV_HEIGHT 240 #define TV_REFRESH 60 #if ((TV_WIDTH) % 2) #error "TV_WIDTH not even" #endif #if ((TV_HEIGHT) % 2) #error "TV_HEIGHT not even" #endif #ifdef OMV_SPI_LCD_CONTROLLER ///////////////////////////////////////////////////////////// // http://www.vsdsp-forum.com/phpbb/viewtopic.php?f=14&t=1801 ///////////////////////////////////////////////////////////// // Crystal frequency in MHZ (float, observe accuracy) #define XTAL_MHZ 3.579545 // Line length in microseconds (float, observe accuracy) #define LINE_LENGTH_US 63.556 #define FIXED_VCLK_CYCLES 10 #define FIXED_CSCLK_CYCLES ((FIXED_VCLK_CYCLES) / 8.0) // Normal visible picture line sync length is 4.7 us #define SYNC_US 4.7 #define SYNC ((uint16_t) (((SYNC_US) *(XTAL_MHZ)) - (FIXED_CSCLK_CYCLES) +0.5)) // Color burst starts at 5.3 us #define BURST_US 5.3 #define BURST ((uint16_t) (((BURST_US) *(XTAL_MHZ)) - (FIXED_CSCLK_CYCLES) +0.5)) // Color burst duration is 2.5 us #define BURST_DUR_US 2.5 #define BURST_DUR ((uint16_t) (((BURST_DUR_US) *(XTAL_MHZ)) + 0.5)) // Black video starts at 9.4 us #define BLACK_US 9.4 #define BLACK ((uint16_t) (((BLACK_US) *(XTAL_MHZ)) - (FIXED_CSCLK_CYCLES) +0.5)) // Black video duration is 52.656 us #define BLACK_DUR_US 52.656 #define BLACK_DUR ((uint16_t) (((BLACK_DUR_US) *(XTAL_MHZ)) + 0.5)) // Define NTSC video timing constants // NTSC short sync duration is 2.3 us #define SHORT_SYNC_US 2.3 // For the start of the line, the first 10 extra PLLCLK sync (0) cycles are subtracted. #define SHORTSYNC ((uint16_t) (((SHORT_SYNC_US) *(XTAL_MHZ)) - (FIXED_CSCLK_CYCLES) +0.5)) // For the middle of the line the whole duration of sync pulse is used. #define SHORTSYNCM ((uint16_t) (((SHORT_SYNC_US) *(XTAL_MHZ)) + 0.5)) // NTSC long sync duration is 27.078 us #define LONG_SYNC_US 27.078 #define LONGSYNC ((uint16_t) (((LONG_SYNC_US) *(XTAL_MHZ)) - (FIXED_CSCLK_CYCLES) +0.5)) #define LONGSYNCM ((uint16_t) (((LONG_SYNC_US) *(XTAL_MHZ)) + 0.5)) // Number of lines used after the VSYNC but before visible area. #define VSYNC_LINES 9 #define FRONT_PORCH_LINES 13 // Definitions for picture lines // On which line the picture area begins, the Y direction. #define STARTLINE ((VSYNC_LINES) + (FRONT_PORCH_LINES)) // Frame length in lines (visible lines + nonvisible lines) // Amount has to be odd for NTSC and RGB colors #define TOTAL_LINES ((STARTLINE) + (TV_HEIGHT) +1) #if ((TOTAL_LINES) != 263) #error "Progressive NTSC must have 263 lines!" #endif // Width, in PLL clocks, of each pixel. #define PLLCLKS_PER_PIXEL 4 // The first pixel of the picture area, the X direction. #define STARTPIX ((BLACK) +7) // The last pixel of the picture area. #define ENDPIX ((uint16_t) ((STARTPIX) + (((PLLCLKS_PER_PIXEL) *(TV_WIDTH)) / 8))) // Reserve memory for this number of different prototype lines // (prototype lines are used for sync timing, porch and border area) #define PROTOLINES 3 // PLL frequency #define PLL_MHZ ((XTAL_MHZ) * 8) // 10 first pllclks, which are not in the counters are decremented here #define PLLCLKS_PER_LINE ((uint16_t) (((LINE_LENGTH_US) *(PLL_MHZ)) - (FIXED_VCLK_CYCLES))) // 10 first pllclks, which are not in the counters are decremented here #define COLORCLKS_PER_LINE ((uint16_t) ((((((LINE_LENGTH_US) *(PLL_MHZ)) / 1) + 7) / 8) - (FIXED_CSCLK_CYCLES))) #define COLORCLKS_LINE_HALF ((uint16_t) ((((((LINE_LENGTH_US) *(PLL_MHZ)) / 2) + 7) / 8) - (FIXED_CSCLK_CYCLES))) #define PROTO_AREA_WORDS ((COLORCLKS_PER_LINE) *(PROTOLINES)) #define INDEX_START_LONGWORDS (((PROTO_AREA_WORDS) +1) / 2) #define INDEX_START_BYTES ((INDEX_START_LONGWORDS) * 4) // Protoline 0 starts always at address 0 #define PROTOLINE_BYTE_ADDRESS(n) ((COLORCLKS_PER_LINE) * 2 * (n)) #define PROTOLINE_WORD_ADDRESS(n) ((COLORCLKS_PER_LINE) * 1 * (n)) // Calculate picture lengths in pixels and bytes, coordinate areas for picture area #define PICBITS 12 #define PICLINE_LENGTH_BYTES (((TV_WIDTH) *(PICBITS)) / 8) #define LINE_INDEX_BYTE_SIZE 3 // Picture area memory start point #define PICLINE_START ((INDEX_START_BYTES) + ((TOTAL_LINES) *(LINE_INDEX_BYTE_SIZE))) // Picture area line start addresses #define PICLINE_BYTE_ADDRESS(n) ((PICLINE_START) + ((PICLINE_LENGTH_BYTES) *(n))) // Pattern generator microcode // --------------------------- // Bits 7:6 a=00|b=01|y=10|-=11 // Bits 5:3 n pick bits 1..8 // bits 2:0 shift 0..6 #define PICK_A (0 << 6) #define PICK_B (1 << 6) #define PICK_Y (2 << 6) #define PICK_NOTHING (3 << 6) #define PICK_BITS(a) (((a) - 1) << 3) #define SHIFT_BITS(a) (a) // 16 bits per pixel, U4 V4 Y8 // PICK_B is U #define OP1 (PICK_B + PICK_BITS(4) + SHIFT_BITS(4)) // PICK_A is V #define OP2 (PICK_A + PICK_BITS(4) + SHIFT_BITS(4)) #define OP3 (PICK_Y + PICK_BITS(8) + SHIFT_BITS(6)) #define OP4 (PICK_NOTHING + SHIFT_BITS(2)) // General VS23 commands #define WRITE_STATUS 0x01 #define WRITE_SRAM 0x02 #define WRITE_GPIO 0x82 #define READ_GPIO 0x84 #define WRITE_MULTIIC 0xb8 #define WRITE_BLOCKMVC1 0x34 // Bit definitions #define VDCTRL1 0x2B #define VDCTRL1_UVSKIP (1 << 0) #define VDCTRL1_PLL_ENABLE (1 << 12) #define VDCTRL2 0x2D #define VDCTRL2_LINECOUNT (1 << 0) #define VDCTRL2_PIXEL_WIDTH (1 << 10) #define VDCTRL2_ENABLE_VIDEO (1 << 15) #define BLOCKMVC1_PYF (1 << 4) // VS23 video commands #define PROGRAM 0x30 #define PICSTART 0x28 #define PICEND 0x29 #define LINELEN 0x2a #define INDEXSTART 0x2c // Sync, blank, burst and white level definitions, here are several options // These are for proto lines and so format is VVVVUUUUYYYYYYYY // Sync is always 0 #define SYNC_LEVEL 0x0000 // 285 mV to 75 ohm load #define BLANK_LEVEL 0x0066 // 285 mV burst #define BURST_LEVEL 0x0d66 #define SPI_RAM_SIZE (128 * 1024) // COLORCLKS_PER_LINE can't be used in pre-processor logic. #if ((((((227 * (PROTOLINES)) + 1) / 2) * 4) + ((TOTAL_LINES) *(LINE_INDEX_BYTE_SIZE)) + \ ((PICLINE_LENGTH_BYTES) *(TV_HEIGHT))) > (SPI_RAM_SIZE)) #error "TV_WIDTH * TV_HEIGHT is too big!" #endif static void SpiRamWriteByteRegister(int opcode, int data) { uint8_t packet[2] = {opcode, data}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static int SpiRamReadByteRegister(int opcode) { uint8_t packet[2] = {opcode, 0}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_TransmitReceive(OMV_SPI_LCD_CONTROLLER->spi, packet, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); return packet[1]; } static void SpiRamWriteWordRegister(int opcode, int data) { uint8_t packet[3] = {opcode, data >> 8, data}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static void SpiClearRam() { uint8_t packet[4] = {WRITE_SRAM, 0, 0, 0}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); packet[0] = 0; for (int i = 0; i < (SPI_RAM_SIZE / sizeof(packet)); i++) { HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); } omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static void SpiRamWriteProgram(int data0, int data1, int data2, int data3) { uint8_t packet[5] = {PROGRAM, data3, data2, data1, data0}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static void SpiRamWriteLowPassFilter(int data) { uint8_t packet[6] = {WRITE_BLOCKMVC1, 0, 0, 0, 0, data}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static void SpiRamWriteWord(int w_address, int data) { int address = w_address * sizeof(uint16_t); uint8_t packet[6] = {WRITE_SRAM, address >> 16, address >> 8, address, data >> 8, data}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static void SpiRamWriteVSyncProtoLine(int line, int length_1, int length_2) { int w0 = PROTOLINE_WORD_ADDRESS(line); for (int i = 0; i < COLORCLKS_PER_LINE; i++) { SpiRamWriteWord(w0++, BLANK_LEVEL); } int w1 = PROTOLINE_WORD_ADDRESS(line); for (int i = 0; i < length_1; i++) { SpiRamWriteWord(w1++, SYNC_LEVEL); } int w2 = PROTOLINE_WORD_ADDRESS(line) + COLORCLKS_LINE_HALF; for (int i = 0; i < length_2; i++) { SpiRamWriteWord(w2++, SYNC_LEVEL); } } static void SpiRamWriteLine(int line, int index) { int address = INDEX_START_BYTES + (line * LINE_INDEX_BYTE_SIZE); int data = index << 7; uint8_t packet[7] = {WRITE_SRAM, address >> 16, address >> 8, address, data, data >> 8, data >> 16}; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, packet, sizeof(packet), HAL_MAX_DELAY); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } static void SpiRamVideoInit() { // Select the first VS23 for following commands in case there // are several VS23 ICs connected to same SPI bus. SpiRamWriteByteRegister(WRITE_MULTIIC, 0xe); // Set SPI memory address autoincrement SpiRamWriteByteRegister(WRITE_STATUS, 0x40); // Reset the video display controller SpiRamWriteWordRegister(VDCTRL1, 0); SpiRamWriteWordRegister(VDCTRL2, 0); // Write picture start and end SpiRamWriteWordRegister(PICSTART, (STARTPIX - 1)); SpiRamWriteWordRegister(PICEND, (ENDPIX - 1)); // Enable PLL clock SpiRamWriteWordRegister(VDCTRL1, VDCTRL1_PLL_ENABLE | VDCTRL1_UVSKIP); // Clear the video memory SpiClearRam(); // Set length of one complete line (unit: PLL clocks) SpiRamWriteWordRegister(LINELEN, PLLCLKS_PER_LINE); // Set microcode program for picture lines SpiRamWriteProgram(OP1, OP2, OP3, OP4); // Define where Line Indexes are stored in memory SpiRamWriteWordRegister(INDEXSTART, INDEX_START_LONGWORDS); // At this time, the chip would continuously output the proto line 0. // This protoline will become our most "normal" horizontal line. // For TV-Out, fill the line with black level, // and insert a few pixels of sync level (0) and color burst to the beginning. // Note that the chip hardware adds black level to all nonproto areas so // protolines and normal picture have different meaning for the same Y value. // In protolines, Y=0 is at sync level and in normal picture Y=0 is at black level (offset +102). // In protolines, each pixel is 8 PLLCLKs, which in TV-out modes means one color // subcarrier cycle. Each pixel has 16 bits (one word): VVVVUUUUYYYYYYYY. SpiRamWriteVSyncProtoLine(0, SYNC, 0); int w = PROTOLINE_WORD_ADDRESS(0) + BURST; for (int i = 0; i < BURST_DUR; i++) { SpiRamWriteWord(w++, BURST_LEVEL); } // short_low + long_high + short_low + long_high SpiRamWriteVSyncProtoLine(1, SHORTSYNC, SHORTSYNCM); // long_low + short_high + long_low + short_high SpiRamWriteVSyncProtoLine(2, LONGSYNC, LONGSYNCM); for (int i = 0; i <= 2; i++) { SpiRamWriteLine(i, PROTOLINE_BYTE_ADDRESS(1)); // short_low + long_high + short_low + long_high } for (int i = 3; i <= 5; i++) { SpiRamWriteLine(i, PROTOLINE_BYTE_ADDRESS(2)); // long_low + short_high + long_low + short_high } for (int i = 6; i <= 8; i++) { SpiRamWriteLine(i, PROTOLINE_BYTE_ADDRESS(1)); // short_low + long_high + short_low + long_high } // Set pic line indexes to point to protoline 0 and their individual picture line. for (int i = 0; i < TV_HEIGHT; i++) { SpiRamWriteLine(STARTLINE + i, PICLINE_BYTE_ADDRESS(i)); } // Set number of lines, length of pixel and enable video generation SpiRamWriteWordRegister(VDCTRL2, (VDCTRL2_LINECOUNT * (TOTAL_LINES - 1)) | (VDCTRL2_PIXEL_WIDTH * (PLLCLKS_PER_PIXEL - 1)) | (VDCTRL2_ENABLE_VIDEO)); // Enable the low-pass Y filter. SpiRamWriteLowPassFilter(BLOCKMVC1_PYF); } #endif // TV lines are converted from 16-bit RGB565 to 12-bit YUV. #define TV_WIDTH_RGB565 ((TV_WIDTH) * 2) // bytes #if ((PICLINE_LENGTH_BYTES) > (TV_WIDTH_RGB565)) #error "PICLINE_LENGTH_BYTES > TV_WIDTH_RGB565" #endif #define FRAMEBUFFER_COUNT 3 static int framebuffer_head = 0; static volatile int framebuffer_tail = 0; static uint16_t *framebuffers[FRAMEBUFFER_COUNT] = {}; static enum { TV_NONE, TV_SHIELD, } tv_type = TV_NONE; static bool tv_triple_buffer = false; #ifdef OMV_SPI_LCD_CONTROLLER static DMA_HandleTypeDef spi_tx_dma = {}; static volatile enum { SPI_TX_CB_IDLE, SPI_TX_CB_MEMORY_WRITE_CMD, SPI_TX_CB_MEMORY_WRITE } spi_tx_cb_state = SPI_TX_CB_IDLE; static void spi_config_deinit() { if (tv_triple_buffer) { HAL_SPI_Abort(OMV_SPI_LCD_CONTROLLER->spi); spi_tx_cb_state = SPI_TX_CB_IDLE; fb_alloc_free_till_mark_past_mark_permanent(); } spi_deinit(OMV_SPI_LCD_CONTROLLER); // Do not put in HAL_SPI_MspDeinit as other modules share the SPI2 bus. omv_gpio_deinit(OMV_SPI_LCD_MOSI_PIN); omv_gpio_deinit(OMV_SPI_LCD_MISO_PIN); omv_gpio_deinit(OMV_SPI_LCD_SCLK_PIN); omv_gpio_deinit(OMV_SPI_LCD_SSEL_PIN); } static void spi_tv_callback(SPI_HandleTypeDef *hspi); static void spi_config_init(bool triple_buffer) { OMV_SPI_LCD_CONTROLLER->spi->Init.Mode = SPI_MODE_MASTER; OMV_SPI_LCD_CONTROLLER->spi->Init.Direction = SPI_DIRECTION_2LINES; OMV_SPI_LCD_CONTROLLER->spi->Init.NSS = SPI_NSS_SOFT; OMV_SPI_LCD_CONTROLLER->spi->Init.TIMode = SPI_TIMODE_DISABLE; OMV_SPI_LCD_CONTROLLER->spi->Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE; spi_set_params(OMV_SPI_LCD_CONTROLLER, 0xffffffff, TV_WIDTH * TV_HEIGHT * TV_REFRESH * PICBITS, 0, 0, 8, 0); spi_init(OMV_SPI_LCD_CONTROLLER, true); HAL_SPI_RegisterCallback(OMV_SPI_LCD_CONTROLLER->spi, HAL_SPI_TX_COMPLETE_CB_ID, spi_tv_callback); // Do not put in HAL_SPI_MspInit as other modules share the SPI2 bus. omv_gpio_config(OMV_SPI_LCD_MOSI_PIN, OMV_GPIO_MODE_ALT, OMV_GPIO_PULL_NONE, OMV_GPIO_SPEED_MED, -1); omv_gpio_config(OMV_SPI_LCD_MISO_PIN, OMV_GPIO_MODE_ALT, OMV_GPIO_PULL_NONE, OMV_GPIO_SPEED_MED, -1); omv_gpio_config(OMV_SPI_LCD_SCLK_PIN, OMV_GPIO_MODE_ALT, OMV_GPIO_PULL_NONE, OMV_GPIO_SPEED_MED, -1); omv_gpio_config(OMV_SPI_LCD_SSEL_PIN, OMV_GPIO_MODE_OUTPUT, OMV_GPIO_PULL_NONE, OMV_GPIO_SPEED_LOW, -1); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); SpiRamVideoInit(); // Set default channel. SpiRamWriteByteRegister(WRITE_GPIO, 0x77); if (triple_buffer) { fb_alloc_mark(); framebuffer_head = 0; framebuffer_tail = 0; for (int i = 0; i < FRAMEBUFFER_COUNT; i++) { framebuffers[i] = (uint16_t *) fb_alloc0(TV_WIDTH_RGB565 * TV_HEIGHT, FB_ALLOC_CACHE_ALIGN); } dma_init(&spi_tx_dma, OMV_SPI_LCD_CONTROLLER->tx_dma_descr, DMA_MEMORY_TO_PERIPH, OMV_SPI_LCD_CONTROLLER->spi); OMV_SPI_LCD_CONTROLLER->spi->hdmatx = &spi_tx_dma; OMV_SPI_LCD_CONTROLLER->spi->hdmarx = NULL; #if defined(MCU_SERIES_H7) spi_tx_dma.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; #else spi_tx_dma.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; #endif spi_tx_dma.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; spi_tx_dma.Init.FIFOMode = DMA_FIFOMODE_ENABLE; spi_tx_dma.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; spi_tx_dma.Init.MemBurst = DMA_MBURST_INC4; #if defined(MCU_SERIES_H7) spi_tx_dma.Init.PeriphBurst = DMA_PBURST_INC4; #else spi_tx_dma.Init.PeriphBurst = DMA_PBURST_SINGLE; #endif DMA_Stream_TypeDef *dma_chan = spi_tx_dma.Instance; #if defined(MCU_SERIES_H7) dma_chan->CR = (dma_chan->CR & ~DMA_SxCR_PSIZE_Msk) | DMA_PDATAALIGN_WORD; #else dma_chan->CR = (dma_chan->CR & ~DMA_SxCR_PSIZE_Msk) | DMA_PDATAALIGN_BYTE; #endif dma_chan->CR = (dma_chan->CR & ~DMA_SxCR_MSIZE_Msk) | DMA_MDATAALIGN_WORD; dma_chan->FCR = (dma_chan->FCR & ~DMA_SxFCR_DMDIS_Msk) | DMA_FIFOMODE_ENABLE; dma_chan->FCR = (dma_chan->FCR & ~DMA_SxFCR_FTH_Msk) | DMA_FIFO_THRESHOLD_FULL; dma_chan->CR = (dma_chan->CR & ~DMA_SxCR_MBURST_Msk) | DMA_MBURST_INC4; #if defined(MCU_SERIES_H7) dma_chan->CR = (dma_chan->CR & ~DMA_SxCR_PBURST_Msk) | DMA_PBURST_INC4; #else dma_chan->CR = (dma_chan->CR & ~DMA_SxCR_PBURST_Msk) | DMA_PBURST_SINGLE; #endif fb_alloc_mark_permanent(); } } static const uint8_t write_sram[] = { // Cannot be allocated on the stack for HAL_SPI_Transmit_IT(). WRITE_SRAM, (uint8_t) (PICLINE_BYTE_ADDRESS(0) >> 16), (uint8_t) (PICLINE_BYTE_ADDRESS(0) >> 8), (uint8_t) (PICLINE_BYTE_ADDRESS(0) >> 0) }; static void spi_tv_callback(SPI_HandleTypeDef *hspi) { if (tv_type == TV_SHIELD) { static uint8_t *spi_tx_cb_state_memory_write_addr = NULL; static size_t spi_tx_cb_state_memory_write_count = 0; switch (spi_tx_cb_state) { case SPI_TX_CB_MEMORY_WRITE_CMD: { omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); spi_tx_cb_state = SPI_TX_CB_MEMORY_WRITE; spi_tx_cb_state_memory_write_addr = (uint8_t *) framebuffers[framebuffer_head]; spi_tx_cb_state_memory_write_count = PICLINE_LENGTH_BYTES * TV_HEIGHT; framebuffer_tail = framebuffer_head; #if defined(MCU_SERIES_H7) OMV_SPI_LCD_CONTROLLER->spi->Instance->CFG1 = (OMV_SPI_LCD_CONTROLLER->spi->Instance->CFG1 & ~SPI_CFG1_FTHLV_Msk) | SPI_FIFO_THRESHOLD_01DATA; #endif omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); // When starting the interrupt chain the first HAL_SPI_Transmit_IT is not executed // in interrupt context. So, disable interrupts for the first HAL_SPI_Transmit_IT so // that it completes first and unlocks the SPI bus before allowing the interrupt // it causes to trigger starting the interrupt chain. uint32_t irq_state = disable_irq(); HAL_SPI_Transmit_IT(OMV_SPI_LCD_CONTROLLER->spi, (uint8_t *) write_sram, sizeof(write_sram)); enable_irq(irq_state); break; } case SPI_TX_CB_MEMORY_WRITE: { uint8_t *addr = spi_tx_cb_state_memory_write_addr; size_t count = IM_MIN(spi_tx_cb_state_memory_write_count, (65536 - 16u)); spi_tx_cb_state = (spi_tx_cb_state_memory_write_count > (65536 - 16)) ? SPI_TX_CB_MEMORY_WRITE : SPI_TX_CB_MEMORY_WRITE_CMD; spi_tx_cb_state_memory_write_addr += count; spi_tx_cb_state_memory_write_count -= count; #if defined(MCU_SERIES_H7) OMV_SPI_LCD_CONTROLLER->spi->Instance->CFG1 = (OMV_SPI_LCD_CONTROLLER->spi->Instance->CFG1 & ~SPI_CFG1_FTHLV_Msk) | SPI_FIFO_THRESHOLD_16DATA; #endif HAL_SPI_Transmit_DMA(OMV_SPI_LCD_CONTROLLER->spi, addr, count); break; } default: { break; } } } } // Convert a 8-bit Grayscale line of pixels to 12-bit YUV422 with padding (line is 16-bit per pixel). static void spi_tv_draw_image_cb_convert_grayscale(uint8_t *row_pointer_i, uint8_t *row_pointer_o) { for (int i = TV_WIDTH - 2, j = ((TV_WIDTH * 3) / 2) - 3; i >= 0; i -= 2, j -= 3) { int y0 = IMAGE_GET_GRAYSCALE_PIXEL_FAST(row_pointer_i, i); int y1 = IMAGE_GET_GRAYSCALE_PIXEL_FAST(row_pointer_i, i + 1); IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_pointer_o, j, 0); IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_pointer_o, j + 1, y0); IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_pointer_o, j + 2, y1); } } // Convert a 16-bit RGB565 line of pixels to 12-bit YUV422 with padding (line is 16-bit per pixel). static void spi_tv_draw_image_cb_convert_rgb565(uint16_t *row_pointer_i, uint8_t *row_pointer_o) { for (int i = 0, j = 0; i < TV_WIDTH; i += 2, j += 3) { #if defined(ARM_MATH_DSP) int pixels = *((uint32_t *) (row_pointer_i + i)); int r_pixels = ((pixels >> 8) & 0xf800f8) | ((pixels >> 13) & 0x70007); int g_pixels = ((pixels >> 3) & 0xfc00fc) | ((pixels >> 9) & 0x30003); int b_pixels = ((pixels << 3) & 0xf800f8) | ((pixels >> 2) & 0x70007); int y = ((r_pixels * 38) + (g_pixels * 75) + (b_pixels * 15)) >> 7; int u = __SSUB16(b_pixels * 64, (r_pixels * 21) + (g_pixels * 43)); int v = __SSUB16(r_pixels * 64, (g_pixels * 54) + (b_pixels * 10)); int y0 = __UXTB_RORn(y, 0), y1 = __UXTB_RORn(y, 16); int u_avg = __SMUAD(u, 0x00010001) >> 7; int v_avg = __SMUAD(v, 0x00010001) >> 7; #else int pixel0 = IMAGE_GET_RGB565_PIXEL_FAST(row_pointer_i, i); int r0 = COLOR_RGB565_TO_R8(pixel0); int g0 = COLOR_RGB565_TO_G8(pixel0); int b0 = COLOR_RGB565_TO_B8(pixel0); int y0 = COLOR_RGB888_TO_Y(r0, g0, b0); int u0 = COLOR_RGB888_TO_U(r0, g0, b0); int v0 = COLOR_RGB888_TO_V(r0, g0, b0); int pixel1 = IMAGE_GET_RGB565_PIXEL_FAST(row_pointer_i, i + 1); int r1 = COLOR_RGB565_TO_R8(pixel1); int g1 = COLOR_RGB565_TO_G8(pixel1); int b1 = COLOR_RGB565_TO_B8(pixel1); int y1 = COLOR_RGB888_TO_Y(r1, g1, b1); int u1 = COLOR_RGB888_TO_U(r1, g1, b1); int v1 = COLOR_RGB888_TO_V(r1, g1, b1); int u_avg = u0 + u1; int v_avg = v0 + v1; #endif int uv = ((u_avg >> 1) & 0xf0) | (((-v_avg) >> 5) & 0xf); IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_pointer_o, j, uv); IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_pointer_o, j + 1, y0); IMAGE_PUT_GRAYSCALE_PIXEL_FAST(row_pointer_o, j + 2, y1); } } static void spi_tv_draw_image_cb_grayscale(int x_start, int x_end, int y_row, imlib_draw_row_data_t *data) { spi_tv_draw_image_cb_convert_grayscale((uint8_t *) data->dst_row_override, (uint8_t *) data->dst_row_override); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, data->dst_row_override, PICLINE_LENGTH_BYTES, HAL_MAX_DELAY); } static void spi_tv_draw_image_cb_rgb565(int x_start, int x_end, int y_row, imlib_draw_row_data_t *data) { spi_tv_draw_image_cb_convert_rgb565((uint16_t *) data->dst_row_override, (uint8_t *) data->dst_row_override); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, data->dst_row_override, PICLINE_LENGTH_BYTES, HAL_MAX_DELAY); } static void spi_tv_display(image_t *src_img, int dst_x_start, int dst_y_start, float x_scale, float y_scale, rectangle_t *roi, int rgb_channel, int alpha, const uint16_t *color_palette, const uint8_t *alpha_palette, image_hint_t hint) { bool rgb565 = ((rgb_channel == -1) && src_img->is_color) || color_palette; imlib_draw_row_callback_t cb = rgb565 ? spi_tv_draw_image_cb_rgb565 : spi_tv_draw_image_cb_grayscale; image_t dst_img; dst_img.w = TV_WIDTH; dst_img.h = TV_HEIGHT; dst_img.pixfmt = rgb565 ? PIXFORMAT_RGB565 : PIXFORMAT_GRAYSCALE; int x0, x1, y0, y1; bool black = !imlib_draw_image_rectangle(&dst_img, src_img, dst_x_start, dst_y_start, x_scale, y_scale, roi, alpha, alpha_palette, hint, &x0, &x1, &y0, &y1); if (!tv_triple_buffer) { dst_img.data = fb_alloc0(TV_WIDTH_RGB565, FB_ALLOC_NO_HINT); omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 0); HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, (uint8_t *) write_sram, sizeof(write_sram), HAL_MAX_DELAY); if (black) { // zero the whole image for (int i = 0; i < TV_HEIGHT; i++) { HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, dst_img.data, PICLINE_LENGTH_BYTES, HAL_MAX_DELAY); } } else { // Zero the top rows for (int i = 0; i < y0; i++) { HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, dst_img.data, PICLINE_LENGTH_BYTES, HAL_MAX_DELAY); } // Transmits left/right parts already zeroed... imlib_draw_image(&dst_img, src_img, dst_x_start, dst_y_start, x_scale, y_scale, roi, rgb_channel, alpha, color_palette, alpha_palette, hint | IMAGE_HINT_BLACK_BACKGROUND, cb, dst_img.data); // Zero the bottom rows if (y1 < TV_HEIGHT) { memset(dst_img.data, 0, TV_WIDTH_RGB565); } for (int i = y1; i < TV_HEIGHT; i++) { HAL_SPI_Transmit(OMV_SPI_LCD_CONTROLLER->spi, dst_img.data, PICLINE_LENGTH_BYTES, HAL_MAX_DELAY); } } omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); fb_free(); } else { // For triple buffering we are never drawing where head or tail (which may instantly update to // to be equal to head) is. int new_framebuffer_head = (framebuffer_head + 1) % FRAMEBUFFER_COUNT; if (new_framebuffer_head == framebuffer_tail) { new_framebuffer_head = (new_framebuffer_head + 1) % FRAMEBUFFER_COUNT; } dst_img.data = (uint8_t *) framebuffers[new_framebuffer_head]; if (rgb565) { if (black) { // zero the whole image memset(dst_img.data, 0, TV_WIDTH * TV_HEIGHT * sizeof(uint16_t)); } else { // Zero the top rows if (y0) { memset(dst_img.data, 0, TV_WIDTH * y0 * sizeof(uint16_t)); } if (x0) { for (int i = y0; i < y1; i++) { // Zero left memset(IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(&dst_img, i), 0, x0 * sizeof(uint16_t)); } } imlib_draw_image(&dst_img, src_img, dst_x_start, dst_y_start, x_scale, y_scale, roi, rgb_channel, alpha, color_palette, alpha_palette, hint | IMAGE_HINT_BLACK_BACKGROUND, NULL, NULL); if (TV_WIDTH - x1) { for (int i = y0; i < y1; i++) { // Zero right memset(IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(&dst_img, i) + x1, 0, (TV_WIDTH - x1) * sizeof(uint16_t)); } } // Zero the bottom rows if (TV_HEIGHT - y1) { memset(IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(&dst_img, y1), 0, TV_WIDTH * (TV_HEIGHT - y1) * sizeof(uint16_t)); } } for (int i = 0; i < TV_HEIGHT; i++) { // Convert the image. spi_tv_draw_image_cb_convert_rgb565(IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(&dst_img, i), dst_img.data + (PICLINE_LENGTH_BYTES * i)); } } else { if (black) { // zero the whole image memset(dst_img.data, 0, TV_WIDTH * TV_HEIGHT * sizeof(uint8_t)); } else { // Zero the top rows if (y0) { memset(dst_img.data, 0, TV_WIDTH * y0 * sizeof(uint8_t)); } if (x0) { for (int i = y0; i < y1; i++) { // Zero left memset(IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(&dst_img, i), 0, x0 * sizeof(uint8_t)); } } imlib_draw_image(&dst_img, src_img, dst_x_start, dst_y_start, x_scale, y_scale, roi, rgb_channel, alpha, color_palette, alpha_palette, hint | IMAGE_HINT_BLACK_BACKGROUND, NULL, NULL); if (TV_WIDTH - x1) { for (int i = y0; i < y1; i++) { // Zero right memset(IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(&dst_img, i) + x1, 0, (TV_WIDTH - x1) * sizeof(uint8_t)); } } // Zero the bottom rows if (TV_HEIGHT - y1) { memset(IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(&dst_img, y1), 0, TV_WIDTH * (TV_HEIGHT - y1) * sizeof(uint8_t)); } } for (int i = TV_HEIGHT - 1; i >= 0; i--) { // Convert the image. spi_tv_draw_image_cb_convert_grayscale(IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(&dst_img, i), dst_img.data + (PICLINE_LENGTH_BYTES * i)); } } #ifdef __DCACHE_PRESENT // Flush data for DMA SCB_CleanDCache(); #endif // Update head which means a new image is ready. framebuffer_head = new_framebuffer_head; // Kick off an update of the display. if (spi_tx_cb_state == SPI_TX_CB_IDLE) { spi_tx_cb_state = SPI_TX_CB_MEMORY_WRITE_CMD; spi_tv_callback(OMV_SPI_LCD_CONTROLLER->spi); } } } #endif STATIC mp_obj_t py_tv_deinit() { switch (tv_type) { #ifdef OMV_SPI_LCD_CONTROLLER case TV_SHIELD: { spi_config_deinit(); break; } #endif default: { break; } } tv_triple_buffer = false; return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_deinit_obj, py_tv_deinit); STATIC mp_obj_t py_tv_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { py_tv_deinit(); int type = py_helper_keyword_int(n_args, args, 0, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_type), TV_SHIELD); switch (type) { #ifdef OMV_SPI_LCD_CONTROLLER case TV_SHIELD: { bool triple_buffer = py_helper_keyword_int(n_args, args, 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_triple_buffer), false); spi_config_init(triple_buffer); tv_type = TV_SHIELD; tv_triple_buffer = triple_buffer; break; } #endif default: { break; } } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_tv_init_obj, 0, py_tv_init); STATIC mp_obj_t py_tv_width() { if (tv_type == TV_NONE) { return mp_const_none; } return mp_obj_new_int(TV_WIDTH); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_width_obj, py_tv_width); STATIC mp_obj_t py_tv_height() { if (tv_type == TV_NONE) { return mp_const_none; } return mp_obj_new_int(TV_HEIGHT); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_height_obj, py_tv_height); STATIC mp_obj_t py_tv_type() { if (tv_type == TV_NONE) { return mp_const_none; } return mp_obj_new_int(tv_type); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_type_obj, py_tv_type); STATIC mp_obj_t py_tv_triple_buffer() { if (tv_type == TV_NONE) { return mp_const_none; } return mp_obj_new_int(tv_triple_buffer); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_triple_buffer_obj, py_tv_triple_buffer); STATIC mp_obj_t py_tv_refresh() { if (tv_type == TV_NONE) { return mp_const_none; } return mp_obj_new_int(TV_REFRESH); } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_refresh_obj, py_tv_refresh); STATIC mp_obj_t py_tv_channel(uint n_args, const mp_obj_t *args) { if (tv_type == TV_NONE) { return mp_const_none; } #ifdef OMV_SPI_LCD_CONTROLLER if (tv_triple_buffer) { HAL_SPI_Abort(OMV_SPI_LCD_CONTROLLER->spi); spi_tx_cb_state = SPI_TX_CB_IDLE; omv_gpio_write(OMV_SPI_LCD_SSEL_PIN, 1); } if (n_args) { int channel = mp_obj_get_int(*args); if ((channel < 1) || (8 < channel)) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("1 <= channel <= 8!")); } SpiRamWriteByteRegister(WRITE_GPIO, 0x70 | (channel - 1)); } else { int channel = SpiRamReadByteRegister(READ_GPIO); return mp_obj_new_int((channel & 0x7) + 1); } #endif return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(py_tv_channel_obj, 0, 1, py_tv_channel); STATIC mp_obj_t py_tv_display(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) { image_t *arg_img = py_image_cobj(args[0]); int arg_x_off = 0; int arg_y_off = 0; uint offset = 1; if (n_args > 1) { if (MP_OBJ_IS_TYPE(args[1], &mp_type_tuple) || MP_OBJ_IS_TYPE(args[1], &mp_type_list)) { mp_obj_t *arg_vec; mp_obj_get_array_fixed_n(args[1], 2, &arg_vec); arg_x_off = mp_obj_get_int(arg_vec[0]); arg_y_off = mp_obj_get_int(arg_vec[1]); offset = 2; } else if (n_args > 2) { arg_x_off = mp_obj_get_int(args[1]); arg_y_off = mp_obj_get_int(args[2]); offset = 3; } else if (n_args > 1) { mp_raise_msg(&mp_type_TypeError, MP_ERROR_TEXT("Expected x and y offset!")); } } float arg_x_scale = 1.f; bool got_x_scale = py_helper_keyword_float_maybe(n_args, args, offset, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_x_scale), &arg_x_scale); float arg_y_scale = 1.f; bool got_y_scale = py_helper_keyword_float_maybe(n_args, args, offset + 1, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_y_scale), &arg_y_scale); rectangle_t arg_roi; py_helper_keyword_rectangle_roi(arg_img, n_args, args, offset + 2, kw_args, &arg_roi); int arg_rgb_channel = py_helper_keyword_int(n_args, args, offset + 3, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_rgb_channel), -1); if ((arg_rgb_channel < -1) || (2 < arg_rgb_channel)) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("-1 <= rgb_channel <= 2!")); } int arg_alpha = py_helper_keyword_int(n_args, args, offset + 4, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_alpha), 256); if ((arg_alpha < 0) || (256 < arg_alpha)) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("0 <= alpha <= 256!")); } const uint16_t *color_palette = py_helper_keyword_color_palette(n_args, args, offset + 5, kw_args, NULL); const uint8_t *alpha_palette = py_helper_keyword_alpha_palette(n_args, args, offset + 6, kw_args, NULL); image_hint_t hint = py_helper_keyword_int(n_args, args, offset + 7, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_hint), 0); int arg_x_size; bool got_x_size = py_helper_keyword_int_maybe(n_args, args, offset + 8, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_x_size), &arg_x_size); int arg_y_size; bool got_y_size = py_helper_keyword_int_maybe(n_args, args, offset + 9, kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_y_size), &arg_y_size); if (got_x_scale && got_x_size) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Choose either x_scale or x_size not both!")); } if (got_y_scale && got_y_size) { mp_raise_msg(&mp_type_ValueError, MP_ERROR_TEXT("Choose either y_scale or y_size not both!")); } if (got_x_size) { arg_x_scale = arg_x_size / ((float) arg_roi.w); } if (got_y_size) { arg_y_scale = arg_y_size / ((float) arg_roi.h); } if ((!got_x_scale) && (!got_x_size) && got_y_size) { arg_x_scale = arg_y_scale; } if ((!got_y_scale) && (!got_y_size) && got_x_size) { arg_y_scale = arg_x_scale; } switch (tv_type) { #ifdef OMV_SPI_LCD_CONTROLLER case TV_SHIELD: { fb_alloc_mark(); spi_tv_display(arg_img, arg_x_off, arg_y_off, arg_x_scale, arg_y_scale, &arg_roi, arg_rgb_channel, arg_alpha, color_palette, alpha_palette, hint); fb_alloc_free_till_mark(); break; } #endif default: { break; } } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_KW(py_tv_display_obj, 1, py_tv_display); STATIC mp_obj_t py_tv_clear() { switch (tv_type) { #ifdef OMV_SPI_LCD_CONTROLLER case TV_SHIELD: { fb_alloc_mark(); spi_tv_display(NULL, 0, 0, 1.f, 1.f, NULL, 0, 0, NULL, NULL, 0); fb_alloc_free_till_mark(); break; } #endif default: { break; } } return mp_const_none; } STATIC MP_DEFINE_CONST_FUN_OBJ_0(py_tv_clear_obj, py_tv_clear); STATIC const mp_rom_map_elem_t globals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_tv) }, { MP_ROM_QSTR(MP_QSTR_TV_NONE), MP_ROM_INT(TV_NONE) }, { MP_ROM_QSTR(MP_QSTR_TV_SHIELD), MP_ROM_INT(TV_SHIELD) }, { MP_ROM_QSTR(MP_QSTR_init), MP_ROM_PTR(&py_tv_init_obj) }, { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&py_tv_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR_width), MP_ROM_PTR(&py_tv_width_obj) }, { MP_ROM_QSTR(MP_QSTR_height), MP_ROM_PTR(&py_tv_height_obj) }, { MP_ROM_QSTR(MP_QSTR_type), MP_ROM_PTR(&py_tv_type_obj) }, { MP_ROM_QSTR(MP_QSTR_triple_buffer), MP_ROM_PTR(&py_tv_triple_buffer_obj) }, { MP_ROM_QSTR(MP_QSTR_refresh), MP_ROM_PTR(&py_tv_refresh_obj) }, { MP_ROM_QSTR(MP_QSTR_channel), MP_ROM_PTR(&py_tv_channel_obj) }, { MP_ROM_QSTR(MP_QSTR_display), MP_ROM_PTR(&py_tv_display_obj) }, { MP_ROM_QSTR(MP_QSTR_clear), MP_ROM_PTR(&py_tv_clear_obj) }, }; STATIC MP_DEFINE_CONST_DICT(globals_dict, globals_dict_table); const mp_obj_module_t tv_module = { .base = { &mp_type_module }, .globals = (mp_obj_t) &globals_dict, }; void py_tv_init0() { py_tv_deinit(); } MP_REGISTER_MODULE(MP_QSTR_tv, tv_module); #endif // MICROPY_PY_TV
71e08817f9d2e38f0ebb8bba433db478d5c9e298
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/risc-v/src/mpfs/mpfs_opensbi.c
769e9075a0d7b554e12d2a0194f33e45bd90db45
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
18,493
c
mpfs_opensbi.c
/**************************************************************************** * arch/risc-v/src/mpfs/mpfs_opensbi.c * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you 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. * ****************************************************************************/ /**************************************************************************** * Included Files ****************************************************************************/ #include <hardware/mpfs_plic.h> #include <hardware/mpfs_memorymap.h> #include <hardware/mpfs_clint.h> #include <hardware/mpfs_sysreg.h> #ifdef CONFIG_MPFS_IHC_SBI #include <hardware/mpfs_ihc_sbi.h> #endif #include <sbi/riscv_io.h> #include <sbi/riscv_encoding.h> #include <sbi/sbi_console.h> #include <sbi/sbi_platform.h> #include <sbi/sbi_init.h> #include <sbi/sbi_scratch.h> #include <sbi/sbi_trap.h> #include <sbi_utils/irqchip/plic.h> #include <sbi_utils/ipi/aclint_mswi.h> #include <sbi_utils/timer/aclint_mtimer.h> #ifdef CONFIG_MPFS_IHC_SBI #include <mpfs_ihc.h> #endif /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ #define MPFS_SYS_CLK 1000000000 #define MPFS_MAX_NUM_HARTS 5 #define MPFS_HART_COUNT 5 #define MPFS_ACLINT_MSWI_ADDR MPFS_CLINT_MSIP0 #define MPFS_ACLINT_MTIMER_ADDR MPFS_CLINT_MTIMECMP0 #define MPFS_PMP_DEFAULT_ADDR 0xfffffffff #define MPFS_PMP_DEFAULT_PERM 0x000000009f #define MPFS_SYSREG_SOFT_RESET_CR (MPFS_SYSREG_BASE + \ MPFS_SYSREG_SOFT_RESET_CR_OFFSET) #define MPFS_SYSREG_SUBBLK_CLOCK_CR (MPFS_SYSREG_BASE + \ MPFS_SYSREG_SUBBLK_CLOCK_CR_OFFSET) #define MICROCHIP_TECHNOLOGY_MVENDOR_ID 0x029 #define SBI_EXT_MICROCHIP_TECHNOLOGY (SBI_EXT_VENDOR_START | \ MICROCHIP_TECHNOLOGY_MVENDOR_ID) /**************************************************************************** * Private Types ****************************************************************************/ struct sbi_scratch_holder_s { union { struct sbi_scratch scratch; unsigned long buffer[SBI_SCRATCH_SIZE / sizeof(uintptr_t)]; }; }; typedef struct sbi_scratch_holder_s sbi_scratch_holder_t; /* Linker provided region start / end addresses */ extern const uint8_t __mpfs_nuttx_start[]; extern const uint8_t __mpfs_nuttx_end[]; /**************************************************************************** * Private Function Prototypes ****************************************************************************/ static void mpfs_console_putc(char ch); static int mpfs_early_init(bool cold_boot); static int mpfs_opensbi_console_init(void); static int mpfs_irqchip_init(bool cold_boot); static int mpfs_ipi_init(bool cold_boot); static int mpfs_timer_init(bool cold_boot); #ifdef CONFIG_MPFS_IHC_SBI static int mpfs_opensbi_vendor_ext_check(long extid); static int mpfs_opensbi_ecall_handler(long extid, long funcid, const struct sbi_trap_regs *regs, unsigned long *out_val, struct sbi_trap_info *out_trap); #endif /**************************************************************************** * Extern Function Declarations ****************************************************************************/ /* riscv_internal.h cannot be included due to a number of redefinition * conflicts. Thus, define the riscv_lowputc() with the extern definition. */ extern void riscv_lowputc(char ch); extern uintptr_t mpfs_get_entrypt(uint64_t hartid); /* domains init implemented in board specific file */ #ifdef CONFIG_OPENSBI_DOMAINS extern int board_domains_init(void); #endif /**************************************************************************** * Private Data ****************************************************************************/ static bool mpfs_console_ready = false; static struct plic_data mpfs_plic = { .addr = MPFS_PLIC_BASE, .num_src = MPFS_HART_COUNT, }; static struct sbi_console_device mpfs_console = { .name = "mpfs_uart", .console_putc = mpfs_console_putc, .console_getc = NULL, }; static struct aclint_mtimer_data mpfs_mtimer = { .mtime_freq = MPFS_SYS_CLK, .mtime_addr = MPFS_ACLINT_MTIMER_ADDR + ACLINT_DEFAULT_MTIME_OFFSET, .mtime_size = ACLINT_DEFAULT_MTIME_SIZE, .mtimecmp_addr = MPFS_ACLINT_MTIMER_ADDR + ACLINT_DEFAULT_MTIMECMP_OFFSET, .mtimecmp_size = ACLINT_DEFAULT_MTIMECMP_SIZE, .first_hartid = 0, .hart_count = MPFS_HART_COUNT, .has_64bit_mmio = TRUE, }; static const struct sbi_platform_operations platform_ops = { #ifdef CONFIG_OPENSBI_DOMAINS .domains_init = board_domains_init, #endif .console_init = mpfs_opensbi_console_init, .early_init = mpfs_early_init, .irqchip_init = mpfs_irqchip_init, .irqchip_exit = NULL, .ipi_init = mpfs_ipi_init, .ipi_exit = NULL, .timer_init = mpfs_timer_init, .timer_exit = NULL, #ifdef CONFIG_MPFS_IHC_SBI .vendor_ext_check = mpfs_opensbi_vendor_ext_check, .vendor_ext_provider = mpfs_opensbi_ecall_handler, #endif }; static struct aclint_mswi_data mpfs_mswi = { .addr = MPFS_ACLINT_MSWI_ADDR, .size = ACLINT_MSWI_SIZE, .first_hartid = 0, .hart_count = MPFS_HART_COUNT, }; /* OpenSBI picks the used and unused harts via the hart_index2id table. * Unused hart is marked with -1. Mpfs will always have the hart0 unused. */ static const u32 mpfs_hart_index2id[MPFS_HART_COUNT] = { [0] = -1, #ifdef CONFIG_MPFS_HART1_SBI [1] = 1, #else [1] = -1, #endif #ifdef CONFIG_MPFS_HART2_SBI [2] = 2, #else [2] = -1, #endif #ifdef CONFIG_MPFS_HART3_SBI [3] = 3, #else [3] = -1, #endif #ifdef CONFIG_MPFS_HART4_SBI [4] = 4, #else [4] = -1, #endif }; static const struct sbi_platform platform = { .opensbi_version = OPENSBI_VERSION, .platform_version = SBI_PLATFORM_VERSION(0x0, 0x01), .name = "Microchip PolarFire(R) SoC", .features = SBI_PLATFORM_DEFAULT_FEATURES, .hart_count = MPFS_HART_COUNT, .hart_index2id = mpfs_hart_index2id, .hart_stack_size = SBI_PLATFORM_DEFAULT_HART_STACK_SIZE, .platform_ops_addr = (unsigned long)&platform_ops, .firmware_context = 0 }; /* This must go into l2_scratchpad region, starting at 0x0a000000. */ sbi_scratch_holder_t g_scratches[MPFS_MAX_NUM_HARTS] \ __attribute__((section(".l2_scratchpad"))); /**************************************************************************** * Private Functions ****************************************************************************/ /**************************************************************************** * Name: mpfs_hart_to_scratch * * Description: * Returns the scratch area start for the given hart. * * Input Parameters: * hartid (0,1..5) * * Returned Value: * The scratch area in l2_scratchpad. * ****************************************************************************/ static unsigned long mpfs_hart_to_scratch(int hartid) { return (unsigned long)(&g_scratches[hartid].scratch); } /**************************************************************************** * Name: mpfs_irqchip_init * * Description: * Sets the interrupt priorities via the plic_cold_irqchip_init() call. * Also this provides the proper PLIC base address for further irq * property handling such as threshold levels. * * Input Parameters: * cold_boot - True, if this is the hart doing the real boot * * Returned Value: * Zero (OK) is returned on success. A negated errno value is returned on * failure. * ****************************************************************************/ static int mpfs_irqchip_init(bool cold_boot) { int rc; uint32_t hartid = current_hartid(); if (cold_boot) { rc = plic_cold_irqchip_init(&mpfs_plic); if (rc) { return rc; } } return plic_warm_irqchip_init(&mpfs_plic, (hartid) ? (2 * hartid - 1) : 0, (hartid) ? (2 * hartid) : -1); } /**************************************************************************** * Name: mpfs_console_putc * * Description: * Sets the interrupt priorities via the plic_cold_irqchip_init() call. * Also this provides the proper PLIC base address for further irq * property handling such as threshold levels. * * Input Parameters: * ch - Character to be printed out * * Returned Value: * None * ****************************************************************************/ static void mpfs_console_putc(char ch) { #ifdef CONFIG_DEBUG_FEATURES if (mpfs_console_ready) { riscv_lowputc(ch); } #endif } /**************************************************************************** * Name: mpfs_opensbi_console_init * * Description: * Initializes the console for OpenSBI usage. OpenSBI expects this * function to be present. * * Input Parameters: * None * * Returned Value: * Always zero indicating a success. * ****************************************************************************/ static int mpfs_opensbi_console_init(void) { mpfs_console_ready = true; return 0; } /**************************************************************************** * Name: mpfs_ipi_init * * Description: * Initializes the IPI for OpenSBI usage. Also adds the regions into * OpenSBI domains. * * Input Parameters: * cold_boot - Indicates the primary boot hart * * Returned Value: * Zero (OK) is returned on success. A negated errno value is returned on * failure. * ****************************************************************************/ static int mpfs_ipi_init(bool cold_boot) { int rc; if (cold_boot) { rc = aclint_mswi_cold_init(&mpfs_mswi); if (rc) { return rc; } } return aclint_mswi_warm_init(); } /**************************************************************************** * Name: mpfs_timer_init * * Description: * Initializes the clint timer interface. Commands such as "csrr a0, time" * (reading the CSR time register) will cause an illegal instruction * exception, because the hardware has no support for it. That command is * emulated via the CLINT timer in the OpenSBI trap handler. * * Input Parameters: * cold_boot - If set, indicates the primary boot hart * * Returned Value: * Zero (OK) is returned on success. A negated errno value is returned on * failure. * ****************************************************************************/ static int mpfs_timer_init(bool cold_boot) { int rc; if (cold_boot) { rc = aclint_mtimer_cold_init(&mpfs_mtimer, NULL); if (rc) { return rc; } } return aclint_mtimer_warm_init(); } /**************************************************************************** * Name: mpfs_early_init * * Description: * Initializes the clint timer interface. Commands such as "csrr a0, time" * (reading the CSR time register) will cause an illegal instruction * exception, because the hardware has no support for it. That command is * emulated via the CLINT timer in the OpenSBI trap handler. * * Input Parameters: * cold_boot - If set, indicates the primary boot hart * * Returned Value: * Zero (OK) is returned on success. * ****************************************************************************/ static int mpfs_early_init(bool cold_boot) { uint32_t val; /* We expect that e51 has terminated the following irqs with * up_disable_irq(): * 1. MPFS_IRQ_MMC_MAIN * 2. MPFS_IRQ_MTIMER * * U-boot will reuse eMMC and loads the kernel from there. OpenSBI will * use CLINT timer. Upstream u-boot doesn't turn the clocks on itsef. */ if (!cold_boot) { return 0; } /* Explicitly reset eMMC */ val = readl((void *)MPFS_SYSREG_SOFT_RESET_CR); writel(val | SYSREG_SOFT_RESET_CR_MMC, (void *)MPFS_SYSREG_SOFT_RESET_CR); writel(val & ~SYSREG_SOFT_RESET_CR_MMC, (void *)MPFS_SYSREG_SOFT_RESET_CR); /* There are other clocks that need to be enabled for the Linux kernel to * run. For now, turn on all the clocks. */ writel(0x0, (void *)MPFS_SYSREG_SOFT_RESET_CR); writel(0x7fffffff, (void *)MPFS_SYSREG_SUBBLK_CLOCK_CR); return 0; } /**************************************************************************** * Name: mpfs_opensbi_scratch_setup * * Description: * Initializes the scratch area per hart. The scratch area is used to save * and restore registers (see mpfs_exception_opensbi), and to send and * reveice messages to other harts via the IPI mechanism. * * Input Parameters: * hartid - hart number to be prepared * * Returned Value: * None * ****************************************************************************/ static void mpfs_opensbi_scratch_setup(uint32_t hartid) { g_scratches[hartid].scratch.options = SBI_SCRATCH_DEBUG_PRINTS; g_scratches[hartid].scratch.hartid_to_scratch = (unsigned long)mpfs_hart_to_scratch; g_scratches[hartid].scratch.platform_addr = (unsigned long)&platform; /* Our FW area in l2lim section. OpenSBI needs to be aware of it in order * to protect the area. However, we set the PMP values already and lock * them so that OpenSBI has no chance override then. */ g_scratches[hartid].scratch.fw_start = (unsigned long)__mpfs_nuttx_start; g_scratches[hartid].scratch.fw_size = (unsigned long)__mpfs_nuttx_end - (unsigned long)__mpfs_nuttx_start; } /**************************************************************************** * Name: mpfs_opensbi_pmp_setup * * Description: * Initializes the PMP registers in a known default state. All harts need * to set these registers. * * Input Parameters: * None * * Returned Value: * None * ****************************************************************************/ static void mpfs_opensbi_pmp_setup(void) { /* All access granted */ csr_write(pmpaddr0, MPFS_PMP_DEFAULT_ADDR); csr_write(pmpcfg0, MPFS_PMP_DEFAULT_PERM); csr_write(pmpcfg2, 0); } /**************************************************************************** * Name: mpfs_opensbi_vendor_ext_check * * Description: * Used by the OpenSBI in vendor probe to check the vendor ID. * * Input Parameters: * extid - Vendor ID to be checked * * Returned Value: * 1 on match, zero in case of no match * ****************************************************************************/ #ifdef CONFIG_MPFS_IHC_SBI static int mpfs_opensbi_vendor_ext_check(long extid) { return (SBI_EXT_MICROCHIP_TECHNOLOGY == extid); } /**************************************************************************** * Name: mpfs_opensbi_ecall_handler * * Description: * Used by the S-mode kernel such as Linux to perform M-mode ecall actions * related to Inter-Hart Communication (IHC). * * Input Parameters: * extid - Vendor ID * funcid - One of the valid functions * sbi_trap_regs - SBI trap registers * out_val - Error code location * out_trap - Trap registers such as epc, unused * * Returned Value: * 0 always * ****************************************************************************/ static int mpfs_opensbi_ecall_handler(long extid, long funcid, const struct sbi_trap_regs *regs, unsigned long *out_val, struct sbi_trap_info *out_trap) { uint32_t remote_channel = (uint32_t)regs->a0; uint32_t *message_ptr = (uint32_t *)regs->a1; int result = 0; switch (funcid) { case SBI_EXT_IHC_CTX_INIT: case SBI_EXT_IHC_SEND: case SBI_EXT_IHC_RECEIVE: result = mpfs_ihc_sbi_ecall_handler(funcid, remote_channel, message_ptr); break; default: result = SBI_ENOTSUPP; } *out_val = result; return 0; } #endif /**************************************************************************** * Public Functions ****************************************************************************/ /**************************************************************************** * Name: mpfs_opensbi_setup * * Description: * Calls the necessary OpenSBI init functions: * - Sets up the PMP registers (to avoid OpenSBI overriding them) * - Sets up the OpenSBI console * - Sets up the mscratch registers * - Sets up the firmware to be run (should be already at .next_addr) * - Calls the sbi_init() that will not return * * Input Parameters: * None * * Returned Value: * None - this will never return * ****************************************************************************/ void __attribute__((noreturn)) mpfs_opensbi_setup(void) { uint32_t hartid = current_hartid(); mpfs_opensbi_pmp_setup(); sbi_console_set_device(&mpfs_console); mpfs_opensbi_scratch_setup(hartid); csr_write(mscratch, &g_scratches[hartid].scratch); g_scratches[hartid].scratch.next_mode = PRV_S; g_scratches[hartid].scratch.next_addr = mpfs_get_entrypt(hartid); g_scratches[hartid].scratch.next_arg1 = 0; sbi_init(&g_scratches[hartid].scratch); /* Will never get here */ sbi_panic(__func__); }
eb5e9e44b77b76906adcd5a1f8cc5877728883a0
88ae8695987ada722184307301e221e1ba3cc2fa
/buildtools/third_party/libc++/trunk/test/support/msvc_stdlib_force_include.h
3c61f0b880b18c1a6da3929c19fb5865dec3c959
[ "NCSA", "LLVM-exception", "MIT", "Apache-2.0", "BSD-3-Clause" ]
permissive
iridium-browser/iridium-browser
71d9c5ff76e014e6900b825f67389ab0ccd01329
5ee297f53dc7f8e70183031cff62f37b0f19d25f
refs/heads/master
2023-08-03T16:44:16.844552
2023-07-20T15:17:00
2023-07-23T16:09:30
220,016,632
341
40
BSD-3-Clause
2021-08-13T13:54:45
2019-11-06T14:32:31
null
UTF-8
C
false
false
3,783
h
msvc_stdlib_force_include.h
//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H #define SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H // This header is force-included when running the libc++ tests against the // MSVC standard library. #ifndef _LIBCXX_IN_DEVCRT // Silence warnings about CRT machinery. #define _CRT_SECURE_NO_WARNINGS 1 // Avoid assertion dialogs. #define _CRT_SECURE_INVALID_PARAMETER(EXPR) ::abort() #endif // _LIBCXX_IN_DEVCRT #include <crtdbg.h> #include <stdlib.h> #if defined(_LIBCPP_VERSION) #error This header may not be used when targeting libc++ #endif #ifndef _LIBCXX_IN_DEVCRT struct AssertionDialogAvoider { AssertionDialogAvoider() { _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); } }; const AssertionDialogAvoider assertion_dialog_avoider{}; #endif // _LIBCXX_IN_DEVCRT // MSVC frontend only configurations #if !defined(__clang__) // Simulate feature-test macros. #define __has_feature(X) _MSVC_HAS_FEATURE_ ## X #define _MSVC_HAS_FEATURE_cxx_exceptions 1 #define _MSVC_HAS_FEATURE_cxx_rtti 1 #define _MSVC_HAS_FEATURE_address_sanitizer 0 #define _MSVC_HAS_FEATURE_memory_sanitizer 0 #define _MSVC_HAS_FEATURE_thread_sanitizer 0 #define __has_attribute(X) _MSVC_HAS_ATTRIBUTE_ ## X #define _MSVC_HAS_ATTRIBUTE_vector_size 0 // Silence compiler warnings. #pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored #pragma warning(disable: 4324) // structure was padded due to alignment specifier #pragma warning(disable: 4521) // multiple copy constructors specified #pragma warning(disable: 4702) // unreachable code #pragma warning(disable: 28251) // Inconsistent annotation for 'new': this instance has no annotations. #endif // !defined(__clang__) #ifndef _LIBCXX_IN_DEVCRT // atomic_is_lock_free.pass.cpp needs this VS 2015 Update 2 fix. #define _ENABLE_ATOMIC_ALIGNMENT_FIX // Restore features that are removed in C++20. #define _HAS_FEATURES_REMOVED_IN_CXX20 1 // Silence warnings about the unspecified complex<non-floating-point> #define _SILENCE_NONFLOATING_COMPLEX_DEPRECATION_WARNING // Silence warnings about features that are deprecated in non-default language modes. #define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS #define _SILENCE_ALL_CXX20_DEPRECATION_WARNINGS #define _SILENCE_ALL_CXX23_DEPRECATION_WARNINGS #endif // _LIBCXX_IN_DEVCRT #include <version> #if _HAS_CXX23 #define TEST_STD_VER 99 #elif _HAS_CXX20 #define TEST_STD_VER 20 #elif _HAS_CXX17 #define TEST_STD_VER 17 #else #define TEST_STD_VER 14 #endif #define _LIBCPP_AVAILABILITY_THROW_BAD_ANY_CAST #ifdef __clang__ #define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ _Pragma("GCC diagnostic push") \ _Pragma("GCC diagnostic ignored \"-Wdeprecated\"") #define _LIBCPP_SUPPRESS_DEPRECATED_POP \ _Pragma("GCC diagnostic pop") #else // ^^^ clang / MSVC vvv #define _LIBCPP_SUPPRESS_DEPRECATED_PUSH \ __pragma(warning(push)) \ __pragma(warning(disable : 4996)) \ __pragma(warning(disable : 5215)) #define _LIBCPP_SUPPRESS_DEPRECATED_POP \ __pragma(warning(pop)) #endif // __clang__ #endif // SUPPORT_MSVC_STDLIB_FORCE_INCLUDE_H
e8a617a864bfa80e8786c29eedec6cbb188511fa
454820ba5d1b51b97c9d0485f88322a29577b08c
/bpf/filter.c
2d0e59cd2e7710b0a9e2341687bf8fcb6fb49ccf
[ "Apache-2.0" ]
permissive
aojea/netkat
becdc58de091a351107bb574065558546d837ea9
0aff52e544e0df9b96fea261a4a9b96a36ad44f3
refs/heads/main
2023-07-19T13:17:37.389576
2021-09-20T06:44:50
2021-09-20T06:44:50
364,681,851
131
4
Apache-2.0
2021-09-20T08:14:30
2021-05-05T19:13:42
Go
UTF-8
C
false
false
4,359
c
filter.c
#include <linux/bpf.h> #include <linux/in.h> #include <linux/if_ether.h> #include <linux/if_packet.h> #include <linux/if_vlan.h> #include <linux/ip.h> #include <linux/tcp.h> #include <linux/udp.h> #include <linux/pkt_cls.h> #include "bpf_helpers.h" #include "bpf_endian.h" // #define DEBUG 1 #ifdef DEBUG /* Only use this for debug output. Notice output from bpf_trace_printk() * end-up in /sys/kernel/debug/tracing/trace_pipe */ #define bpf_debug(fmt, ...) \ ( \ { \ char ____fmt[] = fmt; \ bpf_trace_printk(____fmt, sizeof(____fmt), \ ##__VA_ARGS__); \ }) #else #define bpf_debug(fmt, ...) \ { \ } \ while (0) #endif #define AF_INET 2 /* IP protocol family. */ #define AF_INET6 10 /* IP version 6. */ /* * #define PROTO IPPROTO_ICMP * #define IP_FAMILY AF_INET * #define SRC_IP 0xAC110002 * #define DST_IP 0 * #define SRC_PORT 0 * #define DST_PORT 80 */ /* * Constants that define the filter: * ipFamily: ipv4 or ipv6 * protocol: TCP or UDP * destIP * srcIP * destPort * srcPort */ static volatile unsigned const char IP_FAMILY; static volatile unsigned const char IP_FAMILY = 4; static volatile unsigned const int SRC_IP; static volatile unsigned const int SRC_IP = 0; static volatile unsigned const int DST_IP; static volatile unsigned const int DST_IP = 0; static volatile unsigned const char PROTO; static volatile unsigned const char PROTO = IPPROTO_ICMP; static volatile unsigned const short SRC_PORT; static volatile unsigned const short SRC_PORT = 0; static volatile unsigned const short DST_PORT; static volatile unsigned const short DST_PORT = 0; SEC("classifier") int _ingress(struct __sk_buff *skb) { __be32 dest_ip = 0, src_ip = 0; __be16 dest_port = 0, src_port = 0; __u16 h_proto; __u64 nh_off; int ipproto; void *data = (void *)(long)skb->data; struct ethhdr *eth = data; void *data_end = (void *)(long)skb->data_end; nh_off = sizeof(*eth); if (data + nh_off > data_end) return TC_ACT_OK; /* allow arp */ h_proto = eth->h_proto; if (h_proto == __constant_htons(ETH_P_RARP) || h_proto == __constant_htons(ETH_P_ARP)) { return TC_ACT_OK; } /* allow non IPv4 */ if (h_proto != __constant_htons(ETH_P_IP) && IP_FAMILY != AF_INET) return TC_ACT_OK; /* get IP header */ struct iphdr *iph = data + nh_off; if (iph + 1 > data_end) return TC_ACT_OK; /* get IP transport protocol */ src_ip = __bpf_ntohl(iph->saddr); dest_ip = __bpf_ntohl(iph->daddr); bpf_debug("ip src %x ip dst %x", src_ip, dest_ip); // if SRC_IP specified check it if (SRC_IP != 0 && src_ip != SRC_IP) { bpf_debug("ip src %x does not match %x", src_ip, SRC_IP); return TC_ACT_OK; } // if DST_IP specified check it if (DST_IP != 0 && dest_ip != DST_IP) { bpf_debug("ip dest %x does not match %x", dest_ip, DST_IP); return TC_ACT_OK; } ipproto = iph->protocol; if (ipproto != PROTO) { return TC_ACT_OK; } /* get transport ports */ struct udphdr *udph; struct tcphdr *tcph; switch (ipproto) { case IPPROTO_UDP: udph = iph + 1; if (udph + 1 > data_end) { bpf_debug("Invalid UDPv4 packet: L4off:%llu\n", sizeof(struct iphdr) + sizeof(struct udphdr)); return TC_ACT_OK; } src_port = __bpf_ntohs(udph->source); dest_port = __bpf_ntohs(udph->dest); break; case IPPROTO_TCP: tcph = iph + 1; if (tcph + 1 > data_end) { bpf_debug("Invalid TCPv4 packet: L4off:%llu\n", sizeof(struct iphdr) + sizeof(struct tcphdr)); return TC_ACT_OK; } src_port = __bpf_ntohs(tcph->source); dest_port = __bpf_ntohs(tcph->dest); break; default: return TC_ACT_OK; } bpf_debug("src port %x dst port %x", src_port, dest_port); // if SRC_PORT specified check it if (SRC_PORT != 0 && src_port != SRC_PORT) { bpf_debug("src port %x does not match %x", src_port, SRC_PORT); return TC_ACT_OK; } // if DST_PORT specified check it if (DST_PORT != 0 && dest_port != DST_PORT) { bpf_debug("dest port %x does not match %x", dest_port, DST_PORT); return TC_ACT_OK; } // it matches 5-tuple, drop it like is hot bpf_debug("dropping"); return TC_ACT_SHOT; } char _license[] SEC("license") = "GPL";
6e0a14c4a975a7e5cbf67069b67f900080335425
035660e8cc10571ebbd0d4393fef063bb7eb98f6
/src/overlays/actors/ovl_En_Kendo_Js/z_en_kendo_js.c
0b4fe5e686683f2cc75378b45d21c31df9cabcc6
[]
no_license
zeldaret/mm
f163a5e7c4314105777369fa7671ce9c2a99922a
4ae00e909e74044f05155683b49d2561f91de7ba
refs/heads/master
2023-08-06T07:22:04.912966
2023-08-04T20:36:03
2023-08-04T20:36:03
247,875,852
915
328
null
2023-09-14T11:48:59
2020-03-17T04:03:07
C
UTF-8
C
false
false
25,237
c
z_en_kendo_js.c
/* * File: z_en_kendo_js.c * Overlay: ovl_En_Kendo_Js * Description: Swordsman */ #include "z_en_kendo_js.h" #include "overlays/actors/ovl_En_Maruta/z_en_maruta.h" #include "objects/object_js/object_js.h" #define FLAGS (ACTOR_FLAG_1 | ACTOR_FLAG_8 | ACTOR_FLAG_10 | ACTOR_FLAG_2000000 | ACTOR_FLAG_CANT_LOCK_ON) #define THIS ((EnKendoJs*)thisx) void EnKendoJs_Init(Actor* thisx, PlayState* play); void EnKendoJs_Destroy(Actor* thisx, PlayState* play); void EnKendoJs_Update(Actor* thisx, PlayState* play); void EnKendoJs_Draw(Actor* thisx, PlayState* play); void func_80B26538(EnKendoJs* this); void func_80B2654C(EnKendoJs* this, PlayState* play); void func_80B26AE8(EnKendoJs* this); void func_80B26AFC(EnKendoJs* this, PlayState* play); void func_80B2701C(EnKendoJs* this); void func_80B27030(EnKendoJs* this, PlayState* play); void func_80B2714C(EnKendoJs* this); void func_80B27188(EnKendoJs* this, PlayState* play); void func_80B273D0(EnKendoJs* this); void func_80B2740C(EnKendoJs* this, PlayState* play); void func_80B274BC(EnKendoJs* this, PlayState* play); void func_80B276C4(EnKendoJs* this); void func_80B276D8(EnKendoJs* this, PlayState* play); void func_80B27760(EnKendoJs* this); void func_80B27774(EnKendoJs* this, PlayState* play); void func_80B2783C(EnKendoJs* this, PlayState* play); s32 func_80B278C4(PlayState* play, Vec3f arg1); void func_80B279F0(EnKendoJs* this, PlayState* play, s32 arg2); void func_80B27A90(EnKendoJs* this, PlayState* play); ActorInit En_Kendo_Js_InitVars = { ACTOR_EN_KENDO_JS, ACTORCAT_NPC, FLAGS, OBJECT_JS, sizeof(EnKendoJs), (ActorFunc)EnKendoJs_Init, (ActorFunc)EnKendoJs_Destroy, (ActorFunc)EnKendoJs_Update, (ActorFunc)EnKendoJs_Draw, }; static ColliderCylinderInit sCylinderInit = { { COLTYPE_NONE, AT_NONE, AC_NONE, OC1_ON | OC1_TYPE_ALL, OC2_TYPE_2, COLSHAPE_CYLINDER, }, { ELEMTYPE_UNK0, { 0x00000000, 0x00, 0x00 }, { 0xF7CFFFFF, 0x00, 0x00 }, TOUCH_NONE | TOUCH_SFX_NORMAL, BUMP_NONE, OCELEM_ON, }, { 18, 30, 0, { 0, 0, 0 } }, }; static CollisionCheckInfoInit2 sColChkInfoInit = { 0, 0, 0, 0, MASS_IMMOVABLE }; static AnimationInfo sAnimationInfo[] = { { &object_js_Anim_000C7C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, { &object_js_Anim_000F4C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, { &object_js_Anim_00016C, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, { &object_js_Anim_0003DC, 1.0f, 0.0f, 0.0f, ANIMMODE_ONCE, -8.0f }, { &object_js_Anim_000AD4, 1.0f, 0.0f, 0.0f, ANIMMODE_LOOP, -8.0f }, }; s16 D_80B27CE0[][3] = { { 0x2731, 0x2732, 0x2733 }, { 0x2734, 0x2735, 0x2736 }, { 0x2737, 0x2738, 0x2739 }, }; s16 D_80B27CF4[][3] = { { 0x2710, 0x2712, 0x2714 }, { 0x2711, 0x2713, 0x2715 }, }; s16 D_80B27D00[] = { 0x271C, 0x271E, 0x2720, 0x2722, 0x2724, 0x2726, 0x2728, }; s16 D_80B27D10[] = { 0x271B, 0x271D, 0x271F, 0x2721, 0x2723, 0x2725, 0x2727, }; void EnKendoJs_Init(Actor* thisx, PlayState* play) { s32 pad; EnKendoJs* this = THIS; ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawCircle, 36.0f); Collider_InitCylinder(play, &this->collider); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); CollisionCheck_SetInfo2(&this->actor.colChkInfo, DamageTable_Get(0x16), &sColChkInfoInit); SkelAnime_InitFlex(play, &this->skelAnime, &object_js_Skel_006990, &object_js_Anim_000F4C, this->jointTable, this->morphTable, 13); if ((CURRENT_DAY == 3) && !((gSaveContext.save.time <= CLOCK_TIME(23, 0)) && (gSaveContext.save.time >= CLOCK_TIME(6, 0)))) { if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { Actor_Spawn(&play->actorCtx, play, ACTOR_EN_KANBAN, this->actor.home.pos.x, this->actor.home.pos.y, this->actor.home.pos.z - 10.0f, this->actor.home.rot.x, this->actor.home.rot.y, this->actor.home.rot.z, 0x10); Actor_Kill(&this->actor); } else { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 4); } } else if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { Actor_Kill(&this->actor); } Actor_UpdateBgCheckInfo(play, &this->actor, 0.0f, 0.0f, 0.0f, UPDBGCHECKINFO_FLAG_4); if (ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) { Path* path = &play->setupPathList[ENKENDOJS_GET_FF00(&this->actor)]; this->unk_274 = Lib_SegmentedToVirtual(path->points); } this->actor.flags &= ~ACTOR_FLAG_1; this->actor.focus.pos = this->actor.world.pos; this->actor.focus.pos.y += 30.0f; this->actor.child = NULL; this->unk_28A = 0; this->unk_28C = 0; this->unk_28E = 0; this->unk_286 = 0; func_80B26538(this); } void EnKendoJs_Destroy(Actor* thisx, PlayState* play) { EnKendoJs* this = THIS; Collider_DestroyCylinder(play, &this->collider); CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); } void func_80B26538(EnKendoJs* this) { this->actionFunc = func_80B2654C; } void func_80B2654C(EnKendoJs* this, PlayState* play) { s32 phi_v0; s32 sp30; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (CURRENT_DAY != 0) { sp30 = CURRENT_DAY - 1; } else { sp30 = 0; } if (ENKENDOJS_GET_FF(&this->actor) == ENKENDOJS_FF_1) { Message_StartTextbox(play, 0x273C, &this->actor); this->unk_288 = 0x273C; } else if (GET_PLAYER_FORM != PLAYER_FORM_HUMAN) { switch (GET_PLAYER_FORM) { case PLAYER_FORM_DEKU: phi_v0 = 0; break; case PLAYER_FORM_GORON: phi_v0 = 1; break; case PLAYER_FORM_ZORA: phi_v0 = 2; break; default: phi_v0 = 0; break; } Message_StartTextbox(play, D_80B27CE0[phi_v0][sp30], &this->actor); this->unk_288 = D_80B27CE0[phi_v0][sp30]; } else if ((Player_GetMask(play) != PLAYER_MASK_NONE) && (Player_GetMask(play) < PLAYER_MASK_GIANT)) { u16 sp2E = Player_GetMask(play) + 0x273C; //! FAKE: if (1) {} Message_StartTextbox(play, sp2E, &this->actor); this->unk_288 = sp2E; } else { if (this->unk_28A == 0) { this->unk_28A = 1; phi_v0 = 0; } else { phi_v0 = 1; } Message_StartTextbox(play, D_80B27CF4[phi_v0][sp30], &this->actor); this->unk_288 = D_80B27CF4[phi_v0][sp30]; } func_80B26AE8(this); } else { Actor_OfferTalk(&this->actor, play, 100.0f); } } void func_80B26758(EnKendoJs* this, PlayState* play) { if (Message_ShouldAdvance(play) && (this->unk_288 == 0x2716)) { switch (play->msgCtx.choiceIndex) { case 0: if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); } else if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk1206C) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2718, &this->actor); this->unk_288 = 0x2718; } else { Audio_PlaySfx_MessageDecide(); Rupees_ChangeBy(-play->msgCtx.unk1206C); Message_StartTextbox(play, 0x2719, &this->actor); this->unk_288 = 0x2719; } break; case 1: if (GET_CUR_EQUIP_VALUE(EQUIP_TYPE_SWORD) == EQUIP_VALUE_SWORD_NONE) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x272C, &this->actor); this->unk_288 = 0x272C; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); } else if (gSaveContext.save.saveInfo.playerData.rupees < play->msgCtx.unk12070) { Audio_PlaySfx(NA_SE_SY_ERROR); Message_StartTextbox(play, 0x2718, &this->actor); this->unk_288 = 0x2718; } else { Audio_PlaySfx_MessageDecide(); Rupees_ChangeBy(-play->msgCtx.unk12070); Message_StartTextbox(play, 0x273A, &this->actor); this->unk_288 = 0x273A; } break; case 2: Audio_PlaySfx_MessageCancel(); Message_StartTextbox(play, 0x2717, &this->actor); this->unk_288 = 0x2717; } } } void func_80B269A4(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); if (!Message_ShouldAdvance(play)) { return; } switch (this->unk_288) { case 0x2710: case 0x2711: case 0x2712: case 0x2713: case 0x2714: case 0x2715: Message_StartTextbox(play, 0x2716, &this->actor); this->unk_288 = 0x2716; break; case 0x2719: Message_CloseTextbox(play); player->stateFlags1 |= PLAYER_STATE1_20; func_80B2701C(this); break; case 0x271A: Message_CloseTextbox(play); func_80B2714C(this); break; case 0x273A: Message_StartTextbox(play, 0x273B, &this->actor); this->unk_288 = 0x273B; break; case 0x273B: Message_CloseTextbox(play); Interface_InitMinigame(play); player->stateFlags1 |= PLAYER_STATE1_20; func_80B273D0(this); break; case 0x272D: Message_CloseTextbox(play); gSaveContext.minigameStatus = MINIGAME_STATUS_END; func_80B276C4(this); func_80B276D8(this, play); break; } } void func_80B26AE8(EnKendoJs* this) { this->actionFunc = func_80B26AFC; } void func_80B26AFC(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); switch (Message_GetState(&play->msgCtx)) { case TEXT_STATE_CHOICE: func_80B26758(this, play); break; case TEXT_STATE_5: func_80B269A4(this, play); break; case TEXT_STATE_DONE: if (Message_ShouldAdvance(play)) { if (this->unk_288 == 0x272C) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); } if ((this->unk_288 == 0x272E) || (this->unk_288 == 0x272F) || (this->unk_288 == 0x2730)) { gSaveContext.minigameStatus = MINIGAME_STATUS_END; } player->stateFlags1 &= ~PLAYER_STATE1_20; func_80B26538(this); } case TEXT_STATE_NONE: case TEXT_STATE_1: case TEXT_STATE_CLOSING: case TEXT_STATE_3: break; } } s32 func_80B26BF8(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); switch (this->unk_284) { case 0: if (func_80122FCC(play)) { return 0; } if ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } break; case 1: if ((player->stateFlags3 & PLAYER_STATE3_8000000)) { return 0; } if ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } break; case 2: if (func_80122F9C(play)) { return 0; } if ((player->meleeWeaponState != PLAYER_MELEE_WEAPON_STATE_0) || (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { return 1; } this->unk_28E = 0; break; case 3: if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_SLASH_1H) || (player->meleeWeaponAnimation == PLAYER_MWA_RIGHT_COMBO_1H))) { this->unk_28E = 0; return 0; } if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } break; case 4: if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_SLASH_1H) || (player->meleeWeaponAnimation == PLAYER_MWA_FORWARD_COMBO_1H))) { this->unk_28E = 0; return 0; } if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } break; case 5: if ((this->unk_28E == 1) && (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H)) { this->unk_28E = 0; return 0; } if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } break; case 6: if ((this->unk_28E == 1) && ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH))) { this->unk_28E = 0; return 0; } if ((this->unk_28E == 1) || (player->stateFlags3 & PLAYER_STATE3_8000000) || (player->stateFlags2 & PLAYER_STATE2_80000)) { this->unk_28E = 0; return 1; } break; } return 2; } void func_80B26EB4(EnKendoJs* this, PlayState* play) { Message_StartTextbox(play, D_80B27D00[this->unk_284], &this->actor); this->unk_288 = D_80B27D00[this->unk_284]; this->unk_284++; } void func_80B26F14(EnKendoJs* this, PlayState* play) { Message_StartTextbox(play, D_80B27D10[this->unk_284], &this->actor); this->unk_288 = D_80B27D10[this->unk_284]; } s32 func_80B26F6C(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); switch (this->unk_288) { case 0x271D: if (Player_GetMeleeWeaponHeld(player) != PLAYER_MELEEWEAPON_NONE) { Message_StartTextbox(play, 0x272A, &this->actor); this->unk_288 = 0x272A; return true; } break; case 0x2721: if (this->unk_292 != 0) { Message_StartTextbox(play, 0x272B, &this->actor); this->unk_288 = 0x272B; return true; } break; } return false; } void func_80B2701C(EnKendoJs* this) { this->actionFunc = func_80B27030; } void func_80B27030(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f sp20 = this->actor.world.pos; sp20.z += 200.0f; if (func_80B278C4(play, sp20)) { this->actor.flags |= ACTOR_FLAG_10000; if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { this->actor.flags &= ~ACTOR_FLAG_10000; player->stateFlags1 &= ~PLAYER_STATE1_20; func_80B279F0(this, play, 0); Message_StartTextbox(play, 0x271A, &this->actor); this->unk_288 = 0x271A; func_80B26AE8(this); } else { Actor_OfferTalk(&this->actor, play, 800.0f); } } } void func_80B2714C(EnKendoJs* this) { SET_WEEKEVENTREG(WEEKEVENTREG_82_08); this->unk_28C = 1; this->unk_290 = 0; this->unk_284 = 0; this->unk_286 = 1; this->actionFunc = func_80B27188; } void func_80B27188(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); if ((Message_GetState(&play->msgCtx) == TEXT_STATE_5) && Message_ShouldAdvance(play)) { if (this->unk_288 == 0x2729) { func_80B26F14(this, play); } else if (!func_80B26F6C(this, play)) { if (this->skelAnime.animation == &object_js_Anim_00016C) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 3); } this->unk_286 = 2; Message_CloseTextbox(play); player->stateFlags1 &= ~PLAYER_STATE1_20; } } else if (this->unk_286 == 2) { this->unk_286 = 1; } if (this->unk_286 == 1) { switch (func_80B26BF8(this, play)) { case 0: this->unk_286 = 0; Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); player->stateFlags1 |= PLAYER_STATE1_20; func_80B26EB4(this, play); break; case 1: Actor_PlaySfx(&this->actor, NA_SE_SY_ERROR); this->unk_286 = 0; player->stateFlags1 |= PLAYER_STATE1_20; Message_StartTextbox(play, 0x2729, &this->actor); this->unk_288 = 0x2729; Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 2); break; default: if (this->unk_28C == 0) { this->unk_290++; if (this->unk_290 == 30) { this->unk_290 = 0; func_80B279F0(this, play, 0); } } break; } if ((this->skelAnime.animation == &object_js_Anim_0003DC) && Animation_OnFrame(&this->skelAnime, this->skelAnime.endFrame)) { Actor_ChangeAnimationByInfo(&this->skelAnime, sAnimationInfo, 1); } if (this->unk_284 == 7) { CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); func_80B26AE8(this); } } } void func_80B273D0(EnKendoJs* this) { SET_WEEKEVENTREG(WEEKEVENTREG_82_08); this->unk_290 = 120; this->unk_284 = 0; this->unk_286 = 1; this->actionFunc = func_80B2740C; } void func_80B2740C(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); Vec3f sp18 = this->actor.world.pos; sp18.z += 300.0f; if (func_80B278C4(play, sp18)) { this->unk_28C = 0; player->stateFlags1 &= ~PLAYER_STATE1_20; this->actionFunc = func_80B274BC; } } void func_80B274BC(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); if (this->unk_290 >= 140) { if (this->unk_284 == 5) { if (gSaveContext.minigameScore == 30) { Message_StartTextbox(play, 0x272D, &this->actor); this->unk_288 = 0x272D; } else { Message_StartTextbox(play, 0x272E, &this->actor); this->unk_288 = 0x272E; } player->stateFlags1 |= PLAYER_STATE1_20; CLEAR_WEEKEVENTREG(WEEKEVENTREG_82_08); func_80B26AE8(this); return; } Audio_PlaySfx(NA_SE_SY_FOUND); func_80B279F0(this, play, ((u8)Rand_Next() % 3) + 1); func_80B279F0(this, play, ((u8)Rand_Next() % 3) + 4); this->unk_290 = 0; this->unk_284++; } else if (this->unk_290 == 120) { func_80B27A90(this, play); this->unk_290++; } else { this->unk_290++; } if (this->unk_28E == 1) { if ((player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_START) || (player->meleeWeaponAnimation == PLAYER_MWA_JUMPSLASH_FINISH)) { play->interfaceCtx.minigamePoints = 3; if (gSaveContext.minigameScore >= 27) { player->stateFlags1 |= PLAYER_STATE1_20; } } else if (player->meleeWeaponAnimation == PLAYER_MWA_STAB_1H) { play->interfaceCtx.minigamePoints = 2; } else { play->interfaceCtx.minigamePoints = 1; } Actor_PlaySfx(&this->actor, NA_SE_SY_TRE_BOX_APPEAR); this->unk_28E = 0; } func_80B2783C(this, play); } void func_80B276C4(EnKendoJs* this) { this->actionFunc = func_80B276D8; } void func_80B276D8(EnKendoJs* this, PlayState* play) { if (Actor_HasParent(&this->actor, play)) { this->actor.parent = NULL; func_80B27760(this); } else if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_20)) { Actor_OfferGetItem(&this->actor, play, GI_HEART_PIECE, 800.0f, 100.0f); } else { Actor_OfferGetItem(&this->actor, play, GI_RUPEE_RED, 800.0f, 100.0f); } } void func_80B27760(EnKendoJs* this) { this->actionFunc = func_80B27774; } void func_80B27774(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); if (Actor_ProcessTalkRequest(&this->actor, &play->state)) { if (!CHECK_WEEKEVENTREG(WEEKEVENTREG_63_20)) { SET_WEEKEVENTREG(WEEKEVENTREG_63_20); Message_StartTextbox(play, 0x272F, &this->actor); this->unk_288 = 0x272F; } else { Message_StartTextbox(play, 0x2730, &this->actor); this->unk_288 = 0x2730; } func_80B26AE8(this); player->stateFlags1 &= ~PLAYER_STATE1_20; } else { Actor_OfferTalkExchangeEquiCylinder(&this->actor, play, 1000.0f, PLAYER_IA_MINUS1); } } void func_80B2783C(EnKendoJs* this, PlayState* play) { if (this->actor.csId != CS_ID_NONE) { Camera_ChangeActorCsCamIndex(play->cameraPtrs[CAM_ID_MAIN], CutsceneManager_GetCutsceneEntry(this->actor.csId)->csCamId); } } void func_80B27880(EnKendoJs* this, PlayState* play) { Player* player = GET_PLAYER(play); f32 temp_f0 = this->actor.world.pos.z + 70.0f; if ((ENKENDOJS_GET_FF(&this->actor) != ENKENDOJS_FF_1) && (player->actor.world.pos.z < temp_f0)) { player->actor.world.pos.z = temp_f0; } } s32 func_80B278C4(PlayState* play, Vec3f arg1) { Player* player = GET_PLAYER(play); f32 temp_f0; f32 sp28; s16 sp22 = Math_Vec3f_Yaw(&player->actor.world.pos, &arg1); temp_f0 = Math_Vec3f_DistXZ(&player->actor.world.pos, &arg1); if (temp_f0 < 20.0f) { sp28 = 10.0f; } else if (temp_f0 < 40.0f) { sp28 = 40.0f; } else { sp28 = 80.0f; } play->actorCtx.unk268 = 1; func_800B6F20(play, &play->actorCtx.unk_26C, sp28, sp22); if (temp_f0 < 20.0f) { return true; } else { return false; } } void func_80B279AC(EnKendoJs* this, PlayState* play) { Collider_UpdateCylinder(&this->actor, &this->collider); CollisionCheck_SetOC(play, &play->colChkCtx, &this->collider.base); } void func_80B279F0(EnKendoJs* this, PlayState* play, s32 arg2) { f32 x = this->unk_274[arg2].x; f32 y = this->unk_274[arg2].y; f32 z = this->unk_274[arg2].z; Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_MARUTA, x, y, z, 0, 0, 0, 0); this->unk_28C++; } void func_80B27A90(EnKendoJs* this, PlayState* play) { Actor* actor = play->actorCtx.actorLists[ACTORCAT_PROP].first; while (actor != NULL) { if (actor->id == ACTOR_EN_MARUTA) { ((EnMaruta*)actor)->unk_220 = 1; } actor = actor->next; } this->unk_28C = 0; } void EnKendoJs_Update(Actor* thisx, PlayState* play) { EnKendoJs* this = THIS; this->actionFunc(this, play); SkelAnime_Update(&this->skelAnime); Actor_TrackPlayer(play, &this->actor, &this->unk_278, &this->unk_27E, this->actor.focus.pos); func_80B279AC(this, play); func_80B27880(this, play); } s32 EnKendoJs_OverrideLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3s* rot, Actor* thisx) { EnKendoJs* this = THIS; if (limbIndex == 12) { rot->y -= this->unk_278.y; } return false; } void EnKendoJs_PostLimbDraw(PlayState* play, s32 limbIndex, Gfx** dList, Vec3s* rot, Actor* thisx) { } void EnKendoJs_Draw(Actor* thisx, PlayState* play) { EnKendoJs* this = THIS; Gfx_SetupDL25_Opa(play->state.gfxCtx); SkelAnime_DrawFlexOpa(play, this->skelAnime.skeleton, this->skelAnime.jointTable, this->skelAnime.dListCount, EnKendoJs_OverrideLimbDraw, EnKendoJs_PostLimbDraw, &this->actor); }
15fada2d1cf7794fb95f454d7f509f80eb89d4b0
89e36105f3a39e9ca051e3e63a51dc855ec55559
/randomcode/threadlurker.c
735bb3e51762e15b9577f2b4c64b60bd8258c0ae
[]
no_license
jordansissel/experiments
771e062cfbc3a64ce67ad827e31c6c7256bba65a
1b969a86fe2eea515edf6fa0e4c0c83e146495f2
refs/heads/master
2023-08-21T22:47:57.022936
2023-03-14T04:47:38
2023-03-14T04:47:38
1,790,809
103
22
null
2023-03-06T12:27:59
2011-05-23T23:49:43
JavaScript
UTF-8
C
false
false
927
c
threadlurker.c
/* LD_PRELOAD this, then attach with gdb and call the startlurker function. * It'll leave the lurker function running in a thread. * Detach with GDB, and we now have a way to run a thread along side other * programs. Fun? * * It's possible to override __libc_start_main, too, and gain similar * functionality, but I haven't tried it yet. */ #include <sys/types.h> #include <sys/stat.h> #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> static pthread_t t_lurker; static int started = 0; void *lurker(void *data) { for (;;) { char *x; printf("Lurker alive...\n"); printf("sbrk(0): %zd", sbrk(0)); x = malloc(4096000); memset(x, 1, 4096000); sleep(1); } } void startlurker() { printf("Startlurker!\n"); if (!started) { printf("Startlurker2!\n"); t_lurker = pthread_create(&t_lurker, NULL, lurker, NULL); started = 1; } }
1d7a0114825dd112579a339f7a978b9af2bbeb00
3d144a23e67c839a4df1c073c6a2c842508f16b2
/validation-test/execution/Inputs/arc_36509461.h
898c66c08849c7d4a02039789c96af272bfc1cfe
[ "Apache-2.0", "Swift-exception" ]
permissive
apple/swift
c2724e388959f6623cf6e4ad6dc1cdd875fd0592
98ada1b200a43d090311b72eb45fe8ecebc97f81
refs/heads/main
2023-08-16T10:48:25.985330
2023-08-16T09:00:42
2023-08-16T09:00:42
44,838,949
78,897
15,074
Apache-2.0
2023-09-14T21:19:23
2015-10-23T21:15:07
C++
UTF-8
C
false
false
179
h
arc_36509461.h
#ifndef DEMOHEADER_H #define DEMOHEADER_H #include <stdbool.h> typedef bool (^fake_apply_t)(const char *key, id value); bool fake_apply(id obj, fake_apply_t applier); #endif
4719abcba23c8cb09c23723b007f3c62c33c6ff6
8149d6751e142ecbc200b43c2da2d5a94c0735df
/modules/pcp/pcp.h
1d9f332bfe692c5667891f5eeedcde97542d7dd1
[ "BSD-3-Clause" ]
permissive
baresip/baresip
3c8ebef031f6a01a1462a9f36264197f90ce6ffe
5ace2f75b317bba60d46030ca3fd5e8fa045fecf
refs/heads/main
2023-08-25T12:55:24.860248
2023-08-17T06:56:31
2023-08-17T06:56:31
16,664,594
834
205
BSD-3-Clause
2023-09-14T12:47:57
2014-02-09T10:44:09
C
UTF-8
C
false
false
332
h
pcp.h
/** * @file pcp.h Port Control Protocol module -- internal interface * * Copyright (C) 2010 - 2016 Alfred E. Heggestad */ /* listener */ struct pcp_listener; typedef void (pcp_msg_h)(const struct pcp_msg *msg, void *arg); int pcp_listen(struct pcp_listener **plp, const struct sa *srv, pcp_msg_h *msgh, void *arg);
adb6d32eb1323f2750ff1d61130697e146ebf143
d325e0d8d87128cc86e975a822516604a71294e9
/drivers/STM32F1xx/Src/serial.c
57c1a9c500c518cc6f074ae547bedc3dfce70a06
[]
no_license
terjeio/grblHAL
12b93d229b046bc09c87902c3569767337dd270a
cd693465a8d7b9dabf1d85acdf3eba40a0994db1
refs/heads/master
2022-01-27T19:09:19.281567
2021-12-27T06:34:25
2021-12-27T06:34:25
142,401,894
251
104
null
2021-03-18T06:16:59
2018-07-26T07:00:52
C
UTF-8
C
false
false
6,052
c
serial.c
/* serial.c - serial port implementation for STM32F103C8 ARM processors Part of grblHAL Copyright (c) 2019-2021 Terje Io Grbl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Grbl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Grbl. If not, see <http://www.gnu.org/licenses/>. */ #include <string.h> #include "driver.h" #include "serial.h" #include "grbl.h" #include "main.h" #if !USB_SERIAL_CDC static stream_rx_buffer_t rxbuf = {0}; static stream_tx_buffer_t txbuf = {0}; void serialInit (void) { __HAL_RCC_USART1_CLK_ENABLE(); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.Pin = GPIO_PIN_9; GPIO_InitStructure.Mode = GPIO_MODE_AF_PP; GPIO_InitStructure.Speed = GPIO_SPEED_FREQ_HIGH; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_InitStructure.Pin = GPIO_PIN_10; GPIO_InitStructure.Mode = GPIO_MODE_INPUT; GPIO_InitStructure.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &GPIO_InitStructure); USART1->CR1 |= (USART_CR1_RE|USART_CR1_TE); USART1->BRR = UART_BRR_SAMPLING16(HAL_RCC_GetPCLK2Freq(), 115200); USART1->CR1 |= (USART_CR1_UE|USART_CR1_RXNEIE); HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART1_IRQn); } // // Returns number of free characters in serial input buffer // uint16_t serialRxFree (void) { uint16_t tail = rxbuf.tail, head = rxbuf.head; return RX_BUFFER_SIZE - BUFCOUNT(head, tail, RX_BUFFER_SIZE); } // // Flushes the serial input buffer // void serialRxFlush (void) { rxbuf.head = rxbuf.tail = 0; } // // Flushes and adds a CAN character to the serial input buffer // void serialRxCancel (void) { rxbuf.data[rxbuf.head] = ASCII_CAN; rxbuf.tail = rxbuf.head; rxbuf.head = (rxbuf.tail + 1) & (RX_BUFFER_SIZE - 1); } // // Attempt to send a character bypassing buffering // inline static bool serialPutCNonBlocking (const char c) { bool ok; if((ok = !(USART1->CR1 & USART_CR1_TXEIE) && !(USART1->SR & USART_SR_TXE))) USART1->DR = c; return ok; } // // Writes a character to the serial output stream // bool serialPutC (const char c) { // if(txbuf.head != txbuf.tail || !serialPutCNonBlocking(c)) { // Try to send character without buffering... uint16_t next_head = (txbuf.head + 1) & (TX_BUFFER_SIZE - 1); // .. if not, get pointer to next free slot in buffer while(txbuf.tail == next_head) { // While TX buffer full if(!hal.stream_blocking_callback()) // check if blocking for space, return false; // exit if not (leaves TX buffer in an inconsistent state) } txbuf.data[txbuf.head] = c; // Add data to buffer, txbuf.head = next_head; // update head pointer and USART1->CR1 |= USART_CR1_TXEIE; // enable TX interrupts // } return true; } // // Writes a null terminated string to the serial output stream, blocks if buffer full // void serialWriteS (const char *s) { char c, *ptr = (char *)s; while((c = *ptr++) != '\0') serialPutC(c); } // // Writes a number of characters from string to the serial output stream followed by EOL, blocks if buffer full // void serialWrite(const char *s, uint16_t length) { char *ptr = (char *)s; while(length--) serialPutC(*ptr++); } // // serialGetC - returns -1 if no data available // int16_t serialGetC (void) { uint16_t bptr = rxbuf.tail; if(bptr == rxbuf.head) return -1; // no data available else EOF char data = rxbuf.data[bptr++]; // Get next character, increment tmp pointer rxbuf.tail = bptr & (RX_BUFFER_SIZE - 1); // and update pointer return (int16_t)data; } bool serialSuspendInput (bool suspend) { return stream_rx_suspend(&rxbuf, suspend); } void USART1_IRQHandler (void) { if(USART1->SR & USART_SR_RXNE) { uint16_t next_head = (rxbuf.head + 1) & (RX_BUFFER_SIZE - 1); // Get and increment buffer pointer if(rxbuf.tail == next_head) { // If buffer full rxbuf.overflow = 1; // flag overflow next_head = USART1->DR; // and do dummy read to clear interrupt } else { char data = USART1->DR; if(data == CMD_TOOL_ACK && !rxbuf.backup) { stream_rx_backup(&rxbuf); hal.stream.read = serialGetC; // restore normal input } else if(!hal.stream.enqueue_realtime_command(data)) { // Check and strip realtime commands, rxbuf.data[rxbuf.head] = data; // if not add data to buffer rxbuf.head = next_head; // and update pointer } } } if((USART1->SR & USART_SR_TXE) && (USART1->CR1 & USART_CR1_TXEIE)) { uint16_t tail = txbuf.tail; // Get buffer pointer USART1->DR = txbuf.data[tail++]; // Send next character and increment pointer if(tail == TX_BUFFER_SIZE) // If at end tail = 0; // wrap pointer around txbuf.tail = tail; // Update global pointer if(tail == txbuf.head) // If buffer empty then USART1->CR1 &= ~USART_CR1_TXEIE; // disable UART TX interrupt } } #endif
5a8bbc6fe3035a888aa03e2af153400b7c90b122
010279e2ba272d09e9d2c4e903722e5faba2cf7a
/contrib/python/Pillow/py2/libImaging/Quant.c
b94dc6e1d096fbe8bfa643aa6af43dc5a36bfdbc
[ "LicenseRef-scancode-secret-labs-2011", "Apache-2.0" ]
permissive
catboost/catboost
854c1a1f439a96f1ae6b48e16644be20aa04dba2
f5042e35b945aded77b23470ead62d7eacefde92
refs/heads/master
2023-09-01T12:14:14.174108
2023-09-01T10:01:01
2023-09-01T10:22:12
97,556,265
8,012
1,425
Apache-2.0
2023-09-11T03:32:32
2017-07-18T05:29:04
Python
UTF-8
C
false
false
44,760
c
Quant.c
/* * The Python Imaging Library * $Id$ * * image quantizer * * history: * 1998-09-10 tjs Contributed * 1998-12-29 fl Added to PIL 1.0b1 * 2004-02-21 fl Fixed bogus free() on quantization error * 2005-02-07 fl Limit number of colors to 256 * * Written by Toby J Sargeant <tjs@longford.cs.monash.edu.au>. * * Copyright (c) 1998 by Toby J Sargeant * Copyright (c) 1998-2004 by Secret Labs AB. All rights reserved. * * See the README file for information on usage and redistribution. */ #include "Imaging.h" #include <stdio.h> #include <stdlib.h> #include <memory.h> #include <time.h> #include "QuantTypes.h" #include "QuantOctree.h" #include "QuantPngQuant.h" #include "QuantHash.h" #include "QuantHeap.h" /* MSVC9.0 */ #ifndef UINT32_MAX #define UINT32_MAX 0xffffffff #endif #define NO_OUTPUT typedef struct { uint32_t scale; } PixelHashData; typedef struct _PixelList { struct _PixelList *next[3],*prev[3]; Pixel p; unsigned int flag:1; int count; } PixelList; typedef struct _BoxNode { struct _BoxNode *l,*r; PixelList *head[3],*tail[3]; int axis; int volume; uint32_t pixelCount; } BoxNode; #define _SQR(x) ((x)*(x)) #define _DISTSQR(p1,p2) \ _SQR((int)((p1)->c.r)-(int)((p2)->c.r))+ \ _SQR((int)((p1)->c.g)-(int)((p2)->c.g))+ \ _SQR((int)((p1)->c.b)-(int)((p2)->c.b)) #define MAX_HASH_ENTRIES 65536 #define PIXEL_HASH(r,g,b) \ (((unsigned int)(r) )*463 ^ \ ((unsigned int)(g)<< 8)*10069 ^ \ ((unsigned int)(b)<<16)*64997) #define PIXEL_UNSCALE(p,q,s) \ ((q)->c.r=(p)->c.r<<(s)), \ ((q)->c.g=(p)->c.g<<(s)), \ ((q)->c.b=(p)->c.b<<(s)) #define PIXEL_SCALE(p,q,s)\ ((q)->c.r=(p)->c.r>>(s)), \ ((q)->c.g=(p)->c.g>>(s)), \ ((q)->c.b=(p)->c.b>>(s)) static uint32_t unshifted_pixel_hash(const HashTable *h, const Pixel pixel) { return PIXEL_HASH(pixel.c.r, pixel.c.g, pixel.c.b); } static int unshifted_pixel_cmp(const HashTable *h, const Pixel pixel1, const Pixel pixel2) { if (pixel1.c.r==pixel2.c.r) { if (pixel1.c.g==pixel2.c.g) { if (pixel1.c.b==pixel2.c.b) { return 0; } else { return (int)(pixel1.c.b)-(int)(pixel2.c.b); } } else { return (int)(pixel1.c.g)-(int)(pixel2.c.g); } } else { return (int)(pixel1.c.r)-(int)(pixel2.c.r); } } static uint32_t pixel_hash(const HashTable *h,const Pixel pixel) { PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); return PIXEL_HASH(pixel.c.r>>d->scale, pixel.c.g>>d->scale, pixel.c.b>>d->scale); } static int pixel_cmp(const HashTable *h,const Pixel pixel1, const Pixel pixel2) { PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); uint32_t A,B; A=PIXEL_HASH(pixel1.c.r>>d->scale, pixel1.c.g>>d->scale, pixel1.c.b>>d->scale); B=PIXEL_HASH(pixel2.c.r>>d->scale, pixel2.c.g>>d->scale, pixel2.c.b>>d->scale); return (A==B)?0:((A<B)?-1:1); } static void exists_count_func(const HashTable *h, const Pixel key, uint32_t *val) { *val+=1; } static void new_count_func(const HashTable *h, const Pixel key, uint32_t *val) { *val=1; } static void rehash_collide(const HashTable *h, Pixel *keyp, uint32_t *valp, Pixel newkey, uint32_t newval) { *valp += newval; } /* %% */ static HashTable * create_pixel_hash(Pixel *pixelData,uint32_t nPixels) { PixelHashData *d; HashTable *hash; uint32_t i; #ifndef NO_OUTPUT uint32_t timer,timer2,timer3; #endif /* malloc check ok, small constant allocation */ d=malloc(sizeof(PixelHashData)); if (!d) return NULL; hash=hashtable_new(pixel_hash,pixel_cmp); hashtable_set_user_data(hash,d); d->scale=0; #ifndef NO_OUTPUT timer=timer3=clock(); #endif for (i=0;i<nPixels;i++) { if (!hashtable_insert_or_update_computed(hash, pixelData[i], new_count_func, exists_count_func)) {; } while (hashtable_get_count(hash)>MAX_HASH_ENTRIES) { d->scale++; #ifndef NO_OUTPUT printf ("rehashing - new scale: %d\n",(int)d->scale); timer2=clock(); #endif hashtable_rehash_compute(hash,rehash_collide); #ifndef NO_OUTPUT timer2=clock()-timer2; printf ("rehash took %f sec\n",timer2/(double)CLOCKS_PER_SEC); timer+=timer2; #endif } } #ifndef NO_OUTPUT printf ("inserts took %f sec\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif #ifndef NO_OUTPUT printf ("total %f sec\n",(clock()-timer3)/(double)CLOCKS_PER_SEC); #endif return hash; } static void destroy_pixel_hash(HashTable *hash) { PixelHashData *d=(PixelHashData *)hashtable_get_user_data(hash); if (d) free(d); hashtable_free(hash); } /* 1. hash quantized pixels. */ /* 2. create R,G,B lists of sorted quantized pixels. */ /* 3. median cut. */ /* 4. build hash table from median cut boxes. */ /* 5. for each pixel, compute entry in hash table, and hence median cut box. */ /* 6. compute median cut box pixel averages. */ /* 7. map each pixel to nearest average. */ static int compute_box_volume(BoxNode *b) { unsigned char rl,rh,gl,gh,bl,bh; if (b->volume>=0) return b->volume; if (!b->head[0]) { b->volume=0; } else { rh=b->head[0]->p.c.r; rl=b->tail[0]->p.c.r; gh=b->head[1]->p.c.g; gl=b->tail[1]->p.c.g; bh=b->head[2]->p.c.b; bl=b->tail[2]->p.c.b; b->volume=(rh-rl+1)*(gh-gl+1)*(bh-bl+1); } return b->volume; } static void hash_to_list(const HashTable *h, const Pixel pixel, const uint32_t count, void *u) { PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); PixelList **pl=(PixelList **)u; PixelList *p; int i; Pixel q; PIXEL_SCALE(&pixel,&q,d->scale); /* malloc check ok, small constant allocation */ p=malloc(sizeof(PixelList)); if (!p) return; p->flag=0; p->p=q; p->count=count; for (i=0;i<3;i++) { p->next[i]=pl[i]; p->prev[i]=NULL; if (pl[i]) pl[i]->prev[i]=p; pl[i]=p; } } static PixelList * mergesort_pixels(PixelList *head, int i) { PixelList *c,*t,*a,*b,*p; if (!head||!head->next[i]) { if (head) { head->next[i]=NULL; head->prev[i]=NULL; } return head; } for (c=t=head;c&&t;c=c->next[i],t=(t->next[i])?t->next[i]->next[i]:NULL); if (c) { if (c->prev[i]) c->prev[i]->next[i]=NULL; c->prev[i]=NULL; } a=mergesort_pixels(head,i); b=mergesort_pixels(c,i); head=NULL; p=NULL; while (a&&b) { if (a->p.a.v[i]>b->p.a.v[i]) { c=a; a=a->next[i]; } else { c=b; b=b->next[i]; } c->prev[i]=p; c->next[i]=NULL; if (p) p->next[i]=c; p=c; if (!head) head=c; } if (a) { c->next[i]=a; a->prev[i]=c; } else if (b) { c->next[i]=b; b->prev[i]=c; } return head; } #if defined(TEST_MERGESORT) || defined(TEST_SORTED) static int test_sorted(PixelList *pl[3]) { int i,n,l; PixelList *t; for(i=0;i<3;i++) { n=0; l=256; for (t=pl[i];t;t=t->next[i]) { if (l<t->p.a.v[i]) return 0; l=t->p.a.v[i]; } } return 1; } #endif static int box_heap_cmp(const Heap *h, const void *A, const void *B) { BoxNode *a=(BoxNode *)A; BoxNode *b=(BoxNode *)B; return (int)a->pixelCount-(int)b->pixelCount; } #define LUMINANCE(p) (77*(p)->c.r+150*(p)->c.g+29*(p)->c.b) static int splitlists(PixelList *h[3], PixelList *t[3], PixelList *nh[2][3], PixelList *nt[2][3], uint32_t nCount[2], int axis, uint32_t pixelCount) { uint32_t left; PixelList *l,*r,*c,*n; int i; int nRight,nLeft; int splitColourVal; #ifdef TEST_SPLIT { PixelList *_prevTest,*_nextTest; int _i,_nextCount[3],_prevCount[3]; for (_i=0;_i<3;_i++) { for (_nextCount[_i]=0,_nextTest=h[_i];_nextTest&&_nextTest->next[_i];_nextTest=_nextTest->next[_i],_nextCount[_i]++); for (_prevCount[_i]=0,_prevTest=t[_i];_prevTest&&_prevTest->prev[_i];_prevTest=_prevTest->prev[_i],_prevCount[_i]++); if (_nextTest!=t[_i]) { printf ("next-list of axis %d does not end at tail\n",_i); exit(1); } if (_prevTest!=h[_i]) { printf ("prev-list of axis %d does not end at head\n",_i); exit(1); } for (;_nextTest&&_nextTest->prev[_i];_nextTest=_nextTest->prev[_i]); for (;_prevTest&&_prevTest->next[_i];_prevTest=_prevTest->next[_i]); if (_nextTest!=h[_i]) { printf ("next-list of axis %d does not loop back to head\n",_i); exit(1); } if (_prevTest!=t[_i]) { printf ("prev-list of axis %d does not loop back to tail\n",_i); exit(1); } } for (_i=1;_i<3;_i++) { if (_prevCount[_i]!=_prevCount[_i-1] || _nextCount[_i]!=_nextCount[_i-1] || _prevCount[_i]!=_nextCount[_i]) { printf ("{%d %d %d} {%d %d %d}\n", _prevCount[0], _prevCount[1], _prevCount[2], _nextCount[0], _nextCount[1], _nextCount[2]); exit(1); } } } #endif nCount[0]=nCount[1]=0; nLeft=nRight=0; for (left=0,c=h[axis];c;) { left=left+c->count; nCount[0]+=c->count; c->flag=0; nLeft++; c=c->next[axis]; if (left*2>pixelCount) { break; } } if (c) { splitColourVal=c->prev[axis]->p.a.v[axis]; for (;c;c=c->next[axis]) { if (splitColourVal!=c->p.a.v[axis]) { break; } c->flag=0; nLeft++; nCount[0]+=c->count; } } for (;c;c=c->next[axis]) { c->flag=1; nRight++; nCount[1]+=c->count; } if (!nRight) { for (c=t[axis],splitColourVal=t[axis]->p.a.v[axis];c;c=c->prev[axis]) { if (splitColourVal!=c->p.a.v[axis]) { break; } c->flag=1; nRight++; nLeft--; nCount[0]-=c->count; nCount[1]+=c->count; } } #ifndef NO_OUTPUT if (!nLeft) { for (c=h[axis];c;c=c->next[axis]) { printf ("[%d %d %d]\n",c->p.c.r,c->p.c.g,c->p.c.b); } printf ("warning... trivial split\n"); } #endif for (i=0;i<3;i++) { l=r=NULL; nh[0][i]=nt[0][i]=NULL; nh[1][i]=nt[1][i]=NULL; for (c=h[i];c;c=n) { n=c->next[i]; if (c->flag) { /* move pixel to right list*/ if (r) r->next[i]=c; else nh[1][i]=c; c->prev[i]=r; r=c; } else { /* move pixel to left list */ if (l) l->next[i]=c; else nh[0][i]=c; c->prev[i]=l; l=c; } } if (l) l->next[i]=NULL; if (r) r->next[i]=NULL; nt[0][i]=l; nt[1][i]=r; } return 1; } static int split(BoxNode *node) { unsigned char rl,rh,gl,gh,bl,bh; int f[3]; int best,axis; int i; PixelList *heads[2][3]; PixelList *tails[2][3]; uint32_t newCounts[2]; BoxNode *left,*right; rh=node->head[0]->p.c.r; rl=node->tail[0]->p.c.r; gh=node->head[1]->p.c.g; gl=node->tail[1]->p.c.g; bh=node->head[2]->p.c.b; bl=node->tail[2]->p.c.b; #ifdef TEST_SPLIT printf ("splitting node [%d %d %d] [%d %d %d] ",rl,gl,bl,rh,gh,bh); #endif f[0]=(rh-rl)*77; f[1]=(gh-gl)*150; f[2]=(bh-bl)*29; best=f[0]; axis=0; for (i=1;i<3;i++) { if (best<f[i]) { best=f[i]; axis=i; } } #ifdef TEST_SPLIT printf ("along axis %d\n",axis+1); #endif #ifdef TEST_SPLIT { PixelList *_prevTest,*_nextTest; int _i,_nextCount[3],_prevCount[3]; for (_i=0;_i<3;_i++) { if (node->tail[_i]->next[_i]) { printf ("tail is not tail\n"); printf ("node->tail[%d]->next[%d]=%p\n",_i,_i,node->tail[_i]->next[_i]); } if (node->head[_i]->prev[_i]) { printf ("head is not head\n"); printf ("node->head[%d]->prev[%d]=%p\n",_i,_i,node->head[_i]->prev[_i]); } } for (_i=0;_i<3;_i++) { for (_nextCount[_i]=0,_nextTest=node->head[_i];_nextTest&&_nextTest->next[_i];_nextTest=_nextTest->next[_i],_nextCount[_i]++); for (_prevCount[_i]=0,_prevTest=node->tail[_i];_prevTest&&_prevTest->prev[_i];_prevTest=_prevTest->prev[_i],_prevCount[_i]++); if (_nextTest!=node->tail[_i]) { printf ("next-list of axis %d does not end at tail\n",_i); } if (_prevTest!=node->head[_i]) { printf ("prev-list of axis %d does not end at head\n",_i); } for (;_nextTest&&_nextTest->prev[_i];_nextTest=_nextTest->prev[_i]); for (;_prevTest&&_prevTest->next[_i];_prevTest=_prevTest->next[_i]); if (_nextTest!=node->head[_i]) { printf ("next-list of axis %d does not loop back to head\n",_i); } if (_prevTest!=node->tail[_i]) { printf ("prev-list of axis %d does not loop back to tail\n",_i); } } for (_i=1;_i<3;_i++) { if (_prevCount[_i]!=_prevCount[_i-1] || _nextCount[_i]!=_nextCount[_i-1] || _prevCount[_i]!=_nextCount[_i]) { printf ("{%d %d %d} {%d %d %d}\n", _prevCount[0], _prevCount[1], _prevCount[2], _nextCount[0], _nextCount[1], _nextCount[2]); } } } #endif node->axis=axis; if (!splitlists(node->head, node->tail, heads, tails, newCounts, axis, node->pixelCount)) { #ifndef NO_OUTPUT printf ("list split failed.\n"); #endif return 0; } #ifdef TEST_SPLIT if (!test_sorted(heads[0])) { printf ("bug in split"); exit(1); } if (!test_sorted(heads[1])) { printf ("bug in split"); exit(1); } #endif /* malloc check ok, small constant allocation */ left=malloc(sizeof(BoxNode)); right=malloc(sizeof(BoxNode)); if (!left||!right) { free(left); free(right); return 0; } for(i=0;i<3;i++) { left->head[i]=heads[0][i]; left->tail[i]=tails[0][i]; right->head[i]=heads[1][i]; right->tail[i]=tails[1][i]; node->head[i]=NULL; node->tail[i]=NULL; } #ifdef TEST_SPLIT if (left->head[0]) { rh=left->head[0]->p.c.r; rl=left->tail[0]->p.c.r; gh=left->head[1]->p.c.g; gl=left->tail[1]->p.c.g; bh=left->head[2]->p.c.b; bl=left->tail[2]->p.c.b; printf (" left node [%3d %3d %3d] [%3d %3d %3d]\n",rl,gl,bl,rh,gh,bh); } if (right->head[0]) { rh=right->head[0]->p.c.r; rl=right->tail[0]->p.c.r; gh=right->head[1]->p.c.g; gl=right->tail[1]->p.c.g; bh=right->head[2]->p.c.b; bl=right->tail[2]->p.c.b; printf (" right node [%3d %3d %3d] [%3d %3d %3d]\n",rl,gl,bl,rh,gh,bh); } #endif left->l=left->r=NULL; right->l=right->r=NULL; left->axis=right->axis=-1; left->volume=right->volume=-1; left->pixelCount=newCounts[0]; right->pixelCount=newCounts[1]; node->l=left; node->r=right; return 1; } static BoxNode * median_cut(PixelList *hl[3], uint32_t imPixelCount, int nPixels) { PixelList *tl[3]; int i; BoxNode *root; Heap* h; BoxNode *thisNode; h=ImagingQuantHeapNew(box_heap_cmp); /* malloc check ok, small constant allocation */ root=malloc(sizeof(BoxNode)); if (!root) { ImagingQuantHeapFree(h); return NULL; } for(i=0;i<3;i++) { for (tl[i]=hl[i];tl[i]&&tl[i]->next[i];tl[i]=tl[i]->next[i]); root->head[i]=hl[i]; root->tail[i]=tl[i]; } root->l=root->r=NULL; root->axis=-1; root->volume=-1; root->pixelCount=imPixelCount; ImagingQuantHeapAdd(h,(void *)root); while (--nPixels) { do { if (!ImagingQuantHeapRemove(h,(void **)&thisNode)) { goto done; } } while (compute_box_volume(thisNode)==1); if (!split(thisNode)) { #ifndef NO_OUTPUT printf ("Oops, split failed...\n"); #endif exit (1); } ImagingQuantHeapAdd(h,(void *)(thisNode->l)); ImagingQuantHeapAdd(h,(void *)(thisNode->r)); } done: ImagingQuantHeapFree(h); return root; } static void free_box_tree(BoxNode *n) { PixelList *p,*pp; if (n->l) free_box_tree(n->l); if (n->r) free_box_tree(n->r); for (p=n->head[0];p;p=pp) { pp=p->next[0]; free(p); } free(n); } #ifdef TEST_SPLIT_INTEGRITY static int checkContained(BoxNode *n,Pixel *pp) { if (n->l&&n->r) { return checkContained(n->l,pp)+checkContained(n->r,pp); } if (n->l||n->r) { #ifndef NO_OUTPUT printf ("box tree is dead\n"); #endif return 0; } if ( pp->c.r<=n->head[0]->p.c.r && pp->c.r>=n->tail[0]->p.c.r && pp->c.g<=n->head[1]->p.c.g && pp->c.g>=n->tail[1]->p.c.g && pp->c.b<=n->head[2]->p.c.b && pp->c.b>=n->tail[2]->p.c.b) { return 1; } return 0; } #endif static int annotate_hash_table(BoxNode *n,HashTable *h,uint32_t *box) { PixelList *p; PixelHashData *d=(PixelHashData *)hashtable_get_user_data(h); Pixel q; if (n->l&&n->r) { return annotate_hash_table(n->l,h,box) && annotate_hash_table(n->r,h,box); } if (n->l||n->r) { #ifndef NO_OUTPUT printf ("box tree is dead\n"); #endif return 0; } for (p=n->head[0];p;p=p->next[0]) { PIXEL_UNSCALE(&(p->p),&q,d->scale); if (!hashtable_insert(h,q,*box)) { #ifndef NO_OUTPUT printf ("hashtable insert failed\n"); #endif return 0; } } if (n->head[0]) (*box)++; return 1; } static int _sort_ulong_ptr_keys(const void *a, const void *b) { uint32_t A=**(uint32_t **)a; uint32_t B=**(uint32_t **)b; return (A==B)?0:((A<B)?-1:+1); } static int resort_distance_tables(uint32_t *avgDist, uint32_t **avgDistSortKey, Pixel *p, uint32_t nEntries) { uint32_t i,j,k; uint32_t **skRow; uint32_t *skElt; for (i=0;i<nEntries;i++) { avgDist[i*nEntries+i]=0; for (j=0;j<i;j++) { avgDist[j*nEntries+i]= avgDist[i*nEntries+j]=_DISTSQR(p+i,p+j); } } for (i=0;i<nEntries;i++) { skRow=avgDistSortKey+i*nEntries; for (j=1;j<nEntries;j++) { skElt=skRow[j]; for (k=j;k&&(*(skRow[k-1])>*(skRow[k]));k--) { skRow[k]=skRow[k-1]; } if (k!=j) skRow[k]=skElt; } } return 1; } static int build_distance_tables(uint32_t *avgDist, uint32_t **avgDistSortKey, Pixel *p, uint32_t nEntries) { uint32_t i,j; for (i=0;i<nEntries;i++) { avgDist[i*nEntries+i]=0; avgDistSortKey[i*nEntries+i]=&(avgDist[i*nEntries+i]); for (j=0;j<i;j++) { avgDist[j*nEntries+i]= avgDist[i*nEntries+j]=_DISTSQR(p+i,p+j); avgDistSortKey[j*nEntries+i]=&(avgDist[j*nEntries+i]); avgDistSortKey[i*nEntries+j]=&(avgDist[i*nEntries+j]); } } for (i=0;i<nEntries;i++) { qsort(avgDistSortKey+i*nEntries, nEntries, sizeof(uint32_t *), _sort_ulong_ptr_keys); } return 1; } static int map_image_pixels(Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, uint32_t *avgDist, uint32_t **avgDistSortKey, uint32_t *pixelArray) { uint32_t *aD,**aDSK; uint32_t idx; uint32_t i,j; uint32_t bestdist,bestmatch,dist; uint32_t initialdist; HashTable *h2; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (!hashtable_lookup(h2,pixelData[i],&bestmatch)) { bestmatch=0; initialdist=_DISTSQR(paletteData+bestmatch,pixelData+i); bestdist=initialdist; initialdist<<=2; aDSK=avgDistSortKey+bestmatch*nPaletteEntries; aD=avgDist+bestmatch*nPaletteEntries; for (j=0;j<nPaletteEntries;j++) { idx=aDSK[j]-aD; if (*(aDSK[j])<=initialdist) { dist=_DISTSQR(paletteData+idx,pixelData+i); if (dist<bestdist) { bestdist=dist; bestmatch=idx; } } else { break; } } hashtable_insert(h2,pixelData[i],bestmatch); } pixelArray[i]=bestmatch; } hashtable_free(h2); return 1; } static int map_image_pixels_from_quantized_pixels( Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, uint32_t *avgDist, uint32_t **avgDistSortKey, uint32_t *pixelArray, uint32_t *avg[3], uint32_t *count) { uint32_t *aD,**aDSK; uint32_t idx; uint32_t i,j; uint32_t bestdist,bestmatch,dist; uint32_t initialdist; HashTable *h2; int changes=0; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (!hashtable_lookup(h2,pixelData[i],&bestmatch)) { bestmatch=pixelArray[i]; initialdist=_DISTSQR(paletteData+bestmatch,pixelData+i); bestdist=initialdist; initialdist<<=2; aDSK=avgDistSortKey+bestmatch*nPaletteEntries; aD=avgDist+bestmatch*nPaletteEntries; for (j=0;j<nPaletteEntries;j++) { idx=aDSK[j]-aD; if (*(aDSK[j])<=initialdist) { dist=_DISTSQR(paletteData+idx,pixelData+i); if (dist<bestdist) { bestdist=dist; bestmatch=idx; } } else { break; } } hashtable_insert(h2,pixelData[i],bestmatch); } if (pixelArray[i]!=bestmatch) { changes++; avg[0][bestmatch]+=pixelData[i].c.r; avg[1][bestmatch]+=pixelData[i].c.g; avg[2][bestmatch]+=pixelData[i].c.b; avg[0][pixelArray[i]]-=pixelData[i].c.r; avg[1][pixelArray[i]]-=pixelData[i].c.g; avg[2][pixelArray[i]]-=pixelData[i].c.b; count[bestmatch]++; count[pixelArray[i]]--; pixelArray[i]=bestmatch; } } hashtable_free(h2); return changes; } static int map_image_pixels_from_median_box( Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, HashTable *medianBoxHash, uint32_t *avgDist, uint32_t **avgDistSortKey, uint32_t *pixelArray) { uint32_t *aD,**aDSK; uint32_t idx; uint32_t i,j; uint32_t bestdist,bestmatch,dist; uint32_t initialdist; HashTable *h2; uint32_t pixelVal; h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (hashtable_lookup(h2,pixelData[i],&pixelVal)) { pixelArray[i]=pixelVal; continue; } if (!hashtable_lookup(medianBoxHash,pixelData[i],&pixelVal)) { #ifndef NO_OUTPUT printf ("pixel lookup failed\n"); #endif return 0; } initialdist=_DISTSQR(paletteData+pixelVal,pixelData+i); bestdist=initialdist; bestmatch=pixelVal; initialdist<<=2; aDSK=avgDistSortKey+pixelVal*nPaletteEntries; aD=avgDist+pixelVal*nPaletteEntries; for (j=0;j<nPaletteEntries;j++) { idx=aDSK[j]-aD; if (*(aDSK[j])<=initialdist) { dist=_DISTSQR(paletteData+idx,pixelData+i); if (dist<bestdist) { bestdist=dist; bestmatch=idx; } } else { break; } } pixelArray[i]=bestmatch; hashtable_insert(h2,pixelData[i],bestmatch); } hashtable_free(h2); return 1; } static int compute_palette_from_median_cut( Pixel *pixelData, uint32_t nPixels, HashTable *medianBoxHash, Pixel **palette, uint32_t nPaletteEntries) { uint32_t i; uint32_t paletteEntry; Pixel *p; uint32_t *avg[3]; uint32_t *count; *palette=NULL; /* malloc check ok, using calloc */ if (!(count=calloc(nPaletteEntries, sizeof(uint32_t)))) { return 0; } for(i=0;i<3;i++) { avg[i]=NULL; } for(i=0;i<3;i++) { /* malloc check ok, using calloc */ if (!(avg[i]=calloc(nPaletteEntries, sizeof(uint32_t)))) { for(i=0;i<3;i++) { if (avg[i]) free (avg[i]); } free(count); return 0; } } for (i=0;i<nPixels;i++) { #ifdef TEST_SPLIT_INTEGRITY if (!(i%100)) { printf ("%05d\r",i); fflush(stdout); } if (checkContained(root,pixelData+i)>1) { printf ("pixel in two boxes\n"); for(i=0;i<3;i++) free (avg[i]); free(count); return 0; } #endif if (!hashtable_lookup(medianBoxHash,pixelData[i],&paletteEntry)) { #ifndef NO_OUTPUT printf ("pixel lookup failed\n"); #endif for(i=0;i<3;i++) free (avg[i]); free(count); return 0; } if (paletteEntry>=nPaletteEntries) { #ifndef NO_OUTPUT printf ("panic - paletteEntry>=nPaletteEntries (%d>=%d)\n",(int)paletteEntry,(int)nPaletteEntries); #endif for(i=0;i<3;i++) free (avg[i]); free(count); return 0; } avg[0][paletteEntry]+=pixelData[i].c.r; avg[1][paletteEntry]+=pixelData[i].c.g; avg[2][paletteEntry]+=pixelData[i].c.b; count[paletteEntry]++; } /* malloc check ok, using calloc */ p=calloc(nPaletteEntries, sizeof(Pixel)); if (!p) { for(i=0;i<3;i++) free (avg[i]); free(count); return 0; } for (i=0;i<nPaletteEntries;i++) { p[i].c.r=(int)(.5+(double)avg[0][i]/(double)count[i]); p[i].c.g=(int)(.5+(double)avg[1][i]/(double)count[i]); p[i].c.b=(int)(.5+(double)avg[2][i]/(double)count[i]); } *palette=p; for(i=0;i<3;i++) free (avg[i]); free(count); return 1; } static int recompute_palette_from_averages( Pixel *palette, uint32_t nPaletteEntries, uint32_t *avg[3], uint32_t *count) { uint32_t i; for (i=0;i<nPaletteEntries;i++) { palette[i].c.r=(int)(.5+(double)avg[0][i]/(double)count[i]); palette[i].c.g=(int)(.5+(double)avg[1][i]/(double)count[i]); palette[i].c.b=(int)(.5+(double)avg[2][i]/(double)count[i]); } return 1; } static int compute_palette_from_quantized_pixels( Pixel *pixelData, uint32_t nPixels, Pixel *palette, uint32_t nPaletteEntries, uint32_t *avg[3], uint32_t *count, uint32_t *qp) { uint32_t i; memset(count,0,sizeof(uint32_t)*nPaletteEntries); for(i=0;i<3;i++) { memset(avg[i],0,sizeof(uint32_t)*nPaletteEntries); } for (i=0;i<nPixels;i++) { if (qp[i]>=nPaletteEntries) { #ifndef NO_OUTPUT printf ("scream\n"); #endif return 0; } avg[0][qp[i]]+=pixelData[i].c.r; avg[1][qp[i]]+=pixelData[i].c.g; avg[2][qp[i]]+=pixelData[i].c.b; count[qp[i]]++; } for (i=0;i<nPaletteEntries;i++) { palette[i].c.r=(int)(.5+(double)avg[0][i]/(double)count[i]); palette[i].c.g=(int)(.5+(double)avg[1][i]/(double)count[i]); palette[i].c.b=(int)(.5+(double)avg[2][i]/(double)count[i]); } return 1; } static int k_means(Pixel *pixelData, uint32_t nPixels, Pixel *paletteData, uint32_t nPaletteEntries, uint32_t *qp, int threshold) { uint32_t *avg[3]; uint32_t *count; uint32_t i; uint32_t *avgDist; uint32_t **avgDistSortKey; int changes; int built=0; if (nPaletteEntries > UINT32_MAX / (sizeof(uint32_t))) { return 0; } /* malloc check ok, using calloc */ if (!(count=calloc(nPaletteEntries, sizeof(uint32_t)))) { return 0; } for(i=0;i<3;i++) { avg[i]=NULL; } for(i=0;i<3;i++) { /* malloc check ok, using calloc */ if (!(avg[i]=calloc(nPaletteEntries, sizeof(uint32_t)))) { goto error_1; } } /* this is enough of a check, since the multiplication n*size is done above */ if (nPaletteEntries > UINT32_MAX / nPaletteEntries) { goto error_1; } /* malloc check ok, using calloc, checking n*n above */ avgDist=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t)); if (!avgDist) { goto error_1; } /* malloc check ok, using calloc, checking n*n above */ avgDistSortKey=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t *)); if (!avgDistSortKey) { goto error_2; } #ifndef NO_OUTPUT printf("[");fflush(stdout); #endif while (1) { if (!built) { compute_palette_from_quantized_pixels(pixelData,nPixels,paletteData,nPaletteEntries,avg,count,qp); build_distance_tables(avgDist,avgDistSortKey,paletteData,nPaletteEntries); built=1; } else { recompute_palette_from_averages(paletteData,nPaletteEntries,avg,count); resort_distance_tables(avgDist,avgDistSortKey,paletteData,nPaletteEntries); } changes=map_image_pixels_from_quantized_pixels(pixelData, nPixels, paletteData, nPaletteEntries, avgDist, avgDistSortKey, qp, avg, count); if (changes<0) { goto error_3; } #ifndef NO_OUTPUT printf (".(%d)",changes);fflush(stdout); #endif if (changes<=threshold) break; } #ifndef NO_OUTPUT printf("]\n"); #endif if (avgDistSortKey) free(avgDistSortKey); if (avgDist) free(avgDist); for(i=0;i<3;i++) if (avg[i]) free (avg[i]); if (count) free(count); return 1; error_3: if (avgDistSortKey) free(avgDistSortKey); error_2: if (avgDist) free(avgDist); error_1: for(i=0;i<3;i++) if (avg[i]) free (avg[i]); if (count) free(count); return 0; } int quantize(Pixel *pixelData, uint32_t nPixels, uint32_t nQuantPixels, Pixel **palette, uint32_t *paletteLength, uint32_t **quantizedPixels, int kmeans) { PixelList *hl[3]; HashTable *h; BoxNode *root; uint32_t i; uint32_t *qp; uint32_t nPaletteEntries; uint32_t *avgDist; uint32_t **avgDistSortKey; Pixel *p; #ifndef NO_OUTPUT uint32_t timer,timer2; #endif #ifndef NO_OUTPUT timer2=clock(); printf ("create hash table..."); fflush(stdout); timer=clock(); #endif h=create_pixel_hash(pixelData,nPixels); #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif if (!h) { goto error_0; } #ifndef NO_OUTPUT printf ("create lists from hash table..."); fflush(stdout); timer=clock(); #endif hl[0]=hl[1]=hl[2]=NULL; hashtable_foreach(h,hash_to_list,hl); #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif if (!hl[0]) { goto error_1; } #ifndef NO_OUTPUT printf ("mergesort lists..."); fflush(stdout); timer=clock(); #endif for(i=0;i<3;i++) { hl[i]=mergesort_pixels(hl[i],i); } #ifdef TEST_MERGESORT if (!test_sorted(hl)) { printf ("bug in mergesort\n"); goto error_1; } #endif #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif #ifndef NO_OUTPUT printf ("median cut..."); fflush(stdout); timer=clock(); #endif root=median_cut(hl,nPixels,nQuantPixels); #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif if (!root) { goto error_1; } nPaletteEntries=0; #ifndef NO_OUTPUT printf ("median cut tree to hash table..."); fflush(stdout); timer=clock(); #endif annotate_hash_table(root,h,&nPaletteEntries); #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif #ifndef NO_OUTPUT printf ("compute palette...\n"); fflush(stdout); timer=clock(); #endif if (!compute_palette_from_median_cut(pixelData,nPixels,h,&p,nPaletteEntries)) { goto error_3; } #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif free_box_tree(root); root=NULL; /* malloc check ok, using calloc for overflow */ qp=calloc(nPixels, sizeof(uint32_t)); if (!qp) { goto error_4; } if (nPaletteEntries > UINT32_MAX / nPaletteEntries ) { goto error_5; } /* malloc check ok, using calloc for overflow, check of n*n above */ avgDist=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t)); if (!avgDist) { goto error_5; } /* malloc check ok, using calloc for overflow, check of n*n above */ avgDistSortKey=calloc(nPaletteEntries*nPaletteEntries, sizeof(uint32_t *)); if (!avgDistSortKey) { goto error_6; } if (!build_distance_tables(avgDist,avgDistSortKey,p,nPaletteEntries)) { goto error_7; } if (!map_image_pixels_from_median_box(pixelData,nPixels,p,nPaletteEntries,h,avgDist,avgDistSortKey,qp)) { goto error_7; } #ifdef TEST_NEAREST_NEIGHBOUR #include <math.h> { uint32_t bestmatch,bestdist,dist; HashTable *h2; printf ("nearest neighbour search (full search)..."); fflush(stdout); timer=clock(); h2=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { if (hashtable_lookup(h2,pixelData[i],&paletteEntry)) { bestmatch=paletteEntry; } else { bestmatch=0; bestdist= _SQR(pixelData[i].c.r-p[0].c.r)+ _SQR(pixelData[i].c.g-p[0].c.g)+ _SQR(pixelData[i].c.b-p[0].c.b); for (j=1;j<nPaletteEntries;j++) { dist= _SQR(pixelData[i].c.r-p[j].c.r)+ _SQR(pixelData[i].c.g-p[j].c.g)+ _SQR(pixelData[i].c.b-p[j].c.b); if (dist==bestdist && j==qp[i]) { bestmatch=j; } if (dist<bestdist) { bestdist=dist; bestmatch=j; } } hashtable_insert(h2,pixelData[i],bestmatch); } if (qp[i]!=bestmatch ) { printf ("discrepancy in matching algorithms pixel %d [%d %d] %f %f\n", i,qp[i],bestmatch, sqrt((double)(_SQR(pixelData[i].c.r-p[qp[i]].c.r)+ _SQR(pixelData[i].c.g-p[qp[i]].c.g)+ _SQR(pixelData[i].c.b-p[qp[i]].c.b))), sqrt((double)(_SQR(pixelData[i].c.r-p[bestmatch].c.r)+ _SQR(pixelData[i].c.g-p[bestmatch].c.g)+ _SQR(pixelData[i].c.b-p[bestmatch].c.b))) ); } } hashtable_free(h2); } #endif #ifndef NO_OUTPUT printf ("k means...\n"); fflush(stdout); timer=clock(); #endif if (kmeans) k_means(pixelData,nPixels,p,nPaletteEntries,qp,kmeans-1); #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); #endif *quantizedPixels=qp; *palette=p; *paletteLength=nPaletteEntries; #ifndef NO_OUTPUT printf ("cleanup..."); fflush(stdout); timer=clock(); #endif if (avgDist) free(avgDist); if (avgDistSortKey) free(avgDistSortKey); destroy_pixel_hash(h); #ifndef NO_OUTPUT printf ("done (%f)\n",(clock()-timer)/(double)CLOCKS_PER_SEC); printf ("-----\ntotal time %f\n",(clock()-timer2)/(double)CLOCKS_PER_SEC); #endif return 1; error_7: if (avgDistSortKey) free(avgDistSortKey); error_6: if (avgDist) free(avgDist); error_5: if (qp) free(qp); error_4: if (p) free(p); error_3: if (root) free_box_tree(root); error_1: destroy_pixel_hash(h); error_0: *quantizedPixels=NULL; *paletteLength=0; *palette=NULL; return 0; } typedef struct { Pixel new; Pixel furthest; uint32_t furthestDistance; int secondPixel; } DistanceData; static void compute_distances(const HashTable *h, const Pixel pixel, uint32_t *dist, void *u) { DistanceData *data=(DistanceData *)u; uint32_t oldDist=*dist; uint32_t newDist; newDist=_DISTSQR(&(data->new),&pixel); if (data->secondPixel || newDist<oldDist) { *dist=newDist; oldDist=newDist; } if (oldDist>data->furthestDistance) { data->furthestDistance=oldDist; data->furthest.v=pixel.v; } } int quantize2(Pixel *pixelData, uint32_t nPixels, uint32_t nQuantPixels, Pixel **palette, uint32_t *paletteLength, uint32_t **quantizedPixels, int kmeans) { HashTable *h; uint32_t i; uint32_t mean[3]; Pixel *p; DistanceData data; uint32_t *qp; uint32_t *avgDist; uint32_t **avgDistSortKey; /* malloc check ok, using calloc */ p=calloc(nQuantPixels, sizeof(Pixel)); if (!p) return 0; mean[0]=mean[1]=mean[2]=0; h=hashtable_new(unshifted_pixel_hash,unshifted_pixel_cmp); for (i=0;i<nPixels;i++) { hashtable_insert(h,pixelData[i],0xffffffff); mean[0]+=pixelData[i].c.r; mean[1]+=pixelData[i].c.g; mean[2]+=pixelData[i].c.b; } data.new.c.r=(int)(.5+(double)mean[0]/(double)nPixels); data.new.c.g=(int)(.5+(double)mean[1]/(double)nPixels); data.new.c.b=(int)(.5+(double)mean[2]/(double)nPixels); for (i=0;i<nQuantPixels;i++) { data.furthestDistance=0; data.secondPixel=(i==1)?1:0; hashtable_foreach_update(h,compute_distances,&data); p[i].v=data.furthest.v; data.new.v=data.furthest.v; } hashtable_free(h); /* malloc check ok, using calloc */ qp=calloc(nPixels, sizeof(uint32_t)); if (!qp) { goto error_1; } if (nQuantPixels > UINT32_MAX / nQuantPixels ) { goto error_2; } /* malloc check ok, using calloc for overflow, check of n*n above */ avgDist=calloc(nQuantPixels*nQuantPixels, sizeof(uint32_t)); if (!avgDist) { goto error_2; } /* malloc check ok, using calloc for overflow, check of n*n above */ avgDistSortKey=calloc(nQuantPixels*nQuantPixels, sizeof(uint32_t *)); if (!avgDistSortKey) { goto error_3; } if (!build_distance_tables(avgDist,avgDistSortKey,p,nQuantPixels)) { goto error_4; } if (!map_image_pixels(pixelData,nPixels,p,nQuantPixels,avgDist,avgDistSortKey,qp)) { goto error_4; } if (kmeans) k_means(pixelData,nPixels,p,nQuantPixels,qp,kmeans-1); *paletteLength=nQuantPixels; *palette=p; *quantizedPixels=qp; free(avgDistSortKey); free(avgDist); return 1; error_4: free(avgDistSortKey); error_3: free(avgDist); error_2: free(qp); error_1: free(p); return 0; } Imaging ImagingQuantize(Imaging im, int colors, int mode, int kmeans) { int i, j; int x, y, v; UINT8* pp; Pixel* p; Pixel* palette; uint32_t paletteLength; int result; uint32_t* newData; Imaging imOut; int withAlpha = 0; ImagingSectionCookie cookie; if (!im) return ImagingError_ModeError(); if (colors < 1 || colors > 256) /* FIXME: for colors > 256, consider returning an RGB image instead (see @PIL205) */ return (Imaging) ImagingError_ValueError("bad number of colors"); if (strcmp(im->mode, "L") != 0 && strcmp(im->mode, "P") != 0 && strcmp(im->mode, "RGB") != 0 && strcmp(im->mode, "RGBA") !=0) return ImagingError_ModeError(); /* only octree and imagequant supports RGBA */ if (!strcmp(im->mode, "RGBA") && mode != 2 && mode != 3) return ImagingError_ModeError(); if (im->xsize > INT_MAX / im->ysize) { return ImagingError_MemoryError(); } /* malloc check ok, using calloc for final overflow, x*y above */ p = calloc(im->xsize * im->ysize, sizeof(Pixel)); if (!p) return ImagingError_MemoryError(); /* collect statistics */ /* FIXME: maybe we could load the hash tables directly from the image data? */ if (!strcmp(im->mode, "L")) { /* greyscale */ /* FIXME: converting a "L" image to "P" with 256 colors should be done by a simple copy... */ for (i = y = 0; y < im->ysize; y++) for (x = 0; x < im->xsize; x++, i++) { p[i].c.r = p[i].c.g = p[i].c.b = im->image8[y][x]; p[i].c.a = 255; } } else if (!strcmp(im->mode, "P")) { /* palette */ pp = im->palette->palette; for (i = y = 0; y < im->ysize; y++) for (x = 0; x < im->xsize; x++, i++) { v = im->image8[y][x]; p[i].c.r = pp[v*4+0]; p[i].c.g = pp[v*4+1]; p[i].c.b = pp[v*4+2]; p[i].c.a = pp[v*4+3]; } } else if (!strcmp(im->mode, "RGB") || !strcmp(im->mode, "RGBA")) { /* true colour */ for (i = y = 0; y < im->ysize; y++) for (x = 0; x < im->xsize; x++, i++) p[i].v = im->image32[y][x]; } else { free(p); return (Imaging) ImagingError_ValueError("internal error"); } ImagingSectionEnter(&cookie); switch (mode) { case 0: /* median cut */ result = quantize( p, im->xsize*im->ysize, colors, &palette, &paletteLength, &newData, kmeans ); break; case 1: /* maximum coverage */ result = quantize2( p, im->xsize*im->ysize, colors, &palette, &paletteLength, &newData, kmeans ); break; case 2: if (!strcmp(im->mode, "RGBA")) { withAlpha = 1; } result = quantize_octree( p, im->xsize*im->ysize, colors, &palette, &paletteLength, &newData, withAlpha ); break; case 3: #ifdef HAVE_LIBIMAGEQUANT if (!strcmp(im->mode, "RGBA")) { withAlpha = 1; } result = quantize_pngquant( p, im->xsize, im->ysize, colors, &palette, &paletteLength, &newData, withAlpha ); #else result = -1; #endif break; default: result = 0; break; } free(p); ImagingSectionLeave(&cookie); if (result > 0) { imOut = ImagingNewDirty("P", im->xsize, im->ysize); ImagingSectionEnter(&cookie); for (i = y = 0; y < im->ysize; y++) for (x = 0; x < im->xsize; x++) imOut->image8[y][x] = (unsigned char) newData[i++]; free(newData); pp = imOut->palette->palette; for (i = j = 0; i < (int) paletteLength; i++) { *pp++ = palette[i].c.r; *pp++ = palette[i].c.g; *pp++ = palette[i].c.b; if (withAlpha) { *pp++ = palette[i].c.a; } else { *pp++ = 255; } } for (; i < 256; i++) { *pp++ = 0; *pp++ = 0; *pp++ = 0; *pp++ = 255; } if (withAlpha) { strcpy(imOut->palette->mode, "RGBA"); } free(palette); ImagingSectionLeave(&cookie); return imOut; } else { if (result == -1) { return (Imaging) ImagingError_ValueError( "dependency required by this method was not " "enabled at compile time"); } return (Imaging) ImagingError_ValueError("quantization error"); } }
1a90270c8e1c5679d1e24d9f0d0dedf7097639ce
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/input/mouse/synaptics.h
fb2e076738ae3bee7fdd844de7e93dd3fa5146c6
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
7,075
h
synaptics.h
/* * Synaptics TouchPad PS/2 mouse driver * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ #ifndef _SYNAPTICS_H #define _SYNAPTICS_H /* synaptics queries */ #define SYN_QUE_IDENTIFY 0x00 #define SYN_QUE_MODES 0x01 #define SYN_QUE_CAPABILITIES 0x02 #define SYN_QUE_MODEL 0x03 #define SYN_QUE_SERIAL_NUMBER_PREFIX 0x06 #define SYN_QUE_SERIAL_NUMBER_SUFFIX 0x07 #define SYN_QUE_RESOLUTION 0x08 #define SYN_QUE_EXT_CAPAB 0x09 #define SYN_QUE_FIRMWARE_ID 0x0a #define SYN_QUE_EXT_CAPAB_0C 0x0c #define SYN_QUE_EXT_MAX_COORDS 0x0d #define SYN_QUE_EXT_MIN_COORDS 0x0f /* synatics modes */ #define SYN_BIT_ABSOLUTE_MODE (1 << 7) #define SYN_BIT_HIGH_RATE (1 << 6) #define SYN_BIT_SLEEP_MODE (1 << 3) #define SYN_BIT_DISABLE_GESTURE (1 << 2) #define SYN_BIT_FOUR_BYTE_CLIENT (1 << 1) #define SYN_BIT_W_MODE (1 << 0) /* synaptics model ID bits */ #define SYN_MODEL_ROT180(m) ((m) & (1 << 23)) #define SYN_MODEL_PORTRAIT(m) ((m) & (1 << 22)) #define SYN_MODEL_SENSOR(m) (((m) >> 16) & 0x3f) #define SYN_MODEL_HARDWARE(m) (((m) >> 9) & 0x7f) #define SYN_MODEL_NEWABS(m) ((m) & (1 << 7)) #define SYN_MODEL_PEN(m) ((m) & (1 << 6)) #define SYN_MODEL_SIMPLIC(m) ((m) & (1 << 5)) #define SYN_MODEL_GEOMETRY(m) ((m) & 0x0f) /* synaptics capability bits */ #define SYN_CAP_EXTENDED(c) ((c) & (1 << 23)) #define SYN_CAP_MIDDLE_BUTTON(c) ((c) & (1 << 18)) #define SYN_CAP_PASS_THROUGH(c) ((c) & (1 << 7)) #define SYN_CAP_SLEEP(c) ((c) & (1 << 4)) #define SYN_CAP_FOUR_BUTTON(c) ((c) & (1 << 3)) #define SYN_CAP_MULTIFINGER(c) ((c) & (1 << 1)) #define SYN_CAP_PALMDETECT(c) ((c) & (1 << 0)) #define SYN_CAP_SUBMODEL_ID(c) (((c) & 0x00ff00) >> 8) #define SYN_EXT_CAP_REQUESTS(c) (((c) & 0x700000) >> 20) #define SYN_CAP_MULTI_BUTTON_NO(ec) (((ec) & 0x00f000) >> 12) #define SYN_CAP_PRODUCT_ID(ec) (((ec) & 0xff0000) >> 16) /* * The following describes response for the 0x0c query. * * byte mask name meaning * ---- ---- ------- ------------ * 1 0x01 adjustable threshold capacitive button sensitivity * can be adjusted * 1 0x02 report max query 0x0d gives max coord reported * 1 0x04 clearpad sensor is ClearPad product * 1 0x08 advanced gesture not particularly meaningful * 1 0x10 clickpad bit 0 1-button ClickPad * 1 0x60 multifinger mode identifies firmware finger counting * (not reporting!) algorithm. * Not particularly meaningful * 1 0x80 covered pad W clipped to 14, 15 == pad mostly covered * 2 0x01 clickpad bit 1 2-button ClickPad * 2 0x02 deluxe LED controls touchpad support LED commands * ala multimedia control bar * 2 0x04 reduced filtering firmware does less filtering on * position data, driver should watch * for noise. * 2 0x08 image sensor image sensor tracks 5 fingers, but only * reports 2. * 2 0x20 report min query 0x0f gives min coord reported * 2 0x80 forcepad forcepad is a variant of clickpad that * does not have physical buttons but rather * uses pressure above certain threshold to * report primary clicks. Forcepads also have * clickpad bit set. */ #define SYN_CAP_CLICKPAD(ex0c) ((ex0c) & 0x100000) /* 1-button ClickPad */ #define SYN_CAP_CLICKPAD2BTN(ex0c) ((ex0c) & 0x000100) /* 2-button ClickPad */ #define SYN_CAP_MAX_DIMENSIONS(ex0c) ((ex0c) & 0x020000) #define SYN_CAP_MIN_DIMENSIONS(ex0c) ((ex0c) & 0x002000) #define SYN_CAP_ADV_GESTURE(ex0c) ((ex0c) & 0x080000) #define SYN_CAP_REDUCED_FILTERING(ex0c) ((ex0c) & 0x000400) #define SYN_CAP_IMAGE_SENSOR(ex0c) ((ex0c) & 0x000800) #define SYN_CAP_FORCEPAD(ex0c) ((ex0c) & 0x008000) /* synaptics modes query bits */ #define SYN_MODE_ABSOLUTE(m) ((m) & (1 << 7)) #define SYN_MODE_RATE(m) ((m) & (1 << 6)) #define SYN_MODE_BAUD_SLEEP(m) ((m) & (1 << 3)) #define SYN_MODE_DISABLE_GESTURE(m) ((m) & (1 << 2)) #define SYN_MODE_PACKSIZE(m) ((m) & (1 << 1)) #define SYN_MODE_WMODE(m) ((m) & (1 << 0)) /* synaptics identify query bits */ #define SYN_ID_MODEL(i) (((i) >> 4) & 0x0f) #define SYN_ID_MAJOR(i) ((i) & 0x0f) #define SYN_ID_MINOR(i) (((i) >> 16) & 0xff) #define SYN_ID_FULL(i) ((SYN_ID_MAJOR(i) << 8) | SYN_ID_MINOR(i)) #define SYN_ID_IS_SYNAPTICS(i) ((((i) >> 8) & 0xff) == 0x47) #define SYN_ID_DISGEST_SUPPORTED(i) (SYN_ID_MAJOR(i) >= 4) /* synaptics special commands */ #define SYN_PS_SET_MODE2 0x14 #define SYN_PS_CLIENT_CMD 0x28 /* synaptics packet types */ #define SYN_NEWABS 0 #define SYN_NEWABS_STRICT 1 #define SYN_NEWABS_RELAXED 2 #define SYN_OLDABS 3 /* amount to fuzz position data when touchpad reports reduced filtering */ #define SYN_REDUCED_FILTER_FUZZ 8 /* * A structure to describe which internal touchpad finger slots are being * reported in raw packets. */ struct synaptics_mt_state { int count; /* num fingers being tracked */ int sgm; /* which slot is reported by sgm pkt */ int agm; /* which slot is reported by agm pkt*/ }; /* * A structure to describe the state of the touchpad hardware (buttons and pad) */ struct synaptics_hw_state { int x; int y; int z; int w; unsigned int left:1; unsigned int right:1; unsigned int middle:1; unsigned int up:1; unsigned int down:1; unsigned char ext_buttons; signed char scroll; /* As reported in last AGM-CONTACT packets */ struct synaptics_mt_state mt_state; }; struct synaptics_data { /* Data read from the touchpad */ unsigned long int model_id; /* Model-ID */ unsigned long int firmware_id; /* Firmware-ID */ unsigned long int board_id; /* Board-ID */ unsigned long int capabilities; /* Capabilities */ unsigned long int ext_cap; /* Extended Capabilities */ unsigned long int ext_cap_0c; /* Ext Caps from 0x0c query */ unsigned long int identity; /* Identification */ unsigned int x_res, y_res; /* X/Y resolution in units/mm */ unsigned int x_max, y_max; /* Max coordinates (from FW) */ unsigned int x_min, y_min; /* Min coordinates (from FW) */ unsigned char pkt_type; /* packet type - old, new, etc */ unsigned char mode; /* current mode byte */ int scroll; bool absolute_mode; /* run in Absolute mode */ bool disable_gesture; /* disable gestures */ struct serio *pt_port; /* Pass-through serio port */ struct synaptics_mt_state mt_state; /* Current mt finger state */ bool mt_state_lost; /* mt_state may be incorrect */ /* * Last received Advanced Gesture Mode (AGM) packet. An AGM packet * contains position data for a second contact, at half resolution. */ struct synaptics_hw_state agm; bool agm_pending; /* new AGM packet received */ /* ForcePad handling */ unsigned long press_start; bool press; bool report_press; }; void synaptics_module_init(void); int synaptics_detect(struct psmouse *psmouse, bool set_properties); int synaptics_init(struct psmouse *psmouse); int synaptics_init_relative(struct psmouse *psmouse); void synaptics_reset(struct psmouse *psmouse); bool synaptics_supported(void); #endif /* _SYNAPTICS_H */
50dbd22b5f9fc435f9b7e8ec3fe77637291676d4
487c8455b34e2b312da42bf8a43162aa5c5027df
/Target/Demo/TRICORE_TC3_TC375_Lite_Kit_ADS/Boot/Libraries/iLLD/TC37A/Tricore/Cpu/Std/Ifx_Types.h
d4e92ee05b24cd189efb3c4b152ff55e365fb51b
[]
no_license
feaser/openblt
bf3a72e7beb998cb635a67db85fa68100d048bb8
57b517eabeb37d945606e18736e106bde34010bc
refs/heads/master
2023-08-31T23:54:09.030534
2023-07-07T10:29:56
2023-07-07T10:29:56
102,110,352
534
236
null
2023-09-14T11:11:56
2017-09-01T12:26:08
C
UTF-8
C
false
false
8,532
h
Ifx_Types.h
/** * \file Ifx_Types.h * \brief This files defines all types used by the IFX HAL and libraries * * \version iLLD_1_0_1_12_0_1 * \copyright Copyright (c) 2018 Infineon Technologies AG. All rights reserved. * * * IMPORTANT NOTICE * * Use of this file is subject to the terms of use agreed between (i) you or * the company in which ordinary course of business you are acting and (ii) * Infineon Technologies AG or its licensees. If and as long as no such terms * of use are agreed, use of this file is subject to following: * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, must * be included in all copies of the Software, in whole or in part, and all * derivative works of the Software, unless such copies or derivative works are * solely in the form of machine-executable object code generated by a source * language processor. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * */ #ifndef IFX_TYPES_H #define IFX_TYPES_H 1 /******************************************************************************/ #include "Tricore/Compilers/Compilers.h" /* mapping compiler specific keywords */ #include "Platform_Types.h" /******************************************************************************* ** Global Data Types ** ** (Types not defined by AUTOSAR) ** *******************************************************************************/ typedef const char *pchar; /**< \brief const char pointer */ typedef void *pvoid; /**< \brief void pointer */ typedef volatile void *vvoid; /**< \brief volatile void pointer */ typedef void (*voidfuncvoid) (void); /**< \brief void pointer which takes void argument */ typedef struct { float32 real; /**< \brief Real part */ float32 imag; /**< \brief Imaginary part */ } cfloat32; typedef struct { sint32 real; /**< \brief Real part */ sint32 imag; /**< \brief Imaginary part */ } csint32; typedef struct { sint16 real; /**< \brief Real part */ sint16 imag; /**< \brief Imaginary part */ } csint16; typedef sint64 Ifx_TickTime; /**< \brief Time in ticks */ #define TIME_INFINITE ((Ifx_TickTime)0x7FFFFFFFFFFFFFFFLL) #define TIME_NULL ((Ifx_TickTime)0x0000000000000000LL) #define IFX_ONES (0xFFFFFFFFFFFFFFFFU) #define IFX_ZEROS (0x0000000000000000U) #if CFG_LONG_SIZE_T #define IFX_SIZET_MAX (0x7FFFFFFFL) typedef sint32 Ifx_SizeT; /**< \brief Type used for data stream size */ #else #define IFX_SIZET_MAX (0x7FFF) typedef sint16 Ifx_SizeT; /**< \brief Type used for data stream size */ #endif /** \brief Circular buffer definition. */ typedef struct { void *base; /**< \brief buffer base address */ uint16 index; /**< \brief buffer current index */ uint16 length; /**< \brief buffer length*/ } Ifx_CircularBuffer; typedef uint16 Ifx_Priority; /**< \brief Used in interrupt service priorities */ typedef uint32 Ifx_TimerValue; /**< \brief Used in timer values */ typedef sint32 Ifx_SignedTimerVal; /**< \brief Used in signed timer values */ typedef pvoid Ifx_AddressValue; /**< \brief Used in address values */ typedef struct { uint16 priority; uint16 provider; } Ifx_IsrSetting; /** \brief Signal active state definition. */ typedef enum { Ifx_ActiveState_low = 0, /**< \brief The signal is low active */ Ifx_ActiveState_high = 1 /**< \brief The signal is high active */ } Ifx_ActiveState; typedef enum { Ifx_ParityMode_even = 0, Ifx_ParityMode_odd = 1 } Ifx_ParityMode; /** \brief input multiplexer definition used in PinMaps */ typedef enum { Ifx_RxSel_a, Ifx_RxSel_b, Ifx_RxSel_c, Ifx_RxSel_d, Ifx_RxSel_e, Ifx_RxSel_f, Ifx_RxSel_g, Ifx_RxSel_h } Ifx_RxSel; /** \brief Module address and index map */ typedef struct { volatile void *module; /**< \brief Module address */ sint32 index; /**< \brief Module index */ } IfxModule_IndexMap; typedef struct { Ifx_TickTime timestamp; uint8 data; }Ifx_DataBufferMode_TimeStampSingle; /* * typedef struct * { * Ifx_TickTime timestamp; * uint8 count[1]; // Number of valid data * uint8 data[7]; * }Ifx_DataBufferMode_TimeStampBurst; */ typedef enum { Ifx_DataBufferMode_normal = 0, /**< \brief normal mode, each received byte is moved to the rx fifo */ Ifx_DataBufferMode_timeStampSingle, /**< \brief Single byte type stamp mode. The rx fifo is filled in with Ifx_DataBufferMode_TimeStampSingle items. */ // Ifx_DataBufferMode_timeStameBurst /**< \brief Burst byte type stamp mode. The rx fifo is filled in with Ifx_DataBufferMode_TimeStampBurst items. */ }Ifx_DataBufferMode; /** * Defines the PWM modes * * The 1st member shall start with value 0, and the next members value shall be the previous member +1 * pwmMode_off shall be the member with the higher index * \note enum order and values should not be modified, except Ifx_Pwm_Mode_init and Ifx_Pwm_Mode_count */ typedef enum { Ifx_Pwm_Mode_centerAligned = 0, /**< \brief Center aligned mode */ Ifx_Pwm_Mode_centerAlignedInverted = 1, /**< \brief Center aligned inverted aligned mode */ Ifx_Pwm_Mode_leftAligned = 2, /**< \brief Left aligned mode. The PWM period starts with a rising edge */ Ifx_Pwm_Mode_rightAligned = 3, /**< \brief Right aligned mode. The PWM period starts with a falling edge*/ Ifx_Pwm_Mode_off = 4, /**< \brief All switch open */ Ifx_Pwm_Mode_init = 5, /**< \brief Initialisation mode, do not use at run time */ Ifx_Pwm_Mode_count /**< \brief Number of defined modes */ } Ifx_Pwm_Mode; #ifdef __DCC__ #include "Ifx_TypesDcc.h" #elif defined(__TASKING__) #include "Ifx_TypesTasking.h" #elif defined(__HIGHTEC__) #include "Ifx_TypesGnuc.h" #elif defined(__ghs__) #include "Ifx_TypesGhs.h" #elif defined(__MSVC__) #include "Ifx_TypesMsvc.h" #else #error Unsupported compiler. #endif typedef struct { fract real; /**< \brief Real part */ fract imag; /**< \brief Imaginary part */ } cfract; typedef struct { sfract real; /**< \brief Real part */ sfract imag; /**< \brief Imaginary part */ } csfract; #define IFX_PI (3.1415926535897932384626433832795f) #define IFX_TWO_OVER_PI (2.0 / IFX_PI) #define IFX_ONE_OVER_SQRT_THREE (0.57735026918962576450914878050196f) #define IFX_SQRT_TWO (1.4142135623730950488016887242097f) #define IFX_SQRT_THREE (1.7320508075688772935274463415059f) #define IFX_UNUSED_PARAMETER(x) if(x){} /**< \brief Added to handle warning resulting from cases where one/multiple function argument(s) is/are not used(but function signature maintained for legacy purposes). Another use case being usage of intrinsics wherein the compiler ignores it and copy pastes the statements using intrinsics directly to the object file and hence usage of arguments isn't visible to it.(eg: __mfcr() etc) */ #endif /* IFX_TYPES_H */
b9086badb0639f669f58c40e943f8b9615cc83b2
03b2c80dbc41e904b167d504666e27d798da5447
/src/bignum_data.c
d6e0069ef33c0ac1422a0de030c203fa871c7b40
[ "Unlicense" ]
permissive
nptcl/npt
7c1570b497cdce0b8971cb445fbc04cb500232d3
aa714a2370ac9fa5348c2fc96159b40b9de3de07
refs/heads/master
2023-03-20T09:13:54.669118
2022-07-02T11:17:44
2022-07-02T11:17:44
171,985,905
160
12
Unlicense
2023-03-11T01:36:37
2019-02-22T03:11:34
C
UTF-8
C
false
false
36,128
c
bignum_data.c
#include <math.h> #include "bignum_data.h" #include "bignum_equal.h" #include "bignum_object.h" #include "character.h" #include "condition.h" #include "heap.h" #include "integer.h" #include "local.h" #include "memory.h" #include "object.h" /***************************************************************************** operator *****************************************************************************/ static void multinumber3(fixed *result, fixed rvalue, fixed *carry) { /* 2 1 [rvalue] * 2 1 [cvalue] * ----- * a b c * d e f * ------- * C C R R */ fixed cvalue, r1, r2, c1, c2, a, b, c, d, e, f; cvalue = *carry; if (rvalue == 0 || cvalue == 0) { *result = *carry = 0; return; } if (rvalue == 1) { *result = cvalue; *carry = 0; return; } if (cvalue == 1) { *result = rvalue; *carry = 0; return; } r2 = HIGHVALUE(rvalue); c2 = HIGHVALUE(cvalue); if (r2 == 0 && c2 == 0) { *result = rvalue * cvalue; *carry = 0; return; } r1 = LOWVALUE(rvalue); c1 = LOWVALUE(cvalue); if (c2 == 0) { c = r1 * c1; b = r2 * c1; b += HIGHVALUE(c); a = HIGHVALUE(b); b = LOWVALUE(b); c = LOWVALUE(c); *result = HIGHLOW(b, c); *carry = a; return; } if (r2 == 0) { c = r1 * c1; b = r1 * c2; b += HIGHVALUE(c); a = HIGHVALUE(b); b = LOWVALUE(b); c = LOWVALUE(c); *result = HIGHLOW(b, c); *carry = a; return; } /* first */ c = r1 * c1; b = r2 * c1; b += HIGHVALUE(c); a = HIGHVALUE(b); b = LOWVALUE(b); c = LOWVALUE(c); /* second */ f = r1 * c2; e = r2 * c2; e += HIGHVALUE(f); d = HIGHVALUE(e); e = LOWVALUE(e); f = LOWVALUE(f); /* result * a b c * d e f * ------- * C C R R */ b += f; *result = HIGHLOW(LOWVALUE(b), c); a += e + HIGHVALUE(b); *carry = HIGHLOW(d + HIGHVALUE(a), LOWVALUE(a)); } static inline void multinumber(fixed *result, fixed *carry) { multinumber3(result, *result, carry); } static inline void plusnumber(fixed *result, fixed *carry) { /* * *ret = c1 + c2; * return (*ret < c1); */ #ifdef BIGNUM_FULLCODE *result += *carry; *carry = *result < *carry; #else *result += *carry; *carry = (*result >> BIGNUM_FULLBIT) != 0; *result &= BIGNUM_FULL; #endif } void plusnumber_bigdata(fixed *result, fixed *carry) { plusnumber(result, carry); } static inline void plusnumber3(fixed *result, fixed value, fixed *carry) { /* * *ret = c1 + c2; * return (*ret < c1); */ #ifdef BIGNUM_FULLCODE *result = value + *carry; *carry = *result < *carry; #else *result = value + *carry; *carry = (*result >> BIGNUM_FULLBIT) != 0; *result &= BIGNUM_FULL; #endif } static void pluscarry(fixed *result, fixed value, fixed *carry) { plusnumber(result, &value); plusnumber(result, carry); *carry += value; } static inline void pluscarry4(fixed *result, fixed left, fixed right, fixed *carry) { plusnumber3(result, left, &right); plusnumber(result, carry); *carry += right; } static inline void multicarry(fixed *result, fixed value, fixed *carry) { multinumber(result, &value); plusnumber(result, carry); *carry += value; } void multicarry_bigdata(fixed *result, fixed value, fixed *carry) { multicarry(result, value, carry); } static void inline multicarry4(fixed *result, fixed left, fixed right, fixed *carry) { multinumber3(result, left, &right); plusnumber(result, carry); *carry += right; } /***************************************************************************** compare *****************************************************************************/ int equal_bigdata(addr left, addr right) { size_t size1, size2; Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); Check(GetType(right) != LISPTYPE_BIGNUM, "type right error"); GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); if (size1 != size2) return 0; GetRootBignum(left, &left); GetRootBignum(right, &right); return bigcmp(PtrDataBignum(left), PtrDataBignum(right), size1) == 0; } int compare_bigdata(addr left, addr right) { const fixed *data1, *data2; size_t size1, size2, i, index; fixed value1, value2; Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); Check(GetType(right) != LISPTYPE_BIGNUM, "type right error"); GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); if (size1 != size2) return (size1 < size2)? -1: 1; GetRootDataBignum(left, &left, &data1); GetRootDataBignum(right, &right, &data2); for (i = 0; i < size1; i++) { index = size1 - i - 1; value1 = data1[index]; value2 = data2[index]; if (value1 < value2) return -1; if (value1 > value2) return 1; } return 0; } /***************************************************************************** plus / minus *****************************************************************************/ static inline void minusnumber(fixed *result, fixed *carry) { /* * *ret = c1 - c2; * return (*ret > c1); */ fixed value = *result; #ifdef BIGNUM_FULLCODE *result -= *carry; #else *result = BIGNUM_FULL & (value - *carry); #endif *carry = *result > value; } static inline void minusnumber3(fixed *result, fixed value, fixed *carry) { /* * *ret = c1 - c2; * return (*ret > c1); */ #ifdef BIGNUM_FULLCODE *result = value - *carry; #else *result = BIGNUM_FULL & (value - *carry); #endif *carry = *result > value; } static void minuscarry(fixed *result, fixed value, fixed *carry) { minusnumber(result, &value); minusnumber(result, carry); *carry += value; } static inline void minuscarry4(fixed *result, fixed left, fixed right, fixed *carry) { minusnumber3(result, left, &right); minusnumber(result, carry); *carry += right; } #define TailCopy(a,b,s,i) bigcpy((a)+(i), (b)+(i), ((s)-(i))) void setplusvalue_bigdata(addr set, addr left, int sign, fixed right) { addr root; fixed *data1; const fixed *data2; size_t size, i; GetSizeBignum(left, &size); GetRootDataBignum(set, &root, &data1); GetRootDataBignum(left, &root, &data2); for (i = 0; right && i < size; i++) plusnumber3(&data1[i], data2[i], &right); if (i < size) TailCopy(data1, data2, size, i); if (right) { data1[i] = right; size++; } Check(RefAllocBignum(set) < size, "bignum size error"); SetSizeBignum(set, size); SetSignBignum(set, sign); } void plusvalue_bigdata_alloc(LocalRoot local, addr left, int sign, fixed right, addr *ret) { addr pos; Check(GetType(left) != LISPTYPE_BIGNUM, "type error"); alloc_bignum(local, &pos, RefSizeBignum(left) + 1UL); setplusvalue_bigdata(pos, left, sign, right); *ret = pos; } void setminusvalue_bigdata(addr set, addr left, int sign, fixed right) { addr root; fixed *data1, value; const fixed *data2; size_t size, i; GetSizeBignum(left, &size); SetSizeBignum(set, size); GetRootDataBignum(set, &root, &data1); GetRootDataBignum(left, &root, &data2); /* single value */ Check(size == 0, "size error"); if (size == 1) { value = data2[0]; if (value == right) { setzero_bignum(set); } else if (value < right) { data1[0] = right - value; SetSignBignum(set, SignNot(sign)); } else { data1[0] = value - right; SetSignBignum(set, sign); } return; } /* multi value */ SetSignBignum(set, sign); for (i = 0; right; i++) minusnumber3(&data1[i], data2[i], &right); if (i < size) TailCopy(data1, data2, size, i); sizepress_bignum(set); } void minusvalue_bigdata_alloc(LocalRoot local, addr left, int sign, fixed right, addr *ret) { addr pos; Check(GetType(left) != LISPTYPE_BIGNUM, "type error"); alloc_bignum(local, &pos, RefSizeBignum(left)); setminusvalue_bigdata(pos, left, sign, right); *ret = pos; } static void plusloop(addr pos, size_t size1, size_t size2, const fixed *data1, const fixed *data2) { size_t i; fixed carry, *data; struct bignuminfo *ptr; ptr = StructBignum(pos); Check(size2 < size1, "size error"); Check(ptr->alloc <= size2, "alloc error"); GetRootDataBignum(pos, &pos, &data); carry = 0; for (i = 0; i < size1; i++) pluscarry4(&data[i], data1[i], data2[i], &carry); for (; carry && i < size2; i++) plusnumber3(&data[i], data2[i], &carry); if (i < size2) TailCopy(data, data2, size2, i); if (carry) { data[i] = carry; size2++; } ptr->size = size2; } void plus_bigdata_alloc(LocalRoot local, addr left, addr right, addr *ret) { addr pos; const fixed *data1, *data2; size_t size1, size2; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); GetRootDataBignum(left, &left, &data1); GetRootDataBignum(right, &right, &data2); if (size1 < size2) { alloc_bignum(local, &pos, size2 + 1); plusloop(pos, size1, size2, data1, data2); } else { alloc_bignum(local, &pos, size1 + 1); plusloop(pos, size2, size1, data2, data1); } *ret = pos; } void letplus_noexpand_bigdata(addr left, addr right) { addr root; const fixed *data1, *data2; size_t size1, size2; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); Check(RefAllocBignum(left) < size1 + 1, "size1 error"); Check(RefAllocBignum(left) < size2 + 1, "size2 error"); GetRootDataBignum(left, &root, &data1); GetRootDataBignum(right, &root, &data2); if (size1 < size2) { plusloop(left, size1, size2, data1, data2); } else { plusloop(left, size2, size1, data2, data1); } } static inline void setminus_bigdata_call(addr pos, const fixed *data1, size_t size1, const fixed *data2, size_t size2) { addr root; fixed carry, *data; size_t i; GetRootDataBignum(pos, &root, &data); SetSizeBignum(pos, size1); carry = 0; for (i = 0; i < size2; i++) minuscarry4(&data[i], data1[i], data2[i], &carry); for (; carry; i++) minusnumber3(&data[i], data1[i], &carry); if (i < size1) TailCopy(data, data1, size1, i); sizepress_bignum(pos); } static void minus_bigdata_call(LocalRoot local, addr *ret, const fixed *data1, size_t size1, const fixed *data2, size_t size2) { alloc_bignum(local, ret, size1); setminus_bigdata_call(*ret, data1, size1, data2, size2); } void minus_bigdata_alloc(LocalRoot local, addr left, addr right, addr *ret) { addr root; size_t size1, size2; const fixed *data1, *data2; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); GetRootDataBignum(left, &root, &data1); GetRootDataBignum(right, &root, &data2); Check(size1 < size2, "size error"); Check((size1 == 1) && (data1[0] < data2[0]), "value error"); Check(size1 == size2 && compare_bigdata(left, right) < 0, "compare error"); minus_bigdata_call(local, ret, data1, size1, data2, size2); } int minuscheck_bigdata_alloc(LocalRoot local, addr left, addr right, addr *ret) { int check; addr root; size_t size1, size2; const fixed *data1, *data2; check = compare_bigdata(left, right); if (check == 0) { bignum_value_alloc(local, ret, SignPlus, 0); return 0; } if (0 < check) { GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); GetRootDataBignum(left, &root, &data1); GetRootDataBignum(right, &root, &data2); check = 0; } else { GetSizeBignum(left, &size2); GetSizeBignum(right, &size1); GetRootDataBignum(left, &root, &data2); GetRootDataBignum(right, &root, &data1); check = 1; } minus_bigdata_call(local, ret, data1, size1, data2, size2); return check; } static void setminus_noexpand(addr pos, addr left, addr right) { addr root; size_t size1, size2; const fixed *data1, *data2; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); GetRootDataBignum(left, &root, &data1); GetRootDataBignum(right, &root, &data2); Check(size1 < size2, "size error"); Check((size1 == 1) && (data1[0] < data2[0]), "value error"); Check(size1 == size2 && compare_bigdata(left, right) < 0, "compare error"); Check(RefAllocBignum(pos) < size1, "alloc error"); setminus_bigdata_call(pos, data1, size1, data2, size2); } int letminus_noexpand_bigdata(addr left, addr right) { int check; check = compare_bigdata(left, right); if (check == 0) { setzero_bignum(left); return 0; } if (check < 0) { setminus_noexpand(left, right, left); return 1; } else { setminus_noexpand(left, left, right); return 0; } } /***************************************************************************** multiple *****************************************************************************/ void multicarry_fixnum(LocalRoot local, fixnum left, fixnum right, addr *ret) { int sign1, sign2; fixed fixed1, fixed2; castfixed(left, &sign1, &fixed1); castfixed(right, &sign2, &fixed2); sign1 = SignMulti(sign1, sign2); multinumber(&fixed1, &fixed2); if (fixed2 != 0) { bignum_value2_alloc(local, ret, sign1, fixed2, fixed1); } else if (IsPlus(sign1) && (fixed1 <= FIXNUM_MAX)) { fixnum_alloc(local, ret, (fixnum)fixed1); } else if (IsMinus(sign1) && (fixed1 <= FIXNUM_UMIN)) { fixnum_alloc(local, ret, -(fixnum)fixed1); } else { bignum_value_alloc(local, ret, sign1, fixed1); } } void multicarry_bignum(LocalRoot local, fixnum left, fixnum right, addr *ret) { int sign1, sign2; fixed fixed1, fixed2; castfixed(left, &sign1, &fixed1); castfixed(right, &sign2, &fixed2); sign1 = SignMulti(sign1, sign2); multinumber(&fixed1, &fixed2); if (fixed2) bignum_value2_alloc(local, ret, sign1, fixed2, fixed1); else bignum_value_alloc(local, ret, sign1, fixed1); } void setmultivalue_bigdata(addr pos, addr left, fixed right) { addr root; fixed *data1, carry; const fixed *data2; size_t i, size; Check(GetType(pos) != LISPTYPE_BIGNUM, "type pos error"); Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); GetSizeBignum(left, &size); Check(RefAllocBignum(pos) <= size, "size error"); GetRootDataBignum(pos, &root, &data1); GetRootDataBignum(left, &root, &data2); carry = 0; for (i = 0; i < size; i++) multicarry4(&data1[i], data2[i], right, &carry); if (carry) data1[i++] = carry; SetSizeBignum(pos, i); } void setmulti_bigdata(addr pos, addr left, addr right) { addr root; size_t size1, size2, a, b, c; fixed *data, value1, value2, carry; const fixed *data1, *data2; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); Check(RefAllocBignum(pos) < size1 + size2, "size error"); GetRootDataBignum(pos, &root, &data); GetRootDataBignum(left, &root, &data1); GetRootDataBignum(right, &root, &data2); bigset(data, 0, size1 + size2); for (b = c = 0; b < size2; b++) { value2 = data2[b]; carry = 0; for (a = 0; a < size1; a++) { value1 = data1[a]; multicarry(&value1, value2, &carry); for (c = a + b; value1; c++) plusnumber(&data[c], &value1); } for (c = a + b; carry; c++) plusnumber(&data[c], &carry); } SetSizeBignum(pos, c); } void multi_bigdata_alloc(LocalRoot local, addr left, addr right, addr *ret) { Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); Check(GetType(right) != LISPTYPE_BIGNUM, "type right error"); alloc_plus_bignum(local, ret, RefSizeBignum(left), RefSizeBignum(right)); setmulti_bigdata(*ret, left, right); } /***************************************************************************** division *****************************************************************************/ static void divhalf(fixed *high, fixed *low, fixed denom, fixed *carry) { fixed v1, v2, n3, n4, a2, a3, a4, a; v1 = CUTB(*high); v2 = CUTB(*low); n3 = HIGHVALUE(v2); n4 = LOWVALUE(v2); a2 = v1 / denom; a = v1 % denom; v1 = HIGHLOW(a, n3); a3 = v1 / denom; a = v1 % denom; v1 = HIGHLOW(a, n4); a4 = v1 / denom; *high = CUTB(a2); *low = HIGHLOW(a3, a4); *carry = CUTB(v1 % denom); } static void divloop(fixed m1, fixed denom, fixed *quot, fixed *rem, fixed n1, fixed n2, fixed n3) { /* * a: [n1 n2 n3] / denom */ fixed a, nn, v1, v2, v3; /* nn = [n2 n3] */ SETB(n1); SETB(n2); SETB(n3); nn = CUTB(HIGHLOW(n2, n3)); if (n1 == 0 && nn < denom) { *quot = 0; *rem = nn; return; } /* a = [n1 n2] / m1; */ a = CUTB(HIGHLOW(n1, n2) / m1); /* a * denom = [v1 v2 v2] */ v1 = 0; multicarry4(&v2, a, denom, &v1); SETB(v2); /* [n1 n2 n3] - [v1 v2 v2] */ v3 = 0; minuscarry(&nn, v2, &v3); SETB(nn); SETB(v3); minuscarry(&n1, v1, &v3); SETB(n1); SETB(v3); while (v3) { a--; SETB(a); v3 = 0; pluscarry(&nn, denom, &v3); SETB(nn); SETB(v3); v3 = (v3 == 0); } *quot = a; *rem = nn; } #define GETSHIFTVALUECHECK (1ULL << (BIGNUM_FULLBIT - 1)) static int getshiftvalue(fixed *value) { int count; #ifdef LISP_BIGNUM_DEBUG if (*value == 0) { Abort("getshiftvalue error"); } #endif for (count = 0; *value < GETSHIFTVALUECHECK; count++) *value <<= 1; return count; } static void divfull(fixed *high, fixed *low, fixed denom, fixed *carry) { int shift, nshift; fixed m1, a2, a3, a4; fixed nn, s1, s2; /* shift denom */ shift = getshiftvalue(&denom); #ifdef LISP_BIGNUM_DEBUG if (BIGNUM_HALFBIT <= shift) { Abort("getshiftvalue error"); } #endif m1 = HIGHVALUE(denom); s1 = CUTB(*high); s2 = CUTB(*low); if (shift == 0) { /* a2: [n1 n2] / denom */ if (s1 < denom) { a2 = 0; nn = s1; } else { a2 = s1 / denom; nn = s1 % denom; } shift = 0; goto second; } /* shift */ nshift = BIGNUM_FULLBIT - shift; nn = CUTB(s1 >> nshift); s1 = CUTB((s1 << shift) | (s2 >> nshift)); s2 = CUTB(s2 << shift); /* a2: [n0 n1 n2] / denom */ divloop(m1, denom, &a2, &nn, CUTB(nn), HIGHVALUE(s1), LOWVALUE(s1)); second: /* a3: [n1 n2 n3] / denom */ divloop(m1, denom, &a3, &nn, HIGHVALUE(nn), LOWVALUE(nn), HIGHVALUE(s2)); /* a4: [n2 n3 n4] / denom */ divloop(m1, denom, &a4, &nn, HIGHVALUE(nn), LOWVALUE(nn), LOWVALUE(s2)); /* result */ *high = CUTB(a2); *low = HIGHLOW(a3, a4); *carry = CUTB(nn >> shift); } static void divdouble(fixed *high, fixed *low, fixed denom, fixed *carry) { /* * 1. ----/00 -> error * 2. 0000/-- -> 0 * 3. 00bb/cc -> b/c * 4. aabb/-c -> divhalf(aabb/-c) * 5. aabb/cc -> divfull(aabb/cc) */ fixed value; #ifdef LISP_BIGNUM_DEBUG /* denom is zero */ if (denom == 0) { Abort("divdouble error, denom is zero."); } #endif /* single division */ if (*high == 0) { /* numerator is zero */ value = *low; if (value == 0) { *carry = 0; return; } /* normal division */ *low = value / denom; *carry = value % denom; return; } if (denom == 1) { *carry = 0; return; } if (HIGHVALUE(denom)) divfull(high, low, denom, carry); else divhalf(high, low, denom, carry); } static void divcarry4_half(fixed *ptr, fixed left, fixed denom, fixed *carry) { fixed n1; #ifndef LISP_BIGNUM_DEBUG fixed n2; #endif #ifdef LISP_BIGNUM_DEBUG if (denom <= *carry) { Abort("divcarry4_half error. (carry)"); } if (HIGHVALUE(denom)) { Abort("divcarry4_half error. (denom)"); } #endif if (*carry == 0) { *ptr = left / denom; *carry = left % denom; return; } #ifdef LISP_BIGNUM_DEBUG n1 = *carry; divhalf(&n1, &left, denom, carry); if (n1) { Abort("divcarry4_half error"); } *ptr = left; #else n1 = HIGHLOW(*carry, HIGHVALUE(left)); n2 = n1 / denom; n1 = n1 % denom; n1 = HIGHLOW(n1, LOWVALUE(left)); *carry = n1 % denom; *ptr = HIGHLOW(n2, n1 / denom); #endif } static void divcarry4_full(fixed *ptr, fixed left, fixed denom, fixed *carry) { fixed high; if (*carry == 0) { *ptr = left / denom; *carry = left % denom; return; } high = *carry; divfull(&high, &left, denom, carry); #ifdef LISP_BIGNUM_DEBUG if (high) { Abort("divcarry4_full error"); } #endif *ptr = left; } static void multiminusdata( fixed *r, const fixed *data2, size_t size, fixed a, fixed *carry) { size_t i; fixed m, check; check = 0; for (i = 0; i < size; i++) { multicarry4(&m, data2[i], a, &check); minuscarry(&r[i], m, carry); } minuscarry(&r[i], check, carry); } static void pluscarrydata(fixed *r, const fixed *data2, size_t size, fixed *carry) { size_t i; fixed check; check = 0; for (i = 0; i < size; i++) pluscarry(&r[i], data2[i], &check); if (check) *carry = 0; } static int comparedata( const fixed *data1, size_t size1, const fixed *data2, size_t size2) { size_t i, index1, index2; fixed a, b; for (i = 0; i < size2; i++) { index1 = size1 - i - 1; index2 = size2 - i - 1; a = data1[index1]; b = data2[index2]; if (a < b) return -1; if (a > b) return 1; } return 0; } static int comparedata2( const fixed *data1, size_t size1, const fixed *data2, size_t size2) { size_t i, index; fixed a, b; for (; size1 && data1[size1 - 1] == 0; size1--) continue; for (; size2 && data2[size2 - 1] == 0; size2--) continue; if (size1 < size2) return -1; if (size1 > size2) return 1; for (i = 0; i < size1; i++) { index = size1 - i - 1; a = data1[index]; b = data2[index]; if (a < b) return -1; if (a > b) return 1; } return 0; } static void quotdata(fixed *datar, const fixed *data2, size_t size2, fixed *q) { fixed carry; carry = 0; multiminusdata(datar, data2, size2, *q, &carry); while (carry) { (*q)--; pluscarrydata(datar, data2, size2, &carry); } datar[size2] = 0; } static void divrem_calculate(addr quot, addr rem, addr left, addr right) { int compare; size_t pos, size1, size2, sizer, sizeq, len; const fixed *data1, *data2; fixed *datar, *dataq, high, q, dn, carry; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); GetSizeBignum(quot, &sizeq); GetSizeBignum(rem, &sizer); GetRootDataBignum(left, &left, &data1); GetRootDataBignum(right, &right, &data2); GetRootDataBignum(quot, &quot, &dataq); GetRootDataBignum(rem, &rem, &datar); pos = 0; len = size1 - size2 + 1; dn = data2[size2 - 1]; /* first check */ compare = comparedata(data1, size1, data2, size2); if (compare == 0) { /* equal */ dataq[sizeq - pos++ - 1] = 1; bigset(datar, 0, sizer); } else if (0 < compare) { /* N division */ q = data1[size1 - 1] / dn; bigcpy(datar, data1 + size1 - size2, size2); datar[size2] = 0; quotdata(datar, data2, size2, &q); dataq[sizeq - pos++ - 1] = q; } else { /* N+1 division */ bigcpy(datar, data1 + size1 - size2, size2); datar[size2] = 0; dataq[sizeq - pos++ - 1] = 0; } /* N+1 division */ for (; pos < len; pos++) { /* shift */ bigmove(datar + 1, datar, size2); datar[0] = data1[size1 - size2 - pos]; compare = comparedata2(datar, sizer, data2, size2); if (compare == 0) { dataq[sizeq - pos - 1] = 1; bigset(datar, 0, sizer); continue; } else if (compare < 0) { dataq[sizeq - pos - 1] = 0; continue; } /* quot */ high = datar[sizer - 1]; q = datar[sizer - 2]; divdouble(&high, &q, dn, &carry); if (high) q = BIGNUM_FULL; quotdata(datar, data2, size2, &q); dataq[sizeq - pos - 1] = q; } } static void shiftup(int shift, int nshift, fixed *dst, const fixed *src, size_t size, int final) { size_t i; fixed carry, temp; carry = 0; for (i = 0; i < size; i++) { temp = src[i]; dst[i] = CUTB((temp << shift) | (carry >> nshift)); carry = temp; } if (final) dst[i] = carry >> nshift; } static void shiftdown(int shift, int nshift, fixed *dst, size_t size) { size_t i, index; fixed carry, temp; carry = 0; for (i = 0; i < size; i++) { index = size - i - 1; temp = dst[index]; dst[index] = CUTB((carry << nshift) | (temp >> shift)); carry = temp; } } #define make_bignum_local(local, ret, size) { \ addr __pos; \ alloc_bignum(local, &__pos, (size)); \ SetSizeBignum(__pos, (size)); \ *(ret) = __pos; \ } static void div_noexpand(LocalRoot local, addr *rq, addr *rr, addr left, addr right) { int shift, nshift; addr root, quot, rem, a, b; fixed *data1, *data2, *dataa, *datab, carry; size_t size1, size2, sizea; GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); GetRootDataBignum(right, &root, &data2); carry = data2[size2 - 1]; shift = getshiftvalue(&carry); if (shift == 0) { make_bignum_local(local, &quot, size1 - size2 + 1); make_bignum_local(local, &rem, size2 + 1); divrem_calculate(quot, rem, left, right); } else { /* memory allocate */ make_bignum_local(local, &a, size1 + 1); make_bignum_local(local, &b, size2); /* shiftup */ nshift = BIGNUM_FULLBIT - shift; GetRootDataBignum(left, &root, &data1); GetRootDataBignum(right, &root, &data2); GetRootDataBignum(a, &root, &dataa); GetRootDataBignum(b, &root, &datab); shiftup(shift, nshift, dataa, data1, size1, 1); shiftup(shift, nshift, datab, data2, size2, 0); sizepress_bignum(a); /* run calculate */ GetSizeBignum(a, &sizea); make_bignum_local(local, &quot, sizea - size2 + 1); make_bignum_local(local, &rem, size2 + 1); divrem_calculate(quot, rem, a, b); /* shift reverse rem */ GetRootDataBignum(rem, &root, &data1); GetSizeBignum(rem, &size1); shiftdown(shift, nshift, data1, size1); } sizepress_bignum(quot); sizepress_bignum(rem); *rq = quot; *rr = rem; } static void letdiv_noexpand(LocalRoot local, addr left, addr right) { addr quot, rem; LocalStack stack; push_local(local, &stack); div_noexpand(local, &quot, &rem, left, right); copy_noexpand_bignum(left, quot); rollback_local(local, stack); } static fixed letdivvalue_buffer(addr left, fixed right) { addr root; fixed *data, carry; size_t size, i, index; GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data); /* single */ if (size == 1) { carry = data[0] % right; data[0] /= right; return carry; } /* multiple */ carry = 0; index = size - 1; if (HIGHVALUE(right)) { for (i = 0; i < size; i++) { divcarry4_full(&data[index], data[index], right, &carry); index--; } } else { for (i = 0; i < size; i++) { divcarry4_half(&data[index], data[index], right, &carry); index--; } } sizepress_bignum(left); return carry; } void letdiv_noexpand_bigdata(LocalRoot local, addr left, addr right) { int check1, check2, compare; size_t size1, size2; fixed a, b; Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); Check(GetType(right) != LISPTYPE_BIGNUM, "type left error"); if (zerop_bignum(right)) { Abort("division-by-zero error."); return; } if (zerop_bignum(left)) { setzero_bignum(left); return; } GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); check1 = (size1 == 1); check2 = (size2 == 1); if (check1 && check2) { GetRootBignum(right, &right); b = PtrDataBignum(right)[0]; GetRootBignum(left, &right); a = PtrDataBignum(right)[0]; setvalue_bignum(left, SignPlus, a / b); return; } if (check2) { GetRootBignum(right, &right); b = PtrDataBignum(right)[0]; if (b == 1) return; (void)letdivvalue_buffer(left, b); return; } compare = compare_bigdata(left, right); if (compare == 0) { setvalue_bignum(left, SignPlus, 1); return; } if (compare < 0) { setzero_bignum(left); return; } letdiv_noexpand(local, left, right); } static void setrem_noexpand(LocalRoot local, addr set, addr left, addr right) { addr quot, rem; LocalStack stack; push_local(local, &stack); div_noexpand(local, &quot, &rem, left, right); copy_noexpand_bignum(set, rem); rollback_local(local, stack); } static fixed remvalue_buffer(addr left, fixed right) { addr root; fixed *data, carry, dummy; size_t size, i, index; GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data); /* single */ if (size == 1) return data[0] % right; /* multiple */ carry = 0; index = size - 1; if (HIGHVALUE(right)) { for (i = 0; i < size; i++) { divcarry4_full(&dummy, data[index], right, &carry); index--; } } else { for (i = 0; i < size; i++) { divcarry4_half(&dummy, data[index], right, &carry); index--; } } return carry; } void setrem_noexpand_bigdata(LocalRoot local, addr set, addr left, addr right) { int check1, check2, compare; size_t size1, size2; fixed a, b; Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); Check(GetType(right) != LISPTYPE_BIGNUM, "type left error"); if (zerop_bignum(right)) { Abort("division-by-zero error."); return; } if (zerop_bignum(left)) { setzero_bignum(set); return; } GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); check1 = (size1 == 1); check2 = (size2 == 1); if (check1 && check2) { GetRootBignum(left, &left); GetRootBignum(right, &right); a = PtrDataBignum(left)[0]; b = PtrDataBignum(right)[0]; setvalue_bignum(set, SignPlus, a % b); return; } if (check2) { GetRootBignum(right, &right); b = PtrDataBignum(right)[0]; if (b == 1) { setzero_bignum(set); return; } b = remvalue_buffer(left, b); setvalue_bignum(set, SignPlus, b); return; } compare = compare_bigdata(left, right); if (compare == 0) { setzero_bignum(set); return; } if (compare < 0) { copy_noexpand_bignum(set, left); return; } setrem_noexpand(local, set, left, right); } void divrem_bigdata_local(LocalRoot local, addr *quot, addr *rem, addr left, addr right) { int check1, check2, compare; size_t size1, size2; fixed a, b; Check(local == NULL, "local error"); Check(GetType(left) != LISPTYPE_BIGNUM, "type left error"); Check(GetType(right) != LISPTYPE_BIGNUM, "type left error"); if (zerop_bignum(right)) { Abort("division-by-zero error."); return; } if (zerop_bignum(left)) { bignum_value_alloc(local, quot, SignPlus, 0); bignum_value_alloc(local, rem, SignPlus, 0); return; } GetSizeBignum(left, &size1); GetSizeBignum(right, &size2); Check(size1 == 0, "size1 error"); Check(size2 == 0, "size2 error"); check1 = (size1 <= 1); check2 = (size2 <= 1); if (check1 && check2) { GetRootBignum(left, &left); GetRootBignum(right, &right); a = PtrDataBignum(left)[0]; b = PtrDataBignum(right)[0]; bignum_value_alloc(local, quot, SignPlus, a / b); bignum_value_alloc(local, rem, SignPlus, a % b); return; } if (check2) { GetRootBignum(right, &right); b = PtrDataBignum(right)[0]; if (b == 1) { bignum_copy_nosign_alloc(local, quot, left); bignum_value_alloc(local, rem, SignPlus, 0); } else { bignum_copy_nosign_alloc(local, quot, left); b = letdivvalue_buffer(*quot, b); bignum_value_alloc(local, rem, SignPlus, b); } return; } compare = compare_bigdata(left, right); if (compare == 0) { bignum_value_alloc(local, quot, SignPlus, 1); bignum_value_alloc(local, rem, SignPlus, 0); return; } if (compare < 0) { bignum_value_alloc(local, quot, SignPlus, 0); bignum_copy_nosign_alloc(local, rem, left); return; } div_noexpand(local, quot, rem, left, right); } /* * shift */ void power2_bigdata_alloc(LocalRoot local, addr *ret, size_t value) { size_t count; fixed *data; addr pos, root; count = value / BIGNUM_FULLBIT; value = value % BIGNUM_FULLBIT; alloc_bignum(local, &pos, count + 1); GetRootDataBignum(pos, &root, &data); if (count) { bigset(data, 0, count); } data[count] = (1ULL << (fixed)value); SetSizeBignum(pos, count + 1); *ret = pos; } void division2_bigdata_alloc(LocalRoot local, addr *ret, addr left) { addr pos, root; fixed *data1, *data2, carry, value; size_t size, i, index; GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data1); if (size == 1) { bignum_value_alloc(local, ret, SignPlus, data1[0] >> 1); return; } if (data1[size - 1] == 1) { carry = 1; size--; } else { carry = 0; } alloc_bignum(local, &pos, size); SetSizeBignum(pos, size); GetRootDataBignum(pos, &root, &data2); for (i = 0; i < size; i++) { index = size - i - 1ULL; value = data1[index]; data2[index] = (carry << (BIGNUM_FULLBIT - 1ULL)) | (value >> 1ULL); carry = (value & 1ULL); } *ret = pos; } void shiftup_bigdata_alloc(LocalRoot local, addr *ret, addr left, size_t value) { addr pos, root; size_t size, count, dsize, i; fixed *data1, *data2, next, temp; if (value == 0) { bignum_throw_alloc(local, left, ret); return; } count = value / BIGNUM_FULLBIT; value = value % BIGNUM_FULLBIT; GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data1); if (size == 1 && data1[0] == 0) { bignum_zero_alloc(local, ret); return; } dsize = size + count; if (value) { alloc_bignum(local, &pos, dsize + 1); GetRootDataBignum(pos, &root, &data2); SetSizeBignum(pos, dsize + 1); bigset(data2, 0, count); next = 0; for (i = 0; i < size; i++) { temp = data1[i]; data2[i + count] = CUTB(temp << value) | next; next = temp >> (BIGNUM_FULLBIT - value); } data2[i + count] = next; sizepress_bignum(pos); } else { alloc_bignum(local, &pos, dsize); GetRootDataBignum(pos, &root, &data2); SetSizeBignum(pos, dsize); bigcpy(data2 + count, data1, size); bigset(data2, 0, count); } SetSignBignum(pos, RefSignBignum(left)); *ret = pos; } void shiftdown_bigdata_alloc(LocalRoot local, addr *ret, addr left, size_t value) { addr pos, root; size_t size, count, dsize, i; fixed *data1, *data2, x, y; if (value == 0) { bignum_throw_alloc(local, left, ret); return; } count = value / BIGNUM_FULLBIT; value = value % BIGNUM_FULLBIT; GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data1); if ((size == 1 && data1[0] == 0) || (size <= count)) { bignum_zero_alloc(local, ret); return; } dsize = size - count; alloc_bignum(local, &pos, dsize); GetRootDataBignum(pos, &root, &data2); SetSizeBignum(pos, dsize); if (value) { dsize--; for (i = 0; i < dsize; i++) { x = (data1[i + count] >> value); y = (data1[i + count + 1] << (BIGNUM_FULLBIT - value)); data2[i] = x | y; } data2[i] = (data1[i + count] >> value); sizepress_bignum(pos); } else { bigcpy(data2, data1 + count, dsize); } SetSignBignum(pos, RefSignBignum(left)); *ret = pos; } /* shiftdown-minus */ static void shiftdown_minus_make(LocalRoot local, addr *ret, addr src) { addr pos, root; size_t size; fixed *data1, *data2; GetSizeBignum(src, &size); alloc_bignum(local, &pos, size + 1UL); GetRootDataBignum(src, &root, &data1); GetRootDataBignum(pos, &root, &data2); bigcpy(data2, data1, size); data2[size] = 0UL; SetSizeBignum(pos, size + 1UL); *ret = pos; } static void shiftdown_minus_reverse(addr pos) { size_t size, i; fixed *data; GetDataBignum(pos, &data); GetSizeBignum(pos, &size); for (i = 0; i < size; i++) data[i] = ~(data[i]); } static void shiftdown_minus_oneplus(addr pos) { setplusvalue_bigdata(pos, pos, SignPlus, 1); } static void shiftdown_minus_shift(addr pos, size_t value) { addr root; size_t size, count, dsize, i, dfullbit; fixed *data, x, y; count = value / BIGNUM_FULLBIT; value = value % BIGNUM_FULLBIT; GetSizeBignum(pos, &size); GetRootDataBignum(pos, &root, &data); dsize = size - count; dfullbit = BIGNUM_FULLBIT - value; if (value) { dsize--; for (i = 0; i < dsize; i++) { x = data[i + count] >> value; y = data[i + count + 1] << dfullbit; data[i] = x | y; } x = data[i + count] >> value; y = (BIGNUM_FULL >> dfullbit) << dfullbit; data[i] = x | y; i++; } else { bigmove(data, data + count, dsize); i = dsize; } /* fill-bit */ for (; i < size; i++) data[i] = BIGNUM_FULL; } void shiftdown_minus_bigdata(LocalRoot local, addr *ret, addr left, size_t value) { int sign; addr pos, root; size_t size, count; fixed *data; if (value == 0) { bignum_throw_alloc(local, left, ret); return; } count = value / BIGNUM_FULLBIT; GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data); if ((size == 1 && data[0] == 0) || (size <= count)) { bignum_fixnum_value_alloc(local, ret, -1); return; } shiftdown_minus_make(local, &pos, left); /* reverse */ shiftdown_minus_reverse(pos); shiftdown_minus_oneplus(pos); /* shift */ shiftdown_minus_shift(pos, value); /* reverse */ shiftdown_minus_reverse(pos); shiftdown_minus_oneplus(pos); /* result */ GetSignBignum(left, &sign); SetSignBignum(pos, sign); sizepress_bignum(pos); *ret = pos; } /* * output */ fixed letdiv_half_bigdata(addr left, fixed right) { addr root; fixed *data, carry; size_t size, i, index; Check(HIGHVALUE(right), "right size error"); GetSizeBignum(left, &size); GetRootDataBignum(left, &root, &data); /* single */ if (size == 1) { carry = data[0] % right; data[0] /= right; return carry; } /* multiple */ carry = 0; index = size - 1; for (i = 0; i < size; i++) { divcarry4_half(&data[index], data[index], right, &carry); index--; } sizepress_bignum(left); return carry; }
01497dc8cc750fff5bd2bce85bfc6480447718d4
8e56b05b32a978eb170e01409a7aaaa1fc755979
/sys/tests/pmap.c
b411ce6f603a1bc0f60cebca74c93f7f458270a1
[]
permissive
cahirwpz/mimiker
d71f37c2c6efc58a0026e8e4cfcd676d85ef7445
5343231aeeeb0d16b2419f84405f52981dc51c07
refs/heads/master
2023-09-01T20:20:07.256932
2023-08-30T18:36:27
2023-08-30T18:36:27
46,346,617
278
67
BSD-3-Clause
2023-09-14T16:57:32
2015-11-17T12:46:47
C
UTF-8
C
false
false
4,946
c
pmap.c
#include <sys/klog.h> #include <sys/pmap.h> #include <sys/vm.h> #include <sys/vm_physmem.h> #include <sys/ktest.h> #include <sys/sched.h> #include <sys/kmem.h> #ifdef __riscv #include <riscv/cpufunc.h> #endif static vm_page_t *x_vm_page_alloc(size_t npages) { vm_page_t *pg = vm_page_alloc(npages); assert(pg != NULL); return pg; } static vaddr_t x_kva_alloc(size_t size) { vaddr_t vaddr = kva_alloc(size, M_WAITOK); assert(vaddr != 0); return vaddr; } /* * Kernel physical map tests. */ static int test_pmap_kenter(void) { vm_page_t *pg = x_vm_page_alloc(1); vaddr_t va = x_kva_alloc(PAGESIZE); bool done; unsigned i, val; unsigned *ptr = (unsigned *)va; /* read-write */ pmap_kenter(va, pg->paddr, VM_PROT_READ | VM_PROT_WRITE, 0); for (i = 0; i < PAGESIZE / sizeof(unsigned); i++) { done = try_store_word(&ptr[i], i); assert(done); } /* read-only */ pmap_kenter(va, pg->paddr, VM_PROT_READ, 0); for (i = 0; i < PAGESIZE / sizeof(unsigned); i++) { done = try_load_word(&ptr[i], &val); assert(done && val == i); } done = try_store_word(ptr, 0xDEADC0DE); assert(!done); /* no access allowed */ pmap_kenter(va, pg->paddr, 0, 0); done = try_load_word(ptr, &val); assert(!done); done = try_store_word(ptr, 0xDEADC0DE); assert(!done); pmap_kremove(va, PAGESIZE); kva_free(va); vm_page_free(pg); return KTEST_SUCCESS; } static int test_pmap_kextract(void) { vm_page_t *pg = x_vm_page_alloc(1); vaddr_t va = x_kva_alloc(PAGESIZE); pmap_kenter(va, pg->paddr, VM_PROT_READ, 0); paddr_t pa; bool ok = pmap_kextract(va, &pa); assert(ok && pa == pg->paddr); pmap_kremove(va, PAGESIZE); kva_free(va); vm_page_free(pg); return KTEST_SUCCESS; } static int test_pmap_page_copy(void) { vm_page_t *pg1 = x_vm_page_alloc(1); vm_page_t *pg2 = x_vm_page_alloc(2); vaddr_t va = x_kva_alloc(PAGESIZE); bool done; unsigned i, val; unsigned *ptr = (unsigned *)va; pmap_kenter(va, pg1->paddr, VM_PROT_READ | VM_PROT_WRITE, 0); for (i = 0; i < PAGESIZE / sizeof(unsigned); i++) { done = try_store_word(&ptr[i], i); assert(done); } pmap_copy_page(pg1, pg2); pmap_zero_page(pg1); for (i = 0; i < PAGESIZE / sizeof(unsigned); i++) { done = try_load_word(&ptr[i], &val); assert(done && val == 0); } pmap_kenter(va, pg2->paddr, VM_PROT_READ, 0); for (i = 0; i < PAGESIZE / sizeof(unsigned); i++) { done = try_load_word(&ptr[i], &val); assert(done && val == i); } pmap_kremove(va, PAGESIZE); kva_free(va); vm_page_free(pg1); vm_page_free(pg2); return KTEST_SUCCESS; } KTEST_ADD(pmap_kenter, test_pmap_kenter, 0); KTEST_ADD(pmap_kextract, test_pmap_kextract, 0); KTEST_ADD(pmap_page_copy, test_pmap_page_copy, 0); /* * User physical map tests. */ static int test_user_pmap(void) { /* This test mustn't be preempted since PCPU's user-space vm_map * (and its pmap) will not be restored while switching back. */ SCOPED_NO_PREEMPTION(); pmap_t *orig = pmap_user(); pmap_t *pmap1 = pmap_new(); pmap_t *pmap2 = pmap_new(); vaddr_t start = 0x1001000; vm_page_t *pg1 = x_vm_page_alloc(1); vm_page_t *pg2 = x_vm_page_alloc(1); pmap_activate(pmap1); pmap_enter(pmap1, start, pg1, VM_PROT_READ | VM_PROT_WRITE, 0); pmap_activate(pmap2); pmap_enter(pmap2, start, pg2, VM_PROT_READ | VM_PROT_WRITE, 0); #ifdef __riscv enter_user_access(); #endif volatile int *ptr = (int *)start; *ptr = 100; pmap_activate(pmap1); *ptr = 200; pmap_activate(pmap2); assert(*ptr == 100); pmap_activate(pmap1); assert(*ptr == 200); #ifdef __riscv exit_user_access(); #endif pmap_delete(pmap1); pmap_delete(pmap2); /* Restore original user pmap */ pmap_activate(orig); return KTEST_SUCCESS; } static int test_rmbits(void) { /* This test mustn't be preempted since PCPU's user-space vm_map * (and its pmap) will not be restored while switching back. */ SCOPED_NO_PREEMPTION(); pmap_t *orig = pmap_user(); pmap_t *pmap = pmap_new(); volatile int *ptr = (int *)0x1001000; vm_page_t *pg = x_vm_page_alloc(1); pmap_activate(pmap); pmap_enter(pmap, (vaddr_t)ptr, pg, VM_PROT_READ | VM_PROT_WRITE, 0); assert(!pmap_is_referenced(pg) && !pmap_is_modified(pg)); #ifdef __riscv enter_user_access(); #endif /* vm_page_alloc doesn't return zeroed pages, so we cannot assume any value */ __unused int value = *ptr; assert(pmap_is_referenced(pg) && !pmap_is_modified(pg)); pmap_clear_referenced(pg); *ptr = 100; assert(pmap_is_referenced(pg) && pmap_is_modified(pg)); pmap_clear_modified(pg); assert(*ptr == 100); assert(pmap_is_referenced(pg) && !pmap_is_modified(pg)); #ifdef __riscv exit_user_access(); #endif pmap_delete(pmap); /* Restore original user pmap */ pmap_activate(orig); return KTEST_SUCCESS; } KTEST_ADD(pmap_user, test_user_pmap, 0); KTEST_ADD(pmap_rmbits, test_rmbits, 0);
d472ee58e5283f14a927c013440d768a5e322857
fa1ad2e2ac7e376fc7cb3b3a6e1bb88eed3e80be
/govern/data-security/krb-1.2.1/src/lib/krb5/os/t_locate_kdc.c
1b836e334ff4c72aba715b8e00483981d467de82
[ "BSD-4-Clause", "LicenseRef-scancode-generic-export-compliance", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-mit-old-style", "BSD-4-Clause-UC", "LicenseRef-scancode-rsa-1990", "BSD-3-Clause", "MIT-CMU", "LicenseRef-scancode-mit-no-advert-export-control", "CC-BY-SA-3.0", "LicenseRef-scancode-mit-modification-obligations", "LicenseRef-scancode-proprietary-license", "GPL-2.0-or-later", "LicenseRef-scancode-michigan-disclaimer", "ISC", "LicenseRef-scancode-nrl-permission", "FreeBSD-DOC", "LicenseRef-scancode-rsa-md4", "RSA-MD", "OLDAP-2.8", "FSFULLRWD", "BSD-2-Clause", "LicenseRef-scancode-brian-gladman", "MIT", "Apache-2.0" ]
permissive
alldatacenter/alldata
7bc7713c9f1d56ad6b8e59ea03206d1073b7e047
8d5f9a2d49ab8f9e85ccf058cb02c2fda287afc6
refs/heads/master
2023-08-05T07:32:25.442740
2023-08-03T13:17:24
2023-08-03T13:17:24
213,321,771
774
250
Apache-2.0
2023-09-06T17:35:32
2019-10-07T07:36:18
null
UTF-8
C
false
false
3,442
c
t_locate_kdc.c
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ #include "k5-platform.h" #include "port-sockets.h" #include <sys/types.h> #include <com_err.h> #define TEST #include "fake-addrinfo.h" #include "dnsglue.c" #include "dnssrv.c" #include "locate_kdc.c" enum { LOOKUP_CONF = 3, LOOKUP_DNS, LOOKUP_WHATEVER } how = LOOKUP_WHATEVER; const char *prog; struct serverlist sl; static void kfatal (krb5_error_code err) { com_err (prog, err, "- exiting"); exit (1); } static const char * ttypename (k5_transport ttype) { static char buf[20]; switch (ttype) { case TCP_OR_UDP: return "tcp or udp"; case TCP: return "tcp"; case UDP: return "udp"; case HTTPS: return "https"; default: snprintf(buf, sizeof(buf), "?%d", ttype); return buf; } } static void print_addrs (void) { size_t i; int err; printf("%d servers:\n", (int)sl.nservers); for (i = 0; i < sl.nservers; i++) { struct server_entry *entry = &sl.servers[i]; char hostbuf[NI_MAXHOST], srvbuf[NI_MAXSERV]; if (entry->hostname != NULL) { printf("%d: h:%s t:%s p:%d m:%d P:%s\n", (int)i, entry->hostname, ttypename(entry->transport), entry->port, entry->primary, entry->uri_path ? entry->uri_path : ""); continue; } err = getnameinfo((struct sockaddr *)&entry->addr, entry->addrlen, hostbuf, sizeof(hostbuf), srvbuf, sizeof(srvbuf), NI_NUMERICHOST | NI_NUMERICSERV); if (err) { printf("%2d: getnameinfo returns error %d=%s\n", (int)i, err, gai_strerror(err)); } else { printf("%2d: address %s\t%s\tport %s\n", (int)i, hostbuf, ttypename(entry->transport), srvbuf); } } } int main (int argc, char *argv[]) { char *p, *realmname; krb5_data realm; krb5_context ctx; krb5_error_code err; int primary = 0; p = strrchr (argv[0], '/'); if (p) prog = p+1; else prog = argv[0]; switch (argc) { case 2: /* foo $realm */ realmname = argv[1]; break; case 3: if (!strcmp (argv[1], "-c")) how = LOOKUP_CONF; else if (!strcmp (argv[1], "-d")) how = LOOKUP_DNS; else if (!strcmp (argv[1], "-m")) primary = 1; else goto usage; realmname = argv[2]; break; default: usage: fprintf (stderr, "%s: usage: %s [-c | -d | -m] realm\n", prog, prog); return 1; } err = krb5_init_context (&ctx); if (err) kfatal (err); realm.data = realmname; realm.length = strlen (realmname); switch (how) { case LOOKUP_CONF: err = krb5_locate_srv_conf(ctx, &realm, "kdc", &sl, htons(88)); break; case LOOKUP_DNS: err = locate_srv_dns_1(ctx, &realm, "_kerberos", "_udp", &sl); break; case LOOKUP_WHATEVER: err = k5_locate_kdc(ctx, &realm, &sl, primary, FALSE); break; } if (err) kfatal (err); print_addrs(); k5_free_serverlist(&sl); krb5_free_context(ctx); return 0; }
ac58041e246b961a65504c15e1e6bbaa847df8eb
290c96ec464bc49084696b1df71c088ddcc9ffff
/modules/network/httpclient/main.c
cca675045e6e2712fd95a3127d84e3241886838c
[ "AFL-3.0" ]
permissive
ps2homebrew/Open-PS2-Loader
c23cce4e8b6d08bdc4b229da9bcb7c9bd31fc255
9e12706ef5ac0f4a3b72fe5860c1e38d2e94e151
refs/heads/master
2023-08-14T21:37:43.222099
2023-08-14T18:18:19
2023-08-14T18:18:19
70,989,832
1,378
262
AFL-3.0
2023-08-19T21:20:14
2016-10-15T13:37:16
C
UTF-8
C
false
false
3,671
c
main.c
#include <errno.h> #include <intrman.h> #include <loadcore.h> #include <sifcmd.h> #include <sifman.h> #include <stdio.h> #include <sysclib.h> #include <thbase.h> #include <irx.h> #include "httpclient.h" IRX_ID("HTTP_Client", 1, 1); static SifRpcDataQueue_t SifQueueData; static SifRpcServerData_t SifServerData; static int RpcThreadID; static unsigned char SifServerRxBuffer[256]; static unsigned char SifServerTxBuffer[16]; static unsigned char DmaBuffer[512]; extern struct irx_export_table _exp_httpc; static void *SifRpc_handler(int fno, void *buffer, int nbytes) { SifDmaTransfer_t dmat; int OldState; switch (fno) { case HTTP_CLIENT_CMD_CONN_ESTAB: *(int *)SifServerTxBuffer = HttpEstabConnection(((struct HttpClientConnEstabArgs *)buffer)->server, ((struct HttpClientConnEstabArgs *)buffer)->port); break; case HTTP_CLIENT_CMD_CONN_CLOSE: HttpCloseConnection(((struct HttpClientConnCloseArgs *)buffer)->socket); break; case HTTP_CLIENT_CMD_SEND_GET_REQ: if (((struct HttpClientSendGetArgs *)buffer)->out_len > sizeof(DmaBuffer)) { printf("HttpClient: truncating output.\n"); ((struct HttpClientSendGetArgs *)buffer)->out_len = sizeof(DmaBuffer); } ((struct HttpClientSendGetResult *)SifServerTxBuffer)->result = HttpSendGetRequest(((struct HttpClientSendGetArgs *)buffer)->socket, ((struct HttpClientSendGetArgs *)buffer)->UserAgent, ((struct HttpClientSendGetArgs *)buffer)->host, &((struct HttpClientSendGetArgs *)buffer)->mode, ((struct HttpClientSendGetArgs *)buffer)->hasMtime ? ((struct HttpClientSendGetArgs *)buffer)->mtime : NULL, ((struct HttpClientSendGetArgs *)buffer)->uri, (char *)DmaBuffer, &((struct HttpClientSendGetArgs *)buffer)->out_len); ((struct HttpClientSendGetResult *)SifServerTxBuffer)->mode = ((struct HttpClientSendGetArgs *)buffer)->mode; ((struct HttpClientSendGetResult *)SifServerTxBuffer)->out_len = ((struct HttpClientSendGetArgs *)buffer)->out_len; dmat.src = DmaBuffer; dmat.dest = ((struct HttpClientSendGetArgs *)buffer)->output; dmat.size = (((struct HttpClientSendGetArgs *)buffer)->out_len + 0xF) & ~0xF; dmat.attr = 0; CpuSuspendIntr(&OldState); while (sceSifSetDma(&dmat, 1) == 0) ; CpuResumeIntr(OldState); break; default: *(int *)SifServerTxBuffer = -ENXIO; } return SifServerTxBuffer; } static void RpcThread(void *arg) { sceSifSetRpcQueue(&SifQueueData, GetThreadId()); sceSifRegisterRpc(&SifServerData, 0x00001B14, &SifRpc_handler, SifServerRxBuffer, NULL, NULL, &SifQueueData); sceSifRpcLoop(&SifQueueData); } int _start(int argc, char *argv[]) { int result; iop_thread_t thread; printf("HTTPClient start\n"); if (RegisterLibraryEntries(&_exp_httpc) == 0) { thread.attr = TH_C; thread.option = 0x00001B14; thread.thread = &RpcThread; thread.priority = 0x20; thread.stacksize = 0x800; if ((RpcThreadID = CreateThread(&thread)) > 0) { StartThread(RpcThreadID, NULL); result = 0; } else { result = RpcThreadID; ReleaseLibraryEntries(&_exp_httpc); } } else { result = -1; } return (result == 0 ? MODULE_RESIDENT_END : MODULE_NO_RESIDENT_END); } int _exit(int argc, char *argv[]) { ReleaseLibraryEntries(&_exp_httpc); TerminateThread(RpcThreadID); DeleteThread(RpcThreadID); return MODULE_NO_RESIDENT_END; }
af46d96c2c1ed85d15449a2e0c36f9864df33615
08d6e4a36de09b2aff205d83178440e4ddf30b6b
/impl/node.c
dbf70ab07b518be9843f276576ba91950b701403
[ "ISC" ]
permissive
vmxdev/tkvdb
315f7c0b42b0e795ce2d3b625bdc89259f93fe81
701c29a11dd9aee12a0023127a3b7e76e9a9176c
refs/heads/master
2023-03-09T00:08:36.193426
2022-02-18T20:25:11
2022-02-18T20:25:11
70,838,515
330
27
ISC
2018-07-23T09:49:51
2016-10-13T18:59:37
C
UTF-8
C
false
false
12,580
c
node.c
/* * tkvdb * * Copyright (c) 2016-2019, Vladimir Misyurov * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ /* get memory for node * memory block is taken from system using malloc() * when 'tr->tr_buf_dynalloc' is true * or from preallocated buffer * preallocation occurs in tkvdb_tr_create() */ void * TKVDB_IMPL_NODE_ALLOC(tkvdb_tr *trns, size_t node_size) { TKVDB_MEMNODE_TYPE *node; tkvdb_tr_data *tr = trns->data; if (tr->params.tr_buf_dynalloc) { /* allocate node using system malloc() */ if ((tr->tr_buf_allocated + node_size) > tr->params.tr_buf_limit) { /* memory limit exceeded */ return NULL; } node = malloc(node_size); if (!node) { return NULL; } } else { uint8_t *buf_ptr; /* FIXME: don't hardcode! */ /* align to 16-byte boundary */ buf_ptr = (uint8_t *) ((uintptr_t)(tr->tr_buf_ptr + 16 - 1) & (-16)); /* calculate node size with alignment */ node_size += buf_ptr - tr->tr_buf_ptr; if ((tr->tr_buf_allocated + node_size) > tr->params.tr_buf_limit) { /* memory limit exceeded */ return NULL; } node = (TKVDB_MEMNODE_TYPE *)buf_ptr; tr->tr_buf_ptr += node_size; } tr->tr_buf_allocated += node_size; return node; } /* create new node and append prefix and value */ void * TKVDB_IMPL_NODE_NEW(tkvdb_tr *tr, int type, size_t prefix_size, const void *prefix, size_t val_size, const void *val, size_t meta_size, void *meta) { TKVDB_MEMNODE_TYPE *node; TKVDB_MEMNODE_TYPE_LEAF *node_leaf; TKVDB_MEMNODE_TYPE_COMMON *node_common; size_t node_size; void *ret; #ifdef TKVDB_PARAMS_ALIGN_VAL /* aligned value */ #define NODE_ALIGN (((tkvdb_tr_data *)(tr->data))->params.alignval) #define PTR_TO_VAL(NODE) ((uintptr_t)(NODE->prefix_val_meta + prefix_size)) #define VALPADDING(NODE) \ (((PTR_TO_VAL(NODE) + NODE_ALIGN - 1) & -NODE_ALIGN) \ - PTR_TO_VAL(NODE)) #define COPY_VAL(NODE) \ do { \ memcpy(NODE->prefix_val_meta + prefix_size + NODE->c.val_pad, \ val, val_size); \ } while(0) #define COPY_META(NODE) \ do { \ memcpy(NODE->prefix_val_meta + prefix_size + NODE->c.val_pad \ + val_size, meta, meta_size); \ } while(0) #else /* non-aligned value */ #define NODE_ALIGN 0 #define COPY_VAL(NODE) \ do { \ memcpy(NODE->prefix_val_meta + prefix_size, val, val_size); \ } while(0) #define COPY_META(NODE) \ do { \ memcpy(NODE->prefix_val_meta + prefix_size + val_size, meta, \ meta_size); \ } while(0) #endif if (type & TKVDB_NODE_LEAF) { node_size = sizeof(TKVDB_MEMNODE_TYPE_LEAF) + prefix_size + val_size + NODE_ALIGN + meta_size; node_leaf = TKVDB_IMPL_NODE_ALLOC(tr, node_size); if (!node_leaf) { return NULL; } node_common = &node_leaf->c; } else { node_size = sizeof(TKVDB_MEMNODE_TYPE) + prefix_size + val_size + NODE_ALIGN + meta_size; node = TKVDB_IMPL_NODE_ALLOC(tr, node_size); if (!node) { return NULL; } node_common = &node->c; } node_common->type = type; node_common->prefix_size = prefix_size; node_common->val_size = val_size; node_common->meta_size = meta_size; node_common->replaced_by = NULL; node_common->disk_size = 0; node_common->disk_off = 0; node_common->nsubnodes = 0; if (type & TKVDB_NODE_LEAF) { if (prefix_size > 0) { memcpy(node_leaf->prefix_val_meta, prefix, prefix_size); } #ifdef TKVDB_PARAMS_ALIGN_VAL node_leaf->c.val_pad = VALPADDING(node_leaf); #endif if (val_size > 0) { COPY_VAL(node_leaf); } if (meta && (meta_size > 0)) { COPY_META(node_leaf); } ret = node_leaf; } else { if (prefix_size > 0) { memcpy(node->prefix_val_meta, prefix, prefix_size); } #ifdef TKVDB_PARAMS_ALIGN_VAL node->c.val_pad = VALPADDING(node); #endif if (val_size > 0) { COPY_VAL(node); } memset(node->next, 0, sizeof(TKVDB_MEMNODE_TYPE *) * 256); #ifndef TKVDB_PARAMS_NODBFILE memset(node->fnext, 0, sizeof(uint64_t) * 256); #endif if (meta && (meta_size > 0)) { COPY_META(node); } ret = node; } return ret; #undef NODE_ALIGN #undef PTR_TO_VAL #undef VALPADDING #undef COPY_VAL #undef COPY_META } static void TKVDB_IMPL_CLONE_SUBNODES(TKVDB_MEMNODE_TYPE *dst, TKVDB_MEMNODE_TYPE *src) { if (dst->c.type & TKVDB_NODE_LEAF) { /* dst has no subnodes, nothing to do */ return; } if (src->c.type & TKVDB_NODE_LEAF) { memset(dst->next, 0, sizeof(void *) * 256); #ifndef TKVDB_PARAMS_NODBFILE memset(dst->fnext, 0, sizeof(uint64_t) * 256); #endif } else { memcpy(dst->next, src->next, sizeof(TKVDB_MEMNODE_TYPE *) * 256); #ifndef TKVDB_PARAMS_NODBFILE memcpy(dst->fnext, src->fnext, sizeof(uint64_t) * 256); #endif } dst->c.nsubnodes = src->c.nsubnodes; } /* read node from disk */ #ifndef TKVDB_PARAMS_NODBFILE static TKVDB_RES TKVDB_IMPL_NODE_READ(tkvdb_tr *trns, uint64_t off, TKVDB_MEMNODE_TYPE **node_ptr) { uint8_t buf[TKVDB_READ_SIZE]; struct tkvdb_disknode *disknode; size_t prefix_val_meta_size; uint8_t *ptr; int fd; unsigned char *prefix_val_meta; tkvdb_tr_data *tr = trns->data; #ifdef TKVDB_PARAMS_ALIGN_VAL /* aligned value */ #define NODE_ALIGN (tr->params.alignval) #define PTR_TO_VAL(NODE) ((uintptr_t)(prefix_val_meta + NODE->c.prefix_size)) #define VALPADDING(NODE) \ (((PTR_TO_VAL(NODE) + NODE_ALIGN - 1) & -NODE_ALIGN) \ - PTR_TO_VAL(NODE)) #else #define NODE_ALIGN 0 #endif fd = tr->db->fd; if (lseek(fd, off, SEEK_SET) != (off_t)off) { return TKVDB_IO_ERROR; } if (!tkvdb_try_read_file(fd, buf, TKVDB_READ_SIZE, 1)) { return TKVDB_IO_ERROR; } disknode = (struct tkvdb_disknode *)buf; /* calculate size of prefix + value + metadata */ prefix_val_meta_size = disknode->size - sizeof(struct tkvdb_disknode) + sizeof(uint8_t) * 1; if (disknode->type & TKVDB_NODE_VAL) { prefix_val_meta_size -= sizeof(uint32_t); } if (disknode->type & TKVDB_NODE_META) { prefix_val_meta_size -= sizeof(uint32_t); } if (disknode->nsubnodes > TKVDB_SUBNODES_THR) { prefix_val_meta_size -= 256 * sizeof(uint64_t); } else { prefix_val_meta_size -= disknode->nsubnodes * sizeof(uint8_t); prefix_val_meta_size -= disknode->nsubnodes * sizeof(uint64_t); } /* allocate memnode */ if (disknode->type & TKVDB_NODE_LEAF) { *node_ptr = TKVDB_IMPL_NODE_ALLOC(trns, sizeof(TKVDB_MEMNODE_TYPE_LEAF) + prefix_val_meta_size + NODE_ALIGN); } else { *node_ptr = TKVDB_IMPL_NODE_ALLOC(trns, sizeof(TKVDB_MEMNODE_TYPE) + prefix_val_meta_size + NODE_ALIGN); } if (!(*node_ptr)) { return TKVDB_ENOMEM; } (*node_ptr)->c.replaced_by = NULL; /* now fill memnode with values from disk node */ (*node_ptr)->c.type = disknode->type; (*node_ptr)->c.prefix_size = disknode->prefix_size; (*node_ptr)->c.disk_size = 0; (*node_ptr)->c.disk_off = 0; (*node_ptr)->c.nsubnodes = disknode->nsubnodes; ptr = disknode->data; (*node_ptr)->c.val_size = (*node_ptr)->c.meta_size = 0; if (disknode->type & TKVDB_NODE_VAL) { (*node_ptr)->c.val_size = *((uint32_t *)ptr); ptr += sizeof(uint32_t); } if (disknode->type & TKVDB_NODE_META) { (*node_ptr)->c.meta_size = *((uint32_t *)ptr); ptr += sizeof(uint32_t); } if (disknode->type & TKVDB_NODE_LEAF) { TKVDB_MEMNODE_TYPE_LEAF *node_leaf; node_leaf = (TKVDB_MEMNODE_TYPE_LEAF *)(*node_ptr); prefix_val_meta = node_leaf->prefix_val_meta; } else { /* non-leaf node */ memset((*node_ptr)->next, 0, sizeof(TKVDB_MEMNODE_TYPE *) * 256); if (disknode->nsubnodes > TKVDB_SUBNODES_THR) { memcpy((*node_ptr)->fnext, ptr, 256 * sizeof(uint64_t)); ptr += 256 * sizeof(uint64_t); } else { int i; uint64_t *offptr; offptr = (uint64_t *)(ptr + disknode->nsubnodes * sizeof(uint8_t)); memset((*node_ptr)->fnext, 0, sizeof(uint64_t) * 256); for (i=0; i<disknode->nsubnodes; i++) { (*node_ptr)->fnext[*ptr] = *offptr; ptr++; offptr++; } ptr += disknode->nsubnodes * sizeof(uint64_t); } prefix_val_meta = (*node_ptr)->prefix_val_meta; } if (disknode->size > TKVDB_READ_SIZE) { /* prefix + value + metadata bigger than read block */ size_t blk_tail = TKVDB_READ_SIZE - (disknode->size - prefix_val_meta_size); #ifdef TKVDB_PARAMS_ALIGN_VAL size_t pfx_size = (*node_ptr)->c.prefix_size; uint8_t *val_meta_ptr; if (blk_tail >= pfx_size) { /* prefix is in buffer, copy it to node */ memcpy(prefix_val_meta, ptr, pfx_size); /* copy start of value + metadata */ (*node_ptr)->c.val_pad = VALPADDING((*node_ptr)); val_meta_ptr = prefix_val_meta + pfx_size + (*node_ptr)->c.val_pad; memcpy(val_meta_ptr, ptr + pfx_size, blk_tail - pfx_size); /* read rest of value + metadata */ val_meta_ptr += blk_tail - pfx_size; if (!tkvdb_try_read_file(fd, val_meta_ptr, disknode->size - TKVDB_READ_SIZE, 0)) { return TKVDB_IO_ERROR; } } else { /* copy start of prefix */ memcpy(prefix_val_meta, ptr, blk_tail); /* read rest of prefix */ if (!tkvdb_try_read_file(fd, prefix_val_meta + blk_tail, pfx_size - blk_tail, 0)) { return TKVDB_IO_ERROR; } /* read value + metadata */ (*node_ptr)->c.val_pad = VALPADDING((*node_ptr)); val_meta_ptr = prefix_val_meta + pfx_size + (*node_ptr)->c.val_pad; if (!tkvdb_try_read_file(fd, val_meta_ptr, prefix_val_meta_size - pfx_size, 0)) { return TKVDB_IO_ERROR; } } #else memcpy(prefix_val_meta, ptr, blk_tail); if (!tkvdb_try_read_file(fd, prefix_val_meta + blk_tail, disknode->size - TKVDB_READ_SIZE, 0)) { return TKVDB_IO_ERROR; } #endif } else { #ifdef TKVDB_PARAMS_ALIGN_VAL /* copy prefix */ memcpy(prefix_val_meta, ptr, (*node_ptr)->c.prefix_size); /* and value */ (*node_ptr)->c.val_pad = VALPADDING((*node_ptr)); memcpy(prefix_val_meta + (*node_ptr)->c.prefix_size + (*node_ptr)->c.val_pad, ptr + (*node_ptr)->c.prefix_size, prefix_val_meta_size - (*node_ptr)->c.prefix_size); #else memcpy(prefix_val_meta, ptr, prefix_val_meta_size); #endif } return TKVDB_OK; #undef NODE_ALIGN #undef PTR_TO_VAL #undef VALPADDING } #endif /* no NODE_READ function in RAM-only mode */ /* free node and subnodes */ static void TKVDB_IMPL_NODE_FREE(tkvdb_tr_data *tr, TKVDB_MEMNODE_TYPE *node) { size_t stack_size = 0; TKVDB_MEMNODE_TYPE *next; int off = 0; for (;;) { if (node->c.replaced_by) { next = node->c.replaced_by; free(node); node = next; continue; } if (!(node->c.type & TKVDB_NODE_LEAF)) { /* search in subnodes */ next = NULL; for (; off<256; off++) { if (node->next[off]) { next = node->next[off]; break; } } if (next) { /* push */ if ((stack_size + 1) > tr->stack_allocated) { tr->stack = realloc(tr->stack, (stack_size + 1) * sizeof(struct tkvdb_visit_helper)); if (!tr->stack) { return; } tr->stack_allocated = stack_size + 1; } tr->stack[stack_size].node = node; tr->stack[stack_size].off = off; stack_size++; node = next; off = 0; continue; } } /* no more subnodes */ if (stack_size < 1) { break; } free(node); /* get node from stack's top */ stack_size--; node = tr->stack[stack_size].node; off = tr->stack[stack_size].off; off++; } free(node); }
c305137abb4a4ff3000f2446698961d9410fe247
de21f9075f55640514c29ef0f1fe3f0690845764
/regression/contracts/invariant_side_effects/main.c
b2000c05c063c0c2ff5769354644f675f5f18632
[ "BSD-2-Clause", "LicenseRef-scancode-unknown-license-reference", "BSD-4-Clause" ]
permissive
diffblue/cbmc
975a074ac445febb3b5715f8792beb545522dc18
decd2839c2f51a54b2ad0f3e89fdc1b4bf78cd16
refs/heads/develop
2023-08-31T05:52:05.342195
2023-08-30T13:31:51
2023-08-30T13:31:51
51,877,056
589
309
NOASSERTION
2023-09-14T18:49:17
2016-02-16T23:03:52
C++
UTF-8
C
false
false
310
c
main.c
#include <assert.h> #include <stdlib.h> int main() { unsigned N, *a = malloc(sizeof(unsigned int)); *a = 0; while(*a < N) // clang-format off __CPROVER_loop_invariant((0 <= *a) && (*a <= N)) __CPROVER_decreases(N - *a) // clang-format on { ++(*a); } assert(*a == N); }
7c6e210bd1f8e336491a1639d69ce1438fe2edb9
52c8ed39b32ccc7c0673278c1adea3638797c9ff
/src/include/xui/split.h
9c2cf9617d75d7fd815b7e7e03ff0c390c16451a
[ "MIT" ]
permissive
xboot/xboot
0cab7b440b612aa0a4c366025598a53a7ec3adf1
6d6b93947b7fcb8c3924fedb0715c23877eedd5e
refs/heads/master
2023-08-20T05:56:25.149388
2023-07-12T07:38:29
2023-07-12T07:38:29
471,539
765
296
MIT
2023-05-25T09:39:01
2010-01-14T08:25:12
C
UTF-8
C
false
false
651
h
split.h
#ifndef __XUI_SPLIT_H__ #define __XUI_SPLIT_H__ #ifdef __cplusplus extern "C" { #endif #include <xui/xui.h> enum { XUI_SPLIT_PRIMARY = (0x0 << 8), XUI_SPLIT_SECONDARY = (0x1 << 8), XUI_SPLIT_SUCCESS = (0x2 << 8), XUI_SPLIT_INFO = (0x3 << 8), XUI_SPLIT_WARNING = (0x4 << 8), XUI_SPLIT_DANGER = (0x5 << 8), XUI_SPLIT_HORIZONTAL = (0x0 << 12), XUI_SPLIT_VERTICAL = (0x1 << 12), }; void xui_split_ex(struct xui_context_t * ctx, int opt); static inline void xui_split(struct xui_context_t * ctx) { xui_split_ex(ctx, XUI_SPLIT_HORIZONTAL); } #ifdef __cplusplus } #endif #endif /* __XUI_SPLIT_H__ */
12c022c5946d981b09d385f6bc68fb6cf61f50e9
6f8bf483b372d8bd526698a083309edb50b0bd90
/wgpu/inject-wgpu.c
f21a7ff235912f18add9212ac43d9f9a408f3c32
[ "MIT" ]
permissive
floooh/sokol-samples
d48466f0da1b07c57b98733827074289faa335c9
578d71daed073dbeb2e5e3d74a3485cf46733cd7
refs/heads/master
2023-08-31T04:06:28.791638
2023-07-26T19:31:00
2023-07-26T19:31:00
97,253,410
496
100
MIT
2023-07-26T19:31:01
2017-07-14T16:29:50
C
UTF-8
C
false
false
7,648
c
inject-wgpu.c
//------------------------------------------------------------------------------ // inject-wgpu.c // // Demonstrates injection of native WebGPU buffers and textures into sokol-gfx. //------------------------------------------------------------------------------ #define HANDMADE_MATH_IMPLEMENTATION #define HANDMADE_MATH_NO_SSE #include "HandmadeMath.h" #define SOKOL_IMPL #define SOKOL_WGPU #include "sokol_gfx.h" #include "sokol_log.h" #include "wgpu_entry.h" #include "inject-wgpu.glsl.h" /* NOTE: webgpu.h is already included by sokol_gfx.h */ #define WIDTH (640) #define HEIGHT (480) #define SAMPLE_COUNT (4) #define IMG_WIDTH (32) #define IMG_HEIGHT (32) static struct { sg_pass_action pass_action; sg_pipeline pip; sg_bindings bind; float rx, ry; uint32_t counter; hmm_mat4 view_proj; uint32_t pixels[IMG_WIDTH*IMG_HEIGHT]; WGPUBuffer wgpu_vertex_buffer; WGPUBuffer wgpu_index_buffer; WGPUTexture wgpu_texture; } state = { .pass_action = { .colors[0] = { .action = SG_ACTION_CLEAR, .value = { 0.0f, 0.0f, 0.0f, 1.0f } } } }; static void init(void) { /* setup sokol_gfx */ sg_setup(&(sg_desc){ .context = wgpu_get_context(), .logger.func = slog_func, }); WGPUDevice wgpu_dev = (WGPUDevice) wgpu_get_context().wgpu.device; /* create native WebGPU vertex- and index-buffer */ float vertices[] = { /* pos uvs */ -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, -1.0f, 1.0f, 0.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 1.0f, 0.0f, 1.0f, -1.0f, -1.0f, -1.0f, 0.0f, 0.0f, -1.0f, -1.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, 0.0f, 1.0f, -1.0f, 1.0f, -1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, -1.0f, 0.0f, 1.0f }; uint16_t indices[] = { 0, 1, 2, 0, 2, 3, 6, 5, 4, 7, 6, 4, 8, 9, 10, 8, 10, 11, 14, 13, 12, 15, 14, 12, 16, 17, 18, 16, 18, 19, 22, 21, 20, 23, 22, 20 }; WGPUCreateBufferMappedResult buf_res = wgpuDeviceCreateBufferMapped(wgpu_dev, &(WGPUBufferDescriptor) { .size = sizeof(vertices), .usage = WGPUBufferUsage_Vertex }); state.wgpu_vertex_buffer = buf_res.buffer; memcpy(buf_res.data, vertices, sizeof(vertices)); wgpuBufferUnmap(state.wgpu_vertex_buffer); buf_res = wgpuDeviceCreateBufferMapped(wgpu_dev, &(WGPUBufferDescriptor) { .size = sizeof(indices), .usage = WGPUBufferUsage_Index }); state.wgpu_index_buffer = buf_res.buffer; memcpy(buf_res.data, indices, sizeof(indices)); wgpuBufferUnmap(state.wgpu_index_buffer); /* important to call sg_reset_state_cache() after calling WebGPU functions directly */ sg_reset_state_cache(); /* create sokol_gfx buffers with injected WebGPU buffer objects */ state.bind.vertex_buffers[0] = sg_make_buffer(&(sg_buffer_desc){ .type = SG_BUFFERTYPE_VERTEXBUFFER, .size = sizeof(vertices), .wgpu_buffer = state.wgpu_vertex_buffer }); state.bind.index_buffer = sg_make_buffer(&(sg_buffer_desc){ .type = SG_BUFFERTYPE_INDEXBUFFER, .size = sizeof(indices), .wgpu_buffer = state.wgpu_index_buffer }); /* create dynamically updated WebGPU texture object */ state.wgpu_texture = wgpuDeviceCreateTexture(wgpu_dev, &(WGPUTextureDescriptor) { .usage = WGPUTextureUsage_Sampled|WGPUTextureUsage_CopyDst, .dimension = WGPUTextureDimension_2D, .size = { .width = IMG_WIDTH, .height = IMG_HEIGHT, .depth = 1 }, .arrayLayerCount = 1, .format = WGPUTextureFormat_RGBA8Unorm, .mipLevelCount = 1, .sampleCount = 1, }); sg_reset_state_cache(); /* ... and the sokol-gfx texture object with the injected WGPU texture */ state.bind.fs_images[0] = sg_make_image(&(sg_image_desc){ .usage = SG_USAGE_STREAM, .width = IMG_WIDTH, .height = IMG_HEIGHT, .pixel_format = SG_PIXELFORMAT_RGBA8, .min_filter = SG_FILTER_LINEAR, .mag_filter = SG_FILTER_LINEAR, .wrap_u = SG_WRAP_REPEAT, .wrap_v = SG_WRAP_REPEAT, .wgpu_texture = state.wgpu_texture }); /* a pipeline state object and shader */ sg_pipeline_desc pip_desc = { .layout = { .attrs = { [0] = { .format=SG_VERTEXFORMAT_FLOAT3 }, [1] = { .format=SG_VERTEXFORMAT_FLOAT2 } }, }, .shader = sg_make_shader(inject_shader_desc(sg_query_backend())), .index_type = SG_INDEXTYPE_UINT16, .depth = { .compare = SG_COMPAREFUNC_LESS_EQUAL, .write_enabled = true }, .cull_mode = SG_CULLMODE_BACK, }; state.pip = sg_make_pipeline(&pip_desc); /* view-projection matrix */ hmm_mat4 proj = HMM_Perspective(60.0f, (float)WIDTH/(float)HEIGHT, 0.01f, 10.0f); hmm_mat4 view = HMM_LookAt(HMM_Vec3(0.0f, 1.5f, 6.0f), HMM_Vec3(0.0f, 0.0f, 0.0f), HMM_Vec3(0.0f, 1.0f, 0.0f)); state.view_proj = HMM_MultiplyMat4(proj, view); } void frame() { /* compute model-view-projection matrix for vertex shader */ vs_params_t vs_params; state.rx += 1.0f; state.ry += 2.0f; hmm_mat4 rxm = HMM_Rotate(state.rx, HMM_Vec3(1.0f, 0.0f, 0.0f)); hmm_mat4 rym = HMM_Rotate(state.ry, HMM_Vec3(0.0f, 1.0f, 0.0f)); hmm_mat4 model = HMM_MultiplyMat4(rxm, rym); vs_params.mvp = HMM_MultiplyMat4(state.view_proj, model); /* update texture image with some generated pixel data */ for (int y = 0; y < IMG_WIDTH; y++) { for (int x = 0; x < IMG_HEIGHT; x++) { state.pixels[y * IMG_WIDTH + x] = 0xFF000000 | (state.counter & 0xFF)<<16 | ((state.counter*3) & 0xFF)<<8 | ((state.counter*23) & 0xFF); state.counter++; } } state.counter++; sg_image_data content = { .subimage[0][0] = SG_RANGE(state.pixels) }; sg_update_image(state.bind.fs_images[0], &content); sg_begin_default_pass(&state.pass_action, wgpu_width(), wgpu_height()); sg_apply_pipeline(state.pip); sg_apply_bindings(&state.bind); sg_apply_uniforms(SG_SHADERSTAGE_VS, 0, &SG_RANGE(vs_params)); sg_draw(0, 36, 1); sg_end_pass(); sg_commit(); } void shutdown() { sg_shutdown(); wgpuBufferRelease(state.wgpu_vertex_buffer); wgpuBufferRelease(state.wgpu_index_buffer); wgpuTextureRelease(state.wgpu_texture); } int main() { wgpu_start(&(wgpu_desc_t){ .init_cb = init, .frame_cb = frame, .shutdown_cb = shutdown, .sample_count = SAMPLE_COUNT, .width = 640, .height = 480, .title = "inject-wgpu" }); return 0; }
14960ef8df0c18899e93384b2090ce6950183d64
aa3befea459382dc5c01c925653d54f435b3fb0f
/arch/arm/src/sam34/hardware/sam3u_pio.h
d014ca04aee01984c760186237218f6cd0af7154
[ "MIT-open-group", "BSD-3-Clause", "HPND-sell-variant", "BSD-4-Clause-UC", "LicenseRef-scancode-warranty-disclaimer", "MIT-0", "LicenseRef-scancode-bsd-atmel", "LicenseRef-scancode-gary-s-brown", "LicenseRef-scancode-proprietary-license", "SunPro", "MIT", "LicenseRef-scancode-public-domain-disclaimer", "LicenseRef-scancode-other-permissive", "HPND", "ISC", "Apache-2.0", "LicenseRef-scancode-public-domain", "BSD-2-Clause", "GPL-1.0-or-later", "CC-BY-2.0", "CC-BY-4.0" ]
permissive
apache/nuttx
14519a7bff4a87935d94fb8fb2b19edb501c7cec
606b6d9310fb25c7d92c6f95bf61737e3c79fa0f
refs/heads/master
2023-08-25T06:55:45.822534
2023-08-23T16:03:31
2023-08-24T21:25:47
228,103,273
407
241
Apache-2.0
2023-09-14T18:26:05
2019-12-14T23:27:55
C
UTF-8
C
false
false
29,352
h
sam3u_pio.h
/**************************************************************************** * arch/arm/src/sam34/hardware/sam3u_pio.h * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. The * ASF licenses this file to you 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. * ****************************************************************************/ #ifndef __ARCH_ARM_SRC_SAM34_HARDWARE_SAM3U_PIO_H #define __ARCH_ARM_SRC_SAM34_HARDWARE_SAM3U_PIO_H /**************************************************************************** * Included Files ****************************************************************************/ #include <nuttx/config.h> #include "chip.h" #include "hardware/sam_memorymap.h" /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ /* PIO register offsets *****************************************************/ #define SAM_PIO_PER_OFFSET 0x0000 /* PIO Enable Register */ #define SAM_PIO_PDR_OFFSET 0x0004 /* PIO Disable Register */ #define SAM_PIO_PSR_OFFSET 0x0008 /* PIO Status Register */ /* 0x000c: Reserved */ #define SAM_PIO_OER_OFFSET 0x0010 /* Output Enable Register */ #define SAM_PIO_ODR_OFFSET 0x0014 /* Output Disable Register */ #define SAM_PIO_OSR_OFFSET 0x0018 /* Output Status Register */ /* 0x001c: Reserved */ #define SAM_PIO_IFER_OFFSET 0x0020 /* Glitch Input Filter Enable Register */ #define SAM_PIO_IFDR_OFFSET 0x0024 /* Glitch Input Filter Disable Register */ #define SAM_PIO_IFSR_OFFSET 0x0028 /* Glitch Input Filter Status Register */ /* 0x002c: Reserved */ #define SAM_PIO_SODR_OFFSET 0x0030 /* Set Output Data Register */ #define SAM_PIO_CODR_OFFSET 0x0034 /* Clear Output Data Register */ #define SAM_PIO_ODSR_OFFSET 0x0038 /* Output Data Status Register */ #define SAM_PIO_PDSR_OFFSET 0x003c /* Pin Data Status Register */ #define SAM_PIO_IER_OFFSET 0x0040 /* Interrupt Enable Register */ #define SAM_PIO_IDR_OFFSET 0x0044 /* Interrupt Disable Register */ #define SAM_PIO_IMR_OFFSET 0x0048 /* Interrupt Mask Register */ #define SAM_PIO_ISR_OFFSET 0x004c /* Interrupt Status Register */ #define SAM_PIO_MDER_OFFSET 0x0050 /* Multi-driver Enable Register */ #define SAM_PIO_MDDR_OFFSET 0x0054 /* Multi-driver Disable Register */ #define SAM_PIO_MDSR_OFFSET 0x0058 /* Multi-driver Status Register */ /* 0x005c: Reserved */ #define SAM_PIO_PUDR_OFFSET 0x0060 /* Pull-up Disable Register */ #define SAM_PIO_PUER_OFFSET 0x0064 /* Pull-up Enable Register */ #define SAM_PIO_PUSR_OFFSET 0x0068 /* Pad Pull-up Status Register */ /* 0x006c: Reserved */ #define SAM_PIO_ABSR_OFFSET 0x0070 /* Peripheral AB Select Register */ /* 0x0074-0x007c: Reserved */ #define SAM_PIO_SCIFSR_OFFSET 0x0080 /* System Clock Glitch Input Filter Select Register */ #define SAM_PIO_DIFSR_OFFSET 0x0084 /* Debouncing Input Filter Select Register */ #define SAM_PIO_IFDGSR_OFFSET 0x0088 /* Glitch or Debouncing Input Filter Clock Selection Status Register */ #define SAM_PIO_SCDR_OFFSET 0x008c /* Slow Clock Divider Debouncing Register */ /* 0x0090-0x009c: Reserved */ #define SAM_PIO_OWER_OFFSET 0x00a0 /* Output Write Enable */ #define SAM_PIO_OWDR_OFFSET 0x00a4 /* Output Write Disable */ #define SAM_PIO_OWSR_OFFSET 0x00a8 /* Output Write Status Register */ /* 0x00ac: Reserved */ #define SAM_PIO_AIMER_OFFSET 0x00b0 /* Additional Interrupt Modes Enable Register */ #define SAM_PIO_AIMDR_OFFSET 0x00b4 /* Additional Interrupt Modes Disables Register */ #define SAM_PIO_AIMMR_OFFSET 0x00b8 /* Additional Interrupt Modes Mask Register */ /* 0x00bc: Reserved */ #define SAM_PIO_ESR_OFFSET 0x00c0 /* Edge Select Register */ #define SAM_PIO_LSR_OFFSET 0x00c4 /* Level Select Register */ #define SAM_PIO_ELSR_OFFSET 0x00c8 /* Edge/Level Status Register */ /* 0x00cc: Reserved */ #define SAM_PIO_FELLSR_OFFSET 0x00d0 /* Falling Edge/Low Level Select Register */ #define SAM_PIO_REHLSR_OFFSET 0x00d4 /* Rising Edge/ High Level Select Register */ #define SAM_PIO_FRLHSR_OFFSET 0x00d8 /* Fall/Rise - Low/High Status Register */ /* 0x00dc: Reserved */ #define SAM_PIO_LOCKSR_OFFSET 0x00e0 /* Lock Status */ #define SAM_PIO_WPMR_OFFSET 0x00e4 /* Write Protect Mode Register */ #define SAM_PIO_WPSR_OFFSET 0x00e8 /* Write Protect Status Register */ /* 0x00ec-0x00f8: Reserved */ /* 0x0100-0x0144: Reserved */ /* PIO register addresses ***************************************************/ #define PIOA (0) #define PIOB (1) #define PIOC (2) #if defined(CONFIG_ARCH_CHIP_SAM3X) || defined(CONFIG_ARCH_CHIP_SAM3A) # define PIOD (3) # define PIOE (4) # define PIOF (5) # define NPIO (6) #else # define NPIO (3) #endif #define SAM_PIO_PER(n) (SAM_PIO_BASE(n)+SAM_PIO_PER_OFFSET) #define SAM_PIO_PDR(n) (SAM_PIO_BASE(n)+SAM_PIO_PDR_OFFSET) #define SAM_PIO_PSR(n) (SAM_PIO_BASE(n)+SAM_PIO_PSR_OFFSET) #define SAM_PIO_OER(n) (SAM_PIO_BASE(n)+SAM_PIO_OER_OFFSET) #define SAM_PIO_ODR(n) (SAM_PIO_BASE(n)+SAM_PIO_ODR_OFFSET) #define SAM_PIO_OSR(n) (SAM_PIO_BASE(n)+SAM_PIO_OSR_OFFSET) #define SAM_PIO_IFER(n) (SAM_PIO_BASE(n)+SAM_PIO_IFER_OFFSET) #define SAM_PIO_IFDR(n) (SAM_PIO_BASE(n)+SAM_PIO_IFDR_OFFSET) #define SAM_PIO_IFSR(n) (SAM_PIO_BASE(n)+SAM_PIO_IFSR_OFFSET) #define SAM_PIO_SODR(n) (SAM_PIO_BASE(n)+SAM_PIO_SODR_OFFSET) #define SAM_PIO_CODR(n) (SAM_PIO_BASE(n)+SAM_PIO_CODR_OFFSET) #define SAM_PIO_ODSR(n) (SAM_PIO_BASE(n)+SAM_PIO_ODSR_OFFSET) #define SAM_PIO_PDSR(n) (SAM_PIO_BASE(n)+SAM_PIO_PDSR_OFFSET) #define SAM_PIO_IER(n) (SAM_PIO_BASE(n)+SAM_PIO_IER_OFFSET) #define SAM_PIO_IDR(n) (SAM_PIO_BASE(n)+SAM_PIO_IDR_OFFSET) #define SAM_PIO_IMR(n) (SAM_PIO_BASE(n)+SAM_PIO_IMR_OFFSET) #define SAM_PIO_ISR(n) (SAM_PIO_BASE(n)+SAM_PIO_ISR_OFFSET) #define SAM_PIO_MDER(n) (SAM_PIO_BASE(n)+SAM_PIO_MDER_OFFSET) #define SAM_PIO_MDDR(n) (SAM_PIO_BASE(n)+SAM_PIO_MDDR_OFFSET) #define SAM_PIO_MDSR(n) (SAM_PIO_BASE(n)+SAM_PIO_MDSR_OFFSET) #define SAM_PIO_PUDR(n) (SAM_PIO_BASE(n)+SAM_PIO_PUDR_OFFSET) #define SAM_PIO_PUER(n) (SAM_PIO_BASE(n)+SAM_PIO_PUER_OFFSET) #define SAM_PIO_PUSR(n) (SAM_PIO_BASE(n)+SAM_PIO_PUSR_OFFSET) #define SAM_PIO_ABSR(n) (SAM_PIO_BASE(n)+SAM_PIO_ABSR_OFFSET) #define SAM_PIO_SCIFSR(n) (SAM_PIO_BASE(n)+SAM_PIO_SCIFSR_OFFSET) #define SAM_PIO_DIFSR(n) (SAM_PIO_BASE(n)+SAM_PIO_DIFSR_OFFSET) #define SAM_PIO_IFDGSR(n) (SAM_PIO_BASE(n)+SAM_PIO_IFDGSR_OFFSET) #define SAM_PIO_SCDR(n) (SAM_PIO_BASE(n)+SAM_PIO_SCDR_OFFSET) #define SAM_PIO_OWER(n) (SAM_PIO_BASE(n)+SAM_PIO_OWER_OFFSET) #define SAM_PIO_OWDR(n) (SAM_PIO_BASE(n)+SAM_PIO_OWDR_OFFSET) #define SAM_PIO_OWSR(n) (SAM_PIO_BASE(n)+SAM_PIO_OWSR_OFFSET) #define SAM_PIO_AIMER(n) (SAM_PIO_BASE(n)+SAM_PIO_AIMER_OFFSET) #define SAM_PIO_AIMDR(n) (SAM_PIO_BASE(n)+SAM_PIO_AIMDR_OFFSET) #define SAM_PIO_AIMMR(n) (SAM_PIO_BASE(n)+SAM_PIO_AIMMR_OFFSET) #define SAM_PIO_ESR(n) (SAM_PIO_BASE(n)+SAM_PIO_ESR_OFFSET) #define SAM_PIO_LSR(n) (SAM_PIO_BASE(n)+SAM_PIO_LSR_OFFSET) #define SAM_PIO_ELSR(n) (SAM_PIO_BASE(n)+SAM_PIO_ELSR_OFFSET) #define SAM_PIO_FELLSR(n) (SAM_PIO_BASE(n)+SAM_PIO_FELLSR_OFFSET) #define SAM_PIO_REHLSR(n) (SAM_PIO_BASE(n)+SAM_PIO_REHLSR_OFFSET) #define SAM_PIO_FRLHSR(n) (SAM_PIO_BASE(n)+SAM_PIO_FRLHSR_OFFSET) #define SAM_PIO_LOCKSR(n) (SAM_PIO_BASE(n)+SAM_PIO_LOCKSR_OFFSET) #define SAM_PIO_WPMR(n) (SAM_PIO_BASE(n)+SAM_PIO_WPMR_OFFSET) #define SAM_PIO_WPSR(n) (SAM_PIO_BASE(n)+SAM_PIO_WPSR_OFFSET) #define SAM_PIOA_PER (SAM_PIOA_BASE+SAM_PIO_PER_OFFSET) #define SAM_PIOA_PDR (SAM_PIOA_BASE+SAM_PIO_PDR_OFFSET) #define SAM_PIOA_PSR (SAM_PIOA_BASE+SAM_PIO_PSR_OFFSET) #define SAM_PIOA_OER (SAM_PIOA_BASE+SAM_PIO_OER_OFFSET) #define SAM_PIOA_ODR (SAM_PIOA_BASE+SAM_PIO_ODR_OFFSET) #define SAM_PIOA_OSR (SAM_PIOA_BASE+SAM_PIO_OSR_OFFSET) #define SAM_PIOA_IFER (SAM_PIOA_BASE+SAM_PIO_IFER_OFFSET) #define SAM_PIOA_IFDR (SAM_PIOA_BASE+SAM_PIO_IFDR_OFFSET) #define SAM_PIOA_IFSR (SAM_PIOA_BASE+SAM_PIO_IFSR_OFFSET) #define SAM_PIOA_SODR (SAM_PIOA_BASE+SAM_PIO_SODR_OFFSET) #define SAM_PIOA_CODR (SAM_PIOA_BASE+SAM_PIO_CODR_OFFSET) #define SAM_PIOA_ODSR (SAM_PIOA_BASE+SAM_PIO_ODSR_OFFSET) #define SAM_PIOA_PDSR (SAM_PIOA_BASE+SAM_PIO_PDSR_OFFSET) #define SAM_PIOA_IER (SAM_PIOA_BASE+SAM_PIO_IER_OFFSET) #define SAM_PIOA_IDR (SAM_PIOA_BASE+SAM_PIO_IDR_OFFSET) #define SAM_PIOA_IMR (SAM_PIOA_BASE+SAM_PIO_IMR_OFFSET) #define SAM_PIOA_ISR (SAM_PIOA_BASE+SAM_PIO_ISR_OFFSET) #define SAM_PIOA_MDER (SAM_PIOA_BASE+SAM_PIO_MDER_OFFSET) #define SAM_PIOA_MDDR (SAM_PIOA_BASE+SAM_PIO_MDDR_OFFSET) #define SAM_PIOA_MDSR (SAM_PIOA_BASE+SAM_PIO_MDSR_OFFSET) #define SAM_PIOA_PUDR (SAM_PIOA_BASE+SAM_PIO_PUDR_OFFSET) #define SAM_PIOA_PUER (SAM_PIOA_BASE+SAM_PIO_PUER_OFFSET) #define SAM_PIOA_PUSR (SAM_PIOA_BASE+SAM_PIO_PUSR_OFFSET) #define SAM_PIOA_ABSR (SAM_PIOA_BASE+SAM_PIO_ABSR_OFFSET) #define SAM_PIOA_SCIFSR (SAM_PIOA_BASE+SAM_PIO_SCIFSR_OFFSET) #define SAM_PIOA_DIFSR (SAM_PIOA_BASE+SAM_PIO_DIFSR_OFFSET) #define SAM_PIOA_IFDGSR (SAM_PIOA_BASE+SAM_PIO_IFDGSR_OFFSET) #define SAM_PIOA_SCDR (SAM_PIOA_BASE+SAM_PIO_SCDR_OFFSET) #define SAM_PIOA_OWER (SAM_PIOA_BASE+SAM_PIO_OWER_OFFSET) #define SAM_PIOA_OWDR (SAM_PIOA_BASE+SAM_PIO_OWDR_OFFSET) #define SAM_PIOA_OWSR (SAM_PIOA_BASE+SAM_PIO_OWSR_OFFSET) #define SAM_PIOA_AIMER (SAM_PIOA_BASE+SAM_PIO_AIMER_OFFSET) #define SAM_PIOA_AIMDR (SAM_PIOA_BASE+SAM_PIO_AIMDR_OFFSET) #define SAM_PIOA_AIMMR (SAM_PIOA_BASE+SAM_PIO_AIMMR_OFFSET) #define SAM_PIOA_ESR (SAM_PIOA_BASE+SAM_PIO_ESR_OFFSET) #define SAM_PIOA_LSR (SAM_PIOA_BASE+SAM_PIO_LSR_OFFSET) #define SAM_PIOA_ELSR (SAM_PIOA_BASE+SAM_PIO_ELSR_OFFSET) #define SAM_PIOA_FELLSR (SAM_PIOA_BASE+SAM_PIO_FELLSR_OFFSET) #define SAM_PIOA_REHLSR (SAM_PIOA_BASE+SAM_PIO_REHLSR_OFFSET) #define SAM_PIOA_FRLHSR (SAM_PIOA_BASE+SAM_PIO_FRLHSR_OFFSET) #define SAM_PIOA_LOCKSR (SAM_PIOA_BASE+SAM_PIO_LOCKSR_OFFSET) #define SAM_PIOA_WPMR (SAM_PIOA_BASE+SAM_PIO_WPMR_OFFSET) #define SAM_PIOA_WPSR (SAM_PIOA_BASE+SAM_PIO_WPSR_OFFSET) #define SAM_PIOB_PER (SAM_PIOB_BASE+SAM_PIO_PER_OFFSET) #define SAM_PIOB_PDR (SAM_PIOB_BASE+SAM_PIO_PDR_OFFSET) #define SAM_PIOB_PSR (SAM_PIOB_BASE+SAM_PIO_PSR_OFFSET) #define SAM_PIOB_OER (SAM_PIOB_BASE+SAM_PIO_OER_OFFSET) #define SAM_PIOB_ODR (SAM_PIOB_BASE+SAM_PIO_ODR_OFFSET) #define SAM_PIOB_OSR (SAM_PIOB_BASE+SAM_PIO_OSR_OFFSET) #define SAM_PIOB_IFER (SAM_PIOB_BASE+SAM_PIO_IFER_OFFSET) #define SAM_PIOB_IFDR (SAM_PIOB_BASE+SAM_PIO_IFDR_OFFSET) #define SAM_PIOB_IFSR (SAM_PIOB_BASE+SAM_PIO_IFSR_OFFSET) #define SAM_PIOB_SODR (SAM_PIOB_BASE+SAM_PIO_SODR_OFFSET) #define SAM_PIOB_CODR (SAM_PIOB_BASE+SAM_PIO_CODR_OFFSET) #define SAM_PIOB_ODSR (SAM_PIOB_BASE+SAM_PIO_ODSR_OFFSET) #define SAM_PIOB_PDSR (SAM_PIOB_BASE+SAM_PIO_PDSR_OFFSET) #define SAM_PIOB_IER (SAM_PIOB_BASE+SAM_PIO_IER_OFFSET) #define SAM_PIOB_IDR (SAM_PIOB_BASE+SAM_PIO_IDR_OFFSET) #define SAM_PIOB_IMR (SAM_PIOB_BASE+SAM_PIO_IMR_OFFSET) #define SAM_PIOB_ISR (SAM_PIOB_BASE+SAM_PIO_ISR_OFFSET) #define SAM_PIOB_MDER (SAM_PIOB_BASE+SAM_PIO_MDER_OFFSET) #define SAM_PIOB_MDDR (SAM_PIOB_BASE+SAM_PIO_MDDR_OFFSET) #define SAM_PIOB_MDSR (SAM_PIOB_BASE+SAM_PIO_MDSR_OFFSET) #define SAM_PIOB_PUDR (SAM_PIOB_BASE+SAM_PIO_PUDR_OFFSET) #define SAM_PIOB_PUER (SAM_PIOB_BASE+SAM_PIO_PUER_OFFSET) #define SAM_PIOB_PUSR (SAM_PIOB_BASE+SAM_PIO_PUSR_OFFSET) #define SAM_PIOB_ABSR (SAM_PIOB_BASE+SAM_PIO_ABSR_OFFSET) #define SAM_PIOB_SCIFSR (SAM_PIOB_BASE+SAM_PIO_SCIFSR_OFFSET) #define SAM_PIOB_DIFSR (SAM_PIOB_BASE+SAM_PIO_DIFSR_OFFSET) #define SAM_PIOB_IFDGSR (SAM_PIOB_BASE+SAM_PIO_IFDGSR_OFFSET) #define SAM_PIOB_SCDR (SAM_PIOB_BASE+SAM_PIO_SCDR_OFFSET) #define SAM_PIOB_OWER (SAM_PIOB_BASE+SAM_PIO_OWER_OFFSET) #define SAM_PIOB_OWDR (SAM_PIOB_BASE+SAM_PIO_OWDR_OFFSET) #define SAM_PIOB_OWSR (SAM_PIOB_BASE+SAM_PIO_OWSR_OFFSET) #define SAM_PIOB_AIMER (SAM_PIOB_BASE+SAM_PIO_AIMER_OFFSET) #define SAM_PIOB_AIMDR (SAM_PIOB_BASE+SAM_PIO_AIMDR_OFFSET) #define SAM_PIOB_AIMMR (SAM_PIOB_BASE+SAM_PIO_AIMMR_OFFSET) #define SAM_PIOB_ESR (SAM_PIOB_BASE+SAM_PIO_ESR_OFFSET) #define SAM_PIOB_LSR (SAM_PIOB_BASE+SAM_PIO_LSR_OFFSET) #define SAM_PIOB_ELSR (SAM_PIOB_BASE+SAM_PIO_ELSR_OFFSET) #define SAM_PIOB_FELLSR (SAM_PIOB_BASE+SAM_PIO_FELLSR_OFFSET) #define SAM_PIOB_REHLSR (SAM_PIOB_BASE+SAM_PIO_REHLSR_OFFSET) #define SAM_PIOB_FRLHSR (SAM_PIOB_BASE+SAM_PIO_FRLHSR_OFFSET) #define SAM_PIOB_LOCKSR (SAM_PIOB_BASE+SAM_PIO_LOCKSR_OFFSET) #define SAM_PIOB_WPMR (SAM_PIOB_BASE+SAM_PIO_WPMR_OFFSET) #define SAM_PIOB_WPSR (SAM_PIOB_BASE+SAM_PIO_WPSR_OFFSET) #define SAM_PIOC_PER (SAM_PIOC_BASE+SAM_PIO_PER_OFFSET) #define SAM_PIOC_PDR (SAM_PIOC_BASE+SAM_PIO_PDR_OFFSET) #define SAM_PIOC_PSR (SAM_PIOC_BASE+SAM_PIO_PSR_OFFSET) #define SAM_PIOC_OER (SAM_PIOC_BASE+SAM_PIO_OER_OFFSET) #define SAM_PIOC_ODR (SAM_PIOC_BASE+SAM_PIO_ODR_OFFSET) #define SAM_PIOC_OSR (SAM_PIOC_BASE+SAM_PIO_OSR_OFFSET) #define SAM_PIOC_IFER (SAM_PIOC_BASE+SAM_PIO_IFER_OFFSET) #define SAM_PIOC_IFDR (SAM_PIOC_BASE+SAM_PIO_IFDR_OFFSET) #define SAM_PIOC_IFSR (SAM_PIOC_BASE+SAM_PIO_IFSR_OFFSET) #define SAM_PIOC_SODR (SAM_PIOC_BASE+SAM_PIO_SODR_OFFSET) #define SAM_PIOC_CODR (SAM_PIOC_BASE+SAM_PIO_CODR_OFFSET) #define SAM_PIOC_ODSR (SAM_PIOC_BASE+SAM_PIO_ODSR_OFFSET) #define SAM_PIOC_PDSR (SAM_PIOC_BASE+SAM_PIO_PDSR_OFFSET) #define SAM_PIOC_IER (SAM_PIOC_BASE+SAM_PIO_IER_OFFSET) #define SAM_PIOC_IDR (SAM_PIOC_BASE+SAM_PIO_IDR_OFFSET) #define SAM_PIOC_IMR (SAM_PIOC_BASE+SAM_PIO_IMR_OFFSET) #define SAM_PIOC_ISR (SAM_PIOC_BASE+SAM_PIO_ISR_OFFSET) #define SAM_PIOC_MDER (SAM_PIOC_BASE+SAM_PIO_MDER_OFFSET) #define SAM_PIOC_MDDR (SAM_PIOC_BASE+SAM_PIO_MDDR_OFFSET) #define SAM_PIOC_MDSR (SAM_PIOC_BASE+SAM_PIO_MDSR_OFFSET) #define SAM_PIOC_PUDR (SAM_PIOC_BASE+SAM_PIO_PUDR_OFFSET) #define SAM_PIOC_PUER (SAM_PIOC_BASE+SAM_PIO_PUER_OFFSET) #define SAM_PIOC_PUSR (SAM_PIOC_BASE+SAM_PIO_PUSR_OFFSET) #define SAM_PIOC_ABSR (SAM_PIOC_BASE+SAM_PIO_ABSR_OFFSET) #define SAM_PIOC_SCIFSR (SAM_PIOC_BASE+SAM_PIO_SCIFSR_OFFSET) #define SAM_PIOC_DIFSR (SAM_PIOC_BASE+SAM_PIO_DIFSR_OFFSET) #define SAM_PIOC_IFDGSR (SAM_PIOC_BASE+SAM_PIO_IFDGSR_OFFSET) #define SAM_PIOC_SCDR (SAM_PIOC_BASE+SAM_PIO_SCDR_OFFSET) #define SAM_PIOC_OWER (SAM_PIOC_BASE+SAM_PIO_OWER_OFFSET) #define SAM_PIOC_OWDR (SAM_PIOC_BASE+SAM_PIO_OWDR_OFFSET) #define SAM_PIOC_OWSR (SAM_PIOC_BASE+SAM_PIO_OWSR_OFFSET) #define SAM_PIOC_AIMER (SAM_PIOC_BASE+SAM_PIO_AIMER_OFFSET) #define SAM_PIOC_AIMDR (SAM_PIOC_BASE+SAM_PIO_AIMDR_OFFSET) #define SAM_PIOC_AIMMR (SAM_PIOC_BASE+SAM_PIO_AIMMR_OFFSET) #define SAM_PIOC_ESR (SAM_PIOC_BASE+SAM_PIO_ESR_OFFSET) #define SAM_PIOC_LSR (SAM_PIOC_BASE+SAM_PIO_LSR_OFFSET) #define SAM_PIOC_ELSR (SAM_PIOC_BASE+SAM_PIO_ELSR_OFFSET) #define SAM_PIOC_FELLSR (SAM_PIOC_BASE+SAM_PIO_FELLSR_OFFSET) #define SAM_PIOC_REHLSR (SAM_PIOC_BASE+SAM_PIO_REHLSR_OFFSET) #define SAM_PIOC_FRLHSR (SAM_PIOC_BASE+SAM_PIO_FRLHSR_OFFSET) #define SAM_PIOC_LOCKSR (SAM_PIOC_BASE+SAM_PIO_LOCKSR_OFFSET) #define SAM_PIOC_WPMR (SAM_PIOC_BASE+SAM_PIO_WPMR_OFFSET) #define SAM_PIOC_WPSR (SAM_PIOC_BASE+SAM_PIO_WPSR_OFFSET) #if defined(CONFIG_ARCH_CHIP_SAM3X) || defined(CONFIG_ARCH_CHIP_SAM3A) # define SAM_PIOD_PER (SAM_PIOD_BASE+SAM_PIO_PER_OFFSET) # define SAM_PIOD_PDR (SAM_PIOD_BASE+SAM_PIO_PDR_OFFSET) # define SAM_PIOD_PSR (SAM_PIOD_BASE+SAM_PIO_PSR_OFFSET) # define SAM_PIOD_OER (SAM_PIOD_BASE+SAM_PIO_OER_OFFSET) # define SAM_PIOD_ODR (SAM_PIOD_BASE+SAM_PIO_ODR_OFFSET) # define SAM_PIOD_OSR (SAM_PIOD_BASE+SAM_PIO_OSR_OFFSET) # define SAM_PIOD_IFER (SAM_PIOD_BASE+SAM_PIO_IFER_OFFSET) # define SAM_PIOD_IFDR (SAM_PIOD_BASE+SAM_PIO_IFDR_OFFSET) # define SAM_PIOD_IFSR (SAM_PIOD_BASE+SAM_PIO_IFSR_OFFSET) # define SAM_PIOD_SODR (SAM_PIOD_BASE+SAM_PIO_SODR_OFFSET) # define SAM_PIOD_CODR (SAM_PIOD_BASE+SAM_PIO_CODR_OFFSET) # define SAM_PIOD_ODSR (SAM_PIOD_BASE+SAM_PIO_ODSR_OFFSET) # define SAM_PIOD_PDSR (SAM_PIOD_BASE+SAM_PIO_PDSR_OFFSET) # define SAM_PIOD_IER (SAM_PIOD_BASE+SAM_PIO_IER_OFFSET) # define SAM_PIOD_IDR (SAM_PIOD_BASE+SAM_PIO_IDR_OFFSET) # define SAM_PIOD_IMR (SAM_PIOD_BASE+SAM_PIO_IMR_OFFSET) # define SAM_PIOD_ISR (SAM_PIOD_BASE+SAM_PIO_ISR_OFFSET) # define SAM_PIOD_MDER (SAM_PIOD_BASE+SAM_PIO_MDER_OFFSET) # define SAM_PIOD_MDDR (SAM_PIOD_BASE+SAM_PIO_MDDR_OFFSET) # define SAM_PIOD_MDSR (SAM_PIOD_BASE+SAM_PIO_MDSR_OFFSET) # define SAM_PIOD_PUDR (SAM_PIOD_BASE+SAM_PIO_PUDR_OFFSET) # define SAM_PIOD_PUER (SAM_PIOD_BASE+SAM_PIO_PUER_OFFSET) # define SAM_PIOD_PUSR (SAM_PIOD_BASE+SAM_PIO_PUSR_OFFSET) # define SAM_PIOD_ABSR (SAM_PIOD_BASE+SAM_PIO_ABSR_OFFSET) # define SAM_PIOD_SCIFSR (SAM_PIOD_BASE+SAM_PIO_SCIFSR_OFFSET) # define SAM_PIOD_DIFSR (SAM_PIOD_BASE+SAM_PIO_DIFSR_OFFSET) # define SAM_PIOD_IFDGSR (SAM_PIOD_BASE+SAM_PIO_IFDGSR_OFFSET) # define SAM_PIOD_SCDR (SAM_PIOD_BASE+SAM_PIO_SCDR_OFFSET) # define SAM_PIOD_OWER (SAM_PIOD_BASE+SAM_PIO_OWER_OFFSET) # define SAM_PIOD_OWDR (SAM_PIOD_BASE+SAM_PIO_OWDR_OFFSET) # define SAM_PIOD_OWSR (SAM_PIOD_BASE+SAM_PIO_OWSR_OFFSET) # define SAM_PIOD_AIMER (SAM_PIOD_BASE+SAM_PIO_AIMER_OFFSET) # define SAM_PIOD_AIMDR (SAM_PIOD_BASE+SAM_PIO_AIMDR_OFFSET) # define SAM_PIOD_AIMMR (SAM_PIOD_BASE+SAM_PIO_AIMMR_OFFSET) # define SAM_PIOD_ESR (SAM_PIOD_BASE+SAM_PIO_ESR_OFFSET) # define SAM_PIOD_LSR (SAM_PIOD_BASE+SAM_PIO_LSR_OFFSET) # define SAM_PIOD_ELSR (SAM_PIOD_BASE+SAM_PIO_ELSR_OFFSET) # define SAM_PIOD_FELLSR (SAM_PIOD_BASE+SAM_PIO_FELLSR_OFFSET) # define SAM_PIOD_REHLSR (SAM_PIOD_BASE+SAM_PIO_REHLSR_OFFSET) # define SAM_PIOD_FRLHSR (SAM_PIOD_BASE+SAM_PIO_FRLHSR_OFFSET) # define SAM_PIOD_LOCKSR (SAM_PIOD_BASE+SAM_PIO_LOCKSR_OFFSET) # define SAM_PIOD_WPMR (SAM_PIOD_BASE+SAM_PIO_WPMR_OFFSET) # define SAM_PIOD_WPSR (SAM_PIOD_BASE+SAM_PIO_WPSR_OFFSET) # define SAM_PIOE_PER (SAM_PIOE_BASE+SAM_PIO_PER_OFFSET) # define SAM_PIOE_PDR (SAM_PIOE_BASE+SAM_PIO_PDR_OFFSET) # define SAM_PIOE_PSR (SAM_PIOE_BASE+SAM_PIO_PSR_OFFSET) # define SAM_PIOE_OER (SAM_PIOE_BASE+SAM_PIO_OER_OFFSET) # define SAM_PIOE_ODR (SAM_PIOE_BASE+SAM_PIO_ODR_OFFSET) # define SAM_PIOE_OSR (SAM_PIOE_BASE+SAM_PIO_OSR_OFFSET) # define SAM_PIOE_IFER (SAM_PIOE_BASE+SAM_PIO_IFER_OFFSET) # define SAM_PIOE_IFDR (SAM_PIOE_BASE+SAM_PIO_IFDR_OFFSET) # define SAM_PIOE_IFSR (SAM_PIOE_BASE+SAM_PIO_IFSR_OFFSET) # define SAM_PIOE_SODR (SAM_PIOE_BASE+SAM_PIO_SODR_OFFSET) # define SAM_PIOE_CODR (SAM_PIOE_BASE+SAM_PIO_CODR_OFFSET) # define SAM_PIOE_ODSR (SAM_PIOE_BASE+SAM_PIO_ODSR_OFFSET) # define SAM_PIOE_PDSR (SAM_PIOE_BASE+SAM_PIO_PDSR_OFFSET) # define SAM_PIOE_IER (SAM_PIOE_BASE+SAM_PIO_IER_OFFSET) # define SAM_PIOE_IDR (SAM_PIOE_BASE+SAM_PIO_IDR_OFFSET) # define SAM_PIOE_IMR (SAM_PIOE_BASE+SAM_PIO_IMR_OFFSET) # define SAM_PIOE_ISR (SAM_PIOE_BASE+SAM_PIO_ISR_OFFSET) # define SAM_PIOE_MDER (SAM_PIOE_BASE+SAM_PIO_MDER_OFFSET) # define SAM_PIOE_MDDR (SAM_PIOE_BASE+SAM_PIO_MDDR_OFFSET) # define SAM_PIOE_MDSR (SAM_PIOE_BASE+SAM_PIO_MDSR_OFFSET) # define SAM_PIOE_PUDR (SAM_PIOE_BASE+SAM_PIO_PUDR_OFFSET) # define SAM_PIOE_PUER (SAM_PIOE_BASE+SAM_PIO_PUER_OFFSET) # define SAM_PIOE_PUSR (SAM_PIOE_BASE+SAM_PIO_PUSR_OFFSET) # define SAM_PIOE_ABSR (SAM_PIOE_BASE+SAM_PIO_ABSR_OFFSET) # define SAM_PIOE_SCIFSR (SAM_PIOE_BASE+SAM_PIO_SCIFSR_OFFSET) # define SAM_PIOE_DIFSR (SAM_PIOE_BASE+SAM_PIO_DIFSR_OFFSET) # define SAM_PIOE_IFDGSR (SAM_PIOE_BASE+SAM_PIO_IFDGSR_OFFSET) # define SAM_PIOE_SCDR (SAM_PIOE_BASE+SAM_PIO_SCDR_OFFSET) # define SAM_PIOE_OWER (SAM_PIOE_BASE+SAM_PIO_OWER_OFFSET) # define SAM_PIOE_OWDR (SAM_PIOE_BASE+SAM_PIO_OWDR_OFFSET) # define SAM_PIOE_OWSR (SAM_PIOE_BASE+SAM_PIO_OWSR_OFFSET) # define SAM_PIOE_AIMER (SAM_PIOE_BASE+SAM_PIO_AIMER_OFFSET) # define SAM_PIOE_AIMDR (SAM_PIOE_BASE+SAM_PIO_AIMDR_OFFSET) # define SAM_PIOE_AIMMR (SAM_PIOE_BASE+SAM_PIO_AIMMR_OFFSET) # define SAM_PIOE_ESR (SAM_PIOE_BASE+SAM_PIO_ESR_OFFSET) # define SAM_PIOE_LSR (SAM_PIOE_BASE+SAM_PIO_LSR_OFFSET) # define SAM_PIOE_ELSR (SAM_PIOE_BASE+SAM_PIO_ELSR_OFFSET) # define SAM_PIOE_FELLSR (SAM_PIOE_BASE+SAM_PIO_FELLSR_OFFSET) # define SAM_PIOE_REHLSR (SAM_PIOE_BASE+SAM_PIO_REHLSR_OFFSET) # define SAM_PIOE_FRLHSR (SAM_PIOE_BASE+SAM_PIO_FRLHSR_OFFSET) # define SAM_PIOE_LOCKSR (SAM_PIOE_BASE+SAM_PIO_LOCKSR_OFFSET) # define SAM_PIOE_WPMR (SAM_PIOE_BASE+SAM_PIO_WPMR_OFFSET) # define SAM_PIOE_WPSR (SAM_PIOE_BASE+SAM_PIO_WPSR_OFFSET) # define SAM_PIOF_PER (SAM_PIOF_BASE+SAM_PIO_PER_OFFSET) # define SAM_PIOF_PDR (SAM_PIOF_BASE+SAM_PIO_PDR_OFFSET) # define SAM_PIOF_PSR (SAM_PIOF_BASE+SAM_PIO_PSR_OFFSET) # define SAM_PIOF_OER (SAM_PIOF_BASE+SAM_PIO_OER_OFFSET) # define SAM_PIOF_ODR (SAM_PIOF_BASE+SAM_PIO_ODR_OFFSET) # define SAM_PIOF_OSR (SAM_PIOF_BASE+SAM_PIO_OSR_OFFSET) # define SAM_PIOF_IFER (SAM_PIOF_BASE+SAM_PIO_IFER_OFFSET) # define SAM_PIOF_IFDR (SAM_PIOF_BASE+SAM_PIO_IFDR_OFFSET) # define SAM_PIOF_IFSR (SAM_PIOF_BASE+SAM_PIO_IFSR_OFFSET) # define SAM_PIOF_SODR (SAM_PIOF_BASE+SAM_PIO_SODR_OFFSET) # define SAM_PIOF_CODR (SAM_PIOF_BASE+SAM_PIO_CODR_OFFSET) # define SAM_PIOF_ODSR (SAM_PIOF_BASE+SAM_PIO_ODSR_OFFSET) # define SAM_PIOF_PDSR (SAM_PIOF_BASE+SAM_PIO_PDSR_OFFSET) # define SAM_PIOF_IER (SAM_PIOF_BASE+SAM_PIO_IER_OFFSET) # define SAM_PIOF_IDR (SAM_PIOF_BASE+SAM_PIO_IDR_OFFSET) # define SAM_PIOF_IMR (SAM_PIOF_BASE+SAM_PIO_IMR_OFFSET) # define SAM_PIOF_ISR (SAM_PIOF_BASE+SAM_PIO_ISR_OFFSET) # define SAM_PIOF_MDER (SAM_PIOF_BASE+SAM_PIO_MDER_OFFSET) # define SAM_PIOF_MDDR (SAM_PIOF_BASE+SAM_PIO_MDDR_OFFSET) # define SAM_PIOF_MDSR (SAM_PIOF_BASE+SAM_PIO_MDSR_OFFSET) # define SAM_PIOF_PUDR (SAM_PIOF_BASE+SAM_PIO_PUDR_OFFSET) # define SAM_PIOF_PUER (SAM_PIOF_BASE+SAM_PIO_PUER_OFFSET) # define SAM_PIOF_PUSR (SAM_PIOF_BASE+SAM_PIO_PUSR_OFFSET) # define SAM_PIOF_ABSR (SAM_PIOF_BASE+SAM_PIO_ABSR_OFFSET) # define SAM_PIOF_SCIFSR (SAM_PIOF_BASE+SAM_PIO_SCIFSR_OFFSET) # define SAM_PIOF_DIFSR (SAM_PIOF_BASE+SAM_PIO_DIFSR_OFFSET) # define SAM_PIOF_IFDGSR (SAM_PIOF_BASE+SAM_PIO_IFDGSR_OFFSET) # define SAM_PIOF_SCDR (SAM_PIOF_BASE+SAM_PIO_SCDR_OFFSET) # define SAM_PIOF_OWER (SAM_PIOF_BASE+SAM_PIO_OWER_OFFSET) # define SAM_PIOF_OWDR (SAM_PIOF_BASE+SAM_PIO_OWDR_OFFSET) # define SAM_PIOF_OWSR (SAM_PIOF_BASE+SAM_PIO_OWSR_OFFSET) # define SAM_PIOF_AIMER (SAM_PIOF_BASE+SAM_PIO_AIMER_OFFSET) # define SAM_PIOF_AIMDR (SAM_PIOF_BASE+SAM_PIO_AIMDR_OFFSET) # define SAM_PIOF_AIMMR (SAM_PIOF_BASE+SAM_PIO_AIMMR_OFFSET) # define SAM_PIOF_ESR (SAM_PIOF_BASE+SAM_PIO_ESR_OFFSET) # define SAM_PIOF_LSR (SAM_PIOF_BASE+SAM_PIO_LSR_OFFSET) # define SAM_PIOF_ELSR (SAM_PIOF_BASE+SAM_PIO_ELSR_OFFSET) # define SAM_PIOF_FELLSR (SAM_PIOF_BASE+SAM_PIO_FELLSR_OFFSET) # define SAM_PIOF_REHLSR (SAM_PIOF_BASE+SAM_PIO_REHLSR_OFFSET) # define SAM_PIOF_FRLHSR (SAM_PIOF_BASE+SAM_PIO_FRLHSR_OFFSET) # define SAM_PIOF_LOCKSR (SAM_PIOF_BASE+SAM_PIO_LOCKSR_OFFSET) # define SAM_PIOF_WPMR (SAM_PIOF_BASE+SAM_PIO_WPMR_OFFSET) # define SAM_PIOF_WPSR (SAM_PIOF_BASE+SAM_PIO_WPSR_OFFSET) #endif /* PIO register bit definitions *********************************************/ /* Common bit definitions for ALMOST all IO registers (exceptions follow) */ #define PIO(n) (1<<(n)) /* Bit n: PIO n */ /* PIO Write Protect Mode Register */ #define PIO_WPMR_WPEN (1 << 0) /* Bit 0: Write Protect Enable */ #define PIO_WPMR_WPKEY_SHIFT (8) /* Bits 8-31: Write Protect KEY */ #define PIO_WPMR_WPKEY_MASK (0xffffff << PIO_WPMR_WPKEY_SHIFT) # define PIO_WPMR_WPKEY (0x50494f << PIO_WPMR_WPKEY_SHIFT) /* PIO Write Protect Status Register */ #define PIO_WPSR_WPVS (1 << 0) /* Bit 0: Write Protect Violation Status */ #define PIO_WPSR_WPVSRC_SHIFT (8) /* Bits 8-23: Write Protect Violation Source */ #define PIO_WPSR_WPVSRC_MASK (0xffff << PIO_WPSR_WPVSRC_SHIFT) /**************************************************************************** * Public Types ****************************************************************************/ /**************************************************************************** * Public Data ****************************************************************************/ /**************************************************************************** * Public Functions Prototypes ****************************************************************************/ #endif /* __ARCH_ARM_SRC_SAM34_HARDWARE_SAM3U_PIO_H */
7a2ee5a8fa1ea8b3e2ded474640b1a8fae737ae2
7c857119fe1505b1d80d6e62969661c06dc1a2f4
/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c
2daf47ba6fe5f5cf40f1717f7d1e81ece81bba17
[ "BSD-2-Clause" ]
permissive
CloverHackyColor/CloverBootloader
7042ca7dd6b513d22be591a295e49071ae1482ee
2711170df4f60b2ae5aa20add3e00f35cf57b7e5
refs/heads/master
2023-08-30T22:14:34.590134
2023-08-27T19:14:02
2023-08-27T19:14:02
205,810,121
4,734
770
BSD-2-Clause
2023-09-03T12:41:33
2019-09-02T08:22:14
C
UTF-8
C
false
false
20,208
c
Mmu.c
/*++ Copyright (c) 2009, Hewlett-Packard Company. All rights reserved.<BR> Portions copyright (c) 2010, Apple Inc. All rights reserved.<BR> Portions copyright (c) 2013-2021, Arm Limited. All rights reserved.<BR> Copyright (c) 2017, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent --*/ #include <Library/MemoryAllocationLib.h> #include "CpuDxe.h" EFI_STATUS SectionToGcdAttributes ( IN UINT32 SectionAttributes, OUT UINT64 *GcdAttributes ) { *GcdAttributes = 0; // determine cacheability attributes switch (SectionAttributes & TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK) { case TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED: *GcdAttributes |= EFI_MEMORY_UC; break; case TT_DESCRIPTOR_SECTION_CACHE_POLICY_SHAREABLE_DEVICE: *GcdAttributes |= EFI_MEMORY_UC; break; case TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC: *GcdAttributes |= EFI_MEMORY_WT; break; case TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_NO_ALLOC: *GcdAttributes |= EFI_MEMORY_WB; break; case TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE: *GcdAttributes |= EFI_MEMORY_WC; break; case TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC: *GcdAttributes |= EFI_MEMORY_WB; break; case TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_SHAREABLE_DEVICE: *GcdAttributes |= EFI_MEMORY_UC; break; default: return EFI_UNSUPPORTED; } // determine protection attributes switch (SectionAttributes & TT_DESCRIPTOR_SECTION_AP_MASK) { case TT_DESCRIPTOR_SECTION_AP_NO_NO: // no read, no write // *GcdAttributes |= EFI_MEMORY_RO | EFI_MEMORY_RP; break; case TT_DESCRIPTOR_SECTION_AP_RW_NO: case TT_DESCRIPTOR_SECTION_AP_RW_RW: // normal read/write access, do not add additional attributes break; // read only cases map to write-protect case TT_DESCRIPTOR_SECTION_AP_RO_NO: case TT_DESCRIPTOR_SECTION_AP_RO_RO: *GcdAttributes |= EFI_MEMORY_RO; break; default: return EFI_UNSUPPORTED; } // now process eXectue Never attribute if ((SectionAttributes & TT_DESCRIPTOR_SECTION_XN_MASK) != 0 ) { *GcdAttributes |= EFI_MEMORY_XP; } return EFI_SUCCESS; } EFI_STATUS PageToGcdAttributes ( IN UINT32 PageAttributes, OUT UINT64 *GcdAttributes ) { *GcdAttributes = 0; // determine cacheability attributes switch (PageAttributes & TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK) { case TT_DESCRIPTOR_PAGE_CACHE_POLICY_STRONGLY_ORDERED: *GcdAttributes |= EFI_MEMORY_UC; break; case TT_DESCRIPTOR_PAGE_CACHE_POLICY_SHAREABLE_DEVICE: *GcdAttributes |= EFI_MEMORY_UC; break; case TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC: *GcdAttributes |= EFI_MEMORY_WT; break; case TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_NO_ALLOC: *GcdAttributes |= EFI_MEMORY_WB; break; case TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_CACHEABLE: *GcdAttributes |= EFI_MEMORY_WC; break; case TT_DESCRIPTOR_PAGE_CACHE_POLICY_WRITE_BACK_ALLOC: *GcdAttributes |= EFI_MEMORY_WB; break; case TT_DESCRIPTOR_PAGE_CACHE_POLICY_NON_SHAREABLE_DEVICE: *GcdAttributes |= EFI_MEMORY_UC; break; default: return EFI_UNSUPPORTED; } // determine protection attributes switch (PageAttributes & TT_DESCRIPTOR_PAGE_AP_MASK) { case TT_DESCRIPTOR_PAGE_AP_NO_NO: // no read, no write // *GcdAttributes |= EFI_MEMORY_RO | EFI_MEMORY_RP; break; case TT_DESCRIPTOR_PAGE_AP_RW_NO: case TT_DESCRIPTOR_PAGE_AP_RW_RW: // normal read/write access, do not add additional attributes break; // read only cases map to write-protect case TT_DESCRIPTOR_PAGE_AP_RO_NO: case TT_DESCRIPTOR_PAGE_AP_RO_RO: *GcdAttributes |= EFI_MEMORY_RO; break; default: return EFI_UNSUPPORTED; } // now process eXectue Never attribute if ((PageAttributes & TT_DESCRIPTOR_PAGE_XN_MASK) != 0 ) { *GcdAttributes |= EFI_MEMORY_XP; } return EFI_SUCCESS; } EFI_STATUS SyncCacheConfigPage ( IN UINT32 SectionIndex, IN UINT32 FirstLevelDescriptor, IN UINTN NumberOfDescriptors, IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, IN OUT EFI_PHYSICAL_ADDRESS *NextRegionBase, IN OUT UINT64 *NextRegionLength, IN OUT UINT32 *NextSectionAttributes ) { EFI_STATUS Status; UINT32 i; volatile ARM_PAGE_TABLE_ENTRY *SecondLevelTable; UINT32 NextPageAttributes; UINT32 PageAttributes; UINT32 BaseAddress; UINT64 GcdAttributes; // Get the Base Address from FirstLevelDescriptor; BaseAddress = TT_DESCRIPTOR_PAGE_BASE_ADDRESS (SectionIndex << TT_DESCRIPTOR_SECTION_BASE_SHIFT); // Convert SectionAttributes into PageAttributes NextPageAttributes = TT_DESCRIPTOR_CONVERT_TO_PAGE_CACHE_POLICY (*NextSectionAttributes, 0) | TT_DESCRIPTOR_CONVERT_TO_PAGE_AP (*NextSectionAttributes); // obtain page table base SecondLevelTable = (ARM_PAGE_TABLE_ENTRY *)(FirstLevelDescriptor & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK); for (i = 0; i < TRANSLATION_TABLE_PAGE_COUNT; i++) { if ((SecondLevelTable[i] & TT_DESCRIPTOR_PAGE_TYPE_MASK) == TT_DESCRIPTOR_PAGE_TYPE_PAGE) { // extract attributes (cacheability and permissions) PageAttributes = SecondLevelTable[i] & (TT_DESCRIPTOR_PAGE_CACHE_POLICY_MASK | TT_DESCRIPTOR_PAGE_AP_MASK); if (NextPageAttributes == 0) { // start on a new region *NextRegionLength = 0; *NextRegionBase = BaseAddress | (i << TT_DESCRIPTOR_PAGE_BASE_SHIFT); NextPageAttributes = PageAttributes; } else if (PageAttributes != NextPageAttributes) { // Convert Section Attributes into GCD Attributes Status = PageToGcdAttributes (NextPageAttributes, &GcdAttributes); ASSERT_EFI_ERROR (Status); // update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK) SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, *NextRegionBase, *NextRegionLength, GcdAttributes); // start on a new region *NextRegionLength = 0; *NextRegionBase = BaseAddress | (i << TT_DESCRIPTOR_PAGE_BASE_SHIFT); NextPageAttributes = PageAttributes; } } else if (NextPageAttributes != 0) { // Convert Page Attributes into GCD Attributes Status = PageToGcdAttributes (NextPageAttributes, &GcdAttributes); ASSERT_EFI_ERROR (Status); // update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK) SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, *NextRegionBase, *NextRegionLength, GcdAttributes); *NextRegionLength = 0; *NextRegionBase = BaseAddress | (i << TT_DESCRIPTOR_PAGE_BASE_SHIFT); NextPageAttributes = 0; } *NextRegionLength += TT_DESCRIPTOR_PAGE_SIZE; } // Convert back PageAttributes into SectionAttributes *NextSectionAttributes = TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY (NextPageAttributes, 0) | TT_DESCRIPTOR_CONVERT_TO_SECTION_AP (NextPageAttributes); return EFI_SUCCESS; } EFI_STATUS SyncCacheConfig ( IN EFI_CPU_ARCH_PROTOCOL *CpuProtocol ) { EFI_STATUS Status; UINT32 i; EFI_PHYSICAL_ADDRESS NextRegionBase; UINT64 NextRegionLength; UINT32 NextSectionAttributes; UINT32 SectionAttributes; UINT64 GcdAttributes; volatile ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable; UINTN NumberOfDescriptors; EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; DEBUG ((DEBUG_PAGE, "SyncCacheConfig()\n")); // This code assumes MMU is enabled and filed with section translations ASSERT (ArmMmuEnabled ()); // // Get the memory space map from GCD // MemorySpaceMap = NULL; Status = gDS->GetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap); ASSERT_EFI_ERROR (Status); // The GCD implementation maintains its own copy of the state of memory space attributes. GCD needs // to know what the initial memory space attributes are. The CPU Arch. Protocol does not provide a // GetMemoryAttributes function for GCD to get this so we must resort to calling GCD (as if we were // a client) to update its copy of the attributes. This is bad architecture and should be replaced // with a way for GCD to query the CPU Arch. driver of the existing memory space attributes instead. // obtain page table base FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)(ArmGetTTBR0BaseAddress ()); // Get the first region NextSectionAttributes = FirstLevelTable[0] & (TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK | TT_DESCRIPTOR_SECTION_AP_MASK); // iterate through each 1MB descriptor NextRegionBase = NextRegionLength = 0; for (i = 0; i < TRANSLATION_TABLE_SECTION_COUNT; i++) { if ((FirstLevelTable[i] & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) { // extract attributes (cacheability and permissions) SectionAttributes = FirstLevelTable[i] & (TT_DESCRIPTOR_SECTION_CACHE_POLICY_MASK | TT_DESCRIPTOR_SECTION_AP_MASK); if (NextSectionAttributes == 0) { // start on a new region NextRegionLength = 0; NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT); NextSectionAttributes = SectionAttributes; } else if (SectionAttributes != NextSectionAttributes) { // Convert Section Attributes into GCD Attributes Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes); ASSERT_EFI_ERROR (Status); // update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK) SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes); // start on a new region NextRegionLength = 0; NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT); NextSectionAttributes = SectionAttributes; } NextRegionLength += TT_DESCRIPTOR_SECTION_SIZE; } else if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (FirstLevelTable[i])) { // In this case any bits set in the 'NextSectionAttributes' are garbage and were set from // bits that are actually part of the pagetable address. We clear it out to zero so that // the SyncCacheConfigPage will use the page attributes instead of trying to convert the // section attributes into page attributes NextSectionAttributes = 0; Status = SyncCacheConfigPage ( i, FirstLevelTable[i], NumberOfDescriptors, MemorySpaceMap, &NextRegionBase, &NextRegionLength, &NextSectionAttributes ); ASSERT_EFI_ERROR (Status); } else { // We do not support yet 16MB sections ASSERT ((FirstLevelTable[i] & TT_DESCRIPTOR_SECTION_TYPE_MASK) != TT_DESCRIPTOR_SECTION_TYPE_SUPERSECTION); // start on a new region if (NextSectionAttributes != 0) { // Convert Section Attributes into GCD Attributes Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes); ASSERT_EFI_ERROR (Status); // update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK) SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes); NextRegionLength = 0; NextRegionBase = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (i << TT_DESCRIPTOR_SECTION_BASE_SHIFT); NextSectionAttributes = 0; } NextRegionLength += TT_DESCRIPTOR_SECTION_SIZE; } } // section entry loop if (NextSectionAttributes != 0) { // Convert Section Attributes into GCD Attributes Status = SectionToGcdAttributes (NextSectionAttributes, &GcdAttributes); ASSERT_EFI_ERROR (Status); // update GCD with these changes (this will recurse into our own CpuSetMemoryAttributes below which is OK) SetGcdMemorySpaceAttributes (MemorySpaceMap, NumberOfDescriptors, NextRegionBase, NextRegionLength, GcdAttributes); } FreePool (MemorySpaceMap); return EFI_SUCCESS; } UINT64 EfiAttributeToArmAttribute ( IN UINT64 EfiAttributes ) { UINT64 ArmAttributes; switch (EfiAttributes & EFI_MEMORY_CACHETYPE_MASK) { case EFI_MEMORY_UC: // Map to strongly ordered ArmAttributes = TT_DESCRIPTOR_SECTION_CACHE_POLICY_STRONGLY_ORDERED; // TEX[2:0] = 0, C=0, B=0 break; case EFI_MEMORY_WC: // Map to normal non-cacheable ArmAttributes = TT_DESCRIPTOR_SECTION_CACHE_POLICY_NON_CACHEABLE; // TEX [2:0]= 001 = 0x2, B=0, C=0 break; case EFI_MEMORY_WT: // Write through with no-allocate ArmAttributes = TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_THROUGH_NO_ALLOC; // TEX [2:0] = 0, C=1, B=0 break; case EFI_MEMORY_WB: // Write back (with allocate) ArmAttributes = TT_DESCRIPTOR_SECTION_CACHE_POLICY_WRITE_BACK_ALLOC; // TEX [2:0] = 001, C=1, B=1 break; case EFI_MEMORY_UCE: default: ArmAttributes = TT_DESCRIPTOR_SECTION_TYPE_FAULT; break; } // Determine protection attributes if ((EfiAttributes & EFI_MEMORY_RO) != 0) { ArmAttributes |= TT_DESCRIPTOR_SECTION_AP_RO_RO; } else { ArmAttributes |= TT_DESCRIPTOR_SECTION_AP_RW_RW; } // Determine eXecute Never attribute if ((EfiAttributes & EFI_MEMORY_XP) != 0) { ArmAttributes |= TT_DESCRIPTOR_SECTION_XN_MASK; } return ArmAttributes; } EFI_STATUS GetMemoryRegionPage ( IN UINT32 *PageTable, IN OUT UINTN *BaseAddress, OUT UINTN *RegionLength, OUT UINTN *RegionAttributes ) { UINT32 PageAttributes; UINT32 TableIndex; UINT32 PageDescriptor; // Convert the section attributes into page attributes PageAttributes = ConvertSectionAttributesToPageAttributes (*RegionAttributes, 0); // Calculate index into first level translation table for start of modification TableIndex = ((*BaseAddress) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT; ASSERT (TableIndex < TRANSLATION_TABLE_PAGE_COUNT); // Go through the page table to find the end of the section for ( ; TableIndex < TRANSLATION_TABLE_PAGE_COUNT; TableIndex++) { // Get the section at the given index PageDescriptor = PageTable[TableIndex]; if ((PageDescriptor & TT_DESCRIPTOR_PAGE_TYPE_MASK) == TT_DESCRIPTOR_PAGE_TYPE_FAULT) { // Case: End of the boundary of the region return EFI_SUCCESS; } else if ((PageDescriptor & TT_DESCRIPTOR_PAGE_TYPE_PAGE) == TT_DESCRIPTOR_PAGE_TYPE_PAGE) { if ((PageDescriptor & TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK) == PageAttributes) { *RegionLength = *RegionLength + TT_DESCRIPTOR_PAGE_SIZE; } else { // Case: End of the boundary of the region return EFI_SUCCESS; } } else { // We do not support Large Page yet. We return EFI_SUCCESS that means end of the region. ASSERT (0); return EFI_SUCCESS; } } return EFI_NOT_FOUND; } EFI_STATUS GetMemoryRegion ( IN OUT UINTN *BaseAddress, OUT UINTN *RegionLength, OUT UINTN *RegionAttributes ) { EFI_STATUS Status; UINT32 TableIndex; UINT32 PageAttributes; UINT32 PageTableIndex; UINT32 SectionDescriptor; ARM_FIRST_LEVEL_DESCRIPTOR *FirstLevelTable; UINT32 *PageTable; // Initialize the arguments *RegionLength = 0; // Obtain page table base FirstLevelTable = (ARM_FIRST_LEVEL_DESCRIPTOR *)ArmGetTTBR0BaseAddress (); // Calculate index into first level translation table for start of modification TableIndex = TT_DESCRIPTOR_SECTION_BASE_ADDRESS (*BaseAddress) >> TT_DESCRIPTOR_SECTION_BASE_SHIFT; ASSERT (TableIndex < TRANSLATION_TABLE_SECTION_COUNT); // Get the section at the given index SectionDescriptor = FirstLevelTable[TableIndex]; if (!SectionDescriptor) { return EFI_NOT_FOUND; } // If 'BaseAddress' belongs to the section then round it to the section boundary if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) || ((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SUPERSECTION)) { *BaseAddress = (*BaseAddress) & TT_DESCRIPTOR_SECTION_BASE_ADDRESS_MASK; *RegionAttributes = SectionDescriptor & TT_DESCRIPTOR_SECTION_ATTRIBUTE_MASK; } else { // Otherwise, we round it to the page boundary *BaseAddress = (*BaseAddress) & TT_DESCRIPTOR_PAGE_BASE_ADDRESS_MASK; // Get the attribute at the page table level (Level 2) PageTable = (UINT32 *)(SectionDescriptor & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK); // Calculate index into first level translation table for start of modification PageTableIndex = ((*BaseAddress) & TT_DESCRIPTOR_PAGE_INDEX_MASK) >> TT_DESCRIPTOR_PAGE_BASE_SHIFT; ASSERT (PageTableIndex < TRANSLATION_TABLE_PAGE_COUNT); PageAttributes = PageTable[PageTableIndex] & TT_DESCRIPTOR_PAGE_ATTRIBUTE_MASK; *RegionAttributes = TT_DESCRIPTOR_CONVERT_TO_SECTION_CACHE_POLICY (PageAttributes, 0) | TT_DESCRIPTOR_CONVERT_TO_SECTION_AP (PageAttributes); } for ( ; TableIndex < TRANSLATION_TABLE_SECTION_COUNT; TableIndex++) { // Get the section at the given index SectionDescriptor = FirstLevelTable[TableIndex]; // If the entry is a level-2 page table then we scan it to find the end of the region if (TT_DESCRIPTOR_SECTION_TYPE_IS_PAGE_TABLE (SectionDescriptor)) { // Extract the page table location from the descriptor PageTable = (UINT32 *)(SectionDescriptor & TT_DESCRIPTOR_SECTION_PAGETABLE_ADDRESS_MASK); // Scan the page table to find the end of the region. Status = GetMemoryRegionPage (PageTable, BaseAddress, RegionLength, RegionAttributes); // If we have found the end of the region (Status == EFI_SUCCESS) then we exit the for-loop if (Status == EFI_SUCCESS) { break; } } else if (((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SECTION) || ((SectionDescriptor & TT_DESCRIPTOR_SECTION_TYPE_MASK) == TT_DESCRIPTOR_SECTION_TYPE_SUPERSECTION)) { if ((SectionDescriptor & TT_DESCRIPTOR_SECTION_ATTRIBUTE_MASK) != *RegionAttributes) { // If the attributes of the section differ from the one targeted then we exit the loop break; } else { *RegionLength = *RegionLength + TT_DESCRIPTOR_SECTION_SIZE; } } else { // If we are on an invalid section then it means it is the end of our section. break; } } return EFI_SUCCESS; }
8cf3e92066494469e6f76643b3c24bbc812f09d8
4b52bc727e3757a133a02fe5b98dcbdbe80bb2e6
/front/listcomp.h
dd52e184e3adebf00b1d08e09941905619c8d5f7
[ "MIT" ]
permissive
never-lang/never
bbad1b6c6de7cd14c1cd956fdb9622f03cd2db9a
008b8f3a143513cda312473595dccb9b1212981d
refs/heads/master
2023-09-04T09:20:41.379437
2023-09-02T07:39:04
2023-09-02T07:39:04
134,974,042
432
19
MIT
2023-09-02T07:29:45
2018-05-26T15:41:59
C
UTF-8
C
false
false
1,661
h
listcomp.h
#ifndef __LISTCOMP_H__ #define __LISTCOMP_H__ typedef enum qualifier_type { QUALIFIER_UNKNOWN = 0, QUALIFIER_GENERATOR = 1, QUALIFIER_FILTER = 2, } qualifier_type; typedef struct array array; typedef struct expr expr; typedef struct param param; typedef struct symtab symtab; typedef struct qualifier { qualifier_type type; char * id; expr * expr_value; int stack_level; unsigned int line_no; } qualifier; typedef struct qualifier_list_node { qualifier * value; struct qualifier_list_node * prev; struct qualifier_list_node * next; } qualifier_list_node; typedef struct qualifier_list { qualifier_list_node * head; qualifier_list_node * tail; } qualifier_list; typedef struct listcomp { symtab * stab; expr * expr_value; qualifier_list * list; param * ret; int stack_level; unsigned int line_no; } listcomp; qualifier * qualifier_new_generator(char * id, expr * expr_value); qualifier * qualifier_new_filter(expr * expr_value); void qualifier_delete(qualifier * value); void qualifier_print(qualifier * value); const char * qualifier_type_str(qualifier_type type); qualifier_list_node * qualifier_list_node_new(qualifier * value); void qualifier_list_node_delete(qualifier_list_node * node); qualifier_list * qualifier_list_new(); void qualifier_list_delete(qualifier_list * list); void qualifier_list_add_beg(qualifier_list * list, qualifier * value); void qualifier_list_add_end(qualifier_list * list, qualifier * value); listcomp * listcomp_new(expr * expr_value, qualifier_list * list, param * ret); void listcomp_delete(listcomp * value); #endif /* __LISTCOMP_H__ */
780805bddf4f0c3dfef3d738ddb884a82a3fcd62
e100cedc265380fd666b08bd99ffdbeb4dfe0d3c
/include/SFML/Graphics/Color.h
4e82aa15d1787720f3ea8026f94337a98c54e0b9
[ "Zlib" ]
permissive
SFML/CSFML
50db0712f6f28c8958748df374a95a8c52a8063d
a80542d67d86dd37b9c6693e11ee666cbcfbe9f1
refs/heads/master
2023-08-19T00:21:35.753336
2023-08-06T22:12:44
2023-08-07T11:36:07
2,008,752
308
182
NOASSERTION
2023-09-09T21:36:25
2011-07-06T20:35:15
C
UTF-8
C
false
false
5,033
h
Color.h
//////////////////////////////////////////////////////////// // // SFML - Simple and Fast Multimedia Library // Copyright (C) 2007-2023 Laurent Gomila (laurent@sfml-dev.org) // // This software is provided 'as-is', without any express or implied warranty. // In no event will the authors be held liable for any damages arising from the use of this software. // // Permission is granted to anyone to use this software for any purpose, // including commercial applications, and to alter it and redistribute it freely, // subject to the following restrictions: // // 1. The origin of this software must not be misrepresented; // you must not claim that you wrote the original software. // If you use this software in a product, an acknowledgment // in the product documentation would be appreciated but is not required. // // 2. Altered source versions must be plainly marked as such, // and must not be misrepresented as being the original software. // // 3. This notice may not be removed or altered from any source distribution. // //////////////////////////////////////////////////////////// #ifndef SFML_COLOR_H #define SFML_COLOR_H //////////////////////////////////////////////////////////// // Headers //////////////////////////////////////////////////////////// #include <SFML/Graphics/Export.h> //////////////////////////////////////////////////////////// /// \brief Utility class for manpulating RGBA colors /// //////////////////////////////////////////////////////////// typedef struct { sfUint8 r; sfUint8 g; sfUint8 b; sfUint8 a; } sfColor; CSFML_GRAPHICS_API sfColor sfBlack; ///< Black predefined color CSFML_GRAPHICS_API sfColor sfWhite; ///< White predefined color CSFML_GRAPHICS_API sfColor sfRed; ///< Red predefined color CSFML_GRAPHICS_API sfColor sfGreen; ///< Green predefined color CSFML_GRAPHICS_API sfColor sfBlue; ///< Blue predefined color CSFML_GRAPHICS_API sfColor sfYellow; ///< Yellow predefined color CSFML_GRAPHICS_API sfColor sfMagenta; ///< Magenta predefined color CSFML_GRAPHICS_API sfColor sfCyan; ///< Cyan predefined color CSFML_GRAPHICS_API sfColor sfTransparent; ///< Transparent (black) predefined color //////////////////////////////////////////////////////////// /// \brief Construct a color from its 3 RGB components /// /// \param red Red component (0 .. 255) /// \param green Green component (0 .. 255) /// \param blue Blue component (0 .. 255) /// /// \return sfColor constructed from the components /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfColor_fromRGB(sfUint8 red, sfUint8 green, sfUint8 blue); //////////////////////////////////////////////////////////// /// \brief Construct a color from its 4 RGBA components /// /// \param red Red component (0 .. 255) /// \param green Green component (0 .. 255) /// \param blue Blue component (0 .. 255) /// \param alpha Alpha component (0 .. 255) /// /// \return sfColor constructed from the components /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfColor_fromRGBA(sfUint8 red, sfUint8 green, sfUint8 blue, sfUint8 alpha); //////////////////////////////////////////////////////////// /// \brief Construct the color from 32-bit unsigned integer /// /// \param color Number containing the RGBA components (in that order) /// /// \return sfColor constructed from the 32-bit unsigned integer /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfColor_fromInteger(sfUint32 color); //////////////////////////////////////////////////////////// /// \brief Convert a color to a 32-bit unsigned integer /// /// \return Color represented as a 32-bit unsigned integer /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfUint32 sfColor_toInteger(sfColor color); //////////////////////////////////////////////////////////// /// \brief Add two colors /// /// \param color1 First color /// \param color2 Second color /// /// \return Component-wise saturated addition of the two colors /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfColor_add(sfColor color1, sfColor color2); //////////////////////////////////////////////////////////// /// \brief Subtract two colors /// /// \param color1 First color /// \param color2 Second color /// /// \return Component-wise saturated subtraction of the two colors /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfColor_subtract(sfColor color1, sfColor color2); //////////////////////////////////////////////////////////// /// \brief Modulate two colors /// /// \param color1 First color /// \param color2 Second color /// /// \return Component-wise multiplication of the two colors /// //////////////////////////////////////////////////////////// CSFML_GRAPHICS_API sfColor sfColor_modulate(sfColor color1, sfColor color2); #endif // SFML_COLOR_H
7691d229905cd12936f77bf3197a50f84a5f0abc
6ed2b7cac5384d4de83e0166179bdb049bc73f7e
/test/esp-idf/esp_timer.h
780d6a9a3653334b1043d3f9e604c24a61e4717b
[ "MIT", "Vim" ]
permissive
jandelgado/jled
deae493dcd23700333677e6e89dc4967ae5af874
06331214fb4fdbc59c564d44d9585e5e18454adb
refs/heads/master
2023-09-01T10:48:01.516474
2023-08-20T19:33:20
2023-08-20T19:33:20
94,705,769
290
61
MIT
2023-09-10T16:04:55
2017-06-18T18:35:16
C++
UTF-8
C
false
false
194
h
esp_timer.h
// ESP32 ESP-IDF mock // Copyright (c) 2017-2022 Jan Delgado <jdelgado[at]gmx.net> // #pragma once #include <stdint.h> int64_t esp_timer_get_time(); void esp32_mock_set_esp_timer(int64_t t);
da46f0fc14da8f47778e7dd0169e77b2b75ea8c9
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/watchdog/ath79_wdt.c
c97a47ca89710e69060e7301115d7fbec2b11c62
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
7,624
c
ath79_wdt.c
/* * Atheros AR71XX/AR724X/AR913X built-in hardware watchdog timer. * * Copyright (C) 2008-2011 Gabor Juhos <juhosg@openwrt.org> * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org> * * This driver was based on: drivers/watchdog/ixp4xx_wdt.c * Author: Deepak Saxena <dsaxena@plexity.net> * Copyright 2004 (c) MontaVista, Software, Inc. * * which again was based on sa1100 driver, * Copyright (C) 2000 Oleg Drokin <green@crimea.edu> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include <linux/bitops.h> #include <linux/delay.h> #include <linux/errno.h> #include <linux/fs.h> #include <linux/init.h> #include <linux/io.h> #include <linux/kernel.h> #include <linux/miscdevice.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/platform_device.h> #include <linux/types.h> #include <linux/watchdog.h> #include <linux/clk.h> #include <linux/err.h> #include <linux/of.h> #include <linux/of_platform.h> #define DRIVER_NAME "ath79-wdt" #define WDT_TIMEOUT 15 /* seconds */ #define WDOG_REG_CTRL 0x00 #define WDOG_REG_TIMER 0x04 #define WDOG_CTRL_LAST_RESET BIT(31) #define WDOG_CTRL_ACTION_MASK 3 #define WDOG_CTRL_ACTION_NONE 0 /* no action */ #define WDOG_CTRL_ACTION_GPI 1 /* general purpose interrupt */ #define WDOG_CTRL_ACTION_NMI 2 /* NMI */ #define WDOG_CTRL_ACTION_FCR 3 /* full chip reset */ static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started " "(default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); static int timeout = WDT_TIMEOUT; module_param(timeout, int, 0); MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds " "(default=" __MODULE_STRING(WDT_TIMEOUT) "s)"); static unsigned long wdt_flags; #define WDT_FLAGS_BUSY 0 #define WDT_FLAGS_EXPECT_CLOSE 1 static struct clk *wdt_clk; static unsigned long wdt_freq; static int boot_status; static int max_timeout; static void __iomem *wdt_base; static inline void ath79_wdt_wr(unsigned reg, u32 val) { iowrite32(val, wdt_base + reg); } static inline u32 ath79_wdt_rr(unsigned reg) { return ioread32(wdt_base + reg); } static inline void ath79_wdt_keepalive(void) { ath79_wdt_wr(WDOG_REG_TIMER, wdt_freq * timeout); /* flush write */ ath79_wdt_rr(WDOG_REG_TIMER); } static inline void ath79_wdt_enable(void) { ath79_wdt_keepalive(); /* * Updating the TIMER register requires a few microseconds * on the AR934x SoCs at least. Use a small delay to ensure * that the TIMER register is updated within the hardware * before enabling the watchdog. */ udelay(2); ath79_wdt_wr(WDOG_REG_CTRL, WDOG_CTRL_ACTION_FCR); /* flush write */ ath79_wdt_rr(WDOG_REG_CTRL); } static inline void ath79_wdt_disable(void) { ath79_wdt_wr(WDOG_REG_CTRL, WDOG_CTRL_ACTION_NONE); /* flush write */ ath79_wdt_rr(WDOG_REG_CTRL); } static int ath79_wdt_set_timeout(int val) { if (val < 1 || val > max_timeout) return -EINVAL; timeout = val; ath79_wdt_keepalive(); return 0; } static int ath79_wdt_open(struct inode *inode, struct file *file) { if (test_and_set_bit(WDT_FLAGS_BUSY, &wdt_flags)) return -EBUSY; clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); ath79_wdt_enable(); return nonseekable_open(inode, file); } static int ath79_wdt_release(struct inode *inode, struct file *file) { if (test_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags)) ath79_wdt_disable(); else { pr_crit("device closed unexpectedly, watchdog timer will not stop!\n"); ath79_wdt_keepalive(); } clear_bit(WDT_FLAGS_BUSY, &wdt_flags); clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); return 0; } static ssize_t ath79_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) { if (len) { if (!nowayout) { size_t i; clear_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); for (i = 0; i != len; i++) { char c; if (get_user(c, data + i)) return -EFAULT; if (c == 'V') set_bit(WDT_FLAGS_EXPECT_CLOSE, &wdt_flags); } } ath79_wdt_keepalive(); } return len; } static const struct watchdog_info ath79_wdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE | WDIOF_CARDRESET, .firmware_version = 0, .identity = "ATH79 watchdog", }; static long ath79_wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { void __user *argp = (void __user *)arg; int __user *p = argp; int err; int t; switch (cmd) { case WDIOC_GETSUPPORT: err = copy_to_user(argp, &ath79_wdt_info, sizeof(ath79_wdt_info)) ? -EFAULT : 0; break; case WDIOC_GETSTATUS: err = put_user(0, p); break; case WDIOC_GETBOOTSTATUS: err = put_user(boot_status, p); break; case WDIOC_KEEPALIVE: ath79_wdt_keepalive(); err = 0; break; case WDIOC_SETTIMEOUT: err = get_user(t, p); if (err) break; err = ath79_wdt_set_timeout(t); if (err) break; /* fallthrough */ case WDIOC_GETTIMEOUT: err = put_user(timeout, p); break; default: err = -ENOTTY; break; } return err; } static const struct file_operations ath79_wdt_fops = { .owner = THIS_MODULE, .llseek = no_llseek, .write = ath79_wdt_write, .unlocked_ioctl = ath79_wdt_ioctl, .open = ath79_wdt_open, .release = ath79_wdt_release, }; static struct miscdevice ath79_wdt_miscdev = { .minor = WATCHDOG_MINOR, .name = "watchdog", .fops = &ath79_wdt_fops, }; static int ath79_wdt_probe(struct platform_device *pdev) { struct resource *res; u32 ctrl; int err; if (wdt_base) return -EBUSY; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); wdt_base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(wdt_base)) return PTR_ERR(wdt_base); wdt_clk = devm_clk_get(&pdev->dev, "wdt"); if (IS_ERR(wdt_clk)) return PTR_ERR(wdt_clk); err = clk_enable(wdt_clk); if (err) return err; wdt_freq = clk_get_rate(wdt_clk); if (!wdt_freq) { err = -EINVAL; goto err_clk_disable; } max_timeout = (0xfffffffful / wdt_freq); if (timeout < 1 || timeout > max_timeout) { timeout = max_timeout; dev_info(&pdev->dev, "timeout value must be 0 < timeout < %d, using %d\n", max_timeout, timeout); } ctrl = ath79_wdt_rr(WDOG_REG_CTRL); boot_status = (ctrl & WDOG_CTRL_LAST_RESET) ? WDIOF_CARDRESET : 0; err = misc_register(&ath79_wdt_miscdev); if (err) { dev_err(&pdev->dev, "unable to register misc device, err=%d\n", err); goto err_clk_disable; } return 0; err_clk_disable: clk_disable(wdt_clk); return err; } static int ath79_wdt_remove(struct platform_device *pdev) { misc_deregister(&ath79_wdt_miscdev); clk_disable(wdt_clk); return 0; } static void ath97_wdt_shutdown(struct platform_device *pdev) { ath79_wdt_disable(); } #ifdef CONFIG_OF static const struct of_device_id ath79_wdt_match[] = { { .compatible = "qca,ar7130-wdt" }, {}, }; MODULE_DEVICE_TABLE(of, ath79_wdt_match); #endif static struct platform_driver ath79_wdt_driver = { .probe = ath79_wdt_probe, .remove = ath79_wdt_remove, .shutdown = ath97_wdt_shutdown, .driver = { .name = DRIVER_NAME, .owner = THIS_MODULE, .of_match_table = of_match_ptr(ath79_wdt_match), }, }; module_platform_driver(ath79_wdt_driver); MODULE_DESCRIPTION("Atheros AR71XX/AR724X/AR913X hardware watchdog driver"); MODULE_AUTHOR("Gabor Juhos <juhosg@openwrt.org"); MODULE_AUTHOR("Imre Kaloz <kaloz@openwrt.org"); MODULE_LICENSE("GPL v2"); MODULE_ALIAS("platform:" DRIVER_NAME); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
ba601945bd301a3dc56626eabf84837301e438bf
a5a7c59b04a1a64fe34653c7970c3cf173f9c1df
/numerics/src/tools/internal/open_lib.h
81d2fd92013ffb6e87af16a63eb913e9053b0cd9
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
siconos/siconos
a7afdba41a2bc1192ad8dcd93ac7266fa281f4cf
82a8d1338bfc1be0d36b5e8a9f40c1ad5384a641
refs/heads/master
2023-08-21T22:22:55.625941
2023-07-17T13:07:32
2023-07-17T13:07:32
37,709,357
166
33
Apache-2.0
2023-07-17T12:31:16
2015-06-19T07:55:53
C
UTF-8
C
false
false
1,430
h
open_lib.h
/* Siconos is a program dedicated to modeling, simulation and control * of non smooth dynamical systems. * * Copyright 2022 INRIA. * * 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. */ /** \file open_lib.h * \brief function to open library and find functions in then (useful for * plugin */ #ifndef OPEN_LIB_H #define OPEN_LIB_H #include "SiconosConfig.h" #if defined(__cplusplus) && !defined(BUILD_AS_CPP) extern "C" { #endif /** open a library and return an handle (casted as void*) * \param lib_name name of the library * \param flags additional flags (for dlopen) */ void* open_library(const char* lib_name, const int flags); /** get the address of a function in an already opened lib * \param plugin handle to the library * \param func name of function */ void* get_function_address(void* plugin, const char* func); #if defined(__cplusplus) && !defined(BUILD_AS_CPP) } #endif #endif
c78c033c028528443e3e419d22cdd19b235150f4
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/arch/powerpc/platforms/ps3/os-area.c
09787139834ddd8bd01fbce0448ca34297a1cd5c
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
22,224
c
os-area.c
/* * PS3 flash memory os area. * * Copyright (C) 2006 Sony Computer Entertainment Inc. * Copyright 2006 Sony Corp. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <linux/kernel.h> #include <linux/io.h> #include <linux/workqueue.h> #include <linux/fs.h> #include <linux/syscalls.h> #include <linux/export.h> #include <linux/ctype.h> #include <linux/memblock.h> #include <linux/of.h> #include <linux/slab.h> #include <asm/prom.h> #include "platform.h" enum { OS_AREA_SEGMENT_SIZE = 0X200, }; enum os_area_ldr_format { HEADER_LDR_FORMAT_RAW = 0, HEADER_LDR_FORMAT_GZIP = 1, }; #define OS_AREA_HEADER_MAGIC_NUM "cell_ext_os_area" /** * struct os_area_header - os area header segment. * @magic_num: Always 'cell_ext_os_area'. * @hdr_version: Header format version number. * @db_area_offset: Starting segment number of other os database area. * @ldr_area_offset: Starting segment number of bootloader image area. * @ldr_format: HEADER_LDR_FORMAT flag. * @ldr_size: Size of bootloader image in bytes. * * Note that the docs refer to area offsets. These are offsets in units of * segments from the start of the os area (top of the header). These are * better thought of as segment numbers. The os area of the os area is * reserved for the os image. */ struct os_area_header { u8 magic_num[16]; u32 hdr_version; u32 db_area_offset; u32 ldr_area_offset; u32 _reserved_1; u32 ldr_format; u32 ldr_size; u32 _reserved_2[6]; }; enum os_area_boot_flag { PARAM_BOOT_FLAG_GAME_OS = 0, PARAM_BOOT_FLAG_OTHER_OS = 1, }; enum os_area_ctrl_button { PARAM_CTRL_BUTTON_O_IS_YES = 0, PARAM_CTRL_BUTTON_X_IS_YES = 1, }; /** * struct os_area_params - os area params segment. * @boot_flag: User preference of operating system, PARAM_BOOT_FLAG flag. * @num_params: Number of params in this (params) segment. * @rtc_diff: Difference in seconds between 1970 and the ps3 rtc value. * @av_multi_out: User preference of AV output, PARAM_AV_MULTI_OUT flag. * @ctrl_button: User preference of controller button config, PARAM_CTRL_BUTTON * flag. * @static_ip_addr: User preference of static IP address. * @network_mask: User preference of static network mask. * @default_gateway: User preference of static default gateway. * @dns_primary: User preference of static primary dns server. * @dns_secondary: User preference of static secondary dns server. * * The ps3 rtc maintains a read-only value that approximates seconds since * 2000-01-01 00:00:00 UTC. * * User preference of zero for static_ip_addr means use dhcp. */ struct os_area_params { u32 boot_flag; u32 _reserved_1[3]; u32 num_params; u32 _reserved_2[3]; /* param 0 */ s64 rtc_diff; u8 av_multi_out; u8 ctrl_button; u8 _reserved_3[6]; /* param 1 */ u8 static_ip_addr[4]; u8 network_mask[4]; u8 default_gateway[4]; u8 _reserved_4[4]; /* param 2 */ u8 dns_primary[4]; u8 dns_secondary[4]; u8 _reserved_5[8]; }; #define OS_AREA_DB_MAGIC_NUM "-db-" /** * struct os_area_db - Shared flash memory database. * @magic_num: Always '-db-'. * @version: os_area_db format version number. * @index_64: byte offset of the database id index for 64 bit variables. * @count_64: number of usable 64 bit index entries * @index_32: byte offset of the database id index for 32 bit variables. * @count_32: number of usable 32 bit index entries * @index_16: byte offset of the database id index for 16 bit variables. * @count_16: number of usable 16 bit index entries * * Flash rom storage for exclusive use by guests running in the other os lpar. * The current system configuration allocates 1K (two segments) for other os * use. */ struct os_area_db { u8 magic_num[4]; u16 version; u16 _reserved_1; u16 index_64; u16 count_64; u16 index_32; u16 count_32; u16 index_16; u16 count_16; u32 _reserved_2; u8 _db_data[1000]; }; /** * enum os_area_db_owner - Data owners. */ enum os_area_db_owner { OS_AREA_DB_OWNER_ANY = -1, OS_AREA_DB_OWNER_NONE = 0, OS_AREA_DB_OWNER_PROTOTYPE = 1, OS_AREA_DB_OWNER_LINUX = 2, OS_AREA_DB_OWNER_PETITBOOT = 3, OS_AREA_DB_OWNER_MAX = 32, }; enum os_area_db_key { OS_AREA_DB_KEY_ANY = -1, OS_AREA_DB_KEY_NONE = 0, OS_AREA_DB_KEY_RTC_DIFF = 1, OS_AREA_DB_KEY_VIDEO_MODE = 2, OS_AREA_DB_KEY_MAX = 8, }; struct os_area_db_id { int owner; int key; }; static const struct os_area_db_id os_area_db_id_empty = { .owner = OS_AREA_DB_OWNER_NONE, .key = OS_AREA_DB_KEY_NONE }; static const struct os_area_db_id os_area_db_id_any = { .owner = OS_AREA_DB_OWNER_ANY, .key = OS_AREA_DB_KEY_ANY }; static const struct os_area_db_id os_area_db_id_rtc_diff = { .owner = OS_AREA_DB_OWNER_LINUX, .key = OS_AREA_DB_KEY_RTC_DIFF }; static const struct os_area_db_id os_area_db_id_video_mode = { .owner = OS_AREA_DB_OWNER_LINUX, .key = OS_AREA_DB_KEY_VIDEO_MODE }; #define SECONDS_FROM_1970_TO_2000 946684800LL /** * struct saved_params - Static working copies of data from the PS3 'os area'. * * The order of preference we use for the rtc_diff source: * 1) The database value. * 2) The game os value. * 3) The number of seconds from 1970 to 2000. */ struct saved_params { unsigned int valid; s64 rtc_diff; unsigned int av_multi_out; } static saved_params; static struct property property_rtc_diff = { .name = "linux,rtc_diff", .length = sizeof(saved_params.rtc_diff), .value = &saved_params.rtc_diff, }; static struct property property_av_multi_out = { .name = "linux,av_multi_out", .length = sizeof(saved_params.av_multi_out), .value = &saved_params.av_multi_out, }; static DEFINE_MUTEX(os_area_flash_mutex); static const struct ps3_os_area_flash_ops *os_area_flash_ops; void ps3_os_area_flash_register(const struct ps3_os_area_flash_ops *ops) { mutex_lock(&os_area_flash_mutex); os_area_flash_ops = ops; mutex_unlock(&os_area_flash_mutex); } EXPORT_SYMBOL_GPL(ps3_os_area_flash_register); static ssize_t os_area_flash_read(void *buf, size_t count, loff_t pos) { ssize_t res = -ENODEV; mutex_lock(&os_area_flash_mutex); if (os_area_flash_ops) res = os_area_flash_ops->read(buf, count, pos); mutex_unlock(&os_area_flash_mutex); return res; } static ssize_t os_area_flash_write(const void *buf, size_t count, loff_t pos) { ssize_t res = -ENODEV; mutex_lock(&os_area_flash_mutex); if (os_area_flash_ops) res = os_area_flash_ops->write(buf, count, pos); mutex_unlock(&os_area_flash_mutex); return res; } /** * os_area_set_property - Add or overwrite a saved_params value to the device tree. * * Overwrites an existing property. */ static void os_area_set_property(struct device_node *node, struct property *prop) { int result; struct property *tmp = of_find_property(node, prop->name, NULL); if (tmp) { pr_debug("%s:%d found %s\n", __func__, __LINE__, prop->name); of_remove_property(node, tmp); } result = of_add_property(node, prop); if (result) pr_debug("%s:%d of_set_property failed\n", __func__, __LINE__); } /** * os_area_get_property - Get a saved_params value from the device tree. * */ static void __init os_area_get_property(struct device_node *node, struct property *prop) { const struct property *tmp = of_find_property(node, prop->name, NULL); if (tmp) { BUG_ON(prop->length != tmp->length); memcpy(prop->value, tmp->value, prop->length); } else pr_debug("%s:%d not found %s\n", __func__, __LINE__, prop->name); } static void dump_field(char *s, const u8 *field, int size_of_field) { #if defined(DEBUG) int i; for (i = 0; i < size_of_field; i++) s[i] = isprint(field[i]) ? field[i] : '.'; s[i] = 0; #endif } #define dump_header(_a) _dump_header(_a, __func__, __LINE__) static void _dump_header(const struct os_area_header *h, const char *func, int line) { char str[sizeof(h->magic_num) + 1]; dump_field(str, h->magic_num, sizeof(h->magic_num)); pr_debug("%s:%d: h.magic_num: '%s'\n", func, line, str); pr_debug("%s:%d: h.hdr_version: %u\n", func, line, h->hdr_version); pr_debug("%s:%d: h.db_area_offset: %u\n", func, line, h->db_area_offset); pr_debug("%s:%d: h.ldr_area_offset: %u\n", func, line, h->ldr_area_offset); pr_debug("%s:%d: h.ldr_format: %u\n", func, line, h->ldr_format); pr_debug("%s:%d: h.ldr_size: %xh\n", func, line, h->ldr_size); } #define dump_params(_a) _dump_params(_a, __func__, __LINE__) static void _dump_params(const struct os_area_params *p, const char *func, int line) { pr_debug("%s:%d: p.boot_flag: %u\n", func, line, p->boot_flag); pr_debug("%s:%d: p.num_params: %u\n", func, line, p->num_params); pr_debug("%s:%d: p.rtc_diff %lld\n", func, line, p->rtc_diff); pr_debug("%s:%d: p.av_multi_out %u\n", func, line, p->av_multi_out); pr_debug("%s:%d: p.ctrl_button: %u\n", func, line, p->ctrl_button); pr_debug("%s:%d: p.static_ip_addr: %u.%u.%u.%u\n", func, line, p->static_ip_addr[0], p->static_ip_addr[1], p->static_ip_addr[2], p->static_ip_addr[3]); pr_debug("%s:%d: p.network_mask: %u.%u.%u.%u\n", func, line, p->network_mask[0], p->network_mask[1], p->network_mask[2], p->network_mask[3]); pr_debug("%s:%d: p.default_gateway: %u.%u.%u.%u\n", func, line, p->default_gateway[0], p->default_gateway[1], p->default_gateway[2], p->default_gateway[3]); pr_debug("%s:%d: p.dns_primary: %u.%u.%u.%u\n", func, line, p->dns_primary[0], p->dns_primary[1], p->dns_primary[2], p->dns_primary[3]); pr_debug("%s:%d: p.dns_secondary: %u.%u.%u.%u\n", func, line, p->dns_secondary[0], p->dns_secondary[1], p->dns_secondary[2], p->dns_secondary[3]); } static int verify_header(const struct os_area_header *header) { if (memcmp(header->magic_num, OS_AREA_HEADER_MAGIC_NUM, sizeof(header->magic_num))) { pr_debug("%s:%d magic_num failed\n", __func__, __LINE__); return -1; } if (header->hdr_version < 1) { pr_debug("%s:%d hdr_version failed\n", __func__, __LINE__); return -1; } if (header->db_area_offset > header->ldr_area_offset) { pr_debug("%s:%d offsets failed\n", __func__, __LINE__); return -1; } return 0; } static int db_verify(const struct os_area_db *db) { if (memcmp(db->magic_num, OS_AREA_DB_MAGIC_NUM, sizeof(db->magic_num))) { pr_debug("%s:%d magic_num failed\n", __func__, __LINE__); return -EINVAL; } if (db->version != 1) { pr_debug("%s:%d version failed\n", __func__, __LINE__); return -EINVAL; } return 0; } struct db_index { uint8_t owner:5; uint8_t key:3; }; struct db_iterator { const struct os_area_db *db; struct os_area_db_id match_id; struct db_index *idx; struct db_index *last_idx; union { uint64_t *value_64; uint32_t *value_32; uint16_t *value_16; }; }; static unsigned int db_align_up(unsigned int val, unsigned int size) { return (val + (size - 1)) & (~(size - 1)); } /** * db_for_each_64 - Iterator for 64 bit entries. * * A NULL value for id can be used to match all entries. * OS_AREA_DB_OWNER_ANY and OS_AREA_DB_KEY_ANY can be used to match all. */ static int db_for_each_64(const struct os_area_db *db, const struct os_area_db_id *match_id, struct db_iterator *i) { next: if (!i->db) { i->db = db; i->match_id = match_id ? *match_id : os_area_db_id_any; i->idx = (void *)db + db->index_64; i->last_idx = i->idx + db->count_64; i->value_64 = (void *)db + db->index_64 + db_align_up(db->count_64, 8); } else { i->idx++; i->value_64++; } if (i->idx >= i->last_idx) { pr_debug("%s:%d: reached end\n", __func__, __LINE__); return 0; } if (i->match_id.owner != OS_AREA_DB_OWNER_ANY && i->match_id.owner != (int)i->idx->owner) goto next; if (i->match_id.key != OS_AREA_DB_KEY_ANY && i->match_id.key != (int)i->idx->key) goto next; return 1; } static int db_delete_64(struct os_area_db *db, const struct os_area_db_id *id) { struct db_iterator i; for (i.db = NULL; db_for_each_64(db, id, &i); ) { pr_debug("%s:%d: got (%d:%d) %llxh\n", __func__, __LINE__, i.idx->owner, i.idx->key, (unsigned long long)*i.value_64); i.idx->owner = 0; i.idx->key = 0; *i.value_64 = 0; } return 0; } static int db_set_64(struct os_area_db *db, const struct os_area_db_id *id, uint64_t value) { struct db_iterator i; pr_debug("%s:%d: (%d:%d) <= %llxh\n", __func__, __LINE__, id->owner, id->key, (unsigned long long)value); if (!id->owner || id->owner == OS_AREA_DB_OWNER_ANY || id->key == OS_AREA_DB_KEY_ANY) { pr_debug("%s:%d: bad id: (%d:%d)\n", __func__, __LINE__, id->owner, id->key); return -1; } db_delete_64(db, id); i.db = NULL; if (db_for_each_64(db, &os_area_db_id_empty, &i)) { pr_debug("%s:%d: got (%d:%d) %llxh\n", __func__, __LINE__, i.idx->owner, i.idx->key, (unsigned long long)*i.value_64); i.idx->owner = id->owner; i.idx->key = id->key; *i.value_64 = value; pr_debug("%s:%d: set (%d:%d) <= %llxh\n", __func__, __LINE__, i.idx->owner, i.idx->key, (unsigned long long)*i.value_64); return 0; } pr_debug("%s:%d: database full.\n", __func__, __LINE__); return -1; } static int db_get_64(const struct os_area_db *db, const struct os_area_db_id *id, uint64_t *value) { struct db_iterator i; i.db = NULL; if (db_for_each_64(db, id, &i)) { *value = *i.value_64; pr_debug("%s:%d: found %lld\n", __func__, __LINE__, (long long int)*i.value_64); return 0; } pr_debug("%s:%d: not found\n", __func__, __LINE__); return -1; } static int db_get_rtc_diff(const struct os_area_db *db, int64_t *rtc_diff) { return db_get_64(db, &os_area_db_id_rtc_diff, (uint64_t*)rtc_diff); } #define dump_db(a) _dump_db(a, __func__, __LINE__) static void _dump_db(const struct os_area_db *db, const char *func, int line) { char str[sizeof(db->magic_num) + 1]; dump_field(str, db->magic_num, sizeof(db->magic_num)); pr_debug("%s:%d: db.magic_num: '%s'\n", func, line, str); pr_debug("%s:%d: db.version: %u\n", func, line, db->version); pr_debug("%s:%d: db.index_64: %u\n", func, line, db->index_64); pr_debug("%s:%d: db.count_64: %u\n", func, line, db->count_64); pr_debug("%s:%d: db.index_32: %u\n", func, line, db->index_32); pr_debug("%s:%d: db.count_32: %u\n", func, line, db->count_32); pr_debug("%s:%d: db.index_16: %u\n", func, line, db->index_16); pr_debug("%s:%d: db.count_16: %u\n", func, line, db->count_16); } static void os_area_db_init(struct os_area_db *db) { enum { HEADER_SIZE = offsetof(struct os_area_db, _db_data), INDEX_64_COUNT = 64, VALUES_64_COUNT = 57, INDEX_32_COUNT = 64, VALUES_32_COUNT = 57, INDEX_16_COUNT = 64, VALUES_16_COUNT = 57, }; memset(db, 0, sizeof(struct os_area_db)); memcpy(db->magic_num, OS_AREA_DB_MAGIC_NUM, sizeof(db->magic_num)); db->version = 1; db->index_64 = HEADER_SIZE; db->count_64 = VALUES_64_COUNT; db->index_32 = HEADER_SIZE + INDEX_64_COUNT * sizeof(struct db_index) + VALUES_64_COUNT * sizeof(u64); db->count_32 = VALUES_32_COUNT; db->index_16 = HEADER_SIZE + INDEX_64_COUNT * sizeof(struct db_index) + VALUES_64_COUNT * sizeof(u64) + INDEX_32_COUNT * sizeof(struct db_index) + VALUES_32_COUNT * sizeof(u32); db->count_16 = VALUES_16_COUNT; /* Rules to check db layout. */ BUILD_BUG_ON(sizeof(struct db_index) != 1); BUILD_BUG_ON(sizeof(struct os_area_db) != 2 * OS_AREA_SEGMENT_SIZE); BUILD_BUG_ON(INDEX_64_COUNT & 0x7); BUILD_BUG_ON(VALUES_64_COUNT > INDEX_64_COUNT); BUILD_BUG_ON(INDEX_32_COUNT & 0x7); BUILD_BUG_ON(VALUES_32_COUNT > INDEX_32_COUNT); BUILD_BUG_ON(INDEX_16_COUNT & 0x7); BUILD_BUG_ON(VALUES_16_COUNT > INDEX_16_COUNT); BUILD_BUG_ON(HEADER_SIZE + INDEX_64_COUNT * sizeof(struct db_index) + VALUES_64_COUNT * sizeof(u64) + INDEX_32_COUNT * sizeof(struct db_index) + VALUES_32_COUNT * sizeof(u32) + INDEX_16_COUNT * sizeof(struct db_index) + VALUES_16_COUNT * sizeof(u16) > sizeof(struct os_area_db)); } /** * update_flash_db - Helper for os_area_queue_work_handler. * */ static int update_flash_db(void) { const unsigned int buf_len = 8 * OS_AREA_SEGMENT_SIZE; struct os_area_header *header; ssize_t count; int error; loff_t pos; struct os_area_db* db; /* Read in header and db from flash. */ header = kmalloc(buf_len, GFP_KERNEL); if (!header) { pr_debug("%s: kmalloc failed\n", __func__); return -ENOMEM; } count = os_area_flash_read(header, buf_len, 0); if (count < 0) { pr_debug("%s: os_area_flash_read failed %zd\n", __func__, count); error = count; goto fail; } pos = header->db_area_offset * OS_AREA_SEGMENT_SIZE; if (count < OS_AREA_SEGMENT_SIZE || verify_header(header) || count < pos) { pr_debug("%s: verify_header failed\n", __func__); dump_header(header); error = -EINVAL; goto fail; } /* Now got a good db offset and some maybe good db data. */ db = (void *)header + pos; error = db_verify(db); if (error) { pr_notice("%s: Verify of flash database failed, formatting.\n", __func__); dump_db(db); os_area_db_init(db); } /* Now got good db data. */ db_set_64(db, &os_area_db_id_rtc_diff, saved_params.rtc_diff); count = os_area_flash_write(db, sizeof(struct os_area_db), pos); if (count < sizeof(struct os_area_db)) { pr_debug("%s: os_area_flash_write failed %zd\n", __func__, count); error = count < 0 ? count : -EIO; } fail: kfree(header); return error; } /** * os_area_queue_work_handler - Asynchronous write handler. * * An asynchronous write for flash memory and the device tree. Do not * call directly, use os_area_queue_work(). */ static void os_area_queue_work_handler(struct work_struct *work) { struct device_node *node; int error; pr_debug(" -> %s:%d\n", __func__, __LINE__); node = of_find_node_by_path("/"); if (node) { os_area_set_property(node, &property_rtc_diff); of_node_put(node); } else pr_debug("%s:%d of_find_node_by_path failed\n", __func__, __LINE__); error = update_flash_db(); if (error) pr_warning("%s: Could not update FLASH ROM\n", __func__); pr_debug(" <- %s:%d\n", __func__, __LINE__); } static void os_area_queue_work(void) { static DECLARE_WORK(q, os_area_queue_work_handler); wmb(); schedule_work(&q); } /** * ps3_os_area_save_params - Copy data from os area mirror to @saved_params. * * For the convenience of the guest the HV makes a copy of the os area in * flash to a high address in the boot memory region and then puts that RAM * address and the byte count into the repository for retrieval by the guest. * We copy the data we want into a static variable and allow the memory setup * by the HV to be claimed by the memblock manager. * * The os area mirror will not be available to a second stage kernel, and * the header verify will fail. In this case, the saved_params values will * be set from flash memory or the passed in device tree in ps3_os_area_init(). */ void __init ps3_os_area_save_params(void) { int result; u64 lpar_addr; unsigned int size; struct os_area_header *header; struct os_area_params *params; struct os_area_db *db; pr_debug(" -> %s:%d\n", __func__, __LINE__); result = ps3_repository_read_boot_dat_info(&lpar_addr, &size); if (result) { pr_debug("%s:%d ps3_repository_read_boot_dat_info failed\n", __func__, __LINE__); return; } header = (struct os_area_header *)__va(lpar_addr); params = (struct os_area_params *)__va(lpar_addr + OS_AREA_SEGMENT_SIZE); result = verify_header(header); if (result) { /* Second stage kernels exit here. */ pr_debug("%s:%d verify_header failed\n", __func__, __LINE__); dump_header(header); return; } db = (struct os_area_db *)__va(lpar_addr + header->db_area_offset * OS_AREA_SEGMENT_SIZE); dump_header(header); dump_params(params); dump_db(db); result = db_verify(db) || db_get_rtc_diff(db, &saved_params.rtc_diff); if (result) saved_params.rtc_diff = params->rtc_diff ? params->rtc_diff : SECONDS_FROM_1970_TO_2000; saved_params.av_multi_out = params->av_multi_out; saved_params.valid = 1; memset(header, 0, sizeof(*header)); pr_debug(" <- %s:%d\n", __func__, __LINE__); } /** * ps3_os_area_init - Setup os area device tree properties as needed. */ void __init ps3_os_area_init(void) { struct device_node *node; pr_debug(" -> %s:%d\n", __func__, __LINE__); node = of_find_node_by_path("/"); if (!saved_params.valid && node) { /* Second stage kernels should have a dt entry. */ os_area_get_property(node, &property_rtc_diff); os_area_get_property(node, &property_av_multi_out); } if(!saved_params.rtc_diff) saved_params.rtc_diff = SECONDS_FROM_1970_TO_2000; if (node) { os_area_set_property(node, &property_rtc_diff); os_area_set_property(node, &property_av_multi_out); of_node_put(node); } else pr_debug("%s:%d of_find_node_by_path failed\n", __func__, __LINE__); pr_debug(" <- %s:%d\n", __func__, __LINE__); } /** * ps3_os_area_get_rtc_diff - Returns the rtc diff value. */ u64 ps3_os_area_get_rtc_diff(void) { return saved_params.rtc_diff; } EXPORT_SYMBOL_GPL(ps3_os_area_get_rtc_diff); /** * ps3_os_area_set_rtc_diff - Set the rtc diff value. * * An asynchronous write is needed to support writing updates from * the timer interrupt context. */ void ps3_os_area_set_rtc_diff(u64 rtc_diff) { if (saved_params.rtc_diff != rtc_diff) { saved_params.rtc_diff = rtc_diff; os_area_queue_work(); } } EXPORT_SYMBOL_GPL(ps3_os_area_set_rtc_diff); /** * ps3_os_area_get_av_multi_out - Returns the default video mode. */ enum ps3_param_av_multi_out ps3_os_area_get_av_multi_out(void) { return saved_params.av_multi_out; } EXPORT_SYMBOL_GPL(ps3_os_area_get_av_multi_out);
7f8b9cefa65c2a70a8b97d2063dd5c36cd427029
4bd36a0d1af75dd8a0386fb14fcf8114ed758b99
/scripts-for-manuscript/figure4/src/bgzf-mean/mean.c
faffbfd42036a6f710060de8fc7295b24756f38c
[ "MIT" ]
permissive
38/d4-format
6d36b628cee813260f36945f13eba8b2add7072f
945b36b46e0d22bf5e1d1ebbf7f7a59b9470fdd4
refs/heads/master
2023-08-14T21:20:25.967487
2023-07-29T14:05:48
2023-07-29T14:05:48
248,287,897
146
18
MIT
2022-11-18T07:17:47
2020-03-18T16:42:42
Rust
UTF-8
C
false
false
928
c
mean.c
#include <htslib/bgzf.h> #include <stdio.h> int main(int argc, char** argv) { BGZF* fp = bgzf_open(argv[1], "r"); bgzf_set_cache_size(fp, 102400); char buffer[4097] = {}; int bytes_can_read = 0; int bytes_read = 0; double sum = 0; double size = 0; while((bytes_read = bgzf_read(fp, buffer + bytes_can_read, 4096 - bytes_can_read)) > 0) { bytes_can_read += bytes_read; const char* ptr; const char* last_line = buffer; int ws_count = 0; long long begin, end, value; char name[32]; for(ptr = buffer; ptr < buffer + bytes_can_read; ptr ++) { if(*ptr == '\n') { sscanf(last_line, "%s%lld%lld%lld", name, &begin, &end, &value); sum += value * (end - begin); size += end - begin; last_line = ptr + 1; ws_count = 0; } } bytes_can_read -= last_line - buffer; memmove(buffer, last_line, bytes_can_read); } bgzf_close(fp); printf("%lf\n", sum / size); return 0; }
bdbccca2d10bc4b404c36a5a8d5ac2d632d92666
75196819c910f3fd523f1a4d28e5d0fe12570ab1
/src/bdb53/src/db/db_reclaim.c
d7d32dc9f4c43dbfa12ad6043a6059e5f0829385
[ "MIT", "BSD-3-Clause", "Sleepycat" ]
permissive
gridcoin-community/Gridcoin-Research
889967579b5b05bcc3ae836697a0f173b5ae91ea
21414dd0f63c9a34060f7f762f08d1a52aeb9e87
refs/heads/development
2023-09-04T09:21:55.006935
2023-09-03T17:45:20
2023-09-03T17:45:20
23,332,350
292
117
MIT
2023-09-11T10:22:10
2014-08-25T23:41:04
HTML
UTF-8
C
false
false
6,035
c
db_reclaim.c
/*- * See the file LICENSE for redistribution information. * * Copyright (c) 1996, 2013 Oracle and/or its affiliates. All rights reserved. * * $Id$ */ #include "db_config.h" #include "db_int.h" #include "dbinc/db_page.h" #include "dbinc/btree.h" #include "dbinc/mp.h" /* * __db_traverse_big * Traverse a chain of overflow pages and call the callback routine * on each one. The calling convention for the callback is: * callback(dbc, page, cookie, did_put), * where did_put is a return value indicating if the page in question has * already been returned to the mpool. * * PUBLIC: int __db_traverse_big __P((DBC *, db_pgno_t, * PUBLIC: int (*)(DBC *, PAGE *, void *, int *), void *)); */ int __db_traverse_big(dbc, pgno, callback, cookie) DBC *dbc; db_pgno_t pgno; int (*callback) __P((DBC *, PAGE *, void *, int *)); void *cookie; { DB_MPOOLFILE *mpf; PAGE *p; int did_put, ret; mpf = dbc->dbp->mpf; do { did_put = 0; if ((ret = __memp_fget(mpf, &pgno, dbc->thread_info, dbc->txn, 0, &p)) != 0) return (ret); /* * If we are freeing pages only process the overflow * chain if the head of the chain has a refcount of 1. */ pgno = NEXT_PGNO(p); if (callback == __db_truncate_callback && OV_REF(p) != 1) pgno = PGNO_INVALID; if ((ret = callback(dbc, p, cookie, &did_put)) == 0 && !did_put) ret = __memp_fput(mpf, dbc->thread_info, p, dbc->priority); } while (ret == 0 && pgno != PGNO_INVALID); return (ret); } /* * __db_reclaim_callback * This is the callback routine used during a delete of a subdatabase. * we are traversing a btree or hash table and trying to free all the * pages. Since they share common code for duplicates and overflow * items, we traverse them identically and use this routine to do the * actual free. The reason that this is callback is because hash uses * the same traversal code for statistics gathering. * * PUBLIC: int __db_reclaim_callback __P((DBC *, PAGE *, void *, int *)); */ int __db_reclaim_callback(dbc, p, cookie, putp) DBC *dbc; PAGE *p; void *cookie; int *putp; { DB *dbp; int ret; dbp = dbc->dbp; /* * We don't want to log the free of the root with the subdb. * If we abort then the subdb may not be openable to undo * the free. */ if ((dbp->type == DB_BTREE || dbp->type == DB_RECNO) && PGNO(p) == ((BTREE *)dbp->bt_internal)->bt_root) return (0); if ((ret = __db_free(dbc, p, *(u_int32_t *)cookie)) != 0) return (ret); *putp = 1; return (0); } /* * __db_truncate_callback * This is the callback routine used during a truncate. * we are traversing a btree or hash table and trying to free all the * pages. * * PUBLIC: int __db_truncate_callback __P((DBC *, PAGE *, void *, int *)); */ int __db_truncate_callback(dbc, p, cookie, putp) DBC *dbc; PAGE *p; void *cookie; int *putp; { DB *dbp; DBT ddbt, ldbt; DB_MPOOLFILE *mpf; db_indx_t indx, len, off, tlen, top; u_int8_t *hk, type; u_int32_t *countp; int ret; top = NUM_ENT(p); dbp = dbc->dbp; mpf = dbp->mpf; countp = cookie; *putp = 1; switch (TYPE(p)) { case P_LBTREE: /* Skip for off-page duplicates and deleted items. */ for (indx = 0; indx < top; indx += P_INDX) { type = GET_BKEYDATA(dbp, p, indx + O_INDX)->type; if (!B_DISSET(type) && B_TYPE(type) != B_DUPLICATE) ++*countp; } /* FALLTHROUGH */ case P_IBTREE: case P_IRECNO: case P_INVALID: if (dbp->type != DB_HASH && ((BTREE *)dbp->bt_internal)->bt_root == PGNO(p)) { type = dbp->type == DB_RECNO ? P_LRECNO : P_LBTREE; goto reinit; } break; case P_OVERFLOW: if ((ret = __memp_dirty(mpf, &p, dbc->thread_info, dbc->txn, dbc->priority, 0)) != 0) return (ret); if (DBC_LOGGING(dbc)) { if ((ret = __db_ovref_log(dbp, dbc->txn, &LSN(p), 0, p->pgno, -1, &LSN(p))) != 0) return (ret); } else LSN_NOT_LOGGED(LSN(p)); if (--OV_REF(p) != 0) *putp = 0; break; case P_LRECNO: for (indx = 0; indx < top; indx += O_INDX) { type = GET_BKEYDATA(dbp, p, indx)->type; if (!B_DISSET(type)) ++*countp; } if (((BTREE *)dbp->bt_internal)->bt_root == PGNO(p)) { type = P_LRECNO; goto reinit; } break; case P_LDUP: /* Correct for deleted items. */ for (indx = 0; indx < top; indx += O_INDX) if (!B_DISSET(GET_BKEYDATA(dbp, p, indx)->type)) ++*countp; break; case P_HASH: /* Correct for on-page duplicates and deleted items. */ for (indx = 0; indx < top; indx += P_INDX) { switch (*H_PAIRDATA(dbp, p, indx)) { case H_OFFDUP: break; case H_OFFPAGE: case H_KEYDATA: ++*countp; break; case H_DUPLICATE: tlen = LEN_HDATA(dbp, p, 0, indx); hk = H_PAIRDATA(dbp, p, indx); for (off = 0; off < tlen; off += len + 2 * sizeof(db_indx_t)) { ++*countp; memcpy(&len, HKEYDATA_DATA(hk) + off, sizeof(db_indx_t)); } break; default: return (__db_pgfmt(dbp->env, p->pgno)); } } /* Don't free the head of the bucket. */ if (PREV_PGNO(p) == PGNO_INVALID) { type = P_HASH; reinit: if ((ret = __memp_dirty(mpf, &p, dbc->thread_info, dbc->txn, dbc->priority, 0)) != 0) return (ret); *putp = 0; if (DBC_LOGGING(dbc)) { memset(&ldbt, 0, sizeof(ldbt)); memset(&ddbt, 0, sizeof(ddbt)); ldbt.data = p; ldbt.size = P_OVERHEAD(dbp); ldbt.size += p->entries * sizeof(db_indx_t); ddbt.data = (u_int8_t *)p + HOFFSET(p); ddbt.size = dbp->pgsize - HOFFSET(p); if ((ret = __db_pg_init_log(dbp, dbc->txn, &LSN(p), 0, p->pgno, &ldbt, &ddbt)) != 0) return (ret); } else LSN_NOT_LOGGED(LSN(p)); P_INIT(p, dbp->pgsize, PGNO(p), PGNO_INVALID, PGNO_INVALID, type == P_HASH ? 0 : 1, type); } break; default: return (__db_pgfmt(dbp->env, p->pgno)); } if (*putp == 1) { if ((ret = __db_free(dbc, p, 0)) != 0) return (ret); } else { if ((ret = __memp_fput(mpf, dbc->thread_info, p, dbc->priority)) != 0) return (ret); *putp = 1; } return (0); }
ba5e3914eb50db6d0a6b7193abda639b20d6e06f
0882ed3c9e1078a8f69a1fc720d2c05c9289dd23
/src/bin/exrenvmap/makeCubeMap.h
56ad127009ca49a8c590bdc73087a783e56633e9
[ "BSD-3-Clause", "LicenseRef-scancode-generic-cla" ]
permissive
AcademySoftwareFoundation/openexr
846500ee441cc7b60d717ca4377050c55949ecde
1ee0ffec3a499ac8bae1ad7e5eff60571d1d83de
refs/heads/main
2023-09-01T11:33:55.842765
2023-08-31T20:30:32
2023-08-31T20:30:32
3,533,348
782
281
BSD-3-Clause
2023-09-14T20:59:10
2012-02-24T06:30:00
C
UTF-8
C
false
false
1,041
h
makeCubeMap.h
// // SPDX-License-Identifier: BSD-3-Clause // Copyright (c) Contributors to the OpenEXR Project. // #ifndef INCLUDED_MAKE_CUBE_MAP_H #define INCLUDED_MAKE_CUBE_MAP_H //----------------------------------------------------------------------------- // // function makeCubeMap() -- makes cube-face environment maps // //----------------------------------------------------------------------------- #include "namespaceAlias.h" #include "readInputImage.h" #include <ImfCompression.h> #include <ImfTileDescription.h> void makeCubeMap ( EnvmapImage& image, IMF::Header& header, IMF::RgbaChannels channels, const char outFileName[], int tileWidth, int tileHeight, IMF::LevelMode levelMode, IMF::LevelRoundingMode roundingMode, IMF::Compression compression, int mapWidth, float filterRadius, int numSamples, bool verbose); #endif
476f5a67e8c0eac43bdf7451771b32bbf212ed2c
1231379e557a3094413045721b4c65ce9bae568b
/src/core/send_buffer.h
3d1735b90c3926c3abc2e0a5c07cb3cb47c405fe
[ "MIT" ]
permissive
microsoft/msquic
a63982f1b7d017fb0497e2dce56f1ef527bd6eaa
f91ccc2f975225a278bc68238555ed0923e676ba
refs/heads/main
2023-09-04T01:25:39.133074
2023-08-28T18:04:51
2023-08-28T18:04:51
217,654,199
3,641
521
MIT
2023-09-14T14:36:09
2019-10-26T04:10:24
C
UTF-8
C
false
false
1,932
h
send_buffer.h
/*++ Copyright (c) Microsoft Corporation. Licensed under the MIT License. --*/ typedef struct QUIC_SEND_BUFFER { // // Sum of bytes over all send requests (both buffered // and unbuffered requests). This is a useful diagnostic // counter for cases when throughput is starved by an // app that is sending too slowly. // uint64_t PostedBytes; // // Sum of bytes in buffered requests. This is tracked so that // IdealBytes can be used as a soft limit on buffering. // uint64_t BufferedBytes; // // The number of bytes that need to be available in the send // buffer to avoid limiting throughput. // uint64_t IdealBytes; } QUIC_SEND_BUFFER; _IRQL_requires_max_(DISPATCH_LEVEL) void QuicSendBufferInitialize( _Inout_ QUIC_SEND_BUFFER* SendBuffer ); _IRQL_requires_max_(DISPATCH_LEVEL) void QuicSendBufferUninitialize( _In_ QUIC_SEND_BUFFER* SendBuffer ); _IRQL_requires_max_(DISPATCH_LEVEL) _Success_(return != NULL) uint8_t* QuicSendBufferAlloc( _Inout_ QUIC_SEND_BUFFER* SendBuffer, _In_ uint32_t Size ); // // Caller must pass the same size that was passed to QuicSendBufferAlloc. // _IRQL_requires_max_(DISPATCH_LEVEL) void QuicSendBufferFree( _Inout_ QUIC_SEND_BUFFER* SendBuffer, _In_ uint8_t* Buf, _In_ uint32_t Size ); // // Buffers pending send requests until the send buffer is full. // Should be called when the send buffer is adjusted or bytes are ACKed. // _IRQL_requires_max_(PASSIVE_LEVEL) void QuicSendBufferFill( _In_ QUIC_CONNECTION* Connection ); // // Indicates an ISB update to the stream. // _IRQL_requires_max_(PASSIVE_LEVEL) void QuicSendBufferStreamAdjust( _In_ QUIC_STREAM* Stream ); // // Updates IdealBytes upon change of BytesInFlightMax. // _IRQL_requires_max_(PASSIVE_LEVEL) void QuicSendBufferConnectionAdjust( _In_ QUIC_CONNECTION* Connection );
3d32013d7be722aab966c9324c11f29113515726
ea5e2bb5a7ee24f78be9ee4d65bb064c324e7132
/src/dictionary/ion_master_table.h
5e9cfa468480d1fbaafc32a9cb8c55bff2ec8387
[ "BSD-3-Clause", "MPL-2.0", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-unknown-license-reference" ]
permissive
iondbproject/iondb
55163c283ce0478ecf21c13f04e814d94a95944a
cb5fb680f14251a83328f656e40b7dc39113a065
refs/heads/development
2023-08-11T04:32:35.302095
2022-12-30T18:49:52
2022-12-30T18:49:52
31,342,455
648
65
BSD-3-Clause
2022-12-30T18:49:53
2015-02-26T00:07:10
C
UTF-8
C
false
false
9,989
h
ion_master_table.h
/******************************************************************************/ /** @file ion_master_table.h @author Eric Huang, Graeme Douglas, Scott Fazackerley, Wade Penson @brief Master table API. @details At compile time, the master table is either used, OR it is not included at all. The directive, ION_USING_MASTER_TABLE controls this. If the master table is used, the assumption is that the user does not bypass the master table and call dictionary_create directly. If the master table is not used, the user must provide IDs directly to dictionary creation and the onus is on the user to resolve conflicts, if they occur. @copyright Copyright 2017 The University of British Columbia, IonDB Project Contributors (see AUTHORS.md) @par Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @par 1.Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. @par 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. @par 3.Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. @par THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /******************************************************************************/ #if !defined(ION_MASTER_TABLE_H_) #define ION_MASTER_TABLE_H_ #if defined(__cplusplus) extern "C" { #endif #include "dictionary.h" #include "../file/sd_stdio_c_iface.h" #include "../file/kv_stdio_intercept.h" #include "bpp_tree/bpp_tree_handler.h" #include "flat_file/flat_file_dictionary_handler.h" #include "open_address_file_hash/open_address_file_hash_dictionary_handler.h" #include "open_address_hash/open_address_hash_dictionary_handler.h" #include "skip_list/skip_list_handler.h" #include "linear_hash/linear_hash_handler.h" #define ION_MASTER_TABLE_CALCULATE_POS -1 #define ION_MASTER_TABLE_WRITE_FROM_END -2 #define ION_MASTER_TABLE_RECORD_SIZE(cp) (sizeof((cp)->id) + sizeof((cp)->use_type) + sizeof((cp)->type) + sizeof((cp)->key_size) + sizeof((cp)->value_size) + sizeof((cp)->dictionary_size) + sizeof((cp)->dictionary_type) + sizeof((cp)->dictionary_status)) #if ION_USING_MASTER_TABLE /** @brief File name for IonDB master table. @details Needs to be relatively short for devices. */ #define ION_MASTER_TABLE_FILENAME "ion_mt.tbl" /** @brief ID of the master table. */ #define ION_MASTER_TABLE_ID 0 /** @brief Flag used when searching master table; search for first instance matching criteria. */ #define ION_MASTER_TABLE_FIND_FIRST 1 /** @brief Flag used when searching master table; search for last instance matching criteria. */ #define ION_MASTER_TABLE_FIND_LAST -1 /** @brief Master table resposible for managing instances. */ extern ion_dictionary_id_t ion_master_table_next_id; /** @brief Master table file. */ extern FILE *ion_master_table_file; /** @brief Write a record to the master table. @details Automatically, this call will reposition the file position back to where it was once the call is complete. @param[in] config A pointer to a previously allocated config object to write from. @param[in] where An integral value representing where to write to in the file. This file offset is byte-aligned, not record aligned, in general. Two special flags can be passed in here: - @c ION_MASTER_TABLE_CALCULATE_POS Calculate the position based on the passed-in config id. - @c ION_MASTER_TABLE_WRITE_FROM_END Write the record at the end of the file. @returns An error code describing the result of the call. */ ion_err_t ion_master_table_write( ion_dictionary_config_info_t *config, long where ); /** @brief Opens the master table. @details Can be safely called multiple times without closing. */ ion_err_t ion_init_master_table( void ); /** @brief Closes the master table. */ ion_err_t ion_close_master_table( void ); /** @brief Closes the master table and all dictionary instances within it. @details For this method to work properly, all dictionary instances must already be closed or must have been closed previously and are now re-opened. */ ion_err_t ion_close_all_master_table( void ); /** @brief Deletes the master table. */ ion_err_t ion_delete_master_table( void ); /** @brief Creates a dictionary through use of the master table. @param handler A pointer to an allocated and initialized dictionary handler object that contains all implementation specific data and function pointers. @param dictionary A pointer to an allocated dictionary object, which will be written into when opened. @param key_type The type of key to be used with this dictionary, which determines the key comparison operator. @param key_size The size of the key type to be used with this dictionary. @param value_size The size of the value type to be used with this dictionary. @param dictionary_size The dictionary implementation specific dictionary size parameter. @returns An error code describing the result of the operation. */ ion_err_t ion_master_table_create_dictionary( ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_key_type_t key_type, ion_key_size_t key_size, ion_value_size_t value_size, ion_dictionary_size_t dictionary_size ); /** @brief Looks up the config of the given id. @param id The identifier identifying the dictionary metadata in the master table which is to be looked up. @param config A pointer to an already allocated configuration object that will be read into from the master table. */ ion_err_t ion_lookup_in_master_table( ion_dictionary_id_t id, ion_dictionary_config_info_t *config ); /** @brief Find first or last dictionary in master table with a given use. @param config A pointer to an already allocated configuration object that will be used to open the found dictionary. @param use_type The integral usage type for the dictionary. This is user defined. @param whence Whether to find the first or the last dictionary having @p use_type. This can take exactly two values, @ref ION_MASTER_TABLE_FIND_FIRST or @ref ION_MASTER_TABLE_FIND_LAST. @returns @c err_ok if a dictionary having usage type @p use_type is found, otherwise an error code properly describing the situation and outcome. */ ion_err_t ion_find_by_use_master_table( ion_dictionary_config_info_t *config, ion_dict_use_t use_type, char whence ); /** @brief Deletes a dictionary from the master table. @param id The identifier identifying the dictionary metadata in the master table. @returns An error code describing the result of the operation. */ ion_err_t ion_delete_from_master_table( ion_dictionary_id_t id ); /** @brief Finds the target dictionary and opens it. @param handler A pointer to the handler object to be initialized. @param dictionary A pointer to the dictionary object to open. @param id The identifier identifying the dictionary metadata in the master table. @returns An error code describing the result of the operation. */ ion_err_t ion_open_dictionary( ion_dictionary_handler_t *handler, ion_dictionary_t *dictionary, ion_dictionary_id_t id ); /** @brief Closes a given dictionary. @param dictionary A pointer to the dictionary object to close. */ ion_err_t ion_close_dictionary( ion_dictionary_t *dictionary ); /** @brief Deletes a given dictionary instance and deletes it from the master table. @param dictionary A pointer to the dictionary object to delete. @param id The identifier identifying the dictionary metadata in the master table. Required to delete a closed dictionary without reopening it. */ ion_err_t ion_delete_dictionary( ion_dictionary_t *dictionary, ion_dictionary_id_t id ); /** @brief Retrieves the type of dictionary stored under a particular id in the master table. @param type The type of dictionary instance to initialize the handler to. @param handler A pointer to the handler to be set. @returns An error code describing the result of the operation. */ ion_err_t ion_switch_handler( ion_dictionary_type_t type, ion_dictionary_handler_t *handler ); /** @brief Returns the next dictionary ID, then increments. @param id An identifier pointer to be written into. @returns An error code describing the result of the operation. */ ion_err_t ion_master_table_get_next_id( ion_dictionary_id_t *id ); /** @brief Retrieves the type of dictionary stored under a particular id in the master table. @param id The identifier identifying the dictionary metadata in the master table. @returns The type of dictionary implementation corresponding to the id. */ ion_dictionary_type_t ion_get_dictionary_type( ion_dictionary_id_t id ); #if defined(__cplusplus) } #endif /* C++ Guard */ #endif /* ION_USING_MASTER_TABLE */ #endif /* ION_MASTER_TABLE_H_ */
8e9d9b2e26758f9b85d25d85ce1200de5e2ea4e5
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/drivers/misc/vmw_vmci/vmci_host.c
d4722b3dc8ec762987f18d25268727ea9954b32c
[ "LicenseRef-scancode-free-unknown", "Apache-2.0", "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
28,371
c
vmci_host.c
/* * VMware VMCI Driver * * Copyright (C) 2012 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation version 2 and no later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. */ #include <linux/vmw_vmci_defs.h> #include <linux/vmw_vmci_api.h> #include <linux/moduleparam.h> #include <linux/miscdevice.h> #include <linux/interrupt.h> #include <linux/highmem.h> #include <linux/atomic.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/mutex.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/file.h> #include <linux/init.h> #include <linux/poll.h> #include <linux/pci.h> #include <linux/smp.h> #include <linux/fs.h> #include <linux/io.h> #include "vmci_handle_array.h" #include "vmci_queue_pair.h" #include "vmci_datagram.h" #include "vmci_doorbell.h" #include "vmci_resource.h" #include "vmci_context.h" #include "vmci_driver.h" #include "vmci_event.h" #define VMCI_UTIL_NUM_RESOURCES 1 enum { VMCI_NOTIFY_RESOURCE_QUEUE_PAIR = 0, VMCI_NOTIFY_RESOURCE_DOOR_BELL = 1, }; enum { VMCI_NOTIFY_RESOURCE_ACTION_NOTIFY = 0, VMCI_NOTIFY_RESOURCE_ACTION_CREATE = 1, VMCI_NOTIFY_RESOURCE_ACTION_DESTROY = 2, }; /* * VMCI driver initialization. This block can also be used to * pass initial group membership etc. */ struct vmci_init_blk { u32 cid; u32 flags; }; /* VMCIqueue_pairAllocInfo_VMToVM */ struct vmci_qp_alloc_info_vmvm { struct vmci_handle handle; u32 peer; u32 flags; u64 produce_size; u64 consume_size; u64 produce_page_file; /* User VA. */ u64 consume_page_file; /* User VA. */ u64 produce_page_file_size; /* Size of the file name array. */ u64 consume_page_file_size; /* Size of the file name array. */ s32 result; u32 _pad; }; /* VMCISetNotifyInfo: Used to pass notify flag's address to the host driver. */ struct vmci_set_notify_info { u64 notify_uva; s32 result; u32 _pad; }; /* * Per-instance host state */ struct vmci_host_dev { struct vmci_ctx *context; int user_version; enum vmci_obj_type ct_type; struct mutex lock; /* Mutex lock for vmci context access */ }; static struct vmci_ctx *host_context; static bool vmci_host_device_initialized; static atomic_t vmci_host_active_users = ATOMIC_INIT(0); /* * Determines whether the VMCI host personality is * available. Since the core functionality of the host driver is * always present, all guests could possibly use the host * personality. However, to minimize the deviation from the * pre-unified driver state of affairs, we only consider the host * device active if there is no active guest device or if there * are VMX'en with active VMCI contexts using the host device. */ bool vmci_host_code_active(void) { return vmci_host_device_initialized && (!vmci_guest_code_active() || atomic_read(&vmci_host_active_users) > 0); } /* * Called on open of /dev/vmci. */ static int vmci_host_open(struct inode *inode, struct file *filp) { struct vmci_host_dev *vmci_host_dev; vmci_host_dev = kzalloc(sizeof(struct vmci_host_dev), GFP_KERNEL); if (vmci_host_dev == NULL) return -ENOMEM; vmci_host_dev->ct_type = VMCIOBJ_NOT_SET; mutex_init(&vmci_host_dev->lock); filp->private_data = vmci_host_dev; return 0; } /* * Called on close of /dev/vmci, most often when the process * exits. */ static int vmci_host_close(struct inode *inode, struct file *filp) { struct vmci_host_dev *vmci_host_dev = filp->private_data; if (vmci_host_dev->ct_type == VMCIOBJ_CONTEXT) { vmci_ctx_destroy(vmci_host_dev->context); vmci_host_dev->context = NULL; /* * The number of active contexts is used to track whether any * VMX'en are using the host personality. It is incremented when * a context is created through the IOCTL_VMCI_INIT_CONTEXT * ioctl. */ atomic_dec(&vmci_host_active_users); } vmci_host_dev->ct_type = VMCIOBJ_NOT_SET; kfree(vmci_host_dev); filp->private_data = NULL; return 0; } /* * This is used to wake up the VMX when a VMCI call arrives, or * to wake up select() or poll() at the next clock tick. */ static unsigned int vmci_host_poll(struct file *filp, poll_table *wait) { struct vmci_host_dev *vmci_host_dev = filp->private_data; struct vmci_ctx *context = vmci_host_dev->context; unsigned int mask = 0; if (vmci_host_dev->ct_type == VMCIOBJ_CONTEXT) { /* Check for VMCI calls to this VM context. */ if (wait) poll_wait(filp, &context->host_context.wait_queue, wait); spin_lock(&context->lock); if (context->pending_datagrams > 0 || vmci_handle_arr_get_size( context->pending_doorbell_array) > 0) { mask = POLLIN; } spin_unlock(&context->lock); } return mask; } /* * Copies the handles of a handle array into a user buffer, and * returns the new length in userBufferSize. If the copy to the * user buffer fails, the functions still returns VMCI_SUCCESS, * but retval != 0. */ static int drv_cp_harray_to_user(void __user *user_buf_uva, u64 *user_buf_size, struct vmci_handle_arr *handle_array, int *retval) { u32 array_size = 0; struct vmci_handle *handles; if (handle_array) array_size = vmci_handle_arr_get_size(handle_array); if (array_size * sizeof(*handles) > *user_buf_size) return VMCI_ERROR_MORE_DATA; *user_buf_size = array_size * sizeof(*handles); if (*user_buf_size) *retval = copy_to_user(user_buf_uva, vmci_handle_arr_get_handles (handle_array), *user_buf_size); return VMCI_SUCCESS; } /* * Sets up a given context for notify to work. Calls drv_map_bool_ptr() * which maps the notify boolean in user VA in kernel space. */ static int vmci_host_setup_notify(struct vmci_ctx *context, unsigned long uva) { struct page *page; int retval; if (context->notify_page) { pr_devel("%s: Notify mechanism is already set up\n", __func__); return VMCI_ERROR_DUPLICATE_ENTRY; } /* * We are using 'bool' internally, but let's make sure we explicit * about the size. */ BUILD_BUG_ON(sizeof(bool) != sizeof(u8)); if (!access_ok(VERIFY_WRITE, (void __user *)uva, sizeof(u8))) return VMCI_ERROR_GENERIC; /* * Lock physical page backing a given user VA. */ down_read(&current->mm->mmap_sem); retval = get_user_pages(current, current->mm, PAGE_ALIGN(uva), 1, 1, 0, &page, NULL); up_read(&current->mm->mmap_sem); if (retval != 1) return VMCI_ERROR_GENERIC; /* * Map the locked page and set up notify pointer. */ context->notify = kmap(page) + (uva & (PAGE_SIZE - 1)); vmci_ctx_check_signal_notify(context); return VMCI_SUCCESS; } static int vmci_host_get_version(struct vmci_host_dev *vmci_host_dev, unsigned int cmd, void __user *uptr) { if (cmd == IOCTL_VMCI_VERSION2) { int __user *vptr = uptr; if (get_user(vmci_host_dev->user_version, vptr)) return -EFAULT; } /* * The basic logic here is: * * If the user sends in a version of 0 tell it our version. * If the user didn't send in a version, tell it our version. * If the user sent in an old version, tell it -its- version. * If the user sent in an newer version, tell it our version. * * The rationale behind telling the caller its version is that * Workstation 6.5 required that VMX and VMCI kernel module were * version sync'd. All new VMX users will be programmed to * handle the VMCI kernel module version. */ if (vmci_host_dev->user_version > 0 && vmci_host_dev->user_version < VMCI_VERSION_HOSTQP) { return vmci_host_dev->user_version; } return VMCI_VERSION; } #define vmci_ioctl_err(fmt, ...) \ pr_devel("%s: " fmt, ioctl_name, ##__VA_ARGS__) static int vmci_host_do_init_context(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_init_blk init_block; const struct cred *cred; int retval; if (copy_from_user(&init_block, uptr, sizeof(init_block))) { vmci_ioctl_err("error reading init block\n"); return -EFAULT; } mutex_lock(&vmci_host_dev->lock); if (vmci_host_dev->ct_type != VMCIOBJ_NOT_SET) { vmci_ioctl_err("received VMCI init on initialized handle\n"); retval = -EINVAL; goto out; } if (init_block.flags & ~VMCI_PRIVILEGE_FLAG_RESTRICTED) { vmci_ioctl_err("unsupported VMCI restriction flag\n"); retval = -EINVAL; goto out; } cred = get_current_cred(); vmci_host_dev->context = vmci_ctx_create(init_block.cid, init_block.flags, 0, vmci_host_dev->user_version, cred); put_cred(cred); if (IS_ERR(vmci_host_dev->context)) { retval = PTR_ERR(vmci_host_dev->context); vmci_ioctl_err("error initializing context\n"); goto out; } /* * Copy cid to userlevel, we do this to allow the VMX * to enforce its policy on cid generation. */ init_block.cid = vmci_ctx_get_id(vmci_host_dev->context); if (copy_to_user(uptr, &init_block, sizeof(init_block))) { vmci_ctx_destroy(vmci_host_dev->context); vmci_host_dev->context = NULL; vmci_ioctl_err("error writing init block\n"); retval = -EFAULT; goto out; } vmci_host_dev->ct_type = VMCIOBJ_CONTEXT; atomic_inc(&vmci_host_active_users); retval = 0; out: mutex_unlock(&vmci_host_dev->lock); return retval; } static int vmci_host_do_send_datagram(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_datagram_snd_rcv_info send_info; struct vmci_datagram *dg = NULL; u32 cid; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&send_info, uptr, sizeof(send_info))) return -EFAULT; if (send_info.len > VMCI_MAX_DG_SIZE) { vmci_ioctl_err("datagram is too big (size=%d)\n", send_info.len); return -EINVAL; } if (send_info.len < sizeof(*dg)) { vmci_ioctl_err("datagram is too small (size=%d)\n", send_info.len); return -EINVAL; } dg = kmalloc(send_info.len, GFP_KERNEL); if (!dg) { vmci_ioctl_err( "cannot allocate memory to dispatch datagram\n"); return -ENOMEM; } if (copy_from_user(dg, (void __user *)(uintptr_t)send_info.addr, send_info.len)) { vmci_ioctl_err("error getting datagram\n"); kfree(dg); return -EFAULT; } pr_devel("Datagram dst (handle=0x%x:0x%x) src (handle=0x%x:0x%x), payload (size=%llu bytes)\n", dg->dst.context, dg->dst.resource, dg->src.context, dg->src.resource, (unsigned long long)dg->payload_size); /* Get source context id. */ cid = vmci_ctx_get_id(vmci_host_dev->context); send_info.result = vmci_datagram_dispatch(cid, dg, true); kfree(dg); return copy_to_user(uptr, &send_info, sizeof(send_info)) ? -EFAULT : 0; } static int vmci_host_do_receive_datagram(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_datagram_snd_rcv_info recv_info; struct vmci_datagram *dg = NULL; int retval; size_t size; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&recv_info, uptr, sizeof(recv_info))) return -EFAULT; size = recv_info.len; recv_info.result = vmci_ctx_dequeue_datagram(vmci_host_dev->context, &size, &dg); if (recv_info.result >= VMCI_SUCCESS) { void __user *ubuf = (void __user *)(uintptr_t)recv_info.addr; retval = copy_to_user(ubuf, dg, VMCI_DG_SIZE(dg)); kfree(dg); if (retval != 0) return -EFAULT; } return copy_to_user(uptr, &recv_info, sizeof(recv_info)) ? -EFAULT : 0; } static int vmci_host_do_alloc_queuepair(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_handle handle; int vmci_status; int __user *retptr; u32 cid; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } cid = vmci_ctx_get_id(vmci_host_dev->context); if (vmci_host_dev->user_version < VMCI_VERSION_NOVMVM) { struct vmci_qp_alloc_info_vmvm alloc_info; struct vmci_qp_alloc_info_vmvm __user *info = uptr; if (copy_from_user(&alloc_info, uptr, sizeof(alloc_info))) return -EFAULT; handle = alloc_info.handle; retptr = &info->result; vmci_status = vmci_qp_broker_alloc(alloc_info.handle, alloc_info.peer, alloc_info.flags, VMCI_NO_PRIVILEGE_FLAGS, alloc_info.produce_size, alloc_info.consume_size, NULL, vmci_host_dev->context); if (vmci_status == VMCI_SUCCESS) vmci_status = VMCI_SUCCESS_QUEUEPAIR_CREATE; } else { struct vmci_qp_alloc_info alloc_info; struct vmci_qp_alloc_info __user *info = uptr; struct vmci_qp_page_store page_store; if (copy_from_user(&alloc_info, uptr, sizeof(alloc_info))) return -EFAULT; handle = alloc_info.handle; retptr = &info->result; page_store.pages = alloc_info.ppn_va; page_store.len = alloc_info.num_ppns; vmci_status = vmci_qp_broker_alloc(alloc_info.handle, alloc_info.peer, alloc_info.flags, VMCI_NO_PRIVILEGE_FLAGS, alloc_info.produce_size, alloc_info.consume_size, &page_store, vmci_host_dev->context); } if (put_user(vmci_status, retptr)) { if (vmci_status >= VMCI_SUCCESS) { vmci_status = vmci_qp_broker_detach(handle, vmci_host_dev->context); } return -EFAULT; } return 0; } static int vmci_host_do_queuepair_setva(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_qp_set_va_info set_va_info; struct vmci_qp_set_va_info __user *info = uptr; s32 result; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (vmci_host_dev->user_version < VMCI_VERSION_NOVMVM) { vmci_ioctl_err("is not allowed\n"); return -EINVAL; } if (copy_from_user(&set_va_info, uptr, sizeof(set_va_info))) return -EFAULT; if (set_va_info.va) { /* * VMX is passing down a new VA for the queue * pair mapping. */ result = vmci_qp_broker_map(set_va_info.handle, vmci_host_dev->context, set_va_info.va); } else { /* * The queue pair is about to be unmapped by * the VMX. */ result = vmci_qp_broker_unmap(set_va_info.handle, vmci_host_dev->context, 0); } return put_user(result, &info->result) ? -EFAULT : 0; } static int vmci_host_do_queuepair_setpf(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_qp_page_file_info page_file_info; struct vmci_qp_page_file_info __user *info = uptr; s32 result; if (vmci_host_dev->user_version < VMCI_VERSION_HOSTQP || vmci_host_dev->user_version >= VMCI_VERSION_NOVMVM) { vmci_ioctl_err("not supported on this VMX (version=%d)\n", vmci_host_dev->user_version); return -EINVAL; } if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&page_file_info, uptr, sizeof(*info))) return -EFAULT; /* * Communicate success pre-emptively to the caller. Note that the * basic premise is that it is incumbent upon the caller not to look at * the info.result field until after the ioctl() returns. And then, * only if the ioctl() result indicates no error. We send up the * SUCCESS status before calling SetPageStore() store because failing * to copy up the result code means unwinding the SetPageStore(). * * It turns out the logic to unwind a SetPageStore() opens a can of * worms. For example, if a host had created the queue_pair and a * guest attaches and SetPageStore() is successful but writing success * fails, then ... the host has to be stopped from writing (anymore) * data into the queue_pair. That means an additional test in the * VMCI_Enqueue() code path. Ugh. */ if (put_user(VMCI_SUCCESS, &info->result)) { /* * In this case, we can't write a result field of the * caller's info block. So, we don't even try to * SetPageStore(). */ return -EFAULT; } result = vmci_qp_broker_set_page_store(page_file_info.handle, page_file_info.produce_va, page_file_info.consume_va, vmci_host_dev->context); if (result < VMCI_SUCCESS) { if (put_user(result, &info->result)) { /* * Note that in this case the SetPageStore() * call failed but we were unable to * communicate that to the caller (because the * copy_to_user() call failed). So, if we * simply return an error (in this case * -EFAULT) then the caller will know that the * SetPageStore failed even though we couldn't * put the result code in the result field and * indicate exactly why it failed. * * That says nothing about the issue where we * were once able to write to the caller's info * memory and now can't. Something more * serious is probably going on than the fact * that SetPageStore() didn't work. */ return -EFAULT; } } return 0; } static int vmci_host_do_qp_detach(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_qp_dtch_info detach_info; struct vmci_qp_dtch_info __user *info = uptr; s32 result; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&detach_info, uptr, sizeof(detach_info))) return -EFAULT; result = vmci_qp_broker_detach(detach_info.handle, vmci_host_dev->context); if (result == VMCI_SUCCESS && vmci_host_dev->user_version < VMCI_VERSION_NOVMVM) { result = VMCI_SUCCESS_LAST_DETACH; } return put_user(result, &info->result) ? -EFAULT : 0; } static int vmci_host_do_ctx_add_notify(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_ctx_info ar_info; struct vmci_ctx_info __user *info = uptr; s32 result; u32 cid; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&ar_info, uptr, sizeof(ar_info))) return -EFAULT; cid = vmci_ctx_get_id(vmci_host_dev->context); result = vmci_ctx_add_notification(cid, ar_info.remote_cid); return put_user(result, &info->result) ? -EFAULT : 0; } static int vmci_host_do_ctx_remove_notify(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_ctx_info ar_info; struct vmci_ctx_info __user *info = uptr; u32 cid; int result; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&ar_info, uptr, sizeof(ar_info))) return -EFAULT; cid = vmci_ctx_get_id(vmci_host_dev->context); result = vmci_ctx_remove_notification(cid, ar_info.remote_cid); return put_user(result, &info->result) ? -EFAULT : 0; } static int vmci_host_do_ctx_get_cpt_state(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_ctx_chkpt_buf_info get_info; u32 cid; void *cpt_buf; int retval; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&get_info, uptr, sizeof(get_info))) return -EFAULT; cid = vmci_ctx_get_id(vmci_host_dev->context); get_info.result = vmci_ctx_get_chkpt_state(cid, get_info.cpt_type, &get_info.buf_size, &cpt_buf); if (get_info.result == VMCI_SUCCESS && get_info.buf_size) { void __user *ubuf = (void __user *)(uintptr_t)get_info.cpt_buf; retval = copy_to_user(ubuf, cpt_buf, get_info.buf_size); kfree(cpt_buf); if (retval) return -EFAULT; } return copy_to_user(uptr, &get_info, sizeof(get_info)) ? -EFAULT : 0; } static int vmci_host_do_ctx_set_cpt_state(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_ctx_chkpt_buf_info set_info; u32 cid; void *cpt_buf; int retval; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&set_info, uptr, sizeof(set_info))) return -EFAULT; cpt_buf = kmalloc(set_info.buf_size, GFP_KERNEL); if (!cpt_buf) { vmci_ioctl_err( "cannot allocate memory to set cpt state (type=%d)\n", set_info.cpt_type); return -ENOMEM; } if (copy_from_user(cpt_buf, (void __user *)(uintptr_t)set_info.cpt_buf, set_info.buf_size)) { retval = -EFAULT; goto out; } cid = vmci_ctx_get_id(vmci_host_dev->context); set_info.result = vmci_ctx_set_chkpt_state(cid, set_info.cpt_type, set_info.buf_size, cpt_buf); retval = copy_to_user(uptr, &set_info, sizeof(set_info)) ? -EFAULT : 0; out: kfree(cpt_buf); return retval; } static int vmci_host_do_get_context_id(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { u32 __user *u32ptr = uptr; return put_user(VMCI_HOST_CONTEXT_ID, u32ptr) ? -EFAULT : 0; } static int vmci_host_do_set_notify(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_set_notify_info notify_info; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&notify_info, uptr, sizeof(notify_info))) return -EFAULT; if (notify_info.notify_uva) { notify_info.result = vmci_host_setup_notify(vmci_host_dev->context, notify_info.notify_uva); } else { vmci_ctx_unset_notify(vmci_host_dev->context); notify_info.result = VMCI_SUCCESS; } return copy_to_user(uptr, &notify_info, sizeof(notify_info)) ? -EFAULT : 0; } static int vmci_host_do_notify_resource(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_dbell_notify_resource_info info; u32 cid; if (vmci_host_dev->user_version < VMCI_VERSION_NOTIFY) { vmci_ioctl_err("invalid for current VMX versions\n"); return -EINVAL; } if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (copy_from_user(&info, uptr, sizeof(info))) return -EFAULT; cid = vmci_ctx_get_id(vmci_host_dev->context); switch (info.action) { case VMCI_NOTIFY_RESOURCE_ACTION_NOTIFY: if (info.resource == VMCI_NOTIFY_RESOURCE_DOOR_BELL) { u32 flags = VMCI_NO_PRIVILEGE_FLAGS; info.result = vmci_ctx_notify_dbell(cid, info.handle, flags); } else { info.result = VMCI_ERROR_UNAVAILABLE; } break; case VMCI_NOTIFY_RESOURCE_ACTION_CREATE: info.result = vmci_ctx_dbell_create(cid, info.handle); break; case VMCI_NOTIFY_RESOURCE_ACTION_DESTROY: info.result = vmci_ctx_dbell_destroy(cid, info.handle); break; default: vmci_ioctl_err("got unknown action (action=%d)\n", info.action); info.result = VMCI_ERROR_INVALID_ARGS; } return copy_to_user(uptr, &info, sizeof(info)) ? -EFAULT : 0; } static int vmci_host_do_recv_notifications(struct vmci_host_dev *vmci_host_dev, const char *ioctl_name, void __user *uptr) { struct vmci_ctx_notify_recv_info info; struct vmci_handle_arr *db_handle_array; struct vmci_handle_arr *qp_handle_array; void __user *ubuf; u32 cid; int retval = 0; if (vmci_host_dev->ct_type != VMCIOBJ_CONTEXT) { vmci_ioctl_err("only valid for contexts\n"); return -EINVAL; } if (vmci_host_dev->user_version < VMCI_VERSION_NOTIFY) { vmci_ioctl_err("not supported for the current vmx version\n"); return -EINVAL; } if (copy_from_user(&info, uptr, sizeof(info))) return -EFAULT; if ((info.db_handle_buf_size && !info.db_handle_buf_uva) || (info.qp_handle_buf_size && !info.qp_handle_buf_uva)) { return -EINVAL; } cid = vmci_ctx_get_id(vmci_host_dev->context); info.result = vmci_ctx_rcv_notifications_get(cid, &db_handle_array, &qp_handle_array); if (info.result != VMCI_SUCCESS) return copy_to_user(uptr, &info, sizeof(info)) ? -EFAULT : 0; ubuf = (void __user *)(uintptr_t)info.db_handle_buf_uva; info.result = drv_cp_harray_to_user(ubuf, &info.db_handle_buf_size, db_handle_array, &retval); if (info.result == VMCI_SUCCESS && !retval) { ubuf = (void __user *)(uintptr_t)info.qp_handle_buf_uva; info.result = drv_cp_harray_to_user(ubuf, &info.qp_handle_buf_size, qp_handle_array, &retval); } if (!retval && copy_to_user(uptr, &info, sizeof(info))) retval = -EFAULT; vmci_ctx_rcv_notifications_release(cid, db_handle_array, qp_handle_array, info.result == VMCI_SUCCESS && !retval); return retval; } static long vmci_host_unlocked_ioctl(struct file *filp, unsigned int iocmd, unsigned long ioarg) { #define VMCI_DO_IOCTL(ioctl_name, ioctl_fn) do { \ char *name = __stringify(IOCTL_VMCI_ ## ioctl_name); \ return vmci_host_do_ ## ioctl_fn( \ vmci_host_dev, name, uptr); \ } while (0) struct vmci_host_dev *vmci_host_dev = filp->private_data; void __user *uptr = (void __user *)ioarg; switch (iocmd) { case IOCTL_VMCI_INIT_CONTEXT: VMCI_DO_IOCTL(INIT_CONTEXT, init_context); case IOCTL_VMCI_DATAGRAM_SEND: VMCI_DO_IOCTL(DATAGRAM_SEND, send_datagram); case IOCTL_VMCI_DATAGRAM_RECEIVE: VMCI_DO_IOCTL(DATAGRAM_RECEIVE, receive_datagram); case IOCTL_VMCI_QUEUEPAIR_ALLOC: VMCI_DO_IOCTL(QUEUEPAIR_ALLOC, alloc_queuepair); case IOCTL_VMCI_QUEUEPAIR_SETVA: VMCI_DO_IOCTL(QUEUEPAIR_SETVA, queuepair_setva); case IOCTL_VMCI_QUEUEPAIR_SETPAGEFILE: VMCI_DO_IOCTL(QUEUEPAIR_SETPAGEFILE, queuepair_setpf); case IOCTL_VMCI_QUEUEPAIR_DETACH: VMCI_DO_IOCTL(QUEUEPAIR_DETACH, qp_detach); case IOCTL_VMCI_CTX_ADD_NOTIFICATION: VMCI_DO_IOCTL(CTX_ADD_NOTIFICATION, ctx_add_notify); case IOCTL_VMCI_CTX_REMOVE_NOTIFICATION: VMCI_DO_IOCTL(CTX_REMOVE_NOTIFICATION, ctx_remove_notify); case IOCTL_VMCI_CTX_GET_CPT_STATE: VMCI_DO_IOCTL(CTX_GET_CPT_STATE, ctx_get_cpt_state); case IOCTL_VMCI_CTX_SET_CPT_STATE: VMCI_DO_IOCTL(CTX_SET_CPT_STATE, ctx_set_cpt_state); case IOCTL_VMCI_GET_CONTEXT_ID: VMCI_DO_IOCTL(GET_CONTEXT_ID, get_context_id); case IOCTL_VMCI_SET_NOTIFY: VMCI_DO_IOCTL(SET_NOTIFY, set_notify); case IOCTL_VMCI_NOTIFY_RESOURCE: VMCI_DO_IOCTL(NOTIFY_RESOURCE, notify_resource); case IOCTL_VMCI_NOTIFICATIONS_RECEIVE: VMCI_DO_IOCTL(NOTIFICATIONS_RECEIVE, recv_notifications); case IOCTL_VMCI_VERSION: case IOCTL_VMCI_VERSION2: return vmci_host_get_version(vmci_host_dev, iocmd, uptr); default: pr_devel("%s: Unknown ioctl (iocmd=%d)\n", __func__, iocmd); return -EINVAL; } #undef VMCI_DO_IOCTL } static const struct file_operations vmuser_fops = { .owner = THIS_MODULE, .open = vmci_host_open, .release = vmci_host_close, .poll = vmci_host_poll, .unlocked_ioctl = vmci_host_unlocked_ioctl, .compat_ioctl = vmci_host_unlocked_ioctl, }; static struct miscdevice vmci_host_miscdev = { .name = "vmci", .minor = MISC_DYNAMIC_MINOR, .fops = &vmuser_fops, }; int __init vmci_host_init(void) { int error; host_context = vmci_ctx_create(VMCI_HOST_CONTEXT_ID, VMCI_DEFAULT_PROC_PRIVILEGE_FLAGS, -1, VMCI_VERSION, NULL); if (IS_ERR(host_context)) { error = PTR_ERR(host_context); pr_warn("Failed to initialize VMCIContext (error%d)\n", error); return error; } error = misc_register(&vmci_host_miscdev); if (error) { pr_warn("Module registration error (name=%s, major=%d, minor=%d, err=%d)\n", vmci_host_miscdev.name, MISC_MAJOR, vmci_host_miscdev.minor, error); pr_warn("Unable to initialize host personality\n"); vmci_ctx_destroy(host_context); return error; } pr_info("VMCI host device registered (name=%s, major=%d, minor=%d)\n", vmci_host_miscdev.name, MISC_MAJOR, vmci_host_miscdev.minor); vmci_host_device_initialized = true; return 0; } void __exit vmci_host_exit(void) { int error; vmci_host_device_initialized = false; error = misc_deregister(&vmci_host_miscdev); if (error) pr_warn("Error unregistering character device: %d\n", error); vmci_ctx_destroy(host_context); vmci_qp_broker_exit(); pr_debug("VMCI host driver module unloaded\n"); }
5a70b2f572e3614d912a2b574552329ce74d6494
376e1818d427b5e4d32fa6dd6c7b71e9fd88afdb
/shells/mksh/patches/manual-funcs.c
8fc54c834e0d6b8fb2aea7d92101d6ccdde086fc
[]
no_license
NetBSD/pkgsrc
a0732c023519650ef821ab89c23ab6ab59e25bdb
d042034ec4896cc5b47ed6f2e5b8802d9bc5c556
refs/heads/trunk
2023-09-01T07:40:12.138283
2023-09-01T05:25:19
2023-09-01T05:25:19
88,439,572
321
138
null
2023-07-12T22:34:14
2017-04-16T20:04:15
null
UTF-8
C
false
false
1,253
c
manual-funcs.c
$NetBSD: manual-funcs.c,v 1.1 2020/07/06 10:11:34 jperkin Exp $ Apple switched from using RLIMIT_RSS (ulimit -m) in 10.3 (xnu-517.12.7) over to RLIMIT_AS (ulimit -v) in 10.4 (xnu-792), providing a compatibility define for RLIMIT_RSS. The default bash shell since 10.4 supports both -m and -v. Because the current design of the ULIMIT_CMD_* variables in mk/platform/*.mk dictates that we must use a single value, -m is chosen so that all releases are supported. However, mksh removes -m support by default if it is identical to -v, thus breaking ULIMIT_CMD_memorysize. In order to provide maximum compatibility in pkgsrc, we apply the following patch so that "ulimit -m" continues to work with mksh, acting as an alias for -v. For the record, it appears that /bin/zsh also supports -v but not -m, whereas shells/pdksh supports -m but not -v. --- files/funcs.c.orig 2020-06-25 09:34:59.000000000 +0000 +++ files/funcs.c @@ -3240,7 +3240,7 @@ ptest_error(Test_env *te, int ofs, const #else #define ULIMIT_M_IS_RSS #endif -#if defined(ULIMIT_M_IS_RSS) && defined(RLIMIT_AS) && (RLIMIT_RSS == RLIMIT_AS) +#if defined(ULIMIT_M_IS_RSS) && defined(RLIMIT_AS) && (RLIMIT_RSS == RLIMIT_AS) && !defined(__APPLE__) #undef ULIMIT_M_IS_RSS #endif #endif
908294c59ce8f9c0853d93457dfc933cdb380ca7
ed98b77f3f09b392e68a0d59c48eec299e883bb9
/src/tclique/tclique_branch.c
57ba57924b78961d8527e5d922236391380e90dd
[ "Apache-2.0" ]
permissive
scipopt/scip
c8ddbe7cdec0a3af5a230c04b74b76ffacbdcc33
dc856a4c966ea50bd5f52c58d7be4fea33706f4c
refs/heads/master
2023-08-19T11:39:12.578790
2023-08-15T20:05:58
2023-08-15T20:05:58
342,522,859
262
46
NOASSERTION
2023-08-03T07:37:45
2021-02-26T09:16:17
C
UTF-8
C
false
false
42,451
c
tclique_branch.c
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ /* This file is part of the program */ /* TCLIQUE --- Algorithm for Maximum Cliques */ /* */ /* Copyright (c) 1996-2023 Zuse Institute Berlin (ZIB) */ /* */ /* 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. */ /* */ /* You should have received a copy of the Apache-2.0 license */ /* along with TCLIQUE; see the file LICENSE. */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**@file tclique_branch.c * @ingroup OTHER_CFILES * @brief branch and bound part of algorithm for maximum cliques * @author Tobias Achterberg * @author Ralf Borndoerfer * @author Zoltan Kormos * @author Kati Wolter */ /*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/ #include <stdio.h> #include <assert.h> #include <stdlib.h> #include <limits.h> #include "tclique/tclique.h" #include "tclique/tclique_def.h" #include "tclique/tclique_coloring.h" #include "blockmemshell/memory.h" #define CHUNK_SIZE (64) #define CLIQUEHASH_INITSIZE (1024) /*************************** * clique hash table methods ***************************/ typedef struct clique CLIQUE; /**< single element of the clique hash table */ /** single element of the clique hash table */ struct clique { int* nodes; /**< node number of the clique elements */ int nnodes; /**< length of the clique */ }; typedef struct cliquehash CLIQUEHASH; /**< hash table for storing cliques */ /** hash table for storing cliques */ struct cliquehash { CLIQUE** cliques; /**< elements of the table */ int cliquessize; /**< size of the table */ int ncliques; /**< number of cliques stored in the table */ }; /** creates a clique */ static void createClique( CLIQUE** clique, /**< pointer to the clique */ int* nodes, /**< nodes of the clique */ int nnodes /**< number of nodes in the clique */ ) { int i; assert(clique != NULL); ALLOC_ABORT( BMSallocMemory(clique) ); ALLOC_ABORT( BMSallocMemoryArray(&(*clique)->nodes, nnodes) ); /* sort the nodes into the clique's node array */ for( i = 0; i < nnodes; ++i ) { int node; int j; node = nodes[i]; for( j = i; j > 0 && node < (*clique)->nodes[j-1]; --j ) (*clique)->nodes[j] = (*clique)->nodes[j-1]; (*clique)->nodes[j] = node; } (*clique)->nnodes = nnodes; } /** frees a clique */ static void freeClique( CLIQUE** clique /**< pointer to the clique */ ) { assert(clique != NULL); assert(*clique != NULL); BMSfreeMemoryArray(&(*clique)->nodes); BMSfreeMemory(clique); } /** checks, whether clique1 is a subset of clique2 and returns the following value: * == 0 if clique1 == clique2, or clique1 is contained in clique2, * < 0 if clique1 < clique2, and clique1 is not contained in clique2, * > 0 if clique1 > clique2, and clique1 is not contained in clique2 */ static int compSubcliques( CLIQUE* clique1, /**< first clique to compare */ CLIQUE* clique2 /**< second clique to compare */ ) { int pos1; int pos2; TCLIQUE_Bool clique2smaller; assert(clique1 != NULL); assert(clique2 != NULL); pos1 = 0; pos2 = 0; clique2smaller = FALSE; while( pos1 < clique1->nnodes && pos2 < clique2->nnodes ) { if( clique1->nodes[pos1] < clique2->nodes[pos2] ) { /* clique1 has an element not contained in clique2: clique1 is lex-smaller, if clique2 was not * detected earlier to be lex-smaller */ return (clique2smaller ? +1 : -1); } else if( clique1->nodes[pos1] > clique2->nodes[pos2] ) { /* clique2 has an element not contained in clique1: clique2 is lex-smaller, but probably clique1 is * contained in clique2 */ pos2++; clique2smaller = TRUE; } else { pos1++; pos2++; } } /* if clique1 has additional elements, it is not contained in clique2 */ if( pos1 < clique1->nnodes ) return (clique2smaller ? +1 : -1); /* clique1 is contained in clique2 */ return 0; } #ifndef NDEBUG /** performs an integrity check of the clique hash table */ static void checkCliquehash( CLIQUEHASH* cliquehash /**< clique hash table */ ) { int i; assert(cliquehash != NULL); for( i = 0; i < cliquehash->ncliques-1; ++i ) assert(compSubcliques(cliquehash->cliques[i], cliquehash->cliques[i+1]) < 0); } #else #define checkCliquehash(cliquehash) /**/ #endif /** creates a table for storing cliques */ static void createCliquehash( CLIQUEHASH** cliquehash, /**< pointer to store the clique hash table */ int tablesize /**< initial size of the clique hash table */ ) { assert(cliquehash != NULL); assert(tablesize > 0); ALLOC_ABORT( BMSallocMemory(cliquehash) ); ALLOC_ABORT( BMSallocMemoryArray(&(*cliquehash)->cliques, tablesize) ); (*cliquehash)->cliquessize = tablesize; (*cliquehash)->ncliques = 0; } /** clears the clique hash table and frees all inserted cliques */ static void clearCliquehash( CLIQUEHASH* cliquehash /**< clique hash table */ ) { int i; assert(cliquehash != NULL); /* free the cliques in the table */ for( i = 0; i < cliquehash->ncliques; ++i ) freeClique(&cliquehash->cliques[i]); cliquehash->ncliques = 0; } /** frees the table for storing cliques and all inserted cliques */ static void freeCliquehash( CLIQUEHASH** cliquehash /**< pointer to the clique hash table */ ) { assert(cliquehash != NULL); assert(*cliquehash != NULL); /* free the cliques in the table */ clearCliquehash(*cliquehash); /* free the table data structure */ BMSfreeMemoryArray(&(*cliquehash)->cliques); BMSfreeMemory(cliquehash); } /** ensures, that the clique hash table is able to store at least the given number of cliques */ static void ensureCliquehashSize( CLIQUEHASH* cliquehash, /**< clique hash table */ int num /**< minimal number of cliques to store */ ) { assert(cliquehash != NULL); if( num > cliquehash->cliquessize ) { int newsize; newsize = 2*cliquehash->cliquessize; if( num > newsize ) newsize = num; ALLOC_ABORT( BMSreallocMemoryArray(&cliquehash->cliques, newsize) ); cliquehash->cliquessize = newsize; } assert(cliquehash->cliquessize >= num); } #ifdef TCLIQUE_DEBUG /** displayes clique hash table */ static void printCliquehash( CLIQUEHASH* cliquehash /**< clique hash table */ ) { int i; assert(cliquehash != NULL); debugMessage("cliquehash (%d cliques):\n", cliquehash->ncliques); for( i = 0; i < cliquehash->ncliques; ++i ) { int j; debugPrintf("%d:", i); for( j = 0; j < cliquehash->cliques[i]->nnodes; ++j ) debugPrintf(" %d", cliquehash->cliques[i]->nodes[j]); debugPrintf("\n"); } } #endif /** searches the given clique in the clique hash table and returns whether it (or a stronger clique) exists */ static TCLIQUE_Bool inCliquehash( CLIQUEHASH* cliquehash, /**< clique hash table */ CLIQUE* clique, /**< clique to search in the table */ int* insertpos /**< position where the clique should be inserted in the table */ ) { int left; int right; int middle; int cmp; assert(cliquehash != NULL); assert(cliquehash->cliquessize > 0); assert(clique != NULL); assert(insertpos != NULL); /* perform a binary search on the clique hash table */ left = 0; right = cliquehash->ncliques-1; while( left <= right ) { middle = (left+right)/2; cmp = compSubcliques(clique, cliquehash->cliques[middle]); if( cmp > 0 ) left = middle+1; else if( cmp < 0 ) right = middle-1; else { *insertpos = middle; return TRUE; } } /* we found the correct insertion position for the clique, but it might be contained in a lex-smaller clique */ *insertpos = left; for( middle = left-1; middle >= 0; --middle ) { cmp = compSubcliques(clique, cliquehash->cliques[middle]); assert(cmp >= 0); if( cmp == 0 ) return TRUE; } return FALSE; } /** inserts clique into clique hash table */ static void insertClique( CLIQUEHASH* cliquehash, /**< clique hash table */ CLIQUE* clique, /**< clique to search in the table */ int insertpos /**< position to insert clique into table (returned by inCliquehash()) */ ) { int i; assert(cliquehash != NULL); assert(clique != NULL); assert(0 <= insertpos && insertpos <= cliquehash->ncliques); /* allocate memory */ ensureCliquehashSize(cliquehash, cliquehash->ncliques+1); /* insert clique into table */ for( i = cliquehash->ncliques; i > insertpos; --i ) cliquehash->cliques[i] = cliquehash->cliques[i-1]; cliquehash->cliques[insertpos] = clique; cliquehash->ncliques++; /* check, whether the clique hash table is still sorted */ checkCliquehash(cliquehash); debug(printCliquehash(cliquehash)); } /**************************** * clique calculation methods ****************************/ /** extends given clique by additional zero-weight nodes of the given node set */ static void extendCliqueZeroWeight( TCLIQUE_SELECTADJNODES((*selectadjnodes)),/**< user function to select adjacent edges */ TCLIQUE_GRAPH* tcliquegraph, /**< pointer to graph data structure */ int* buffer, /**< buffer of size nnodes */ int* Vzero, /**< zero weighted nodes */ int nVzero, /**< number of zero weighted nodes */ int maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */ int* curcliquenodes, /**< nodes of the clique */ int* ncurcliquenodes /**< pointer to store number of nodes in the clique */ ) { int i; int* zerocands; int nzerocands; int nzeroextensions; assert(selectadjnodes != NULL); assert(buffer != NULL); assert(Vzero != NULL); assert(curcliquenodes != NULL); assert(ncurcliquenodes != NULL); debugMessage("extending temporary clique (size %d) with zero-weighted nodes (nVzero=%d)\n", *ncurcliquenodes, nVzero); if( maxnzeroextensions == 0 ) return; /* initialize the zero-weighted candidates for clique extension */ zerocands = buffer; BMScopyMemoryArray(zerocands, Vzero, nVzero); nzerocands = nVzero; /* for each node in the clique, remove non-adjacent nodes from the zero extension candidates */ for( i = 0; i < *ncurcliquenodes && nzerocands > 0; ++i ) { nzerocands = selectadjnodes(tcliquegraph, curcliquenodes[i], zerocands, nzerocands, zerocands); } /* put zero-weighted candidates into the clique, and remove non-adjacent nodes from the candidate set */ nzeroextensions = 0; while( nzerocands > 0 ) { /* put first candidate into the clique */ curcliquenodes[*ncurcliquenodes] = zerocands[0]; (*ncurcliquenodes)++; nzerocands--; zerocands++; nzeroextensions++; if( nzeroextensions >= maxnzeroextensions ) break; /* remove candidates that are not adjacent to the inserted zero-weighted node */ nzerocands = selectadjnodes(tcliquegraph, curcliquenodes[(*ncurcliquenodes)-1], zerocands, nzerocands, zerocands); } } /** calls user callback after a new solution was found, that is better than the current incumbent * * The callback decides, whether this solution should be accepted as new incumbent, and whether the solution process * should be stopped. */ static void newSolution( TCLIQUE_SELECTADJNODES((*selectadjnodes)), /**< user function to select adjacent edges */ TCLIQUE_GRAPH* tcliquegraph, /**< pointer to graph data structure */ TCLIQUE_NEWSOL((*newsol)), /**< user function to call on every new solution */ TCLIQUE_DATA* tcliquedata, /**< user data to pass to user callback function */ CLIQUEHASH* cliquehash, /**< clique hash table */ int* buffer, /**< buffer of size nnodes */ int* Vzero, /**< zero weighted nodes */ int nVzero, /**< number of zero weighted nodes */ int maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */ int* curcliquenodes, /**< nodes of the new clique */ int ncurcliquenodes, /**< number of nodes in the new clique */ TCLIQUE_WEIGHT curcliqueweight, /**< weight of the new clique */ int* maxcliquenodes, /**< pointer to store nodes of the maximum weight clique */ int* nmaxcliquenodes, /**< pointer to store number of nodes in the maximum weight clique */ TCLIQUE_WEIGHT* maxcliqueweight, /**< pointer to store weight of the maximum weight clique */ TCLIQUE_Bool* stopsolving /**< pointer to store whether the solving should be stopped */ ) { CLIQUE* clique; int insertpos; TCLIQUE_Bool acceptsol; assert(curcliquenodes != NULL); assert(maxcliquenodes != NULL); assert(nmaxcliquenodes != NULL); assert(maxcliqueweight != NULL); assert(curcliqueweight > *maxcliqueweight); assert(stopsolving != NULL); assert(newsol == NULL || cliquehash != NULL); acceptsol = TRUE; *stopsolving = FALSE; clique = NULL; insertpos = 0; if( newsol != NULL ) { /* check whether the clique is already stored in the table */ if( cliquehash->ncliques > 0 ) { createClique(&clique, curcliquenodes, ncurcliquenodes); acceptsol = !inCliquehash(cliquehash, clique, &insertpos); } } /* check, if this is a new clique */ if( acceptsol ) { /* extend the clique with the zero-weighted nodes */ extendCliqueZeroWeight(selectadjnodes, tcliquegraph, buffer, Vzero, nVzero, maxnzeroextensions, curcliquenodes, &ncurcliquenodes); if( newsol != NULL ) { /* call user callback method */ newsol(tcliquedata, curcliquenodes, ncurcliquenodes, curcliqueweight, maxcliqueweight, &acceptsol, stopsolving); /* if clique was accepted, clear the clique hash table; otherwise, insert it into the clique hash table, such that * the same or a weaker clique is not presented to the user again */ if( acceptsol ) clearCliquehash(cliquehash); else { /* if the clique was not yet created, do it now */ if( clique == NULL ) { assert(insertpos == 0); assert(cliquehash->ncliques == 0); createClique(&clique, curcliquenodes, ncurcliquenodes); } /* insert clique into clique hash table */ insertClique(cliquehash, clique, insertpos); clique = NULL; /* the clique now belongs to the table */ } } } /* free the clique, if it was created and not put into the clique hash table */ if( clique != NULL ) freeClique(&clique); if( acceptsol ) { /* copy the solution to the incumbent */ BMScopyMemoryArray(maxcliquenodes, curcliquenodes, ncurcliquenodes); *nmaxcliquenodes = ncurcliquenodes; if( curcliqueweight > *maxcliqueweight ) *maxcliqueweight = curcliqueweight; } #ifdef TCLIQUE_DEBUG debugMessage(" -> clique %s (weight %d):", acceptsol ? "accepted" : "rejected", curcliqueweight); { int i; for( i = 0; i < ncurcliquenodes; ++i ) debugPrintf(" %d", curcliquenodes[i]); debugPrintf("\n"); } #endif } /** tries to find a clique, if V has only one or two nodes */ static void reduced( TCLIQUE_GETWEIGHTS((*getweights)), /**< user function to get the node weights */ TCLIQUE_ISEDGE((*isedge)), /**< user function to check for existence of an edge */ TCLIQUE_GRAPH* tcliquegraph, /**< pointer to graph data structure */ int* V, /**< non-zero weighted nodes for branching */ int nV, /**< number of non-zero weighted nodes for branching */ TCLIQUE_WEIGHT* apbound, /**< apriori bound of nodes for branching */ int* tmpcliquenodes, /**< buffer for storing the temporary clique */ int* ntmpcliquenodes, /**< pointer to store number of nodes of the temporary clique */ TCLIQUE_WEIGHT* tmpcliqueweight /**< pointer to store weight of the temporary clique */ ) { const TCLIQUE_WEIGHT* weights; assert(getweights != NULL); assert(isedge != NULL); assert(tcliquegraph != NULL); assert(V != NULL); assert(0 <= nV && nV <= 2); assert(apbound != NULL); assert(tmpcliquenodes != NULL); assert(ntmpcliquenodes != NULL); assert(tmpcliqueweight != NULL); weights = getweights(tcliquegraph); assert(nV == 0 || weights[V[0]] > 0); assert(nV <= 1 || weights[V[1]] > 0); if( nV >= 1 ) apbound[0] = weights[V[0]]; if( nV >= 2 ) apbound[1] = weights[V[1]]; /* check if nodes are adjacent */ if( nV >= 2 && isedge(tcliquegraph, V[0], V[1]) ) { assert(isedge(tcliquegraph, V[1], V[0])); /* put nodes into clique */ tmpcliquenodes[0] = V[0]; tmpcliquenodes[1] = V[1]; *ntmpcliquenodes = 2; *tmpcliqueweight = weights[V[0]] + weights[V[1]]; apbound[0] += weights[V[1]]; } else if( nV >= 2 && weights[V[1]] > weights[V[0]] ) { /* put V[1] into clique */ tmpcliquenodes[0] = V[1]; *ntmpcliquenodes = 1; *tmpcliqueweight = weights[V[1]]; } else if( nV >= 1 ) { /* put V[0] into clique */ tmpcliquenodes[0] = V[0]; *ntmpcliquenodes = 1; *tmpcliqueweight = weights[V[0]]; } else { *tmpcliqueweight = 0; *ntmpcliquenodes = 0; } } /** calculates upper bound on remaining subgraph, and heuristically generates a clique */ static TCLIQUE_WEIGHT boundSubgraph( TCLIQUE_GETNNODES((*getnnodes)), /**< user function to get the number of nodes */ TCLIQUE_GETWEIGHTS((*getweights)), /**< user function to get the node weights */ TCLIQUE_ISEDGE((*isedge)), /**< user function to check for existence of an edge */ TCLIQUE_SELECTADJNODES((*selectadjnodes)), /**< user function to select adjacent edges */ TCLIQUE_GRAPH* tcliquegraph, /**< pointer to graph data structure */ BMS_CHKMEM* mem, /**< block memory */ int* buffer, /**< buffer of size nnodes */ int* V, /**< non-zero weighted nodes for branching */ int nV, /**< number of non-zero weighted nodes for branching */ NBC* gsd, /**< neighbour color information of all nodes */ TCLIQUE_Bool* iscolored, /**< coloring status of all nodes */ TCLIQUE_WEIGHT* apbound, /**< apriori bound of nodes for branching */ int* tmpcliquenodes, /**< buffer for storing the temporary clique */ int* ntmpcliquenodes, /**< pointer to store number of nodes of the temporary clique */ TCLIQUE_WEIGHT* tmpcliqueweight /**< pointer to store weight of the temporary clique */ ) { assert(tmpcliqueweight != NULL); /* check if we are in an easy case with at most 2 nodes left */ if( nV <= 2 ) { /* get 1- or 2-clique and bounds without coloring */ reduced(getweights, isedge, tcliquegraph, V, nV, apbound, tmpcliquenodes, ntmpcliquenodes, tmpcliqueweight); return *tmpcliqueweight; } else { /* color the graph induces by nodes of V to get an upper bound for the remaining subgraph */ return tcliqueColoring(getnnodes, getweights, selectadjnodes, tcliquegraph, mem, buffer, V, nV, gsd, iscolored, apbound, tmpcliquenodes, ntmpcliquenodes, tmpcliqueweight); } } /** gets the index of the node of V with the maximum apriori bound; returns -1, if no node exists */ static int getMaxApBoundIndex( int nV, /**< number of nodes of V */ TCLIQUE_WEIGHT* apbound /**< apriori bound of nodes of V */ ) { TCLIQUE_WEIGHT maxapbound; int maxindex; int i; assert(apbound != NULL); maxapbound = 0; maxindex = -1; for( i = 0 ; i < nV; i++ ) { assert(apbound[i] > 0); if( apbound[i] >= maxapbound ) { maxapbound = apbound[i]; maxindex = i; } } return maxindex; } /** gets the index of the node of V with the maximum apriori bound, but ignores nodes with weights * larger than the given maximal weight * * Returns -1 if no node with weight smaller or equal than maxweight is found. */ static int getMaxApBoundIndexNotMaxWeight( int* V, /**< non-zero weighted nodes for branching */ int nV, /**< number of non-zero weighted nodes for branching */ const TCLIQUE_WEIGHT* apbound, /**< apriori bound of nodes of V */ const TCLIQUE_WEIGHT* weights, /**< weights of nodes */ TCLIQUE_WEIGHT maxweight /**< maximal weight of node to be candidate for selection */ ) { TCLIQUE_WEIGHT maxapbound; int maxindex; int i; assert(apbound != NULL); maxapbound = 0; maxindex = -1; for( i = 0 ; i < nV; i++ ) { assert(apbound[i] > 0); assert(weights[V[i]] > 0); if( apbound[i] >= maxapbound && weights[V[i]] <= maxweight ) { maxapbound = apbound[i]; maxindex = i; } } return maxindex; } /** branches the searching tree, branching nodes are selected in decreasing order of their apriori bound, * returns the level to which we should backtrack, or INT_MAX for continuing normally */ static int branch( TCLIQUE_GETNNODES((*getnnodes)), /**< user function to get the number of nodes */ TCLIQUE_GETWEIGHTS((*getweights)), /**< user function to get the node weights */ TCLIQUE_ISEDGE((*isedge)), /**< user function to check for existence of an edge */ TCLIQUE_SELECTADJNODES((*selectadjnodes)),/**< user function to select adjacent edges */ TCLIQUE_GRAPH* tcliquegraph, /**< pointer to graph data structure */ TCLIQUE_NEWSOL((*newsol)), /**< user function to call on every new solution */ TCLIQUE_DATA* tcliquedata, /**< user data to pass to user callback function */ BMS_CHKMEM* mem, /**< block memory */ CLIQUEHASH* cliquehash, /**< clique hash table */ int* buffer, /**< buffer of size nnodes */ int level, /**< level of b&b tree */ int* V, /**< non-zero weighted nodes for branching */ int nV, /**< number of non-zero weighted nodes for branching */ int* Vzero, /**< zero weighted nodes */ int nVzero, /**< number of zero weighted nodes */ NBC* gsd, /**< neighbour color information of all nodes */ TCLIQUE_Bool* iscolored, /**< coloring status of all nodes */ int* K, /**< nodes from the b&b tree */ TCLIQUE_WEIGHT weightK, /**< weight of the nodes from b&b tree */ int* maxcliquenodes, /**< pointer to store nodes of the maximum weight clique */ int* nmaxcliquenodes, /**< pointer to store number of nodes in the maximum weight clique */ TCLIQUE_WEIGHT* maxcliqueweight, /**< pointer to store weight of the maximum weight clique */ int* curcliquenodes, /**< pointer to store nodes of currenct clique */ int* ncurcliquenodes, /**< pointer to store number of nodes in current clique */ TCLIQUE_WEIGHT* curcliqueweight, /**< pointer to store weight of current clique */ int* tmpcliquenodes, /**< buffer for storing the temporary clique */ TCLIQUE_WEIGHT maxfirstnodeweight, /**< maximum weight of branching nodes in level 0; 0 if not used * (for cliques with at least one fractional node) */ int* ntreenodes, /**< pointer to store number of nodes of b&b tree */ int maxntreenodes, /**< maximal number of nodes of b&b tree */ int backtrackfreq, /**< frequency to backtrack to first level of tree (0: no premature backtracking) */ int maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */ int fixednode, /**< node that is forced to be in the clique, or -1; must have positive weight */ TCLIQUE_STATUS* status /**< pointer to store the status of the solving call */ ) { TCLIQUE_Bool isleaf; const TCLIQUE_WEIGHT* weights; TCLIQUE_WEIGHT* apbound; TCLIQUE_WEIGHT subgraphweight; TCLIQUE_WEIGHT weightKold; TCLIQUE_WEIGHT tmpcliqueweight; int backtracklevel; int ntmpcliquenodes; int i; assert(getnnodes != NULL); assert(getweights != NULL); assert(selectadjnodes != NULL); assert(mem != NULL); assert(V != NULL); assert(gsd != NULL); assert(iscolored != NULL); assert(K != NULL); assert(maxcliqueweight != NULL); assert(curcliquenodes != NULL); assert(ncurcliquenodes != NULL); assert(curcliqueweight != NULL); assert(ntreenodes != NULL); assert(maxfirstnodeweight >= 0); assert(*ntreenodes >= 0); assert(maxntreenodes >= 0); assert(status != NULL); /* increase the number of nodes, and stop solving, if the node limit is exceeded */ (*ntreenodes)++; #ifdef TCLIQUE_DEBUG debugMessage("(level %d, treenode %d) maxclique = %d, curclique = %d [mem=%" SCIP_LONGINT_FORMAT " (%" SCIP_LONGINT_FORMAT "), cliques=%d]\n", level, *ntreenodes, *maxcliqueweight, *curcliqueweight, BMSgetChunkMemoryUsed(mem), BMSgetMemoryUsed(), cliquehash == NULL ? 0 : cliquehash->ncliques); debugMessage(" -> current branching (weight %d):", weightK); for( i = 0; i < level; ++i ) debugPrintf(" %d", K[i]); debugPrintf("\n"); debugMessage(" -> branching candidates:"); for( i = 0; i < nV; ++i ) debugPrintf(" %d", V[i]); debugPrintf("\n"); #endif if( *ntreenodes > maxntreenodes ) { *status = TCLIQUE_NODELIMIT; return TRUE; } weights = getweights(tcliquegraph); backtracklevel = INT_MAX; isleaf = TRUE; /* allocate temporary memory for a priori bounds */ ALLOC_ABORT( BMSallocMemoryArray(&apbound, nV) ); BMSclearMemoryArray(apbound, nV); /* use coloring relaxation to generate an upper bound for the current subtree and a heuristic solution */ subgraphweight = boundSubgraph(getnnodes, getweights, isedge, selectadjnodes, tcliquegraph, mem, buffer, V, nV, gsd, iscolored, apbound, tmpcliquenodes, &ntmpcliquenodes, &tmpcliqueweight); #ifndef NDEBUG /* check correctness of V and apbound arrays */ for( i = 0; i < nV; ++i ) { assert(0 <= V[i] && V[i] < getnnodes(tcliquegraph)); assert(i == 0 || V[i-1] < V[i]); assert(apbound[i] >= 0); assert((apbound[i] == 0) == (weights[V[i]] == 0)); } #endif /* check, whether the heuristic solution is better than the current subtree's solution; * if the user wanted to have a fixed variable inside the clique and we are in level 0, we first have to * fix this variable in this level (the current clique might not contain the fixed node) */ if( weightK + tmpcliqueweight > *curcliqueweight && (level > 0 || fixednode == -1) ) { /* install the newly generated clique as current clique */ for( i = 0; i < level; ++i ) curcliquenodes[i] = K[i]; for( i = 0; i < ntmpcliquenodes; ++i ) curcliquenodes[level+i] = tmpcliquenodes[i]; *ncurcliquenodes = level + ntmpcliquenodes; *curcliqueweight = weightK + tmpcliqueweight; #ifdef TCLIQUE_DEBUG debugMessage(" -> new current clique with weight %d at node %d in level %d:", *curcliqueweight, *ntreenodes, level); for( i = 0; i < *ncurcliquenodes; ++i ) debugPrintf(" %d", curcliquenodes[i]); debugPrintf("\n"); #endif } /* discard subtree, if the upper bound is not better than the weight of the currently best clique; * if only 2 nodes are left, the maximal weighted clique was already calculated in boundSubgraph() and nothing * more has to be done; * however, if the user wanted to have a fixed node and we are in the first decision level, we have to continue */ if( weightK + subgraphweight > *maxcliqueweight && (nV > 2 || (fixednode >= 0 && level == 0)) ) { int* Vcurrent; int nVcurrent; int nValive; int branchingnode; assert(nV > 0); /* process current subtree */ level++; /* set up data structures */ ALLOC_ABORT( BMSallocMemoryArray(&Vcurrent, nV-1) ); nValive = nV; weightKold = weightK; debugMessage("============================ branching level %d ===============================\n", level); /* branch on the nodes of V by decreasing order of their apriori bound */ while( backtracklevel >= level && nValive > 0 ) { int branchidx; /* check if we meet the backtracking frequency - in this case abort the search until we have reached first level */ if( level > 1 && backtrackfreq > 0 && (*ntreenodes) % backtrackfreq == 0 ) { backtracklevel = 1; break; } /* get next branching node */ if( level == 1 && fixednode >= 0 ) { /* select the fixed node as first "branching" candidate */ for( branchidx = 0; branchidx < nValive && V[branchidx] != fixednode; branchidx++ ) {} assert(branchidx < nValive); assert(V[branchidx] == fixednode); } else if( level == 1 && maxfirstnodeweight > 0 ) branchidx = getMaxApBoundIndexNotMaxWeight(V, nValive, apbound, weights, maxfirstnodeweight); else branchidx = getMaxApBoundIndex(nValive, apbound); if( branchidx < 0 ) break; assert(0 <= branchidx && branchidx < nValive && nValive <= nV); assert(apbound[branchidx] > 0); assert(weights[V[branchidx]] > 0); /* test a priori bound */ if( (weightKold + apbound[branchidx]) <= *maxcliqueweight ) break; debugMessage("%d. branching in level %d (treenode %d): bidx=%d, node %d, weight %d, upperbound: %d+%d = %d, maxclique=%d\n", nV-nValive+1, level, *ntreenodes, branchidx, V[branchidx], weights[V[branchidx]], weightKold, apbound[branchidx], weightKold + apbound[branchidx], *maxcliqueweight); /* because we branch on this node, the node is no leaf in the tree */ isleaf = FALSE; /* update the set of nodes from the b&b tree * K = K & {branchingnode} */ branchingnode = V[branchidx]; K[level-1] = branchingnode; weightK = weightKold + weights[branchingnode]; /* update the set of nodes for branching * V = V \ {branchingnode} */ nValive--; for( i = branchidx; i < nValive; ++i ) { V[i] = V[i+1]; apbound[i] = apbound[i+1]; } /* set the nodes for the next level of b&b tree * Vcurrent = nodes of V, that are adjacent to branchingnode */ nVcurrent = selectadjnodes(tcliquegraph, branchingnode, V, nValive, Vcurrent); /* process the selected subtree */ backtracklevel = branch(getnnodes, getweights, isedge, selectadjnodes, tcliquegraph, newsol, tcliquedata, /*lint !e838*/ mem, cliquehash, buffer, level, Vcurrent, nVcurrent, Vzero, nVzero, gsd, iscolored, K, weightK, maxcliquenodes, nmaxcliquenodes, maxcliqueweight, curcliquenodes, ncurcliquenodes, curcliqueweight, tmpcliquenodes, maxfirstnodeweight, ntreenodes, maxntreenodes, backtrackfreq, maxnzeroextensions, -1, status); /* if all other candidates stayed in the candidate list, the current branching was optimal and * there is no need to try the remaining ones */ if( nVcurrent == nValive ) { debugMessage("branching on node %d was optimal - ignoring remaining candidates\n", branchingnode); nValive = 0; } /* if we had a fixed node, ignore all other nodes */ if( fixednode >= 0 ) nValive = 0; } debugMessage("========================== branching level %d end =============================\n\n", level); /* free data structures */ BMSfreeMemoryArray(&Vcurrent); } /* check, whether any branchings have been applied, or if this node is a leaf of the branching tree */ if( isleaf ) { /* the current clique is the best clique found on the path to this leaf * -> check, whether it is an improvement to the currently best clique */ if( *curcliqueweight > *maxcliqueweight ) { TCLIQUE_Bool stopsolving; debugMessage("found clique of weight %d at node %d in level %d\n", *curcliqueweight, *ntreenodes, level); newSolution(selectadjnodes, tcliquegraph, newsol, tcliquedata, cliquehash, buffer, Vzero, nVzero, maxnzeroextensions, curcliquenodes, *ncurcliquenodes, *curcliqueweight, maxcliquenodes, nmaxcliquenodes, maxcliqueweight, &stopsolving); if( stopsolving ) { debugMessage(" -> solving terminated by callback method\n"); backtracklevel = 0; } } /* discard the current clique */ *ncurcliquenodes = 0; *curcliqueweight = 0; } #ifdef TCLIQUE_DEBUG if( level > backtracklevel ) { debugMessage("premature backtracking after %d nodes - level %d\n", *ntreenodes, level); } #endif /* free data structures */ BMSfreeMemoryArray(&apbound); return backtracklevel; } /** finds maximum weight clique */ void tcliqueMaxClique( TCLIQUE_GETNNODES((*getnnodes)), /**< user function to get the number of nodes */ TCLIQUE_GETWEIGHTS((*getweights)), /**< user function to get the node weights */ TCLIQUE_ISEDGE((*isedge)), /**< user function to check for existence of an edge */ TCLIQUE_SELECTADJNODES((*selectadjnodes)),/**< user function to select adjacent edges */ TCLIQUE_GRAPH* tcliquegraph, /**< pointer to graph data structure that is passed to graph callbacks */ TCLIQUE_NEWSOL((*newsol)), /**< user function to call on every new solution */ TCLIQUE_DATA* tcliquedata, /**< user data to pass to new solution callback function */ int* maxcliquenodes, /**< pointer to store nodes of the maximum weight clique */ int* nmaxcliquenodes, /**< pointer to store number of nodes in the maximum weight clique */ TCLIQUE_WEIGHT* maxcliqueweight, /**< pointer to store weight of the maximum weight clique */ TCLIQUE_WEIGHT maxfirstnodeweight, /**< maximum weight of branching nodes in level 0; 0 if not used * for cliques with at least one fractional node) */ TCLIQUE_WEIGHT minweight, /**< lower bound for weight of generated cliques */ int maxntreenodes, /**< maximal number of nodes of b&b tree */ int backtrackfreq, /**< frequency to backtrack to first level of tree (0: no premature backtracking) */ int maxnzeroextensions, /**< maximal number of zero-valued variables extending the clique */ int fixednode, /**< node that is forced to be in the clique, or -1; must have positive weight */ int* ntreenodes, /**< pointer to store the number of used tree nodes (or NULL) */ TCLIQUE_STATUS* status /**< pointer to store the status of the solving call */ ) { CLIQUEHASH* cliquehash; const TCLIQUE_WEIGHT* weights; int* buffer; int* K; int* V; int* Vzero; int nnodes; int nV; int nVzero; int i; BMS_CHKMEM* mem; NBC* gsd; TCLIQUE_Bool* iscolored; int* curcliquenodes; int ncurcliquenodes; TCLIQUE_WEIGHT curcliqueweight; int* tmpcliquenodes; int nbbtreenodes; int backtracklevel; assert(maxcliquenodes != NULL); assert(nmaxcliquenodes != NULL); assert(maxcliqueweight != NULL); assert(maxntreenodes >= 0); assert(backtrackfreq >= 0); assert(maxnzeroextensions >= 0); assert(status != NULL); *status = TCLIQUE_OPTIMAL; /* use default graph callbacks, if NULL pointers are given */ if( getnnodes == NULL ) getnnodes = tcliqueGetNNodes; if( getweights == NULL ) getweights = tcliqueGetWeights; if( isedge == NULL ) isedge = tcliqueIsEdge; if( selectadjnodes == NULL ) selectadjnodes = tcliqueSelectAdjnodes; /* get number of nodes */ nnodes = getnnodes(tcliquegraph); debugMessage("calculating maximal weighted clique in graph (%d nodes)\n", nnodes); /* set up data structures */ if( newsol != NULL ) createCliquehash(&cliquehash, CLIQUEHASH_INITSIZE); else cliquehash = NULL; ALLOC_ABORT( BMSallocMemoryArray(&buffer, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&K, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&V, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&Vzero, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&gsd, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&iscolored, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&curcliquenodes, nnodes) ); ALLOC_ABORT( BMSallocMemoryArray(&tmpcliquenodes, nnodes) ); /* set weight and number of nodes of maximum weighted clique */ *nmaxcliquenodes = 0; *maxcliqueweight = minweight-1; ncurcliquenodes = 0; curcliqueweight = 0; nbbtreenodes = 0; /* set up V and Vzero */ weights = getweights(tcliquegraph); assert(weights != NULL); nV = 0; nVzero = 0; for( i = 0 ; i < nnodes; i++ ) { if( weights[i] == 0 ) { Vzero[nVzero] = i; nVzero++; } else { V[nV] = i; nV++; } } /* initialize own memory allocator for coloring */ mem = BMScreateChunkMemory(sizeof(LIST_ITV), CHUNK_SIZE, -1); /* branch to find maximum weight clique */ backtracklevel = branch(getnnodes, getweights, isedge, selectadjnodes, tcliquegraph, newsol, tcliquedata, mem, cliquehash, buffer, 0, V, nV, Vzero, nVzero, gsd, iscolored, K, 0, maxcliquenodes, nmaxcliquenodes, maxcliqueweight, curcliquenodes, &ncurcliquenodes, &curcliqueweight, tmpcliquenodes, maxfirstnodeweight, &nbbtreenodes, maxntreenodes, backtrackfreq, maxnzeroextensions, fixednode, status); if ( ntreenodes != NULL ) *ntreenodes = nbbtreenodes; if( backtracklevel != INT_MAX && *status == TCLIQUE_OPTIMAL ) *status = TCLIQUE_USERABORT; /* delete own memory allocator for coloring */ BMSdestroyChunkMemory(&mem); /* free data structures */ BMSfreeMemoryArray(&tmpcliquenodes); BMSfreeMemoryArray(&curcliquenodes); BMSfreeMemoryArray(&iscolored); BMSfreeMemoryArray(&gsd); BMSfreeMemoryArray(&Vzero); BMSfreeMemoryArray(&V); BMSfreeMemoryArray(&K); BMSfreeMemoryArray(&buffer); if( newsol != NULL ) freeCliquehash(&cliquehash); } /*lint !e438*/
f8e2fbdd83ec3db585bf3c6bc48bd36450058cf4
4e32ea5b4a215f427af04630e01b1312ffd31a55
/test/programs/parser/cbmc/Fixedbv2/main.c
879b85f62ef8aa1fe5c2c37b4a9be9b7daa9be95
[ "Apache-2.0", "GPL-1.0-or-later" ]
permissive
sosy-lab/cpachecker
1add74cb774316dd6e1aea3fb1f352c8141466b7
1822761867d106301bda0bc99ed3cc0a25c529aa
refs/heads/trunk
2023-08-31T14:47:22.284597
2023-08-31T14:20:58
2023-08-31T14:20:58
20,107,238
186
90
Apache-2.0
2021-07-27T14:24:30
2014-05-23T16:57:37
SWIG
UTF-8
C
false
false
132
c
main.c
main() { float a; double b; a=1.25L; assert(a==1.25); b=1.250; assert(b==1.25); }
faa39424ff556cc5c46522c0a6763ea5e8a37c5e
ca2125d3a3a4aa7167326a09ff3adae4a03c90fe
/Tests/IncludeTest/GraphicsEngine/ShaderResourceVaraibleH_test.c
c9d125e76cb8cad33011468cdac22a93e7df9c85
[ "Apache-2.0", "BSD-3-Clause", "MIT", "LicenseRef-scancode-public-domain", "LicenseRef-scancode-nvidia-2002", "BSD-2-Clause" ]
permissive
DiligentGraphics/DiligentCore
9e124fee53bda1b280b3aa8c11ef1d3dc577d630
2ebd6cd1b3221a50d7f11f77ac51023a2b33697f
refs/heads/master
2023-08-28T14:13:18.861391
2023-08-24T00:52:40
2023-08-24T00:52:40
44,292,712
545
180
Apache-2.0
2023-09-11T14:44:45
2015-10-15T03:56:34
C++
UTF-8
C
false
false
2,344
c
ShaderResourceVaraibleH_test.c
/* * Copyright 2019-2022 Diligent Graphics LLC * Copyright 2015-2019 Egor Yusov * * 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. * * In no event and under no legal theory, whether in tort (including negligence), * contract, or otherwise, unless required by applicable law (such as deliberate * and grossly negligent acts) or agreed to in writing, shall any Contributor be * liable for any damages, including any direct, indirect, special, incidental, * or consequential damages of any character arising as a result of this License or * out of the use or inability to use the software (including but not limited to damages * for loss of goodwill, work stoppage, computer failure or malfunction, or any and * all other commercial damages or losses), even if such Contributor has been advised * of the possibility of such damages. */ #include "DiligentCore/Graphics/GraphicsEngine/interface/ShaderResourceVariable.h" void TestShaderResourceVariable_CInterface(IShaderResourceVariable* pVar) { IShaderResourceVariable_Set(pVar, (struct IDeviceObject*)NULL, SET_SHADER_RESOURCE_FLAG_NONE); IShaderResourceVariable_SetArray(pVar, (struct IDeviceObject* const*)NULL, (Uint32)1, (Uint32)2, SET_SHADER_RESOURCE_FLAG_NONE); IShaderResourceVariable_SetBufferRange(pVar, (struct IDeviceObject*)NULL, (Uint64)0, (Uint64)16, (Uint32)1, SET_SHADER_RESOURCE_FLAG_NONE); IShaderResourceVariable_SetBufferOffset(pVar, (Uint32)1024, (Uint32)1); SHADER_RESOURCE_VARIABLE_TYPE Type = IShaderResourceVariable_GetType(pVar); (void)Type; ShaderResourceDesc ResDesc; IShaderResourceVariable_GetResourceDesc(pVar, &ResDesc); Uint32 Idx = IShaderResourceVariable_GetIndex(pVar); (void)Idx; struct IDeviceObject* pObj = IShaderResourceVariable_Get(pVar, (Uint32)1); (void)pObj; }
69f80f70214e6f002e5b296da99a96a54d0a872c
51c60b88750841787e334a213a2042fcba7c7106
/v3.1/glfw/glfw_wl_init.c
014cc05862d6088d753bce64080e336c6c592732
[ "BSD-3-Clause" ]
permissive
go-gl/glfw
f7b87f9fa8379a4714a612460b00387344a2bac0
93cebf72946bdd130bbda47817ad53315d776ca7
refs/heads/master
2023-08-25T08:35:58.025548
2022-10-17T16:15:38
2022-10-17T16:15:38
10,151,943
1,498
229
BSD-3-Clause
2023-03-13T00:37:19
2013-05-19T06:38:45
C
UTF-8
C
false
false
60
c
glfw_wl_init.c
#ifdef _GLFW_WAYLAND #include "glfw/src/wl_init.c" #endif
06220131b61ddc43d917645420c13ad1d01792aa
1879a927280681ad82490c2207309928fb5b3622
/Resources/usr_old/include/__typedef_mode_t.h
398f64cc8147b782b0654c4c431b7e63d5cfa098
[ "BSD-3-Clause" ]
permissive
holzschu/a-shell
9d0cbc2c80a4eedb45414d73abd7fe47ee5a95da
41d76f2b61a7a3c91837532abc3b52b9b3af1ed4
refs/heads/master
2023-09-01T02:57:20.730777
2023-05-25T19:29:12
2023-05-25T19:29:12
196,275,239
2,112
107
BSD-3-Clause
2023-05-07T05:10:30
2019-07-10T21:08:32
C
UTF-8
C
false
false
116
h
__typedef_mode_t.h
#ifndef __wasm_basics___typedef_mode_t_h #define __wasm_basics___typedef_mode_t_h typedef unsigned mode_t; #endif
d79d7a0901964b418363c0c217718e7b1e75a3fc
ace570f65d70e6ce9461bcb81aaaac31c57ec111
/firmware/greatfet_usb/usb_streaming.c
a57992ef01ea8a627b1bd905264f763e9ed9e17d
[ "BSD-3-Clause" ]
permissive
greatscottgadgets/greatfet
9ed060aec2d293844c0ac59612f09ecae9c7632b
2409575d28fc7c9cae44c9085c7457ddfb54f893
refs/heads/master
2023-05-12T18:12:31.748720
2023-05-05T07:18:21
2023-05-05T07:18:21
48,184,998
273
95
BSD-3-Clause
2023-05-05T07:18:22
2015-12-17T16:17:35
C
UTF-8
C
false
false
7,873
c
usb_streaming.c
/** * Simple predecessor to the pipe API; currently being used until a few speed issues with the pipe API are fixed. * (We need to generate more machine code; yay.) * * This file is part of greatfet. */ #include <errno.h> #include <debug.h> #include <string.h> #include <toolchain.h> #include <drivers/comms.h> #include <drivers/sgpio.h> #include <drivers/usb/usb.h> #include <drivers/usb/usb_queue.h> #include <drivers/platform_clock.h> #include "usb_streaming.h" #include "usb_bulk_buffer.h" #include "usb_endpoint.h" #include "greatfet_core.h" typedef void (*streaming_handler_t)(void); static bool usb_streaming_enabled = false; static unsigned int phase = 1; static volatile uint32_t *position_in_buffer; static volatile uint32_t *data_in_buffer; volatile uint32_t debug_data; // Abstract storage for buffer metadata. Used for functionality in which we manage the buffer, // rather than the caller. volatile uint32_t read_position; volatile uint32_t write_position; volatile uint32_t buffer_content_count; // Timer objects used by our "periodic upload" functionality. hw_timer_t periodic_event_timer; // XXX static inline void cm_enable_interrupts(void) { __asm__("CPSIE I\n"); } static inline void cm_disable_interrupts(void) { __asm__("CPSID I\n"); } static int streaming_detect_overrun(void) { // We reach the overrun threshold if the logic analyzer has captured enough data to fill // every available buffer -- that is, every buffer except the one we're actively using to transmit. uint32_t overrun_threeshold = USB_STREAMING_NUM_BUFFERS * USB_STREAMING_BUFFER_SIZE; if (!data_in_buffer) { return 0; } // Basic overrun detection: if we have more than our threshold remaining after // consuming a buffer (really, passing it to the USB hardware for transmission), // then we overran. if (*data_in_buffer > overrun_threeshold) { pr_debug("streaming: debug: host isn't reading from us (possible overflow) -- stalling endpoint\n"); usb_endpoint_stall(&usb0_endpoint_bulk_in); // Tentative: stop streaming if we ever overrun. usb_streaming_stop_streaming_to_host(); return EOVERFLOW; } return 0; } /** * Schedules transmission of a completed logic-analyzer buffer. */ static int streaming_schedule_usb_transfer_in(int buffer_number) { int rc; // If we don't have a full buffer of data to transmit, we can't send anything yet. Bail out. if (data_in_buffer && (*data_in_buffer < USB_STREAMING_BUFFER_SIZE)) { return EAGAIN; } if (streaming_detect_overrun()) { return EOVERFLOW; } // Otherwise, transmit the relevant (complete) buffer... rc = usb_transfer_schedule( &usb0_endpoint_bulk_in, &usb_bulk_buffer[buffer_number * USB_STREAMING_BUFFER_SIZE], USB_STREAMING_BUFFER_SIZE, 0, 0); if (rc) { return EAGAIN; } // ... and mark those samples as no longer pending transfer. if (data_in_buffer) { cm_disable_interrupts(); *data_in_buffer -= USB_STREAMING_BUFFER_SIZE; cm_enable_interrupts(); } return 0; } static void service_usb_streaming_in(void) { static unsigned int transfers = 0; int rc; if ((*position_in_buffer >= USB_STREAMING_BUFFER_SIZE) && phase == 1) { rc = streaming_schedule_usb_transfer_in(0); if(rc) { return; } phase = 0; ++transfers; } else if ((*position_in_buffer < USB_STREAMING_BUFFER_SIZE) && phase == 0) { rc = streaming_schedule_usb_transfer_in(1); if(rc) { return; } phase = 1; ++transfers; } else { streaming_detect_overrun(); return; } // Toggle the LED a bit to indicate progress. if ((transfers % 200) == 0) { led_toggle(LED4); } } /** * Sets up a task thread that will rapidly stream data to/from a USB host. */ void usb_streaming_start_streaming_to_host(volatile uint32_t *user_position_in_buffer, volatile uint32_t *user_data_in_buffer) { usb_endpoint_init(&usb0_endpoint_bulk_in); usb_endpoint_clear_stall(&usb0_endpoint_bulk_in); // Store our references to the user variables to be updated. position_in_buffer = user_position_in_buffer; data_in_buffer = user_data_in_buffer; phase = (*position_in_buffer > USB_STREAMING_BUFFER_SIZE) ? 0 : 1; // And enable USB streaming. // FIXME: support out streaming, too usb_streaming_enabled = true; } /** * Sets up a task thread that will periodically call a callback, and then deliver the collected * data to the host. */ uint32_t usb_streaming_start_periodic_data_gathering(uint32_t frequency, timer_callback_t callback, void *callback_argument) { // Allocate a periodic event timer... int rc = acquire_timer(&periodic_event_timer); if (rc) { pr_error("error: streaming: could not allocate a timer for periodic events (%u)!\n", rc); return rc; } // ... set up our USB streaming ... read_position = 0; write_position = 0; buffer_content_count = 0; usb_endpoint_init(&usb0_endpoint_bulk_in); // ... and enable data gathering. call_function_periodically(&periodic_event_timer, frequency, callback, callback_argument); return 0; } /** * Sets up a task thread that will rapidly stream data to/from a USB host. */ void usb_streaming_stop_streaming_to_host() { usb_streaming_enabled = false; usb_endpoint_disable(&usb0_endpoint_bulk_in); led_off(LED4); } /** * Halts a periodic data gathering request. */ void usb_streaming_stop_periodic_gathering(void) { cancel_periodic_function_calls(&periodic_event_timer); release_timer(&periodic_event_timer); } static uint32_t usb_streaming_submit_data(void *data_in, uint32_t count) { uint32_t original_position_in_buffer = write_position; uint8_t *data_in_window = data_in; uint32_t data_after_start = 0; // Compute the vital statistics of our buffer. const uint32_t buffer_size = sizeof(usb_bulk_buffer); // Figure out how much data we want to place directly follwing the current // write pointer. uint32_t space_remaining_to_end = buffer_size - write_position; uint32_t data_after_pointer = count; // If we'd wrap around... if (count > space_remaining_to_end) { //... copy from the write pointer to the end... data_after_pointer = space_remaining_to_end; count -= space_remaining_to_end; // and copy the remaining data to the beginning. data_after_start = count; } // Update our write pointer... write_position = (write_position + count) % buffer_size; buffer_content_count += count; // ... and perform the copy itself. memcpy(&usb_bulk_buffer[original_position_in_buffer], data_in, data_after_pointer); memcpy(&usb_bulk_buffer[0], &data_in_window[data_after_pointer], data_after_start); return 0; } /** * Submit data into the user buffer for streaming, and schedule a USB transfer to gather * the relevant data iff a transfer is available. */ uint32_t usb_streaming_send_data(void *data_in, uint32_t count) { int rc; uint32_t data_to_send; uint32_t bytes_to_end_of_buffer; // Add the data to our buffer... usb_streaming_submit_data(data_in, count); // Send either the amount of data we have available, or the bytes to the end of the buffer, whichever is less. bytes_to_end_of_buffer = sizeof(usb_bulk_buffer) - read_position; data_to_send = buffer_content_count < bytes_to_end_of_buffer ? buffer_content_count : bytes_to_end_of_buffer; // Try to schedule a USB transfer. rc = usb_transfer_schedule( &usb0_endpoint_bulk_in, &usb_bulk_buffer[read_position], data_to_send, NULL, NULL); // If we succeeded in scheduling a transfer, advance the read pointer. if (!rc) { read_position = (read_position + data_to_send) % sizeof(usb_bulk_buffer); buffer_content_count -= data_to_send; } return 0; } /** * Core USB streaming service routine: ferries data to or from the host. */ void task_usb_streaming(void) { if(!usb_streaming_enabled) { return; } // TODO: support USB streaming out, too service_usb_streaming_in(); } DEFINE_TASK(task_usb_streaming);
f8cd38a08c93f74d2df54c63eb09a8f8dc389fb0
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_0002/AKWF_0166.h
e3f14aaabd34b2bd215c69b7b31becd8df8850e4
[ "CC0-1.0" ]
permissive
KristofferKarlAxelEkstrand/AKWF-FREE
b2defa1a2d389d309be6dd2e9f968923daf80d1b
cf8171df36e9fec25416b5f568b72a6e2cb69194
refs/heads/master
2023-07-23T18:22:36.939705
2023-07-10T17:14:40
2023-07-10T17:14:40
145,817,187
359
59
CC0-1.0
2023-07-10T17:14:41
2018-08-23T07:26:56
null
UTF-8
C
false
false
4,672
h
AKWF_0166.h
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library * * Adventure Kid Waveforms(AKWF) Open waveforms library * https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/ * * This code is in the public domain, CC0 1.0 Universal (CC0 1.0) * https://creativecommons.org/publicdomain/zero/1.0/ * * Converted by Brad Roy, https://github.com/prosper00 */ /* AKWF_0166 256 samples +-----------------------------------------------------------------------------------------------------------------+ | ** *** | | ** *** ******* | | ** *** *** *** | | ** *** ********** ** | | * ** *** ** *** | |** ** *** ****** | |* * ** **** | | ** ** ** *| | ** *** **** ***** **| | ** *** **** ******* | | ** **** | | ** *** | | ** ** | | ** ** | | ******* ** | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_0166 [] = { 33397, 35413, 37461, 39676, 41927, 44234, 46520, 48764, 50920, 52956, 54851, 56575, 58128, 59483, 60653, 61605, 62347, 62841, 63098, 63095, 62859, 62392, 61738, 60916, 59971, 58925, 57825, 56699, 55596, 54546, 53577, 52702, 51920, 51223, 50588, 49990, 49403, 48802, 48164, 47483, 46758, 45979, 45124, 44175, 43105, 41900, 40548, 39050, 37413, 35659, 33806, 31879, 29899, 27892, 25876, 23868, 21884, 19936, 18033, 16186, 14401, 12688, 11070, 9566, 8202, 6998, 5965, 5100, 4395, 3834, 3394, 3055, 2791, 2588, 2425, 2296, 2193, 2111, 2044, 1987, 1920, 1831, 1703, 1528, 1309, 1059, 792, 532, 302, 121, 16, 11, 138, 419, 874, 1507, 2312, 3272, 4360, 5550, 6807, 8105, 9417, 10714, 11961, 13128, 14191, 15128, 15931, 16606, 17171, 17652, 18080, 18487, 18909, 19377, 19909, 20518, 21205, 21963, 22775, 23620, 24495, 25389, 26292, 27195, 28109, 29037, 30002, 31013, 32076, 33192, 34347, 35526, 36709, 37873, 39000, 40074, 41083, 42017, 42875, 43652, 44351, 44963, 45477, 45878, 46158, 46312, 46349, 46283, 46140, 45948, 45735, 45530, 45362, 45266, 45272, 45409, 45700, 46148, 46747, 47478, 48316, 49227, 50176, 51134, 52072, 52974, 53836, 54641, 55363, 55975, 56449, 56763, 56901, 56860, 56646, 56271, 55755, 55117, 54378, 53557, 52673, 51739, 50770, 49778, 48769, 47752, 46733, 45724, 44740, 43810, 42953, 42190, 41531, 40978, 40520, 40142, 39825, 39543, 39280, 39015, 38736, 38431, 38096, 37730, 37328, 36884, 36384, 35813, 35157, 34413, 33583, 32683, 31728, 30747, 29758, 28791, 27869, 27020, 26276, 25662, 25202, 24899, 24753, 24741, 24849, 25040, 25296, 25576, 25869, 26136, 26356, 26488, 26522, 26425, 26203, 25852, 25405, 24887, 24344, 23813, 23340, 22966, 22722, 22642, 22725, 23004, 23447, 24100, 24904, 25935, 27092, 28486, 29931, 31700, };
9ae8e9bafee52628e72deef4d58bbf7821f80f1b
0d7fc78bb265197a9c81fded765f70871e4668e6
/sample/callback_each_match.c
10ed56defcdf856ca654434b4ee2fa485e16632a
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
kkos/oniguruma
7e10a9d6e8bda7940cf66ee6b30883c3c37804f1
1713dfaed25f9ef680ba998e83767487f80cf5ae
refs/heads/master
2023-09-04T16:44:46.396571
2023-08-21T06:22:41
2023-08-21T06:22:41
38,999,874
2,164
393
NOASSERTION
2023-07-11T09:23:42
2015-07-13T08:19:17
C
UTF-8
C
false
false
4,579
c
callback_each_match.c
/* * callback_each_match.c */ #include <stdio.h> #include <string.h> #include "oniguruma.h" static int each_match_callback(const UChar* str, const UChar* end, const UChar* match_start, OnigRegion* region, void* user_data) { #if 1 fprintf(stdout, "each_match_callback:\n"); fprintf(stdout, " match at: %ld - %d: %p\n", match_start - str, region->end[0], user_data); fprintf(stdout, " region[0]: %d - %d\n", region->beg[0], region->end[0]); #else int i; i = region->beg[0]; fputc('<', stdout); while (i < region->end[0]) { fputc((int )str[i], stdout); i++; } fputc('>', stdout); #endif #if 0 /* terminate match/search if returns error code < 0 */ return ONIG_ABORT; #endif return ONIG_NORMAL; } static int search(UChar* pattern, UChar* str, OnigOptionType options, OnigOptionType runtime_options) { int r; unsigned char *start, *range, *end; regex_t* reg; OnigErrorInfo einfo; OnigRegion *region; OnigMatchParam* mp; void* user_data; r = onig_new(&reg, pattern, pattern + strlen((char* )pattern), options, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r, &einfo); fprintf(stderr, "ERROR: %s\n", s); return -1; } region = onig_region_new(); end = str + strlen((char* )str); start = str; range = end; mp = onig_new_match_param(); if (mp == 0) return -2; user_data = (void* )0x1234; onig_set_callout_user_data_of_match_param(mp, user_data); r = onig_search_with_param(reg, str, end, start, range, region, runtime_options, mp); onig_free_match_param(mp); if (r >= 0) { /* If ONIG_OPTION_CALLBACK_EACH_MATCH is used with ONIG_OPTION_FIND_LONGEST, it may also return positive value. */ fprintf(stdout, "\nr: %d\n", r); } else if (r == ONIG_MISMATCH) { /* always return ONIG_MISMATCH if ONIG_OPTION_CALLBACK_EACH_MATCH */ fprintf(stdout, "\n"); } else { /* error */ char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r); fprintf(stderr, "ERROR: %s\n", s); onig_region_free(region, 1 /* 1:free self, 0:free contents only */); onig_free(reg); onig_end(); return -1; } return 0; } static int match(UChar* pattern, UChar* str, UChar* at, OnigOptionType options, OnigOptionType runtime_options) { int r; unsigned char *start, *range, *end; regex_t* reg; OnigErrorInfo einfo; OnigRegion *region; OnigMatchParam* mp; void* user_data; r = onig_new(&reg, pattern, pattern + strlen((char* )pattern), options, ONIG_ENCODING_ASCII, ONIG_SYNTAX_DEFAULT, &einfo); if (r != ONIG_NORMAL) { char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r, &einfo); fprintf(stderr, "ERROR: %s\n", s); return -1; } region = onig_region_new(); end = str + strlen((char* )str); start = str; range = end; mp = onig_new_match_param(); if (mp == 0) return -2; user_data = (void* )0x1234; onig_set_callout_user_data_of_match_param(mp, user_data); r = onig_match_with_param(reg, str, end, at, region, runtime_options, mp); onig_free_match_param(mp); if (r >= 0) { /* If ONIG_OPTION_CALLBACK_EACH_MATCH is used with ONIG_OPTION_FIND_LONGEST, it may also return positive value. */ fprintf(stdout, "\nr: %d\n", r); } else if (r == ONIG_MISMATCH) { /* always return ONIG_MISMATCH if ONIG_OPTION_CALLBACK_EACH_MATCH */ fprintf(stdout, "\n"); } else { /* error */ char s[ONIG_MAX_ERROR_MESSAGE_LEN]; onig_error_code_to_str((UChar* )s, r); fprintf(stderr, "ERROR: %s\n", s); onig_region_free(region, 1 /* 1:free self, 0:free contents only */); onig_free(reg); onig_end(); return -1; } return 0; } extern int main(int argc, char* argv[]) { OnigEncoding use_encs[1]; static UChar* pattern = (UChar* )"a(.*)\\Kb|[e-f]+"; static UChar* str = (UChar* )"zzzzafffb"; use_encs[0] = ONIG_ENCODING_ASCII; onig_initialize(use_encs, sizeof(use_encs)/sizeof(use_encs[0])); onig_set_callback_each_match(each_match_callback); fprintf(stdout, "<search>\n"); search(pattern, str, ONIG_OPTION_NONE, ONIG_OPTION_CALLBACK_EACH_MATCH); fprintf(stdout, "<search with FIND_LONGEST>\n"); search(pattern, str, ONIG_OPTION_FIND_LONGEST, ONIG_OPTION_CALLBACK_EACH_MATCH); fprintf(stdout, "<match>\n"); match(pattern, str, str + 5, ONIG_OPTION_NONE, ONIG_OPTION_CALLBACK_EACH_MATCH); onig_end(); return 0; }
dc644fde2c5ce1254bb0d55b7ad9b28c20b8673a
fdbb74a95924e2677466614f6ab6e2bb13b2a95a
/libc/tinymath/cos.c
13f7ac54a3f4fde71c0c127e72b18bf4b456f559
[ "LLVM-exception", "MIT", "Apache-2.0", "BSD-4-Clause-UC", "BSD-2-Clause", "LicenseRef-scancode-other-permissive", "LicenseRef-scancode-public-domain", "BSD-3-Clause", "LGPL-2.0-or-later", "GPL-1.0-or-later", "LicenseRef-scancode-proprietary-license", "LicenseRef-scancode-musl-exception", "ISC" ]
permissive
jart/cosmopolitan
fb11b5658939023977060a7c6c71a74093d9cb44
0d748ad58e1063dd1f8560f18a0c75293b9415b7
refs/heads/master
2023-09-06T09:17:29.303607
2023-09-02T03:49:13
2023-09-02T03:50:18
272,457,606
11,887
435
ISC
2023-09-14T17:47:58
2020-06-15T14:16:13
C
UTF-8
C
false
false
5,330
c
cos.c
/*-*- mode:c;indent-tabs-mode:t;c-basic-offset:8;tab-width:8;coding:utf-8 -*-│ │vi: set et ft=c ts=8 tw=8 fenc=utf-8 :vi│ ╚──────────────────────────────────────────────────────────────────────────────╝ │ │ │ Musl Libc │ │ Copyright © 2005-2014 Rich Felker, et al. │ │ │ │ Permission is hereby granted, free of charge, to any person obtaining │ │ a copy of this software and associated documentation files (the │ │ "Software"), to deal in the Software without restriction, including │ │ without limitation the rights to use, copy, modify, merge, publish, │ │ distribute, sublicense, and/or sell copies of the Software, and to │ │ permit persons to whom the Software is furnished to do so, subject to │ │ the following conditions: │ │ │ │ The above copyright notice and this permission notice shall be │ │ included in all copies or substantial portions of the Software. │ │ │ │ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, │ │ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF │ │ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. │ │ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY │ │ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, │ │ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE │ │ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. │ │ │ ╚─────────────────────────────────────────────────────────────────────────────*/ #include "libc/math.h" #include "libc/tinymath/feval.internal.h" #include "libc/tinymath/kernel.internal.h" asm(".ident\t\"\\n\\n\ fdlibm (fdlibm license)\\n\ Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\""); asm(".ident\t\"\\n\\n\ Musl libc (MIT License)\\n\ Copyright 2005-2014 Rich Felker, et. al.\""); asm(".include \"libc/disclaimer.inc\""); // clang-format off /* origin: FreeBSD /usr/src/lib/msun/src/s_cos.c */ /* * ==================================================== * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * * Developed at SunPro, a Sun Microsystems, Inc. business. * Permission to use, copy, modify, and distribute this * software is freely granted, provided that this notice * is preserved. * ==================================================== */ /* cos(x) * Return cosine function of x. * * kernel function: * __sin ... sine function on [-pi/4,pi/4] * __cos ... cosine function on [-pi/4,pi/4] * __rem_pio2 ... argument reduction routine * * Method. * Let S,C and T denote the sin, cos and tan respectively on * [-PI/4, +PI/4]. Reduce the argument x to y1+y2 = x-k*pi/2 * in [-pi/4 , +pi/4], and let n = k mod 4. * We have * * n sin(x) cos(x) tan(x) * ---------------------------------------------------------- * 0 S C T * 1 C -S -1/T * 2 -S -C T * 3 -C S -1/T * ---------------------------------------------------------- * * Special cases: * Let trig be any of sin, cos, or tan. * trig(+-INF) is NaN, with signals; * trig(NaN) is that NaN; * * Accuracy: * TRIG(x) returns trig(x) nearly rounded */ #define asuint64(f) ((union{double _f; uint64_t _i;}){f})._i #define gethighw(hi,d) (hi) = asuint64(d) >> 32 /** * Returns cosine of 𝑥. * @note should take ~5ns */ double cos(double x) { double y[2]; uint32_t ix; unsigned n; gethighw(ix, x); ix &= 0x7fffffff; /* |x| ~< pi/4 */ if (ix <= 0x3fe921fb) { if (ix < 0x3e46a09e) { /* |x| < 2**-27 * sqrt(2) */ /* raise inexact if x!=0 */ feval(x + 0x1p120f); return 1.0; } return __cos(x, 0); } /* cos(Inf or NaN) is NaN */ if (ix >= 0x7ff00000) return x-x; /* argument reduction */ n = __rem_pio2(x, y); switch (n&3) { case 0: return __cos(y[0], y[1]); case 1: return -__sin(y[0], y[1], 1); case 2: return -__cos(y[0], y[1]); default: return __sin(y[0], y[1], 1); } } #if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024 __weak_reference(cos, cosl); #endif
590553dbb6addb952bb6c6cf61934a744460f94f
cf60f9591fef521d3092f81785de7942d0ca568e
/PubNub/include/PNAPNSModificationAPICallBuilder.h
7e9706a4adb99bde92df9a15372ab104b0245e54
[ "MIT" ]
permissive
pubnub/objective-c
a49e2e5c7898eb893b601ae31a098361fb8b4406
eef06ae76fd45931ea09900e3b3ce50133870eca
refs/heads/master
2023-04-07T08:28:47.174178
2023-01-05T11:15:57
2023-01-05T11:15:57
8,490,984
137
145
NOASSERTION
2023-03-30T08:47:36
2013-03-01T00:10:41
Objective-C
UTF-8
C
false
false
65
h
PNAPNSModificationAPICallBuilder.h
../Data/Builders/API Call/APNS/PNAPNSModificationAPICallBuilder.h
fc8a3b72ae43f46dc864c48f7472cf24656dabbf
c2634ebec1d4448e372d174f459c3cbc03fd1edc
/lib/node_modules/@stdlib/ndarray/base/unary/include/stdlib/ndarray/base/unary/s_i.h
87e714ba9c147b44170e689bb37bf611cf423a53
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference", "MIT", "SunPro", "BSD-3-Clause", "BSL-1.0", "LicenseRef-scancode-public-domain" ]
permissive
stdlib-js/stdlib
ede11aee78f08e4f78a0bb939cb0bc244850b55b
f10c6e7db1a2b15cdd2b6237dd0927466ebd7278
refs/heads/develop
2023-09-05T03:29:36.368208
2023-09-03T22:42:11
2023-09-03T22:42:11
54,614,238
4,163
230
Apache-2.0
2023-09-13T21:26:07
2016-03-24T04:19:52
JavaScript
UTF-8
C
false
false
5,758
h
s_i.h
/** * @license Apache-2.0 * * Copyright (c) 2023 The Stdlib Authors. * * 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. */ /* * The following is auto-generated. Do not manually edit. See scripts/loops.js. */ #ifndef STDLIB_NDARRAY_BASE_UNARY_S_I_H #define STDLIB_NDARRAY_BASE_UNARY_S_I_H #include "stdlib/ndarray/ctor.h" #include <stdint.h> /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. */ #ifdef __cplusplus extern "C" { #endif /** * Applies a unary callback to an input ndarray and assigns results to elements in an output ndarray. */ int8_t stdlib_ndarray_s_i( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a zero-dimensional input ndarray and assigns results to elements in a zero-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_0d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a one-dimensional input ndarray and assigns results to elements in a one-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_1d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a two-dimensional input ndarray and assigns results to elements in a two-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_2d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a two-dimensional input ndarray and assigns results to elements in a two-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_2d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a three-dimensional input ndarray and assigns results to elements in a three-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_3d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a three-dimensional input ndarray and assigns results to elements in a three-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_3d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a four-dimensional input ndarray and assigns results to elements in a four-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_4d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a four-dimensional input ndarray and assigns results to elements in a four-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_4d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a five-dimensional input ndarray and assigns results to elements in a five-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_5d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a five-dimensional input ndarray and assigns results to elements in a five-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_5d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a six-dimensional input ndarray and assigns results to elements in a six-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_6d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a six-dimensional input ndarray and assigns results to elements in a six-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_6d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a seven-dimensional input ndarray and assigns results to elements in a seven-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_7d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a seven-dimensional input ndarray and assigns results to elements in a seven-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_7d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to an eight-dimensional input ndarray and assigns results to elements in an eight-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_8d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to an eight-dimensional input ndarray and assigns results to elements in an eight-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_8d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a nine-dimensional input ndarray and assigns results to elements in a nine-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_9d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a nine-dimensional input ndarray and assigns results to elements in a nine-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_9d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a ten-dimensional input ndarray and assigns results to elements in a ten-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_10d( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to a ten-dimensional input ndarray and assigns results to elements in a ten-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_10d_blocked( struct ndarray *arrays[], void *fcn ); /** * Applies a unary callback to an n-dimensional input ndarray and assigns results to elements in an n-dimensional output ndarray. */ int8_t stdlib_ndarray_s_i_nd( struct ndarray *arrays[], void *fcn ); #ifdef __cplusplus } #endif #endif // !STDLIB_NDARRAY_BASE_UNARY_S_I_H
a68d317e7c483c0f7ad8eab3d274c053ea9b903f
14ed2724b7c610543959f23d401e7b90283e63c4
/Source/dos32/fogtable.h
a17a5bcd972b991ab77236ebb2419f24aaaae30d
[ "MIT" ]
permissive
powervr-graphics/PowerVR-Series1
d0ec36623d257e05c078e5d3f4bdfcd786ba46a4
c8c11cbe29c5b758ed1ef9600fc8614fc8da618e
refs/heads/main
2023-08-14T18:42:40.609670
2022-03-23T10:29:37
2022-03-23T10:29:37
467,444,934
260
17
null
null
null
null
UTF-8
C
false
false
3,088
h
fogtable.h
/****************************************************************************** * Name : fogtable.h * Title : this is the fog table to be loaded into sabre. * Author : Peter Leaback * Created : 20/10/1995 * * Copyright : 1995-2022 Imagination Technologies (c) * License : MIT * * Description : * * Platform : ANSI * * Modifications: * $Log: fogtable.h,v $ * Revision 1.2 1997/06/18 14:46:33 mjg * Replaced Windows types (UINT and the rest) with sgl_ typedefs. * * Revision 1.1 1997/03/31 19:01:38 mlj * Initial revision * * Revision 1.1 1996/06/10 11:51:12 jop * Initial revision * * Revision 1.1 1996/06/10 11:39:13 jop * Initial revision * * Revision 1.2 1995/10/20 19:31:07 pdl * *** empty log message *** * * Revision 1.1 1995/10/20 18:37:21 pdl * Initial revision * * *****************************************************************************/ #ifdef __FOGTABLE_H__ #pragma message ("Fogtable header message") #else #define __FOGTABLE_H__ static sgl_uint32 FogTable[]={ 0x000000ff, 0x000000fe, 0x000000fd, 0x000000fb, 0x000000fa, 0x000000f9, 0x000000f7, 0x000000f6, 0x000000f5, 0x000000f3, 0x000000f2, 0x000000f1, 0x000000ef, 0x000000ee, 0x000000ed, 0x000000ec, 0x000000ea, 0x000000e9, 0x000000e8, 0x000000e6, 0x000000e5, 0x000000e4, 0x000000e3, 0x000000e2, 0x000000e0, 0x000000df, 0x000000de, 0x000000dd, 0x000000db, 0x000000da, 0x000000d9, 0x000000d8, 0x000000d7, 0x000000d6, 0x000000d4, 0x000000d3, 0x000000d2, 0x000000d1, 0x000000d0, 0x000000cf, 0x000000ce, 0x000000cd, 0x000000cb, 0x000000ca, 0x000000c9, 0x000000c8, 0x000000c7, 0x000000c6, 0x000000c5, 0x000000c4, 0x000000c3, 0x000000c2, 0x000000c1, 0x000000c0, 0x000000bf, 0x000000be, 0x000000bd, 0x000000bc, 0x000000ba, 0x000000b9, 0x000000b8, 0x000000b7, 0x000000b6, 0x000000b6, 0x000000b5, 0x000000b4, 0x000000b3, 0x000000b2, 0x000000b1, 0x000000b0, 0x000000af, 0x000000ae, 0x000000ad, 0x000000ac, 0x000000ab, 0x000000aa, 0x000000a9, 0x000000a8, 0x000000a7, 0x000000a6, 0x000000a5, 0x000000a5, 0x000000a4, 0x000000a3, 0x000000a2, 0x000000a1, 0x000000a0, 0x0000009f, 0x0000009e, 0x0000009e, 0x0000009d, 0x0000009c, 0x0000009b, 0x0000009a, 0x00000099, 0x00000099, 0x00000098, 0x00000097, 0x00000096, 0x00000095, 0x00000094, 0x00000094, 0x00000093, 0x00000092, 0x00000091, 0x00000090, 0x00000090, 0x0000008f, 0x0000008e, 0x0000008d, 0x0000008d, 0x0000008c, 0x0000008b, 0x0000008a, 0x0000008a, 0x00000089, 0x00000088, 0x00000087, 0x00000087, 0x00000086, 0x00000085, 0x00000084, 0x00000084, 0x00000083, 0x00000082, 0x00000082, 0x00000081, 0x00000080}; #endif
803e9121b4757b4ce4642c3b26ad77c4d1f57ead
8b8ea4b0780d55e3ac53d3b7a42e12ccccd0a45b
/components/esp_codec_dev/device/es7210/es7210_reg.h
d5dcb8bd707b65c8529c1426767e5fbfff25b37f
[ "Apache-2.0", "MIT", "LicenseRef-scancode-other-permissive" ]
permissive
espressif/esp-adf
f55d3a21d3968f209dbe0fa83f1ec1270386c206
5c7d67ece63d5cf9d9c53f768f963265978f09c7
refs/heads/master
2023-09-06T05:29:57.930802
2023-09-04T06:42:42
2023-09-04T06:42:42
127,718,181
1,317
662
NOASSERTION
2023-08-10T20:46:28
2018-04-02T07:03:49
C
UTF-8
C
false
false
2,608
h
es7210_reg.h
/* * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #ifndef _ES7210_REG_H #define _ES7210_REG_H #ifdef __cplusplus extern "C" { #endif #define ES7210_RESET_REG00 0x00 /* Reset control */ #define ES7210_CLOCK_OFF_REG01 0x01 /* Used to turn off the ADC clock */ #define ES7210_MAINCLK_REG02 0x02 /* Set ADC clock frequency division */ #define ES7210_MASTER_CLK_REG03 0x03 /* MCLK source $ SCLK division */ #define ES7210_LRCK_DIVH_REG04 0x04 /* lrck_divh */ #define ES7210_LRCK_DIVL_REG05 0x05 /* lrck_divl */ #define ES7210_POWER_DOWN_REG06 0x06 /* power down */ #define ES7210_OSR_REG07 0x07 #define ES7210_MODE_CONFIG_REG08 0x08 /* Set master/slave & channels */ #define ES7210_TIME_CONTROL0_REG09 0x09 /* Set Chip intial state period*/ #define ES7210_TIME_CONTROL1_REG0A 0x0A /* Set Power up state period */ #define ES7210_SDP_INTERFACE1_REG11 0x11 /* Set sample & fmt */ #define ES7210_SDP_INTERFACE2_REG12 0x12 /* Pins state */ #define ES7210_ADC_AUTOMUTE_REG13 0x13 /* Set mute */ #define ES7210_ADC34_MUTERANGE_REG14 0x14 /* Set mute range */ #define ES7210_ADC34_HPF2_REG20 0x20 /* HPF */ #define ES7210_ADC34_HPF1_REG21 0x21 #define ES7210_ADC12_HPF1_REG22 0x22 #define ES7210_ADC12_HPF2_REG23 0x23 #define ES7210_ANALOG_REG40 0x40 /* ANALOG Power */ #define ES7210_MIC12_BIAS_REG41 0x41 #define ES7210_MIC34_BIAS_REG42 0x42 #define ES7210_MIC1_GAIN_REG43 0x43 #define ES7210_MIC2_GAIN_REG44 0x44 #define ES7210_MIC3_GAIN_REG45 0x45 #define ES7210_MIC4_GAIN_REG46 0x46 #define ES7210_MIC1_POWER_REG47 0x47 #define ES7210_MIC2_POWER_REG48 0x48 #define ES7210_MIC3_POWER_REG49 0x49 #define ES7210_MIC4_POWER_REG4A 0x4A #define ES7210_MIC12_POWER_REG4B 0x4B /* MICBias & ADC & PGA Power */ #define ES7210_MIC34_POWER_REG4C 0x4C typedef enum { ES7210_AD1_AD0_00 = 0x80, ES7210_AD1_AD0_01 = 0x82, ES7210_AD1_AD0_10 = 0x84, ES7210_AD1_AD0_11 = 0x86 } es7210_address_t; typedef enum { ES7210_INPUT_MIC1 = 0x01, ES7210_INPUT_MIC2 = 0x02, ES7210_INPUT_MIC3 = 0x04, ES7210_INPUT_MIC4 = 0x08 } es7210_input_mics_t; typedef enum gain_value { GAIN_0DB = 0, GAIN_3DB, GAIN_6DB, GAIN_9DB, GAIN_12DB, GAIN_15DB, GAIN_18DB, GAIN_21DB, GAIN_24DB, GAIN_27DB, GAIN_30DB, GAIN_33DB, GAIN_34_5DB, GAIN_36DB, GAIN_37_5DB, } es7210_gain_value_t; #ifdef __cplusplus } #endif #endif /* _ES7210_H_ */
c0153bd2c4280c14288ed226e0a521d8337b5526
4674b8088ffdf55905d44995f08a0792a3e4cd5c
/src/rsn_supp/tdls.c
14b346a6ed9b562ed5b874c4964474f4fd66e11f
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
vanhoefm/krackattacks-scripts
41daca791638a92aa4cfa68a582e46119037560e
4b78669686f74efe664c6543b1b5b1616b22f902
refs/heads/research
2022-10-29T20:21:11.512335
2022-10-16T18:44:41
2022-10-16T18:44:41
107,408,514
2,184
577
NOASSERTION
2021-07-06T12:43:49
2017-10-18T12:58:08
C
UTF-8
C
false
false
83,967
c
tdls.c
/* * wpa_supplicant - TDLS * Copyright (c) 2010-2011, Atheros Communications * * This software may be distributed under the terms of the BSD license. * See README for more details. */ #include "utils/includes.h" #include "utils/common.h" #include "utils/eloop.h" #include "utils/os.h" #include "common/ieee802_11_defs.h" #include "common/ieee802_11_common.h" #include "crypto/sha256.h" #include "crypto/crypto.h" #include "crypto/aes_wrap.h" #include "rsn_supp/wpa.h" #include "rsn_supp/wpa_ie.h" #include "rsn_supp/wpa_i.h" #include "drivers/driver.h" #include "l2_packet/l2_packet.h" #ifdef CONFIG_TDLS_TESTING #define TDLS_TESTING_LONG_FRAME BIT(0) #define TDLS_TESTING_ALT_RSN_IE BIT(1) #define TDLS_TESTING_DIFF_BSSID BIT(2) #define TDLS_TESTING_SHORT_LIFETIME BIT(3) #define TDLS_TESTING_WRONG_LIFETIME_RESP BIT(4) #define TDLS_TESTING_WRONG_LIFETIME_CONF BIT(5) #define TDLS_TESTING_LONG_LIFETIME BIT(6) #define TDLS_TESTING_CONCURRENT_INIT BIT(7) #define TDLS_TESTING_NO_TPK_EXPIRATION BIT(8) #define TDLS_TESTING_DECLINE_RESP BIT(9) #define TDLS_TESTING_IGNORE_AP_PROHIBIT BIT(10) #define TDLS_TESTING_WRONG_MIC BIT(11) #define TDLS_TESTING_DOUBLE_TPK_M2 BIT(12) unsigned int tdls_testing = 0; #endif /* CONFIG_TDLS_TESTING */ #define TPK_LIFETIME 43200 /* 12 hours */ #define TPK_M1_RETRY_COUNT 3 #define TPK_M1_TIMEOUT 5000 /* in milliseconds */ #define TPK_M2_RETRY_COUNT 10 #define TPK_M2_TIMEOUT 500 /* in milliseconds */ #define TDLS_MIC_LEN 16 #define TDLS_TIMEOUT_LEN 4 struct wpa_tdls_ftie { u8 ie_type; /* FTIE */ u8 ie_len; u8 mic_ctrl[2]; u8 mic[TDLS_MIC_LEN]; u8 Anonce[WPA_NONCE_LEN]; /* Responder Nonce in TDLS */ u8 Snonce[WPA_NONCE_LEN]; /* Initiator Nonce in TDLS */ /* followed by optional elements */ } STRUCT_PACKED; struct wpa_tdls_timeoutie { u8 ie_type; /* Timeout IE */ u8 ie_len; u8 interval_type; u8 value[TDLS_TIMEOUT_LEN]; } STRUCT_PACKED; struct wpa_tdls_lnkid { u8 ie_type; /* Link Identifier IE */ u8 ie_len; u8 bssid[ETH_ALEN]; u8 init_sta[ETH_ALEN]; u8 resp_sta[ETH_ALEN]; } STRUCT_PACKED; /* TDLS frame headers as per IEEE Std 802.11z-2010 */ struct wpa_tdls_frame { u8 payloadtype; /* IEEE80211_TDLS_RFTYPE */ u8 category; /* Category */ u8 action; /* Action (enum tdls_frame_type) */ } STRUCT_PACKED; static u8 * wpa_add_tdls_timeoutie(u8 *pos, u8 *ie, size_t ie_len, u32 tsecs); static void wpa_tdls_tpk_retry_timeout(void *eloop_ctx, void *timeout_ctx); static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer); static void wpa_tdls_disable_peer_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer); static int wpa_tdls_send_teardown(struct wpa_sm *sm, const u8 *addr, u16 reason_code); #define TDLS_MAX_IE_LEN 80 #define IEEE80211_MAX_SUPP_RATES 32 struct wpa_tdls_peer { struct wpa_tdls_peer *next; unsigned int reconfig_key:1; int initiator; /* whether this end was initiator for TDLS setup */ u8 addr[ETH_ALEN]; /* other end MAC address */ u8 inonce[WPA_NONCE_LEN]; /* Initiator Nonce */ u8 rnonce[WPA_NONCE_LEN]; /* Responder Nonce */ u8 rsnie_i[TDLS_MAX_IE_LEN]; /* Initiator RSN IE */ size_t rsnie_i_len; u8 rsnie_p[TDLS_MAX_IE_LEN]; /* Peer RSN IE */ size_t rsnie_p_len; u32 lifetime; int cipher; /* Selected cipher (WPA_CIPHER_*) */ u8 dtoken; struct tpk { u8 kck[16]; /* TPK-KCK */ u8 tk[16]; /* TPK-TK; assuming only CCMP will be used */ } tpk; int tpk_set; int tk_set; /* TPK-TK configured to the driver */ int tpk_success; int tpk_in_progress; struct tpk_timer { u8 dest[ETH_ALEN]; int count; /* Retry Count */ int timer; /* Timeout in milliseconds */ u8 action_code; /* TDLS frame type */ u8 dialog_token; u16 status_code; u32 peer_capab; int buf_len; /* length of TPK message for retransmission */ u8 *buf; /* buffer for TPK message */ } sm_tmr; u16 capability; u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; size_t supp_rates_len; struct ieee80211_ht_capabilities *ht_capabilities; struct ieee80211_vht_capabilities *vht_capabilities; u8 qos_info; u16 aid; u8 *ext_capab; size_t ext_capab_len; u8 *supp_channels; size_t supp_channels_len; u8 *supp_oper_classes; size_t supp_oper_classes_len; u8 wmm_capable; /* channel switch currently enabled */ int chan_switch_enabled; }; static int wpa_tdls_get_privacy(struct wpa_sm *sm) { /* * Get info needed from supplicant to check if the current BSS supports * security. Other than OPEN mode, rest are considered secured * WEP/WPA/WPA2 hence TDLS frames are processed for TPK handshake. */ return sm->pairwise_cipher != WPA_CIPHER_NONE; } static u8 * wpa_add_ie(u8 *pos, const u8 *ie, size_t ie_len) { os_memcpy(pos, ie, ie_len); return pos + ie_len; } static int wpa_tdls_del_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { if (wpa_sm_set_key(sm, WPA_ALG_NONE, peer->addr, 0, 0, NULL, 0, NULL, 0) < 0) { wpa_printf(MSG_WARNING, "TDLS: Failed to delete TPK-TK from " "the driver"); return -1; } return 0; } static int wpa_tdls_set_key(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { u8 key_len; u8 rsc[6]; enum wpa_alg alg; if (peer->tk_set) { /* * This same TPK-TK has already been configured to the driver * and this new configuration attempt (likely due to an * unexpected retransmitted frame) would result in clearing * the TX/RX sequence number which can break security, so must * not allow that to happen. */ wpa_printf(MSG_INFO, "TDLS: TPK-TK for the peer " MACSTR " has already been configured to the driver - do not reconfigure", MAC2STR(peer->addr)); return -1; } os_memset(rsc, 0, 6); switch (peer->cipher) { case WPA_CIPHER_CCMP: alg = WPA_ALG_CCMP; key_len = 16; break; case WPA_CIPHER_NONE: wpa_printf(MSG_DEBUG, "TDLS: Pairwise Cipher Suite: " "NONE - do not use pairwise keys"); return -1; default: wpa_printf(MSG_WARNING, "TDLS: Unsupported pairwise cipher %d", sm->pairwise_cipher); return -1; } wpa_printf(MSG_DEBUG, "TDLS: Configure pairwise key for peer " MACSTR, MAC2STR(peer->addr)); if (wpa_sm_set_key(sm, alg, peer->addr, -1, 1, rsc, sizeof(rsc), peer->tpk.tk, key_len) < 0) { wpa_printf(MSG_WARNING, "TDLS: Failed to set TPK to the " "driver"); return -1; } peer->tk_set = 1; return 0; } static int wpa_tdls_send_tpk_msg(struct wpa_sm *sm, const u8 *dst, u8 action_code, u8 dialog_token, u16 status_code, u32 peer_capab, int initiator, const u8 *buf, size_t len) { return wpa_sm_send_tdls_mgmt(sm, dst, action_code, dialog_token, status_code, peer_capab, initiator, buf, len); } static int wpa_tdls_tpk_send(struct wpa_sm *sm, const u8 *dest, u8 action_code, u8 dialog_token, u16 status_code, u32 peer_capab, int initiator, const u8 *msg, size_t msg_len) { struct wpa_tdls_peer *peer; wpa_printf(MSG_DEBUG, "TDLS: TPK send dest=" MACSTR " action_code=%u " "dialog_token=%u status_code=%u peer_capab=%u initiator=%d " "msg_len=%u", MAC2STR(dest), action_code, dialog_token, status_code, peer_capab, initiator, (unsigned int) msg_len); if (wpa_tdls_send_tpk_msg(sm, dest, action_code, dialog_token, status_code, peer_capab, initiator, msg, msg_len)) { wpa_printf(MSG_INFO, "TDLS: Failed to send message " "(action_code=%u)", action_code); return -1; } if (action_code == WLAN_TDLS_SETUP_CONFIRM || action_code == WLAN_TDLS_TEARDOWN || action_code == WLAN_TDLS_DISCOVERY_REQUEST || action_code == WLAN_TDLS_DISCOVERY_RESPONSE) return 0; /* No retries */ for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, dest, ETH_ALEN) == 0) break; } if (peer == NULL) { wpa_printf(MSG_INFO, "TDLS: No matching entry found for " "retry " MACSTR, MAC2STR(dest)); return 0; } eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); if (action_code == WLAN_TDLS_SETUP_RESPONSE) { peer->sm_tmr.count = TPK_M2_RETRY_COUNT; peer->sm_tmr.timer = TPK_M2_TIMEOUT; } else { peer->sm_tmr.count = TPK_M1_RETRY_COUNT; peer->sm_tmr.timer = TPK_M1_TIMEOUT; } /* Copy message to resend on timeout */ os_memcpy(peer->sm_tmr.dest, dest, ETH_ALEN); peer->sm_tmr.action_code = action_code; peer->sm_tmr.dialog_token = dialog_token; peer->sm_tmr.status_code = status_code; peer->sm_tmr.peer_capab = peer_capab; peer->sm_tmr.buf_len = msg_len; os_free(peer->sm_tmr.buf); peer->sm_tmr.buf = os_memdup(msg, msg_len); if (peer->sm_tmr.buf == NULL) return -1; wpa_printf(MSG_DEBUG, "TDLS: Retry timeout registered " "(action_code=%u)", action_code); eloop_register_timeout(peer->sm_tmr.timer / 1000, (peer->sm_tmr.timer % 1000) * 1000, wpa_tdls_tpk_retry_timeout, sm, peer); return 0; } static int wpa_tdls_do_teardown(struct wpa_sm *sm, struct wpa_tdls_peer *peer, u16 reason_code) { int ret; ret = wpa_tdls_send_teardown(sm, peer->addr, reason_code); /* disable the link after teardown was sent */ wpa_tdls_disable_peer_link(sm, peer); return ret; } static void wpa_tdls_tpk_retry_timeout(void *eloop_ctx, void *timeout_ctx) { struct wpa_sm *sm = eloop_ctx; struct wpa_tdls_peer *peer = timeout_ctx; if (peer->sm_tmr.count) { peer->sm_tmr.count--; wpa_printf(MSG_INFO, "TDLS: Retrying sending of message " "(action_code=%u)", peer->sm_tmr.action_code); if (peer->sm_tmr.buf == NULL) { wpa_printf(MSG_INFO, "TDLS: No retry buffer available " "for action_code=%u", peer->sm_tmr.action_code); eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); return; } /* resend TPK Handshake Message to Peer */ if (wpa_tdls_send_tpk_msg(sm, peer->sm_tmr.dest, peer->sm_tmr.action_code, peer->sm_tmr.dialog_token, peer->sm_tmr.status_code, peer->sm_tmr.peer_capab, peer->initiator, peer->sm_tmr.buf, peer->sm_tmr.buf_len)) { wpa_printf(MSG_INFO, "TDLS: Failed to retry " "transmission"); } eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); eloop_register_timeout(peer->sm_tmr.timer / 1000, (peer->sm_tmr.timer % 1000) * 1000, wpa_tdls_tpk_retry_timeout, sm, peer); } else { eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); wpa_printf(MSG_DEBUG, "TDLS: Sending Teardown Request"); wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } } static void wpa_tdls_tpk_retry_timeout_cancel(struct wpa_sm *sm, struct wpa_tdls_peer *peer, u8 action_code) { if (action_code == peer->sm_tmr.action_code) { wpa_printf(MSG_DEBUG, "TDLS: Retry timeout cancelled for " "action_code=%u", action_code); /* Cancel Timeout registered */ eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); /* free all resources meant for retry */ os_free(peer->sm_tmr.buf); peer->sm_tmr.buf = NULL; peer->sm_tmr.count = 0; peer->sm_tmr.timer = 0; peer->sm_tmr.buf_len = 0; peer->sm_tmr.action_code = 0xff; } else { wpa_printf(MSG_INFO, "TDLS: Error in cancelling retry timeout " "(Unknown action_code=%u)", action_code); } } static void wpa_tdls_generate_tpk(struct wpa_tdls_peer *peer, const u8 *own_addr, const u8 *bssid) { u8 key_input[SHA256_MAC_LEN]; const u8 *nonce[2]; size_t len[2]; u8 data[3 * ETH_ALEN]; /* IEEE Std 802.11-2016 12.7.9.2: * TPK-Key-Input = Hash(min(SNonce, ANonce) || max(SNonce, ANonce)) * Hash = SHA-256 for TDLS */ len[0] = WPA_NONCE_LEN; len[1] = WPA_NONCE_LEN; if (os_memcmp(peer->inonce, peer->rnonce, WPA_NONCE_LEN) < 0) { nonce[0] = peer->inonce; nonce[1] = peer->rnonce; } else { nonce[0] = peer->rnonce; nonce[1] = peer->inonce; } wpa_hexdump(MSG_DEBUG, "TDLS: min(Nonce)", nonce[0], WPA_NONCE_LEN); wpa_hexdump(MSG_DEBUG, "TDLS: max(Nonce)", nonce[1], WPA_NONCE_LEN); sha256_vector(2, nonce, len, key_input); wpa_hexdump_key(MSG_DEBUG, "TDLS: TPK-Key-Input", key_input, SHA256_MAC_LEN); /* * TPK = KDF-Hash-Length(TPK-Key-Input, "TDLS PMK", * min(MAC_I, MAC_R) || max(MAC_I, MAC_R) || BSSID) */ if (os_memcmp(own_addr, peer->addr, ETH_ALEN) < 0) { os_memcpy(data, own_addr, ETH_ALEN); os_memcpy(data + ETH_ALEN, peer->addr, ETH_ALEN); } else { os_memcpy(data, peer->addr, ETH_ALEN); os_memcpy(data + ETH_ALEN, own_addr, ETH_ALEN); } os_memcpy(data + 2 * ETH_ALEN, bssid, ETH_ALEN); wpa_hexdump(MSG_DEBUG, "TDLS: KDF Context", data, sizeof(data)); sha256_prf(key_input, SHA256_MAC_LEN, "TDLS PMK", data, sizeof(data), (u8 *) &peer->tpk, sizeof(peer->tpk)); wpa_hexdump_key(MSG_DEBUG, "TDLS: TPK-KCK", peer->tpk.kck, sizeof(peer->tpk.kck)); wpa_hexdump_key(MSG_DEBUG, "TDLS: TPK-TK", peer->tpk.tk, sizeof(peer->tpk.tk)); peer->tpk_set = 1; } /** * wpa_tdls_ftie_mic - Calculate TDLS FTIE MIC * @kck: TPK-KCK * @lnkid: Pointer to the beginning of Link Identifier IE * @rsnie: Pointer to the beginning of RSN IE used for handshake * @timeoutie: Pointer to the beginning of Timeout IE used for handshake * @ftie: Pointer to the beginning of FT IE * @mic: Pointer for writing MIC * * Calculate MIC for TDLS frame. */ static int wpa_tdls_ftie_mic(const u8 *kck, u8 trans_seq, const u8 *lnkid, const u8 *rsnie, const u8 *timeoutie, const u8 *ftie, u8 *mic) { u8 *buf, *pos; struct wpa_tdls_ftie *_ftie; const struct wpa_tdls_lnkid *_lnkid; int ret; int len = 2 * ETH_ALEN + 1 + 2 + lnkid[1] + 2 + rsnie[1] + 2 + timeoutie[1] + 2 + ftie[1]; buf = os_zalloc(len); if (!buf) { wpa_printf(MSG_WARNING, "TDLS: No memory for MIC calculation"); return -1; } pos = buf; _lnkid = (const struct wpa_tdls_lnkid *) lnkid; /* 1) TDLS initiator STA MAC address */ os_memcpy(pos, _lnkid->init_sta, ETH_ALEN); pos += ETH_ALEN; /* 2) TDLS responder STA MAC address */ os_memcpy(pos, _lnkid->resp_sta, ETH_ALEN); pos += ETH_ALEN; /* 3) Transaction Sequence number */ *pos++ = trans_seq; /* 4) Link Identifier IE */ os_memcpy(pos, lnkid, 2 + lnkid[1]); pos += 2 + lnkid[1]; /* 5) RSN IE */ os_memcpy(pos, rsnie, 2 + rsnie[1]); pos += 2 + rsnie[1]; /* 6) Timeout Interval IE */ os_memcpy(pos, timeoutie, 2 + timeoutie[1]); pos += 2 + timeoutie[1]; /* 7) FTIE, with the MIC field of the FTIE set to 0 */ os_memcpy(pos, ftie, 2 + ftie[1]); _ftie = (struct wpa_tdls_ftie *) pos; os_memset(_ftie->mic, 0, TDLS_MIC_LEN); pos += 2 + ftie[1]; wpa_hexdump(MSG_DEBUG, "TDLS: Data for FTIE MIC", buf, pos - buf); wpa_hexdump_key(MSG_DEBUG, "TDLS: KCK", kck, 16); ret = omac1_aes_128(kck, buf, pos - buf, mic); os_free(buf); wpa_hexdump(MSG_DEBUG, "TDLS: FTIE MIC", mic, 16); return ret; } /** * wpa_tdls_key_mic_teardown - Calculate TDLS FTIE MIC for Teardown frame * @kck: TPK-KCK * @trans_seq: Transaction Sequence Number (4 - Teardown) * @rcode: Reason code for Teardown * @dtoken: Dialog Token used for that particular link * @lnkid: Pointer to the beginning of Link Identifier IE * @ftie: Pointer to the beginning of FT IE * @mic: Pointer for writing MIC * * Calculate MIC for TDLS frame. */ static int wpa_tdls_key_mic_teardown(const u8 *kck, u8 trans_seq, u16 rcode, u8 dtoken, const u8 *lnkid, const u8 *ftie, u8 *mic) { u8 *buf, *pos; struct wpa_tdls_ftie *_ftie; int ret; int len; if (lnkid == NULL) return -1; len = 2 + lnkid[1] + sizeof(rcode) + sizeof(dtoken) + sizeof(trans_seq) + 2 + ftie[1]; buf = os_zalloc(len); if (!buf) { wpa_printf(MSG_WARNING, "TDLS: No memory for MIC calculation"); return -1; } pos = buf; /* 1) Link Identifier IE */ os_memcpy(pos, lnkid, 2 + lnkid[1]); pos += 2 + lnkid[1]; /* 2) Reason Code */ WPA_PUT_LE16(pos, rcode); pos += sizeof(rcode); /* 3) Dialog token */ *pos++ = dtoken; /* 4) Transaction Sequence number */ *pos++ = trans_seq; /* 7) FTIE, with the MIC field of the FTIE set to 0 */ os_memcpy(pos, ftie, 2 + ftie[1]); _ftie = (struct wpa_tdls_ftie *) pos; os_memset(_ftie->mic, 0, TDLS_MIC_LEN); pos += 2 + ftie[1]; wpa_hexdump(MSG_DEBUG, "TDLS: Data for FTIE MIC", buf, pos - buf); wpa_hexdump_key(MSG_DEBUG, "TDLS: KCK", kck, 16); ret = omac1_aes_128(kck, buf, pos - buf, mic); os_free(buf); wpa_hexdump(MSG_DEBUG, "TDLS: FTIE MIC", mic, 16); return ret; } static int wpa_supplicant_verify_tdls_mic(u8 trans_seq, struct wpa_tdls_peer *peer, const u8 *lnkid, const u8 *timeoutie, const struct wpa_tdls_ftie *ftie) { u8 mic[16]; if (peer->tpk_set) { wpa_tdls_ftie_mic(peer->tpk.kck, trans_seq, lnkid, peer->rsnie_p, timeoutie, (u8 *) ftie, mic); if (os_memcmp_const(mic, ftie->mic, 16) != 0) { wpa_printf(MSG_INFO, "TDLS: Invalid MIC in FTIE - " "dropping packet"); wpa_hexdump(MSG_DEBUG, "TDLS: Received MIC", ftie->mic, 16); wpa_hexdump(MSG_DEBUG, "TDLS: Calculated MIC", mic, 16); return -1; } } else { wpa_printf(MSG_WARNING, "TDLS: Could not verify TDLS MIC, " "TPK not set - dropping packet"); return -1; } return 0; } static int wpa_supplicant_verify_tdls_mic_teardown( u8 trans_seq, u16 rcode, u8 dtoken, struct wpa_tdls_peer *peer, const u8 *lnkid, const struct wpa_tdls_ftie *ftie) { u8 mic[16]; if (peer->tpk_set) { wpa_tdls_key_mic_teardown(peer->tpk.kck, trans_seq, rcode, dtoken, lnkid, (u8 *) ftie, mic); if (os_memcmp_const(mic, ftie->mic, 16) != 0) { wpa_printf(MSG_INFO, "TDLS: Invalid MIC in Teardown - " "dropping packet"); return -1; } } else { wpa_printf(MSG_INFO, "TDLS: Could not verify TDLS Teardown " "MIC, TPK not set - dropping packet"); return -1; } return 0; } static void wpa_tdls_tpk_timeout(void *eloop_ctx, void *timeout_ctx) { struct wpa_sm *sm = eloop_ctx; struct wpa_tdls_peer *peer = timeout_ctx; /* * On TPK lifetime expiration, we have an option of either tearing down * the direct link or trying to re-initiate it. The selection of what * to do is not strictly speaking controlled by our role in the expired * link, but for now, use that to select whether to renew or tear down * the link. */ if (peer->initiator) { u8 addr[ETH_ALEN]; wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime expired for " MACSTR " - try to renew", MAC2STR(peer->addr)); /* cache the peer address before do_teardown */ os_memcpy(addr, peer->addr, ETH_ALEN); wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); wpa_tdls_start(sm, addr); } else { wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime expired for " MACSTR " - tear down", MAC2STR(peer->addr)); wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } } static void wpa_tdls_peer_remove_from_list(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { struct wpa_tdls_peer *cur, *prev; cur = sm->tdls; prev = NULL; while (cur && cur != peer) { prev = cur; cur = cur->next; } if (cur != peer) { wpa_printf(MSG_ERROR, "TDLS: Could not find peer " MACSTR " to remove it from the list", MAC2STR(peer->addr)); return; } if (prev) prev->next = peer->next; else sm->tdls = peer->next; } static void wpa_tdls_peer_clear(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { wpa_printf(MSG_DEBUG, "TDLS: Clear state for peer " MACSTR, MAC2STR(peer->addr)); eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); eloop_cancel_timeout(wpa_tdls_tpk_retry_timeout, sm, peer); peer->reconfig_key = 0; peer->initiator = 0; peer->tpk_in_progress = 0; os_free(peer->sm_tmr.buf); peer->sm_tmr.buf = NULL; os_free(peer->ht_capabilities); peer->ht_capabilities = NULL; os_free(peer->vht_capabilities); peer->vht_capabilities = NULL; os_free(peer->ext_capab); peer->ext_capab = NULL; os_free(peer->supp_channels); peer->supp_channels = NULL; os_free(peer->supp_oper_classes); peer->supp_oper_classes = NULL; peer->rsnie_i_len = peer->rsnie_p_len = 0; peer->cipher = 0; peer->qos_info = 0; peer->wmm_capable = 0; peer->tk_set = peer->tpk_set = peer->tpk_success = 0; peer->chan_switch_enabled = 0; os_memset(&peer->tpk, 0, sizeof(peer->tpk)); os_memset(peer->inonce, 0, WPA_NONCE_LEN); os_memset(peer->rnonce, 0, WPA_NONCE_LEN); } static void wpa_tdls_peer_free(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { wpa_tdls_peer_clear(sm, peer); wpa_tdls_peer_remove_from_list(sm, peer); os_free(peer); } static void wpa_tdls_linkid(struct wpa_sm *sm, struct wpa_tdls_peer *peer, struct wpa_tdls_lnkid *lnkid) { lnkid->ie_type = WLAN_EID_LINK_ID; lnkid->ie_len = 3 * ETH_ALEN; os_memcpy(lnkid->bssid, sm->bssid, ETH_ALEN); if (peer->initiator) { os_memcpy(lnkid->init_sta, sm->own_addr, ETH_ALEN); os_memcpy(lnkid->resp_sta, peer->addr, ETH_ALEN); } else { os_memcpy(lnkid->init_sta, peer->addr, ETH_ALEN); os_memcpy(lnkid->resp_sta, sm->own_addr, ETH_ALEN); } } static int wpa_tdls_send_teardown(struct wpa_sm *sm, const u8 *addr, u16 reason_code) { struct wpa_tdls_peer *peer; struct wpa_tdls_ftie *ftie; struct wpa_tdls_lnkid lnkid; u8 dialog_token; u8 *rbuf, *pos; int ielen; if (sm->tdls_disabled || !sm->tdls_supported) return -1; /* Find the node and free from the list */ for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (peer == NULL) { wpa_printf(MSG_INFO, "TDLS: No matching entry found for " "Teardown " MACSTR, MAC2STR(addr)); return 0; } /* Cancel active channel switch before teardown */ if (peer->chan_switch_enabled) { wpa_printf(MSG_DEBUG, "TDLS: First returning link with " MACSTR " to base channel", MAC2STR(addr)); wpa_sm_tdls_disable_channel_switch(sm, peer->addr); } dialog_token = peer->dtoken; wpa_printf(MSG_DEBUG, "TDLS: TDLS Teardown for " MACSTR, MAC2STR(addr)); ielen = 0; if (wpa_tdls_get_privacy(sm) && peer->tpk_set && peer->tpk_success) { /* To add FTIE for Teardown request and compute MIC */ ielen += sizeof(*ftie); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) ielen += 170; #endif /* CONFIG_TDLS_TESTING */ } rbuf = os_zalloc(ielen + 1); if (rbuf == NULL) return -1; pos = rbuf; if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success) goto skip_ies; ftie = (struct wpa_tdls_ftie *) pos; ftie->ie_type = WLAN_EID_FAST_BSS_TRANSITION; /* Using the recent nonce which should be for CONFIRM frame */ os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); ftie->ie_len = sizeof(struct wpa_tdls_ftie) - 2; pos = (u8 *) (ftie + 1); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) { wpa_printf(MSG_DEBUG, "TDLS: Testing - add extra subelem to " "FTIE"); ftie->ie_len += 170; *pos++ = 255; /* FTIE subelem */ *pos++ = 168; /* FTIE subelem length */ pos += 168; } #endif /* CONFIG_TDLS_TESTING */ wpa_hexdump(MSG_DEBUG, "TDLS: FTIE for TDLS Teardown handshake", (u8 *) ftie, pos - (u8 *) ftie); /* compute MIC before sending */ wpa_tdls_linkid(sm, peer, &lnkid); wpa_tdls_key_mic_teardown(peer->tpk.kck, 4, reason_code, dialog_token, (u8 *) &lnkid, (u8 *) ftie, ftie->mic); skip_ies: /* TODO: register for a Timeout handler, if Teardown is not received at * the other end, then try again another time */ /* request driver to send Teardown using this FTIE */ wpa_tdls_tpk_send(sm, addr, WLAN_TDLS_TEARDOWN, 0, reason_code, 0, peer->initiator, rbuf, pos - rbuf); os_free(rbuf); return 0; } int wpa_tdls_teardown_link(struct wpa_sm *sm, const u8 *addr, u16 reason_code) { struct wpa_tdls_peer *peer; if (sm->tdls_disabled || !sm->tdls_supported) return -1; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (peer == NULL) { wpa_printf(MSG_DEBUG, "TDLS: Could not find peer " MACSTR " for link Teardown", MAC2STR(addr)); return -1; } if (!peer->tpk_success) { wpa_printf(MSG_DEBUG, "TDLS: Peer " MACSTR " not connected - cannot Teardown link", MAC2STR(addr)); return -1; } return wpa_tdls_do_teardown(sm, peer, reason_code); } static void wpa_tdls_disable_peer_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); wpa_tdls_peer_free(sm, peer); } void wpa_tdls_disable_unreachable_link(struct wpa_sm *sm, const u8 *addr) { struct wpa_tdls_peer *peer; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (!peer || !peer->tpk_success) { wpa_printf(MSG_DEBUG, "TDLS: Peer " MACSTR " not connected - cannot teardown unreachable link", MAC2STR(addr)); return; } if (wpa_tdls_is_external_setup(sm)) { /* * Get us on the base channel, disable the link, send a * teardown packet through the AP, and then reset link data. */ if (peer->chan_switch_enabled) wpa_sm_tdls_disable_channel_switch(sm, peer->addr); wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, addr); wpa_tdls_send_teardown(sm, addr, WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE); wpa_tdls_peer_free(sm, peer); } else { wpa_tdls_disable_peer_link(sm, peer); } } const char * wpa_tdls_get_link_status(struct wpa_sm *sm, const u8 *addr) { struct wpa_tdls_peer *peer; if (sm->tdls_disabled || !sm->tdls_supported) return "disabled"; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (peer == NULL) return "peer does not exist"; if (!peer->tpk_success) return "peer not connected"; return "connected"; } static int wpa_tdls_recv_teardown(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len) { struct wpa_tdls_peer *peer = NULL; struct wpa_tdls_ftie *ftie; struct wpa_tdls_lnkid *lnkid; struct wpa_eapol_ie_parse kde; u16 reason_code; const u8 *pos; int ielen; /* Find the node and free from the list */ for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) break; } if (peer == NULL) { wpa_printf(MSG_INFO, "TDLS: No matching entry found for " "Teardown " MACSTR, MAC2STR(src_addr)); return 0; } pos = buf; pos += 1 /* pkt_type */ + 1 /* Category */ + 1 /* Action */; reason_code = WPA_GET_LE16(pos); pos += 2; wpa_printf(MSG_DEBUG, "TDLS: TDLS Teardown Request from " MACSTR " (reason code %u)", MAC2STR(src_addr), reason_code); ielen = len - (pos - buf); /* start of IE in buf */ /* * Don't reject the message if failing to parse IEs. The IEs we need are * explicitly checked below. Some APs may add arbitrary padding to the * end of short TDLS frames and that would look like invalid IEs. */ if (wpa_supplicant_parse_ies((const u8 *) pos, ielen, &kde) < 0) wpa_printf(MSG_DEBUG, "TDLS: Failed to parse IEs in Teardown - ignore as an interop workaround"); if (kde.lnkid == NULL || kde.lnkid_len < 3 * ETH_ALEN) { wpa_printf(MSG_INFO, "TDLS: No Link Identifier IE in TDLS " "Teardown"); return -1; } lnkid = (struct wpa_tdls_lnkid *) kde.lnkid; if (!wpa_tdls_get_privacy(sm) || !peer->tpk_set || !peer->tpk_success) goto skip_ftie; if (kde.ftie == NULL || kde.ftie_len < sizeof(*ftie)) { wpa_printf(MSG_INFO, "TDLS: No FTIE in TDLS Teardown"); return -1; } ftie = (struct wpa_tdls_ftie *) kde.ftie; /* Process MIC check to see if TDLS Teardown is right */ if (wpa_supplicant_verify_tdls_mic_teardown(4, reason_code, peer->dtoken, peer, (u8 *) lnkid, ftie) < 0) { wpa_printf(MSG_DEBUG, "TDLS: MIC failure for TDLS " "Teardown Request from " MACSTR, MAC2STR(src_addr)); return -1; } skip_ftie: /* * Request the driver to disable the direct link and clear associated * keys. */ wpa_tdls_disable_peer_link(sm, peer); return 0; } /** * wpa_tdls_send_error - To send suitable TDLS status response with * appropriate status code mentioning reason for error/failure. * @dst - MAC addr of Peer station * @tdls_action - TDLS frame type for which error code is sent * @initiator - was this end the initiator of the connection * @status - status code mentioning reason */ static int wpa_tdls_send_error(struct wpa_sm *sm, const u8 *dst, u8 tdls_action, u8 dialog_token, int initiator, u16 status) { wpa_printf(MSG_DEBUG, "TDLS: Sending error to " MACSTR " (action=%u status=%u)", MAC2STR(dst), tdls_action, status); return wpa_tdls_tpk_send(sm, dst, tdls_action, dialog_token, status, 0, initiator, NULL, 0); } static struct wpa_tdls_peer * wpa_tdls_add_peer(struct wpa_sm *sm, const u8 *addr, int *existing) { struct wpa_tdls_peer *peer; if (existing) *existing = 0; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) { if (existing) *existing = 1; return peer; /* re-use existing entry */ } } wpa_printf(MSG_INFO, "TDLS: Creating peer entry for " MACSTR, MAC2STR(addr)); peer = os_zalloc(sizeof(*peer)); if (peer == NULL) return NULL; os_memcpy(peer->addr, addr, ETH_ALEN); peer->next = sm->tdls; sm->tdls = peer; return peer; } static int wpa_tdls_send_tpk_m1(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { size_t buf_len; struct wpa_tdls_timeoutie timeoutie; u16 rsn_capab; struct wpa_tdls_ftie *ftie; u8 *rbuf, *pos, *count_pos; u16 count; struct rsn_ie_hdr *hdr; int status; if (!wpa_tdls_get_privacy(sm)) { wpa_printf(MSG_DEBUG, "TDLS: No security used on the link"); peer->rsnie_i_len = 0; goto skip_rsnie; } /* * TPK Handshake Message 1: * FTIE: ANonce=0, SNonce=initiator nonce MIC=0, DataKDs=(RSNIE_I, * Timeout Interval IE)) */ /* Filling RSN IE */ hdr = (struct rsn_ie_hdr *) peer->rsnie_i; hdr->elem_id = WLAN_EID_RSN; WPA_PUT_LE16(hdr->version, RSN_VERSION); pos = (u8 *) (hdr + 1); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED); pos += RSN_SELECTOR_LEN; count_pos = pos; pos += 2; count = 0; /* * AES-CCMP is the default Encryption preferred for TDLS, so * RSN IE is filled only with CCMP CIPHER * Note: TKIP is not used to encrypt TDLS link. * * Regardless of the cipher used on the AP connection, select CCMP * here. */ RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP); pos += RSN_SELECTOR_LEN; count++; WPA_PUT_LE16(count_pos, count); WPA_PUT_LE16(pos, 1); pos += 2; RSN_SELECTOR_PUT(pos, RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE); pos += RSN_SELECTOR_LEN; rsn_capab = WPA_CAPABILITY_PEERKEY_ENABLED; rsn_capab |= RSN_NUM_REPLAY_COUNTERS_16 << 2; #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_ALT_RSN_IE) { wpa_printf(MSG_DEBUG, "TDLS: Use alternative RSN IE for " "testing"); rsn_capab = WPA_CAPABILITY_PEERKEY_ENABLED; } #endif /* CONFIG_TDLS_TESTING */ WPA_PUT_LE16(pos, rsn_capab); pos += 2; #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_ALT_RSN_IE) { /* Number of PMKIDs */ *pos++ = 0x00; *pos++ = 0x00; } #endif /* CONFIG_TDLS_TESTING */ hdr->len = (pos - peer->rsnie_i) - 2; peer->rsnie_i_len = pos - peer->rsnie_i; wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE for TPK handshake", peer->rsnie_i, peer->rsnie_i_len); skip_rsnie: buf_len = 0; if (wpa_tdls_get_privacy(sm)) buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + sizeof(struct wpa_tdls_timeoutie); #ifdef CONFIG_TDLS_TESTING if (wpa_tdls_get_privacy(sm) && (tdls_testing & TDLS_TESTING_LONG_FRAME)) buf_len += 170; if (tdls_testing & TDLS_TESTING_DIFF_BSSID) buf_len += sizeof(struct wpa_tdls_lnkid); #endif /* CONFIG_TDLS_TESTING */ rbuf = os_zalloc(buf_len + 1); if (rbuf == NULL) { wpa_tdls_peer_free(sm, peer); return -1; } pos = rbuf; if (!wpa_tdls_get_privacy(sm)) goto skip_ies; /* Initiator RSN IE */ pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len); ftie = (struct wpa_tdls_ftie *) pos; ftie->ie_type = WLAN_EID_FAST_BSS_TRANSITION; ftie->ie_len = sizeof(struct wpa_tdls_ftie) - 2; if (os_get_random(peer->inonce, WPA_NONCE_LEN)) { wpa_msg(sm->ctx->msg_ctx, MSG_WARNING, "TDLS: Failed to get random data for initiator Nonce"); os_free(rbuf); wpa_tdls_peer_free(sm, peer); return -1; } peer->tk_set = 0; /* A new nonce results in a new TK */ wpa_hexdump(MSG_DEBUG, "TDLS: Initiator Nonce for TPK handshake", peer->inonce, WPA_NONCE_LEN); os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); wpa_hexdump(MSG_DEBUG, "TDLS: FTIE for TPK Handshake M1", (u8 *) ftie, sizeof(struct wpa_tdls_ftie)); pos = (u8 *) (ftie + 1); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) { wpa_printf(MSG_DEBUG, "TDLS: Testing - add extra subelem to " "FTIE"); ftie->ie_len += 170; *pos++ = 255; /* FTIE subelem */ *pos++ = 168; /* FTIE subelem length */ pos += 168; } #endif /* CONFIG_TDLS_TESTING */ /* Lifetime */ peer->lifetime = TPK_LIFETIME; #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_SHORT_LIFETIME) { wpa_printf(MSG_DEBUG, "TDLS: Testing - use short TPK " "lifetime"); peer->lifetime = 301; } if (tdls_testing & TDLS_TESTING_LONG_LIFETIME) { wpa_printf(MSG_DEBUG, "TDLS: Testing - use long TPK " "lifetime"); peer->lifetime = 0xffffffff; } #endif /* CONFIG_TDLS_TESTING */ pos = wpa_add_tdls_timeoutie(pos, (u8 *) &timeoutie, sizeof(timeoutie), peer->lifetime); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime); skip_ies: #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_DIFF_BSSID) { struct wpa_tdls_lnkid *l = (struct wpa_tdls_lnkid *) pos; wpa_printf(MSG_DEBUG, "TDLS: Testing - use incorrect BSSID in " "Link Identifier"); wpa_tdls_linkid(sm, peer, l); l->bssid[5] ^= 0x01; pos += sizeof(*l); } #endif /* CONFIG_TDLS_TESTING */ wpa_printf(MSG_DEBUG, "TDLS: Sending TDLS Setup Request / TPK " "Handshake Message 1 (peer " MACSTR ")", MAC2STR(peer->addr)); status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_SETUP_REQUEST, 1, 0, 0, peer->initiator, rbuf, pos - rbuf); os_free(rbuf); return status; } static int wpa_tdls_send_tpk_m2(struct wpa_sm *sm, const unsigned char *src_addr, u8 dtoken, struct wpa_tdls_lnkid *lnkid, const struct wpa_tdls_peer *peer) { u8 *rbuf, *pos; size_t buf_len; u32 lifetime; struct wpa_tdls_timeoutie timeoutie; struct wpa_tdls_ftie *ftie; int status; buf_len = 0; if (wpa_tdls_get_privacy(sm)) { /* Peer RSN IE, FTIE(Initiator Nonce, Responder Nonce), * Lifetime */ buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + sizeof(struct wpa_tdls_timeoutie); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) buf_len += 170; #endif /* CONFIG_TDLS_TESTING */ } rbuf = os_zalloc(buf_len + 1); if (rbuf == NULL) return -1; pos = rbuf; if (!wpa_tdls_get_privacy(sm)) goto skip_ies; /* Peer RSN IE */ pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len); ftie = (struct wpa_tdls_ftie *) pos; ftie->ie_type = WLAN_EID_FAST_BSS_TRANSITION; /* TODO: ftie->mic_control to set 2-RESPONSE */ os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); ftie->ie_len = sizeof(struct wpa_tdls_ftie) - 2; wpa_hexdump(MSG_DEBUG, "TDLS: FTIE for TPK M2", (u8 *) ftie, sizeof(*ftie)); pos = (u8 *) (ftie + 1); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) { wpa_printf(MSG_DEBUG, "TDLS: Testing - add extra subelem to " "FTIE"); ftie->ie_len += 170; *pos++ = 255; /* FTIE subelem */ *pos++ = 168; /* FTIE subelem length */ pos += 168; } #endif /* CONFIG_TDLS_TESTING */ /* Lifetime */ lifetime = peer->lifetime; #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_WRONG_LIFETIME_RESP) { wpa_printf(MSG_DEBUG, "TDLS: Testing - use wrong TPK " "lifetime in response"); lifetime++; } #endif /* CONFIG_TDLS_TESTING */ pos = wpa_add_tdls_timeoutie(pos, (u8 *) &timeoutie, sizeof(timeoutie), lifetime); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds from initiator", lifetime); /* compute MIC before sending */ wpa_tdls_ftie_mic(peer->tpk.kck, 2, (u8 *) lnkid, peer->rsnie_p, (u8 *) &timeoutie, (u8 *) ftie, ftie->mic); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_WRONG_MIC) { wpa_printf(MSG_DEBUG, "TDLS: Testing - use wrong MIC"); ftie->mic[0] ^= 0x01; } #endif /* CONFIG_TDLS_TESTING */ skip_ies: status = wpa_tdls_tpk_send(sm, src_addr, WLAN_TDLS_SETUP_RESPONSE, dtoken, 0, 0, peer->initiator, rbuf, pos - rbuf); os_free(rbuf); return status; } static int wpa_tdls_send_tpk_m3(struct wpa_sm *sm, const unsigned char *src_addr, u8 dtoken, struct wpa_tdls_lnkid *lnkid, const struct wpa_tdls_peer *peer) { u8 *rbuf, *pos; size_t buf_len; struct wpa_tdls_ftie *ftie; struct wpa_tdls_timeoutie timeoutie; u32 lifetime; int status; u32 peer_capab = 0; buf_len = 0; if (wpa_tdls_get_privacy(sm)) { /* Peer RSN IE, FTIE(Initiator Nonce, Responder Nonce), * Lifetime */ buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_ftie) + sizeof(struct wpa_tdls_timeoutie); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) buf_len += 170; #endif /* CONFIG_TDLS_TESTING */ } rbuf = os_zalloc(buf_len + 1); if (rbuf == NULL) return -1; pos = rbuf; if (!wpa_tdls_get_privacy(sm)) goto skip_ies; /* Peer RSN IE */ pos = wpa_add_ie(pos, peer->rsnie_p, peer->rsnie_p_len); ftie = (struct wpa_tdls_ftie *) pos; ftie->ie_type = WLAN_EID_FAST_BSS_TRANSITION; /*TODO: ftie->mic_control to set 3-CONFIRM */ os_memcpy(ftie->Anonce, peer->rnonce, WPA_NONCE_LEN); os_memcpy(ftie->Snonce, peer->inonce, WPA_NONCE_LEN); ftie->ie_len = sizeof(struct wpa_tdls_ftie) - 2; pos = (u8 *) (ftie + 1); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_LONG_FRAME) { wpa_printf(MSG_DEBUG, "TDLS: Testing - add extra subelem to " "FTIE"); ftie->ie_len += 170; *pos++ = 255; /* FTIE subelem */ *pos++ = 168; /* FTIE subelem length */ pos += 168; } #endif /* CONFIG_TDLS_TESTING */ /* Lifetime */ lifetime = peer->lifetime; #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_WRONG_LIFETIME_CONF) { wpa_printf(MSG_DEBUG, "TDLS: Testing - use wrong TPK " "lifetime in confirm"); lifetime++; } #endif /* CONFIG_TDLS_TESTING */ pos = wpa_add_tdls_timeoutie(pos, (u8 *) &timeoutie, sizeof(timeoutie), lifetime); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", lifetime); /* compute MIC before sending */ wpa_tdls_ftie_mic(peer->tpk.kck, 3, (u8 *) lnkid, peer->rsnie_p, (u8 *) &timeoutie, (u8 *) ftie, ftie->mic); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_WRONG_MIC) { wpa_printf(MSG_DEBUG, "TDLS: Testing - use wrong MIC"); ftie->mic[0] ^= 0x01; } #endif /* CONFIG_TDLS_TESTING */ skip_ies: if (peer->vht_capabilities) peer_capab |= TDLS_PEER_VHT; if (peer->ht_capabilities) peer_capab |= TDLS_PEER_HT; if (peer->wmm_capable) peer_capab |= TDLS_PEER_WMM; status = wpa_tdls_tpk_send(sm, src_addr, WLAN_TDLS_SETUP_CONFIRM, dtoken, 0, peer_capab, peer->initiator, rbuf, pos - rbuf); os_free(rbuf); return status; } static int wpa_tdls_send_discovery_response(struct wpa_sm *sm, struct wpa_tdls_peer *peer, u8 dialog_token) { size_t buf_len = 0; struct wpa_tdls_timeoutie timeoutie; u16 rsn_capab; u8 *rbuf, *pos, *count_pos; u16 count; struct rsn_ie_hdr *hdr; int status; wpa_printf(MSG_DEBUG, "TDLS: Sending TDLS Discovery Response " "(peer " MACSTR ")", MAC2STR(peer->addr)); if (!wpa_tdls_get_privacy(sm)) goto skip_rsn_ies; /* Filling RSN IE */ hdr = (struct rsn_ie_hdr *) peer->rsnie_i; hdr->elem_id = WLAN_EID_RSN; WPA_PUT_LE16(hdr->version, RSN_VERSION); pos = (u8 *) (hdr + 1); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED); pos += RSN_SELECTOR_LEN; count_pos = pos; pos += 2; count = 0; /* * AES-CCMP is the default encryption preferred for TDLS, so * RSN IE is filled only with CCMP cipher suite. * Note: TKIP is not used to encrypt TDLS link. * * Regardless of the cipher used on the AP connection, select CCMP * here. */ RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP); pos += RSN_SELECTOR_LEN; count++; WPA_PUT_LE16(count_pos, count); WPA_PUT_LE16(pos, 1); pos += 2; RSN_SELECTOR_PUT(pos, RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE); pos += RSN_SELECTOR_LEN; rsn_capab = WPA_CAPABILITY_PEERKEY_ENABLED; rsn_capab |= RSN_NUM_REPLAY_COUNTERS_16 << 2; WPA_PUT_LE16(pos, rsn_capab); pos += 2; hdr->len = (pos - (u8 *) hdr) - 2; peer->rsnie_i_len = pos - peer->rsnie_i; wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE for Discovery Response", (u8 *) hdr, hdr->len + 2); skip_rsn_ies: buf_len = 0; if (wpa_tdls_get_privacy(sm)) { /* Peer RSN IE, Lifetime */ buf_len += peer->rsnie_i_len + sizeof(struct wpa_tdls_timeoutie); } rbuf = os_zalloc(buf_len + 1); if (rbuf == NULL) { wpa_tdls_peer_free(sm, peer); return -1; } pos = rbuf; if (!wpa_tdls_get_privacy(sm)) goto skip_ies; /* Initiator RSN IE */ pos = wpa_add_ie(pos, peer->rsnie_i, peer->rsnie_i_len); /* Lifetime */ peer->lifetime = TPK_LIFETIME; pos = wpa_add_tdls_timeoutie(pos, (u8 *) &timeoutie, sizeof(timeoutie), peer->lifetime); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", peer->lifetime); skip_ies: status = wpa_tdls_tpk_send(sm, peer->addr, WLAN_TDLS_DISCOVERY_RESPONSE, dialog_token, 0, 0, 0, rbuf, pos - rbuf); os_free(rbuf); return status; } static int wpa_tdls_process_discovery_request(struct wpa_sm *sm, const u8 *addr, const u8 *buf, size_t len) { struct wpa_eapol_ie_parse kde; const struct wpa_tdls_lnkid *lnkid; struct wpa_tdls_peer *peer; size_t min_req_len = sizeof(struct wpa_tdls_frame) + 1 /* dialog token */ + sizeof(struct wpa_tdls_lnkid); u8 dialog_token; wpa_printf(MSG_DEBUG, "TDLS: Discovery Request from " MACSTR, MAC2STR(addr)); if (len < min_req_len) { wpa_printf(MSG_DEBUG, "TDLS Discovery Request is too short: " "%d", (int) len); return -1; } dialog_token = buf[sizeof(struct wpa_tdls_frame)]; /* * Some APs will tack on a weird IE to the end of a TDLS * discovery request packet. This needn't fail the response, * since the required IE are verified separately. */ if (wpa_supplicant_parse_ies(buf + sizeof(struct wpa_tdls_frame) + 1, len - (sizeof(struct wpa_tdls_frame) + 1), &kde) < 0) { wpa_printf(MSG_DEBUG, "TDLS: Failed to parse IEs in Discovery Request - ignore as an interop workaround"); } if (!kde.lnkid) { wpa_printf(MSG_DEBUG, "TDLS: Link ID not found in Discovery " "Request"); return -1; } lnkid = (const struct wpa_tdls_lnkid *) kde.lnkid; if (os_memcmp(sm->bssid, lnkid->bssid, ETH_ALEN) != 0) { wpa_printf(MSG_DEBUG, "TDLS: Discovery Request from different " " BSS " MACSTR, MAC2STR(lnkid->bssid)); return -1; } peer = wpa_tdls_add_peer(sm, addr, NULL); if (peer == NULL) return -1; return wpa_tdls_send_discovery_response(sm, peer, dialog_token); } int wpa_tdls_send_discovery_request(struct wpa_sm *sm, const u8 *addr) { if (sm->tdls_disabled || !sm->tdls_supported) return -1; wpa_printf(MSG_DEBUG, "TDLS: Sending Discovery Request to peer " MACSTR, MAC2STR(addr)); return wpa_tdls_tpk_send(sm, addr, WLAN_TDLS_DISCOVERY_REQUEST, 1, 0, 0, 1, NULL, 0); } static int copy_supp_rates(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { if (!kde->supp_rates) { wpa_printf(MSG_DEBUG, "TDLS: No supported rates received"); return -1; } peer->supp_rates_len = merge_byte_arrays( peer->supp_rates, sizeof(peer->supp_rates), kde->supp_rates + 2, kde->supp_rates_len - 2, kde->ext_supp_rates ? kde->ext_supp_rates + 2 : NULL, kde->ext_supp_rates_len - 2); return 0; } static int copy_peer_ht_capab(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { if (!kde->ht_capabilities) { wpa_printf(MSG_DEBUG, "TDLS: No supported ht capabilities " "received"); return 0; } if (!peer->ht_capabilities) { peer->ht_capabilities = os_zalloc(sizeof(struct ieee80211_ht_capabilities)); if (peer->ht_capabilities == NULL) return -1; } os_memcpy(peer->ht_capabilities, kde->ht_capabilities, sizeof(struct ieee80211_ht_capabilities)); wpa_hexdump(MSG_DEBUG, "TDLS: Peer HT capabilities", (u8 *) peer->ht_capabilities, sizeof(struct ieee80211_ht_capabilities)); return 0; } static int copy_peer_vht_capab(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { if (!kde->vht_capabilities) { wpa_printf(MSG_DEBUG, "TDLS: No supported vht capabilities " "received"); return 0; } if (!peer->vht_capabilities) { peer->vht_capabilities = os_zalloc(sizeof(struct ieee80211_vht_capabilities)); if (peer->vht_capabilities == NULL) return -1; } os_memcpy(peer->vht_capabilities, kde->vht_capabilities, sizeof(struct ieee80211_vht_capabilities)); wpa_hexdump(MSG_DEBUG, "TDLS: Peer VHT capabilities", (u8 *) peer->vht_capabilities, sizeof(struct ieee80211_vht_capabilities)); return 0; } static int copy_peer_ext_capab(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { if (!kde->ext_capab) { wpa_printf(MSG_DEBUG, "TDLS: No extended capabilities " "received"); return 0; } if (!peer->ext_capab || peer->ext_capab_len < kde->ext_capab_len - 2) { /* Need to allocate buffer to fit the new information */ os_free(peer->ext_capab); peer->ext_capab = os_zalloc(kde->ext_capab_len - 2); if (peer->ext_capab == NULL) return -1; } peer->ext_capab_len = kde->ext_capab_len - 2; os_memcpy(peer->ext_capab, kde->ext_capab + 2, peer->ext_capab_len); return 0; } static int copy_peer_wmm_capab(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { struct wmm_information_element *wmm; if (!kde->wmm) { wpa_printf(MSG_DEBUG, "TDLS: No supported WMM capabilities received"); return 0; } if (kde->wmm_len < sizeof(struct wmm_information_element)) { wpa_printf(MSG_DEBUG, "TDLS: Invalid supported WMM capabilities received"); return -1; } wmm = (struct wmm_information_element *) kde->wmm; peer->qos_info = wmm->qos_info; peer->wmm_capable = 1; wpa_printf(MSG_DEBUG, "TDLS: Peer WMM QOS Info 0x%x", peer->qos_info); return 0; } static int copy_peer_supp_channels(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { if (!kde->supp_channels) { wpa_printf(MSG_DEBUG, "TDLS: No supported channels received"); return 0; } if (!peer->supp_channels || peer->supp_channels_len < kde->supp_channels_len) { os_free(peer->supp_channels); peer->supp_channels = os_zalloc(kde->supp_channels_len); if (peer->supp_channels == NULL) return -1; } peer->supp_channels_len = kde->supp_channels_len; os_memcpy(peer->supp_channels, kde->supp_channels, peer->supp_channels_len); wpa_hexdump(MSG_DEBUG, "TDLS: Peer Supported Channels", (u8 *) peer->supp_channels, peer->supp_channels_len); return 0; } static int copy_peer_supp_oper_classes(const struct wpa_eapol_ie_parse *kde, struct wpa_tdls_peer *peer) { if (!kde->supp_oper_classes) { wpa_printf(MSG_DEBUG, "TDLS: No supported operating classes received"); return 0; } if (!peer->supp_oper_classes || peer->supp_oper_classes_len < kde->supp_oper_classes_len) { os_free(peer->supp_oper_classes); peer->supp_oper_classes = os_zalloc(kde->supp_oper_classes_len); if (peer->supp_oper_classes == NULL) return -1; } peer->supp_oper_classes_len = kde->supp_oper_classes_len; os_memcpy(peer->supp_oper_classes, kde->supp_oper_classes, peer->supp_oper_classes_len); wpa_hexdump(MSG_DEBUG, "TDLS: Peer Supported Operating Classes", (u8 *) peer->supp_oper_classes, peer->supp_oper_classes_len); return 0; } static int wpa_tdls_addset_peer(struct wpa_sm *sm, struct wpa_tdls_peer *peer, int add) { return wpa_sm_tdls_peer_addset(sm, peer->addr, add, peer->aid, peer->capability, peer->supp_rates, peer->supp_rates_len, peer->ht_capabilities, peer->vht_capabilities, peer->qos_info, peer->wmm_capable, peer->ext_capab, peer->ext_capab_len, peer->supp_channels, peer->supp_channels_len, peer->supp_oper_classes, peer->supp_oper_classes_len); } static int tdls_nonce_set(const u8 *nonce) { int i; for (i = 0; i < WPA_NONCE_LEN; i++) { if (nonce[i]) return 1; } return 0; } static int wpa_tdls_process_tpk_m1(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len) { struct wpa_tdls_peer *peer; struct wpa_eapol_ie_parse kde; struct wpa_ie_data ie; int cipher; const u8 *cpos; struct wpa_tdls_ftie *ftie = NULL; struct wpa_tdls_timeoutie *timeoutie; struct wpa_tdls_lnkid *lnkid; u32 lifetime = 0; #if 0 struct rsn_ie_hdr *hdr; u8 *pos; u16 rsn_capab; u16 rsn_ver; #endif u8 dtoken; u16 ielen; u16 status = WLAN_STATUS_UNSPECIFIED_FAILURE; int tdls_prohibited = sm->tdls_prohibited; int existing_peer = 0; if (len < 3 + 3) return -1; cpos = buf; cpos += 1 /* pkt_type */ + 1 /* Category */ + 1 /* Action */; /* driver had already verified the frame format */ dtoken = *cpos++; /* dialog token */ wpa_printf(MSG_INFO, "TDLS: Dialog Token in TPK M1 %d", dtoken); peer = wpa_tdls_add_peer(sm, src_addr, &existing_peer); if (peer == NULL) goto error; /* If found, use existing entry instead of adding a new one; * how to handle the case where both ends initiate at the * same time? */ if (existing_peer) { if (peer->tpk_success) { wpa_printf(MSG_DEBUG, "TDLS: TDLS Setup Request while " "direct link is enabled - tear down the " "old link first"); wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); wpa_tdls_peer_clear(sm, peer); } else if (peer->initiator) { /* * An entry is already present, so check if we already * sent a TDLS Setup Request. If so, compare MAC * addresses and let the STA with the lower MAC address * continue as the initiator. The other negotiation is * terminated. */ if (os_memcmp(sm->own_addr, src_addr, ETH_ALEN) < 0) { wpa_printf(MSG_DEBUG, "TDLS: Discard request " "from peer with higher address " MACSTR, MAC2STR(src_addr)); return -1; } else { wpa_printf(MSG_DEBUG, "TDLS: Accept request " "from peer with lower address " MACSTR " (terminate previously " "initiated negotiation", MAC2STR(src_addr)); wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); wpa_tdls_peer_clear(sm, peer); } } } /* capability information */ peer->capability = WPA_GET_LE16(cpos); cpos += 2; ielen = len - (cpos - buf); /* start of IE in buf */ /* * Don't reject the message if failing to parse IEs. The IEs we need are * explicitly checked below. Some APs may add arbitrary padding to the * end of short TDLS frames and that would look like invalid IEs. */ if (wpa_supplicant_parse_ies(cpos, ielen, &kde) < 0) wpa_printf(MSG_DEBUG, "TDLS: Failed to parse IEs in TPK M1 - ignore as an interop workaround"); if (kde.lnkid == NULL || kde.lnkid_len < 3 * ETH_ALEN) { wpa_printf(MSG_INFO, "TDLS: No valid Link Identifier IE in " "TPK M1"); goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: Link ID Received from TPK M1", kde.lnkid, kde.lnkid_len); lnkid = (struct wpa_tdls_lnkid *) kde.lnkid; if (os_memcmp(sm->bssid, lnkid->bssid, ETH_ALEN) != 0) { wpa_printf(MSG_INFO, "TDLS: TPK M1 from diff BSS"); status = WLAN_STATUS_REQUEST_DECLINED; goto error; } wpa_printf(MSG_DEBUG, "TDLS: TPK M1 - TPK initiator " MACSTR, MAC2STR(src_addr)); if (copy_supp_rates(&kde, peer) < 0) goto error; if (copy_peer_ht_capab(&kde, peer) < 0) goto error; if (copy_peer_vht_capab(&kde, peer) < 0) goto error; if (copy_peer_ext_capab(&kde, peer) < 0) goto error; if (copy_peer_supp_channels(&kde, peer) < 0) goto error; if (copy_peer_supp_oper_classes(&kde, peer) < 0) goto error; peer->qos_info = kde.qosinfo; /* Overwrite with the qos_info obtained in WMM IE */ if (copy_peer_wmm_capab(&kde, peer) < 0) goto error; peer->aid = kde.aid; #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_CONCURRENT_INIT) { peer = wpa_tdls_add_peer(sm, src_addr, NULL); if (peer == NULL) goto error; wpa_printf(MSG_DEBUG, "TDLS: Testing concurrent initiation of " "TDLS setup - send own request"); peer->initiator = 1; wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, 0, NULL, 0); wpa_tdls_send_tpk_m1(sm, peer); } if ((tdls_testing & TDLS_TESTING_IGNORE_AP_PROHIBIT) && tdls_prohibited) { wpa_printf(MSG_DEBUG, "TDLS: Testing - ignore AP prohibition " "on TDLS"); tdls_prohibited = 0; } #endif /* CONFIG_TDLS_TESTING */ if (tdls_prohibited) { wpa_printf(MSG_INFO, "TDLS: TDLS prohibited in this BSS"); status = WLAN_STATUS_REQUEST_DECLINED; goto error; } if (!wpa_tdls_get_privacy(sm)) { if (kde.rsn_ie) { wpa_printf(MSG_INFO, "TDLS: RSN IE in TPK M1 while " "security is disabled"); status = WLAN_STATUS_SECURITY_DISABLED; goto error; } goto skip_rsn; } if (kde.ftie == NULL || kde.ftie_len < sizeof(*ftie) || kde.rsn_ie == NULL) { wpa_printf(MSG_INFO, "TDLS: No FTIE or RSN IE in TPK M1"); status = WLAN_STATUS_INVALID_PARAMETERS; goto error; } if (kde.rsn_ie_len > TDLS_MAX_IE_LEN) { wpa_printf(MSG_INFO, "TDLS: Too long Initiator RSN IE in " "TPK M1"); status = WLAN_STATUS_INVALID_RSNIE; goto error; } if (wpa_parse_wpa_ie_rsn(kde.rsn_ie, kde.rsn_ie_len, &ie) < 0) { wpa_printf(MSG_INFO, "TDLS: Failed to parse RSN IE in TPK M1"); status = WLAN_STATUS_INVALID_RSNIE; goto error; } cipher = ie.pairwise_cipher; if (cipher & WPA_CIPHER_CCMP) { wpa_printf(MSG_DEBUG, "TDLS: Using CCMP for direct link"); cipher = WPA_CIPHER_CCMP; } else { wpa_printf(MSG_INFO, "TDLS: No acceptable cipher in TPK M1"); status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; goto error; } if ((ie.capabilities & (WPA_CAPABILITY_NO_PAIRWISE | WPA_CAPABILITY_PEERKEY_ENABLED)) != WPA_CAPABILITY_PEERKEY_ENABLED) { wpa_printf(MSG_INFO, "TDLS: Invalid RSN Capabilities in " "TPK M1"); status = WLAN_STATUS_INVALID_RSN_IE_CAPAB; goto error; } /* Lifetime */ if (kde.key_lifetime == NULL) { wpa_printf(MSG_INFO, "TDLS: No Key Lifetime IE in TPK M1"); status = WLAN_STATUS_UNACCEPTABLE_LIFETIME; goto error; } timeoutie = (struct wpa_tdls_timeoutie *) kde.key_lifetime; lifetime = WPA_GET_LE32(timeoutie->value); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds", lifetime); if (lifetime < 300) { wpa_printf(MSG_INFO, "TDLS: Too short TPK lifetime"); status = WLAN_STATUS_UNACCEPTABLE_LIFETIME; goto error; } skip_rsn: #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_CONCURRENT_INIT) { if (os_memcmp(sm->own_addr, peer->addr, ETH_ALEN) < 0) { /* * The request frame from us is going to win, so do not * replace information based on this request frame from * the peer. */ goto skip_rsn_check; } } #endif /* CONFIG_TDLS_TESTING */ peer->initiator = 0; /* Need to check */ peer->dtoken = dtoken; if (!wpa_tdls_get_privacy(sm)) { peer->rsnie_i_len = 0; peer->rsnie_p_len = 0; peer->cipher = WPA_CIPHER_NONE; goto skip_rsn_check; } ftie = (struct wpa_tdls_ftie *) kde.ftie; os_memcpy(peer->rsnie_i, kde.rsn_ie, kde.rsn_ie_len); peer->rsnie_i_len = kde.rsn_ie_len; peer->cipher = cipher; if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0 || !tdls_nonce_set(peer->inonce)) { /* * There is no point in updating the RNonce for every obtained * TPK M1 frame (e.g., retransmission due to timeout) with the * same INonce (SNonce in FTIE). However, if the TPK M1 is * retransmitted with a different INonce, update the RNonce * since this is for a new TDLS session. */ wpa_printf(MSG_DEBUG, "TDLS: New TPK M1 INonce - generate new RNonce"); os_memcpy(peer->inonce, ftie->Snonce, WPA_NONCE_LEN); if (os_get_random(peer->rnonce, WPA_NONCE_LEN)) { wpa_msg(sm->ctx->ctx, MSG_WARNING, "TDLS: Failed to get random data for responder nonce"); goto error; } peer->tk_set = 0; /* A new nonce results in a new TK */ } #if 0 /* get version info from RSNIE received from Peer */ hdr = (struct rsn_ie_hdr *) kde.rsn_ie; rsn_ver = WPA_GET_LE16(hdr->version); /* use min(peer's version, out version) */ if (rsn_ver > RSN_VERSION) rsn_ver = RSN_VERSION; hdr = (struct rsn_ie_hdr *) peer->rsnie_p; hdr->elem_id = WLAN_EID_RSN; WPA_PUT_LE16(hdr->version, rsn_ver); pos = (u8 *) (hdr + 1); RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_NO_GROUP_ADDRESSED); pos += RSN_SELECTOR_LEN; /* Include only the selected cipher in pairwise cipher suite */ WPA_PUT_LE16(pos, 1); pos += 2; if (cipher == WPA_CIPHER_CCMP) RSN_SELECTOR_PUT(pos, RSN_CIPHER_SUITE_CCMP); pos += RSN_SELECTOR_LEN; WPA_PUT_LE16(pos, 1); pos += 2; RSN_SELECTOR_PUT(pos, RSN_AUTH_KEY_MGMT_TPK_HANDSHAKE); pos += RSN_SELECTOR_LEN; rsn_capab = WPA_CAPABILITY_PEERKEY_ENABLED; rsn_capab |= RSN_NUM_REPLAY_COUNTERS_16 << 2; WPA_PUT_LE16(pos, rsn_capab); pos += 2; hdr->len = (pos - peer->rsnie_p) - 2; peer->rsnie_p_len = pos - peer->rsnie_p; #endif /* temp fix: validation of RSNIE later */ os_memcpy(peer->rsnie_p, peer->rsnie_i, peer->rsnie_i_len); peer->rsnie_p_len = peer->rsnie_i_len; wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE for TPK handshake", peer->rsnie_p, peer->rsnie_p_len); peer->lifetime = lifetime; wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid); skip_rsn_check: #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_CONCURRENT_INIT) goto skip_add_peer; #endif /* CONFIG_TDLS_TESTING */ /* add supported rates, capabilities, and qos_info to the TDLS peer */ if (wpa_tdls_addset_peer(sm, peer, 1) < 0) goto error; #ifdef CONFIG_TDLS_TESTING skip_add_peer: #endif /* CONFIG_TDLS_TESTING */ peer->tpk_in_progress = 1; wpa_printf(MSG_DEBUG, "TDLS: Sending TDLS Setup Response / TPK M2"); if (wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer) < 0) { wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); goto error; } #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_DOUBLE_TPK_M2) { wpa_printf(MSG_INFO, "TDLS: Testing - Send another TPK M2"); wpa_tdls_send_tpk_m2(sm, src_addr, dtoken, lnkid, peer); } #endif /* CONFIG_TDLS_TESTING */ return 0; error: wpa_tdls_send_error(sm, src_addr, WLAN_TDLS_SETUP_RESPONSE, dtoken, 0, status); if (peer) wpa_tdls_peer_free(sm, peer); return -1; } static int wpa_tdls_enable_link(struct wpa_sm *sm, struct wpa_tdls_peer *peer) { peer->tpk_success = 1; peer->tpk_in_progress = 0; eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); if (wpa_tdls_get_privacy(sm)) { u32 lifetime = peer->lifetime; /* * Start the initiator process a bit earlier to avoid race * condition with the responder sending teardown request. */ if (lifetime > 3 && peer->initiator) lifetime -= 3; eloop_register_timeout(lifetime, 0, wpa_tdls_tpk_timeout, sm, peer); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_NO_TPK_EXPIRATION) { wpa_printf(MSG_DEBUG, "TDLS: Testing - disable TPK " "expiration"); eloop_cancel_timeout(wpa_tdls_tpk_timeout, sm, peer); } #endif /* CONFIG_TDLS_TESTING */ } if (peer->reconfig_key && wpa_tdls_set_key(sm, peer) < 0) { wpa_printf(MSG_INFO, "TDLS: Could not configure key to the " "driver"); return -1; } peer->reconfig_key = 0; return wpa_sm_tdls_oper(sm, TDLS_ENABLE_LINK, peer->addr); } static int wpa_tdls_process_tpk_m2(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len) { struct wpa_tdls_peer *peer; struct wpa_eapol_ie_parse kde; struct wpa_ie_data ie; int cipher; struct wpa_tdls_ftie *ftie; struct wpa_tdls_timeoutie *timeoutie; struct wpa_tdls_lnkid *lnkid; u32 lifetime; u8 dtoken; int ielen; u16 status; const u8 *pos; int ret = 0; wpa_printf(MSG_DEBUG, "TDLS: Received TDLS Setup Response / TPK M2 " "(Peer " MACSTR ")", MAC2STR(src_addr)); for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) break; } if (peer == NULL) { wpa_printf(MSG_INFO, "TDLS: No matching peer found for " "TPK M2: " MACSTR, MAC2STR(src_addr)); return -1; } if (!peer->initiator) { /* * This may happen if both devices try to initiate TDLS at the * same time and we accept the TPK M1 from the peer in * wpa_tdls_process_tpk_m1() and clear our previous state. */ wpa_printf(MSG_INFO, "TDLS: We were not the initiator, so " "ignore TPK M2 from " MACSTR, MAC2STR(src_addr)); return -1; } if (peer->tpk_success) { wpa_printf(MSG_INFO, "TDLS: Ignore incoming TPK M2 retry, from " MACSTR " as TPK M3 was already sent", MAC2STR(src_addr)); return 0; } wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_REQUEST); if (len < 3 + 2 + 1) { wpa_tdls_disable_peer_link(sm, peer); return -1; } pos = buf; pos += 1 /* pkt_type */ + 1 /* Category */ + 1 /* Action */; status = WPA_GET_LE16(pos); pos += 2 /* status code */; if (status != WLAN_STATUS_SUCCESS) { wpa_printf(MSG_INFO, "TDLS: Status code in TPK M2: %u", status); wpa_tdls_disable_peer_link(sm, peer); return -1; } status = WLAN_STATUS_UNSPECIFIED_FAILURE; /* TODO: need to verify dialog token matches here or in kernel */ dtoken = *pos++; /* dialog token */ wpa_printf(MSG_DEBUG, "TDLS: Dialog Token in TPK M2 %d", dtoken); if (len < 3 + 2 + 1 + 2) { wpa_tdls_disable_peer_link(sm, peer); return -1; } /* capability information */ peer->capability = WPA_GET_LE16(pos); pos += 2; ielen = len - (pos - buf); /* start of IE in buf */ /* * Don't reject the message if failing to parse IEs. The IEs we need are * explicitly checked below. Some APs may add arbitrary padding to the * end of short TDLS frames and that would look like invalid IEs. */ if (wpa_supplicant_parse_ies(pos, ielen, &kde) < 0) wpa_printf(MSG_DEBUG, "TDLS: Failed to parse IEs in TPK M2 - ignore as an interop workaround"); #ifdef CONFIG_TDLS_TESTING if (tdls_testing & TDLS_TESTING_DECLINE_RESP) { wpa_printf(MSG_DEBUG, "TDLS: Testing - decline response"); status = WLAN_STATUS_REQUEST_DECLINED; goto error; } #endif /* CONFIG_TDLS_TESTING */ if (kde.lnkid == NULL || kde.lnkid_len < 3 * ETH_ALEN) { wpa_printf(MSG_INFO, "TDLS: No valid Link Identifier IE in " "TPK M2"); goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: Link ID Received from TPK M2", kde.lnkid, kde.lnkid_len); lnkid = (struct wpa_tdls_lnkid *) kde.lnkid; if (os_memcmp(sm->bssid, lnkid->bssid, ETH_ALEN) != 0) { wpa_printf(MSG_INFO, "TDLS: TPK M2 from different BSS"); status = WLAN_STATUS_NOT_IN_SAME_BSS; goto error; } if (copy_supp_rates(&kde, peer) < 0) goto error; if (copy_peer_ht_capab(&kde, peer) < 0) goto error; if (copy_peer_vht_capab(&kde, peer) < 0) goto error; if (copy_peer_ext_capab(&kde, peer) < 0) goto error; if (copy_peer_supp_channels(&kde, peer) < 0) goto error; if (copy_peer_supp_oper_classes(&kde, peer) < 0) goto error; peer->qos_info = kde.qosinfo; /* Overwrite with the qos_info obtained in WMM IE */ if (copy_peer_wmm_capab(&kde, peer) < 0) goto error; peer->aid = kde.aid; if (!wpa_tdls_get_privacy(sm)) { peer->rsnie_p_len = 0; peer->cipher = WPA_CIPHER_NONE; goto skip_rsn; } if (kde.ftie == NULL || kde.ftie_len < sizeof(*ftie) || kde.rsn_ie == NULL) { wpa_printf(MSG_INFO, "TDLS: No FTIE or RSN IE in TPK M2"); status = WLAN_STATUS_INVALID_PARAMETERS; goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE Received from TPK M2", kde.rsn_ie, kde.rsn_ie_len); if (kde.rsn_ie_len > TDLS_MAX_IE_LEN) { wpa_printf(MSG_INFO, "TDLS: Too long Responder RSN IE in TPK M2"); status = WLAN_STATUS_INVALID_RSNIE; goto error; } /* * FIX: bitwise comparison of RSN IE is not the correct way of * validation this. It can be different, but certain fields must * match. Since we list only a single pairwise cipher in TPK M1, the * memcmp is likely to work in most cases, though. */ if (kde.rsn_ie_len != peer->rsnie_i_len || os_memcmp(peer->rsnie_i, kde.rsn_ie, peer->rsnie_i_len) != 0) { wpa_printf(MSG_INFO, "TDLS: RSN IE in TPK M2 does " "not match with RSN IE used in TPK M1"); wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE Sent in TPK M1", peer->rsnie_i, peer->rsnie_i_len); wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE Received from TPK M2", kde.rsn_ie, kde.rsn_ie_len); status = WLAN_STATUS_INVALID_RSNIE; goto error; } if (wpa_parse_wpa_ie_rsn(kde.rsn_ie, kde.rsn_ie_len, &ie) < 0) { wpa_printf(MSG_INFO, "TDLS: Failed to parse RSN IE in TPK M2"); status = WLAN_STATUS_INVALID_RSNIE; goto error; } cipher = ie.pairwise_cipher; if (cipher == WPA_CIPHER_CCMP) { wpa_printf(MSG_DEBUG, "TDLS: Using CCMP for direct link"); cipher = WPA_CIPHER_CCMP; } else { wpa_printf(MSG_INFO, "TDLS: No acceptable cipher in TPK M2"); status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: FTIE Received from TPK M2", kde.ftie, sizeof(*ftie)); ftie = (struct wpa_tdls_ftie *) kde.ftie; if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { wpa_printf(MSG_INFO, "TDLS: FTIE SNonce in TPK M2 does " "not match with FTIE SNonce used in TPK M1"); /* Silently discard the frame */ return -1; } /* Responder Nonce and RSN IE */ os_memcpy(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN); os_memcpy(peer->rsnie_p, kde.rsn_ie, kde.rsn_ie_len); peer->rsnie_p_len = kde.rsn_ie_len; peer->cipher = cipher; /* Lifetime */ if (kde.key_lifetime == NULL) { wpa_printf(MSG_INFO, "TDLS: No Key Lifetime IE in TPK M2"); status = WLAN_STATUS_UNACCEPTABLE_LIFETIME; goto error; } timeoutie = (struct wpa_tdls_timeoutie *) kde.key_lifetime; lifetime = WPA_GET_LE32(timeoutie->value); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds in TPK M2", lifetime); if (lifetime != peer->lifetime) { wpa_printf(MSG_INFO, "TDLS: Unexpected TPK lifetime %u in " "TPK M2 (expected %u)", lifetime, peer->lifetime); status = WLAN_STATUS_UNACCEPTABLE_LIFETIME; goto error; } wpa_tdls_generate_tpk(peer, sm->own_addr, sm->bssid); /* Process MIC check to see if TPK M2 is right */ if (wpa_supplicant_verify_tdls_mic(2, peer, (u8 *) lnkid, (u8 *) timeoutie, ftie) < 0) { /* Discard the frame */ wpa_tdls_del_key(sm, peer); wpa_tdls_disable_peer_link(sm, peer); return -1; } if (wpa_tdls_set_key(sm, peer) < 0) { /* * Some drivers may not be able to config the key prior to full * STA entry having been configured. */ wpa_printf(MSG_DEBUG, "TDLS: Try to configure TPK again after " "STA entry is complete"); peer->reconfig_key = 1; } skip_rsn: peer->dtoken = dtoken; /* add supported rates, capabilities, and qos_info to the TDLS peer */ if (wpa_tdls_addset_peer(sm, peer, 0) < 0) goto error; wpa_printf(MSG_DEBUG, "TDLS: Sending TDLS Setup Confirm / " "TPK Handshake Message 3"); if (wpa_tdls_send_tpk_m3(sm, src_addr, dtoken, lnkid, peer) < 0) goto error_no_msg; if (!peer->tpk_success) { /* * Enable Link only when tpk_success is 0, signifying that this * processing of TPK M2 frame is not because of a retransmission * during TDLS setup handshake. */ ret = wpa_tdls_enable_link(sm, peer); if (ret < 0) { wpa_printf(MSG_DEBUG, "TDLS: Could not enable link"); wpa_tdls_do_teardown( sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } } return ret; error: wpa_tdls_send_error(sm, src_addr, WLAN_TDLS_SETUP_CONFIRM, dtoken, 1, status); error_no_msg: wpa_tdls_disable_peer_link(sm, peer); return -1; } static int wpa_tdls_process_tpk_m3(struct wpa_sm *sm, const u8 *src_addr, const u8 *buf, size_t len) { struct wpa_tdls_peer *peer; struct wpa_eapol_ie_parse kde; struct wpa_tdls_ftie *ftie; struct wpa_tdls_timeoutie *timeoutie; struct wpa_tdls_lnkid *lnkid; int ielen; u16 status; const u8 *pos; u32 lifetime; int ret = 0; wpa_printf(MSG_DEBUG, "TDLS: Received TDLS Setup Confirm / TPK M3 " "(Peer " MACSTR ")", MAC2STR(src_addr)); for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, src_addr, ETH_ALEN) == 0) break; } if (peer == NULL) { wpa_printf(MSG_INFO, "TDLS: No matching peer found for " "TPK M3: " MACSTR, MAC2STR(src_addr)); return -1; } wpa_tdls_tpk_retry_timeout_cancel(sm, peer, WLAN_TDLS_SETUP_RESPONSE); if (len < 3 + 3) goto error; pos = buf; pos += 1 /* pkt_type */ + 1 /* Category */ + 1 /* Action */; status = WPA_GET_LE16(pos); if (status != 0) { wpa_printf(MSG_INFO, "TDLS: Status code in TPK M3: %u", status); goto error; } pos += 2 /* status code */ + 1 /* dialog token */; ielen = len - (pos - buf); /* start of IE in buf */ /* * Don't reject the message if failing to parse IEs. The IEs we need are * explicitly checked below. Some APs piggy-back broken IEs to the end * of a TDLS Confirm packet, which will fail the link if we don't ignore * this error. */ if (wpa_supplicant_parse_ies((const u8 *) pos, ielen, &kde) < 0) { wpa_printf(MSG_DEBUG, "TDLS: Failed to parse KDEs in TPK M3 - ignore as an interop workaround"); } if (kde.lnkid == NULL || kde.lnkid_len < 3 * ETH_ALEN) { wpa_printf(MSG_INFO, "TDLS: No Link Identifier IE in TPK M3"); goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: Link ID Received from TPK M3", (u8 *) kde.lnkid, kde.lnkid_len); lnkid = (struct wpa_tdls_lnkid *) kde.lnkid; if (os_memcmp(sm->bssid, lnkid->bssid, ETH_ALEN) != 0) { wpa_printf(MSG_INFO, "TDLS: TPK M3 from diff BSS"); goto error; } if (!wpa_tdls_get_privacy(sm)) goto skip_rsn; if (kde.ftie == NULL || kde.ftie_len < sizeof(*ftie)) { wpa_printf(MSG_INFO, "TDLS: No FTIE in TPK M3"); goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: FTIE Received from TPK M3", kde.ftie, sizeof(*ftie)); ftie = (struct wpa_tdls_ftie *) kde.ftie; if (kde.rsn_ie == NULL) { wpa_printf(MSG_INFO, "TDLS: No RSN IE in TPK M3"); goto error; } wpa_hexdump(MSG_DEBUG, "TDLS: RSN IE Received from TPK M3", kde.rsn_ie, kde.rsn_ie_len); if (kde.rsn_ie_len != peer->rsnie_p_len || os_memcmp(kde.rsn_ie, peer->rsnie_p, peer->rsnie_p_len) != 0) { wpa_printf(MSG_INFO, "TDLS: RSN IE in TPK M3 does not match " "with the one sent in TPK M2"); goto error; } if (os_memcmp(peer->rnonce, ftie->Anonce, WPA_NONCE_LEN) != 0) { wpa_printf(MSG_INFO, "TDLS: FTIE ANonce in TPK M3 does " "not match with FTIE ANonce used in TPK M2"); goto error; } if (os_memcmp(peer->inonce, ftie->Snonce, WPA_NONCE_LEN) != 0) { wpa_printf(MSG_INFO, "TDLS: FTIE SNonce in TPK M3 does not " "match with FTIE SNonce used in TPK M1"); goto error; } if (kde.key_lifetime == NULL) { wpa_printf(MSG_INFO, "TDLS: No Key Lifetime IE in TPK M3"); goto error; } timeoutie = (struct wpa_tdls_timeoutie *) kde.key_lifetime; wpa_hexdump(MSG_DEBUG, "TDLS: Timeout IE Received from TPK M3", (u8 *) timeoutie, sizeof(*timeoutie)); lifetime = WPA_GET_LE32(timeoutie->value); wpa_printf(MSG_DEBUG, "TDLS: TPK lifetime %u seconds in TPK M3", lifetime); if (lifetime != peer->lifetime) { wpa_printf(MSG_INFO, "TDLS: Unexpected TPK lifetime %u in " "TPK M3 (expected %u)", lifetime, peer->lifetime); goto error; } if (wpa_supplicant_verify_tdls_mic(3, peer, (u8 *) lnkid, (u8 *) timeoutie, ftie) < 0) { wpa_tdls_del_key(sm, peer); goto error; } if (wpa_tdls_set_key(sm, peer) < 0) { /* * Some drivers may not be able to config the key prior to full * STA entry having been configured. */ wpa_printf(MSG_DEBUG, "TDLS: Try to configure TPK again after " "STA entry is complete"); peer->reconfig_key = 1; } skip_rsn: /* add supported rates, capabilities, and qos_info to the TDLS peer */ if (wpa_tdls_addset_peer(sm, peer, 0) < 0) goto error; if (!peer->tpk_success) { /* * Enable Link only when tpk_success is 0, signifying that this * processing of TPK M3 frame is not because of a retransmission * during TDLS setup handshake. */ ret = wpa_tdls_enable_link(sm, peer); if (ret < 0) { wpa_printf(MSG_DEBUG, "TDLS: Could not enable link"); goto error; } } return ret; error: wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); return -1; } static u8 * wpa_add_tdls_timeoutie(u8 *pos, u8 *ie, size_t ie_len, u32 tsecs) { struct wpa_tdls_timeoutie *lifetime = (struct wpa_tdls_timeoutie *) ie; os_memset(lifetime, 0, ie_len); lifetime->ie_type = WLAN_EID_TIMEOUT_INTERVAL; lifetime->ie_len = sizeof(struct wpa_tdls_timeoutie) - 2; lifetime->interval_type = WLAN_TIMEOUT_KEY_LIFETIME; WPA_PUT_LE32(lifetime->value, tsecs); os_memcpy(pos, ie, ie_len); return pos + ie_len; } /** * wpa_tdls_start - Initiate TDLS handshake (send TPK Handshake Message 1) * @sm: Pointer to WPA state machine data from wpa_sm_init() * @peer: MAC address of the peer STA * Returns: 0 on success, or -1 on failure * * Send TPK Handshake Message 1 info to driver to start TDLS * handshake with the peer. */ int wpa_tdls_start(struct wpa_sm *sm, const u8 *addr) { struct wpa_tdls_peer *peer; int tdls_prohibited = sm->tdls_prohibited; if (sm->tdls_disabled || !sm->tdls_supported) return -1; #ifdef CONFIG_TDLS_TESTING if ((tdls_testing & TDLS_TESTING_IGNORE_AP_PROHIBIT) && tdls_prohibited) { wpa_printf(MSG_DEBUG, "TDLS: Testing - ignore AP prohibition " "on TDLS"); tdls_prohibited = 0; } #endif /* CONFIG_TDLS_TESTING */ if (tdls_prohibited) { wpa_printf(MSG_DEBUG, "TDLS: TDLS is prohibited in this BSS - " "reject request to start setup"); return -1; } peer = wpa_tdls_add_peer(sm, addr, NULL); if (peer == NULL) return -1; if (peer->tpk_in_progress) { wpa_printf(MSG_DEBUG, "TDLS: Setup is already in progress with the peer"); return 0; } peer->initiator = 1; /* add the peer to the driver as a "setup in progress" peer */ if (wpa_sm_tdls_peer_addset(sm, peer->addr, 1, 0, 0, NULL, 0, NULL, NULL, 0, 0, NULL, 0, NULL, 0, NULL, 0)) { wpa_tdls_disable_peer_link(sm, peer); return -1; } peer->tpk_in_progress = 1; if (wpa_tdls_send_tpk_m1(sm, peer) < 0) { wpa_tdls_disable_peer_link(sm, peer); return -1; } return 0; } void wpa_tdls_remove(struct wpa_sm *sm, const u8 *addr) { struct wpa_tdls_peer *peer; if (sm->tdls_disabled || !sm->tdls_supported) return; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (peer == NULL || !peer->tpk_success) return; if (sm->tdls_external_setup) { /* * Disable previous link to allow renegotiation to be completed * on AP path. */ wpa_tdls_do_teardown(sm, peer, WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED); } } /** * wpa_supplicant_rx_tdls - Receive TDLS data frame * * This function is called to receive TDLS (ethertype = 0x890d) data frames. */ static void wpa_supplicant_rx_tdls(void *ctx, const u8 *src_addr, const u8 *buf, size_t len) { struct wpa_sm *sm = ctx; struct wpa_tdls_frame *tf; wpa_hexdump(MSG_DEBUG, "TDLS: Received Data frame encapsulation", buf, len); if (sm->tdls_disabled || !sm->tdls_supported) { wpa_printf(MSG_DEBUG, "TDLS: Discard message - TDLS disabled " "or unsupported by driver"); return; } if (os_memcmp(src_addr, sm->own_addr, ETH_ALEN) == 0) { wpa_printf(MSG_DEBUG, "TDLS: Discard copy of own message"); return; } if (len < sizeof(*tf)) { wpa_printf(MSG_INFO, "TDLS: Drop too short frame"); return; } /* Check to make sure its a valid encapsulated TDLS frame */ tf = (struct wpa_tdls_frame *) buf; if (tf->payloadtype != 2 /* TDLS_RFTYPE */ || tf->category != WLAN_ACTION_TDLS) { wpa_printf(MSG_INFO, "TDLS: Invalid frame - payloadtype=%u " "category=%u action=%u", tf->payloadtype, tf->category, tf->action); return; } switch (tf->action) { case WLAN_TDLS_SETUP_REQUEST: wpa_tdls_process_tpk_m1(sm, src_addr, buf, len); break; case WLAN_TDLS_SETUP_RESPONSE: wpa_tdls_process_tpk_m2(sm, src_addr, buf, len); break; case WLAN_TDLS_SETUP_CONFIRM: wpa_tdls_process_tpk_m3(sm, src_addr, buf, len); break; case WLAN_TDLS_TEARDOWN: wpa_tdls_recv_teardown(sm, src_addr, buf, len); break; case WLAN_TDLS_DISCOVERY_REQUEST: wpa_tdls_process_discovery_request(sm, src_addr, buf, len); break; default: /* Kernel code will process remaining frames */ wpa_printf(MSG_DEBUG, "TDLS: Ignore TDLS frame action code %u", tf->action); break; } } /** * wpa_tdls_init - Initialize driver interface parameters for TDLS * @wpa_s: Pointer to wpa_supplicant data * Returns: 0 on success, -1 on failure * * This function is called to initialize driver interface parameters for TDLS. * wpa_drv_init() must have been called before this function to initialize the * driver interface. */ int wpa_tdls_init(struct wpa_sm *sm) { if (sm == NULL) return -1; sm->l2_tdls = l2_packet_init(sm->bridge_ifname ? sm->bridge_ifname : sm->ifname, sm->own_addr, ETH_P_80211_ENCAP, wpa_supplicant_rx_tdls, sm, 0); if (sm->l2_tdls == NULL) { wpa_printf(MSG_ERROR, "TDLS: Failed to open l2_packet " "connection"); return -1; } /* * Drivers that support TDLS but don't implement the get_capa callback * are assumed to perform everything internally */ if (wpa_sm_tdls_get_capa(sm, &sm->tdls_supported, &sm->tdls_external_setup, &sm->tdls_chan_switch) < 0) { sm->tdls_supported = 1; sm->tdls_external_setup = 0; } wpa_printf(MSG_DEBUG, "TDLS: TDLS operation%s supported by " "driver", sm->tdls_supported ? "" : " not"); wpa_printf(MSG_DEBUG, "TDLS: Driver uses %s link setup", sm->tdls_external_setup ? "external" : "internal"); wpa_printf(MSG_DEBUG, "TDLS: Driver %s TDLS channel switching", sm->tdls_chan_switch ? "supports" : "does not support"); return 0; } void wpa_tdls_teardown_peers(struct wpa_sm *sm) { struct wpa_tdls_peer *peer, *tmp; if (!sm) return; peer = sm->tdls; wpa_printf(MSG_DEBUG, "TDLS: Tear down peers"); while (peer) { tmp = peer->next; wpa_printf(MSG_DEBUG, "TDLS: Tear down peer " MACSTR, MAC2STR(peer->addr)); if (sm->tdls_external_setup) wpa_tdls_do_teardown(sm, peer, WLAN_REASON_DEAUTH_LEAVING); else wpa_sm_tdls_oper(sm, TDLS_TEARDOWN, peer->addr); peer = tmp; } } static void wpa_tdls_remove_peers(struct wpa_sm *sm) { struct wpa_tdls_peer *peer, *tmp; peer = sm->tdls; while (peer) { int res; tmp = peer->next; res = wpa_sm_tdls_oper(sm, TDLS_DISABLE_LINK, peer->addr); wpa_printf(MSG_DEBUG, "TDLS: Remove peer " MACSTR " (res=%d)", MAC2STR(peer->addr), res); wpa_tdls_peer_free(sm, peer); peer = tmp; } } /** * wpa_tdls_deinit - Deinitialize driver interface parameters for TDLS * * This function is called to recover driver interface parameters for TDLS * and frees resources allocated for it. */ void wpa_tdls_deinit(struct wpa_sm *sm) { if (sm == NULL) return; if (sm->l2_tdls) l2_packet_deinit(sm->l2_tdls); sm->l2_tdls = NULL; wpa_tdls_remove_peers(sm); } void wpa_tdls_assoc(struct wpa_sm *sm) { wpa_printf(MSG_DEBUG, "TDLS: Remove peers on association"); wpa_tdls_remove_peers(sm); } void wpa_tdls_disassoc(struct wpa_sm *sm) { wpa_printf(MSG_DEBUG, "TDLS: Remove peers on disassociation"); wpa_tdls_remove_peers(sm); } static int wpa_tdls_prohibited(struct ieee802_11_elems *elems) { /* bit 38 - TDLS Prohibited */ return !!(elems->ext_capab[4] & 0x40); } static int wpa_tdls_chan_switch_prohibited(struct ieee802_11_elems *elems) { /* bit 39 - TDLS Channel Switch Prohibited */ return !!(elems->ext_capab[4] & 0x80); } void wpa_tdls_ap_ies(struct wpa_sm *sm, const u8 *ies, size_t len) { struct ieee802_11_elems elems; sm->tdls_prohibited = 0; sm->tdls_chan_switch_prohibited = 0; if (ies == NULL || ieee802_11_parse_elems(ies, len, &elems, 0) == ParseFailed || elems.ext_capab == NULL || elems.ext_capab_len < 5) return; sm->tdls_prohibited = wpa_tdls_prohibited(&elems); wpa_printf(MSG_DEBUG, "TDLS: TDLS is %s in the target BSS", sm->tdls_prohibited ? "prohibited" : "allowed"); sm->tdls_chan_switch_prohibited = wpa_tdls_chan_switch_prohibited(&elems); wpa_printf(MSG_DEBUG, "TDLS: TDLS channel switch %s in the target BSS", sm->tdls_chan_switch_prohibited ? "prohibited" : "allowed"); } void wpa_tdls_assoc_resp_ies(struct wpa_sm *sm, const u8 *ies, size_t len) { struct ieee802_11_elems elems; if (ies == NULL || ieee802_11_parse_elems(ies, len, &elems, 0) == ParseFailed || elems.ext_capab == NULL || elems.ext_capab_len < 5) return; if (!sm->tdls_prohibited && wpa_tdls_prohibited(&elems)) { wpa_printf(MSG_DEBUG, "TDLS: TDLS prohibited based on " "(Re)Association Response IEs"); sm->tdls_prohibited = 1; } if (!sm->tdls_chan_switch_prohibited && wpa_tdls_chan_switch_prohibited(&elems)) { wpa_printf(MSG_DEBUG, "TDLS: TDLS channel switch prohibited based on (Re)Association Response IEs"); sm->tdls_chan_switch_prohibited = 1; } } void wpa_tdls_enable(struct wpa_sm *sm, int enabled) { wpa_printf(MSG_DEBUG, "TDLS: %s", enabled ? "enabled" : "disabled"); sm->tdls_disabled = !enabled; } int wpa_tdls_is_external_setup(struct wpa_sm *sm) { return sm->tdls_external_setup; } int wpa_tdls_enable_chan_switch(struct wpa_sm *sm, const u8 *addr, u8 oper_class, struct hostapd_freq_params *freq_params) { struct wpa_tdls_peer *peer; int ret; if (sm->tdls_disabled || !sm->tdls_supported) return -1; if (!sm->tdls_chan_switch) { wpa_printf(MSG_DEBUG, "TDLS: Channel switching not supported by the driver"); return -1; } if (sm->tdls_chan_switch_prohibited) { wpa_printf(MSG_DEBUG, "TDLS: Channel switching is prohibited in this BSS - reject request to switch channel"); return -1; } for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (peer == NULL || !peer->tpk_success) { wpa_printf(MSG_ERROR, "TDLS: Peer " MACSTR " not found for channel switching", MAC2STR(addr)); return -1; } if (peer->chan_switch_enabled) { wpa_printf(MSG_DEBUG, "TDLS: Peer " MACSTR " already has channel switching enabled", MAC2STR(addr)); return 0; } ret = wpa_sm_tdls_enable_channel_switch(sm, peer->addr, oper_class, freq_params); if (!ret) peer->chan_switch_enabled = 1; return ret; } int wpa_tdls_disable_chan_switch(struct wpa_sm *sm, const u8 *addr) { struct wpa_tdls_peer *peer; if (sm->tdls_disabled || !sm->tdls_supported) return -1; for (peer = sm->tdls; peer; peer = peer->next) { if (os_memcmp(peer->addr, addr, ETH_ALEN) == 0) break; } if (!peer || !peer->chan_switch_enabled) { wpa_printf(MSG_ERROR, "TDLS: Channel switching not enabled for " MACSTR, MAC2STR(addr)); return -1; } /* ignore the return value */ wpa_sm_tdls_disable_channel_switch(sm, peer->addr); peer->chan_switch_enabled = 0; return 0; }
0414e719c744de248ce7feed1557c0e93885a05c
fae867d62224cdf27ceb85654525a311fb8c4226
/tools/fpgautils/fpgautil.c
5ba29f30b2b61b1dc956f983f5cc343558d8d6cc
[ "BSD-3-Clause" ]
permissive
RedPitaya/RedPitaya
a4a9b0bda0d1806e39b90ee9f3164e2e0dee0ab6
69826707f78c764e5835f3197e61f68ced90f77b
refs/heads/master
2023-09-01T12:25:51.370133
2023-07-26T03:51:31
2023-07-26T03:51:31
17,261,658
447
601
NOASSERTION
2023-07-27T04:07:43
2014-02-27T19:38:52
C
UTF-8
C
false
false
13,945
c
fpgautil.c
/****************************************************************************** * * Copyright (C) 2019-2020 Xilinx, Inc. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is furnished to do * so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * ******************************************************************************/ /*****************************************************************************/ /** * @file: fpgautil.c * Simple command line tool to load fpga via overlay or through sysfs interface * and read fpga configuration using Xilinx Zynq/ZynqMP fpga manager * Author: Appana Durga Kedareswara Rao <appanad@xilinx.com> * Author: Nava kishore Manne <navam@xilinx.com> */ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <string.h> #include <signal.h> #include <getopt.h> #include <poll.h> #include <ctype.h> #include <libgen.h> #include <time.h> #include <errno.h> #include <sys/time.h> #include <sys/stat.h> #define OVERLAY 1 #define FPGA_SYSFS 2 #define READBACK 3 #define ENCRYPTION_USERKEY_EN (0x20U) int fpga_getplatform() { char fpstr[100]; FILE *fptr; char *zynqmpstr = "Xilinx ZynqMP FPGA Manager"; if ((fptr = fopen("/sys/class/fpga_manager/fpga0/name", "r")) == NULL) { printf("Error! opening file"); // Program exits if file pointer returns NULL. exit(1); } // reads text until newline fscanf(fptr,"%[^\n]", fpstr); fclose(fptr); if (!strcmp(zynqmpstr, fpstr)) return 1; else return 0; } void print_usage(char *prg) { int iszynqmp = fpga_getplatform(); fprintf(stderr, "\n%s: FPGA Utility for Loading/reading PL Configuration\n\n", prg); fprintf(stderr, "Usage: %s -b <bin file path> -o <dtbo file path>\n\r", prg); fprintf(stderr, "\n"); fprintf(stderr, "Options: -b <binfile> (Bin file path)\n"); fprintf(stderr, " -o <dtbofile> (DTBO file path)\n"); fprintf(stderr, " -f <flags> Optional: <Bitstream type flags>\n"); fprintf(stderr, " f := <Full | Partial > \n"); fprintf(stderr, " -n <Fpga region info> FPGA Regions represent FPGA's\n"); fprintf(stderr, " and partial reconfiguration\n"); fprintf(stderr, " regions of FPGA's in the\n"); fprintf(stderr, " Device Tree\n"); if (iszynqmp) { fprintf(stderr, " Default: <Full>\n"); fprintf(stderr, " -s <secure flags> Optional: <Secure flags>\n"); fprintf(stderr, " s := <AuthDDR | AuthOCM | EnUsrKey | EnDevKey | AuthEnUsrKeyDDR | AuthEnUsrKeyOCM | AuthEnDevKeyDDR | AuthEnDevKeyOCM>\n"); fprintf(stderr, " -k <AesKey> Optional: <AES User Key>\n"); fprintf(stderr, " -r <Readback> Optional: <file name>\n"); fprintf(stderr, " Default: By default Read back contents will be stored in readback.bin file\n"); fprintf(stderr, " -t Optional: <Readback Type>\n"); fprintf(stderr, " 0 - Configuration Register readback\n"); fprintf(stderr, " 1 - Configuration Data Frames readback\n"); fprintf(stderr, " Default: 0 (Configuration register readback)\n"); fprintf(stderr, " -R Optional: Remove overlay from a live tree\n"); } fprintf(stderr, " \n"); fprintf(stderr, "Examples:\n"); fprintf(stderr, "(Load Full bitstream using Overlay)\n"); fprintf(stderr, "%s -b top.bit.bin -o can.dtbo -f Full -n Full \n", prg); fprintf(stderr, "(Load Partial bitstream using Overlay)\n"); fprintf(stderr, "%s -b rm0.bit.bin -o rm0.dtbo -f Partial -n PR0\n", prg); fprintf(stderr, "(Load Full bitstream using sysfs interface)\n"); fprintf(stderr, "%s -b top.bit.bin -f Full\n", prg); fprintf(stderr, "(Load Partial bitstream using sysfs interface)\n"); fprintf(stderr, "%s -b rm0.bit.bin -f Partial\n", prg); if (iszynqmp) { fprintf(stderr, "(Load Authenticated bitstream through the sysfs interface)\n"); fprintf(stderr, "%s -b top.bit.bin -f Full -s AuthDDR \n", prg); fprintf(stderr, "(Load Parital Encrypted Userkey bitstream using Overlay)\n"); fprintf(stderr, "%s -b top.bit.bin -o pl.dtbo -f Partial -s EnUsrKey -k <32byte key value>\n", prg); fprintf(stderr, "(Read PL Configuration Registers)\n"); fprintf(stderr, "%s -b top.bit.bin -r\n", prg); } fprintf(stderr, " \n"); } int gettime(struct timeval t0, struct timeval t1) { return ((t1.tv_sec - t0.tv_sec) * 1000.0f + (t1.tv_usec -t0.tv_usec) / 1000.0f); } int fpga_state() { FILE *fptr; char buf[10]; char *state_operating = "operating"; char *state_unknown = "unknown"; system("cat /sys/class/fpga_manager/fpga0/state >> /tmp/fpga_util_state_bit.txt"); fptr = fopen("/tmp/fpga_util_state_bit.txt", "r"); if (fptr) { fgets(buf, 10, fptr); fclose(fptr); system("rm /tmp/fpga_util_state_bit.txt"); if ((strncmp(buf, state_operating, 9) == 0) || (strncmp(buf, state_unknown, 7) == 0)) return 0; else return 1; } return 1; } static int fpga_overlay_check(char *cmd, char *state) { char buf[512]; FILE *fptr; int len; system(cmd); len = strlen(state) + 1; fptr = fopen("/tmp/fpga_util_state.txt", "r"); if (fptr) { fgets(buf, len, fptr); fclose(fptr); system("rm /tmp/fpga_util_state.txt"); if (!strcmp(buf, state)) return 0; else return 1; } return 1; } struct fpgaflag { char *flag; unsigned int value; }; static struct fpgaflag flagdump[] = { {.flag = "Full", .value = 0x0}, {.flag = "Partial", .value = 0x1}, {.flag = "AuthDDR", .value = 0x40}, {.flag = "AuthOCM", .value = 0x80}, {.flag = "EnUsrKey", .value = 0x20}, {.flag = "EnDevKey", .value = 0x4}, {.flag = "AuthEnUsrKeyDDR", .value = 0x60}, {.flag = "AuthEnUsrKeyOCM", .value = 0xA0}, {.flag = "AuthEnDevKeyDDR", .value = 0x44}, {.flag = "AuthEnDevKeyOCM", .value = 0x84}, {} }; static int cmd_flags(int argc, const char *name) { int valid_flag = 0; int flag = 0; struct fpgaflag *p = flagdump; while (p->flag) { if (!strcmp(name, p->flag)) { flag = p->value; break; } p++; } return flag; } static int isvalid_flags(int argc, const char *name, bool is_secure) { int valid_flag = 0; int count = 0; struct fpgaflag *p; if (!is_secure) p = flagdump; else p = &flagdump[2]; while (p->flag) { if (!strcmp(name, p->flag)) return 0; else if ((!is_secure) && (++count == 2)) return 1; p++; } return 1; } int main(int argc, char **argv) { int ret; int iszynqmp = fpga_getplatform(); char *binfile = NULL, *overlay = NULL, *AesKey = NULL, *flag = NULL, *partial_overlay = NULL; char *region = NULL, *Module[100] = {0}; int opt, flags = 0, flow = 0,rm_overlay = 0, readback_type = 0, sflags = 0; char command[2048], folder[512], *token, *tmp, *tmp1, *tmp2 , *tmp3; const char *filename = "readback", *name; struct stat sb; double time; struct timeval t1, t0; if (argc == 1) { print_usage(basename(argv[0])); return 1; } while ((opt = getopt(argc, argv, "o:b:n:f:s:p:k:rt::Rh?:")) != -1) { switch (opt) { case 'o': overlay = optarg; flow = OVERLAY; break; case 'b': binfile = optarg; if (!(flow == OVERLAY)) flow = FPGA_SYSFS; break; case 'n': region = optarg; break; case 'f': if (flow == OVERLAY) { name = argv[6]; flags = cmd_flags(argc, name); } else if (flow == FPGA_SYSFS) { name = argv[4]; flags = cmd_flags(argc, name); } ret = isvalid_flags(argc, name, false); if (ret) { printf("Error: Invalid arugments :%s\n", strerror(1)); print_usage(basename(argv[0])); return -EINVAL; } flags += sflags; break; case 's': if (flow == OVERLAY) { name = argv[8]; sflags = cmd_flags(argc, name); } else if (flow == FPGA_SYSFS) { name = argv[6]; sflags = cmd_flags(argc, name); } ret = isvalid_flags(argc, name, true); if (ret) { printf("Error: Invalid arugments :%s\n", strerror(1)); print_usage(basename(argv[0])); return -EINVAL; } flags += sflags; break; case 'p': partial_overlay = optarg; break; case 'k': AesKey = optarg; break; case 't': if (optarg == NULL && argv[4] != NULL) readback_type = atoi(argv[4]); break; case 'r': if (optarg == NULL && argv[2] != NULL) filename = argv[2]; flow = READBACK; break; case 'R': rm_overlay = 1; break; case '?': case 'h': default: print_usage(basename(argv[0])); return 1; break; } } if(region != NULL) snprintf(folder, sizeof(folder), "/configfs/device-tree/overlays/%s", region); else if (!(flags & 1)) snprintf(folder, sizeof(folder), "/configfs/device-tree/overlays/full"); else if (overlay != NULL) { printf("Error: Provide valid Overlay region info\n\r"); return 1; } system("mkdir -p /lib/firmware"); if (rm_overlay) { if (((stat(folder, &sb) == 0) && S_ISDIR(sb.st_mode))) { snprintf(command, sizeof(command), "rmdir %s", folder); system(command); } return 0; } if (flow == OVERLAY) { if (((stat(folder, &sb) == 0) && S_ISDIR(sb.st_mode))) { printf("Error: Overlay already exists in the live tree\n\r"); return 1; } if (((stat("/configfs/device-tree/", &sb) == 0) && S_ISDIR(sb.st_mode))) { } else { system("mkdir /configfs"); system("mount -t configfs configfs /configfs"); } if (binfile != NULL) { snprintf(command, sizeof(command), "cp %s /lib/firmware", binfile); system(command); } snprintf(command, sizeof(command), "cp %s /lib/firmware", overlay); system(command); tmp = strdup(overlay); while((token = strsep(&tmp, "/"))) { tmp1 = token; } if (binfile != NULL) { snprintf(command, sizeof(command), "echo %x > /sys/class/fpga_manager/fpga0/flags", flags); system(command); if (ENCRYPTION_USERKEY_EN & flags) { snprintf(command, sizeof(command), "echo %s > /sys/class/fpga_manager/fpga0/key", AesKey); system(command); } } snprintf(command, sizeof(command), "mkdir %s", folder); system(command); snprintf(command, sizeof(command), "echo -n %s > %s/path", tmp1, folder); gettimeofday(&t0, NULL); system(command); gettimeofday(&t1, NULL); time = gettime(t0, t1); snprintf(command, sizeof(command), "cat %s/path >> /tmp/fpga_util_state.txt", folder); ret = fpga_overlay_check(command, tmp1); if (ret) { printf("Failed to apply Overlay\n\r"); } /* Delete Bin file and DTBO file*/ snprintf(command, sizeof(command), "rm /lib/firmware/%s", tmp1); system(command); if (binfile != NULL) { tmp = strdup(binfile); while((token = strsep(&tmp, "/"))) { tmp1 = token; } snprintf(command, sizeof(command), "rm /lib/firmware/%s", tmp1); system(command); } /* FPGA state check */ if (binfile != NULL) { if (!fpga_state()) { printf("Time taken to load BIN is %f Milli Seconds\n\r", time); printf("BIN FILE loaded through FPGA manager successfully\n\r"); } else { printf("BIN FILE loading through FPGA manager failed\n\r"); } } } else if (flow == FPGA_SYSFS) { if (argc < 3) { printf("%s: For more information run %s -h\n", strerror(22), basename(argv[0])); return 1; } snprintf(command, sizeof(command), "cp %s /lib/firmware", binfile); system(command); snprintf(command, sizeof(command), "echo %x > /sys/class/fpga_manager/fpga0/flags", flags); system(command); if (ENCRYPTION_USERKEY_EN & flags) { snprintf(command, sizeof(command), "echo %s > /sys/class/fpga_manager/fpga0/key", AesKey); system(command); } tmp = strdup(binfile); while((token = strsep(&tmp, "/"))) { tmp1 = token; } snprintf(command, sizeof(command), "echo %s > /sys/class/fpga_manager/fpga0/firmware", tmp1); gettimeofday(&t0, NULL); system(command); gettimeofday(&t1, NULL); time = gettime(t0, t1); /* Delete Bin file and DTBO file*/ snprintf(command, sizeof(command), "rm /lib/firmware/%s", tmp1); system(command); /* FPGA state check */ if (!fpga_state()) { printf("Time taken to load BIN is %f Milli Seconds\n\r", time); printf("BIN FILE loaded through FPGA manager successfully\n\r"); } else { printf("BIN FILE loading through FPGA manager failed\n\r"); } } else if (flow == READBACK) { if (readback_type > 1) { printf("Invalid arugments :%s\n", strerror(1)); printf("For more information run %s -h\n", basename(argv[0])); return -EINVAL; } snprintf(command, sizeof(command), "echo %x > /sys/module/zynqmp_fpga/parameters/readback_type", readback_type); system(command); snprintf(command, sizeof(command), "cat /sys/kernel/debug/fpga/fpga0/image >> %s.bin", filename); system(command); printf("Readback contents are stored in the file %s.bin\n\r", filename); } return 0; }
0d78cc5ee02af539893c1696427ce499aaa6313c
abe704eb3b53944cdd6505f922f58558e334c589
/components/usb/iot_usbh_cdc/include/iot_usbh_cdc.h
071e7f0ff1b1f0e71e3654a67ffc4acd2324d3d4
[ "Apache-2.0" ]
permissive
espressif/esp-iot-solution
c25079eb26a8f54ddacd23689a7288533c721916
2227f0ca21ab37df9cf9d74182fa84c52dffc76f
refs/heads/master
2023-09-01T15:06:17.000154
2023-08-31T10:26:21
2023-08-31T10:26:21
99,690,601
1,612
758
Apache-2.0
2023-09-08T08:43:59
2017-08-08T12:32:16
C
UTF-8
C
false
false
7,898
h
iot_usbh_cdc.h
/* * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once #include "freertos/FreeRTOS.h" #include "esp_err.h" #include "iot_usbh.h" #if (CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3) #define CDC_INTERFACE_NUM_MAX 3 /*!< Support 3 cdc interface at most (each only contains two bulk channel) */ #else #define CDC_INTERFACE_NUM_MAX 0 #error "USB Host CDC not supported" #endif /** * @brief USB receive callback type */ typedef void(*usbh_cdc_cb_t)(void *arg); /** * @brief USB host CDC configuration type * itf_num is the total enabled interface numbers, can not exceed CDC_INTERFACE_NUM_MAX, * itf_num = 0 is same as itf_num = 1 for back compatibility, * if itf_num > 1, user should config params with `s` ending like `bulk_in_ep_addrs` to config each interface, * callbacks should not in block state. */ typedef struct usbh_cdc_config { int itf_num; /*!< interface numbers enabled */ union { uint8_t bulk_in_ep_addr; /*!< USB CDC bulk in endpoint address, will be overwritten if bulk_in_ep is specified */ uint8_t bulk_in_ep_addrs[CDC_INTERFACE_NUM_MAX]; /*!< USB CDC bulk in endpoints addresses, saved as an array, will be overwritten if bulk_in_ep is specified */ }; union { uint8_t bulk_out_ep_addr; /*!< USB CDC bulk out endpoint address, will be overwritten if bulk_out_ep is specified */ uint8_t bulk_out_ep_addrs[CDC_INTERFACE_NUM_MAX]; /*!< USB CDC bulk out endpoint addresses, saved as an array, will be overwritten if bulk_out_ep is specified */ }; union { int rx_buffer_size; /*!< USB receive/in ringbuffer size */ int rx_buffer_sizes[CDC_INTERFACE_NUM_MAX]; /*!< USB receive/in ringbuffer size of each interface */ }; union { int tx_buffer_size; /*!< USB transmit/out ringbuffer size */ int tx_buffer_sizes[CDC_INTERFACE_NUM_MAX]; /*!< USB transmit/out ringbuffer size of each interface */ }; union { usb_ep_desc_t *bulk_in_ep; /*!< USB CDC bulk in endpoint descriptor, set NULL if using default param */ usb_ep_desc_t *bulk_in_eps[CDC_INTERFACE_NUM_MAX]; /*!< USB CDC bulk in endpoint descriptors of each interface, set NULL if using default param */ }; union { usb_ep_desc_t *bulk_out_ep; /*!< USB CDC bulk out endpoint descriptor, set NULL if using default param */ usb_ep_desc_t *bulk_out_eps[CDC_INTERFACE_NUM_MAX]; /*!< USB CDC bulk out endpoint descriptors of each interface, set NULL if using default param */ }; usbh_cdc_cb_t conn_callback; /*!< USB connect callback, set NULL if not use */ usbh_cdc_cb_t disconn_callback; /*!< USB disconnect callback, set NULL if not use */ union { usbh_cdc_cb_t rx_callback; /*!< packet receive callback, set NULL if not use */ usbh_cdc_cb_t rx_callbacks[CDC_INTERFACE_NUM_MAX]; /*!< packet receive callbacks of each interface, set NULL if not use */ }; void *conn_callback_arg; /*!< USB connect callback arg, set NULL if not use */ void *disconn_callback_arg; /*!< USB disconnect callback arg, set NULL if not use */ union { void *rx_callback_arg; /*!< packet receive callback arg, set NULL if not use */ void *rx_callback_args[CDC_INTERFACE_NUM_MAX]; /*!< packet receive callback arg of each interface, set NULL if not use */ }; } usbh_cdc_config_t; /** * @brief Install USB CDC driver. * * @param config USB Host CDC configs * @return * ESP_ERR_INVALID_STATE driver has been installed * ESP_ERR_INVALID_ARG args not supported * ESP_FAIL driver install failed * ESP_OK driver install succeed */ esp_err_t usbh_cdc_driver_install(const usbh_cdc_config_t *config); /** * @brief Uninstall USB driver. * * @return * ESP_ERR_INVALID_STATE driver not installed * ESP_OK start succeed */ esp_err_t usbh_cdc_driver_delete(void); /** * @brief Waiting until CDC device connected * * @param ticks_to_wait timeout value, count in RTOS ticks * @return * ESP_ERR_INVALID_STATE driver not installed * ESP_ERR_TIMEOUT wait timeout * ESP_OK device connect succeed */ esp_err_t usbh_cdc_wait_connect(TickType_t ticks_to_wait); /** * @brief Send data to interface 0 of connected USB device from a given buffer and length, * this function will return after copying all the data to tx ringbuffer. * * @param buf data buffer address * @param length data length to send * @return int The number of bytes pushed to the tx buffer */ int usbh_cdc_write_bytes(const uint8_t *buf, size_t length); /** * @brief Send data to specified interface of connected USB device from a given buffer and length, * this function will return after copying all the data to tx buffer. * * @param itf the interface index * @param buf data buffer address * @param length data length to send * @return int The number of bytes pushed to the tx buffer */ int usbh_cdc_itf_write_bytes(uint8_t itf, const uint8_t *buf, size_t length); /** * @brief Get USB interface 0 rx buffered data length. * * @param size data length buffered * @return * ESP_ERR_INVALID_STATE cdc not configured, or not running * ESP_ERR_INVALID_ARG args not supported * ESP_OK start succeed */ esp_err_t usbh_cdc_get_buffered_data_len(size_t *size); /** * @brief Get USB specified interface rx buffered data length. * * @param itf the interface index * @param size data length buffered * @return * ESP_ERR_INVALID_STATE cdc not configured, or not running * ESP_ERR_INVALID_ARG args not supported * ESP_OK start succeed */ esp_err_t usbh_cdc_itf_get_buffered_data_len(uint8_t itf, size_t *size); /** * @brief Read data bytes from interface 0 rx buffer. * * @param buf data buffer address * @param length data buffer size * @param ticks_to_wait timeout value, count in RTOS ticks * @return int the number of bytes actually read from rx buffer */ int usbh_cdc_read_bytes(uint8_t *buf, size_t length, TickType_t ticks_to_wait); /** * @brief Read data bytes from specified interface rx buffer. * * @param itf the interface index * @param buf data buffer address * @param length data buffer size * @param ticks_to_wait timeout value, count in RTOS ticks * @return int the number of bytes actually read from rx buffer */ int usbh_cdc_itf_read_bytes(uint8_t itf, uint8_t *buf, size_t length, TickType_t ticks_to_wait); /** * @brief Get the connect state of given interface * * @param itf the interface index * @return ** int true is ready, false is not ready */ int usbh_cdc_get_itf_state(uint8_t itf); /** * @brief Flush rx buffer, discard all the data in the ring-buffer. * * @param itf the interface index * @return ** esp_err_t * ESP_ERR_INVALID_STATE cdc not configured, or not running * ESP_ERR_INVALID_ARG args not supported * ESP_OK start succeed */ esp_err_t usbh_cdc_flush_rx_buffer(uint8_t itf); /** * @brief Flush tx buffer, discard all the data in the ring-buffer. * * @param itf the interface index * @return ** esp_err_t * ESP_ERR_INVALID_STATE cdc not configured, or not running * ESP_ERR_INVALID_ARG args not supported * ESP_OK start succeed */ esp_err_t usbh_cdc_flush_tx_buffer(uint8_t itf);
ea36c66fc2520c11e1ef80c499facdb5fbaa106b
18333497cc6db4a990a5f5e7b0dca14e9a517a73
/include/cmt/memory/buffer.h
c7ff2e60fb2e3d756c6b637fcd6093d238ccbe6e
[ "MIT" ]
permissive
recp/cmt
6ecbca0a356ec044257285ab58e062ee6af55c7c
e2730ade077345b389213d6695d0d7a6c4e93264
refs/heads/master
2023-05-25T16:32:50.511305
2023-05-14T11:40:55
2023-05-14T11:40:55
137,069,724
138
12
MIT
2023-05-14T11:40:56
2018-06-12T12:39:37
C
UTF-8
C
false
false
1,217
h
buffer.h
/* * Copyright (c), Recep Aslantas. * MIT License (MIT), http://opensource.org/licenses/MIT */ #ifndef cmt_buffer_h #define cmt_buffer_h #ifdef __cplusplus extern "C" { #endif #include "cmt/common.h" #include "cmt/types.h" #include "cmt/enums.h" #include "cmt/resource.h" MT_EXPORT MT_API_AVAILABLE(mt_macos(10.11), mt_ios(8.0)) void* mtBufferContents(MtBuffer* buf); MT_EXPORT MT_API_AVAILABLE(mt_macos(10.11), mt_ios(8.0)) NsUInteger mtBufferLength(MtBuffer* buf); MT_EXPORT MT_API_AVAILABLE(mt_macos(10.11), mt_ios(8.0)) void mtBufferDidModifyRange(MtBuffer* buf, NsRange ran); MT_EXPORT MT_API_AVAILABLE(mt_macos(10.12), mt_ios(10.0)) void mtBufferAddDebugMarkerRange(MtBuffer* buf, char* string, NsRange range); MT_EXPORT MT_API_AVAILABLE(mt_macos(10.12), mt_ios(10.0)) void mtBufferRemoveAllDebugMarkers(MtBuffer* buf); // Those exist only on osx 10.15 MT_EXPORT MT_API_AVAILABLE(mt_macos(10.15)) MT_API_UNAVAILABLE(mt_ios) MtBuffer* mtBufferNewRemoteBufferViewForDevice(MtBuffer *buf, MtDevice *device); MT_EXPORT MT_API_AVAILABLE(mt_macos(10.15)) MT_API_UNAVAILABLE(mt_ios) MtBuffer* mtBufferRemoteStorageBuffer(MtBuffer *buf); #ifdef __cplusplus } #endif // end 10.15 #endif /* cmt_buffer_h */
b834a448c9b4c2c674d1f74706f0e6523df8c672
d48e09166db1ff0dae2c8a4ddbbe453606689081
/phonelibs/android_frameworks_native/include/media/openmax/OMX_ContentPipe.h
0224c8a2eed1bfca40b5fedb4b0a4ab6c8ec058f
[ "MIT" ]
permissive
Gernby/raspberry-pilot
a8857fdb2a50ade237d657ccd9d1049c5aa65515
0909e7594dff1c6fb524b5502ce3258f1969b6a5
refs/heads/resonant-rails
2023-04-06T10:09:35.457160
2023-01-06T01:57:31
2023-01-06T01:57:31
242,575,807
141
62
MIT
2023-03-05T05:22:49
2020-02-23T19:15:12
C
UTF-8
C
false
false
9,931
h
OMX_ContentPipe.h
/* ------------------------------------------------------------------ * Copyright (C) 1998-2009 PacketVideo * * 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. * ------------------------------------------------------------------- */ /* * Copyright (c) 2008 The Khronos Group Inc. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to * permit persons to whom the Software is furnished to do so, subject * to the following conditions: * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * */ /** OMX_ContentPipe.h - OpenMax IL version 1.1.2 * The OMX_ContentPipe header file contains the definitions used to define * the public interface for content piples. This header file is intended to * be used by the component. */ #ifndef OMX_CONTENTPIPE_H #define OMX_CONTENTPIPE_H #ifndef KD_EACCES /* OpenKODE error codes. CPResult values may be zero (indicating success or one of the following values) */ #define KD_EACCES (1) #define KD_EADDRINUSE (2) #define KD_EAGAIN (5) #define KD_EBADF (7) #define KD_EBUSY (8) #define KD_ECONNREFUSED (9) #define KD_ECONNRESET (10) #define KD_EDEADLK (11) #define KD_EDESTADDRREQ (12) #define KD_ERANGE (35) #define KD_EEXIST (13) #define KD_EFBIG (14) #define KD_EHOSTUNREACH (15) #define KD_EINVAL (17) #define KD_EIO (18) #define KD_EISCONN (20) #define KD_EISDIR (21) #define KD_EMFILE (22) #define KD_ENAMETOOLONG (23) #define KD_ENOENT (24) #define KD_ENOMEM (25) #define KD_ENOSPC (26) #define KD_ENOSYS (27) #define KD_ENOTCONN (28) #define KD_EPERM (33) #define KD_ETIMEDOUT (36) #define KD_EILSEQ (19) #endif /** Map types from OMX standard types only here so interface is as generic as possible. */ typedef OMX_U32 CPresult; typedef char * CPstring; typedef void * CPhandle; typedef OMX_U32 CPuint; typedef OMX_S32 CPint; typedef char CPbyte; typedef OMX_BOOL CPbool; /** enumeration of origin types used in the CP_PIPETYPE's Seek function * @ingroup cp */ typedef enum CP_ORIGINTYPE { CP_OriginBegin, CP_OriginCur, CP_OriginEnd, CP_OriginKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_OriginVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_OriginMax = 0X7FFFFFFF } CP_ORIGINTYPE; /** enumeration of contact access types used in the CP_PIPETYPE's Open function * @ingroup cp */ typedef enum CP_ACCESSTYPE { CP_AccessRead, CP_AccessWrite, CP_AccessReadWrite, CP_AccessKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_AccessVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_AccessMax = 0X7FFFFFFF } CP_ACCESSTYPE; /** enumeration of results returned by the CP_PIPETYPE's CheckAvailableBytes function * @ingroup cp */ typedef enum CP_CHECKBYTESRESULTTYPE { CP_CheckBytesOk, /**< There are at least the request number of bytes available */ CP_CheckBytesNotReady, /**< The pipe is still retrieving bytes and presently lacks sufficient bytes. Client will be called when they are sufficient bytes are available. */ CP_CheckBytesInsufficientBytes, /**< The pipe has retrieved all bytes but those available are less than those requested */ CP_CheckBytesAtEndOfStream, /**< The pipe has reached the end of stream and no more bytes are available. */ CP_CheckBytesOutOfBuffers, /**< All read/write buffers are currently in use. */ CP_CheckBytesKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_CheckBytesVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_CheckBytesMax = 0X7FFFFFFF } CP_CHECKBYTESRESULTTYPE; /** enumeration of content pipe events sent to the client callback. * @ingroup cp */ typedef enum CP_EVENTTYPE{ CP_BytesAvailable, /** bytes requested in a CheckAvailableBytes call are now available*/ CP_Overflow, /** enumeration of content pipe events sent to the client callback*/ CP_PipeDisconnected, /** enumeration of content pipe events sent to the client callback*/ CP_EventKhronosExtensions = 0x6F000000, /**< Reserved region for introducing Khronos Standard Extensions */ CP_EventVendorStartUnused = 0x7F000000, /**< Reserved region for introducing Vendor Extensions */ CP_EventMax = 0X7FFFFFFF } CP_EVENTTYPE; /** content pipe definition * @ingroup cp */ typedef struct CP_PIPETYPE { /** Open a content stream for reading or writing. */ CPresult (*Open)( CPhandle* hContent, CPstring szURI, CP_ACCESSTYPE eAccess ); /** Close a content stream. */ CPresult (*Close)( CPhandle hContent ); /** Create a content source and open it for writing. */ CPresult (*Create)( CPhandle *hContent, CPstring szURI ); /** Check the that specified number of bytes are available for reading or writing (depending on access type).*/ CPresult (*CheckAvailableBytes)( CPhandle hContent, CPuint nBytesRequested, CP_CHECKBYTESRESULTTYPE *eResult ); /** Seek to certain position in the content relative to the specified origin. */ CPresult (*SetPosition)( CPhandle hContent, CPint nOffset, CP_ORIGINTYPE eOrigin); /** Retrieve the current position relative to the start of the content. */ CPresult (*GetPosition)( CPhandle hContent, CPuint *pPosition); /** Retrieve data of the specified size from the content stream (advance content pointer by size of data). Note: pipe client provides pointer. This function is appropriate for small high frequency reads. */ CPresult (*Read)( CPhandle hContent, CPbyte *pData, CPuint nSize); /** Retrieve a buffer allocated by the pipe that contains the requested number of bytes. Buffer contains the next block of bytes, as specified by nSize, of the content. nSize also returns the size of the block actually read. Content pointer advances the by the returned size. Note: pipe provides pointer. This function is appropriate for large reads. The client must call ReleaseReadBuffer when done with buffer. In some cases the requested block may not reside in contiguous memory within the pipe implementation. For instance if the pipe leverages a circular buffer then the requested block may straddle the boundary of the circular buffer. By default a pipe implementation performs a copy in this case to provide the block to the pipe client in one contiguous buffer. If, however, the client sets bForbidCopy, then the pipe returns only those bytes preceding the memory boundary. Here the client may retrieve the data in segments over successive calls. */ CPresult (*ReadBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint *nSize, CPbool bForbidCopy); /** Release a buffer obtained by ReadBuffer back to the pipe. */ CPresult (*ReleaseReadBuffer)(CPhandle hContent, CPbyte *pBuffer); /** Write data of the specified size to the content (advance content pointer by size of data). Note: pipe client provides pointer. This function is appropriate for small high frequency writes. */ CPresult (*Write)( CPhandle hContent, CPbyte *data, CPuint nSize); /** Retrieve a buffer allocated by the pipe used to write data to the content. Client will fill buffer with output data. Note: pipe provides pointer. This function is appropriate for large writes. The client must call WriteBuffer when done it has filled the buffer with data.*/ CPresult (*GetWriteBuffer)( CPhandle hContent, CPbyte **ppBuffer, CPuint nSize); /** Deliver a buffer obtained via GetWriteBuffer to the pipe. Pipe will write the the contents of the buffer to content and advance content pointer by the size of the buffer */ CPresult (*WriteBuffer)( CPhandle hContent, CPbyte *pBuffer, CPuint nFilledSize); /** Register a per-handle client callback with the content pipe. */ CPresult (*RegisterCallback)( CPhandle hContent, CPresult (*ClientCallback)(CP_EVENTTYPE eEvent, CPuint iParam)); } CP_PIPETYPE; #endif
db16078ec31ded2e589cac308ada6064d33b7f1d
7e41167bfae6d2c38689b7e0993b308e045cbd05
/file_cmds/mtree/excludes.c
89047711fc109132f9502975c6600e0e6262c21b
[ "BSD-3-Clause", "curl", "GPL-1.0-or-later", "MIT", "Python-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
holzschu/ios_system
7b18993dbcb33331c353e0257ca54847a5d1b1bb
6a83eb1c6c383a562fbe33a7e97677e88d305b51
refs/heads/master
2023-08-14T09:11:40.627903
2023-04-18T15:12:29
2023-04-18T15:12:29
113,187,304
882
155
BSD-3-Clause
2023-08-19T19:15:35
2017-12-05T13:42:50
C
UTF-8
C
false
false
3,095
c
excludes.c
/* * Copyright 2000 Massachusetts Institute of Technology * * Permission to use, copy, modify, and distribute this software and * its documentation for any purpose and without fee is hereby * granted, provided that both the above copyright notice and this * permission notice appear in all copies, that both the above * copyright notice and this permission notice appear in all * supporting documentation, and that the name of M.I.T. not be used * in advertising or publicity pertaining to distribution of the * software without specific, written prior permission. M.I.T. makes * no representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied * warranty. * * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/usr.sbin/mtree/excludes.c,v 1.8 2003/10/21 08:27:05 phk Exp $"); #include <sys/types.h> #include <sys/time.h> /* XXX for mtree.h */ #include <sys/queue.h> #include <err.h> #include <fnmatch.h> #include <fts.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include "mtree.h" /* XXX for extern.h */ #include "extern.h" /* * We're assuming that there won't be a whole lot of excludes, * so it's OK to use a stupid algorithm. */ struct exclude { LIST_ENTRY(exclude) link; const char *glob; int pathname; }; static LIST_HEAD(, exclude) excludes; void init_excludes(void) { LIST_INIT(&excludes); } void read_excludes_file(const char *name) { FILE *fp; char *line, *str; struct exclude *e; size_t len; fp = fopen(name, "r"); if (fp == 0) err(1, "%s", name); while ((line = fgetln(fp, &len)) != 0) { if (line[len - 1] == '\n') len--; if (len == 0) continue; str = malloc(len + 1); e = malloc(sizeof *e); if (str == 0 || e == 0) errx(1, "memory allocation error"); e->glob = str; memcpy(str, line, len); str[len] = '\0'; if (strchr(str, '/')) e->pathname = 1; else e->pathname = 0; LIST_INSERT_HEAD(&excludes, e, link); } fclose(fp); } int check_excludes(const char *fname, const char *path) { struct exclude *e; /* fnmatch(3) has a funny return value convention... */ #define MATCH(g, n) (fnmatch((g), (n), FNM_PATHNAME) == 0) LIST_FOREACH(e, &excludes, link) { if ((e->pathname && MATCH(e->glob, path)) || MATCH(e->glob, fname)) return 1; } return 0; }
c8b9d2378d52e320e3d871566d76debc3e42b348
ed7189bcb31973648dca4cb9f0d67cb4653d0e70
/tests/rtdl/scope2/test.c
f4f42dc57a04fc2861544088660bcdc8e5e01cae
[ "MIT" ]
permissive
managarm/mlibc
6dedaa86ed74f26a52e300d97f6e5949bac0f93c
74efefb5e9e546adab60a5730d95165334d7ee15
refs/heads/master
2023-09-01T05:17:26.709378
2023-08-29T08:33:01
2023-08-29T08:33:01
63,353,495
717
173
MIT
2023-09-10T10:55:53
2016-07-14T16:46:51
C
UTF-8
C
false
false
910
c
test.c
#include <stddef.h> #include <dlfcn.h> #include <assert.h> #include <string.h> #include <stdio.h> #ifdef USE_HOST_LIBC #define LIBBAR "libnative-bar.so" #define LIBBAZ "libnative-baz.so" #else #define LIBBAR "libbar.so" #define LIBBAZ "libbaz.so" #endif typedef char *strfn(void); int main() { void *baz = dlopen(LIBBAZ, RTLD_LAZY | RTLD_GLOBAL); assert(baz); // At this point, baz is loaded in the global scope. When we load bar locally, // there is a relocation to `foo_baz_conflict` which is defined in both // foo (which is a dependency of bar), and baz. In this case baz should win // since we search the global scope first. void *bar = dlopen(LIBBAR, RTLD_LAZY | RTLD_LOCAL); assert(bar); strfn *bfn = dlsym(bar, "bar_calls_foo_baz_conflict"); assert(!strcmp(bfn(), "resolved to baz")); // TODO: Test RTLD_DEEPBIND and DT_SYMBOLIC once we implement it. dlclose(bar); dlclose(baz); }
a1304764fc0d1bd2388563f2e02dac8bb1743f6a
0dd85c72c457ac317ecdde7dc40518f7be1a2602
/sdk/protocol/boatchainmaker_v2/boatchainmaker.c
0fcd981bfe636efd5f71919580162720019be1e6
[ "LicenseRef-scancode-unknown-license-reference", "Apache-2.0" ]
permissive
aitos-io/BoAT-X-Framework
00072acd6e570b8dda5c3e211103717110303915
92c09bd1ed269903b542b7b39a02137bb0b4f9be
refs/heads/master
2023-07-08T11:20:52.441231
2023-03-08T01:43:57
2023-03-08T01:43:57
249,309,472
2,165
141
Apache-2.0
2023-06-27T03:22:02
2020-03-23T01:39:16
C
UTF-8
C
false
false
7,603
c
boatchainmaker.c
/****************************************************************************** * Copyright (C) 2018-2021 aitos.io * * 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. *****************************************************************************/ /*!@brief Perform RAW transaction @file boatchainmaker.c contains functions to construct a raw transaction, perform it and wait for its receipt. */ /* self-header include */ #include "boatconfig.h" #include "boatchainmaker.h" #include "http2intf.h" #include "boatplatform_internal.h" #include "common/request.pb-c.h" #include "common/transaction.pb-c.h" BOAT_RESULT hlchainmakerTransactionPacked(BoatChainmakerTx *tx_ptr, BCHAR *method, BCHAR *contract_name, TxType tx_type, char *tx_id) { BUINT32 i; boat_try_declare; BOAT_RESULT result = BOAT_SUCCESS; Common__TxRequest common_tx_request = COMMON__TX_REQUEST__INIT; Common__KeyValuePair common_key_value_pair = COMMON__KEY_VALUE_PAIR__INIT; Common__ChainmakerPayload common_payload = COMMON__CHAINMAKER_PAYLOAD__INIT; Common__Limit common_limit = COMMON__LIMIT__INIT; Common__EndorsementEntry common_endorsement_entry = COMMON__ENDORSEMENT_ENTRY__INIT; Accesscontrol__Member accesscontrol_member = ACCESSCONTROL__MEMBER__INIT; BoatFieldVariable hash_data = {NULL, 0}; BoatSignatureResult signatureResult; BUINT8 grpcHeader[5]; BUINT8 hash_result[32]; BUINT32 packedLength; BUINT8 *packedData = NULL; /* step-0: param in check */ if ((tx_ptr == NULL) || (tx_ptr->wallet_ptr == NULL) || (tx_ptr->wallet_ptr->http2Context_ptr == NULL)) { BoatLog(BOAT_LOG_CRITICAL, "parameter should not be NULL."); return BOAT_ERROR_COMMON_INVALID_ARGUMENT; } /* step-1: payload data generate */ common_payload.chain_id = tx_ptr->wallet_ptr->network_info.chain_id; common_payload.tx_type = tx_type; common_payload.tx_id = tx_id; common_payload.timestamp = BoatGetTimes(); common_payload.contract_name = contract_name; common_payload.method = method; common_payload.sequence = 0; common_limit.gas_limit = tx_ptr->gas_limit; common_payload.limit = &common_limit; // Common__KeyValuePair parameters common_payload.n_parameters = tx_ptr->trans_para.n_parameters; common_payload.parameters = (Common__KeyValuePair **)BoatMalloc(sizeof(Common__KeyValuePair *) * tx_ptr->trans_para.n_parameters); if (common_payload.parameters == NULL) { BoatLog(BOAT_LOG_CRITICAL, "Fail parameters malloc"); boat_throw(BOAT_ERROR_COMMON_OUT_OF_MEMORY, chainmakerProposalTransactionPacked_exception); } for (i = 0; i < common_payload.n_parameters; i++) { Common__KeyValuePair *key_value_pair_ptr = BoatMalloc(sizeof(Common__KeyValuePair)); if (key_value_pair_ptr == NULL) { boat_throw(BOAT_ERROR_COMMON_OUT_OF_MEMORY, chainmakerProposalTransactionPacked_exception); } memcpy(key_value_pair_ptr, &common_key_value_pair, sizeof(Common__KeyValuePair)); key_value_pair_ptr->key = tx_ptr->trans_para.parameters[i].key; key_value_pair_ptr->value.len = tx_ptr->trans_para.parameters[i].value.field_len; key_value_pair_ptr->value.data = tx_ptr->trans_para.parameters[i].value.field_ptr; common_payload.parameters[i] = key_value_pair_ptr; } /* step-2: compute payload packed length */ packedLength = common__chainmaker_payload__get_packed_size(&common_payload); hash_data.field_ptr = BoatMalloc(packedLength); if (hash_data.field_ptr == NULL) { BoatLog(BOAT_LOG_NORMAL, "Failed to allocate memory."); return BOAT_ERROR_COMMON_OUT_OF_MEMORY; } hash_data.field_len = packedLength; common__chainmaker_payload__pack(&common_payload, hash_data.field_ptr); /* step-3: compute hash */ result = BoatHash(BOAT_HASH_SHA256, hash_data.field_ptr, hash_data.field_len, hash_result, NULL, NULL); if (result != BOAT_SUCCESS) { BoatLog(BOAT_LOG_CRITICAL, "Fail to exec BoatHash."); boat_throw(result, chainmakerProposalTransactionPacked_exception); } /* step-4: signature */ result = BoatSignature(tx_ptr->wallet_ptr->account_info.prikeyCtx, hash_result, sizeof(hash_result), &signatureResult, NULL); if (result != BOAT_SUCCESS) { BoatLog(BOAT_LOG_CRITICAL, "Fail to exec BoatSignature."); boat_throw(BOAT_ERROR_COMMON_GEN_SIGN_FAIL, chainmakerProposalTransactionPacked_exception); } if (!signatureResult.pkcs_format_used) { BoatLog(BOAT_LOG_CRITICAL, "Fail to find expect signature."); boat_throw(BOAT_ERROR_COMMON_GEN_SIGN_FAIL, chainmakerProposalTransactionPacked_exception); } /************************** sender start *************************/ accesscontrol_member.org_id = tx_ptr->wallet_ptr->network_info.org_id; accesscontrol_member.member_type = tx_ptr->wallet_ptr->network_info.client_member_type; accesscontrol_member.member_info.len = tx_ptr->wallet_ptr->network_info.client_sign_cert_content.length; accesscontrol_member.member_info.data = (uint8_t *)tx_ptr->wallet_ptr->network_info.client_sign_cert_content.content; common_endorsement_entry.signer = &accesscontrol_member; common_endorsement_entry.signature.len = signatureResult.pkcs_sign_length; common_endorsement_entry.signature.data = signatureResult.pkcs_sign; /* step-5: pack the envelope */ common_tx_request.payload = &common_payload; common_tx_request.sender = &common_endorsement_entry; packedLength = common__tx_request__get_packed_size(&common_tx_request); /* print chainmaker transaction message */ BoatLog(BOAT_LOG_VERBOSE, "Transaction Message tx_id = %s", tx_id); BoatLog(BOAT_LOG_VERBOSE, "Transaction Message time = %lld", common_payload.timestamp); for (i = 0; i < common_payload.n_parameters; i++) { BoatLog(BOAT_LOG_VERBOSE, "Transaction Message key = %s, value = %s", common_payload.parameters[i]->key, common_payload.parameters[i]->value.data); } /* step-6: packed length assignment */ ((http2IntfContext *)tx_ptr->wallet_ptr->http2Context_ptr)->sendBuf.field_len = packedLength + sizeof(grpcHeader); if (((http2IntfContext *)tx_ptr->wallet_ptr->http2Context_ptr)->sendBuf.field_len > BOAT_HLCHAINMAKER_HTTP2_SEND_BUF_MAX_LEN) { BoatLog(BOAT_LOG_CRITICAL, "packed length out of sendbuffer size limit."); } /* step-7: packed data assignment */ /* ---grpcHeader compute */ grpcHeader[0] = 0x00; // uncompressed for (int i = 0; i < 4; i++) { grpcHeader[i + 1] = (packedLength >> (32 - 8 * (i + 1))) & 0xFF; } /* ---generate packed data */ packedData = ((http2IntfContext *)tx_ptr->wallet_ptr->http2Context_ptr)->sendBuf.field_ptr; memcpy(packedData, grpcHeader, sizeof(grpcHeader)); common__tx_request__pack(&common_tx_request, &packedData[sizeof(grpcHeader)]); /* boat catch handle */ boat_catch(chainmakerProposalTransactionPacked_exception) { BoatLog(BOAT_LOG_CRITICAL, "Exception: %d", boat_exception); result = boat_exception; } /* free malloc */ if (common_payload.parameters != NULL) { for (i = 0; i < common_payload.n_parameters; i++) { if (common_payload.parameters[i] != NULL) { BoatFree(common_payload.parameters[i]); } } BoatFree(common_payload.parameters); } if (hash_data.field_ptr != NULL) { BoatFree(hash_data.field_ptr); } return result; }
1e02390bc449bd86c78a316c8fbeb6b4af336861
d579699e6728aa74084f8cc4dc435007b9f523a8
/data/signatures/posix/sys/shm.h
1b6489b51cdbf4f258bc1a119f6d36f20840d27a
[ "BSD-3-Clause" ]
permissive
BoomerangDecompiler/boomerang
b3c6b4e88c152ac6d437f3dd3640fd9ffa157cb6
411041305f90d1d7c994f67255b5c03ea8666e60
refs/heads/develop
2023-08-31T03:50:56.112711
2020-12-28T12:11:55
2020-12-28T17:38:56
7,819,729
281
41
NOASSERTION
2020-12-27T17:59:52
2013-01-25T12:26:59
C++
UTF-8
C
false
false
198
h
shm.h
void *shmat(int shmid, const void *shmaddr, int shmflg); int shmctl(int shmid, int cmd, struct shmid_ds *buf); int shmdt(const void *shmaddr); int shmget(key_t key, size_t size, int shmflg);
a45365f958716e6198ecebcede41c96516ce4634
aec185afb47e7b20615e5d9d872f3912137528f1
/dssl/ssl_decode_hs.c
83b4078e2d673f6c0b638707b61f90c639381722
[]
no_license
voipmonitor/sniffer
f5e15e70526c1fabe48d385fe5ec917b9eada62b
162d45491d2b110bdbadfc8a8ac6c44aa44493f0
refs/heads/master
2023-08-19T05:23:19.837497
2023-06-22T15:02:07
2023-06-22T15:02:07
18,056,680
204
99
null
2022-09-17T02:23:50
2014-03-24T08:57:35
C++
UTF-8
C
false
false
28,992
c
ssl_decode_hs.c
/* ** This file is a part of DSSL library. ** ** Copyright (C) 2005-2009, Atomic Labs, Inc. ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** */ #include "stdinc.h" #include <string.h> #include "ssl_session.h" #include "ssl_decode_hs.h" #if (OPENSSL_VERSION_NUMBER < 0x10100000L) #include "ssl2_decode_hs.h" #endif //(OPENSSL_VERSION_NUMBER < 0x10100000L) #include "decoder_stack.h" #include "packet.h" #include "ciphersuites.h" #include "tls-ext.h" #ifndef SSL3_MT_NEWSESSION_TICKET #define SSL3_MT_NEWSESSION_TICKET 4 #endif #ifdef NM_TRACE_SSL_HANDSHAKE static const char* SSL3_HandshakeTypeToString( int hs_type ) { switch(hs_type) { case SSL3_MT_HELLO_REQUEST: return "HelloRequest"; case SSL3_MT_CLIENT_HELLO: return "ClientHello"; case SSL3_MT_SERVER_HELLO: return "ServerHello"; case SSL3_MT_NEWSESSION_TICKET: return "NewSessionTicket (unsupported!)"; case SSL3_MT_CERTIFICATE: return "Certificate"; case SSL3_MT_SERVER_KEY_EXCHANGE: return "ServerKeyExchange"; case SSL3_MT_CERTIFICATE_REQUEST: return "CertificateRequest"; case SSL3_MT_SERVER_DONE: return "ServerHelloDone"; case SSL3_MT_CERTIFICATE_VERIFY: return "CertificateVerify"; case SSL3_MT_CLIENT_KEY_EXCHANGE: return "ClientKeyExchange"; case SSL3_MT_FINISHED: return "Finished"; case SSL3_MT_CERTIFICATE_STATUS: return "CertificateStatus"; case DTLS1_MT_HELLO_VERIFY_REQUEST: return "HelloVerifyRequest"; default: return "Unknown"; } } static const char* SSL3_ExtensionTypeToString( int ext_type ) { static char buff[64]; switch(ext_type) { case 0x0000: return "server_name"; case 0x000a: return "elliptic_curves"; case 0x000b: return "ec_point_format"; case 0x0023: return "Session Ticket TLS"; case 0x002b: return "supported_versions"; default: sprintf(buff, "Unknown (%x)", ext_type); return buff; } } #endif static int ssl3_decode_client_hello( DSSL_Session* sess, u_char* data, uint32_t len ) { u_char* org_data = data; int t_len = 0; /* record the handshake start time */ sess->handshake_start = sess->last_packet->pcap_header.ts; if( data[0] != 3 || data[1] > 3) return NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION ); /* 2 bytes client version */ sess->client_version = MAKE_UINT16( data[0], data[1] ); ssls_set_session_version( sess, MAKE_UINT16( data[0], data[1] ) ); data+= 2; /* make sure */ if( data + 32 > org_data + len ) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); /* 32 bytes ClientRandom */ memcpy( sess->client_random, data, 32 ); data+= 32; DEBUG_TRACE_BUF("client_random", sess->client_random, 32); if( !sess->ssl_si->pkeys && sess->get_keys_fce ) { sess->get_keys_fce(sess->client_random, &sess->get_keys_rslt_data, sess); if(sess->get_keys_rslt_data.set && sess->version != TLS1_3_VERSION && isSetKey(&sess->get_keys_rslt_data.client_random)) { memcpy(sess->master_secret, sess->get_keys_rslt_data.client_random.key, sess->get_keys_rslt_data.client_random.length); } } /* check session ID length */ if( data[0] > 32 ) return NM_ERROR( DSSL_E_SSL_PROTOCOL_ERROR ); if( data[0] > 0 ) { /* Session ID set */ if( data + data[0] > org_data + len ) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); memcpy( sess->session_id, data+1, data[0] ); sess->flags |= SSF_CLIENT_SESSION_ID_SET; data += data[0] + 1; } else { /* no Session ID */ sess->flags &= ~SSF_CLIENT_SESSION_ID_SET; ++data; } /* Cypher Suites */ if(data + 1 >= org_data + len) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); t_len = MAKE_UINT16(data[0], data[1]) + 2; /* cypher suites + cypher sute length size */ data += t_len; /* skip cypher suites */ /* Compression Method */ if(data >= org_data + len) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); if(data + data[0] + 1 > org_data + len) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); t_len = data[0] + 1; data += t_len; /* skip compression methods */ /* Extensions */ /* clear all previous extension fields */ ssls_free_extension_data(sess); if(data >= org_data + len) return DSSL_RC_OK; if(data + 2 > org_data + len) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); t_len = MAKE_UINT16(data[0], data[1]); data += 2; /* positon at the beginning of the first extension record, if any*/ while(t_len >= 4) { int ext_type = MAKE_UINT16(data[0], data[1]); /* extension type */ int ext_len = MAKE_UINT16(data[2], data[3]); #ifdef NM_TRACE_SSL_HANDSHAKE DEBUG_TRACE2( "\nSSL extension: %s len: %d", SSL3_ExtensionTypeToString( ext_type ), ext_len ); #endif /* TLS Session Ticket */ if( ext_type == 0x0023) { /* non empty ticket passed, store it */ if(ext_len > 0) { sess->flags |= SSF_TLS_SESSION_TICKET_SET; sess->session_ticket = (u_char*) malloc(ext_len); if(sess->session_ticket == NULL) return NM_ERROR(DSSL_E_OUT_OF_MEMORY); memcpy(sess->session_ticket, data+4, ext_len); sess->session_ticket_len = ext_len; } } if( ext_type == 0x0017) { sess->flags |= SSF_TLS_CLIENT_EXTENDED_MASTER_SECRET; } data += ext_len + 4; if(data > org_data + len) return NM_ERROR(DSSL_E_SSL_INVALID_RECORD_LENGTH); t_len -= ext_len + 4; } return DSSL_RC_OK; } static int ssl3_decode_server_hello( dssl_decoder_stack* stack, DSSL_Session* sess, u_char* data, uint32_t len ) { uint16_t server_version = 0; u_char* org_data = data; uint16_t session_id_len = 0; int session_id_match = 0; if( data[0] != 3 || data[1] > 3) return NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION ); if( len < SSL3_SERVER_HELLO_MIN_LEN ) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); /* Server Version */ server_version = MAKE_UINT16( data[0], data[1] ); if( sess->version == 0 || server_version < sess->version ) { ssls_set_session_version( sess, server_version ); } data+= 2; /* ServerRandom */ //_ASSERT_STATIC( sizeof(sess->server_random) == 32 ); memcpy( sess->server_random, data, sizeof( sess->server_random ) ); data+= 32; DEBUG_TRACE_BUF("server_random", sess->server_random, 32); /* session ID */ //_ASSERT_STATIC( sizeof(sess->session_id) == 32 ); session_id_len = data[0]; data++; if( session_id_len > 0 ) { if ( session_id_len > 32 ) return NM_ERROR( DSSL_E_SSL_PROTOCOL_ERROR ); if( !IS_ENOUGH_LENGTH( org_data, len, data, session_id_len ) ) { return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); } if( sess->flags & SSF_CLIENT_SESSION_ID_SET && memcmp( sess->session_id, data, session_id_len ) == 0 ) { session_id_match = 1; } else { sess->flags &= ~SSF_CLIENT_SESSION_ID_SET; memcpy( sess->session_id, data, session_id_len ); } data += session_id_len; } /* Cipher Suite and Compression */ if( !IS_ENOUGH_LENGTH( org_data, len, data, 3 ) ) { return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); } sess->cipher_suite = MAKE_UINT16( data[0], data[1] ); sess->compression_method = data[2]; data += 3; sess->flags &= ~SSF_TLS_SERVER_SESSION_TICKET; /* clear server side TLS Session Ticket flag */ /* Process SSL Extensions, if present */ if(IS_ENOUGH_LENGTH( org_data, len, data, 2 )) { int t_len = MAKE_UINT16(data[0], data[1]); data += 2; if(!IS_ENOUGH_LENGTH( org_data, len, data, t_len)) return NM_ERROR(DSSL_E_SSL_INVALID_RECORD_LENGTH); /* cycle through extension records */ while(t_len >= 4) { int ext_type = MAKE_UINT16(data[0], data[1]); /* extension type */ int ext_len = MAKE_UINT16(data[2], data[3]); #ifdef NM_TRACE_SSL_HANDSHAKE DEBUG_TRACE2( "\nSSL extension: %s len: %d", SSL3_ExtensionTypeToString( ext_type ), ext_len ); #endif /* TLS Session Ticket extension found, set the flag */ if( ext_type == 0x0023) { sess->flags |= SSF_TLS_SERVER_SESSION_TICKET; } if( ext_type == 0x0017) { sess->flags |= SSF_TLS_SERVER_EXTENDED_MASTER_SECRET; } if( ext_type == 0x002b) { if(ext_len == 2 && sess->version == TLS1_2_VERSION && MAKE_UINT16(data[4], data[5]) == TLS1_3_VERSION) sess->version = TLS1_3_VERSION; } if( ext_type == 0x0016) { sess->flags |= SSF_ENCRYPT_THEN_MAC; } data += ext_len + 4; if(data > org_data + len) return NM_ERROR(DSSL_E_SSL_INVALID_RECORD_LENGTH); t_len -= ext_len + 4; } } if( session_id_match ) { if( sess->flags & SSF_TLS_SESSION_TICKET_SET) { int rc = ssls_init_from_tls_ticket( sess ); if( NM_IS_FAILED( rc ) && !sess->get_keys_rslt_data.set ) return rc; } else { /* lookup session from the cache for stateful SSL renegotiation */ int rc = ssls_lookup_session( sess ); if( rc != DSSL_E_SSL_SESSION_NOT_IN_CACHE && NM_IS_FAILED( rc ) && !sess->get_keys_rslt_data.set ) return rc; } } else { if( sess->flags & SSF_TLS_SESSION_TICKET_SET ) { if( ssls_init_from_tls_ticket( sess ) == DSSL_RC_OK && ssls_generate_keys( sess ) == DSSL_RC_OK ) { return DSSL_RC_OK; } } } if( sess->flags & SSF_CLIENT_SESSION_ID_SET || sess->get_keys_rslt_data.set ) { if( sess->version == TLS1_3_VERSION ) { if( sess->get_keys_rslt_data.set && tls_13_generate_keys(sess, 0) ) { stack->state = SS_Established; } else { return DSSL_E_TLS_GENERATE_KEYS; } } else if( (sess->version == TLS1_2_VERSION || sess->version == TLS1_1_VERSION || sess->version == TLS1_VERSION) && sess->tls_12_sessionkey_via_ws && sess->get_keys_rslt_data.set ) { if( tls_12_generate_keys(sess, 0) ) { stack->state = SS_Established; } else { return DSSL_E_TLS_GENERATE_KEYS; } } else { int rc = ssls_generate_keys( sess ); if( NM_IS_FAILED( rc ) ) return rc; } } return DSSL_RC_OK; } /* First client_hello is a special case, because of SSL v2 compatibility */ int ssl_decode_first_client_hello( DSSL_Session* sess, u_char* data, uint32_t len, uint32_t* processed ) { int rc = DSSL_RC_OK; #if (OPENSSL_VERSION_NUMBER < 0x10100000L) if( data[0] & 0x80 && len >= 3 && data[2] == SSL2_MT_CLIENT_HELLO ) { int hdrLen = SSL20_CLIENT_HELLO_HDR_LEN; uint32_t recLen = len - hdrLen; rc = ssl2_decode_handshake( sess, ePacketDirFromClient, data + hdrLen, recLen, processed ); if( rc == DSSL_RC_OK ) { if( sess->version >= SSL3_VERSION && sess->version <= TLS1_2_VERSION ) { ssl3_init_handshake_digests( sess ); ssl3_update_handshake_digests( sess, data + hdrLen, recLen ); } *processed += hdrLen; } } else #endif //(OPENSSL_VERSION_NUMBER < 0x10100000L) if( data[0] == SSL3_RT_HANDSHAKE && len > 6 && data[1] == SSL3_VERSION_MAJOR && data[5] == SSL3_MT_CLIENT_HELLO ) { uint32_t recLen = 0; u_char* org_data; data += SSL3_HEADER_LEN; recLen = (((int32_t)data[1]) << 16) | (((int32_t)data[2]) << 8) | data[3]; org_data = data; data += SSL3_HANDSHAKE_HEADER_LEN; len -= SSL3_HANDSHAKE_HEADER_LEN; rc = ssl3_decode_client_hello( sess, data, recLen ); if( rc == DSSL_RC_OK ) { *processed = recLen + SSL3_HANDSHAKE_HEADER_LEN + SSL3_HEADER_LEN; ssl3_init_handshake_digests( sess ); ssl3_update_handshake_digests( sess, org_data, recLen + SSL3_HANDSHAKE_HEADER_LEN ); } } else { rc = NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION ); } return rc; } int ssl_detect_client_hello_version( u_char* data, uint32_t len, uint16_t* ver ) { int rc = DSSL_RC_OK; _ASSERT( ver != NULL ); _ASSERT( data != NULL ); /* SSL v2 header can be sent even by never clients */ if( data[0] & 0x80 && len >= 3 && data[2] == SSL2_MT_CLIENT_HELLO ) { *ver = MAKE_UINT16( data[3], data[4] ); } else if ( data[0] == SSL3_RT_HANDSHAKE && len > 11 && data[1] == SSL3_VERSION_MAJOR && data[5] == SSL3_MT_CLIENT_HELLO ) { uint16_t client_hello_ver = MAKE_UINT16( data[9], data[10] ); *ver = MAKE_UINT16( data[1], data[2] ); if( *ver > client_hello_ver ) rc = NM_ERROR( DSSL_E_SSL_PROTOCOL_ERROR ); } else { rc = NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION ); } return rc; } int ssl_detect_server_hello_version( u_char* data, uint32_t len, uint16_t* ver ) { int rc = DSSL_RC_OK; _ASSERT( ver != NULL ); _ASSERT( data != NULL ); #if (OPENSSL_VERSION_NUMBER < 0x10100000L) if( data[0] & 0x80 && len >= SSL20_SERVER_HELLO_MIN_LEN && data[2] == SSL2_MT_SERVER_HELLO ) { *ver = MAKE_UINT16( data[5], data[6] ); } else #endif //(OPENSSL_VERSION_NUMBER < 0x10100000L) if( data[0] == SSL3_RT_HANDSHAKE && len > 11 && data[1] == SSL3_VERSION_MAJOR && data[5] == SSL3_MT_SERVER_HELLO ) { uint16_t sever_hello_ver = MAKE_UINT16( data[9], data[10] ); *ver = MAKE_UINT16( data[1], data[2] ); if( *ver > sever_hello_ver ) rc = NM_ERROR( DSSL_E_SSL_PROTOCOL_ERROR ); } else if( data[0] == SSL3_RT_ALERT && len == 7 && data[1] == SSL3_VERSION_MAJOR && MAKE_UINT16( data[3], data[4] ) == 2 ) { /* this is an SSL3 Alert message - the server didn't like this session */ *ver = MAKE_UINT16( data[1], data[2] ); } else { rc = NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION ); } return rc; } /* ========= ClientKeyExchange ========= */ int ssl3_decode_client_key_exchange( DSSL_Session* sess, u_char* data, uint32_t len ) { EVP_PKEY *pk = NULL; u_char* org_data = data; uint32_t org_len = len; int pms_len = 0; int rc = DSSL_RC_OK; if( sess->version < SSL3_VERSION || sess->version > TLS1_2_VERSION ) { return NM_ERROR( DSSL_E_SSL_UNKNOWN_VERSION ); } /* TLS is different as it sends the record length, while SSL3 implementaions don't (due to a bug in Netscape implementation) */ if( !isSetMasterSecret(sess->master_secret) ) { if( sess->version > SSL3_VERSION ) { uint16_t recLen = 0; if( !IS_ENOUGH_LENGTH( org_data, org_len, data, 2 ) ) { return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); } recLen = MAKE_UINT16( data[0], data[1] ); if( len != (uint32_t)recLen + 2 ) { /*TODO: set an option to tolerate this bug?*/ return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); } /* advance */ data += len - recLen; len = recLen; } if( !IS_ENOUGH_LENGTH( org_data, org_len, data, SSL_MAX_MASTER_KEY_LENGTH ) ) { return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); } } if( sess->ssl_si->pkeys && !isSetMasterSecret(sess->master_secret) ) { if( sess->ssl_si->pkeys && sess->ssl_si->pkeys_index_ok > 0 && sess->ssl_si->pkeys_index_ok <= sess->ssl_si->pkeys_count) { pk = sess->ssl_si->pkeys[ sess->ssl_si->pkeys_index_ok - 1 ]; } /* if SSL server key is not found, try to find a matching one from the key pool */ if(pk == NULL && sess->last_packet) { // _ASSERT( sess->last_packet); if(sess->env && sess->env->key_count) { pk = ssls_try_ssl_keys( sess, data, len ); /* if a matching key found, register it with the server IP:port */ if(pk != NULL && sess->last_packet->ip_header) { if( ssls_register_ssl_key( sess, pk ) == DSSL_RC_OK) { /* ssls_register_ssl_key clones the key, query the key back */ if( sess->ssl_si->pkeys ) { if( sess->ssl_si->pkeys_index_ok > 0 && sess->ssl_si->pkeys_index_ok <= sess->ssl_si->pkeys_count) { pk = sess->ssl_si->pkeys[ sess->ssl_si->pkeys_index_ok - 1 ]; } else if( sess->ssl_si->pkeys_index_ok == 0 && sess->ssl_si->pkeys_count == 1) { pk = sess->ssl_si->pkeys[ sess->ssl_si->pkeys_index_ok ]; } } } else { pk = NULL; } } } } if(!pk) { if(sess->last_packet && sess->last_packet->ip_header) { ssls_register_missing_key_server( sess ); } return NM_ERROR( DSSL_E_SSL_SERVER_KEY_UNKNOWN ); } if(EVP_PKEY_id( pk ) != EVP_PKEY_RSA) return NM_ERROR( DSSL_E_SSL_CANNOT_DECRYPT_NON_RSA ); pms_len = RSA_private_decrypt( len, data, sess->PMS, EVP_PKEY_get0_RSA( pk ), RSA_PKCS1_PADDING ); if( pms_len != SSL_MAX_MASTER_KEY_LENGTH ) { return NM_ERROR( DSSL_E_SSL_CORRUPTED_PMS ); } if( MAKE_UINT16( sess->PMS[0], sess->PMS[1] ) != sess->client_version ) { return NM_ERROR( DSSL_E_SSL_PMS_VERSION_ROLLBACK ); } rc = ssls_decode_master_secret( sess ); OPENSSL_cleanse(sess->PMS, sizeof(sess->PMS) ); } if( rc != DSSL_RC_OK ) return rc; if( !sess->tls_session ) { rc = ssls_generate_keys( sess ); } if( rc == DSSL_RC_OK ) { ssls_store_session( sess ); } return rc; } static int ssl3_decode_dummy( DSSL_Session* sess, u_char* data, uint32_t len ) { //UNUSED_PARAM( sess ); //UNUSED_PARAM( data ); //UNUSED_PARAM( len ); return DSSL_RC_OK; } /* ========== Server Certificate ========== */ static int ssl3_decode_server_certificate( DSSL_Session* sess, u_char* data, uint32_t len ) { X509 *x=NULL; uint32_t llen = 0; int rc = DSSL_RC_OK; if( !sess ) return NM_ERROR( DSSL_E_INVALID_PARAMETER ); /* TBD: skip server certificate check if SSL key has not yet been mapped for this server */ if( !sess->ssl_si ) return DSSL_RC_OK; if( !sess->ssl_si->pkeys && !sess->master_secret[0]) return NM_ERROR( DSSL_E_UNINITIALIZED_ARGUMENT ); if( len < 3 ) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); llen = MAKE_UINT24( data[0], data[1], data[2] ); data+=3; if( llen + 3 != len || llen < 3 ) return NM_ERROR( DSSL_E_SSL_INVALID_CERTIFICATE_RECORD ); llen = MAKE_UINT24( data[0], data[1], data[2] ); data+=3; if( llen > len ) return NM_ERROR( DSSL_E_SSL_INVALID_CERTIFICATE_LENGTH ); if( sess->ssl_si->pkeys && !sess->master_secret[0] ) { x = d2i_X509( NULL, (const u_char**)&data, llen ); if( !x ) { rc = NM_ERROR( DSSL_E_SSL_BAD_CERTIFICATE ); } if( rc == DSSL_RC_OK ) { sess->ssl_si->pkeys_index_ok = 0; uint8_t pkeys_index; for(pkeys_index = 0; pkeys_index < sess->ssl_si->pkeys_count; pkeys_index++) { if( X509_check_private_key(x, sess->ssl_si->pkeys[pkeys_index]) ) { sess->ssl_si->pkeys_index_ok = pkeys_index + 1; break; } else if( pkeys_index == sess->ssl_si->pkeys_count - 1 ) { rc = NM_ERROR( DSSL_E_SSL_CERTIFICATE_KEY_MISMATCH ); } } } if( x ) X509_free( x ); } return rc; } static int ssl3_decode_new_session_ticket(DSSL_Session* sess, u_char* data, uint32_t len ) { uint16_t sz = 0; if(len < 6) return NM_ERROR(DSSL_E_SSL_INVALID_RECORD_LENGTH); sz = MAKE_UINT16(data[4], data[5]); if(len != sz + 6) return NM_ERROR(DSSL_E_SSL_PROTOCOL_ERROR); return ssls_store_new_ticket( sess, data + 6, sz ); } /* ========== Finished, handshake digest routines ========== */ int ssl3_init_handshake_digests( DSSL_Session* sess ) { EVP_DigestInit_ex( sess->handshake_digest_md5, EVP_md5(), NULL ); EVP_DigestInit_ex( sess->handshake_digest_sha, EVP_sha1(), NULL ); if ( sess->version >= TLS1_2_VERSION ) { EVP_MD* digest = NULL; DSSL_CipherSuite* suite = sess->dssl_cipher_suite; if ( !suite ) suite = DSSL_GetSSL3CipherSuite( sess->cipher_suite ); if ( !suite ) { if( sess->get_keys_rslt_data.set && (sess->version == TLS1_3_VERSION || ((sess->version == TLS1_2_VERSION || sess->version == TLS1_1_VERSION || sess->version == TLS1_VERSION) && sess->tls_12_sessionkey_via_ws)) ) { return DSSL_RC_OK; } else { return DSSL_E_UNKNOWN_CIPHER_SUITE; } } digest = (EVP_MD*)EVP_get_digestbyname( suite->digest ); /* 'sha256' is the default for TLS 1.2 */ if ( !digest ) digest = (EVP_MD*)EVP_sha256(); if ( digest ) EVP_DigestInit_ex( sess->handshake_digest, digest, NULL ); } return DSSL_RC_OK; } int ssl3_update_handshake_digests( DSSL_Session* sess, u_char* data, uint32_t len ) { DSSL_handshake_buffer *q = NULL, *next; /* sanity check in case client hello is not received */ if( EVP_MD_CTX_md( sess->handshake_digest_md5 ) == NULL || EVP_MD_CTX_md( sess->handshake_digest_sha ) == NULL) { ssl3_init_handshake_digests( sess ); } EVP_DigestUpdate( sess->handshake_digest_md5, data, len ); EVP_DigestUpdate( sess->handshake_digest_sha, data, len ); if ( sess->version >= TLS1_2_VERSION ) { /* if digest is still unknown, then queue the packets. * we'll calculate the handshake hash once we determine which digest we should use. */ EVP_MD* digest = NULL; DSSL_CipherSuite* suite = sess->dssl_cipher_suite; if ( !suite ) { suite = DSSL_GetSSL3CipherSuite( sess->cipher_suite ); if( !suite ) { if( sess->get_keys_rslt_data.set && (sess->version == TLS1_3_VERSION || ((sess->version == TLS1_2_VERSION || sess->version == TLS1_1_VERSION || sess->version == TLS1_VERSION) && sess->tls_12_sessionkey_via_ws)) ) { return DSSL_RC_OK; } else { return DSSL_E_UNKNOWN_CIPHER_SUITE; } } } digest = (EVP_MD*)EVP_get_digestbyname( suite->digest ); /* 'sha256' is the default for TLS 1.2, and can be replaced with a different (but stronger) hash */ if ( !digest ) { q = (DSSL_handshake_buffer*) malloc( sizeof(DSSL_handshake_buffer) ); q->next = NULL; q->data = (u_char*) malloc( len ); memcpy(q->data, data, len); q->len = len; if (NULL == sess->handshake_queue) sess->handshake_queue = q; else sess->handshake_queue->next = q; DEBUG_TRACE3( "Queue handshake packet %p (%u @ %p)", q, q->len, q->data ); } else if ( digest != EVP_MD_CTX_md( sess->handshake_digest ) && EVP_MD_size( digest ) >= EVP_MD_size( EVP_MD_CTX_md( sess->handshake_digest ) ) ) { /* specified digest is different than the default. * re-init and re-hash all queued packets. */ EVP_MD_CTX_reset( sess->handshake_digest ); EVP_DigestInit_ex( sess->handshake_digest, digest, NULL ); for (q = sess->handshake_queue; q != NULL; q = next) { DEBUG_TRACE3( "Re-hash handshake packet %p (%u @ %p)", q, q->len, q->data ); EVP_DigestUpdate( sess->handshake_digest, q->data, q->len ); next = q->next; free ( q->data ); free ( q ); } sess->handshake_queue = NULL; } else { /* specified digest is identical to the default. * throw away all the queued packets. */ for (q = sess->handshake_queue; q != NULL; q = next) { DEBUG_TRACE3( "discard handshake packet %p (%u @ %p)", q, q->len, q->data ); next = q->next; free ( q->data ); free ( q ); } sess->handshake_queue = NULL; } if ( EVP_MD_CTX_md( sess->handshake_digest ) ) EVP_DigestUpdate( sess->handshake_digest, data, len ); } return(DSSL_RC_OK); } /* ========== Handshake decoding function ========== */ int ssl3_decode_handshake_record( dssl_decoder_stack* stack, NM_PacketDir dir, u_char* data, uint32_t len, uint32_t* processed ) { int rc = DSSL_E_UNSPECIFIED_ERROR; uint32_t recLen = 0; u_char hs_type = 0; u_char* org_data = data; DSSL_Session* sess = stack->sess; _ASSERT( processed != NULL ); _ASSERT((sess->flags & SSF_SSLV2_CHALLENGE) == 0); if( sess->version == 0 ) { return ssl_decode_first_client_hello( sess, data, len, processed ); } if( len < SSL3_HANDSHAKE_HEADER_LEN ) return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); DEBUG_TRACE_BUF("handshake", data, len); recLen = (((int32_t)data[1]) << 16) | (((int32_t)data[2]) << 8) | data[3]; hs_type = data[0]; if(!recLen && !hs_type) { *processed = len; return DSSL_RC_OK; } data += SSL3_HANDSHAKE_HEADER_LEN; len -= SSL3_HANDSHAKE_HEADER_LEN; if( len < recLen )return NM_ERROR( DSSL_E_SSL_INVALID_RECORD_LENGTH ); #ifdef NM_TRACE_SSL_HANDSHAKE DEBUG_TRACE2( "===>Decoding SSL v3 handshake: %s len: %d...", SSL3_HandshakeTypeToString( hs_type ), (int) recLen ); #endif if(stack->sess->handshake_data && (stack->sess->flags & (SSF_TLS_CLIENT_EXTENDED_MASTER_SECRET|SSF_TLS_SERVER_EXTENDED_MASTER_SECRET)) && hs_type != SSL3_MT_CERTIFICATE_VERIFY) { ssls_handshake_data_append(sess, data - SSL3_HANDSHAKE_HEADER_LEN, recLen + SSL3_HANDSHAKE_HEADER_LEN); } switch( hs_type ) { case SSL3_MT_HELLO_REQUEST: rc = ssl3_decode_dummy( sess, data, recLen ); break; case SSL3_MT_CLIENT_HELLO: rc = ssl3_decode_client_hello( sess, data, recLen ); break; case SSL3_MT_SERVER_HELLO: stack->state = SS_SeenServerHello; rc = ssl3_decode_server_hello( stack, sess, data, recLen ); break; case SSL3_MT_CERTIFICATE: if( sess->get_keys_rslt_data.set && (sess->version == TLS1_3_VERSION || ((sess->version == TLS1_2_VERSION || sess->version == TLS1_1_VERSION || sess->version == TLS1_VERSION) && sess->tls_12_sessionkey_via_ws)) ) { rc = ssl3_decode_dummy( sess, data, recLen ); } else if( dir == ePacketDirFromServer ) { rc = ssl3_decode_server_certificate( sess, data, recLen ); } else { rc = ssl3_decode_dummy( sess, data, recLen ); } break; case SSL3_MT_SERVER_DONE: rc = ssl3_decode_dummy( sess, data, recLen ); break; case SSL3_MT_CLIENT_KEY_EXCHANGE: if( sess->get_keys_rslt_data.set && (sess->version == TLS1_3_VERSION || ((sess->version == TLS1_2_VERSION || sess->version == TLS1_1_VERSION || sess->version == TLS1_VERSION) && sess->tls_12_sessionkey_via_ws)) ) { rc = ssl3_decode_dummy( sess, data, recLen ); } else { rc = ssl3_decode_client_key_exchange( sess, data, recLen ); } break; case SSL3_MT_FINISHED: rc = (*sess->decode_finished_proc)( sess, dir, data, recLen ); if( rc == DSSL_RC_OK ) { stack->state = SS_Established; ssls_handshake_done( sess ); } break; case SSL3_MT_CERTIFICATE_STATUS: rc = ssl3_decode_dummy( sess, data, recLen ); break; case SSL3_MT_SERVER_KEY_EXCHANGE: /*at this point it is clear that the session is not decryptable due to ephemeral keys usage.*/ if( isSetMasterSecret(sess->master_secret) || (sess->get_keys_rslt_data.set && (sess->version == TLS1_3_VERSION || ((sess->version == TLS1_2_VERSION || sess->version == TLS1_1_VERSION || sess->version == TLS1_VERSION) && sess->tls_12_sessionkey_via_ws))) ) { rc = ssl3_decode_dummy( sess, data, recLen ); } else { rc = NM_ERROR( DSSL_E_SSL_CANNOT_DECRYPT_EPHEMERAL ); } break; case SSL3_MT_CERTIFICATE_REQUEST: /* TODO: track CertificateRequest- client certificate / certificate verify */ rc = ssl3_decode_dummy( sess, data, recLen ); break; case SSL3_MT_CERTIFICATE_VERIFY: /* TODO: track CertificateRequest- client certificate / certificate verify */ rc = ssl3_decode_dummy( sess, data, recLen ); break; case SSL3_MT_NEWSESSION_TICKET: rc = ssl3_decode_new_session_ticket( sess, data, recLen ); break; default: rc = NM_ERROR( DSSL_E_SSL_PROTOCOL_ERROR ); break; } if( rc == DSSL_RC_OK ) { *processed = recLen + SSL3_HANDSHAKE_HEADER_LEN; if( hs_type == SSL3_MT_CLIENT_HELLO ) { ssl3_init_handshake_digests( sess ); } if( hs_type != SSL3_MT_HELLO_REQUEST ) { rc = ssl3_update_handshake_digests( sess, org_data, *processed ); } } #ifdef NM_TRACE_SSL_HANDSHAKE if( rc == DSSL_RC_OK ) { DEBUG_TRACE0( "OK\n" ); } else { DEBUG_TRACE1( "Error! (%d)\n", (int)rc ); } #endif return rc; } void ssls_handshake_done( DSSL_Session* sess ) { /* at this point we can safely conclude that the SSL key is working fine, so clear the 'test key' flag, if set */ if(sess->flags & SSF_TEST_SSL_KEY && sess->c_dec.state == SS_Established && sess->s_dec.state == SS_Established) { sess->flags &= ~SSF_TEST_SSL_KEY; _ASSERT(sess->ssl_si); if(sess->event_callback && sess->ssl_si) { (*sess->event_callback)( sess->user_data, eSslMappingDiscovered, sess->ssl_si ); } } if( sess->event_callback && sess->c_dec.state == SS_Established && sess->s_dec.state == SS_Established ) { struct timeval t = sess->last_packet->pcap_header.ts; t.tv_sec -= sess->handshake_start.tv_sec; if(t.tv_usec < sess->handshake_start.tv_usec) { --t.tv_sec; t.tv_usec = t.tv_usec + 1000000 - sess->handshake_start.tv_usec; } else { t.tv_usec -= sess->handshake_start.tv_usec; } (*sess->event_callback)( sess->user_data, eSslHandshakeComplete, &t ); } if(sess->handshake_data) { ssls_handshake_data_free(sess); } } u_int8_t ssl3_handshake_record_is_ok_plain( u_char* data, uint32_t len ) { if( len < 4 ) { return 0; } uint32_t recLen = 0; u_char hs_type = 0; recLen = (((int32_t)data[1]) << 16) | (((int32_t)data[2]) << 8) | data[3]; hs_type = data[0]; if(!recLen && !hs_type) { return 0; } len -= SSL3_HANDSHAKE_HEADER_LEN; if( len < recLen ) { return 0; } return 1; }
b04f48c24773a7e67d77291ffdd5e8795c056ec0
07327b5e8b2831b12352bf7c6426bfda60129da7
/Include/10.0.16299.0/um/recdefs.h
83f71136373869b0957986b970ace9cb16a37b1f
[]
no_license
tpn/winsdk-10
ca279df0fce03f92036e90fb04196d6282a264b7
9b69fd26ac0c7d0b83d378dba01080e93349c2ed
refs/heads/master
2021-01-10T01:56:18.586459
2018-02-19T21:26:31
2018-02-19T21:29:50
44,352,845
218
432
null
null
null
null
UTF-8
C
false
false
15,780
h
recdefs.h
//-------------------------------------------------------------------------- // This is part of the Microsoft Tablet PC Platform SDK // Copyright (C) 2002 Microsoft Corporation // All rights reserved. // // // Module: // RecDefs.h // //-------------------------------------------------------------------------- #ifndef __INC_RECDEFS_H #define __INC_RECDEFS_H #include <winapifamily.h> #pragma region Desktop Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) // RECO FLAGS #define RECOFLAG_WORDMODE 0x00000001 #define RECOFLAG_COERCE 0x00000002 #define RECOFLAG_SINGLESEG 0x00000004 #define RECOFLAG_PREFIXOK 0x00000008 #define RECOFLAG_LINEMODE 0x00000010 #define RECOFLAG_DISABLEPERSONALIZATION 0x00000020 #define RECOFLAG_AUTOSPACE 0x00000040 // Confidence constants #define RECOCONF_LOWCONFIDENCE -1 #define RECOCONF_MEDIUMCONFIDENCE 0 #define RECOCONF_HIGHCONFIDENCE 1 #define RECOCONF_NOTSET 128 // Gesture ids #define GESTURE_NULL 0xf000 #define GESTURE_SCRATCHOUT 0xf001 #define GESTURE_TRIANGLE 0xf002 #define GESTURE_SQUARE 0xf003 #define GESTURE_STAR 0xf004 #define GESTURE_CHECK 0xf005 #define GESTURE_INFINITY 0xf006 #define GESTURE_CROSS 0xf007 #define GESTURE_PARAGRAPH 0xf008 #define GESTURE_SECTION 0xf009 #define GESTURE_BULLET 0xf00a #define GESTURE_BULLET_CROSS 0xf00b #define GESTURE_SQUIGGLE 0xf00c #define GESTURE_SWAP 0xf00d #define GESTURE_OPENUP 0xf00e #define GESTURE_CLOSEUP 0xf00f #define GESTURE_CURLICUE 0xf010 #define GESTURE_DOUBLE_CURLICUE 0xf011 #define GESTURE_RECTANGLE 0xf012 #define GESTURE_CIRCLE 0xf020 #define GESTURE_DOUBLE_CIRCLE 0xf021 #define GESTURE_CIRCLE_TAP 0xf022 #define GESTURE_CIRCLE_CIRCLE 0xf023 #define GESTURE_CIRCLE_CROSS 0xf025 #define GESTURE_CIRCLE_LINE_VERT 0xf026 #define GESTURE_CIRCLE_LINE_HORZ 0xf027 #define GESTURE_SEMICIRCLE_LEFT 0xf028 #define GESTURE_SEMICIRCLE_RIGHT 0xf029 #define GESTURE_CHEVRON_UP 0xf030 #define GESTURE_CHEVRON_DOWN 0xf031 #define GESTURE_CHEVRON_LEFT 0xf032 #define GESTURE_CHEVRON_RIGHT 0xf033 #define GESTURE_ARROW_UP 0xf038 #define GESTURE_ARROW_DOWN 0xf039 #define GESTURE_ARROW_LEFT 0xf03a #define GESTURE_ARROW_RIGHT 0xf03b #define GESTURE_DOUBLE_ARROW_UP 0xf03c #define GESTURE_DOUBLE_ARROW_DOWN 0xf03d #define GESTURE_DOUBLE_ARROW_LEFT 0xf03e #define GESTURE_DOUBLE_ARROW_RIGHT 0xf03f #define GESTURE_UP_ARROW_LEFT 0xf040 #define GESTURE_UP_ARROW_RIGHT 0xf041 #define GESTURE_DOWN_ARROW_LEFT 0xf042 #define GESTURE_DOWN_ARROW_RIGHT 0xf043 #define GESTURE_LEFT_ARROW_UP 0xf044 #define GESTURE_LEFT_ARROW_DOWN 0xf045 #define GESTURE_RIGHT_ARROW_UP 0xf046 #define GESTURE_RIGHT_ARROW_DOWN 0xf047 #define GESTURE_UP 0xf058 #define GESTURE_DOWN 0xf059 #define GESTURE_LEFT 0xf05a #define GESTURE_RIGHT 0xf05b #define GESTURE_DIAGONAL_LEFTUP 0xf05c #define GESTURE_DIAGONAL_RIGHTUP 0xf05d #define GESTURE_DIAGONAL_LEFTDOWN 0xf05e #define GESTURE_DIAGONAL_RIGHTDOWN 0xf05f #define GESTURE_UP_DOWN 0xf060 #define GESTURE_DOWN_UP 0xf061 #define GESTURE_LEFT_RIGHT 0xf062 #define GESTURE_RIGHT_LEFT 0xf063 #define GESTURE_UP_LEFT_LONG 0xf064 #define GESTURE_UP_RIGHT_LONG 0xf065 #define GESTURE_DOWN_LEFT_LONG 0xf066 #define GESTURE_DOWN_RIGHT_LONG 0xf067 #define GESTURE_UP_LEFT 0xf068 #define GESTURE_UP_RIGHT 0xf069 #define GESTURE_DOWN_LEFT 0xf06a #define GESTURE_DOWN_RIGHT 0xf06b #define GESTURE_LEFT_UP 0xf06c #define GESTURE_LEFT_DOWN 0xf06d #define GESTURE_RIGHT_UP 0xf06e #define GESTURE_RIGHT_DOWN 0xf06f #define GESTURE_LETTER_A 0xf080 #define GESTURE_LETTER_B 0xf081 #define GESTURE_LETTER_C 0xf082 #define GESTURE_LETTER_D 0xf083 #define GESTURE_LETTER_E 0xf084 #define GESTURE_LETTER_F 0xf085 #define GESTURE_LETTER_G 0xf086 #define GESTURE_LETTER_H 0xf087 #define GESTURE_LETTER_I 0xf088 #define GESTURE_LETTER_J 0xf089 #define GESTURE_LETTER_K 0xf08a #define GESTURE_LETTER_L 0xf08b #define GESTURE_LETTER_M 0xf08c #define GESTURE_LETTER_N 0xf08d #define GESTURE_LETTER_O 0xf08e #define GESTURE_LETTER_P 0xf08f #define GESTURE_LETTER_Q 0xf090 #define GESTURE_LETTER_R 0xf091 #define GESTURE_LETTER_S 0xf092 #define GESTURE_LETTER_T 0xf093 #define GESTURE_LETTER_U 0xf094 #define GESTURE_LETTER_V 0xf095 #define GESTURE_LETTER_W 0xf096 #define GESTURE_LETTER_X 0xf097 #define GESTURE_LETTER_Y 0xf098 #define GESTURE_LETTER_Z 0xf099 #define GESTURE_DIGIT_0 0xf09a #define GESTURE_DIGIT_1 0xf09b #define GESTURE_DIGIT_2 0xf09c #define GESTURE_DIGIT_3 0xf09d #define GESTURE_DIGIT_4 0xf09e #define GESTURE_DIGIT_5 0xf09f #define GESTURE_DIGIT_6 0xf0a0 #define GESTURE_DIGIT_7 0xf0a1 #define GESTURE_DIGIT_8 0xf0a2 #define GESTURE_DIGIT_9 0xf0a3 #define GESTURE_EXCLAMATION 0xf0a4 #define GESTURE_QUESTION 0xf0a5 #define GESTURE_SHARP 0xf0a6 #define GESTURE_DOLLAR 0xf0a7 #define GESTURE_ASTERISK 0xf0a8 #define GESTURE_PLUS 0xf0a9 #define GESTURE_DOUBLE_UP 0xf0b8 #define GESTURE_DOUBLE_DOWN 0xf0b9 #define GESTURE_DOUBLE_LEFT 0xf0ba #define GESTURE_DOUBLE_RIGHT 0xf0bb #define GESTURE_TRIPLE_UP 0xf0bc #define GESTURE_TRIPLE_DOWN 0xf0bd #define GESTURE_TRIPLE_LEFT 0xf0be #define GESTURE_TRIPLE_RIGHT 0xf0bf #define GESTURE_BRACKET_OVER 0xf0e4 #define GESTURE_BRACKET_UNDER 0xf0e5 #define GESTURE_BRACKET_LEFT 0xf0e6 #define GESTURE_BRACKET_RIGHT 0xf0e7 #define GESTURE_BRACE_OVER 0xf0e8 #define GESTURE_BRACE_UNDER 0xf0e9 #define GESTURE_BRACE_LEFT 0xf0ea #define GESTURE_BRACE_RIGHT 0xf0eb #define GESTURE_TAP 0xf0f0 #define GESTURE_DOUBLE_TAP 0xf0f1 #define GESTURE_TRIPLE_TAP 0xf0f2 #define GESTURE_QUAD_TAP 0xf0f3 #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */ #pragma endregion #pragma region App Family #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) // RECO FLAGS #define RECOFLAG_WORDMODE 0x00000001 #define RECOFLAG_COERCE 0x00000002 #define RECOFLAG_SINGLESEG 0x00000004 #define RECOFLAG_PREFIXOK 0x00000008 #define RECOFLAG_LINEMODE 0x00000010 #define RECOFLAG_DISABLEPERSONALIZATION 0x00000020 #define RECOFLAG_AUTOSPACE 0x00000040 // Confidence constants #define RECOCONF_LOWCONFIDENCE -1 #define RECOCONF_MEDIUMCONFIDENCE 0 #define RECOCONF_HIGHCONFIDENCE 1 #define RECOCONF_NOTSET 128 // Gesture ids #define GESTURE_NULL 0xf000 #define GESTURE_SCRATCHOUT 0xf001 #define GESTURE_TRIANGLE 0xf002 #define GESTURE_SQUARE 0xf003 #define GESTURE_STAR 0xf004 #define GESTURE_CHECK 0xf005 #define GESTURE_INFINITY 0xf006 #define GESTURE_CROSS 0xf007 #define GESTURE_PARAGRAPH 0xf008 #define GESTURE_SECTION 0xf009 #define GESTURE_BULLET 0xf00a #define GESTURE_BULLET_CROSS 0xf00b #define GESTURE_SQUIGGLE 0xf00c #define GESTURE_SWAP 0xf00d #define GESTURE_OPENUP 0xf00e #define GESTURE_CLOSEUP 0xf00f #define GESTURE_CURLICUE 0xf010 #define GESTURE_DOUBLE_CURLICUE 0xf011 #define GESTURE_RECTANGLE 0xf012 #define GESTURE_CIRCLE 0xf020 #define GESTURE_DOUBLE_CIRCLE 0xf021 #define GESTURE_CIRCLE_TAP 0xf022 #define GESTURE_CIRCLE_CIRCLE 0xf023 #define GESTURE_CIRCLE_CROSS 0xf025 #define GESTURE_CIRCLE_LINE_VERT 0xf026 #define GESTURE_CIRCLE_LINE_HORZ 0xf027 #define GESTURE_SEMICIRCLE_LEFT 0xf028 #define GESTURE_SEMICIRCLE_RIGHT 0xf029 #define GESTURE_CHEVRON_UP 0xf030 #define GESTURE_CHEVRON_DOWN 0xf031 #define GESTURE_CHEVRON_LEFT 0xf032 #define GESTURE_CHEVRON_RIGHT 0xf033 #define GESTURE_ARROW_UP 0xf038 #define GESTURE_ARROW_DOWN 0xf039 #define GESTURE_ARROW_LEFT 0xf03a #define GESTURE_ARROW_RIGHT 0xf03b #define GESTURE_DOUBLE_ARROW_UP 0xf03c #define GESTURE_DOUBLE_ARROW_DOWN 0xf03d #define GESTURE_DOUBLE_ARROW_LEFT 0xf03e #define GESTURE_DOUBLE_ARROW_RIGHT 0xf03f #define GESTURE_UP_ARROW_LEFT 0xf040 #define GESTURE_UP_ARROW_RIGHT 0xf041 #define GESTURE_DOWN_ARROW_LEFT 0xf042 #define GESTURE_DOWN_ARROW_RIGHT 0xf043 #define GESTURE_LEFT_ARROW_UP 0xf044 #define GESTURE_LEFT_ARROW_DOWN 0xf045 #define GESTURE_RIGHT_ARROW_UP 0xf046 #define GESTURE_RIGHT_ARROW_DOWN 0xf047 #define GESTURE_UP 0xf058 #define GESTURE_DOWN 0xf059 #define GESTURE_LEFT 0xf05a #define GESTURE_RIGHT 0xf05b #define GESTURE_DIAGONAL_LEFTUP 0xf05c #define GESTURE_DIAGONAL_RIGHTUP 0xf05d #define GESTURE_DIAGONAL_LEFTDOWN 0xf05e #define GESTURE_DIAGONAL_RIGHTDOWN 0xf05f #define GESTURE_UP_DOWN 0xf060 #define GESTURE_DOWN_UP 0xf061 #define GESTURE_LEFT_RIGHT 0xf062 #define GESTURE_RIGHT_LEFT 0xf063 #define GESTURE_UP_LEFT_LONG 0xf064 #define GESTURE_UP_RIGHT_LONG 0xf065 #define GESTURE_DOWN_LEFT_LONG 0xf066 #define GESTURE_DOWN_RIGHT_LONG 0xf067 #define GESTURE_UP_LEFT 0xf068 #define GESTURE_UP_RIGHT 0xf069 #define GESTURE_DOWN_LEFT 0xf06a #define GESTURE_DOWN_RIGHT 0xf06b #define GESTURE_LEFT_UP 0xf06c #define GESTURE_LEFT_DOWN 0xf06d #define GESTURE_RIGHT_UP 0xf06e #define GESTURE_RIGHT_DOWN 0xf06f #define GESTURE_LETTER_A 0xf080 #define GESTURE_LETTER_B 0xf081 #define GESTURE_LETTER_C 0xf082 #define GESTURE_LETTER_D 0xf083 #define GESTURE_LETTER_E 0xf084 #define GESTURE_LETTER_F 0xf085 #define GESTURE_LETTER_G 0xf086 #define GESTURE_LETTER_H 0xf087 #define GESTURE_LETTER_I 0xf088 #define GESTURE_LETTER_J 0xf089 #define GESTURE_LETTER_K 0xf08a #define GESTURE_LETTER_L 0xf08b #define GESTURE_LETTER_M 0xf08c #define GESTURE_LETTER_N 0xf08d #define GESTURE_LETTER_O 0xf08e #define GESTURE_LETTER_P 0xf08f #define GESTURE_LETTER_Q 0xf090 #define GESTURE_LETTER_R 0xf091 #define GESTURE_LETTER_S 0xf092 #define GESTURE_LETTER_T 0xf093 #define GESTURE_LETTER_U 0xf094 #define GESTURE_LETTER_V 0xf095 #define GESTURE_LETTER_W 0xf096 #define GESTURE_LETTER_X 0xf097 #define GESTURE_LETTER_Y 0xf098 #define GESTURE_LETTER_Z 0xf099 #define GESTURE_DIGIT_0 0xf09a #define GESTURE_DIGIT_1 0xf09b #define GESTURE_DIGIT_2 0xf09c #define GESTURE_DIGIT_3 0xf09d #define GESTURE_DIGIT_4 0xf09e #define GESTURE_DIGIT_5 0xf09f #define GESTURE_DIGIT_6 0xf0a0 #define GESTURE_DIGIT_7 0xf0a1 #define GESTURE_DIGIT_8 0xf0a2 #define GESTURE_DIGIT_9 0xf0a3 #define GESTURE_EXCLAMATION 0xf0a4 #define GESTURE_QUESTION 0xf0a5 #define GESTURE_SHARP 0xf0a6 #define GESTURE_DOLLAR 0xf0a7 #define GESTURE_ASTERISK 0xf0a8 #define GESTURE_PLUS 0xf0a9 #define GESTURE_DOUBLE_UP 0xf0b8 #define GESTURE_DOUBLE_DOWN 0xf0b9 #define GESTURE_DOUBLE_LEFT 0xf0ba #define GESTURE_DOUBLE_RIGHT 0xf0bb #define GESTURE_TRIPLE_UP 0xf0bc #define GESTURE_TRIPLE_DOWN 0xf0bd #define GESTURE_TRIPLE_LEFT 0xf0be #define GESTURE_TRIPLE_RIGHT 0xf0bf #define GESTURE_BRACKET_OVER 0xf0e4 #define GESTURE_BRACKET_UNDER 0xf0e5 #define GESTURE_BRACKET_LEFT 0xf0e6 #define GESTURE_BRACKET_RIGHT 0xf0e7 #define GESTURE_BRACE_OVER 0xf0e8 #define GESTURE_BRACE_UNDER 0xf0e9 #define GESTURE_BRACE_LEFT 0xf0ea #define GESTURE_BRACE_RIGHT 0xf0eb #define GESTURE_TAP 0xf0f0 #define GESTURE_DOUBLE_TAP 0xf0f1 #define GESTURE_TRIPLE_TAP 0xf0f2 #define GESTURE_QUAD_TAP 0xf0f3 #endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */ #pragma endregion #endif /* Please keep the trailing blank line, otherwise you will hit RC1004: "unexpected end of file found" */
88754e39387b90f01ba59a4349a8d254e3d8c7f1
984bc4181baec6e5a4b05a657e666b0e9f89f3f3
/include/tmemcacheddriver.h
9ada7e06cb11d5f769dcc8d921768f883e0b4693
[ "BSD-3-Clause" ]
permissive
treefrogframework/treefrog-framework
0173245ff92162d2107af79861505981980d1eca
a1df97793e8cc628779378e5adae9af6987460c1
refs/heads/master
2023-08-22T03:57:58.891846
2023-05-18T14:00:42
2023-05-18T14:00:42
7,067,532
1,152
263
BSD-3-Clause
2023-08-08T20:25:03
2012-12-08T13:17:01
C++
UTF-8
C
false
false
37
h
tmemcacheddriver.h
#include "../src/tmemcacheddriver.h"
e00d0f18e43006439eb84fadd965c02328e539db
06052ccd6db697947c1fcbb6ac96eba79c057fea
/lambdaLayers/SharpLayer/nodejs/node_modules/sharp/vendor/8.10.6/include/vips/almostdeprecated.h
e397c27f624c4c7cd6d3c773d10f1a11d39d12c7
[ "MIT", "Apache-2.0" ]
permissive
venveo/serverless-sharp
89e673e8ab727a00a5bb3cf2c8b9b3876caec8db
1f64468784763bbf40c32497c35de69406765335
refs/heads/master
2023-04-15T01:45:01.990626
2022-06-29T12:30:07
2022-06-29T12:30:07
198,690,918
165
39
MIT
2023-03-04T04:28:54
2019-07-24T18:38:47
JavaScript
UTF-8
C
false
false
10,271
h
almostdeprecated.h
/* Old and broken stuff that we still enable by default, but don't document * and certainly don't recommend. * * 30/6/09 * - from vips.h */ /* This file is part of VIPS. VIPS is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ /* These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk */ #ifndef IM_ALMOSTDEPRECATED_H #define IM_ALMOSTDEPRECATED_H #ifdef __cplusplus extern "C" { #endif /*__cplusplus*/ /* Was public, now deprecated. */ typedef enum { IM_BBITS_BYTE = 8, IM_BBITS_SHORT = 16, IM_BBITS_INT = 32, IM_BBITS_FLOAT = 32, IM_BBITS_COMPLEX = 64, IM_BBITS_DOUBLE = 64, IM_BBITS_DPCOMPLEX = 128 } VipsBBits; /* Used to define a region of interest for im_extract() etc. Too boring to be * public API, see im_extract_area() etc. */ typedef struct { int xstart; int ystart; int xsize; int ysize; int chsel; /* 1 2 3 or 0, for r g b or all respectively *(channel select) */ } IMAGE_BOX; int im_extract( IMAGE *, IMAGE *, IMAGE_BOX * ); DOUBLEMASK *im_measure( IMAGE *im, IMAGE_BOX *box, int h, int v, int *sel, int nsel, const char *name ); gboolean im_isuint( IMAGE *im ); gboolean im_isint( IMAGE *im ); gboolean im_isfloat( IMAGE *im ); gboolean im_isscalar( IMAGE *im ); gboolean im_iscomplex( IMAGE *im ); int im_c2ps( IMAGE *in, IMAGE *out ); int im_clip( IMAGE *in, IMAGE *out ); #define MASK_IDEAL_HIGHPASS IM_MASK_IDEAL_HIGHPASS #define MASK_IDEAL_LOWPASS IM_MASK_IDEAL_LOWPASS #define MASK_BUTTERWORTH_HIGHPASS IM_MASK_BUTTERWORTH_HIGHPASS #define MASK_BUTTERWORTH_LOWPASS IM_MASK_BUTTERWORTH_LOWPASS #define MASK_GAUSS_HIGHPASS IM_MASK_GAUSS_HIGHPASS #define MASK_GAUSS_LOWPASS IM_MASK_GAUSS_LOWPASS #define MASK_IDEAL_RINGPASS IM_MASK_IDEAL_RINGPASS #define MASK_IDEAL_RINGREJECT IM_MASK_IDEAL_RINGREJECT #define MASK_BUTTERWORTH_RINGPASS IM_MASK_BUTTERWORTH_RINGPASS #define MASK_BUTTERWORTH_RINGREJECT IM_MASK_BUTTERWORTH_RINGREJECT #define MASK_GAUSS_RINGPASS IM_MASK_GAUSS_RINGPASS #define MASK_GAUSS_RINGREJECT IM_MASK_GAUSS_RINGREJECT #define MASK_IDEAL_BANDPASS IM_MASK_IDEAL_BANDPASS #define MASK_IDEAL_BANDREJECT IM_MASK_IDEAL_BANDREJECT #define MASK_BUTTERWORTH_BANDPASS IM_MASK_BUTTERWORTH_BANDPASS #define MASK_BUTTERWORTH_BANDREJECT IM_MASK_BUTTERWORTH_BANDREJECT #define MASK_GAUSS_BANDPASS IM_MASK_GAUSS_BANDPASS #define MASK_GAUSS_BANDREJECT IM_MASK_GAUSS_BANDREJECT #define MASK_FRACTAL_FLT IM_MASK_FRACTAL_FLT #define MaskType ImMaskType /* Copy and swap types. */ typedef enum { IM_ARCH_NATIVE, IM_ARCH_BYTE_SWAPPED, IM_ARCH_LSB_FIRST, IM_ARCH_MSB_FIRST } im_arch_type; gboolean im_isnative( im_arch_type arch ); int im_copy_from( IMAGE *in, IMAGE *out, im_arch_type architecture ); /* Backwards compatibility macros. */ #define im_clear_error_string() im_error_clear() #define im_errorstring() im_error_buffer() /* Deprecated API. */ void im_errormsg( const char *fmt, ... ) __attribute__((format(printf, 1, 2))); void im_verrormsg( const char *fmt, va_list ap ); void im_errormsg_system( int err, const char *fmt, ... ) __attribute__((format(printf, 2, 3))); void im_diagnostics( const char *fmt, ... ) __attribute__((format(printf, 1, 2))); void im_warning( const char *fmt, ... ) __attribute__((format(printf, 1, 2))); int im_iterate( VipsImage *im, VipsStartFn start, im_generate_fn generate, VipsStopFn stop, void *a, void *b ); /* Async rendering. */ int im_render_priority( VipsImage *in, VipsImage *out, VipsImage *mask, int width, int height, int max, int priority, void (*notify)( VipsImage *, VipsRect *, void * ), void *client ); int im_cache( VipsImage *in, VipsImage *out, int width, int height, int max ); /* Deprecated operations. */ int im_cmulnorm( IMAGE *in1, IMAGE *in2, IMAGE *out ); int im_fav4( IMAGE **, IMAGE * ); int im_gadd( double, IMAGE *, double, IMAGE *, double, IMAGE *); int im_litecor( IMAGE *, IMAGE *, IMAGE *, int, double ); int im_render_fade( IMAGE *in, IMAGE *out, IMAGE *mask, int width, int height, int max, int fps, int steps, int priority, void (*notify)( IMAGE *, VipsRect *, void * ), void *client ); int im_render( IMAGE *in, IMAGE *out, IMAGE *mask, int width, int height, int max, void (*notify)( IMAGE *, VipsRect *, void * ), void *client ); int im_cooc_matrix( IMAGE *im, IMAGE *m, int xp, int yp, int xs, int ys, int dx, int dy, int flag ); int im_cooc_asm( IMAGE *m, double *asmoment ); int im_cooc_contrast( IMAGE *m, double *contrast ); int im_cooc_correlation( IMAGE *m, double *correlation ); int im_cooc_entropy( IMAGE *m, double *entropy ); int im_glds_matrix( IMAGE *im, IMAGE *m, int xpos, int ypos, int xsize, int ysize, int dx, int dy ); int im_glds_asm( IMAGE *m, double *asmoment ); int im_glds_contrast( IMAGE *m, double *contrast ); int im_glds_entropy( IMAGE *m, double *entropy ); int im_glds_mean( IMAGE *m, double *mean ); int im_dif_std(IMAGE *im, int xpos, int ypos, int xsize, int ysize, int dx, int dy, double *pmean, double *pstd); int im_simcontr( IMAGE *out, int xsize, int ysize ); int im_spatres( IMAGE *in, IMAGE *out, int step ); int im_stretch3( IMAGE *in, IMAGE *out, double dx, double dy ); /* Renamed operations. */ /* arithmetic */ int im_remainderconst_vec( IMAGE *in, IMAGE *out, int n, double *c ); /* boolean */ int im_andconst( IMAGE *, IMAGE *, double ); int im_and_vec( IMAGE *, IMAGE *, int, double * ); int im_orconst( IMAGE *, IMAGE *, double ); int im_or_vec( IMAGE *, IMAGE *, int, double * ); int im_eorconst( IMAGE *, IMAGE *, double ); int im_eor_vec( IMAGE *, IMAGE *, int, double * ); /* mosaicing */ int im_affine( IMAGE *in, IMAGE *out, double a, double b, double c, double d, double dx, double dy, int ox, int oy, int ow, int oh ); int im_similarity( IMAGE *in, IMAGE *out, double a, double b, double dx, double dy ); int im_similarity_area( IMAGE *in, IMAGE *out, double a, double b, double dx, double dy, int ox, int oy, int ow, int oh ); /* colour */ int im_icc_export( IMAGE *in, IMAGE *out, const char *output_profile_filename, int intent ); /* conversion */ int im_clip2dcm( IMAGE *in, IMAGE *out ); int im_clip2cm( IMAGE *in, IMAGE *out ); int im_clip2us( IMAGE *in, IMAGE *out ); int im_clip2ui( IMAGE *in, IMAGE *out ); int im_clip2s( IMAGE *in, IMAGE *out ); int im_clip2i( IMAGE *in, IMAGE *out ); int im_clip2d( IMAGE *in, IMAGE *out ); int im_clip2f( IMAGE *in, IMAGE *out ); int im_clip2c( IMAGE *in, IMAGE *out ); int im_slice( IMAGE *in, IMAGE *out, double, double ); int im_thresh( IMAGE *in, IMAGE *out, double ); int im_print( const char *message ); int im_convsub( IMAGE *in, IMAGE *out, INTMASK *mask, int xskip, int yskip ); int im_bernd( const char *tiffname, int x, int y, int w, int h ); int im_resize_linear( IMAGE *, IMAGE *, int, int ); int im_convf( IMAGE *in, IMAGE *out, DOUBLEMASK *mask ); int im_convsepf( IMAGE *in, IMAGE *out, DOUBLEMASK *mask ); int im_conv_raw( IMAGE *in, IMAGE *out, INTMASK *mask ); int im_convf_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask ); int im_convsep_raw( IMAGE *in, IMAGE *out, INTMASK *mask ); int im_convsepf_raw( IMAGE *in, IMAGE *out, DOUBLEMASK *mask ); int im_fastcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out ); int im_spcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out ); int im_gradcor_raw( IMAGE *in, IMAGE *ref, IMAGE *out ); int im_contrast_surface_raw( IMAGE *in, IMAGE *out, int half_win_size, int spacing ); int im_stdif_raw( IMAGE *in, IMAGE *out, double a, double m0, double b, double s0, int xwin, int ywin ); int im_lhisteq_raw( IMAGE *in, IMAGE *out, int xwin, int ywin ); int im_erode_raw( IMAGE *in, IMAGE *out, INTMASK *m ); int im_dilate_raw( IMAGE *in, IMAGE *out, INTMASK *m ); int im_rank_raw( IMAGE *in, IMAGE *out, int xsize, int ysize, int order ); /* inplace */ int im_circle( IMAGE *im, int cx, int cy, int radius, int intensity ); int im_line( IMAGE *, int, int, int, int, int ); int im_segment( IMAGE *test, IMAGE *mask, int *segments ); int im_paintrect( IMAGE *im, VipsRect *r, PEL *ink ); int im_insertplace( IMAGE *main, IMAGE *sub, int x, int y ); int im_flood_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink ); int im_flood_blob_copy( IMAGE *in, IMAGE *out, int x, int y, PEL *ink ); int im_flood_other_copy( IMAGE *test, IMAGE *mark, IMAGE *out, int x, int y, int serial ); int im_flood( IMAGE *im, int x, int y, PEL *ink, VipsRect *dout ); int im_flood_blob( IMAGE *im, int x, int y, PEL *ink, VipsRect *dout ); int im_flood_other( IMAGE *test, IMAGE *mark, int x, int y, int serial, VipsRect *dout ); int im_fastline( IMAGE *im, int x1, int y1, int x2, int y2, PEL *pel ); int im_fastlineuser( IMAGE *im, int x1, int y1, int x2, int y2, VipsPlotFn fn, void *client1, void *client2, void *client3 ); int im_plotmask( IMAGE *im, int ix, int iy, PEL *ink, PEL *mask, VipsRect *r ); int im_readpoint( IMAGE *im, int x, int y, PEL *pel ); int im_plotpoint( IMAGE *im, int x, int y, PEL *pel ); int im_smudge( IMAGE *image, int ix, int iy, VipsRect *r ); int im_smear( IMAGE *im, int ix, int iy, VipsRect *r ); void vips_warn( const char *domain, const char *fmt, ... ) __attribute__((format(printf, 2, 3))); void vips_vwarn( const char *domain, const char *fmt, va_list ap ); void vips_info_set( gboolean info ); void vips_info( const char *domain, const char *fmt, ... ) __attribute__((format(printf, 2, 3))); void vips_vinfo( const char *domain, const char *fmt, va_list ap ); VipsAngle vips_autorot_get_angle( VipsImage *image ); /* iofuncs */ int vips_free( void *buf ); #ifdef __cplusplus } #endif /*__cplusplus*/ #endif /*IM_ALMOSTDEPRECATED_H*/
0d2b7aef1b9bef11cf32800e75d632fb3a6ce4d1
9e10d8c3cd52a0ee07031345ffedd1b25e9faa85
/win32/io.c
50a701ec9880a32983d47a510f0b0209d3287d89
[ "LicenseRef-scancode-warranty-disclaimer", "BSD-3-Clause" ]
permissive
tcsh-org/tcsh
ab3b0f0bc70387132211c2d73b2d6b483562b0f4
d075ab5b4155ebff9d30e765733c030c3da5e362
refs/heads/master
2023-08-16T23:26:40.284057
2023-06-27T21:47:56
2023-06-27T21:47:56
80,540,178
236
55
NOASSERTION
2023-08-02T07:08:14
2017-01-31T16:46:53
C
UTF-8
C
false
false
11,376
c
io.c
/*- * Copyright (c) 1980, 1991 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. 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. */ /* * io.c * wrapper functions for some i/o routines. * -amol * */ #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <stdio.h> #include <fcntl.h> #include <memory.h> #include <errno.h> #include "sh.h" #include "ntport.h" #include "signal.h" #pragma warning(disable:4127) //conditional expr is constant #define CR 0x0d extern void make_err_str(unsigned int ,char *,int ) ; extern void generic_handler(int); extern int console_write(HANDLE,unsigned char*,int); int consoleread(HANDLE , unsigned char * ,size_t ) ; INPUT_RECORD girec[2048]; unsigned short __nt_want_vcode=0,__nt_vcode=0; HANDLE __h_con_alarm; HANDLE __h_con_int; HANDLE __h_con_hup; extern int NoNLSRebind; extern int OLDSTD, SHIN; /* * force_read: Forces a ReadFile, instead of ReadConsole * */ int force_read(int fd, unsigned char * buf, size_t howmany) { DWORD numread=0,err=0; HANDLE hRead ; hRead= (HANDLE)__nt_get_osfhandle(fd); if (hRead == INVALID_HANDLE_VALUE) { return 0; } again: if (!ReadFile(hRead, buf,(DWORD)howmany,&numread, NULL ) ){ err = GetLastError(); switch(err) { case ERROR_IO_PENDING: break; case ERROR_ACCESS_DENIED: case ERROR_INVALID_HANDLE: errno = EBADF; return -1; break; case ERROR_HANDLE_EOF: case ERROR_BROKEN_PIPE: errno = 0; return 0; default: errno = EBADF; return 0; } } if (numread == 1 && buf[0] == CR) goto again; return numread; } int nt_read(int fd, unsigned char * buf, size_t howmany) { DWORD numread=0,err=0; HANDLE hRead ; DWORD ftype; // hRead= (HANDLE)__nt_get_osfhandle(fd); if (hRead == INVALID_HANDLE_VALUE) { return 0; } ftype = GetFileType(hRead); if ((ftype == FILE_TYPE_CHAR) /*&& (fd != OLDSTD) && (fd != SHIN)*/) return consoleread(hRead,buf,howmany); again: if (!ReadFile(hRead, buf,(DWORD)howmany,&numread, NULL ) ){ err = GetLastError(); switch(err) { case ERROR_IO_PENDING: break; case ERROR_ACCESS_DENIED: case ERROR_INVALID_HANDLE: errno = EBADF; return -1; break; case ERROR_HANDLE_EOF: case ERROR_BROKEN_PIPE: errno = 0; return 0; default: errno = EBADF; return 0; } } if (numread) { if (buf[numread-1] == CR) numread--; if (numread == 0) goto again; } return numread; } /* color-ls patches from TAGA nayuta (nayuta@is.s.u-tokyo.ac.jp) */ #ifdef COLOR_LS_F int nt_write_(int , const unsigned char * , size_t ); int nt_write(int fd, const unsigned char * buf, size_t howmany) { static unsigned char color_buf[256]; static char len = 0; ssize_t i; ssize_t start = 0; int rc,wrote = 0; if (!isatty(fd) || (varval(STRcolor) == NULL)) return nt_write_(fd, buf, howmany); for (i = 0; i < howmany; i++) { switch (len) { case 0: if (buf[i] == '\x1b') { color_buf[len++] = buf[i]; if (0 < i - start){ if ((rc=nt_write_(fd, &(buf[start]), i - start)) <0) return -1; else wrote += rc; } start = -1; } break; case 1: if (buf[i] != '[') goto set_color; color_buf[len++] = buf[i]; break; default: if (buf[i] == 'm' || (!isdigit(buf[i]) && buf[i] != ';')) goto set_color; color_buf[len++] = buf[i]; break; case sizeof(color_buf) - 1: set_color: color_buf[len] = '\0'; set_attributes(color_buf); len = 0; start = i + 1; break; } } if (0 < i - start && 0 <= start) { if ((rc=nt_write_(fd, &(buf[start]), i - start)) < 0) return -1; else wrote += rc; } return wrote; } int nt_write_(int fd, const unsigned char * buf, size_t howmany) #else /* if !COLOR_LS_F */ int nt_write(int fd, const unsigned char * buf, size_t howmany) #endif /* COLOR_LS_F */ { int bytes_rtn,err; HANDLE hout; hout = (HANDLE)__nt_get_osfhandle(fd); /* if (isatty(fd)) ;// return console_write(hout,buf,howmany); */ if(!WriteFile(hout, buf,(DWORD)howmany,(ULONG*)&bytes_rtn, NULL)){ err = GetLastError(); switch(err) { case ERROR_ACCESS_DENIED: case ERROR_INVALID_HANDLE: errno = EBADF; return -1; break; case ERROR_BROKEN_PIPE: errno = EPIPE; return -1; default: errno = EBADF; return -1; } } return bytes_rtn?bytes_rtn:-1; } #define IS_CTRL_COMBO(a) ( (a) & ( RIGHT_CTRL_PRESSED | LEFT_CTRL_PRESSED) ) #define IS_ALT_COMBO(a) ( /*(a) &*/ alt_pressed ) #define IS_SHIFT_COMBO(a) ( (a) & SHIFT_PRESSED) int consoleread(HANDLE hInput, unsigned char * buf,size_t howmany) { INPUT_RECORD *irec = NULL; DWORD numread,controlkey,i; WORD vcode; unsigned char ch; int rc; size_t where=0; int alt_pressed = 0,memfree=0; HANDLE hevents[4]; static int pre_ch = -1; if (0 <= pre_ch) { buf[0] = (unsigned char)pre_ch; pre_ch = -1; return 1; } howmany /= 2; // [ALT + KEY] is expanded ESC KEY, so we need more buffer if (howmany == 0) howmany = 1; if (howmany > 2048){ irec = heap_alloc(howmany*sizeof(INPUT_RECORD)); memfree=1; } else irec = &(girec[0]); if (!irec){ errno = ENOMEM; return -1; } while(1) { hevents[0] = __h_con_alarm; hevents[1] = __h_con_int; hevents[2] = __h_con_hup; hevents[3] = hInput; rc = WaitForMultipleObjects(sizeof(hevents)/sizeof(hevents[0]), hevents,FALSE,INFINITE); if (rc == WAIT_OBJECT_0) { generic_handler(SIGALRM); } if (rc == (WAIT_OBJECT_0 +1) ) { errno = EINTR; generic_handler(SIGINT); break; } if (rc == (WAIT_OBJECT_0 +2) ) { errno = EINTR; generic_handler(SIGHUP); break; } rc = ReadConsoleInput(hInput,irec,(DWORD)howmany,&numread); if (!rc) { rc = GetLastError(); switch (rc) { case ERROR_INVALID_HANDLE: case ERROR_ACCESS_DENIED: errno = EBADF; break; } if (memfree) heap_free(irec); return -1; } __nt_vcode=0; for(i=0;i<numread;i++) { switch(irec[i].EventType) { case KEY_EVENT: if (irec[i].Event.KeyEvent.bKeyDown) { vcode=(irec[i].Event.KeyEvent.wVirtualKeyCode); ch=(irec[i].Event.KeyEvent.uChar.AsciiChar); controlkey=(irec[i].Event.KeyEvent.dwControlKeyState); if (controlkey & LEFT_ALT_PRESSED) alt_pressed=1; else if (controlkey & RIGHT_ALT_PRESSED){ if (NoNLSRebind) alt_pressed=1; } if (__nt_want_vcode != 1) goto skippy; if (vcode >= VK_F1 && vcode <= VK_F24) { __nt_vcode=NT_SPECIFIC_BINDING_OFFSET ; __nt_vcode += (vcode- VK_F1) + SINGLE_KEY_OFFSET; if (IS_CTRL_COMBO(controlkey)) __nt_vcode += CTRL_KEY_OFFSET; else if (IS_ALT_COMBO(controlkey)) __nt_vcode += ALT_KEY_OFFSET; else if (IS_SHIFT_COMBO(controlkey)) __nt_vcode += SHIFT_KEY_OFFSET; __nt_want_vcode=2; return 1; } else if (vcode>= VK_PRIOR && vcode <= VK_DOWN) { __nt_vcode = NT_SPECIFIC_BINDING_OFFSET ; __nt_vcode += KEYPAD_MAPPING_BEGIN; __nt_vcode += (vcode -VK_PRIOR); __nt_vcode += SINGLE_KEY_OFFSET ; if (IS_CTRL_COMBO(controlkey)) __nt_vcode += CTRL_KEY_OFFSET; else if (IS_ALT_COMBO(controlkey)) __nt_vcode += ALT_KEY_OFFSET; else if (IS_SHIFT_COMBO(controlkey)) __nt_vcode += SHIFT_KEY_OFFSET; __nt_want_vcode=2; return 1; } else if (vcode == VK_INSERT) { __nt_vcode = NT_SPECIFIC_BINDING_OFFSET ; __nt_vcode += INS_DEL_MAPPING_BEGIN; if (IS_CTRL_COMBO(controlkey)) __nt_vcode += CTRL_KEY_OFFSET; else if (IS_ALT_COMBO(controlkey)) __nt_vcode += ALT_KEY_OFFSET; else if (IS_SHIFT_COMBO(controlkey)) __nt_vcode += SHIFT_KEY_OFFSET; __nt_want_vcode=2; return 1; } else if (vcode == VK_DELETE) { __nt_vcode = NT_SPECIFIC_BINDING_OFFSET ; __nt_vcode += INS_DEL_MAPPING_BEGIN + 1; if (IS_CTRL_COMBO(controlkey)) __nt_vcode += CTRL_KEY_OFFSET; else if (IS_ALT_COMBO(controlkey)) __nt_vcode += ALT_KEY_OFFSET; else if (IS_SHIFT_COMBO(controlkey)) __nt_vcode += SHIFT_KEY_OFFSET; __nt_want_vcode=2; return 1; } skippy: switch(vcode) { case VK_ESCAPE: buf[where++]='\033'; break; default: if(ch ){ /* * Looks like win95 has a spurious * newline left over */ if (gdwPlatform == VER_PLATFORM_WIN32_WINDOWS && ch == '\r'){ DWORD bread; (void)ReadFile(hInput,&ch,1,&bread,NULL); } /* patch from TAGA nayuta */ if ( NoNLSRebind && (ch == ' ' || ch == '@') && IS_CTRL_COMBO(controlkey) /*(controlkey & LEFT_CTRL_PRESSED || controlkey & RIGHT_CTRL_PRESSED)*/ ) ch = 0; if (alt_pressed) { #ifdef DSPMBYTE buf[where++] = '\033'; if (howmany == 1) pre_ch = ch; else buf[where++] = ch; #else /* !DSPMBYTE */ buf[where++] = ch | 0200; #endif /* !DSPMBYTE */ } else buf[where++] = ch; } break; } alt_pressed=0; } break; default: break; } } if (where == 0) continue; if (howmany < where) // avoid trashing memory. -amol 4/16/97 buf[where]=0; break; } if (memfree) heap_free(irec); if (!where) return -1; return (int)(where ); } int console_write(HANDLE hout, unsigned char * buf,int howmany) { int bytes,rc; bytes = -1; rc = WriteConsole(hout,buf,howmany,(DWORD*)&bytes,NULL); if (!rc) { errno = EBADF; bytes = -1; rc = GetLastError(); } return bytes; }
ed69d2d6cc86f36b00b2a601cb6c622ecc6fd77f
7d3d2af0389f9c0dee5d7ca789660bf21d97249d
/kernel/generic/kernel_sgemm_4x4_lib4.c
adfee9cd15add207ac270e0ee0375bfd6d222303
[ "BSD-2-Clause" ]
permissive
giaf/blasfeo
0ecbcd67429d0507d7f462c090037c388e84a49e
b85a0c3121eae491480f07774fedf67e76b1f038
refs/heads/master
2023-07-22T15:40:53.961071
2023-07-18T15:42:08
2023-07-18T15:42:08
70,173,581
248
78
NOASSERTION
2022-11-25T15:42:08
2016-10-06T16:48:09
Assembly
UTF-8
C
false
false
140,136
c
kernel_sgemm_4x4_lib4.c
/************************************************************************************************** * * * This file is part of BLASFEO. * * * * BLASFEO -- BLAS For Embedded Optimization. * * Copyright (C) 2019 by Gianluca Frison. * * Developed at IMTEK (University of Freiburg) under the supervision of Moritz Diehl. * * All rights reserved. * * * * The 2-Clause BSD License * * * * Redistribution and use in source and binary forms, with or without * * modification, are permitted provided that the following conditions are met: * * * * 1. Redistributions of source code must retain the above copyright notice, this * * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, * * this list of conditions and the following disclaimer in the documentation * * and/or other materials provided with the distribution. * * * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 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. * * * * Author: Gianluca Frison, gianluca.frison (at) imtek.uni-freiburg.de * * * **************************************************************************************************/ #include <math.h> #include <blasfeo_common.h> #include <blasfeo_s_kernel.h> #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_X64_AMD_BULLDOZER) void kernel_sgemm_nt_4x4_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif int k; for(k=0; k<kmax-3; k+=4) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[1]; b_2 = B[2]; b_3 = B[3]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; // k = 1 a_0 = A[4]; a_1 = A[5]; a_2 = A[6]; a_3 = A[7]; b_0 = B[4]; b_1 = B[5]; b_2 = B[6]; b_3 = B[7]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; // k = 2 a_0 = A[8]; a_1 = A[9]; a_2 = A[10]; a_3 = A[11]; b_0 = B[8]; b_1 = B[9]; b_2 = B[10]; b_3 = B[11]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; // k = 3 a_0 = A[12]; a_1 = A[13]; a_2 = A[14]; a_3 = A[15]; b_0 = B[12]; b_1 = B[13]; b_2 = B[14]; b_3 = B[15]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 16; B += 16; } for(; k<kmax; k++) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[1]; b_2 = B[2]; b_3 = B[3]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4; } D[0+bs*0] = beta[0]*C[0+bs*0] + alpha[0]*CC[0+bs*0]; D[1+bs*0] = beta[0]*C[1+bs*0] + alpha[0]*CC[1+bs*0]; D[2+bs*0] = beta[0]*C[2+bs*0] + alpha[0]*CC[2+bs*0]; D[3+bs*0] = beta[0]*C[3+bs*0] + alpha[0]*CC[3+bs*0]; D[0+bs*1] = beta[0]*C[0+bs*1] + alpha[0]*CC[0+bs*1]; D[1+bs*1] = beta[0]*C[1+bs*1] + alpha[0]*CC[1+bs*1]; D[2+bs*1] = beta[0]*C[2+bs*1] + alpha[0]*CC[2+bs*1]; D[3+bs*1] = beta[0]*C[3+bs*1] + alpha[0]*CC[3+bs*1]; D[0+bs*2] = beta[0]*C[0+bs*2] + alpha[0]*CC[0+bs*2]; D[1+bs*2] = beta[0]*C[1+bs*2] + alpha[0]*CC[1+bs*2]; D[2+bs*2] = beta[0]*C[2+bs*2] + alpha[0]*CC[2+bs*2]; D[3+bs*2] = beta[0]*C[3+bs*2] + alpha[0]*CC[3+bs*2]; D[0+bs*3] = beta[0]*C[0+bs*3] + alpha[0]*CC[0+bs*3]; D[1+bs*3] = beta[0]*C[1+bs*3] + alpha[0]*CC[1+bs*3]; D[2+bs*3] = beta[0]*C[2+bs*3] + alpha[0]*CC[2+bs*3]; D[3+bs*3] = beta[0]*C[3+bs*3] + alpha[0]*CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) void kernel_sgemm_nt_4x4_vs_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif kernel_sgemm_nt_4x4_lib4(kmax, alpha, A, B, beta, C, CC); if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_sgemm_nt_4x4_gen_lib4(int kmax, float *alpha, float *A, float *B, float *beta, int offsetC, float *C0, int sdc, int offsetD, float *D0, int sdd, int m0, int m1, int n0, int n1) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *C1, *D1; int k; if(offsetC==0) { CC[0+bs*0] = beta[0]*C0[0+bs*0]; CC[1+bs*0] = beta[0]*C0[1+bs*0]; CC[2+bs*0] = beta[0]*C0[2+bs*0]; CC[3+bs*0] = beta[0]*C0[3+bs*0]; CC[0+bs*1] = beta[0]*C0[0+bs*1]; CC[1+bs*1] = beta[0]*C0[1+bs*1]; CC[2+bs*1] = beta[0]*C0[2+bs*1]; CC[3+bs*1] = beta[0]*C0[3+bs*1]; CC[0+bs*2] = beta[0]*C0[0+bs*2]; CC[1+bs*2] = beta[0]*C0[1+bs*2]; CC[2+bs*2] = beta[0]*C0[2+bs*2]; CC[3+bs*2] = beta[0]*C0[3+bs*2]; CC[0+bs*3] = beta[0]*C0[0+bs*3]; CC[1+bs*3] = beta[0]*C0[1+bs*3]; CC[2+bs*3] = beta[0]*C0[2+bs*3]; CC[3+bs*3] = beta[0]*C0[3+bs*3]; } else if(offsetC==1) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[1+bs*0]; CC[1+bs*0] = beta[0]*C0[2+bs*0]; CC[2+bs*0] = beta[0]*C0[3+bs*0]; CC[3+bs*0] = beta[0]*C1[0+bs*0]; CC[0+bs*1] = beta[0]*C0[1+bs*1]; CC[1+bs*1] = beta[0]*C0[2+bs*1]; CC[2+bs*1] = beta[0]*C0[3+bs*1]; CC[3+bs*1] = beta[0]*C1[0+bs*1]; CC[0+bs*2] = beta[0]*C0[1+bs*2]; CC[1+bs*2] = beta[0]*C0[2+bs*2]; CC[2+bs*2] = beta[0]*C0[3+bs*2]; CC[3+bs*2] = beta[0]*C1[0+bs*2]; CC[0+bs*3] = beta[0]*C0[1+bs*3]; CC[1+bs*3] = beta[0]*C0[2+bs*3]; CC[2+bs*3] = beta[0]*C0[3+bs*3]; CC[3+bs*3] = beta[0]*C1[0+bs*3]; } else if(offsetC==2) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[2+bs*0]; CC[1+bs*0] = beta[0]*C0[3+bs*0]; CC[2+bs*0] = beta[0]*C1[0+bs*0]; CC[3+bs*0] = beta[0]*C1[1+bs*0]; CC[0+bs*1] = beta[0]*C0[2+bs*1]; CC[1+bs*1] = beta[0]*C0[3+bs*1]; CC[2+bs*1] = beta[0]*C1[0+bs*1]; CC[3+bs*1] = beta[0]*C1[1+bs*1]; CC[0+bs*2] = beta[0]*C0[2+bs*2]; CC[1+bs*2] = beta[0]*C0[3+bs*2]; CC[2+bs*2] = beta[0]*C1[0+bs*2]; CC[3+bs*2] = beta[0]*C1[1+bs*2]; CC[0+bs*3] = beta[0]*C0[2+bs*3]; CC[1+bs*3] = beta[0]*C0[3+bs*3]; CC[2+bs*3] = beta[0]*C1[0+bs*3]; CC[3+bs*3] = beta[0]*C1[1+bs*3]; } else //if(offsetC==3) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[3+bs*0]; CC[1+bs*0] = beta[0]*C1[0+bs*0]; CC[2+bs*0] = beta[0]*C1[1+bs*0]; CC[3+bs*0] = beta[0]*C1[2+bs*0]; CC[0+bs*1] = beta[0]*C0[3+bs*1]; CC[1+bs*1] = beta[0]*C1[0+bs*1]; CC[2+bs*1] = beta[0]*C1[1+bs*1]; CC[3+bs*1] = beta[0]*C1[2+bs*1]; CC[0+bs*2] = beta[0]*C0[3+bs*2]; CC[1+bs*2] = beta[0]*C1[0+bs*2]; CC[2+bs*2] = beta[0]*C1[1+bs*2]; CC[3+bs*2] = beta[0]*C1[2+bs*2]; CC[0+bs*3] = beta[0]*C0[3+bs*3]; CC[1+bs*3] = beta[0]*C1[0+bs*3]; CC[2+bs*3] = beta[0]*C1[1+bs*3]; CC[3+bs*3] = beta[0]*C1[2+bs*3]; } float beta1 = 1.0; kernel_sgemm_nt_4x4_lib4(kmax, alpha, A, B, &beta1, CC, CC); // shift sol for cols if(n0>0) { if(n0==1) { CC[0+bs*0] = CC[0+bs*1]; CC[1+bs*0] = CC[1+bs*1]; CC[2+bs*0] = CC[2+bs*1]; CC[3+bs*0] = CC[3+bs*1]; CC[0+bs*1] = CC[0+bs*2]; CC[1+bs*1] = CC[1+bs*2]; CC[2+bs*1] = CC[2+bs*2]; CC[3+bs*1] = CC[3+bs*2]; CC[0+bs*2] = CC[0+bs*3]; CC[1+bs*2] = CC[1+bs*3]; CC[2+bs*2] = CC[2+bs*3]; CC[3+bs*2] = CC[3+bs*3]; D0 += 1*bs; } else if(n0==2) { CC[0+bs*0] = CC[0+bs*2]; CC[1+bs*0] = CC[1+bs*2]; CC[2+bs*0] = CC[2+bs*2]; CC[3+bs*0] = CC[3+bs*2]; CC[0+bs*1] = CC[0+bs*3]; CC[1+bs*1] = CC[1+bs*3]; CC[2+bs*1] = CC[2+bs*3]; CC[3+bs*1] = CC[3+bs*3]; D0 += 2*bs; } else //if(n0==3) { CC[0+bs*0] = CC[0+bs*3]; CC[1+bs*0] = CC[1+bs*3]; CC[2+bs*0] = CC[2+bs*3]; CC[3+bs*0] = CC[3+bs*3]; D0 += 3*bs; } } n1 = 4<n1 ? 4 : n1; int kn = n1 - n0; if(offsetD==0) { if(kn<=0) return; if(m0<=0 & m1>0) D0[0+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[1+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D0[2+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D0[3+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[0+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[1+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D0[2+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D0[3+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[0+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[1+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D0[2+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D0[3+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[0+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[1+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D0[2+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D0[3+bs*3] = CC[3+bs*3]; } else if(offsetD==1) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[1+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[2+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D0[3+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[0+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[1+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[2+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D0[3+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[0+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[1+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[2+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D0[3+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[0+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[1+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[2+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D0[3+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[0+bs*3] = CC[3+bs*3]; } else if(offsetD==2) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[2+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[3+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D1[0+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[1+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[2+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[3+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D1[0+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[1+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[2+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[3+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D1[0+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[1+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[2+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[3+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D1[0+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[1+bs*3] = CC[3+bs*3]; } else //if(offsetD==3) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[3+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D1[0+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D1[1+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[2+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[3+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D1[0+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D1[1+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[2+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[3+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D1[0+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D1[1+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[2+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[3+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D1[0+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D1[1+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[2+bs*3] = CC[3+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X64_AMD_BULLDOZER) void kernel_sgemm_nn_4x4_lib4(int kmax, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *C1, *D1; int k; k = 0; if(offsetB!=0) { if(offsetB==1) { B += 1; a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto scale; a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto scale; a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; B += bs*(sdb-1); k += 1; } else if(offsetB==2) { B += 2; a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto scale; a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; B += bs*(sdb-1); k += 1; } else // if(offsetB==3) { B += 3; a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; B += bs*(sdb-1); k += 1; } } for(; k<kmax-3; k+=4) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; // k = 1 a_0 = A[4]; a_1 = A[5]; a_2 = A[6]; a_3 = A[7]; b_0 = B[1]; b_1 = B[5]; b_2 = B[9]; b_3 = B[13]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; // k = 2 a_0 = A[8]; a_1 = A[9]; a_2 = A[10]; a_3 = A[11]; b_0 = B[2]; b_1 = B[6]; b_2 = B[10]; b_3 = B[14]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; // k = 3 a_0 = A[12]; a_1 = A[13]; a_2 = A[14]; a_3 = A[15]; b_0 = B[3]; b_1 = B[7]; b_2 = B[11]; b_3 = B[15]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 16; B += 4*sdb; } for(; k<kmax; k++) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[4]; b_2 = B[8]; b_3 = B[12]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; } scale: D[0+bs*0] = beta[0]*C[0+bs*0] + alpha[0]*CC[0+bs*0]; D[1+bs*0] = beta[0]*C[1+bs*0] + alpha[0]*CC[1+bs*0]; D[2+bs*0] = beta[0]*C[2+bs*0] + alpha[0]*CC[2+bs*0]; D[3+bs*0] = beta[0]*C[3+bs*0] + alpha[0]*CC[3+bs*0]; D[0+bs*1] = beta[0]*C[0+bs*1] + alpha[0]*CC[0+bs*1]; D[1+bs*1] = beta[0]*C[1+bs*1] + alpha[0]*CC[1+bs*1]; D[2+bs*1] = beta[0]*C[2+bs*1] + alpha[0]*CC[2+bs*1]; D[3+bs*1] = beta[0]*C[3+bs*1] + alpha[0]*CC[3+bs*1]; D[0+bs*2] = beta[0]*C[0+bs*2] + alpha[0]*CC[0+bs*2]; D[1+bs*2] = beta[0]*C[1+bs*2] + alpha[0]*CC[1+bs*2]; D[2+bs*2] = beta[0]*C[2+bs*2] + alpha[0]*CC[2+bs*2]; D[3+bs*2] = beta[0]*C[3+bs*2] + alpha[0]*CC[3+bs*2]; D[0+bs*3] = beta[0]*C[0+bs*3] + alpha[0]*CC[0+bs*3]; D[1+bs*3] = beta[0]*C[1+bs*3] + alpha[0]*CC[1+bs*3]; D[2+bs*3] = beta[0]*C[2+bs*3] + alpha[0]*CC[2+bs*3]; D[3+bs*3] = beta[0]*C[3+bs*3] + alpha[0]*CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) void kernel_sgemm_nn_4x4_vs_lib4(int kmax, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, float *C, float *D, int km, int kn) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif kernel_sgemm_nn_4x4_lib4(kmax, alpha, A, offsetB, B, sdb, beta, C, CC); if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_sgemm_nn_4x4_gen_lib4(int kmax, float *alpha, float *A, int offsetB, float *B, int sdb, float *beta, int offsetC, float *C0, int sdc, int offsetD, float *D0, int sdd, int m0, int m1, int n0, int n1) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *C1, *D1; if(offsetC==0) { CC[0+bs*0] = beta[0]*C0[0+bs*0]; CC[1+bs*0] = beta[0]*C0[1+bs*0]; CC[2+bs*0] = beta[0]*C0[2+bs*0]; CC[3+bs*0] = beta[0]*C0[3+bs*0]; CC[0+bs*1] = beta[0]*C0[0+bs*1]; CC[1+bs*1] = beta[0]*C0[1+bs*1]; CC[2+bs*1] = beta[0]*C0[2+bs*1]; CC[3+bs*1] = beta[0]*C0[3+bs*1]; CC[0+bs*2] = beta[0]*C0[0+bs*2]; CC[1+bs*2] = beta[0]*C0[1+bs*2]; CC[2+bs*2] = beta[0]*C0[2+bs*2]; CC[3+bs*2] = beta[0]*C0[3+bs*2]; CC[0+bs*3] = beta[0]*C0[0+bs*3]; CC[1+bs*3] = beta[0]*C0[1+bs*3]; CC[2+bs*3] = beta[0]*C0[2+bs*3]; CC[3+bs*3] = beta[0]*C0[3+bs*3]; } else if(offsetC==1) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[1+bs*0]; CC[1+bs*0] = beta[0]*C0[2+bs*0]; CC[2+bs*0] = beta[0]*C0[3+bs*0]; CC[3+bs*0] = beta[0]*C1[0+bs*0]; CC[0+bs*1] = beta[0]*C0[1+bs*1]; CC[1+bs*1] = beta[0]*C0[2+bs*1]; CC[2+bs*1] = beta[0]*C0[3+bs*1]; CC[3+bs*1] = beta[0]*C1[0+bs*1]; CC[0+bs*2] = beta[0]*C0[1+bs*2]; CC[1+bs*2] = beta[0]*C0[2+bs*2]; CC[2+bs*2] = beta[0]*C0[3+bs*2]; CC[3+bs*2] = beta[0]*C1[0+bs*2]; CC[0+bs*3] = beta[0]*C0[1+bs*3]; CC[1+bs*3] = beta[0]*C0[2+bs*3]; CC[2+bs*3] = beta[0]*C0[3+bs*3]; CC[3+bs*3] = beta[0]*C1[0+bs*3]; } else if(offsetC==2) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[2+bs*0]; CC[1+bs*0] = beta[0]*C0[3+bs*0]; CC[2+bs*0] = beta[0]*C1[0+bs*0]; CC[3+bs*0] = beta[0]*C1[1+bs*0]; CC[0+bs*1] = beta[0]*C0[2+bs*1]; CC[1+bs*1] = beta[0]*C0[3+bs*1]; CC[2+bs*1] = beta[0]*C1[0+bs*1]; CC[3+bs*1] = beta[0]*C1[1+bs*1]; CC[0+bs*2] = beta[0]*C0[2+bs*2]; CC[1+bs*2] = beta[0]*C0[3+bs*2]; CC[2+bs*2] = beta[0]*C1[0+bs*2]; CC[3+bs*2] = beta[0]*C1[1+bs*2]; CC[0+bs*3] = beta[0]*C0[2+bs*3]; CC[1+bs*3] = beta[0]*C0[3+bs*3]; CC[2+bs*3] = beta[0]*C1[0+bs*3]; CC[3+bs*3] = beta[0]*C1[1+bs*3]; } else //if(offsetC==3) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[3+bs*0]; CC[1+bs*0] = beta[0]*C1[0+bs*0]; CC[2+bs*0] = beta[0]*C1[1+bs*0]; CC[3+bs*0] = beta[0]*C1[2+bs*0]; CC[0+bs*1] = beta[0]*C0[3+bs*1]; CC[1+bs*1] = beta[0]*C1[0+bs*1]; CC[2+bs*1] = beta[0]*C1[1+bs*1]; CC[3+bs*1] = beta[0]*C1[2+bs*1]; CC[0+bs*2] = beta[0]*C0[3+bs*2]; CC[1+bs*2] = beta[0]*C1[0+bs*2]; CC[2+bs*2] = beta[0]*C1[1+bs*2]; CC[3+bs*2] = beta[0]*C1[2+bs*2]; CC[0+bs*3] = beta[0]*C0[3+bs*3]; CC[1+bs*3] = beta[0]*C1[0+bs*3]; CC[2+bs*3] = beta[0]*C1[1+bs*3]; CC[3+bs*3] = beta[0]*C1[2+bs*3]; } float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, alpha, A, offsetB, B, sdb, &beta1, CC, CC); // shift sol for cols if(n0>0) { if(n0==1) { CC[0+bs*0] = CC[0+bs*1]; CC[1+bs*0] = CC[1+bs*1]; CC[2+bs*0] = CC[2+bs*1]; CC[3+bs*0] = CC[3+bs*1]; CC[0+bs*1] = CC[0+bs*2]; CC[1+bs*1] = CC[1+bs*2]; CC[2+bs*1] = CC[2+bs*2]; CC[3+bs*1] = CC[3+bs*2]; CC[0+bs*2] = CC[0+bs*3]; CC[1+bs*2] = CC[1+bs*3]; CC[2+bs*2] = CC[2+bs*3]; CC[3+bs*2] = CC[3+bs*3]; D0 += 1*bs; } else if(n0==2) { CC[0+bs*0] = CC[0+bs*2]; CC[1+bs*0] = CC[1+bs*2]; CC[2+bs*0] = CC[2+bs*2]; CC[3+bs*0] = CC[3+bs*2]; CC[0+bs*1] = CC[0+bs*3]; CC[1+bs*1] = CC[1+bs*3]; CC[2+bs*1] = CC[2+bs*3]; CC[3+bs*1] = CC[3+bs*3]; D0 += 2*bs; } else //if(n0==3) { CC[0+bs*0] = CC[0+bs*3]; CC[1+bs*0] = CC[1+bs*3]; CC[2+bs*0] = CC[2+bs*3]; CC[3+bs*0] = CC[3+bs*3]; D0 += 3*bs; } } n1 = 4<n1 ? 4 : n1; int kn = n1 - n0; if(offsetD==0) { if(kn<=0) return; if(m0<=0 & m1>0) D0[0+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[1+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D0[2+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D0[3+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[0+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[1+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D0[2+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D0[3+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[0+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[1+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D0[2+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D0[3+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[0+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[1+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D0[2+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D0[3+bs*3] = CC[3+bs*3]; } else if(offsetD==1) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[1+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[2+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D0[3+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[0+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[1+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[2+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D0[3+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[0+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[1+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[2+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D0[3+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[0+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[1+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[2+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D0[3+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[0+bs*3] = CC[3+bs*3]; } else if(offsetD==2) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[2+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[3+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D1[0+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[1+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[2+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[3+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D1[0+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[1+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[2+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[3+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D1[0+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[1+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[2+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[3+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D1[0+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[1+bs*3] = CC[3+bs*3]; } else //if(offsetD==3) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[3+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D1[0+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D1[1+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[2+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[3+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D1[0+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D1[1+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[2+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[3+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D1[0+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D1[1+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[2+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[3+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D1[0+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D1[1+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[2+bs*3] = CC[3+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) //|| defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_ssyrk_nt_l_4x4_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif kernel_sgemm_nt_4x4_lib4(kmax, alpha, A, B, beta, C, CC); D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) //|| defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_ssyrk_nt_l_4x4_vs_lib4(int kmax, float *alpha, float *A, float *B, float *beta, float *C, float *D, int km, int kn) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif kernel_sgemm_nt_4x4_lib4(kmax, alpha, A, B, beta, C, CC); if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[2+bs*2] = CC[2+bs*2]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[1+bs*1] = CC[1+bs*1]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_ssyrk_nt_l_4x4_gen_lib4(int kmax, float *alpha, float *A, float *B, float *beta, int offsetC, float *C0, int sdc, int offsetD, float *D0, int sdd, int m0, int m1, int n0, int n1) { const int bs = 4; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *C1, *D1; if(offsetC==0) { CC[0+bs*0] = beta[0]*C0[0+bs*0]; CC[1+bs*0] = beta[0]*C0[1+bs*0]; CC[2+bs*0] = beta[0]*C0[2+bs*0]; CC[3+bs*0] = beta[0]*C0[3+bs*0]; CC[1+bs*1] = beta[0]*C0[1+bs*1]; CC[2+bs*1] = beta[0]*C0[2+bs*1]; CC[3+bs*1] = beta[0]*C0[3+bs*1]; CC[2+bs*2] = beta[0]*C0[2+bs*2]; CC[3+bs*2] = beta[0]*C0[3+bs*2]; CC[3+bs*3] = beta[0]*C0[3+bs*3]; } else if(offsetC==1) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[1+bs*0]; CC[1+bs*0] = beta[0]*C0[2+bs*0]; CC[2+bs*0] = beta[0]*C0[3+bs*0]; CC[3+bs*0] = beta[0]*C1[0+bs*0]; CC[1+bs*1] = beta[0]*C0[2+bs*1]; CC[2+bs*1] = beta[0]*C0[3+bs*1]; CC[3+bs*1] = beta[0]*C1[0+bs*1]; CC[2+bs*2] = beta[0]*C0[3+bs*2]; CC[3+bs*2] = beta[0]*C1[0+bs*2]; CC[3+bs*3] = beta[0]*C1[0+bs*3]; } else if(offsetC==2) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[2+bs*0]; CC[1+bs*0] = beta[0]*C0[3+bs*0]; CC[2+bs*0] = beta[0]*C1[0+bs*0]; CC[3+bs*0] = beta[0]*C1[1+bs*0]; CC[1+bs*1] = beta[0]*C0[3+bs*1]; CC[2+bs*1] = beta[0]*C1[0+bs*1]; CC[3+bs*1] = beta[0]*C1[1+bs*1]; CC[2+bs*2] = beta[0]*C1[0+bs*2]; CC[3+bs*2] = beta[0]*C1[1+bs*2]; CC[3+bs*3] = beta[0]*C1[1+bs*3]; } else //if(offsetC==3) { C1 = C0 + sdc*bs; CC[0+bs*0] = beta[0]*C0[3+bs*0]; CC[1+bs*0] = beta[0]*C1[0+bs*0]; CC[2+bs*0] = beta[0]*C1[1+bs*0]; CC[3+bs*0] = beta[0]*C1[2+bs*0]; CC[1+bs*1] = beta[0]*C1[0+bs*1]; CC[2+bs*1] = beta[0]*C1[1+bs*1]; CC[3+bs*1] = beta[0]*C1[2+bs*1]; CC[2+bs*2] = beta[0]*C1[1+bs*2]; CC[3+bs*2] = beta[0]*C1[2+bs*2]; CC[3+bs*3] = beta[0]*C1[2+bs*3]; } float beta1 = 1.0; kernel_sgemm_nt_4x4_lib4(kmax, alpha, A, B, &beta1, CC, CC); // shift sol for cols if(n0>0) { if(n0==1) { CC[0+bs*0] = CC[0+bs*1]; CC[1+bs*0] = CC[1+bs*1]; CC[2+bs*0] = CC[2+bs*1]; CC[3+bs*0] = CC[3+bs*1]; CC[0+bs*1] = CC[0+bs*2]; CC[1+bs*1] = CC[1+bs*2]; CC[2+bs*1] = CC[2+bs*2]; CC[3+bs*1] = CC[3+bs*2]; CC[0+bs*2] = CC[0+bs*3]; CC[1+bs*2] = CC[1+bs*3]; CC[2+bs*2] = CC[2+bs*3]; CC[3+bs*2] = CC[3+bs*3]; D0 += 1*bs; } else if(n0==2) { CC[0+bs*0] = CC[0+bs*2]; CC[1+bs*0] = CC[1+bs*2]; CC[2+bs*0] = CC[2+bs*2]; CC[3+bs*0] = CC[3+bs*2]; CC[0+bs*1] = CC[0+bs*3]; CC[1+bs*1] = CC[1+bs*3]; CC[2+bs*1] = CC[2+bs*3]; CC[3+bs*1] = CC[3+bs*3]; D0 += 2*bs; } else //if(n0==3) { CC[0+bs*0] = CC[0+bs*3]; CC[1+bs*0] = CC[1+bs*3]; CC[2+bs*0] = CC[2+bs*3]; CC[3+bs*0] = CC[3+bs*3]; D0 += 3*bs; } } n1 = 4<n1 ? 4 : n1; int kn = n1 - n0; if(offsetD==0) { if(m0<=0) { if(kn<=0) return; if(m1>0) D0[0+bs*0] = CC[0+bs*0]; if(m1>1) D0[1+bs*0] = CC[1+bs*0]; if(m1>2) D0[2+bs*0] = CC[2+bs*0]; if(m1>3) D0[3+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>1) D0[1+bs*1] = CC[1+bs*1]; if(m1>2) D0[2+bs*1] = CC[2+bs*1]; if(m1>3) D0[3+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>2) D0[2+bs*2] = CC[2+bs*2]; if(m1>3) D0[3+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m1>3) D0[3+bs*3] = CC[3+bs*3]; } else if(m0<=1) { if(kn<=0) return; if(m1>1) D0[1+bs*0] = CC[1+bs*0]; if(m1>2) D0[2+bs*0] = CC[2+bs*0]; if(m1>3) D0[3+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>2) D0[2+bs*1] = CC[2+bs*1]; if(m1>3) D0[3+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>3) D0[3+bs*2] = CC[3+bs*2]; } else if(m0<=2) { if(kn<=0) return; if(m1>2) D0[2+bs*0] = CC[2+bs*0]; if(m1>3) D0[3+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>3) D0[3+bs*1] = CC[3+bs*1]; } else if(m0<=3) { if(kn<=0) return; if(m1>3) D0[3+bs*0] = CC[3+bs*0]; } } else if(offsetD==1) { D1 = D0 + sdd*bs; if(m0<=0) { if(kn<=0) return; if(m1>0) D0[1+bs*0] = CC[0+bs*0]; if(m1>1) D0[2+bs*0] = CC[1+bs*0]; if(m1>2) D0[3+bs*0] = CC[2+bs*0]; if(m1>3) D1[0+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>1) D0[2+bs*1] = CC[1+bs*1]; if(m1>2) D0[3+bs*1] = CC[2+bs*1]; if(m1>3) D1[0+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>2) D0[3+bs*2] = CC[2+bs*2]; if(m1>3) D1[0+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m1>3) D1[0+bs*3] = CC[3+bs*3]; } else if(m0<=1) { if(kn<=0) return; if(m1>1) D0[2+bs*0] = CC[1+bs*0]; if(m1>2) D0[3+bs*0] = CC[2+bs*0]; if(m1>3) D1[0+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>2) D0[3+bs*1] = CC[2+bs*1]; if(m1>3) D1[0+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>3) D1[0+bs*2] = CC[3+bs*2]; } else if(m0<=2) { if(kn<=0) return; if(m1>2) D0[3+bs*0] = CC[2+bs*0]; if(m1>3) D1[0+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>3) D1[0+bs*1] = CC[3+bs*1]; } else if(m0<=3) { if(kn<=0) return; if(m1>3) D1[0+bs*0] = CC[3+bs*0]; } } else if(offsetD==2) { D1 = D0 + sdd*bs; if(m0<=0) { if(kn<=0) return; if(m1>0) D0[2+bs*0] = CC[0+bs*0]; if(m1>1) D0[3+bs*0] = CC[1+bs*0]; if(m1>2) D1[0+bs*0] = CC[2+bs*0]; if(m1>3) D1[1+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>1) D0[3+bs*1] = CC[1+bs*1]; if(m1>2) D1[0+bs*1] = CC[2+bs*1]; if(m1>3) D1[1+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>2) D1[0+bs*2] = CC[2+bs*2]; if(m1>3) D1[1+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m1>3) D1[1+bs*3] = CC[3+bs*3]; } else if(m0<=1) { if(kn<=0) return; if(m1>1) D0[3+bs*0] = CC[1+bs*0]; if(m1>2) D1[0+bs*0] = CC[2+bs*0]; if(m1>3) D1[1+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>2) D1[0+bs*1] = CC[2+bs*1]; if(m1>3) D1[1+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>3) D1[1+bs*2] = CC[3+bs*2]; } else if(m0<=2) { if(kn<=0) return; if(m1>2) D1[0+bs*0] = CC[2+bs*0]; if(m1>3) D1[1+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>3) D1[1+bs*1] = CC[3+bs*1]; } else if(m0<=3) { if(kn<=0) return; if(m1>3) D1[1+bs*0] = CC[3+bs*0]; } } else //if(offsetD==3) { D1 = D0 + sdd*bs; if(m0<=0) { if(kn<=0) return; if(m1>0) D0[3+bs*0] = CC[0+bs*0]; if(m1>1) D1[0+bs*0] = CC[1+bs*0]; if(m1>2) D1[1+bs*0] = CC[2+bs*0]; if(m1>3) D1[2+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>1) D1[0+bs*1] = CC[1+bs*1]; if(m1>2) D1[1+bs*1] = CC[2+bs*1]; if(m1>3) D1[2+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>2) D1[1+bs*2] = CC[2+bs*2]; if(m1>3) D1[2+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m1>3) D1[2+bs*3] = CC[3+bs*3]; } else if(m0<=1) { if(kn<=0) return; if(m1>1) D1[0+bs*0] = CC[1+bs*0]; if(m1>2) D1[1+bs*0] = CC[2+bs*0]; if(m1>3) D1[2+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>2) D1[1+bs*1] = CC[2+bs*1]; if(m1>3) D1[2+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m1>3) D1[2+bs*2] = CC[3+bs*2]; } else if(m0<=2) { if(kn<=0) return; if(m1>2) D1[1+bs*0] = CC[2+bs*0]; if(m1>3) D1[2+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m1>3) D1[2+bs*1] = CC[3+bs*1]; } else if(m0<=3) { if(kn<=0) return; if(m1>3) D1[2+bs*0] = CC[3+bs*0]; } } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strmm_nt_ru_4x4_lib4(int kmax, float *alpha, float *A, float *B, float *D) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif int k; k = 0; // k = 0 if(kmax>0) { a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 4; k++; } // k = 1 if(kmax>1) { a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[1]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 4; k++; } // k = 2 if(kmax>2) { a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[1]; b_2 = B[2]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 4; k++; } kernel_sgemm_nt_4x4_lib4(kmax-k, alpha, A, B, alpha, CC, D); return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strmm_nt_ru_4x4_vs_lib4(int kmax, float *alpha, float *A, float *B, float *D, int km, int kn) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif int k; k = 0; // k = 0 if(kmax>0) { a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 4; k++; } // k = 1 if(kmax>1) { a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[1]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 4; k++; } // k = 2 if(kmax>2) { a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; b_1 = B[1]; b_2 = B[2]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 4; k++; } kernel_sgemm_nt_4x4_lib4(kmax-k, alpha, A, B, alpha, CC, CC); if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strmm_nn_rl_4x4_lib4(int kmax, float *alpha, float *A, int offsetB, float *B, int sdb, float *D) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *D1; int k; B += offsetB; k = 0; if(offsetB==0) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } else if(offsetB==1) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 4*sdb-3; k += 1; } else if(offsetB==2) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 4*sdb-3; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 4 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 5 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } else // if(offetB==3) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 4*sdb-3; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 4 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } store: CC[0+bs*0] = alpha[0]*CC[0+bs*0]; CC[1+bs*0] = alpha[0]*CC[1+bs*0]; CC[2+bs*0] = alpha[0]*CC[2+bs*0]; CC[3+bs*0] = alpha[0]*CC[3+bs*0]; CC[0+bs*1] = alpha[0]*CC[0+bs*1]; CC[1+bs*1] = alpha[0]*CC[1+bs*1]; CC[2+bs*1] = alpha[0]*CC[2+bs*1]; CC[3+bs*1] = alpha[0]*CC[3+bs*1]; CC[0+bs*2] = alpha[0]*CC[0+bs*2]; CC[1+bs*2] = alpha[0]*CC[1+bs*2]; CC[2+bs*2] = alpha[0]*CC[2+bs*2]; CC[3+bs*2] = alpha[0]*CC[3+bs*2]; CC[0+bs*3] = alpha[0]*CC[0+bs*3]; CC[1+bs*3] = alpha[0]*CC[1+bs*3]; CC[2+bs*3] = alpha[0]*CC[2+bs*3]; CC[3+bs*3] = alpha[0]*CC[3+bs*3]; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax-k, alpha, A, 0, B, sdb, &beta1, CC, D); return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strmm_nn_rl_4x4_vs_lib4(int kmax, float *alpha, float *A, int offsetB, float *B, int sdb, float *D, int m1, int n1) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *D1; int k; B += offsetB; k = 0; if(offsetB==0) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } else if(offsetB==1) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 4*sdb-3; k += 1; } else if(offsetB==2) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 4*sdb-3; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 4 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 5 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } else // if(offetB==3) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 4*sdb-3; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 4 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } store: CC[0+bs*0] = alpha[0]*CC[0+bs*0]; CC[1+bs*0] = alpha[0]*CC[1+bs*0]; CC[2+bs*0] = alpha[0]*CC[2+bs*0]; CC[3+bs*0] = alpha[0]*CC[3+bs*0]; CC[0+bs*1] = alpha[0]*CC[0+bs*1]; CC[1+bs*1] = alpha[0]*CC[1+bs*1]; CC[2+bs*1] = alpha[0]*CC[2+bs*1]; CC[3+bs*1] = alpha[0]*CC[3+bs*1]; CC[0+bs*2] = alpha[0]*CC[0+bs*2]; CC[1+bs*2] = alpha[0]*CC[1+bs*2]; CC[2+bs*2] = alpha[0]*CC[2+bs*2]; CC[3+bs*2] = alpha[0]*CC[3+bs*2]; CC[0+bs*3] = alpha[0]*CC[0+bs*3]; CC[1+bs*3] = alpha[0]*CC[1+bs*3]; CC[2+bs*3] = alpha[0]*CC[2+bs*3]; CC[3+bs*3] = alpha[0]*CC[3+bs*3]; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax-k, alpha, A, 0, B, sdb, &beta1, CC, CC); if(m1>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(n1==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(n1==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(n1==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(m1>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(n1==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(n1==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(n1==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(m1>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(n1==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(n1==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(n1==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(m1>=1) { D[0+bs*0] = CC[0+bs*0]; if(n1==1) return; D[0+bs*1] = CC[0+bs*1]; if(n1==2) return; D[0+bs*2] = CC[0+bs*2]; if(n1==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strmm_nn_rl_4x4_gen_lib4(int kmax, float *alpha, float *A, int offsetB, float *B, int sdb, int offsetD, float *D0, int sdd, int m0, int m1, int n0, int n1) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float *D1; int k; B += offsetB; k = 0; if(offsetB==0) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } else if(offsetB==1) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 4*sdb-3; k += 1; } else if(offsetB==2) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 4*sdb-3; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 4 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 5 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } else // if(offetB==3) { // k = 0 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; A += 4; B += 4*sdb-3; k += 1; if(k>=kmax) goto store; // k = 1 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 2 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 3 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 1; k += 1; if(k>=kmax) goto store; // k = 4 a_0 = A[0]; a_1 = A[1]; a_2 = A[2]; a_3 = A[3]; b_0 = B[0]; CC[0+bs*0] += a_0 * b_0; CC[1+bs*0] += a_1 * b_0; CC[2+bs*0] += a_2 * b_0; CC[3+bs*0] += a_3 * b_0; b_1 = B[4]; CC[0+bs*1] += a_0 * b_1; CC[1+bs*1] += a_1 * b_1; CC[2+bs*1] += a_2 * b_1; CC[3+bs*1] += a_3 * b_1; b_2 = B[8]; CC[0+bs*2] += a_0 * b_2; CC[1+bs*2] += a_1 * b_2; CC[2+bs*2] += a_2 * b_2; CC[3+bs*2] += a_3 * b_2; b_3 = B[12]; CC[0+bs*3] += a_0 * b_3; CC[1+bs*3] += a_1 * b_3; CC[2+bs*3] += a_2 * b_3; CC[3+bs*3] += a_3 * b_3; A += 4; B += 4*sdb-3; k += 1; } store: CC[0+bs*0] = alpha[0]*CC[0+bs*0]; CC[1+bs*0] = alpha[0]*CC[1+bs*0]; CC[2+bs*0] = alpha[0]*CC[2+bs*0]; CC[3+bs*0] = alpha[0]*CC[3+bs*0]; CC[0+bs*1] = alpha[0]*CC[0+bs*1]; CC[1+bs*1] = alpha[0]*CC[1+bs*1]; CC[2+bs*1] = alpha[0]*CC[2+bs*1]; CC[3+bs*1] = alpha[0]*CC[3+bs*1]; CC[0+bs*2] = alpha[0]*CC[0+bs*2]; CC[1+bs*2] = alpha[0]*CC[1+bs*2]; CC[2+bs*2] = alpha[0]*CC[2+bs*2]; CC[3+bs*2] = alpha[0]*CC[3+bs*2]; CC[0+bs*3] = alpha[0]*CC[0+bs*3]; CC[1+bs*3] = alpha[0]*CC[1+bs*3]; CC[2+bs*3] = alpha[0]*CC[2+bs*3]; CC[3+bs*3] = alpha[0]*CC[3+bs*3]; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax-k, alpha, A, 0, B, sdb, &beta1, CC, CC); // shift sol for cols if(n0>0) { if(n0==1) { CC[0+bs*0] = CC[0+bs*1]; CC[1+bs*0] = CC[1+bs*1]; CC[2+bs*0] = CC[2+bs*1]; CC[3+bs*0] = CC[3+bs*1]; CC[0+bs*1] = CC[0+bs*2]; CC[1+bs*1] = CC[1+bs*2]; CC[2+bs*1] = CC[2+bs*2]; CC[3+bs*1] = CC[3+bs*2]; CC[0+bs*2] = CC[0+bs*3]; CC[1+bs*2] = CC[1+bs*3]; CC[2+bs*2] = CC[2+bs*3]; CC[3+bs*2] = CC[3+bs*3]; D0 += 1*bs; } else if(n0==2) { CC[0+bs*0] = CC[0+bs*2]; CC[1+bs*0] = CC[1+bs*2]; CC[2+bs*0] = CC[2+bs*2]; CC[3+bs*0] = CC[3+bs*2]; CC[0+bs*1] = CC[0+bs*3]; CC[1+bs*1] = CC[1+bs*3]; CC[2+bs*1] = CC[2+bs*3]; CC[3+bs*1] = CC[3+bs*3]; D0 += 2*bs; } else //if(n0==3) { CC[0+bs*0] = CC[0+bs*3]; CC[1+bs*0] = CC[1+bs*3]; CC[2+bs*0] = CC[2+bs*3]; CC[3+bs*0] = CC[3+bs*3]; D0 += 3*bs; } } n1 = 4<n1 ? 4 : n1; int kn = n1 - n0; if(offsetD==0) { if(kn<=0) return; if(m0<=0 & m1>0) D0[0+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[1+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D0[2+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D0[3+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[0+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[1+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D0[2+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D0[3+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[0+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[1+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D0[2+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D0[3+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[0+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[1+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D0[2+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D0[3+bs*3] = CC[3+bs*3]; } else if(offsetD==1) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[1+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[2+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D0[3+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[0+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[1+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[2+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D0[3+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[0+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[1+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[2+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D0[3+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[0+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[1+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[2+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D0[3+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[0+bs*3] = CC[3+bs*3]; } else if(offsetD==2) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[2+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D0[3+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D1[0+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[1+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[2+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D0[3+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D1[0+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[1+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[2+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D0[3+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D1[0+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[1+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[2+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D0[3+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D1[0+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[1+bs*3] = CC[3+bs*3]; } else //if(offsetD==3) { D1 = D0 + sdd*bs; if(kn<=0) return; if(m0<=0 & m1>0) D0[3+bs*0] = CC[0+bs*0]; if(m0<=1 & m1>1) D1[0+bs*0] = CC[1+bs*0]; if(m0<=2 & m1>2) D1[1+bs*0] = CC[2+bs*0]; if(m0<=3 & m1>3) D1[2+bs*0] = CC[3+bs*0]; if(kn<=1) return; if(m0<=0 & m1>0) D0[3+bs*1] = CC[0+bs*1]; if(m0<=1 & m1>1) D1[0+bs*1] = CC[1+bs*1]; if(m0<=2 & m1>2) D1[1+bs*1] = CC[2+bs*1]; if(m0<=3 & m1>3) D1[2+bs*1] = CC[3+bs*1]; if(kn<=2) return; if(m0<=0 & m1>0) D0[3+bs*2] = CC[0+bs*2]; if(m0<=1 & m1>1) D1[0+bs*2] = CC[1+bs*2]; if(m0<=2 & m1>2) D1[1+bs*2] = CC[2+bs*2]; if(m0<=3 & m1>3) D1[2+bs*2] = CC[3+bs*2]; if(kn<=3) return; if(m0<=0 & m1>0) D0[3+bs*3] = CC[0+bs*3]; if(m0<=1 & m1>1) D1[0+bs*3] = CC[1+bs*3]; if(m0<=2 & m1>2) D1[1+bs*3] = CC[2+bs*3]; if(m0<=3 & m1>3) D1[2+bs*3] = CC[3+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) void kernel_spotrf_nt_l_4x4_lib4(int kmax, float *A, float *B, float *C, float *D, float *inv_diag_D) { const int bs = 4; float a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3, tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif int k; float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, &beta1, C, CC); if(CC[0+bs*0]>0) { CC[0+bs*0] = sqrtf(CC[0+bs*0]); tmp = 1.0/CC[0+bs*0]; } else { CC[0+bs*0] = 0.0; tmp = 0.0; } CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; inv_diag_D[0] = tmp; CC[1+bs*1] -= CC[1+bs*0] * CC[1+bs*0]; CC[2+bs*1] -= CC[2+bs*0] * CC[1+bs*0]; CC[3+bs*1] -= CC[3+bs*0] * CC[1+bs*0]; if(CC[1+bs*1]>0) { CC[1+bs*1] = sqrtf(CC[1+bs*1]); tmp = 1.0/CC[1+bs*1]; } else { CC[1+bs*1] = 0.0; tmp = 0.0; } CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; inv_diag_D[1] = tmp; CC[2+bs*2] -= CC[2+bs*0] * CC[2+bs*0]; CC[3+bs*2] -= CC[3+bs*0] * CC[2+bs*0]; CC[2+bs*2] -= CC[2+bs*1] * CC[2+bs*1]; CC[3+bs*2] -= CC[3+bs*1] * CC[2+bs*1]; if(CC[2+bs*2]>0) { CC[2+bs*2] = sqrtf(CC[2+bs*2]); tmp = 1.0/CC[2+bs*2]; } else { CC[2+bs*2] = 0.0; tmp = 0.0; } CC[3+bs*2] *= tmp; inv_diag_D[2] = tmp; CC[3+bs*3] -= CC[3+bs*0] * CC[3+bs*0]; CC[3+bs*3] -= CC[3+bs*1] * CC[3+bs*1]; CC[3+bs*3] -= CC[3+bs*2] * CC[3+bs*2]; if(CC[3+bs*3]>0) { CC[3+bs*3] = sqrtf(CC[3+bs*3]); tmp = 1.0/CC[3+bs*3]; } else { CC[3+bs*3] = 0.0; tmp = 0.0; } inv_diag_D[3] = tmp; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) //|| defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_spotrf_nt_l_4x4_vs_lib4(int kmax, float *A, float *B, float *C, float *D, float *inv_diag_D, int km, int kn) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, &beta1, C, CC); if(CC[0+bs*0]>0) { CC[0+bs*0] = sqrtf(CC[0+bs*0]); tmp = 1.0/CC[0+bs*0]; } else { CC[0+bs*0] = 0.0; tmp = 0.0; } CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; inv_diag_D[0] = tmp; if(kn==1) goto store; CC[1+bs*1] -= CC[1+bs*0] * CC[1+bs*0]; CC[2+bs*1] -= CC[2+bs*0] * CC[1+bs*0]; CC[3+bs*1] -= CC[3+bs*0] * CC[1+bs*0]; if(CC[1+bs*1]>0) { CC[1+bs*1] = sqrtf(CC[1+bs*1]); tmp = 1.0/CC[1+bs*1]; } else { CC[1+bs*1] = 0.0; tmp = 0.0; } CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; inv_diag_D[1] = tmp; if(kn==2) goto store; CC[2+bs*2] -= CC[2+bs*0] * CC[2+bs*0]; CC[3+bs*2] -= CC[3+bs*0] * CC[2+bs*0]; CC[2+bs*2] -= CC[2+bs*1] * CC[2+bs*1]; CC[3+bs*2] -= CC[3+bs*1] * CC[2+bs*1]; if(CC[2+bs*2]>0) { CC[2+bs*2] = sqrtf(CC[2+bs*2]); tmp = 1.0/CC[2+bs*2]; } else { CC[2+bs*2] = 0.0; tmp = 0.0; } CC[3+bs*2] *= tmp; inv_diag_D[2] = tmp; if(kn==3) goto store; CC[3+bs*3] -= CC[3+bs*0] * CC[3+bs*0]; CC[3+bs*3] -= CC[3+bs*1] * CC[3+bs*1]; CC[3+bs*3] -= CC[3+bs*2] * CC[3+bs*2]; if(CC[3+bs*3]>0) { CC[3+bs*3] = sqrtf(CC[3+bs*3]); tmp = 1.0/CC[3+bs*3]; } else { CC[3+bs*3] = 0.0; tmp = 0.0; } inv_diag_D[3] = tmp; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[2+bs*2] = CC[2+bs*2]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[1+bs*1] = CC[1+bs*1]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_ssyrk_spotrf_nt_l_4x4_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D) { float alpha = 1.0; float beta = 1.0; kernel_ssyrk_nt_l_4x4_lib4(kp, &alpha, Ap, Bp, &beta, C, D); kernel_spotrf_nt_l_4x4_lib4(km_, Am, Bm, D, D, inv_diag_D); } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_ssyrk_spotrf_nt_l_4x4_vs_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *inv_diag_D, int km, int kn) { float alpha = 1.0; float beta = 1.0; kernel_ssyrk_nt_l_4x4_vs_lib4(kp, &alpha, Ap, Bp, &beta, C, D, km, kn); kernel_spotrf_nt_l_4x4_vs_lib4(km_, Am, Bm, D, D, inv_diag_D, km, kn); } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) void kernel_strsm_nt_rl_inv_4x4_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); tmp = inv_diag_E[0]; CC[0+bs*0] *= tmp; CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; tmp = E[1+bs*0]; CC[0+bs*1] -= CC[0+bs*0] * tmp; CC[1+bs*1] -= CC[1+bs*0] * tmp; CC[2+bs*1] -= CC[2+bs*0] * tmp; CC[3+bs*1] -= CC[3+bs*0] * tmp; tmp = inv_diag_E[1]; CC[0+bs*1] *= tmp; CC[1+bs*1] *= tmp; CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; tmp = E[2+bs*0]; CC[0+bs*2] -= CC[0+bs*0] * tmp; CC[1+bs*2] -= CC[1+bs*0] * tmp; CC[2+bs*2] -= CC[2+bs*0] * tmp; CC[3+bs*2] -= CC[3+bs*0] * tmp; tmp = E[2+bs*1]; CC[0+bs*2] -= CC[0+bs*1] * tmp; CC[1+bs*2] -= CC[1+bs*1] * tmp; CC[2+bs*2] -= CC[2+bs*1] * tmp; CC[3+bs*2] -= CC[3+bs*1] * tmp; tmp = inv_diag_E[2]; CC[0+bs*2] *= tmp; CC[1+bs*2] *= tmp; CC[2+bs*2] *= tmp; CC[3+bs*2] *= tmp; tmp = E[3+bs*0]; CC[0+bs*3] -= CC[0+bs*0] * tmp; CC[1+bs*3] -= CC[1+bs*0] * tmp; CC[2+bs*3] -= CC[2+bs*0] * tmp; CC[3+bs*3] -= CC[3+bs*0] * tmp; tmp = E[3+bs*1]; CC[0+bs*3] -= CC[0+bs*1] * tmp; CC[1+bs*3] -= CC[1+bs*1] * tmp; CC[2+bs*3] -= CC[2+bs*1] * tmp; CC[3+bs*3] -= CC[3+bs*1] * tmp; tmp = E[3+bs*2]; CC[0+bs*3] -= CC[0+bs*2] * tmp; CC[1+bs*3] -= CC[1+bs*2] * tmp; CC[2+bs*3] -= CC[2+bs*2] * tmp; CC[3+bs*3] -= CC[3+bs*2] * tmp; tmp = inv_diag_E[3]; CC[0+bs*3] *= tmp; CC[1+bs*3] *= tmp; CC[2+bs*3] *= tmp; CC[3+bs*3] *= tmp; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_rl_inv_4x4_vs_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E, int km, int kn) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); tmp = inv_diag_E[0]; CC[0+bs*0] *= tmp; CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; if(kn==1) goto store; tmp = E[1+bs*0]; CC[0+bs*1] -= CC[0+bs*0] * tmp; CC[1+bs*1] -= CC[1+bs*0] * tmp; CC[2+bs*1] -= CC[2+bs*0] * tmp; CC[3+bs*1] -= CC[3+bs*0] * tmp; tmp = inv_diag_E[1]; CC[0+bs*1] *= tmp; CC[1+bs*1] *= tmp; CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; if(kn==2) goto store; tmp = E[2+bs*0]; CC[0+bs*2] -= CC[0+bs*0] * tmp; CC[1+bs*2] -= CC[1+bs*0] * tmp; CC[2+bs*2] -= CC[2+bs*0] * tmp; CC[3+bs*2] -= CC[3+bs*0] * tmp; tmp = E[2+bs*1]; CC[0+bs*2] -= CC[0+bs*1] * tmp; CC[1+bs*2] -= CC[1+bs*1] * tmp; CC[2+bs*2] -= CC[2+bs*1] * tmp; CC[3+bs*2] -= CC[3+bs*1] * tmp; tmp = inv_diag_E[2]; CC[0+bs*2] *= tmp; CC[1+bs*2] *= tmp; CC[2+bs*2] *= tmp; CC[3+bs*2] *= tmp; if(kn==3) goto store; tmp = E[3+bs*0]; CC[0+bs*3] -= CC[0+bs*0] * tmp; CC[1+bs*3] -= CC[1+bs*0] * tmp; CC[2+bs*3] -= CC[2+bs*0] * tmp; CC[3+bs*3] -= CC[3+bs*0] * tmp; tmp = E[3+bs*1]; CC[0+bs*3] -= CC[0+bs*1] * tmp; CC[1+bs*3] -= CC[1+bs*1] * tmp; CC[2+bs*3] -= CC[2+bs*1] * tmp; CC[3+bs*3] -= CC[3+bs*1] * tmp; tmp = E[3+bs*2]; CC[0+bs*3] -= CC[0+bs*2] * tmp; CC[1+bs*3] -= CC[1+bs*2] * tmp; CC[2+bs*3] -= CC[2+bs*2] * tmp; CC[3+bs*3] -= CC[3+bs*2] * tmp; tmp = inv_diag_E[3]; CC[0+bs*3] *= tmp; CC[1+bs*3] *= tmp; CC[2+bs*3] *= tmp; CC[3+bs*3] *= tmp; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_sgemm_strsm_nt_rl_inv_4x4_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E) { float alpha = 1.0; float beta = 1.0; kernel_sgemm_nt_4x4_lib4(kp, &alpha, Ap, Bp, &beta, C, D); kernel_strsm_nt_rl_inv_4x4_lib4(km_, Am, Bm, &beta, D, D, E, inv_diag_E); } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_sgemm_strsm_nt_rl_inv_4x4_vs_lib4(int kp, float *Ap, float *Bp, int km_, float *Am, float *Bm, float *C, float *D, float *E, float *inv_diag_E, int km, int kn) { float alpha = 1.0; float beta = 1.0; kernel_sgemm_nt_4x4_vs_lib4(kp, &alpha, Ap, Bp, &beta, C, D, km, kn); kernel_strsm_nt_rl_inv_4x4_vs_lib4(km_, Am, Bm, &beta, D, D, E, inv_diag_E, km, kn); } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_rl_one_4x4_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); tmp = E[1+bs*0]; CC[0+bs*1] -= CC[0+bs*0] * tmp; CC[1+bs*1] -= CC[1+bs*0] * tmp; CC[2+bs*1] -= CC[2+bs*0] * tmp; CC[3+bs*1] -= CC[3+bs*0] * tmp; tmp = E[2+bs*0]; CC[0+bs*2] -= CC[0+bs*0] * tmp; CC[1+bs*2] -= CC[1+bs*0] * tmp; CC[2+bs*2] -= CC[2+bs*0] * tmp; CC[3+bs*2] -= CC[3+bs*0] * tmp; tmp = E[2+bs*1]; CC[0+bs*2] -= CC[0+bs*1] * tmp; CC[1+bs*2] -= CC[1+bs*1] * tmp; CC[2+bs*2] -= CC[2+bs*1] * tmp; CC[3+bs*2] -= CC[3+bs*1] * tmp; tmp = E[3+bs*0]; CC[0+bs*3] -= CC[0+bs*0] * tmp; CC[1+bs*3] -= CC[1+bs*0] * tmp; CC[2+bs*3] -= CC[2+bs*0] * tmp; CC[3+bs*3] -= CC[3+bs*0] * tmp; tmp = E[3+bs*1]; CC[0+bs*3] -= CC[0+bs*1] * tmp; CC[1+bs*3] -= CC[1+bs*1] * tmp; CC[2+bs*3] -= CC[2+bs*1] * tmp; CC[3+bs*3] -= CC[3+bs*1] * tmp; tmp = E[3+bs*2]; CC[0+bs*3] -= CC[0+bs*2] * tmp; CC[1+bs*3] -= CC[1+bs*2] * tmp; CC[2+bs*3] -= CC[2+bs*2] * tmp; CC[3+bs*3] -= CC[3+bs*2] * tmp; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_rl_one_4x4_vs_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E, int km, int kn) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); if(kn==1) goto store; tmp = E[1+bs*0]; CC[0+bs*1] -= CC[0+bs*0] * tmp; CC[1+bs*1] -= CC[1+bs*0] * tmp; CC[2+bs*1] -= CC[2+bs*0] * tmp; CC[3+bs*1] -= CC[3+bs*0] * tmp; if(kn==2) goto store; tmp = E[2+bs*0]; CC[0+bs*2] -= CC[0+bs*0] * tmp; CC[1+bs*2] -= CC[1+bs*0] * tmp; CC[2+bs*2] -= CC[2+bs*0] * tmp; CC[3+bs*2] -= CC[3+bs*0] * tmp; tmp = E[2+bs*1]; CC[0+bs*2] -= CC[0+bs*1] * tmp; CC[1+bs*2] -= CC[1+bs*1] * tmp; CC[2+bs*2] -= CC[2+bs*1] * tmp; CC[3+bs*2] -= CC[3+bs*1] * tmp; if(kn==3) goto store; tmp = E[3+bs*0]; CC[0+bs*3] -= CC[0+bs*0] * tmp; CC[1+bs*3] -= CC[1+bs*0] * tmp; CC[2+bs*3] -= CC[2+bs*0] * tmp; CC[3+bs*3] -= CC[3+bs*0] * tmp; tmp = E[3+bs*1]; CC[0+bs*3] -= CC[0+bs*1] * tmp; CC[1+bs*3] -= CC[1+bs*1] * tmp; CC[2+bs*3] -= CC[2+bs*1] * tmp; CC[3+bs*3] -= CC[3+bs*1] * tmp; tmp = E[3+bs*2]; CC[0+bs*3] -= CC[0+bs*2] * tmp; CC[1+bs*3] -= CC[1+bs*2] * tmp; CC[2+bs*3] -= CC[2+bs*2] * tmp; CC[3+bs*3] -= CC[3+bs*2] * tmp; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_ru_inv_4x4_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); tmp = inv_diag_E[3]; CC[0+bs*3] *= tmp; CC[1+bs*3] *= tmp; CC[2+bs*3] *= tmp; CC[3+bs*3] *= tmp; tmp = E[2+bs*3]; CC[0+bs*2] -= CC[0+bs*3] * tmp; CC[1+bs*2] -= CC[1+bs*3] * tmp; CC[2+bs*2] -= CC[2+bs*3] * tmp; CC[3+bs*2] -= CC[3+bs*3] * tmp; tmp = E[1+bs*3]; CC[0+bs*1] -= CC[0+bs*3] * tmp; CC[1+bs*1] -= CC[1+bs*3] * tmp; CC[2+bs*1] -= CC[2+bs*3] * tmp; CC[3+bs*1] -= CC[3+bs*3] * tmp; tmp = E[0+bs*3]; CC[0+bs*0] -= CC[0+bs*3] * tmp; CC[1+bs*0] -= CC[1+bs*3] * tmp; CC[2+bs*0] -= CC[2+bs*3] * tmp; CC[3+bs*0] -= CC[3+bs*3] * tmp; tmp = inv_diag_E[2]; CC[0+bs*2] *= tmp; CC[1+bs*2] *= tmp; CC[2+bs*2] *= tmp; CC[3+bs*2] *= tmp; tmp = E[1+bs*2]; CC[0+bs*1] -= CC[0+bs*2] * tmp; CC[1+bs*1] -= CC[1+bs*2] * tmp; CC[2+bs*1] -= CC[2+bs*2] * tmp; CC[3+bs*1] -= CC[3+bs*2] * tmp; tmp = E[0+bs*2]; CC[0+bs*0] -= CC[0+bs*2] * tmp; CC[1+bs*0] -= CC[1+bs*2] * tmp; CC[2+bs*0] -= CC[2+bs*2] * tmp; CC[3+bs*0] -= CC[3+bs*2] * tmp; tmp = inv_diag_E[1]; CC[0+bs*1] *= tmp; CC[1+bs*1] *= tmp; CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; tmp = E[0+bs*1]; CC[0+bs*0] -= CC[0+bs*1] * tmp; CC[1+bs*0] -= CC[1+bs*1] * tmp; CC[2+bs*0] -= CC[2+bs*1] * tmp; CC[3+bs*0] -= CC[3+bs*1] * tmp; tmp = inv_diag_E[0]; CC[0+bs*0] *= tmp; CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_ru_inv_4x4_vs_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E, float *inv_diag_E, int km, int kn) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); if(kn>3) { tmp = inv_diag_E[3]; CC[0+bs*3] *= tmp; CC[1+bs*3] *= tmp; CC[2+bs*3] *= tmp; CC[3+bs*3] *= tmp; tmp = E[2+bs*3]; CC[0+bs*2] -= CC[0+bs*3] * tmp; CC[1+bs*2] -= CC[1+bs*3] * tmp; CC[2+bs*2] -= CC[2+bs*3] * tmp; CC[3+bs*2] -= CC[3+bs*3] * tmp; tmp = E[1+bs*3]; CC[0+bs*1] -= CC[0+bs*3] * tmp; CC[1+bs*1] -= CC[1+bs*3] * tmp; CC[2+bs*1] -= CC[2+bs*3] * tmp; CC[3+bs*1] -= CC[3+bs*3] * tmp; tmp = E[0+bs*3]; CC[0+bs*0] -= CC[0+bs*3] * tmp; CC[1+bs*0] -= CC[1+bs*3] * tmp; CC[2+bs*0] -= CC[2+bs*3] * tmp; CC[3+bs*0] -= CC[3+bs*3] * tmp; } if(kn>2) { tmp = inv_diag_E[2]; CC[0+bs*2] *= tmp; CC[1+bs*2] *= tmp; CC[2+bs*2] *= tmp; CC[3+bs*2] *= tmp; tmp = E[1+bs*2]; CC[0+bs*1] -= CC[0+bs*2] * tmp; CC[1+bs*1] -= CC[1+bs*2] * tmp; CC[2+bs*1] -= CC[2+bs*2] * tmp; CC[3+bs*1] -= CC[3+bs*2] * tmp; tmp = E[0+bs*2]; CC[0+bs*0] -= CC[0+bs*2] * tmp; CC[1+bs*0] -= CC[1+bs*2] * tmp; CC[2+bs*0] -= CC[2+bs*2] * tmp; CC[3+bs*0] -= CC[3+bs*2] * tmp; } if(kn>1) { tmp = inv_diag_E[1]; CC[0+bs*1] *= tmp; CC[1+bs*1] *= tmp; CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; tmp = E[0+bs*1]; CC[0+bs*0] -= CC[0+bs*1] * tmp; CC[1+bs*0] -= CC[1+bs*1] * tmp; CC[2+bs*0] -= CC[2+bs*1] * tmp; CC[3+bs*0] -= CC[3+bs*1] * tmp; } tmp = inv_diag_E[0]; CC[0+bs*0] *= tmp; CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_sgetrf_nn_4x4_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *inv_diag_D) { const int bs = 4; int k; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, &beta1, C, CC); // factorization // first column tmp = 1.0 / CC[0+bs*0]; CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; inv_diag_D[0] = tmp; // second column CC[1+bs*1] -= CC[1+bs*0] * CC[0+bs*1]; CC[2+bs*1] -= CC[2+bs*0] * CC[0+bs*1]; CC[3+bs*1] -= CC[3+bs*0] * CC[0+bs*1]; tmp = 1.0 / CC[1+bs*1]; CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; inv_diag_D[1] = tmp; // third column CC[1+bs*2] -= CC[1+bs*0] * CC[0+bs*2]; CC[2+bs*2] -= CC[2+bs*0] * CC[0+bs*2]; CC[3+bs*2] -= CC[3+bs*0] * CC[0+bs*2]; CC[2+bs*2] -= CC[2+bs*1] * CC[1+bs*2]; CC[3+bs*2] -= CC[3+bs*1] * CC[1+bs*2]; tmp = 1.0 / CC[2+bs*2]; CC[3+bs*2] *= tmp; inv_diag_D[2] = tmp; // fourth column CC[1+bs*3] -= CC[1+bs*0] * CC[0+bs*3]; CC[2+bs*3] -= CC[2+bs*0] * CC[0+bs*3]; CC[3+bs*3] -= CC[3+bs*0] * CC[0+bs*3]; CC[2+bs*3] -= CC[2+bs*1] * CC[1+bs*3]; CC[3+bs*3] -= CC[3+bs*1] * CC[1+bs*3]; CC[3+bs*3] -= CC[3+bs*2] * CC[2+bs*3]; tmp = 1.0 / CC[3+bs*3]; inv_diag_D[3] = tmp; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_sgetrf_nn_4x4_vs_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *inv_diag_D, int km, int kn) { const int bs = 4; int k; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, &beta1, C, CC); // factorization // first column tmp = 1.0 / CC[0+bs*0]; CC[1+bs*0] *= tmp; CC[2+bs*0] *= tmp; CC[3+bs*0] *= tmp; inv_diag_D[0] = tmp; if(kn==1) goto store; // second column CC[1+bs*1] -= CC[1+bs*0] * CC[0+bs*1]; CC[2+bs*1] -= CC[2+bs*0] * CC[0+bs*1]; CC[3+bs*1] -= CC[3+bs*0] * CC[0+bs*1]; tmp = 1.0 / CC[1+bs*1]; CC[2+bs*1] *= tmp; CC[3+bs*1] *= tmp; inv_diag_D[1] = tmp; if(kn==2) goto store; // third column CC[1+bs*2] -= CC[1+bs*0] * CC[0+bs*2]; CC[2+bs*2] -= CC[2+bs*0] * CC[0+bs*2]; CC[3+bs*2] -= CC[3+bs*0] * CC[0+bs*2]; CC[2+bs*2] -= CC[2+bs*1] * CC[1+bs*2]; CC[3+bs*2] -= CC[3+bs*1] * CC[1+bs*2]; tmp = 1.0 / CC[2+bs*2]; CC[3+bs*2] *= tmp; inv_diag_D[2] = tmp; if(kn==3) goto store; // fourth column CC[1+bs*3] -= CC[1+bs*0] * CC[0+bs*3]; CC[2+bs*3] -= CC[2+bs*0] * CC[0+bs*3]; CC[3+bs*3] -= CC[3+bs*0] * CC[0+bs*3]; CC[2+bs*3] -= CC[2+bs*1] * CC[1+bs*3]; CC[3+bs*3] -= CC[3+bs*1] * CC[1+bs*3]; CC[3+bs*3] -= CC[3+bs*2] * CC[2+bs*3]; tmp = 1.0 / CC[3+bs*3]; inv_diag_D[3] = tmp; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_ru_one_4x4_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); tmp = E[2+bs*3]; CC[0+bs*2] -= CC[0+bs*3] * tmp; CC[1+bs*2] -= CC[1+bs*3] * tmp; CC[2+bs*2] -= CC[2+bs*3] * tmp; CC[3+bs*2] -= CC[3+bs*3] * tmp; tmp = E[1+bs*3]; CC[0+bs*1] -= CC[0+bs*3] * tmp; CC[1+bs*1] -= CC[1+bs*3] * tmp; CC[2+bs*1] -= CC[2+bs*3] * tmp; CC[3+bs*1] -= CC[3+bs*3] * tmp; tmp = E[0+bs*3]; CC[0+bs*0] -= CC[0+bs*3] * tmp; CC[1+bs*0] -= CC[1+bs*3] * tmp; CC[2+bs*0] -= CC[2+bs*3] * tmp; CC[3+bs*0] -= CC[3+bs*3] * tmp; tmp = E[1+bs*2]; CC[0+bs*1] -= CC[0+bs*2] * tmp; CC[1+bs*1] -= CC[1+bs*2] * tmp; CC[2+bs*1] -= CC[2+bs*2] * tmp; CC[3+bs*1] -= CC[3+bs*2] * tmp; tmp = E[0+bs*2]; CC[0+bs*0] -= CC[0+bs*2] * tmp; CC[1+bs*0] -= CC[1+bs*2] * tmp; CC[2+bs*0] -= CC[2+bs*2] * tmp; CC[3+bs*0] -= CC[3+bs*2] * tmp; tmp = E[0+bs*1]; CC[0+bs*0] -= CC[0+bs*1] * tmp; CC[1+bs*0] -= CC[1+bs*1] * tmp; CC[2+bs*0] -= CC[2+bs*1] * tmp; CC[3+bs*0] -= CC[3+bs*1] * tmp; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_X64_INTEL_HASWELL) || defined(TARGET_X64_INTEL_SANDY_BRIDGE) || defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nt_ru_one_4x4_vs_lib4(int kmax, float *A, float *B, float *beta, float *C, float *D, float *E, int km, int kn) { const int bs = 4; float tmp; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nt_4x4_lib4(kmax, &alpha1, A, B, beta, C, CC); if(kn>3) { tmp = E[2+bs*3]; CC[0+bs*2] -= CC[0+bs*3] * tmp; CC[1+bs*2] -= CC[1+bs*3] * tmp; CC[2+bs*2] -= CC[2+bs*3] * tmp; CC[3+bs*2] -= CC[3+bs*3] * tmp; tmp = E[1+bs*3]; CC[0+bs*1] -= CC[0+bs*3] * tmp; CC[1+bs*1] -= CC[1+bs*3] * tmp; CC[2+bs*1] -= CC[2+bs*3] * tmp; CC[3+bs*1] -= CC[3+bs*3] * tmp; tmp = E[0+bs*3]; CC[0+bs*0] -= CC[0+bs*3] * tmp; CC[1+bs*0] -= CC[1+bs*3] * tmp; CC[2+bs*0] -= CC[2+bs*3] * tmp; CC[3+bs*0] -= CC[3+bs*3] * tmp; } if(kn>2) { tmp = E[1+bs*2]; CC[0+bs*1] -= CC[0+bs*2] * tmp; CC[1+bs*1] -= CC[1+bs*2] * tmp; CC[2+bs*1] -= CC[2+bs*2] * tmp; CC[3+bs*1] -= CC[3+bs*2] * tmp; tmp = E[0+bs*2]; CC[0+bs*0] -= CC[0+bs*2] * tmp; CC[1+bs*0] -= CC[1+bs*2] * tmp; CC[2+bs*0] -= CC[2+bs*2] * tmp; CC[3+bs*0] -= CC[3+bs*2] * tmp; } if(kn>1) { tmp = E[0+bs*1]; CC[0+bs*0] -= CC[0+bs*1] * tmp; CC[1+bs*0] -= CC[1+bs*1] * tmp; CC[2+bs*0] -= CC[2+bs*1] * tmp; CC[3+bs*0] -= CC[3+bs*1] * tmp; } store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nn_ll_one_4x4_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *E) { const int bs = 4; int k; float tmp, e_1, e_2, e_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, &beta1, C, CC); // solution e_1 = E[1+bs*0]; e_2 = E[2+bs*0]; e_3 = E[3+bs*0]; CC[1+bs*0] -= e_1 * CC[0+bs*0]; CC[2+bs*0] -= e_2 * CC[0+bs*0]; CC[3+bs*0] -= e_3 * CC[0+bs*0]; CC[1+bs*1] -= e_1 * CC[0+bs*1]; CC[2+bs*1] -= e_2 * CC[0+bs*1]; CC[3+bs*1] -= e_3 * CC[0+bs*1]; CC[1+bs*2] -= e_1 * CC[0+bs*2]; CC[2+bs*2] -= e_2 * CC[0+bs*2]; CC[3+bs*2] -= e_3 * CC[0+bs*2]; CC[1+bs*3] -= e_1 * CC[0+bs*3]; CC[2+bs*3] -= e_2 * CC[0+bs*3]; CC[3+bs*3] -= e_3 * CC[0+bs*3]; e_2 = E[2+bs*1]; e_3 = E[3+bs*1]; CC[2+bs*0] -= e_2 * CC[1+bs*0]; CC[3+bs*0] -= e_3 * CC[1+bs*0]; CC[2+bs*1] -= e_2 * CC[1+bs*1]; CC[3+bs*1] -= e_3 * CC[1+bs*1]; CC[2+bs*2] -= e_2 * CC[1+bs*2]; CC[3+bs*2] -= e_3 * CC[1+bs*2]; CC[2+bs*3] -= e_2 * CC[1+bs*3]; CC[3+bs*3] -= e_3 * CC[1+bs*3]; e_3 = E[3+bs*2]; CC[3+bs*0] -= e_3 * CC[2+bs*0]; CC[3+bs*1] -= e_3 * CC[2+bs*1]; CC[3+bs*2] -= e_3 * CC[2+bs*2]; CC[3+bs*3] -= e_3 * CC[2+bs*3]; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nn_ll_one_4x4_vs_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *E, int km, int kn) { const int bs = 4; int k; float tmp, e_1, e_2, e_3; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, &beta1, C, CC); // solution if(km==1) goto store; e_1 = E[1+bs*0]; e_2 = E[2+bs*0]; e_3 = E[3+bs*0]; CC[1+bs*0] -= e_1 * CC[0+bs*0]; CC[2+bs*0] -= e_2 * CC[0+bs*0]; CC[3+bs*0] -= e_3 * CC[0+bs*0]; CC[1+bs*1] -= e_1 * CC[0+bs*1]; CC[2+bs*1] -= e_2 * CC[0+bs*1]; CC[3+bs*1] -= e_3 * CC[0+bs*1]; CC[1+bs*2] -= e_1 * CC[0+bs*2]; CC[2+bs*2] -= e_2 * CC[0+bs*2]; CC[3+bs*2] -= e_3 * CC[0+bs*2]; CC[1+bs*3] -= e_1 * CC[0+bs*3]; CC[2+bs*3] -= e_2 * CC[0+bs*3]; CC[3+bs*3] -= e_3 * CC[0+bs*3]; if(km==2) goto store; e_2 = E[2+bs*1]; e_3 = E[3+bs*1]; CC[2+bs*0] -= e_2 * CC[1+bs*0]; CC[3+bs*0] -= e_3 * CC[1+bs*0]; CC[2+bs*1] -= e_2 * CC[1+bs*1]; CC[3+bs*1] -= e_3 * CC[1+bs*1]; CC[2+bs*2] -= e_2 * CC[1+bs*2]; CC[3+bs*2] -= e_3 * CC[1+bs*2]; CC[2+bs*3] -= e_2 * CC[1+bs*3]; CC[3+bs*3] -= e_3 * CC[1+bs*3]; if(km==3) goto store; e_3 = E[3+bs*2]; CC[3+bs*0] -= e_3 * CC[2+bs*0]; CC[3+bs*1] -= e_3 * CC[2+bs*1]; CC[3+bs*2] -= e_3 * CC[2+bs*2]; CC[3+bs*3] -= e_3 * CC[2+bs*3]; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nn_ru_inv_4x4_lib4(int kmax, float *A, float *B, int sdb, float *beta, float *C, float *D, float *E, float *inv_diag_E) { const int bs = 4; int k; float tmp, e_00, e_01, e_02, e_03, e_11, e_12, e_13, e_22, e_23, e_33; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, beta, C, CC); // solve e_00 = inv_diag_E[0]; CC[0+bs*0] *= e_00; CC[1+bs*0] *= e_00; CC[2+bs*0] *= e_00; CC[3+bs*0] *= e_00; e_01 = E[0+bs*1]; e_11 = inv_diag_E[1]; CC[0+bs*1] -= CC[0+bs*0] * e_01; CC[1+bs*1] -= CC[1+bs*0] * e_01; CC[2+bs*1] -= CC[2+bs*0] * e_01; CC[3+bs*1] -= CC[3+bs*0] * e_01; CC[0+bs*1] *= e_11; CC[1+bs*1] *= e_11; CC[2+bs*1] *= e_11; CC[3+bs*1] *= e_11; e_02 = E[0+bs*2]; e_12 = E[1+bs*2]; e_22 = inv_diag_E[2]; CC[0+bs*2] -= CC[0+bs*0] * e_02; CC[1+bs*2] -= CC[1+bs*0] * e_02; CC[2+bs*2] -= CC[2+bs*0] * e_02; CC[3+bs*2] -= CC[3+bs*0] * e_02; CC[0+bs*2] -= CC[0+bs*1] * e_12; CC[1+bs*2] -= CC[1+bs*1] * e_12; CC[2+bs*2] -= CC[2+bs*1] * e_12; CC[3+bs*2] -= CC[3+bs*1] * e_12; CC[0+bs*2] *= e_22; CC[1+bs*2] *= e_22; CC[2+bs*2] *= e_22; CC[3+bs*2] *= e_22; e_03 = E[0+bs*3]; e_13 = E[1+bs*3]; e_23 = E[2+bs*3]; e_33 = inv_diag_E[3]; CC[0+bs*3] -= CC[0+bs*0] * e_03; CC[1+bs*3] -= CC[1+bs*0] * e_03; CC[2+bs*3] -= CC[2+bs*0] * e_03; CC[3+bs*3] -= CC[3+bs*0] * e_03; CC[0+bs*3] -= CC[0+bs*1] * e_13; CC[1+bs*3] -= CC[1+bs*1] * e_13; CC[2+bs*3] -= CC[2+bs*1] * e_13; CC[3+bs*3] -= CC[3+bs*1] * e_13; CC[0+bs*3] -= CC[0+bs*2] * e_23; CC[1+bs*3] -= CC[1+bs*2] * e_23; CC[2+bs*3] -= CC[2+bs*2] * e_23; CC[3+bs*3] -= CC[3+bs*2] * e_23; CC[0+bs*3] *= e_33; CC[1+bs*3] *= e_33; CC[2+bs*3] *= e_33; CC[3+bs*3] *= e_33; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nn_ru_inv_4x4_vs_lib4(int kmax, float *A, float *B, int sdb, float *beta, float *C, float *D, float *E, float *inv_diag_E, int km, int kn) { const int bs = 4; int k; float tmp, e_00, e_01, e_02, e_03, e_11, e_12, e_13, e_22, e_23, e_33; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, beta, C, CC); // solve e_00 = inv_diag_E[0]; CC[0+bs*0] *= e_00; CC[1+bs*0] *= e_00; CC[2+bs*0] *= e_00; CC[3+bs*0] *= e_00; if(kn==1) goto store; e_01 = E[0+bs*1]; e_11 = inv_diag_E[1]; CC[0+bs*1] -= CC[0+bs*0] * e_01; CC[1+bs*1] -= CC[1+bs*0] * e_01; CC[2+bs*1] -= CC[2+bs*0] * e_01; CC[3+bs*1] -= CC[3+bs*0] * e_01; CC[0+bs*1] *= e_11; CC[1+bs*1] *= e_11; CC[2+bs*1] *= e_11; CC[3+bs*1] *= e_11; if(kn==2) goto store; e_02 = E[0+bs*2]; e_12 = E[1+bs*2]; e_22 = inv_diag_E[2]; CC[0+bs*2] -= CC[0+bs*0] * e_02; CC[1+bs*2] -= CC[1+bs*0] * e_02; CC[2+bs*2] -= CC[2+bs*0] * e_02; CC[3+bs*2] -= CC[3+bs*0] * e_02; CC[0+bs*2] -= CC[0+bs*1] * e_12; CC[1+bs*2] -= CC[1+bs*1] * e_12; CC[2+bs*2] -= CC[2+bs*1] * e_12; CC[3+bs*2] -= CC[3+bs*1] * e_12; CC[0+bs*2] *= e_22; CC[1+bs*2] *= e_22; CC[2+bs*2] *= e_22; CC[3+bs*2] *= e_22; if(kn==3) goto store; e_03 = E[0+bs*3]; e_13 = E[1+bs*3]; e_23 = E[2+bs*3]; e_33 = inv_diag_E[3]; CC[0+bs*3] -= CC[0+bs*0] * e_03; CC[1+bs*3] -= CC[1+bs*0] * e_03; CC[2+bs*3] -= CC[2+bs*0] * e_03; CC[3+bs*3] -= CC[3+bs*0] * e_03; CC[0+bs*3] -= CC[0+bs*1] * e_13; CC[1+bs*3] -= CC[1+bs*1] * e_13; CC[2+bs*3] -= CC[2+bs*1] * e_13; CC[3+bs*3] -= CC[3+bs*1] * e_13; CC[0+bs*3] -= CC[0+bs*2] * e_23; CC[1+bs*3] -= CC[1+bs*2] * e_23; CC[2+bs*3] -= CC[2+bs*2] * e_23; CC[3+bs*3] -= CC[3+bs*2] * e_23; CC[0+bs*3] *= e_33; CC[1+bs*3] *= e_33; CC[2+bs*3] *= e_33; CC[3+bs*3] *= e_33; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nn_lu_inv_4x4_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *E, float *inv_diag_E) { const int bs = 4; int k; float tmp, a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3, e_00, e_01, e_02, e_03, e_11, e_12, e_13, e_22, e_23, e_33; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, &beta1, C, CC); // solve e_03 = E[0+bs*3]; e_13 = E[1+bs*3]; e_23 = E[2+bs*3]; e_33 = inv_diag_E[3]; CC[3+bs*0] *= e_33; CC[3+bs*1] *= e_33; CC[3+bs*2] *= e_33; CC[3+bs*3] *= e_33; CC[0+bs*0] -= e_03 * CC[3+bs*0]; CC[0+bs*1] -= e_03 * CC[3+bs*1]; CC[0+bs*2] -= e_03 * CC[3+bs*2]; CC[0+bs*3] -= e_03 * CC[3+bs*3]; CC[1+bs*0] -= e_13 * CC[3+bs*0]; CC[1+bs*1] -= e_13 * CC[3+bs*1]; CC[1+bs*2] -= e_13 * CC[3+bs*2]; CC[1+bs*3] -= e_13 * CC[3+bs*3]; CC[2+bs*0] -= e_23 * CC[3+bs*0]; CC[2+bs*1] -= e_23 * CC[3+bs*1]; CC[2+bs*2] -= e_23 * CC[3+bs*2]; CC[2+bs*3] -= e_23 * CC[3+bs*3]; e_02 = E[0+bs*2]; e_12 = E[1+bs*2]; e_22 = inv_diag_E[2]; CC[2+bs*0] *= e_22; CC[2+bs*1] *= e_22; CC[2+bs*2] *= e_22; CC[2+bs*3] *= e_22; CC[0+bs*0] -= e_02 * CC[2+bs*0]; CC[0+bs*1] -= e_02 * CC[2+bs*1]; CC[0+bs*2] -= e_02 * CC[2+bs*2]; CC[0+bs*3] -= e_02 * CC[2+bs*3]; CC[1+bs*0] -= e_12 * CC[2+bs*0]; CC[1+bs*1] -= e_12 * CC[2+bs*1]; CC[1+bs*2] -= e_12 * CC[2+bs*2]; CC[1+bs*3] -= e_12 * CC[2+bs*3]; e_01 = E[0+bs*1]; e_11 = inv_diag_E[1]; CC[1+bs*0] *= e_11; CC[1+bs*1] *= e_11; CC[1+bs*2] *= e_11; CC[1+bs*3] *= e_11; CC[0+bs*0] -= e_01 * CC[1+bs*0]; CC[0+bs*1] -= e_01 * CC[1+bs*1]; CC[0+bs*2] -= e_01 * CC[1+bs*2]; CC[0+bs*3] -= e_01 * CC[1+bs*3]; e_00 = inv_diag_E[0]; CC[0+bs*0] *= e_00; CC[0+bs*1] *= e_00; CC[0+bs*2] *= e_00; CC[0+bs*3] *= e_00; D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; return; } #endif #if defined(TARGET_GENERIC) || defined(TARGET_X86_AMD_BARCELONA) || defined(TARGET_X86_AMD_JAGUAR) || defined(TARGET_X64_INTEL_CORE) || defined(TARGET_X64_AMD_BULLDOZER) || defined(TARGET_ARMV7A_ARM_CORTEX_A15) || defined(TARGET_ARMV7A_ARM_CORTEX_A7) || defined(TARGET_ARMV7A_ARM_CORTEX_A9) || defined(TARGET_ARMV8A_ARM_CORTEX_A57) || defined(TARGET_ARMV8A_ARM_CORTEX_A53) void kernel_strsm_nn_lu_inv_4x4_vs_lib4(int kmax, float *A, float *B, int sdb, float *C, float *D, float *E, float *inv_diag_E, int km, int kn) { const int bs = 4; int k; float tmp, a_0, a_1, a_2, a_3, b_0, b_1, b_2, b_3, e_00, e_01, e_02, e_03, e_11, e_12, e_13, e_22, e_23, e_33; #if defined(TARGET_GENERIC) float CC[16] = {0}; #else ALIGNED( float CC[16], 64 ) = {0}; #endif float alpha1 = -1.0; float beta1 = 1.0; kernel_sgemm_nn_4x4_lib4(kmax, &alpha1, A, 0, B, sdb, &beta1, C, CC); // solve if(km>3) { e_03 = E[0+bs*3]; e_13 = E[1+bs*3]; e_23 = E[2+bs*3]; e_33 = inv_diag_E[3]; CC[3+bs*0] *= e_33; CC[3+bs*1] *= e_33; CC[3+bs*2] *= e_33; CC[3+bs*3] *= e_33; CC[0+bs*0] -= e_03 * CC[3+bs*0]; CC[0+bs*1] -= e_03 * CC[3+bs*1]; CC[0+bs*2] -= e_03 * CC[3+bs*2]; CC[0+bs*3] -= e_03 * CC[3+bs*3]; CC[1+bs*0] -= e_13 * CC[3+bs*0]; CC[1+bs*1] -= e_13 * CC[3+bs*1]; CC[1+bs*2] -= e_13 * CC[3+bs*2]; CC[1+bs*3] -= e_13 * CC[3+bs*3]; CC[2+bs*0] -= e_23 * CC[3+bs*0]; CC[2+bs*1] -= e_23 * CC[3+bs*1]; CC[2+bs*2] -= e_23 * CC[3+bs*2]; CC[2+bs*3] -= e_23 * CC[3+bs*3]; } if(km>2) { e_02 = E[0+bs*2]; e_12 = E[1+bs*2]; e_22 = inv_diag_E[2]; CC[2+bs*0] *= e_22; CC[2+bs*1] *= e_22; CC[2+bs*2] *= e_22; CC[2+bs*3] *= e_22; CC[0+bs*0] -= e_02 * CC[2+bs*0]; CC[0+bs*1] -= e_02 * CC[2+bs*1]; CC[0+bs*2] -= e_02 * CC[2+bs*2]; CC[0+bs*3] -= e_02 * CC[2+bs*3]; CC[1+bs*0] -= e_12 * CC[2+bs*0]; CC[1+bs*1] -= e_12 * CC[2+bs*1]; CC[1+bs*2] -= e_12 * CC[2+bs*2]; CC[1+bs*3] -= e_12 * CC[2+bs*3]; } if(km>1) { e_01 = E[0+bs*1]; e_11 = inv_diag_E[1]; CC[1+bs*0] *= e_11; CC[1+bs*1] *= e_11; CC[1+bs*2] *= e_11; CC[1+bs*3] *= e_11; CC[0+bs*0] -= e_01 * CC[1+bs*0]; CC[0+bs*1] -= e_01 * CC[1+bs*1]; CC[0+bs*2] -= e_01 * CC[1+bs*2]; CC[0+bs*3] -= e_01 * CC[1+bs*3]; } e_00 = inv_diag_E[0]; CC[0+bs*0] *= e_00; CC[0+bs*1] *= e_00; CC[0+bs*2] *= e_00; CC[0+bs*3] *= e_00; store: if(km>=4) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; D[3+bs*0] = CC[3+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; D[3+bs*1] = CC[3+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; D[3+bs*2] = CC[3+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; D[3+bs*3] = CC[3+bs*3]; } else if(km>=3) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; D[2+bs*0] = CC[2+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; D[2+bs*1] = CC[2+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; D[2+bs*2] = CC[2+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; D[2+bs*3] = CC[2+bs*3]; } else if(km>=2) { D[0+bs*0] = CC[0+bs*0]; D[1+bs*0] = CC[1+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; D[1+bs*1] = CC[1+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; D[1+bs*2] = CC[1+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; D[1+bs*3] = CC[1+bs*3]; } else //if(km>=1) { D[0+bs*0] = CC[0+bs*0]; if(kn==1) return; D[0+bs*1] = CC[0+bs*1]; if(kn==2) return; D[0+bs*2] = CC[0+bs*2]; if(kn==3) return; D[0+bs*3] = CC[0+bs*3]; } return; } #endif //#if defined(BLAS_API) #if ( defined(BLAS_API) | ( defined(LA_HIGH_PERFORMANCE) & defined(MF_COLMAJ) ) ) #include "kernel_sgemm_4x4_lib.c" #endif
18d3ba70453bd46310884738def5ea30804d2b95
79d11d81ffacf6fad9cf271256eda8ae4b30bdbc
/external/rgbcx/rgbcx_table4.h
cda3f0a1ac1e44547363cfb98226888c463f4869
[ "MIT" ]
permissive
nem0/LumixEngine
d6c46d8febc54ff41e5bc5e6d71d861410f5b155
e6314612df50c6f37b34fb0dfcad9683cc506ec7
refs/heads/master
2023-09-02T09:14:49.212586
2023-08-23T21:01:37
2023-08-23T21:01:37
14,590,125
3,660
518
MIT
2023-09-14T14:49:32
2013-11-21T14:43:55
C++
UTF-8
C
false
false
450,869
h
rgbcx_table4.h
{ 202,403,51,450,318,23,120,13,494,5,523,260,77,21,15,128,48,141,33,817,137,269,12,102,1,475,4,326,7,32,453,64,196,115,730,49,165,2,82,342,6,401,180,31,899,59,402,351,197,17,125,457,14,386,40,3,61,58,37,221,95,16,99,719,98,20,10,854,117,153,27,576,134,341,308,216,11,194,30,24,922,285,9,50,86,65,19,615,391,44,75,237,177,90,352,93,56,22,18,116,70,96,247,291,45,110,105,60,57,54,43,36,0,217,421,203,46,629,569,365,210,92,69,66,38,28,144,551 }, { 13,115,51,23,141,217,269,137,318,202,77,21,317,5,64,4,291,2,352,7,32,33,6,372,0,48,365,3,102,349,12,341,177,180,10,237,9,221,403,165,752,22,11,244,28,308,15,128,247,197,49,16,494,125,98,40,120,498,31,90,304,143,95,93,437,196,144,86,44,864,153,18,678,342,901,39,24,30,203,160,117,105,475,14,482,253,457,873,59,35,579,36,569,450,206,72,99,17,717,401,241,453,110,546,201,83,421,61,37,326,260,509,284,275,96,8,109,57,391,386,468,134,82,961,822,576,89,68 }, { 29,58,262,74,287,52,151,331,171,500,396,334,75,27,635,220,53,1,26,409,6,324,5,70,145,223,163,112,73,50,45,549,445,113,297,19,675,651,46,61,502,307,14,17,34,573,186,80,394,436,583,315,138,38,21,767,250,491,820,350,64,2,32,357,42,852,25,764,309,67,802,96,631,48,606,780,243,881,103,241,115,807,13,4,155,181,11,106,611,614,278,153,23,108,69,845,841,308,400,72,853,200,66,196,226,237,587,632,24,281,785,133,128,125,117,380,95,474,294,83,197,90,161,134,366,236,760,311 }, { 40,51,62,33,453,14,23,56,730,196,475,99,12,34,139,775,153,403,585,440,102,38,130,47,162,17,108,880,117,11,202,57,361,84,123,27,184,236,4,128,19,2,670,136,54,26,111,134,13,161,277,719,152,6,377,183,5,59,211,53,412,485,46,328,77,711,78,21,556,452,65,283,421,129,37,514,507,402,176,29,25,229,401,488,757,45,76,205,899,322,32,177,494,527,383,497,457,249,300,114,215,555,386,119,133,0,349,115,3,862,1,165,73,41,523,72,200,64,291,217,80,305,22,318,194,308,18,714 }, { 33,51,102,202,23,128,196,13,64,153,40,12,141,99,403,15,10,269,77,139,475,453,5,318,117,2,14,134,1,86,165,120,401,3,0,22,137,6,197,277,17,402,180,21,421,494,37,115,31,82,38,9,95,342,93,7,110,351,125,457,65,36,361,49,54,19,260,111,44,291,237,28,8,11,194,961,719,352,217,18,485,523,308,730,386,326,210,450,328,300,98,899,27,32,341,48,25,670,34,50,629,26,24,503,498,285,317,67,817,143,365,177,509,41,164,116,757,55,46,203,569,898,373,114,144,16,349,775 }, { 13,23,51,115,77,177,202,4,141,32,40,33,217,64,128,90,269,102,59,318,11,291,0,137,403,22,21,7,165,197,15,210,247,180,16,117,153,352,14,2,125,494,10,49,237,18,95,453,6,9,1,24,28,349,475,216,12,342,317,304,3,196,86,98,275,134,31,17,35,25,365,308,19,341,44,36,372,30,93,20,401,76,241,402,139,752,57,244,105,386,37,26,260,110,288,120,116,48,326,421,221,285,901,38,99,82,498,39,468,55,523,143,111,482,65,300,214,450,203,457,351,43,29,27,8,576,678,569 }, { 235,26,19,648,624,630,78,47,122,444,145,27,665,112,85,42,390,416,813,113,130,65,680,64,711,25,453,108,644,6,53,73,138,256,95,412,22,730,29,289,90,194,34,525,74,690,32,297,128,45,196,250,287,133,445,86,283,214,236,237,137,222,884,200,746,59,52,312,77,280,632,0,17,114,835,51,123,14,288,881,28,307,180,57,381,141,183,70,4,472,10,33,76,337,3,389,247,315,2,18,368,849,874,573,23,58,544,153,151,436,102,322,99,352,36,1,177,714,719,125,597,63,165,519,285,49,13,396 }, { 64,352,751,141,217,247,237,304,269,954,437,372,177,947,312,86,318,349,180,875,95,864,291,597,498,128,678,77,232,92,115,317,752,32,202,588,59,197,579,90,638,392,652,76,210,546,260,1,448,126,340,164,18,303,13,165,275,14,582,120,633,205,179,69,156,296,35,230,391,888,267,572,28,16,379,851,660,96,717,314,0,23,863,49,195,39,223,5,386,137,75,509,107,571,563,46,194,526,309,21,450,342,288,140,83,24,330,87,70,50,12,9,514,365,246,199,100,65,36,385,55,125,658,244,326,264,696,453 }, { 642,898,638,180,901,341,82,197,951,10,762,253,165,15,752,811,479,244,143,365,569,873,242,110,506,351,31,8,116,55,137,115,317,499,141,352,44,338,206,373,386,854,164,22,758,93,37,217,36,1,417,77,629,661,21,717,33,9,564,160,401,456,30,4,203,559,5,509,86,28,326,102,282,268,535,0,13,308,170,269,11,498,391,51,120,2,457,64,704,965,40,32,23,299,421,482,148,615,39,318,533,3,169,961,801,202,260,851,576,117,247,221,349,372,670,968,403,468,291,285,128,824,134,719,237,734,177,342 }, { 51,221,23,254,308,438,21,125,166,39,530,656,159,401,49,13,158,115,386,421,688,613,629,228,743,48,518,190,627,453,0,829,333,30,105,912,341,9,670,424,827,165,406,217,404,840,669,391,137,274,197,301,286,272,170,468,457,95,89,22,770,242,33,310,109,569,938,393,960,1,101,36,88,773,538,364,890,131,616,100,28,219,456,344,64,479,679,734,327,846,365,261,55,317,32,5,4,492,180,68,67,482,237,475,793,385,2,367,16,7,347,293,371,224,86,35,719,762,578,332,202,102,442,865,12,949,351,98 }, { 1,143,31,197,44,116,242,2,180,125,23,55,206,13,93,498,5,8,115,341,36,752,638,338,141,268,64,901,165,456,0,203,951,546,479,365,873,253,417,4,569,137,15,762,506,237,12,352,965,120,3,299,244,170,164,7,22,282,51,144,6,86,864,21,269,384,558,128,37,9,457,326,844,492,160,961,391,499,202,509,599,870,260,317,685,434,127,217,824,393,373,489,629,77,98,903,308,33,559,332,811,473,301,318,401,102,963,28,386,564,918,367,110,105,911,285,959,523,134,482,740,678,169,617,14,96,758,450 }, { 12,23,51,37,13,99,14,38,15,196,328,54,21,134,153,64,453,401,117,128,2,33,139,120,308,5,82,141,361,0,277,29,403,351,719,165,10,115,629,457,46,475,89,450,22,32,110,260,1,31,269,93,9,137,8,386,202,125,86,18,40,111,52,180,17,49,48,4,102,72,477,523,474,326,318,45,898,3,44,402,197,77,730,203,28,24,6,19,421,854,961,352,237,194,114,65,155,373,116,50,36,498,242,236,221,98,55,16,25,7,217,391,569,880,615,41,546,144,509,59,316,79,57,514,494,317,899,488 }, { 13,23,15,961,457,115,569,51,165,38,197,2,4,1,474,5,719,99,629,77,0,14,37,401,3,33,7,94,6,128,11,40,10,453,59,64,153,79,509,482,54,17,21,328,111,89,139,277,12,102,498,188,9,152,141,734,76,157,873,386,196,402,32,475,177,117,72,391,36,8,730,758,237,45,304,57,403,134,579,148,202,775,22,523,341,29,431,318,317,308,120,546,62,313,468,437,86,405,217,180,361,50,269,46,342,90,31,143,16,48,44,339,184,19,49,27,18,749,41,450,880,542,205,901,300,216,164,52 }, { 15,10,12,0,1,23,961,197,5,82,2,4,3,120,134,457,7,165,260,33,51,9,6,11,351,31,22,21,14,64,8,180,40,450,110,141,386,898,719,523,37,17,153,102,77,117,44,341,217,32,326,93,36,854,269,317,115,18,730,352,49,922,196,365,202,901,28,38,99,59,291,817,125,318,16,569,453,403,55,498,475,111,48,30,94,372,349,342,752,41,391,139,72,474,128,19,899,373,210,203,57,873,661,177,494,98,79,86,143,95,509,27,76,401,89,864,615,304,116,431,144,482,758,137,35,45,29,277 }, { 23,51,13,961,719,457,730,401,453,386,758,165,99,899,328,0,10,9,2,1,308,15,134,33,7,6,5,117,54,12,153,11,523,4,391,403,197,629,40,139,14,22,361,28,202,509,128,402,236,231,888,488,369,111,87,57,196,514,79,115,880,317,65,35,817,377,3,291,46,176,77,49,44,38,31,8,450,64,585,477,244,180,141,498,120,507,412,283,102,59,775,475,114,108,62,52,546,237,188,160,157,152,137,94,452,383,260,95,56,440,215,830,774,757,622,569,494,485,472,342,330,300,275,210,203,201,187,144 }, { 134,898,82,117,13,23,33,102,153,77,351,341,196,197,110,260,961,180,901,10,120,165,115,111,457,8,450,854,177,40,569,51,94,365,37,11,922,523,277,4,326,291,0,79,55,342,1,9,93,642,12,217,59,352,817,202,5,730,317,21,873,719,141,31,661,811,629,349,16,98,509,373,386,453,372,44,64,18,54,32,3,139,203,116,615,275,22,125,269,210,899,38,318,128,2,144,752,57,479,49,704,17,28,90,30,6,564,638,95,7,403,475,137,304,494,758,474,300,48,36,391,237,498,482,105,499,14,39 }, { 60,126,167,191,18,71,35,121,199,16,271,24,212,92,146,150,118,575,107,68,727,566,446,132,21,273,463,108,246,7,279,467,48,653,695,608,517,589,1,101,9,598,5,354,14,649,55,562,345,522,97,98,441,375,140,0,195,22,407,640,149,28,32,223,10,156,49,298,125,13,423,755,508,953,363,221,23,411,314,46,50,781,346,447,154,37,12,818,356,95,647,302,31,230,43,69,674,2,388,20,783,809,232,621,359,189,267,362,124,175,67,293,105,51,109,65,360,493,520,236,163,607,535,75,165,103,39,33 }, { 136,62,129,123,128,41,162,789,211,618,249,214,183,678,248,507,38,216,710,119,152,177,269,130,64,17,57,141,245,597,318,205,184,4,179,90,503,77,59,402,305,106,3,313,229,157,266,54,210,139,102,257,275,556,209,45,117,40,13,11,292,99,328,76,457,33,339,23,452,378,217,86,291,80,194,471,369,947,349,383,188,524,497,304,542,381,255,153,519,751,494,240,361,84,803,588,202,32,440,372,115,403,742,164,56,529,12,137,37,790,21,5,504,432,207,196,10,14,285,215,134,342,36,15,587,0,358,165 }, { 523,494,475,403,51,899,817,453,202,23,450,730,421,13,805,120,128,757,102,5,4,719,33,21,342,318,958,326,196,153,260,402,7,1,386,12,48,133,65,20,32,457,141,9,8,615,16,114,108,14,10,77,19,0,361,137,17,300,84,82,59,351,123,3,194,576,11,700,221,401,269,95,64,49,177,541,27,40,57,26,115,125,117,22,474,308,99,37,862,701,304,193,56,503,91,697,551,134,105,283,50,129,86,24,249,240,2,942,814,673,671,579,569,519,490,468,437,397,389,365,352,349,306,291,281,247,218,208 }, { 59,4,84,62,77,40,3,102,76,119,27,33,56,177,32,12,161,73,21,196,136,123,17,210,11,193,216,80,90,18,64,57,128,51,6,25,13,611,300,63,202,65,48,415,42,605,106,23,152,0,99,275,22,217,803,26,49,205,122,503,291,53,5,2,37,29,349,87,667,453,402,318,209,361,19,690,283,403,718,445,342,129,14,61,194,79,436,245,370,397,297,141,86,862,485,269,240,52,91,85,494,304,510,153,95,573,115,1,45,416,249,184,139,757,475,255,133,81,529,292,41,469,111,680,250,813,113,31 }, { 43,414,422,319,20,819,945,7,0,376,61,904,97,470,325,173,707,5,804,693,22,104,14,49,560,426,330,95,595,32,392,17,107,147,207,887,577,246,46,21,324,356,77,74,344,725,58,52,1,198,113,784,347,28,27,18,66,38,76,427,135,105,329,31,858,25,12,158,526,291,263,112,9,523,357,239,232,120,115,362,81,230,359,118,19,10,715,450,119,241,64,44,259,424,315,24,260,140,13,942,292,350,165,102,56,45,37,36,861,125,879,817,719,600,86,33,30,2,814,204,500,476,205,98,26,16,180,179 }, { 13,23,51,217,115,77,141,2,33,10,4,0,64,7,180,6,102,40,11,22,317,9,14,269,352,3,1,5,202,197,15,177,341,165,59,237,291,125,365,16,12,128,28,18,247,318,308,31,153,196,349,95,372,117,36,17,24,137,49,498,98,752,32,403,304,134,90,475,342,457,453,210,143,401,93,391,19,86,44,120,30,901,275,386,8,57,105,216,244,164,569,39,65,494,509,20,29,110,25,421,864,961,139,116,873,38,55,27,719,37,35,82,50,221,482,46,260,56,26,546,450,316,468,351,326,45,899,523 }, { 28,49,24,105,35,65,159,0,55,109,1,16,239,320,14,7,347,95,424,158,168,170,124,9,2,185,67,68,301,18,169,654,286,149,12,289,175,36,5,127,154,21,10,71,69,114,98,64,740,83,512,39,108,13,272,48,164,327,31,23,623,420,374,395,46,50,713,125,371,518,51,194,338,577,312,6,37,143,916,22,346,344,429,570,32,86,835,103,336,761,101,928,44,638,242,890,737,60,133,202,237,293,115,538,30,762,128,141,137,38,302,398,747,484,479,165,439,189,96,844,610,92,221,299,892,308,54,131 }, { 15,10,0,12,1,457,13,165,5,2,82,9,4,117,120,7,961,3,134,6,64,22,197,14,11,260,351,37,33,32,51,21,31,719,77,141,180,38,341,17,8,365,450,317,102,217,153,28,523,269,110,115,44,93,898,372,854,202,386,18,196,40,291,326,99,901,49,730,349,453,352,16,128,125,922,36,237,72,111,318,509,177,76,59,342,403,48,475,817,401,98,391,29,30,89,752,90,474,373,569,27,137,45,704,24,275,19,95,328,55,494,54,498,86,899,143,437,139,210,304,629,758,57,25,402,116,546,873 }, { 7,97,71,14,92,150,140,60,149,189,18,16,517,69,336,398,298,154,124,66,302,35,43,68,175,467,273,38,230,118,251,508,314,429,24,2,28,399,172,232,20,0,882,36,279,55,423,173,267,6,46,1,107,126,67,375,83,566,108,22,74,65,547,29,607,104,192,5,426,246,135,847,52,81,531,420,109,596,501,10,809,9,13,952,387,533,505,608,484,169,21,458,330,674,628,49,823,86,25,345,158,51,191,705,48,101,637,12,386,723,439,570,324,653,462,185,168,697,779,535,783,796,346,114,722,861,799,95 }, { 102,4,77,59,33,210,11,342,40,32,12,64,128,139,624,5,503,196,202,90,494,21,300,91,51,233,318,403,23,17,291,177,416,269,275,678,141,817,450,13,529,0,25,10,3,485,277,153,151,49,37,42,789,216,496,457,115,57,197,680,214,22,18,788,523,249,205,27,389,194,86,72,453,122,145,480,81,26,961,280,148,138,134,111,104,74,65,6,899,730,204,165,120,89,209,804,475,348,123,95,19,636,396,174,693,651,287,125,869,750,629,306,257,76,48,386,349,221,61,45,803,784,544,402,397,240,58,31 }, { 25,42,256,235,19,122,85,436,813,6,297,680,53,26,573,416,233,445,390,63,605,73,250,343,80,27,65,630,389,283,106,255,194,444,45,17,138,544,396,690,525,503,648,269,141,64,119,33,145,123,611,113,128,102,174,112,84,91,29,789,70,624,4,412,77,0,736,483,209,358,205,597,179,56,117,249,243,280,287,108,153,650,196,619,114,32,136,78,678,18,746,348,5,129,2,495,200,57,14,378,76,240,40,511,86,137,161,90,216,10,684,881,23,665,222,22,432,12,289,51,177,1,21,214,370,245,134,11 }, { 102,300,402,128,202,403,33,23,342,77,40,99,21,757,84,12,115,196,483,318,19,119,117,210,494,139,90,32,25,4,569,153,469,277,26,475,91,134,63,59,80,523,73,14,275,51,485,453,44,36,31,10,6,48,576,37,49,22,352,193,56,165,18,790,152,415,53,42,880,125,370,291,177,74,13,1,197,180,81,64,62,3,814,611,343,161,136,106,391,386,138,129,66,54,45,38,34,27,17,2,678,11,378,770,697,543,511,504,120,65,82,226,961,899,862,730,718,690,643,317,256,235,89,87,72,61,47,605 }, { 158,109,9,39,49,0,35,65,168,68,24,124,159,344,185,154,22,55,333,577,272,175,254,289,810,169,16,327,101,346,95,105,570,149,747,627,286,374,71,310,703,67,439,793,30,28,252,429,131,419,1,455,912,114,610,671,347,18,424,364,7,36,835,100,194,14,21,420,239,336,86,688,10,634,69,108,83,538,706,709,578,484,23,518,2,320,64,51,13,166,48,12,60,118,962,170,128,5,190,133,913,398,50,46,125,677,535,137,127,96,98,345,302,189,826,584,103,251,31,224,638,37,265,92,160,722,219,32 }, { 237,498,546,180,115,197,873,287,5,34,923,61,297,509,165,45,400,80,445,2,311,341,3,58,52,468,176,231,186,881,250,64,13,56,151,48,17,217,62,490,14,153,141,23,513,901,51,391,21,667,334,247,352,903,171,84,482,161,549,10,72,401,243,53,738,592,196,46,316,73,719,308,869,666,396,365,645,106,130,585,125,887,635,569,215,86,749,1,207,864,472,177,211,317,22,659,573,37,95,40,227,136,33,372,527,29,507,483,128,651,90,469,229,629,436,833,721,787,758,515,437,54,36,27,117,32,430,304 }, { 120,968,704,260,373,450,202,137,661,326,717,269,349,110,217,77,318,473,1,652,95,851,291,93,177,244,33,21,372,141,719,102,351,82,518,156,51,48,848,340,210,928,713,160,922,98,296,128,817,146,86,827,304,264,32,197,225,115,623,317,212,96,23,751,386,854,35,13,7,863,698,180,919,494,385,64,800,253,730,678,523,140,15,70,65,303,453,437,275,247,49,642,341,352,127,37,888,737,5,942,898,167,776,87,658,744,692,615,389,203,101,36,478,196,190,393,59,55,363,132,118,850,163,131,916,836,811,599 }, { 44,116,144,268,489,434,367,384,127,918,98,855,940,948,617,206,203,959,93,137,105,31,332,393,492,22,131,9,911,282,276,141,219,202,0,49,284,28,299,120,326,36,39,417,269,1,51,523,30,473,935,899,293,318,352,125,23,395,253,64,13,244,55,160,10,551,128,95,403,373,201,143,450,115,260,8,692,386,21,86,109,110,187,730,165,456,272,737,159,791,261,499,170,7,16,341,728,295,77,951,5,48,96,944,559,242,258,365,371,494,24,254,2,317,421,578,752,18,224,716,164,197,391,285,301,498,924,12 }, { 77,13,23,51,102,33,141,64,115,0,177,291,217,202,269,6,2,7,4,318,40,14,180,128,59,1,10,196,117,153,22,11,16,15,352,95,134,9,137,3,165,197,210,18,86,403,17,237,28,49,304,342,125,275,12,349,24,341,247,317,453,5,90,19,475,216,57,25,36,494,65,365,27,20,457,31,120,143,93,498,372,308,401,402,391,29,26,752,260,98,110,719,312,82,961,164,45,56,386,35,44,139,21,99,509,30,730,194,38,244,144,351,8,37,111,203,421,546,50,300,96,288,285,208,46,54,39,901 }, { 15,4,11,40,141,165,23,32,202,180,21,197,64,269,125,13,59,386,120,93,51,110,77,5,128,57,318,457,82,3,12,523,260,0,17,49,10,450,730,134,117,31,403,1,719,352,8,102,137,22,115,90,153,899,351,98,44,326,237,2,494,475,139,203,391,144,9,111,961,56,37,402,116,177,210,48,801,453,65,196,6,95,217,341,509,14,421,99,76,291,7,86,216,373,758,401,498,18,28,752,27,36,275,365,300,72,342,615,901,854,898,247,317,45,922,105,127,30,308,152,304,123,817,551,19,791,393,55 }, { 176,231,585,62,56,161,412,34,236,527,14,440,202,3,57,17,283,361,84,402,136,23,369,51,128,4,803,13,130,472,383,548,322,507,46,719,457,555,53,73,38,514,503,250,381,119,59,200,162,64,77,452,401,495,153,469,11,229,318,29,205,211,196,497,453,152,2,730,556,240,33,390,27,372,210,184,106,961,215,183,123,65,757,629,99,494,108,129,52,37,18,0,21,40,529,515,475,54,377,828,275,209,197,217,117,1,899,543,300,269,245,862,483,305,45,504,378,342,297,111,102,76,50,24,10,95,12,611 }, { 101,9,237,180,0,352,217,230,498,141,100,88,702,115,68,317,83,175,213,39,365,1,252,30,345,752,64,546,482,208,321,864,265,341,490,562,13,372,818,336,952,399,128,69,36,244,197,212,96,410,21,154,689,269,158,28,251,289,166,194,65,382,419,48,443,759,596,901,873,23,468,67,51,16,547,831,797,165,570,55,285,264,930,329,49,756,646,346,124,694,144,391,579,799,854,247,35,190,189,164,699,755,24,364,203,777,323,238,429,569,768,435,37,724,466,201,349,12,509,723,840,50,789,826,160,676,291,137 }, { 28,22,49,109,9,39,1,95,0,105,158,168,83,185,159,55,86,30,96,208,141,272,128,12,420,5,505,13,31,327,169,160,131,69,67,137,23,202,21,64,115,251,286,254,51,35,98,127,2,101,244,44,238,194,48,197,50,531,10,7,217,927,180,533,175,352,584,103,285,269,165,37,65,218,100,535,317,323,68,374,946,239,597,24,837,735,289,797,896,418,341,347,333,601,170,116,346,365,237,143,318,345,678,32,344,125,16,164,498,627,253,752,402,577,424,310,4,219,99,403,252,6,312,144,578,166,789,242 }, { 72,76,38,89,51,477,4,413,308,179,474,12,152,401,57,148,59,11,205,99,54,421,670,23,245,17,629,431,79,488,405,90,94,184,13,569,21,453,32,229,128,3,358,45,197,14,475,188,77,528,157,464,316,165,257,543,115,41,288,202,457,428,961,216,15,341,403,40,734,266,5,339,749,10,64,33,2,452,328,217,645,460,141,775,111,313,468,1,247,361,102,277,432,743,365,381,587,482,62,509,37,269,0,769,497,471,285,137,402,177,794,449,155,6,318,542,377,86,805,181,129,9,369,7,153,524,349,243 }, { 23,13,457,961,15,51,165,629,12,719,11,3,197,2,1,37,0,117,5,569,7,509,33,153,40,196,6,134,328,99,9,542,391,237,17,474,139,111,277,64,453,54,730,546,386,401,57,4,38,14,514,45,775,59,734,361,115,21,102,41,498,477,77,873,431,475,880,369,339,19,587,62,89,377,29,27,523,479,248,128,758,308,482,352,291,275,210,32,8,468,413,164,94,155,659,428,864,752,751,579,494,405,403,397,342,247,240,216,184,180,171,148,122,106,91,84,72,56,52,34,721,188,157,79,654,597,312,95 }, { 254,310,100,166,625,9,265,272,30,731,190,39,404,557,688,1,578,131,98,593,101,616,438,264,0,31,829,252,795,716,127,21,382,51,812,49,88,93,613,48,105,827,478,274,18,639,329,36,44,656,23,203,363,68,411,96,682,159,16,116,327,160,242,128,333,13,5,938,910,224,35,447,286,676,144,165,921,530,67,228,137,520,125,219,223,22,724,455,86,33,846,110,284,118,627,905,120,24,77,115,65,83,737,435,32,158,856,664,95,326,924,821,102,518,167,960,202,385,395,931,371,406,10,69,403,55,709,40 }, { 51,23,202,99,128,12,15,13,120,403,10,453,153,196,141,64,165,5,318,117,475,82,197,269,401,33,260,2,37,3,1,110,0,14,180,93,386,22,21,450,421,31,402,115,125,137,17,351,134,326,102,494,6,38,308,457,44,36,4,77,11,95,523,28,49,7,9,8,719,237,352,730,32,203,116,391,373,57,18,98,59,361,86,54,19,89,285,775,328,277,757,498,341,854,111,16,27,139,72,45,48,41,143,79,509,961,898,758,342,291,65,474,488,30,569,217,144,56,901,242,899,670,34,24,678,817,922,194 }, { 38,99,542,453,139,196,117,457,23,328,13,111,37,134,961,11,12,775,401,51,587,40,474,153,277,477,54,629,475,33,719,79,165,41,14,569,157,4,413,188,89,115,64,339,734,308,15,361,369,197,313,102,94,247,155,45,248,236,57,514,72,758,402,128,181,485,377,509,86,237,488,0,403,266,141,46,10,164,211,471,184,588,65,180,29,2,875,528,490,95,76,22,5,50,17,7,721,670,391,49,18,503,817,789,431,21,257,216,32,208,305,177,136,1,880,803,352,140,342,260,229,202,67,867,597,59,757,899 }, { 85,6,233,343,91,25,138,26,63,174,256,235,122,29,19,81,283,65,605,648,42,718,445,370,4,74,59,573,389,416,194,396,45,177,544,297,355,64,141,348,145,77,114,216,123,280,436,881,133,680,432,87,70,511,137,108,27,128,57,630,0,11,415,18,90,503,619,86,412,40,287,17,397,789,222,14,73,269,32,66,52,291,204,243,56,22,209,275,597,104,76,72,529,148,678,84,80,119,53,643,304,210,208,285,33,46,2,523,5,311,813,636,510,381,255,10,524,112,102,403,289,214,152,483,62,736,525,349 }, { 49,5,197,408,193,18,20,61,713,350,173,21,64,97,509,95,729,841,263,0,241,32,165,104,43,422,65,125,35,510,60,474,7,120,102,523,397,14,48,232,260,128,347,68,546,387,38,58,693,403,16,105,81,71,115,784,10,560,91,72,6,862,27,92,51,707,344,22,9,237,319,29,414,107,55,66,643,147,663,450,391,498,240,357,70,468,90,2,751,370,98,701,84,819,903,330,207,623,141,63,52,718,569,308,864,475,25,159,74,283,356,326,158,86,12,900,494,137,171,42,221,202,85,734,386,847,873,650 }, { 434,144,268,489,116,384,367,855,940,206,617,332,959,911,127,93,44,98,203,137,276,282,219,202,131,22,141,31,417,284,918,9,36,105,28,201,269,258,244,120,473,23,318,523,51,326,253,1,450,39,0,30,352,160,948,143,10,13,8,110,49,64,125,55,551,935,951,692,295,187,128,21,86,261,567,260,499,559,373,96,224,170,899,386,242,115,299,817,95,662,728,293,165,197,811,395,159,48,492,365,109,317,498,403,37,752,341,393,836,638,717,5,180,254,77,15,272,851,164,24,944,494,237,385,16,7,301,391 }, { 106,17,255,32,64,62,136,292,162,129,476,352,237,214,123,519,241,720,141,752,498,247,211,41,119,209,864,507,249,180,179,290,710,954,425,148,317,618,197,90,186,21,5,115,248,77,76,269,217,183,45,48,14,227,130,3,263,12,304,38,165,128,243,546,23,2,358,207,117,164,57,579,51,245,205,54,454,313,152,350,177,13,155,873,339,270,50,4,428,378,157,655,449,496,305,400,365,171,86,1,437,742,556,372,369,408,471,328,266,216,33,80,153,139,460,181,597,542,316,40,102,29,751,59,361,257,84,341 }, { 2,29,52,58,5,50,27,6,53,26,171,45,366,151,14,287,61,19,357,74,17,73,764,1,113,34,297,309,218,262,181,38,133,48,583,70,487,600,739,334,25,396,250,760,281,96,186,445,516,75,502,635,315,114,308,108,3,223,80,549,42,545,103,331,324,106,200,163,112,21,785,67,436,145,603,238,401,243,51,37,651,433,155,834,491,675,236,99,745,209,161,13,845,32,227,115,409,23,894,388,765,12,56,36,311,255,220,920,766,138,323,453,573,24,594,62,59,65,832,754,160,86,54,307,283,83,285,629 }, { 130,711,412,381,59,196,210,730,236,77,402,401,803,202,453,361,99,108,283,291,153,57,183,128,503,421,4,51,14,719,432,11,318,275,117,23,529,757,3,475,13,339,457,133,488,123,670,899,603,369,134,33,65,46,266,386,2,47,754,12,32,389,114,38,838,56,300,40,102,177,739,111,961,523,629,328,758,64,54,90,216,514,269,21,594,0,743,37,775,657,576,894,403,152,650,194,471,34,200,5,832,162,50,494,805,472,18,165,22,6,29,181,95,285,10,129,188,480,15,1,322,24,229,342,139,714,79,86 }, { 13,23,51,217,115,77,141,33,4,64,10,202,102,180,0,40,317,352,177,11,291,269,197,165,9,32,22,59,7,2,128,318,341,18,15,21,237,137,117,6,16,5,95,3,153,403,125,349,365,14,247,752,49,12,196,28,31,453,90,1,24,98,304,17,143,494,372,308,244,475,498,134,210,221,120,901,401,36,342,421,86,93,44,30,216,260,35,164,457,19,110,275,569,391,57,386,203,105,326,55,864,82,402,523,241,139,8,450,39,873,730,719,144,65,20,253,160,27,351,116,72,29,437,509,37,629,285,546 }, { 23,13,202,51,21,269,141,120,5,48,128,137,318,523,15,102,125,98,1,450,93,403,165,260,64,197,77,33,180,12,457,32,221,82,817,115,44,110,31,7,352,494,2,386,475,308,117,4,153,326,14,401,719,116,196,421,37,237,16,453,9,144,730,351,17,99,6,30,291,402,203,18,11,899,19,24,217,96,498,40,391,20,10,39,95,854,3,341,50,134,349,293,373,177,615,35,365,65,139,0,45,285,372,61,8,317,90,922,805,901,342,59,43,898,76,29,509,393,127,86,752,170,208,105,89,72,67,38 }, { 2,1,46,14,52,29,171,67,38,103,58,75,70,69,163,24,83,223,5,96,309,181,54,186,112,334,108,45,394,675,155,366,220,35,238,151,16,236,409,18,281,760,307,133,537,400,36,71,189,328,227,433,28,218,766,61,545,65,17,487,149,7,48,552,21,502,0,12,262,19,87,6,765,114,25,388,267,150,113,820,418,50,549,27,26,37,251,22,99,335,430,486,32,60,536,287,68,587,9,828,55,64,74,243,10,516,137,160,86,66,128,311,600,696,739,852,583,451,336,315,514,72,135,80,175,145,89,294 }, { 15,2,1,13,0,10,153,5,9,7,12,23,3,14,117,6,165,134,4,719,457,196,82,341,180,197,33,22,120,115,77,8,961,21,64,217,102,317,569,365,351,141,260,32,31,18,28,291,11,16,110,111,37,125,93,386,17,202,40,450,269,372,730,901,99,898,44,36,177,854,38,342,349,352,48,523,758,318,453,57,128,401,391,304,72,76,403,19,922,326,752,29,629,49,509,475,237,137,116,98,89,55,373,95,24,27,26,30,494,247,59,482,86,25,210,96,54,46,437,899,139,65,253,817,661,498,308,873 }, { 509,197,546,391,165,180,308,13,23,498,569,29,873,115,901,5,401,61,457,903,80,734,629,468,3,287,34,2,45,758,311,445,250,579,297,341,961,237,17,186,171,749,386,51,14,38,217,231,48,58,62,400,46,752,247,64,211,176,490,106,719,56,764,738,667,227,215,349,151,11,558,316,502,513,833,32,161,243,54,317,153,196,50,21,53,40,365,583,155,923,10,6,587,334,305,483,33,4,369,372,181,136,1,125,119,12,482,130,552,263,57,52,95,123,814,266,84,832,495,645,739,864,96,15,787,472,129,36 }, { 73,19,250,27,714,200,444,472,26,34,813,53,390,322,17,283,78,297,106,630,436,113,122,690,123,432,136,128,176,862,161,389,503,684,611,495,80,378,62,42,108,529,14,56,469,57,25,412,236,177,59,47,65,102,6,216,275,3,381,680,235,179,527,605,84,129,383,130,619,183,368,46,255,814,33,23,318,2,789,77,141,13,453,194,245,51,11,445,45,4,152,63,650,269,22,90,64,0,133,440,29,349,40,585,86,678,736,291,95,196,153,184,361,18,210,38,58,803,401,5,117,10,114,358,61,730,249,119 }, { 17,21,3,45,62,32,155,119,106,38,5,328,14,828,227,76,2,401,209,123,129,243,270,115,540,29,56,536,46,12,221,488,99,13,629,57,72,719,181,51,552,290,361,136,41,37,514,165,543,152,421,408,84,48,77,308,207,255,90,306,23,263,569,11,454,52,587,162,758,378,4,89,80,754,130,402,236,197,186,440,457,27,383,157,50,1,183,311,832,128,10,794,425,59,576,961,211,741,453,805,790,86,742,496,386,34,313,54,700,600,266,148,659,202,19,94,341,22,880,509,229,240,697,770,670,548,73,177 }, { 115,341,873,365,197,13,901,180,569,752,317,1,509,498,10,143,15,4,634,165,268,943,261,5,258,23,237,116,141,0,127,601,244,843,282,253,164,44,12,33,64,860,638,533,219,77,144,9,567,31,134,7,2,352,864,276,160,535,51,206,217,824,125,391,8,28,951,295,11,93,332,201,40,964,844,308,137,6,3,120,531,260,22,36,482,98,177,111,318,474,417,37,170,82,961,291,196,102,169,924,434,203,153,94,954,395,734,898,384,269,242,479,965,735,405,326,30,728,662,617,386,159,24,18,944,401,301,367 }, { 453,51,23,33,403,475,421,196,153,102,670,13,117,753,134,40,494,523,4,730,342,0,21,65,59,22,12,880,77,11,86,801,401,719,202,48,28,899,18,805,757,64,14,10,24,128,1,629,457,99,108,57,308,5,2,217,317,139,16,485,569,165,141,36,361,341,365,177,143,125,283,386,120,82,44,9,115,221,7,817,576,300,152,137,124,123,98,61,50,46,32,6,450,111,775,543,488,417,269,197,114,110,95,93,54,35,31,402,34,17,3,911,642,564,561,554,511,431,332,277,261,253,242,239,194,170,116,96 }, { 23,13,51,33,12,453,196,117,99,153,134,40,102,403,14,128,202,77,15,401,475,37,139,38,54,11,64,165,421,21,2,0,141,115,308,318,719,328,65,108,670,197,10,46,457,361,269,730,79,1,22,402,28,111,120,95,82,18,3,386,9,389,6,17,283,50,36,24,86,236,114,125,775,5,494,180,4,260,31,94,41,32,899,523,19,210,110,137,59,391,7,326,488,450,351,291,217,177,412,341,93,300,485,477,509,880,377,44,39,30,277,52,221,16,8,961,629,365,203,29,758,133,26,817,350,342,237,194 }, { 2,7,14,5,52,29,70,61,112,46,87,592,135,1,66,45,38,16,32,6,186,21,315,290,48,227,24,72,307,113,75,172,425,20,243,58,74,97,666,128,845,631,76,226,155,294,18,738,23,270,25,35,64,141,334,115,0,89,22,50,43,163,151,37,51,171,77,207,69,17,220,36,177,202,19,262,10,13,137,9,90,232,4,54,86,92,263,269,255,278,59,496,655,60,28,95,140,26,106,27,180,12,454,192,148,67,40,209,102,318,33,292,400,849,49,65,324,331,409,405,217,491,311,461,549,476,431,210 }, { 33,102,128,202,51,23,141,196,64,153,13,269,318,403,77,117,10,137,134,40,1,5,453,2,6,165,3,0,14,475,86,99,139,15,180,120,12,22,494,402,17,197,352,260,19,7,95,342,21,110,237,65,82,115,93,125,31,36,37,277,18,217,210,9,49,44,25,177,291,326,523,38,450,401,194,32,457,421,285,386,26,28,351,16,111,719,27,4,11,114,48,341,203,300,8,752,98,373,143,730,361,498,57,54,365,317,24,164,961,116,569,108,275,899,50,34,391,45,41,901,96,244,29,629,133,72,509,144 }, { 92,16,43,20,126,107,7,35,71,97,14,60,140,246,279,68,18,149,230,121,575,356,375,191,362,24,783,150,118,55,695,566,345,48,0,359,175,173,319,598,298,232,939,22,653,441,167,463,21,414,125,819,467,407,33,69,346,38,422,146,77,446,154,608,28,649,336,172,10,199,102,101,104,168,189,637,251,212,49,314,376,2,124,51,9,595,399,221,23,66,5,392,541,755,196,470,386,13,6,158,117,768,393,147,628,551,493,683,165,67,46,36,259,108,81,1,727,535,364,342,325,672,267,281,674,120,203,153 }, { 13,23,77,115,51,33,59,4,177,40,90,64,102,32,141,202,10,128,22,210,291,0,11,21,117,95,137,217,16,318,196,9,180,153,7,197,165,49,28,269,6,342,14,18,2,216,1,237,134,86,98,352,349,203,326,24,403,36,494,31,125,450,120,475,275,15,93,351,341,260,194,386,105,3,247,48,57,365,373,20,372,402,317,457,44,5,139,110,17,35,30,25,12,498,76,144,116,72,39,453,304,19,300,244,208,82,60,401,143,285,65,214,55,38,26,817,569,50,678,551,391,308,123,111,46,854,509,523 }, { 507,162,129,211,41,183,38,123,4,248,59,62,57,556,130,99,361,402,305,128,202,11,266,136,17,3,77,803,152,497,313,452,184,210,369,33,40,471,339,56,117,757,157,54,328,229,205,494,381,23,139,457,153,12,403,84,503,257,19,34,65,13,76,514,119,275,37,188,542,14,80,106,440,475,775,318,618,102,21,134,453,300,27,432,64,880,95,89,49,141,86,196,32,529,377,249,73,79,460,177,50,5,10,90,53,619,548,342,94,401,269,179,288,587,961,383,148,114,579,115,477,216,72,45,805,285,291,217 }, { 643,123,193,718,650,18,802,65,389,84,415,91,177,25,90,619,256,216,87,289,511,183,736,370,217,324,380,235,108,63,808,500,432,102,249,57,275,194,152,6,673,510,304,862,240,524,355,588,561,397,233,372,13,523,130,81,96,4,0,343,605,141,1,22,103,77,59,283,214,64,789,437,306,630,23,85,153,80,33,475,597,529,210,544,349,196,129,56,291,32,27,847,300,114,889,550,138,86,886,444,269,124,28,26,416,421,280,208,174,70,10,2,814,401,115,19,851,117,42,730,469,352,204,17,202,150,73,51 }, { 23,13,51,15,5,1,2,7,115,0,12,6,165,141,21,3,4,457,9,197,180,32,77,14,37,202,217,10,33,120,341,352,11,269,22,8,16,93,569,961,31,401,318,102,247,719,453,308,629,17,365,18,260,403,177,317,901,386,40,48,509,137,752,44,730,28,391,498,72,117,523,128,110,153,59,450,98,494,99,196,36,372,237,30,90,49,475,134,291,326,125,24,210,95,349,89,899,482,38,116,421,468,351,304,19,76,873,82,20,139,57,734,203,86,342,373,546,54,39,437,45,65,817,854,758,922,144,96 }, { 51,23,13,453,21,403,12,475,202,165,141,64,128,115,32,5,95,523,125,730,494,180,197,401,899,308,48,120,37,719,386,269,318,817,457,4,99,421,3,326,1,6,237,17,450,2,260,10,19,22,14,0,217,194,18,402,77,221,90,247,15,177,27,25,26,961,59,9,7,758,137,16,670,391,352,117,11,801,312,33,110,82,50,28,241,57,40,351,123,153,49,615,317,291,72,341,210,24,86,54,61,29,196,102,216,93,56,569,31,304,170,98,275,289,46,42,20,629,361,108,58,89,389,283,144,45,84,203 }, { 204,74,135,174,192,66,138,85,6,280,353,348,580,172,7,673,97,889,426,500,792,568,95,87,355,32,620,64,712,29,65,91,233,81,232,222,52,448,43,872,25,825,42,104,173,888,22,289,226,63,526,86,387,5,312,636,861,49,90,237,278,2,343,415,194,560,21,0,715,92,38,214,145,140,20,256,835,324,235,330,18,10,750,61,28,75,808,1,4,26,681,288,77,36,24,70,69,58,107,45,874,347,125,14,112,314,33,72,337,102,298,241,294,707,59,729,108,180,37,115,370,40,287,76,48,356,164,117 }, { 35,68,149,24,69,0,65,133,103,16,189,9,28,18,50,114,175,336,124,101,1,71,154,46,83,251,14,7,2,55,283,118,230,108,218,238,38,398,345,140,705,75,54,302,443,39,596,22,532,309,335,181,96,361,418,21,399,12,52,394,565,433,412,267,346,109,60,5,29,36,486,236,48,160,375,732,831,545,23,480,487,516,51,220,92,366,86,429,10,13,64,323,328,67,49,252,30,37,330,514,364,212,100,439,547,158,389,95,87,458,194,115,32,646,891,930,246,208,70,641,171,163,6,191,223,722,167,99 }, { 101,118,16,71,24,9,18,154,191,212,0,35,60,520,124,68,694,806,167,364,375,252,604,346,55,302,562,628,28,39,149,917,439,126,419,92,65,826,329,100,706,589,166,108,175,265,264,21,1,273,199,109,22,701,48,925,676,49,158,7,150,363,404,10,146,942,5,88,121,815,105,411,14,967,682,67,23,535,69,13,818,566,882,50,777,907,647,429,95,159,51,96,30,12,333,621,31,2,857,848,32,107,140,722,98,575,821,246,37,847,46,382,905,221,677,169,36,336,125,553,695,83,467,593,185,759,114,286 }, { 35,16,9,0,68,24,65,1,18,71,149,103,67,189,101,28,21,48,212,114,23,335,486,124,13,51,39,118,167,191,55,154,7,133,238,433,50,30,443,141,96,230,22,100,140,218,60,5,137,64,537,352,115,12,88,330,217,223,75,10,128,399,37,269,49,83,411,202,32,283,175,36,31,221,246,264,98,163,398,2,281,723,375,302,69,166,478,447,125,108,487,180,54,372,317,589,44,99,520,336,181,361,345,418,318,363,177,86,695,341,664,565,77,160,95,545,562,252,70,237,116,752,532,190,72,105,92,14 }, { 13,23,202,77,51,128,33,32,115,102,21,269,177,141,318,64,5,217,137,494,291,11,4,10,0,48,22,153,95,210,117,86,90,196,3,15,6,317,2,49,125,349,40,18,12,342,352,9,31,17,247,304,403,194,134,36,16,7,14,450,19,275,98,180,120,1,61,44,372,216,28,341,65,165,221,326,116,76,20,260,59,523,237,365,285,203,24,35,105,453,288,143,386,678,30,351,101,68,60,55,25,817,421,475,96,901,401,367,308,293,99,93,82,39,37,27,752,312,144,615,323,730,58,72,437,859,899,316 }, { 16,92,60,35,7,18,68,150,24,126,149,97,191,246,375,118,14,230,107,140,71,273,575,175,517,653,154,566,55,43,298,345,167,399,0,121,28,467,20,108,279,212,101,441,346,302,336,66,423,232,508,48,22,674,124,38,356,608,314,9,21,2,189,199,359,446,49,10,695,46,5,69,1,463,65,815,589,12,172,439,607,755,251,146,37,362,67,392,23,173,6,109,13,722,125,809,702,796,628,36,32,51,95,637,74,135,354,398,52,132,83,29,429,221,407,768,882,105,672,50,64,104,86,271,501,364,535,96 }, { 76,90,464,21,179,316,205,288,460,245,32,257,184,148,45,358,152,57,270,48,241,38,449,89,14,2,1,350,769,645,229,155,5,497,221,54,17,524,37,243,12,59,227,405,266,428,4,452,413,308,749,432,50,619,99,720,51,29,292,476,217,11,290,46,157,115,79,188,339,129,313,216,401,381,431,471,171,341,247,77,10,94,106,513,400,3,23,64,317,141,52,7,0,365,773,474,477,72,430,528,36,659,162,369,453,181,62,214,128,33,237,741,186,9,6,281,328,13,202,102,502,349,536,498,177,291,180,372 }, { 19,297,26,27,813,80,436,495,17,73,53,250,122,106,200,113,378,390,690,42,4,45,469,361,59,25,742,128,136,161,77,255,202,736,445,605,402,123,862,630,40,63,318,78,383,803,56,11,235,102,283,444,119,527,6,62,210,503,680,14,57,33,148,472,209,129,684,256,84,412,667,611,18,573,85,365,483,0,177,12,3,300,814,153,504,65,22,76,139,61,34,205,133,341,117,64,51,23,13,58,269,152,90,257,10,236,2,358,497,38,432,342,95,47,368,243,183,494,757,453,619,196,184,548,171,714,475,322 }, { 6,26,235,138,145,112,19,42,624,122,70,648,27,331,262,85,78,47,25,500,52,632,630,226,113,444,307,644,409,453,29,222,665,163,75,50,849,324,2,65,108,390,294,64,675,53,416,711,130,220,22,34,196,17,73,813,87,32,95,680,14,280,223,852,412,133,730,151,74,237,315,33,86,45,115,66,197,287,241,58,236,153,583,51,256,28,5,114,1,297,283,792,180,4,165,38,90,63,135,102,337,690,250,21,3,171,820,396,546,36,853,889,357,10,183,137,46,200,445,56,475,125,99,461,603,309,117,0 }, { 16,7,14,92,24,35,60,18,46,140,126,71,87,50,171,54,9,2,38,5,0,220,108,69,23,230,21,13,246,128,163,70,12,107,394,58,20,68,64,121,155,150,330,309,28,48,22,67,32,10,51,141,267,137,55,314,236,202,146,1,37,281,115,181,502,461,269,189,307,852,232,774,132,97,571,328,75,43,223,65,278,199,52,217,86,820,77,366,335,172,72,112,186,6,409,622,318,99,61,95,103,149,262,49,780,552,177,133,36,227,29,294,462,430,17,334,135,352,572,45,675,563,270,66,33,451,39,180 }, { 257,90,205,184,460,769,245,32,179,524,5,45,229,497,288,152,619,21,57,432,452,2,17,292,59,381,266,14,476,1,4,48,106,241,316,358,216,255,29,77,38,217,11,54,155,58,313,64,263,157,425,76,471,12,129,6,227,72,243,148,186,141,3,79,247,37,128,7,339,464,214,188,290,209,207,99,720,519,369,317,177,40,50,115,365,33,710,51,89,270,269,102,221,588,86,46,162,61,202,529,237,291,111,454,94,10,62,372,408,875,23,277,350,618,210,645,349,123,308,19,52,25,180,36,449,352,119,181 }, { 15,4,5,11,13,23,141,21,32,40,202,180,1,0,33,269,3,128,17,318,352,134,51,120,2,64,153,117,450,31,326,12,137,196,22,197,102,82,260,44,6,752,165,59,10,49,7,48,177,217,494,57,341,115,403,523,95,901,237,386,457,37,210,14,317,98,351,365,90,56,9,961,203,817,498,719,125,93,28,730,18,110,19,372,116,291,244,678,86,475,615,8,194,76,342,27,45,453,349,36,61,139,96,873,864,216,402,391,111,72,373,16,275,143,285,30,25,247,39,144,300,253,24,922,214,38,70,164 }, { 130,711,47,412,108,453,730,196,283,390,78,381,27,183,236,503,472,51,14,200,803,128,153,719,59,250,133,432,34,318,57,73,123,4,114,117,65,17,53,177,33,576,714,216,657,56,378,322,475,46,23,3,529,754,134,369,275,339,19,11,269,12,389,899,291,813,402,650,368,40,603,401,21,444,361,436,266,210,99,457,297,202,480,77,102,54,666,592,513,349,403,129,194,106,894,38,471,0,523,32,739,137,18,22,2,690,136,386,594,152,161,684,678,181,162,548,26,670,141,37,10,184,814,743,421,789,45,629 }, { 12,277,51,474,153,111,99,23,37,13,629,961,431,94,569,38,453,542,139,115,79,134,117,401,196,33,40,188,157,89,11,775,457,72,485,15,405,54,4,339,413,300,377,197,477,148,313,328,165,59,734,308,102,719,76,14,45,210,179,21,128,730,152,3,64,17,509,498,386,10,266,880,2,77,32,391,57,482,41,475,0,471,403,304,141,177,898,523,82,18,365,490,205,758,275,5,217,29,402,546,372,488,260,351,341,120,24,202,452,358,237,22,352,873,468,361,6,269,317,216,155,437,162,48,1,229,31,811 }, { 495,469,17,378,106,26,27,483,161,862,383,742,19,73,80,527,53,436,814,136,297,84,62,119,611,56,250,25,440,209,113,42,6,122,34,4,255,128,240,14,3,684,200,59,585,129,65,45,29,123,504,57,573,2,5,11,445,361,141,630,61,64,205,179,86,833,76,32,667,690,33,235,202,245,162,618,40,283,680,548,318,472,402,269,503,77,555,102,194,184,108,183,207,95,151,21,152,112,177,514,46,153,887,491,311,803,54,58,257,12,38,10,507,90,648,196,51,176,22,614,306,48,0,229,130,145,1,114 }, { 681,636,81,750,91,370,138,718,0,104,348,784,174,397,673,693,18,29,355,192,173,280,74,426,306,65,207,6,701,715,86,319,64,124,671,85,52,32,289,95,510,22,90,511,887,204,343,712,560,879,526,422,240,233,214,7,49,312,40,120,72,77,519,43,24,707,484,4,577,353,42,523,84,63,11,177,27,145,835,730,57,474,643,151,448,756,28,25,10,61,19,21,20,260,415,102,194,888,580,87,861,610,825,33,288,232,193,115,66,59,817,76,45,172,847,17,2,719,457,273,114,26,23,450,168,13,414,302 }, { 15,33,77,102,115,117,4,134,153,40,196,11,13,217,1,5,23,317,21,3,365,2,291,341,32,12,59,51,177,139,342,6,0,349,210,7,372,37,180,48,351,111,17,90,569,141,275,36,57,197,457,202,137,72,89,304,14,308,9,120,854,901,898,300,277,10,55,96,64,148,247,961,160,27,165,450,128,437,269,719,352,260,752,38,401,318,523,216,730,734,93,629,76,221,94,482,56,579,18,16,143,253,873,922,453,61,638,179,49,19,22,31,244,498,125,8,697,45,24,817,44,245,403,485,79,326,84,899 }, { 9,0,28,68,35,65,101,39,67,175,1,124,154,69,24,22,55,18,16,238,103,30,336,114,12,49,251,109,149,96,50,13,21,51,7,23,252,5,345,100,596,218,158,141,831,418,189,480,532,37,10,166,115,346,2,433,64,323,217,128,137,48,443,88,86,160,36,439,75,237,547,269,202,71,289,866,646,429,118,335,389,364,285,230,317,930,197,352,180,159,143,181,486,503,402,283,99,133,281,95,223,194,498,208,165,168,318,32,60,14,83,4,657,105,212,131,265,694,745,956,54,185,163,484,6,403,77,722 }, { 23,33,102,40,51,77,13,403,117,196,153,64,11,128,453,134,137,300,59,291,141,4,10,202,22,475,180,95,57,719,139,99,0,342,86,65,494,90,12,28,9,49,485,421,21,115,114,1,194,901,752,210,177,165,120,108,15,37,18,349,328,2,323,269,899,450,391,351,260,197,125,36,961,523,457,361,48,14,341,958,954,947,922,854,817,758,730,546,509,498,412,365,289,275,236,160,93,54,32,16,7,847,805,576,401,217,962,570,467,285,218,124,105,874,835,775,701,670,629,577,569,541,386,373,372,347,277,247 }, { 214,90,289,874,6,65,256,235,64,751,25,42,312,249,194,746,288,875,525,519,247,835,174,85,233,348,544,217,437,32,524,352,343,95,123,138,26,63,355,954,86,122,91,280,630,416,0,177,605,22,204,317,752,648,222,736,141,77,45,579,864,180,74,216,415,304,389,59,597,57,66,306,81,237,287,56,881,588,243,115,84,208,19,445,370,108,498,114,183,87,29,671,4,316,49,283,76,145,275,18,444,205,573,396,240,52,28,112,337,104,10,636,202,624,70,368,11,511,353,33,21,135,102,650,680,137,291,619 }, { 1,22,2,28,67,36,50,5,12,49,0,95,14,168,55,7,83,46,103,105,114,69,194,9,38,21,159,584,35,65,239,133,169,109,24,218,23,16,158,208,10,323,48,170,54,51,96,37,160,597,164,13,29,6,18,320,244,708,32,115,892,202,128,503,505,424,185,874,776,253,312,64,347,143,68,75,238,654,137,141,756,31,124,480,301,531,39,181,269,289,824,3,251,835,646,389,361,318,789,52,98,189,797,532,30,638,285,180,165,308,420,99,286,751,127,237,17,283,45,4,175,44,577,125,533,154,72,197 }, { 269,318,352,202,141,13,77,51,180,102,349,23,372,291,137,403,33,128,125,197,21,44,31,494,342,317,217,32,402,117,1,365,16,901,475,177,49,22,11,5,116,98,93,386,165,160,153,115,59,40,18,752,253,244,15,14,12,10,7,2,0,4,947,704,692,678,661,615,597,576,473,373,326,208,203,48,39,30,6,90,28,24,498,453,421,127,96,17,961,899,817,474,408,401,350,308,304,285,263,241,196,194,185,169,168,148,134,113,111,101,95,94,89,86,71,64,55,36,35,769,638,569,275,257,152,9,8,968 }, { 435,144,274,88,203,418,410,778,190,30,530,960,521,795,686,466,1,321,326,96,367,100,166,822,382,264,692,855,539,131,438,576,335,213,9,265,201,98,613,921,93,615,859,44,31,840,765,403,800,83,772,662,225,744,523,494,284,473,116,957,924,0,909,36,478,217,817,141,28,966,69,934,831,551,137,21,120,731,269,829,219,128,948,669,406,51,639,625,23,5,230,206,39,13,268,77,944,372,110,617,238,260,404,125,716,557,67,856,691,224,32,7,442,349,332,16,805,492,254,242,228,10,704,291,223,35,842,64 }, { 76,72,90,179,205,21,245,316,428,288,32,464,184,37,38,257,460,413,148,54,645,405,57,749,45,308,12,358,152,221,431,14,449,4,155,350,229,48,401,50,270,2,59,1,99,5,497,769,17,11,528,524,452,474,266,241,115,51,243,247,10,128,773,477,79,741,432,281,430,217,129,188,77,181,619,292,64,659,157,339,46,313,227,106,23,453,476,720,36,202,468,7,328,743,381,488,216,94,341,141,3,0,498,794,471,197,137,421,180,536,317,403,237,629,490,29,62,482,86,13,6,165,540,369,33,402,352,162 }, { 77,102,33,141,64,115,23,40,177,13,51,291,2,269,202,217,6,128,10,210,180,318,1,196,7,14,352,137,197,0,165,3,22,4,153,237,95,117,19,17,59,5,275,15,134,139,86,11,342,125,9,16,317,18,25,349,341,12,36,26,494,216,49,403,31,498,752,27,93,143,111,65,300,24,110,312,28,120,457,391,372,386,44,98,21,247,20,901,164,304,29,82,203,453,402,401,365,99,569,57,719,56,509,475,961,194,260,34,730,678,546,45,116,32,50,48,244,35,38,864,37,308,629,46,450,326,8,54 }, { 397,32,788,81,65,693,249,681,90,422,4,804,194,123,21,59,56,348,11,64,23,61,95,91,690,3,725,718,84,319,0,280,152,237,138,43,355,817,174,6,510,57,494,17,523,899,141,114,49,214,52,165,414,370,784,77,526,60,86,51,386,217,74,40,12,904,85,365,102,450,326,208,18,120,945,750,636,343,242,233,115,650,615,5,20,511,342,29,33,887,457,888,524,880,350,263,180,137,133,108,36,24,15,13,222,204,183,177,160,582,532,391,278,135,730,719,289,715,671,597,10,566,421,403,221,218,207,202 }, { 126,60,16,314,150,121,199,146,107,92,246,7,132,35,71,359,232,18,24,14,298,392,649,672,423,517,140,441,97,279,508,388,95,653,32,462,877,195,108,21,230,598,607,407,167,46,172,451,5,118,68,22,387,357,38,267,640,55,522,191,28,156,467,360,271,380,594,0,10,953,733,49,48,2,356,64,66,955,633,809,603,273,278,75,149,65,50,1,52,660,783,135,43,12,362,354,674,236,711,212,702,86,309,13,9,115,493,37,330,20,125,36,220,312,241,54,501,324,101,87,29,345,23,90,550,928,446,77 }, { 217,15,141,115,317,365,341,13,23,260,51,137,120,202,77,372,180,33,349,4,269,352,64,102,40,1,110,373,450,291,197,21,32,36,160,117,244,752,318,128,5,854,351,0,11,922,59,247,134,661,9,304,10,901,165,12,153,22,457,177,143,96,253,28,86,82,48,523,2,196,730,494,57,90,811,49,403,7,326,237,16,83,3,8,18,437,125,39,817,30,72,111,139,55,37,17,961,898,498,899,308,719,24,475,386,76,164,35,717,288,873,704,6,89,221,569,14,642,391,241,203,67,56,509,210,285,95,342 }, { 111,134,117,474,23,13,961,569,12,431,51,37,115,99,277,15,405,38,197,89,72,629,148,457,76,54,4,45,165,11,139,94,719,498,106,59,873,14,79,128,40,10,196,33,482,3,17,179,188,2,64,413,730,775,245,177,153,205,471,57,509,477,401,358,453,0,403,6,485,22,5,152,304,1,180,402,275,475,300,341,901,36,880,339,237,210,82,141,386,32,110,7,758,120,452,77,365,317,260,129,391,31,95,202,308,46,864,542,523,8,757,86,18,44,752,217,162,93,65,734,437,497,421,678,269,229,546,285 }, { 23,13,51,5,202,21,32,1,12,2,141,15,165,115,269,7,4,453,197,403,318,6,48,120,9,0,3,386,128,64,180,14,125,37,475,308,401,137,457,16,10,99,18,450,260,196,523,33,352,237,494,730,719,17,77,11,421,341,326,31,22,40,221,102,8,391,90,24,82,217,30,93,59,117,177,153,351,365,28,19,44,110,899,98,317,569,39,72,61,629,961,817,49,134,509,57,498,247,76,20,29,402,45,27,203,38,36,96,752,89,241,50,56,373,144,25,304,758,86,291,46,54,65,35,349,116,901,576 }, { 13,141,23,5,115,202,4,51,269,352,217,11,2,318,180,137,317,21,7,341,77,3,6,32,197,752,33,1,291,12,64,372,10,365,128,9,102,22,0,165,403,40,15,349,494,498,482,48,308,177,901,31,28,16,37,873,44,237,14,49,125,153,247,18,244,98,30,59,453,120,143,55,401,475,304,36,39,457,342,93,17,72,95,221,24,196,35,117,134,253,86,90,509,579,76,116,203,864,326,961,576,569,210,717,523,859,144,421,678,160,8,719,110,127,216,89,391,260,468,730,65,386,629,450,437,805,164,105 }, { 165,125,391,197,21,13,558,380,23,48,386,237,900,221,66,509,180,14,326,120,457,33,32,357,115,961,97,426,401,298,135,278,308,719,51,98,758,841,172,75,38,56,12,6,571,204,770,74,19,72,554,867,629,408,393,77,670,64,63,25,10,1,42,498,462,134,40,7,563,247,102,715,773,90,31,763,324,808,494,451,523,450,317,293,244,210,177,43,29,20,171,22,572,501,681,582,350,743,615,365,335,262,217,203,105,87,69,490,482,641,370,26,11,81,73,65,53,4,579,192,963,367,342,267,260,241,239,216 }, { 120,82,260,450,351,15,141,21,854,77,217,13,23,51,1,202,817,180,33,898,110,48,326,93,102,32,128,137,5,165,523,269,352,318,125,291,922,2,177,203,275,403,317,4,210,12,373,494,115,64,197,96,386,7,144,0,342,196,36,457,752,37,349,453,9,6,16,221,50,237,615,59,10,475,341,14,372,730,244,18,22,223,285,160,67,365,86,498,661,421,402,401,31,901,308,719,391,70,3,99,35,44,24,95,90,28,473,899,69,30,65,864,704,116,11,29,8,83,367,17,163,49,551,304,961,216,61,692 }, { 23,51,13,15,961,0,2,10,115,1,457,5,569,453,4,7,9,719,14,33,629,11,165,40,197,6,77,21,64,3,474,139,38,401,59,22,72,57,102,12,111,475,32,79,341,730,386,128,54,37,509,177,17,8,196,391,36,237,141,202,277,18,89,148,76,99,734,28,758,308,41,117,498,180,90,403,873,365,482,31,45,328,94,546,48,153,86,210,93,317,24,468,494,247,304,300,269,82,16,95,402,120,670,134,46,488,757,194,110,55,62,125,155,29,188,52,405,49,899,775,50,275,221,880,477,44,152,523 }, { 264,166,435,9,39,254,30,382,921,404,438,363,656,190,100,897,411,478,93,203,812,274,625,1,795,691,88,156,101,473,326,110,265,639,340,51,447,272,141,18,35,165,131,33,329,67,0,354,77,910,616,291,914,530,105,68,118,197,731,137,120,23,21,578,128,36,333,49,593,494,271,98,676,310,102,44,664,613,48,349,28,228,195,5,960,658,800,180,24,724,96,682,678,403,160,688,523,127,829,242,521,83,31,716,13,342,159,69,16,144,260,352,32,269,55,167,158,219,576,364,704,4,615,202,65,60,318,456 }, { 252,9,0,166,265,100,364,329,404,39,101,520,676,419,68,118,553,604,382,88,167,274,18,212,593,333,158,264,16,49,806,865,438,48,812,21,154,30,677,310,1,35,656,24,96,124,51,857,22,13,23,105,28,60,31,71,286,562,65,777,435,455,190,98,639,159,759,109,917,254,344,191,647,125,10,55,907,694,363,221,44,127,5,557,131,327,682,411,67,628,95,83,538,936,149,925,272,36,664,175,375,478,121,64,793,146,821,50,671,69,302,271,921,116,625,541,942,446,530,724,709,706,33,634,463,170,128,223 }, { 15,4,11,141,5,13,21,23,202,40,269,32,12,165,523,3,180,64,318,17,352,457,197,1,93,0,110,2,125,120,128,386,51,59,77,31,117,326,49,10,719,403,961,82,153,48,137,134,899,450,115,260,494,196,44,33,37,730,6,57,203,817,177,752,22,98,9,90,18,373,237,8,7,217,958,351,291,14,139,95,341,144,27,210,475,615,402,391,56,453,901,116,19,143,86,349,244,317,72,105,498,123,485,365,111,152,342,401,76,28,30,247,678,801,65,45,216,36,569,300,308,509,221,99,127,84,164,873 }, { 24,35,69,18,71,68,46,67,16,1,2,50,14,149,108,133,189,28,38,75,83,0,7,9,218,65,238,114,52,335,29,54,251,60,55,309,236,175,118,336,486,267,96,394,181,220,366,87,418,124,154,5,545,412,516,140,70,22,487,12,21,36,101,171,433,641,230,328,58,48,458,345,361,398,283,92,6,37,103,514,302,906,10,388,596,565,273,443,64,160,532,163,399,705,223,891,86,150,262,537,32,51,39,831,23,109,95,375,155,13,99,480,571,45,49,128,281,696,112,194,754,25,137,294,602,208,323,191 }, { 90,214,289,874,64,712,751,77,51,13,177,32,312,23,192,66,194,202,216,59,288,4,835,875,65,0,249,247,95,519,102,57,5,123,33,22,524,234,104,450,173,49,437,500,889,210,217,636,319,597,21,153,416,196,38,20,117,954,304,115,134,120,18,715,86,583,113,494,61,204,10,784,291,28,275,342,147,318,879,43,74,142,11,588,888,403,864,237,2,198,352,426,752,707,48,1,639,17,81,180,750,861,52,315,207,560,24,128,402,40,141,16,671,31,372,36,130,455,260,12,9,317,37,325,349,389,904,306 }, { 9,0,49,127,28,301,98,371,395,159,512,158,916,737,761,31,101,24,623,16,272,68,18,39,35,293,242,1,286,109,44,385,327,65,170,299,55,125,51,23,22,518,105,836,21,116,616,137,685,284,48,599,344,252,7,124,13,276,64,187,95,506,5,131,890,202,456,627,36,2,219,30,254,333,419,763,14,347,12,154,578,320,96,713,141,935,201,144,338,442,870,118,71,128,10,364,168,374,67,60,37,310,221,100,32,318,424,93,269,393,910,165,403,86,688,160,793,908,50,83,69,203,421,492,401,6,244,166 }, { 17,136,62,214,123,129,249,710,119,162,618,292,209,141,32,183,77,128,211,106,64,45,4,11,179,269,507,519,207,59,177,130,3,40,90,86,255,378,33,202,76,57,205,655,790,152,678,38,21,245,37,742,248,5,102,597,476,306,556,41,291,229,117,349,80,339,153,313,266,318,84,54,947,184,56,12,155,134,240,197,305,157,304,217,148,186,165,275,257,789,99,216,13,497,317,72,137,115,10,196,460,383,619,61,51,188,361,457,369,425,50,290,440,14,342,263,180,503,452,241,208,237,194,432,381,65,111,22 }, { 5,107,581,441,356,493,362,660,279,534,32,683,298,423,259,786,22,612,590,359,21,13,49,147,61,508,241,263,929,48,97,246,14,126,0,132,7,465,939,232,64,230,607,95,121,941,23,92,771,115,470,314,51,387,626,172,1,58,12,347,779,392,407,17,150,687,16,357,28,146,43,77,87,60,199,197,37,40,711,178,501,65,10,9,180,140,35,33,24,595,102,120,56,30,70,207,344,324,125,46,31,165,18,20,577,414,376,2,350,4,260,427,173,408,195,141,247,76,603,217,86,11,379,55,729,90,75,50 }, { 51,475,453,13,23,15,730,403,457,421,386,523,899,719,670,401,12,361,6,99,33,1,128,269,961,141,27,19,5,494,165,21,64,2,450,153,202,117,65,115,236,7,196,77,95,32,328,37,14,10,0,318,134,17,391,197,102,308,40,26,120,9,22,4,125,412,389,16,34,194,57,569,402,54,53,8,352,25,758,291,59,3,880,757,503,488,217,90,38,72,48,45,801,177,11,304,509,326,283,260,180,139,137,76,47,41,867,350,629,558,949,838,832,803,775,773,770,754,749,657,597,576,543,514,468,297,255,250 }, { 49,159,272,28,9,327,254,158,22,347,95,627,374,286,131,424,105,168,35,39,912,65,68,578,688,0,538,55,24,518,175,154,124,239,634,346,289,224,169,913,577,16,320,364,747,219,185,616,101,716,67,344,1,890,570,170,30,810,109,333,228,420,21,36,439,64,149,23,127,371,194,13,706,827,125,51,114,312,83,187,98,429,613,10,137,829,610,86,310,166,910,31,835,190,406,71,18,242,202,846,141,938,160,44,14,2,385,69,7,48,308,301,258,128,638,237,115,12,165,96,100,103,562,703,221,116,164,50 }, { 15,33,77,4,102,317,341,141,117,365,134,13,180,1,40,153,5,115,23,11,197,10,217,196,21,901,22,64,752,352,143,253,244,351,137,51,32,2,269,177,82,59,165,12,3,291,569,202,120,0,854,139,342,86,55,36,372,31,9,898,48,498,349,37,260,7,28,111,125,17,482,49,318,160,457,6,450,44,128,90,275,237,95,210,57,386,873,638,98,523,105,164,89,93,30,719,922,961,509,308,8,14,72,951,403,401,730,391,304,116,326,39,468,56,38,717,94,24,579,817,76,61,96,16,18,546,629,494 }, { 134,13,15,23,12,474,569,51,37,10,197,457,961,99,115,4,38,2,165,0,153,5,3,11,719,64,139,431,1,277,120,82,33,6,94,873,14,401,110,7,89,117,351,40,498,128,260,148,54,93,72,629,453,180,21,31,22,9,405,143,141,8,17,77,36,102,44,386,41,509,196,59,450,125,730,55,342,523,86,403,326,45,95,898,98,32,854,237,365,217,391,775,116,349,291,210,179,203,202,317,752,901,372,341,352,177,402,49,57,76,922,475,28,30,144,373,421,318,308,269,90,494,413,46,18,678,899,242 }, { 7,2,66,20,58,29,52,74,128,14,135,5,32,97,192,43,38,61,6,631,16,151,87,21,25,315,172,177,46,48,173,186,45,884,70,90,113,77,227,72,226,23,102,51,137,35,210,337,202,59,40,104,402,155,115,269,89,592,81,33,122,13,60,174,112,107,24,19,243,0,145,222,580,76,37,49,64,10,416,318,738,18,353,204,26,491,678,95,4,290,141,54,232,69,92,22,415,140,712,270,217,12,171,496,86,220,27,17,549,294,209,1,355,609,494,425,285,50,665,148,403,560,36,216,400,75,275,307 }, { 77,202,13,23,128,318,33,269,141,102,403,117,4,342,153,134,51,40,64,196,32,0,49,177,22,494,291,137,11,21,59,65,95,475,98,165,210,90,18,115,48,217,197,15,275,105,10,120,127,86,28,180,9,453,352,36,39,317,31,125,5,194,402,57,450,349,372,14,116,44,16,300,6,2,284,96,24,20,30,457,12,859,678,299,289,242,114,110,109,61,7,1,216,214,100,326,304,260,237,3,82,789,752,579,576,490,347,344,293,207,205,144,139,93,37,615,373,351,285,421,401,961,391,203,817,923,922,901 }, { 2,14,1,46,29,38,6,52,103,50,65,36,67,5,108,75,83,7,22,24,25,69,28,86,208,133,0,323,19,26,484,18,309,782,96,283,236,238,124,160,135,21,10,12,74,87,66,168,17,262,70,412,23,389,16,51,650,278,289,532,45,194,3,756,218,32,220,58,646,244,42,115,95,37,27,13,48,886,49,267,366,226,302,128,54,610,64,516,547,584,137,253,9,308,143,388,141,717,335,480,401,164,185,357,505,109,150,732,602,420,99,285,172,202,891,112,189,324,181,35,418,696,331,90,114,55,294,458 }, { 15,5,1,2,3,4,12,11,13,10,0,341,21,180,7,33,197,6,134,17,77,32,365,23,901,37,117,9,8,40,165,102,153,961,51,498,196,569,14,873,752,217,22,94,64,317,59,36,352,474,31,509,99,141,110,55,291,111,457,120,391,57,19,16,82,48,177,401,38,386,349,202,308,139,93,342,453,72,275,18,44,143,351,28,27,90,128,403,269,372,45,137,76,260,318,89,326,210,86,277,898,413,237,719,148,864,730,96,95,79,373,475,61,24,46,30,523,253,98,482,83,546,54,49,50,41,899,758 }, { 203,268,206,940,93,417,959,499,473,137,31,44,728,692,8,120,202,559,564,450,127,141,260,326,817,244,22,10,0,23,551,318,144,125,13,523,269,128,299,98,1,253,373,51,494,403,9,116,341,143,64,110,638,285,5,615,642,859,367,55,918,576,21,421,180,386,922,165,105,36,401,2,365,115,899,242,352,28,951,393,704,86,30,901,475,7,762,276,77,384,948,237,32,197,49,492,434,160,661,489,170,15,39,752,317,498,854,453,282,717,6,18,16,569,395,479,351,805,12,958,898,456,48,293,851,308,301,509 }, { 15,120,82,10,165,31,0,197,64,260,33,8,93,110,22,351,40,44,77,23,153,13,9,102,4,51,196,125,326,11,450,49,139,28,237,203,386,98,457,18,32,373,95,523,1,21,277,59,854,180,111,202,12,141,898,17,36,116,144,14,115,922,86,57,128,5,45,30,2,391,217,7,817,37,177,730,90,509,719,72,99,16,76,62,453,291,352,475,318,269,403,341,48,134,961,55,24,3,143,899,308,401,137,65,38,615,210,629,317,901,758,342,569,494,661,365,39,247,164,421,704,546,61,6,811,41,642,752 }, { 60,7,16,71,43,0,14,20,28,97,68,22,92,24,149,2,35,10,154,13,126,615,608,51,124,362,140,55,805,18,958,576,566,175,23,359,6,1,48,453,158,150,703,21,421,260,173,475,298,153,107,74,64,36,29,925,46,12,882,899,441,801,81,357,246,196,77,69,38,25,9,117,65,49,314,37,484,386,730,336,115,570,403,356,324,221,135,121,19,401,99,939,420,399,859,942,628,610,289,285,259,125,101,95,33,26,702,677,165,4,653,375,185,192,91,515,302,197,104,326,595,318,230,202,191,143,102,90 }, { 26,19,6,27,80,25,84,45,17,5,504,42,129,2,240,123,618,29,56,106,113,710,4,76,119,128,14,136,65,64,73,59,1,209,483,53,162,51,90,548,122,205,249,202,40,99,3,460,32,257,62,292,61,214,77,245,57,12,378,141,183,453,34,297,11,184,108,23,255,469,0,403,22,33,58,95,10,86,814,318,769,114,179,402,611,667,130,475,21,151,210,137,742,161,38,177,494,7,436,269,102,194,115,445,18,36,421,13,47,153,880,775,54,133,196,37,49,495,306,311,112,46,52,117,250,28,491,48 }, { 15,77,13,33,4,23,102,11,51,5,40,177,0,117,10,202,64,8,93,22,291,32,21,44,31,153,110,1,141,49,115,59,82,180,9,17,318,196,98,269,351,403,137,453,36,95,457,217,3,90,139,128,48,28,898,12,165,450,475,349,341,197,523,18,30,210,317,86,16,260,401,2,961,901,719,57,116,494,854,326,373,125,365,817,352,730,275,134,39,386,105,76,24,7,308,372,37,342,6,421,120,704,144,14,899,922,203,111,304,569,638,72,661,61,629,96,127,99,811,535,498,65,615,752,247,83,402,758 }, { 195,271,98,223,167,132,407,146,360,591,1,212,834,121,522,393,293,199,259,354,446,668,590,562,807,191,156,48,765,125,107,147,941,163,727,541,535,465,126,284,21,346,31,279,23,55,18,5,687,16,60,640,13,697,586,178,534,35,20,608,581,150,955,427,68,70,589,43,142,791,463,198,116,51,883,362,9,963,781,202,49,0,818,96,493,7,948,281,120,165,367,798,450,10,44,318,77,105,14,325,221,92,28,22,61,770,101,777,58,93,32,97,467,141,386,33,144,371,75,127,37,108,929,269,411,598,551,128 }, { 210,128,202,77,402,318,102,403,33,342,275,40,196,475,6,300,139,29,177,99,494,269,42,503,111,757,277,141,117,52,2,4,678,13,153,12,0,23,59,285,37,137,85,81,7,291,859,657,351,122,82,576,44,31,880,260,216,120,91,78,63,14,11,1,745,65,64,93,854,27,684,22,485,180,76,74,19,3,21,805,49,38,281,48,966,838,631,452,450,421,218,134,26,25,569,341,115,898,738,592,110,98,10,315,788,707,491,483,432,396,319,268,242,125,116,95,62,57,56,50,17,16,9,655,526,453,426,422 }, { 40,33,102,23,51,13,117,196,153,77,134,64,128,202,4,59,141,453,65,475,11,403,22,95,0,137,14,139,15,342,210,12,86,318,269,165,115,1,49,10,494,177,28,180,36,291,421,21,57,5,6,217,18,194,99,401,2,457,108,719,125,19,111,260,82,37,27,48,17,3,523,197,133,26,402,120,114,670,352,7,24,730,93,216,90,46,237,50,32,386,361,9,341,351,25,349,300,283,277,38,34,901,365,326,275,98,110,285,45,41,391,44,317,576,961,242,143,16,509,170,31,854,308,54,116,817,757,629 }, { 7,14,16,24,18,28,71,2,92,60,35,22,20,0,154,118,168,6,1,97,69,703,302,149,140,150,185,38,109,43,66,68,108,420,29,55,10,158,610,12,65,67,5,701,189,273,570,95,230,429,46,124,246,289,298,51,21,169,143,49,175,23,107,747,126,671,13,64,48,159,25,925,677,137,36,52,398,32,9,251,584,467,164,128,942,19,86,577,847,83,173,336,403,74,50,424,202,232,882,172,17,344,279,638,375,105,314,104,37,125,115,441,356,505,99,253,239,26,221,359,329,194,533,837,517,165,494,601 }, { 23,1,15,51,2,13,5,0,7,180,21,9,6,115,197,120,12,165,4,33,457,386,523,202,141,3,14,260,450,48,8,16,77,93,31,341,37,269,40,403,44,730,110,326,32,102,317,137,318,453,352,719,365,18,128,217,153,82,475,36,98,64,391,752,401,901,899,421,308,196,11,498,22,28,351,99,116,10,117,24,817,96,221,30,39,494,509,569,177,203,49,961,144,291,373,615,59,17,801,372,482,72,758,90,89,854,50,629,134,127,35,86,349,922,160,55,244,105,237,143,468,898,210,54,46,670,342,45 }, { 132,146,199,107,60,121,126,279,150,441,92,649,16,955,493,195,598,423,653,298,35,407,356,640,362,508,32,21,953,7,360,359,522,18,271,783,5,246,167,0,660,156,534,939,71,191,22,517,590,24,49,259,314,10,607,28,392,13,232,147,68,97,95,14,43,883,118,1,37,581,48,501,354,809,55,108,4,591,12,20,23,347,345,212,467,230,446,241,125,50,941,75,9,31,98,683,929,77,2,672,33,713,463,702,273,61,40,59,70,46,101,58,172,586,357,296,115,779,36,350,109,727,388,236,207,87,105,408 }, { 31,44,276,284,98,299,935,116,201,662,9,39,492,144,489,131,567,371,268,0,49,918,127,137,367,254,28,434,293,737,30,203,1,295,22,456,93,125,219,385,23,202,187,393,21,716,105,599,578,51,36,128,141,836,272,269,244,318,384,13,159,395,48,261,96,110,224,616,326,242,35,16,253,5,95,55,64,160,258,158,143,18,100,699,165,24,115,948,120,37,403,86,166,310,12,924,457,855,940,77,10,442,494,101,109,7,197,317,206,68,2,373,617,761,352,285,908,217,332,341,916,228,32,33,518,688,730,473 }, { 13,15,23,51,1,0,10,2,4,115,77,5,9,202,3,197,457,7,22,11,165,6,961,12,33,14,59,177,403,21,102,40,453,180,719,217,18,31,120,141,32,475,8,318,569,37,16,341,210,17,386,450,401,28,269,64,99,326,494,317,730,308,44,523,93,352,291,90,125,365,260,36,275,24,134,49,139,30,110,498,421,98,57,196,391,19,117,72,342,153,48,817,873,349,482,901,221,629,76,237,111,899,86,95,216,509,752,304,137,247,82,372,116,758,89,27,38,39,65,203,55,402,45,29,373,300,143,615 }, { 162,123,257,184,183,17,229,130,84,136,497,556,152,383,129,452,99,80,3,205,62,57,56,266,106,119,12,128,40,4,161,378,27,14,495,504,381,202,769,469,249,59,77,432,11,34,33,305,64,90,403,240,38,54,5,102,45,32,23,73,618,475,51,361,440,139,775,37,402,471,318,53,21,494,65,141,19,372,453,313,421,177,880,472,757,217,245,548,250,527,2,76,524,349,61,86,216,153,210,196,115,179,10,619,328,269,291,214,72,483,117,209,6,26,22,477,111,95,13,401,114,157,369,211,36,134,48,306 }, { 196,153,117,453,134,33,40,23,102,51,13,475,0,14,22,15,12,2,64,670,21,401,730,4,18,99,65,10,9,11,1,28,95,57,128,77,5,38,46,37,403,386,202,719,24,6,108,457,899,139,31,59,16,82,36,165,32,120,961,86,236,48,8,342,141,775,125,308,137,7,54,523,50,269,197,494,318,115,300,260,39,758,450,180,421,277,90,217,341,629,361,49,3,326,114,93,391,291,210,194,328,317,111,17,352,558,110,377,29,275,283,133,485,817,898,615,801,351,160,19,488,569,350,373,109,84,56,183 }, { 224,219,187,258,442,871,908,385,836,131,944,574,839,127,98,613,31,116,926,44,137,829,860,160,827,276,39,254,284,36,144,228,201,96,406,1,371,530,202,856,716,93,30,51,9,203,268,737,902,492,23,49,21,190,13,318,843,531,326,269,924,125,367,141,64,77,120,166,816,935,800,242,299,115,456,260,293,274,931,494,395,567,110,217,662,5,317,22,717,100,143,434,128,28,48,86,533,10,295,105,332,55,489,180,365,918,418,102,578,197,244,83,341,576,403,384,625,165,261,177,159,352,291,822,863,473,251,206 }, { 195,121,360,590,146,407,156,786,522,132,883,591,626,929,941,259,687,279,379,586,296,465,467,150,178,354,5,21,55,534,70,60,783,771,13,346,340,48,271,581,49,493,163,1,199,147,608,668,125,955,167,562,535,98,518,108,362,18,371,212,446,107,761,878,31,126,50,463,35,818,105,75,120,598,87,0,767,223,165,640,22,447,293,777,159,16,23,9,142,115,658,92,481,44,95,37,807,93,61,58,24,191,33,7,846,395,12,197,4,385,127,423,71,140,82,427,144,116,17,117,2,363,698,246,39,64,32,781 }, { 2,1,29,14,6,46,52,26,75,38,5,25,19,50,96,70,108,114,309,36,103,74,17,65,27,112,45,262,236,220,145,218,58,42,86,516,24,366,22,7,67,21,12,66,532,87,412,18,480,283,602,323,137,3,163,226,238,0,194,51,32,28,10,69,171,37,23,115,208,128,331,394,135,48,99,64,13,433,285,160,61,782,113,357,308,222,95,484,401,16,141,294,151,287,223,83,646,124,389,361,894,866,545,421,54,324,4,278,388,396,186,650,594,53,168,453,289,202,59,253,181,90,273,138,150,403,756,606 }, { 15,82,120,10,197,260,0,165,351,8,64,31,110,93,9,22,117,13,457,450,1,44,33,23,326,102,49,125,898,153,719,77,854,523,18,14,98,12,40,7,961,2,115,373,180,5,51,386,36,111,141,95,730,28,196,922,139,203,55,116,4,817,498,899,128,30,177,86,569,144,661,99,37,202,16,24,65,318,21,873,11,59,6,277,217,391,269,341,38,32,291,143,237,352,210,317,3,365,509,474,349,758,704,642,216,39,615,137,453,275,403,401,94,300,304,629,247,372,242,342,90,48,752,901,801,308,221,811 }, { 7,66,97,172,232,192,226,2,74,324,52,29,135,92,568,222,43,107,353,87,387,580,500,38,620,448,331,526,140,330,5,138,294,174,356,20,14,262,298,32,357,145,173,853,6,359,21,126,58,16,204,808,64,888,337,104,314,673,35,22,729,95,872,25,278,380,70,802,37,583,426,1,49,12,112,69,75,65,86,61,45,60,48,10,246,90,230,0,42,355,24,220,415,85,81,889,46,885,36,825,287,28,194,72,171,792,392,632,560,280,312,50,71,115,76,54,26,18,151,155,707,587,89,17,4,764,147,59 }, { 62,129,123,162,183,507,618,136,249,152,211,57,77,184,205,59,130,4,128,41,11,40,117,17,229,497,361,257,3,33,38,313,452,266,378,248,153,64,106,90,210,383,119,12,328,214,99,432,216,157,196,86,202,556,179,54,102,80,37,381,402,471,134,245,177,5,514,369,188,339,440,305,275,524,141,45,269,84,710,529,291,403,139,342,115,56,318,209,76,504,421,372,742,619,292,240,237,79,27,14,775,22,19,10,23,457,95,21,207,488,13,494,180,542,65,300,401,306,32,34,114,26,215,25,217,769,151,110 }, { 13,1,4,5,2,23,115,15,3,51,6,0,7,77,341,217,11,141,177,33,317,12,180,21,365,197,202,32,318,352,269,102,901,9,291,10,165,40,403,752,59,22,8,31,401,569,349,494,120,308,304,44,110,90,17,386,64,93,37,247,153,210,326,14,450,28,373,117,16,372,48,196,457,260,98,275,475,498,237,453,125,30,18,203,523,342,49,509,391,36,961,128,873,134,719,116,629,24,482,421,39,221,216,139,244,72,730,253,95,817,55,86,143,615,57,661,351,704,144,127,899,105,76,864,576,82,922,758 }, { 6,26,235,145,19,47,112,78,648,624,630,27,85,64,42,95,122,444,25,644,113,70,108,453,29,632,130,711,53,222,74,390,32,65,237,412,416,280,665,287,813,138,730,307,73,680,283,14,196,52,34,4,312,51,236,226,90,262,17,337,22,180,59,331,500,128,86,884,315,194,690,114,133,498,849,137,50,200,3,256,21,2,49,45,33,23,13,66,141,409,445,297,288,57,381,719,11,396,289,247,87,163,165,1,250,5,46,115,153,525,99,183,76,746,324,63,792,675,294,316,56,214,28,583,751,125,285,503 }, { 51,23,99,12,15,13,153,10,117,403,120,37,82,165,128,453,401,64,202,197,2,115,110,14,260,457,21,475,5,308,0,38,93,719,31,3,22,134,141,1,33,196,386,180,351,17,421,569,44,326,125,523,961,11,730,269,137,402,318,450,4,494,8,49,36,9,98,18,7,95,391,6,54,629,328,32,237,28,40,19,86,775,373,57,116,41,854,77,79,59,899,352,94,474,102,203,509,477,65,758,89,341,285,221,901,217,111,177,16,361,144,30,880,757,498,46,29,27,670,105,898,143,24,62,72,277,317,55 }, { 16,24,71,18,92,108,35,60,146,64,7,118,246,199,126,121,32,50,9,267,649,156,167,830,271,133,273,140,36,68,5,230,132,247,21,14,1,640,12,563,48,0,87,388,75,2,237,220,330,86,46,354,115,65,672,304,128,55,751,522,180,360,95,28,236,191,516,114,163,696,149,953,189,22,54,565,141,51,137,217,674,412,352,49,340,23,633,37,309,458,202,39,10,394,58,103,70,597,125,262,72,38,947,726,591,502,437,195,164,363,67,641,514,602,954,124,864,448,107,150,143,101,366,283,13,678,317,177 }, { 15,2,0,13,1,4,3,5,23,7,217,6,9,115,51,8,341,10,11,317,372,180,365,77,33,12,22,247,901,18,120,197,457,14,16,165,291,28,21,202,31,349,961,719,102,260,32,453,30,352,523,40,752,569,730,24,82,450,304,308,110,437,93,117,44,177,36,351,196,403,64,17,318,475,153,899,134,269,494,922,401,386,128,48,482,316,326,37,137,49,57,873,125,39,854,59,55,509,90,579,342,35,817,629,758,373,210,98,498,237,898,116,65,111,144,139,615,19,670,241,20,56,638,468,89,95,275,801 }, { 234,639,178,416,77,455,5,49,142,202,450,427,0,147,329,21,198,315,61,557,344,13,113,32,318,120,22,23,325,48,259,534,494,105,95,347,518,798,39,884,159,58,481,99,817,623,878,291,112,711,70,64,17,1,31,320,51,265,158,65,465,128,362,192,137,236,845,260,403,44,310,141,196,342,177,30,7,271,241,195,135,269,28,290,210,929,15,4,307,170,125,663,102,33,275,263,132,859,408,294,194,786,581,402,301,153,86,523,98,150,423,346,167,25,237,415,36,858,682,592,352,117,100,12,37,10,709,146 }, { 31,1,44,36,116,64,55,5,180,2,22,352,98,86,127,141,12,164,13,498,125,115,144,253,170,4,242,137,752,197,128,105,7,244,0,160,237,23,341,21,165,9,365,299,901,301,3,951,317,10,6,28,864,51,338,269,15,268,844,83,169,217,202,873,638,93,569,509,96,824,546,8,37,456,740,293,512,203,77,395,479,318,206,14,776,599,95,506,33,367,276,11,48,685,954,285,239,457,535,201,492,762,717,401,965,533,102,393,482,208,49,109,391,601,558,489,67,870,284,947,961,403,708,946,35,434,923,40 }, { 120,217,260,141,23,77,13,51,317,1,180,269,15,115,202,450,137,110,373,291,21,352,64,349,5,177,82,326,351,48,318,854,341,36,365,304,165,197,0,32,922,372,128,96,9,93,752,12,22,523,160,10,2,244,7,457,4,28,898,386,86,901,661,498,719,33,16,275,90,247,203,143,11,253,482,40,37,83,403,730,494,102,50,18,961,615,473,221,237,8,817,30,968,125,704,216,39,59,14,67,6,117,210,35,49,95,72,342,308,24,89,453,55,134,475,76,69,116,17,61,31,3,437,864,70,899,576,98 }, { 26,396,648,6,112,122,624,145,287,19,222,416,42,25,573,138,74,651,644,151,66,113,445,45,85,665,280,29,525,204,64,174,337,680,87,884,135,53,65,70,436,27,95,58,297,881,194,73,80,746,544,235,17,86,2,90,243,32,22,5,128,1,609,353,311,141,61,315,307,491,226,106,0,52,81,813,614,209,255,7,632,75,114,10,36,186,580,415,289,63,611,14,34,33,49,214,28,792,117,250,312,283,77,125,172,108,389,76,192,208,355,237,667,56,4,91,165,294,40,348,148,635,102,123,256,153,46,549 }, { 156,360,522,271,146,354,21,446,121,132,5,463,591,340,195,727,586,18,48,407,13,49,167,32,668,60,199,566,23,16,447,698,955,575,9,658,296,493,608,150,126,0,534,35,24,581,92,71,590,363,107,279,141,125,640,31,212,4,929,411,467,562,10,1,51,115,783,165,191,22,623,68,598,379,61,12,293,273,202,95,197,303,163,663,269,108,37,101,221,118,621,391,76,28,17,40,109,7,767,260,55,518,120,33,11,77,259,39,347,941,44,252,713,478,98,140,408,350,93,626,346,264,900,509,818,30,170,763 }, { 21,5,61,49,98,23,95,32,612,178,259,51,182,48,13,481,120,77,683,660,427,291,147,64,70,4,465,33,344,269,241,0,17,767,318,263,202,141,107,415,817,450,180,22,534,392,362,125,116,347,11,929,350,121,595,408,423,352,293,260,196,165,117,105,102,87,86,59,37,18,7,3,557,376,845,663,579,541,490,356,316,115,90,163,928,711,28,132,590,407,941,922,704,645,523,360,346,284,268,232,210,203,195,177,144,134,118,97,65,60,40,16,1,298,153,146,58,937,798,414,113,31,771,246,207,142,281,647 }, { 468,89,358,79,365,94,179,205,317,405,482,498,245,72,115,341,217,180,413,490,111,734,247,431,188,216,37,474,152,452,11,629,569,873,752,749,497,197,4,339,308,13,12,59,901,428,864,579,40,76,23,372,291,875,10,352,134,961,117,77,542,528,401,51,588,349,471,529,33,464,546,477,645,139,221,1,377,38,21,99,36,177,509,64,449,316,14,2,304,143,102,437,9,32,196,741,3,165,5,275,202,128,54,277,237,153,210,743,457,430,300,773,485,460,141,17,0,350,22,288,421,257,270,48,8,184,137,15 }, { 24,35,71,68,16,18,92,118,375,108,7,101,302,175,336,154,60,273,14,124,9,398,230,140,0,150,55,149,28,345,189,399,246,191,65,346,69,722,212,46,1,458,167,22,429,314,2,267,126,674,21,388,439,97,67,38,114,10,48,252,628,95,364,251,882,50,133,637,36,49,39,109,12,823,172,768,602,103,236,650,5,83,520,66,232,64,517,32,562,847,694,815,589,702,107,96,51,594,23,695,363,298,37,535,462,484,29,13,796,86,467,886,604,806,868,121,419,125,54,755,451,168,100,135,570,158,6,169 }, { 421,453,51,801,730,475,23,523,386,670,401,719,13,629,899,365,403,758,457,115,494,569,805,958,576,543,697,165,615,221,423,817,450,33,488,308,197,102,66,21,514,388,56,14,38,734,341,117,7,326,69,467,961,880,323,196,153,19,202,886,770,128,273,97,120,811,642,532,458,207,110,24,10,6,1,540,67,0,753,554,390,135,134,92,73,52,43,894,37,32,743,214,114,103,90,65,29,891,847,782,125,451,269,208,75,754,602,480,244,229,200,133,130,119,16,9,426,162,83,40,22,2,42,25,203,123,4,901 }, { 113,311,614,29,491,145,45,112,80,6,151,631,209,315,74,61,27,2,73,5,287,66,26,243,25,70,396,611,667,52,138,19,58,454,869,122,222,17,186,106,87,255,445,32,64,496,42,297,1,135,684,227,4,128,644,7,86,624,76,337,95,416,65,22,72,85,59,14,204,148,90,21,738,174,250,53,119,141,280,10,483,0,833,137,651,690,549,46,75,226,11,378,37,665,155,742,200,56,194,207,57,177,179,525,12,114,84,77,48,495,40,469,172,292,307,161,49,38,884,887,655,573,881,89,425,18,36,33 }, { 471,339,188,4,11,59,377,79,12,99,94,102,77,33,51,111,542,37,342,152,961,13,474,403,40,202,196,153,128,3,452,453,177,229,431,475,401,23,139,117,184,266,157,57,134,115,494,210,300,17,291,402,129,90,32,529,629,5,141,76,775,72,64,275,38,21,318,757,569,277,216,162,14,421,313,123,269,880,89,1,2,497,257,62,197,405,27,45,285,54,304,148,485,217,15,457,41,10,6,179,165,205,180,137,477,349,130,488,245,19,523,432,437,260,22,120,95,769,372,0,352,381,249,618,482,308,237,7 }, { 15,40,4,11,33,120,10,82,165,77,110,93,31,8,260,0,23,22,102,51,13,59,44,351,125,64,197,139,32,9,21,326,28,450,196,180,98,203,57,141,386,49,373,12,111,95,1,391,5,457,99,403,115,18,453,116,202,134,475,523,719,854,37,117,128,401,237,48,144,177,14,898,36,217,2,90,308,269,342,758,30,210,318,277,730,494,17,509,922,352,291,817,86,3,65,16,901,24,194,402,105,38,137,7,341,317,29,961,39,629,55,72,76,300,661,752,421,899,242,54,775,247,349,365,569,143,615,485 }, { 16,71,24,35,68,18,118,60,0,28,124,92,7,55,9,419,375,14,109,175,149,101,126,252,302,346,150,439,108,154,158,570,169,185,364,22,273,49,65,917,701,329,168,962,420,191,925,39,628,107,2,1,604,46,140,67,97,21,535,265,38,69,159,942,677,10,722,336,105,345,694,467,703,48,5,95,246,553,810,882,20,83,333,43,12,706,13,637,826,100,23,847,671,36,167,279,121,793,189,199,374,50,125,51,212,230,286,66,272,566,6,484,634,344,32,429,289,327,86,103,96,601,114,441,517,37,64,298 }, { 17,45,227,106,209,243,21,290,255,400,207,48,263,270,62,186,119,2,496,454,50,32,3,5,52,221,29,425,136,408,430,46,513,171,14,659,54,84,787,721,741,56,281,38,536,80,181,378,240,742,587,552,1,306,76,123,241,541,655,328,428,61,129,41,666,72,502,57,89,12,760,540,115,155,148,383,449,794,37,96,361,152,11,34,214,4,311,51,440,474,592,431,64,790,202,179,405,350,292,36,90,67,663,6,141,59,13,498,103,583,130,697,514,40,211,99,58,10,128,237,217,770,27,869,157,828,834,391 }, { 340,354,586,658,668,156,195,698,363,447,883,296,1,411,303,18,379,9,919,360,51,621,98,31,48,591,371,13,21,446,163,5,121,70,132,125,23,759,846,127,761,478,60,293,223,271,146,385,120,664,691,108,763,82,634,638,75,4,260,24,807,774,144,44,522,407,30,457,32,16,914,463,126,777,335,93,771,367,71,49,39,12,0,687,351,118,299,201,40,7,50,848,518,284,922,854,758,538,364,279,11,10,724,310,217,326,64,393,77,541,767,167,150,137,105,103,101,87,58,17,115,286,225,33,401,867,850,663 }, { 277,153,111,12,23,51,474,99,38,139,37,457,453,117,542,41,79,629,196,401,13,11,14,569,961,102,33,134,188,89,40,157,54,328,72,775,57,115,17,94,413,339,431,15,377,369,3,477,308,719,248,165,313,4,468,45,485,148,32,197,76,734,216,62,2,21,10,587,405,64,5,59,29,34,6,210,82,509,471,128,155,152,730,177,490,7,266,361,52,120,475,1,0,873,19,305,758,9,899,125,22,110,386,300,211,93,529,229,48,260,237,180,65,50,528,880,77,391,86,36,27,588,326,546,482,402,514,56 }, { 18,16,24,0,159,35,68,49,105,9,60,71,101,28,344,55,7,118,320,109,424,14,327,455,239,22,286,170,272,310,1,374,252,154,419,329,167,158,124,518,23,95,709,39,2,21,51,65,13,301,5,890,48,92,265,98,191,212,12,10,108,137,347,128,30,538,31,364,125,202,37,553,20,149,121,557,185,36,677,67,333,169,338,146,127,346,46,175,64,6,126,100,577,50,254,32,512,916,33,403,86,395,69,242,806,371,115,96,44,77,318,221,479,694,616,102,165,623,83,910,627,737,917,38,793,578,846,375 }, { 0,105,9,16,49,18,24,68,101,518,158,320,28,35,301,170,272,890,344,286,109,327,39,65,55,512,7,1,127,916,98,118,252,60,737,159,239,371,21,71,124,395,154,14,48,455,623,242,31,23,51,419,374,364,761,5,2,12,137,310,95,125,293,333,846,202,13,616,329,347,338,385,30,37,131,44,938,479,128,836,709,22,538,265,506,64,793,627,10,67,167,299,403,827,212,713,578,149,116,32,36,219,100,910,254,553,175,318,677,108,185,50,6,96,46,685,221,421,424,191,577,92,93,269,599,187,165,284 }, { 141,180,1,5,352,365,13,2,4,217,341,115,269,317,15,23,752,3,7,901,6,0,197,21,51,31,77,202,44,318,32,64,372,873,498,10,93,8,11,244,33,9,165,12,102,137,22,253,49,48,237,116,30,98,125,39,177,569,401,28,143,291,308,864,509,40,120,349,403,37,105,391,144,153,482,203,450,110,421,127,72,576,494,95,453,260,247,96,475,373,326,117,36,717,304,131,128,134,90,89,14,457,854,221,206,196,55,811,82,947,629,351,922,386,59,961,734,670,17,437,661,224,201,16,88,76,164,187 }, { 51,4,23,102,33,300,40,485,453,880,153,19,17,196,27,342,78,26,53,403,47,77,210,0,475,117,73,2,57,34,11,5,200,13,99,494,14,1,22,12,176,421,64,111,41,21,368,361,59,757,231,130,123,6,139,128,134,401,106,18,56,49,322,317,177,45,775,48,115,165,108,10,125,65,504,495,197,32,605,229,80,341,221,183,390,813,46,37,618,306,95,719,554,152,753,736,543,444,161,402,277,119,630,236,216,122,113,29,730,237,25,899,217,714,383,297,472,445,378,250,38,678,670,527,503,469,412,318 }, { 62,440,56,184,229,183,556,130,3,136,548,152,266,99,162,161,17,57,84,452,305,12,383,257,123,403,34,40,527,14,205,349,504,555,497,328,4,361,202,139,775,33,38,37,128,475,129,880,313,381,757,102,11,196,59,119,401,432,402,54,471,453,215,77,23,514,507,585,51,211,153,80,494,495,469,236,477,117,111,64,421,240,369,106,21,214,277,157,308,5,291,141,378,249,13,2,803,619,318,45,76,177,27,485,472,134,41,32,412,339,216,65,524,197,10,72,114,176,165,53,90,372,22,188,245,86,217,543 }, { 13,23,115,51,141,202,77,64,269,217,33,318,102,32,21,128,137,0,177,180,4,5,291,9,48,352,10,197,90,196,317,40,153,7,372,18,15,349,22,2,247,165,275,6,403,11,117,125,237,59,3,16,752,494,28,342,304,31,341,134,14,98,86,210,36,241,12,244,49,95,24,498,30,116,39,1,143,901,453,20,450,144,365,402,221,17,475,93,203,127,65,253,216,72,326,120,164,576,35,19,96,44,437,160,421,308,83,67,864,954,569,817,719,25,101,100,61,55,57,284,805,523,401,60,293,285,105,88 }, { 1,22,36,105,170,28,55,239,86,31,2,95,5,9,127,0,98,301,12,64,67,7,49,320,109,654,44,83,10,169,208,143,21,312,35,13,23,128,141,740,125,242,14,512,293,116,160,237,51,395,50,338,37,159,96,6,933,114,115,708,299,751,185,137,844,505,269,168,69,48,638,103,597,928,202,180,244,323,16,352,253,165,3,713,197,194,892,39,24,599,65,54,341,285,318,286,46,685,456,951,4,623,824,32,133,158,365,584,601,535,38,498,144,218,251,841,533,506,30,371,217,479,8,503,284,870,752,276 }, { 15,0,1,2,5,13,23,7,901,9,6,8,12,51,4,3,457,180,341,898,82,22,115,10,141,120,117,31,351,14,202,260,197,28,269,33,153,961,64,30,44,37,93,18,569,854,11,21,16,77,217,137,365,386,719,237,134,391,110,128,523,49,450,36,629,498,352,102,125,326,317,40,401,509,730,318,196,24,203,546,308,39,116,922,55,752,32,86,817,17,403,90,98,35,453,95,373,59,99,873,177,758,111,143,38,291,242,139,65,48,244,899,372,285,642,349,247,144,734,638,615,482,277,72,253,421,89,475 }, { 274,98,100,39,1,265,438,190,310,625,382,30,530,223,909,96,264,593,166,778,88,812,410,960,731,557,252,31,125,21,539,23,254,9,48,51,116,639,44,478,393,131,127,13,101,0,293,284,329,795,404,840,144,656,435,333,724,616,5,219,228,321,272,421,834,165,921,957,224,105,32,36,93,128,697,367,541,669,765,242,221,49,676,137,418,455,160,748,83,897,163,202,682,578,475,453,553,386,807,217,213,551,613,406,335,403,141,466,197,827,180,948,37,158,187,115,905,821,791,203,352,286,258,371,120,863,730,2 }, { 212,18,118,447,167,781,363,411,271,647,146,121,60,562,664,621,463,815,478,1,16,446,9,777,354,628,21,936,48,101,932,132,68,191,98,520,522,223,71,264,5,24,759,55,199,575,727,566,126,13,23,724,156,360,691,125,0,407,591,608,49,293,604,221,51,35,92,195,346,31,107,252,108,375,586,96,154,914,682,541,807,150,39,589,124,848,265,69,22,105,50,834,32,364,302,393,329,12,4,10,382,535,404,28,166,765,100,668,273,33,149,88,706,806,163,279,95,410,598,44,335,955,7,30,67,284,159,467 }, { 24,28,14,7,35,16,22,65,0,1,2,158,49,109,55,159,124,95,18,67,149,105,71,239,169,68,108,185,424,289,9,12,69,46,577,10,175,154,320,5,164,347,6,747,344,21,835,36,286,50,38,83,170,654,892,23,420,92,114,51,64,143,60,13,374,189,302,429,140,48,103,570,118,32,37,29,336,610,133,327,312,398,39,484,128,638,168,301,272,125,202,137,86,150,30,194,230,671,345,584,703,96,54,115,273,251,310,283,141,518,98,308,20,538,401,101,127,52,31,221,346,455,535,236,403,389,458,267 }, { 105,272,131,22,286,239,320,327,98,127,219,9,185,224,374,187,55,28,578,86,31,258,36,913,616,535,1,95,538,64,164,837,634,109,116,601,44,654,312,170,910,49,708,623,115,23,5,0,713,371,201,159,13,505,2,197,83,892,7,35,67,180,533,928,51,933,317,737,301,751,10,716,352,284,6,160,776,237,509,916,165,242,498,251,531,12,395,39,924,137,638,385,293,269,30,276,168,141,217,254,752,208,144,569,896,836,143,346,24,824,21,4,546,468,169,308,14,761,128,345,244,318,482,365,3,597,391,384 }, { 28,301,22,31,127,512,105,98,395,109,44,299,293,95,9,320,1,599,685,900,55,0,239,36,763,338,242,49,116,125,841,168,870,456,286,23,276,506,86,35,284,51,185,65,492,159,2,24,374,479,13,393,928,5,144,7,64,169,713,141,12,137,327,21,202,14,268,237,16,935,10,201,558,272,538,67,401,367,37,143,83,308,424,164,312,128,158,115,48,165,918,654,194,269,923,740,39,347,244,623,18,6,489,253,318,114,963,160,352,289,124,180,68,96,420,170,203,175,131,421,219,434,197,391,221,762,453,93 }, { 2,58,29,52,1,186,334,46,5,14,151,75,45,400,155,50,61,227,163,262,502,69,549,70,220,223,48,38,311,112,67,409,113,780,7,243,675,767,27,17,209,24,103,80,394,96,21,315,54,307,513,536,83,287,787,309,37,281,6,16,106,807,171,587,496,267,19,32,631,474,270,491,12,35,181,26,583,454,74,869,820,852,36,324,721,255,845,278,64,73,335,357,89,87,140,72,537,25,760,290,18,659,614,430,189,66,97,133,663,114,108,592,552,128,331,666,764,141,606,3,86,380,486,366,76,65,148,10 }, { 7,107,232,135,97,387,92,356,298,66,14,2,192,359,278,172,52,357,126,324,448,35,60,526,314,16,38,29,46,330,380,43,362,259,392,230,20,226,74,140,262,246,279,147,24,825,64,58,5,121,568,87,294,32,220,501,132,21,612,465,95,150,86,104,620,18,12,71,173,581,54,534,0,893,37,22,808,583,178,353,90,10,580,550,146,707,802,600,606,331,194,112,222,28,69,660,853,65,70,199,171,68,560,1,174,36,50,77,49,48,779,500,204,683,493,414,6,61,25,764,55,138,33,102,750,888,307,45 }, { 20,43,104,414,560,426,707,784,173,319,861,7,819,81,715,422,879,0,376,330,74,95,97,52,32,192,64,38,22,49,526,356,66,204,681,397,207,140,232,5,470,65,693,61,359,636,387,500,107,324,28,91,712,18,10,29,147,77,21,595,392,113,577,172,729,2,325,24,138,92,33,347,125,86,945,102,90,306,40,115,4,198,370,583,230,174,12,904,180,11,858,312,153,124,17,587,750,76,59,69,344,298,3,135,13,37,46,825,718,357,165,348,315,214,72,887,117,289,353,246,196,141,84,36,427,51,237,48 }, { 104,74,636,204,355,222,66,81,0,145,25,319,784,746,192,750,29,20,173,174,792,64,90,138,280,715,65,194,91,879,525,32,22,4,348,287,43,95,18,422,7,214,415,86,77,42,40,6,681,289,59,524,151,33,10,52,712,2,28,544,945,13,597,102,45,177,97,21,57,11,243,49,85,36,312,500,426,693,141,5,673,624,396,16,1,122,87,115,648,24,26,186,632,233,67,17,172,414,304,416,123,12,353,389,117,651,580,69,588,751,153,113,874,112,14,23,227,216,128,58,217,197,27,875,114,635,137,707 }, { 101,0,9,35,68,154,252,39,65,28,364,124,166,100,149,336,158,289,346,439,429,419,67,55,114,570,694,30,16,265,24,109,484,88,1,329,69,194,404,637,49,189,389,547,133,398,703,826,671,283,22,168,610,175,212,190,7,83,345,103,64,14,768,399,71,274,333,344,230,95,799,50,21,706,36,722,677,420,10,185,962,51,23,18,553,140,254,159,125,967,535,676,46,48,310,2,86,96,952,264,13,12,169,382,5,596,108,323,705,782,251,118,208,857,702,756,562,865,438,218,60,267,131,237,37,755,105,272 }, { 57,14,4,236,231,59,369,361,300,585,342,51,23,719,401,13,38,176,46,202,62,402,3,56,210,54,12,2,412,803,381,457,215,11,507,128,40,757,555,77,514,961,32,730,629,322,161,328,37,162,33,133,283,108,129,21,211,34,102,494,17,152,130,29,99,139,153,52,527,472,181,79,123,475,229,6,497,899,453,240,758,194,205,184,188,183,177,0,136,377,305,134,155,248,165,157,425,290,440,714,495,209,739,196,277,269,80,50,556,10,805,64,65,523,503,386,257,141,16,7,5,179,403,84,600,469,318,180 }, { 2,1,3,5,141,6,7,15,0,269,180,64,33,77,10,352,102,13,202,128,318,11,197,17,14,4,291,12,134,117,9,120,752,165,153,196,137,217,498,341,349,260,110,21,342,93,40,31,237,23,317,44,82,115,22,16,59,19,86,51,351,678,32,57,36,961,37,450,111,125,365,457,27,143,901,569,95,79,203,49,403,873,326,8,139,494,864,372,28,98,402,116,18,244,56,854,509,48,719,386,947,29,922,954,76,94,373,38,45,523,25,391,285,99,730,546,144,475,275,72,90,164,210,26,24,453,817,253 }, { 5,21,61,48,32,202,1,70,259,13,58,115,22,23,178,90,0,494,51,12,475,453,182,18,465,403,49,17,76,450,120,142,318,141,137,147,534,455,402,146,132,128,64,31,11,522,260,771,953,922,859,523,420,269,241,221,207,175,121,72,37,6,4,3,2,768,205,179,415,376,362,28,10,237,30,937,702,113,68,16,9,798,247,590,326,197,165,626,344,279,347,878,125,195,955,933,928,868,854,851,821,815,795,780,765,727,678,668,657,576,562,540,503,502,493,488,482,430,423,411,365,288,285,281,273,118,87,65 }, { 205,141,59,152,245,4,352,72,497,76,216,247,79,452,11,588,94,21,188,217,89,875,77,339,864,954,464,269,115,148,64,12,37,529,38,111,32,358,180,5,316,405,471,490,45,474,365,317,349,752,177,288,437,498,51,99,90,468,102,372,128,318,48,1,237,17,542,23,947,241,431,221,54,3,33,291,2,734,197,413,377,270,460,13,401,961,873,341,14,196,579,482,244,569,629,40,308,645,184,257,304,678,720,449,36,10,202,749,275,134,117,428,15,290,153,143,453,57,139,7,430,6,350,769,281,210,476,403 }, { 15,1,0,2,5,13,4,3,7,6,23,365,341,115,8,51,9,77,31,10,457,93,44,569,120,197,202,141,12,961,165,33,317,450,901,11,260,55,110,352,22,719,730,453,217,98,82,64,401,18,102,40,21,269,523,403,70,386,49,351,752,105,498,28,16,629,308,318,111,61,898,30,117,475,509,391,817,95,922,342,36,59,494,210,134,899,137,421,873,116,854,14,32,177,196,139,153,734,128,143,291,24,20,349,37,758,372,247,90,326,690,801,113,216,48,275,670,27,125,25,39,57,638,17,304,35,237,244 }, { 5,2,50,58,171,186,46,29,14,52,45,38,61,155,17,218,1,281,334,151,227,400,48,487,502,36,54,760,67,133,103,114,21,96,328,236,366,243,80,552,209,83,311,828,27,745,160,920,19,24,766,32,6,108,832,65,12,223,106,514,3,433,70,787,842,99,28,549,113,112,834,540,361,163,26,37,536,516,496,137,765,75,480,454,754,532,780,0,430,966,739,22,238,86,474,51,767,283,18,25,583,115,285,587,309,7,73,287,72,255,23,600,412,128,822,807,13,323,315,208,76,119,545,10,956,270,64,16 }, { 457,795,70,120,846,48,23,761,125,318,64,751,415,291,758,221,763,202,391,269,87,401,77,352,237,21,165,128,96,163,558,13,1,260,137,494,5,51,851,767,141,197,546,557,867,597,49,518,102,349,450,623,509,33,98,177,678,922,900,743,498,293,31,223,342,403,371,32,180,873,854,0,217,884,196,153,95,4,44,308,7,2,541,17,30,127,765,58,351,372,386,117,807,6,903,704,182,845,22,134,663,210,105,39,27,402,326,859,307,159,285,281,82,817,719,455,353,312,192,61,931,523,203,947,247,207,385,45 }, { 23,51,13,40,453,102,33,4,196,77,117,475,64,153,0,22,10,11,65,59,15,12,134,21,1,403,139,202,95,14,210,28,177,108,18,115,141,165,57,137,128,457,86,2,31,99,6,37,36,401,269,49,9,318,82,7,275,180,5,24,217,342,485,16,111,277,125,386,291,44,32,300,197,19,421,352,46,48,194,730,341,237,17,120,93,494,283,133,90,25,523,260,3,285,114,89,216,8,317,899,38,961,719,498,312,50,26,20,365,351,67,391,54,110,373,326,289,208,168,546,752,569,308,304,98,377,402,361 }, { 229,152,266,57,381,452,432,313,471,12,99,17,184,339,369,62,4,129,59,157,128,77,497,3,11,38,123,202,162,37,291,188,257,40,403,136,5,216,21,205,102,111,775,79,51,475,14,33,32,45,402,453,54,619,90,119,115,64,76,177,2,106,361,377,72,880,139,23,494,130,277,757,183,349,84,401,27,56,308,89,80,19,318,141,117,1,94,10,328,529,474,210,245,249,41,36,217,269,421,86,618,6,148,556,342,305,588,179,383,0,134,34,514,477,304,769,542,22,214,378,275,137,13,65,300,95,285,82 }, { 49,109,159,28,272,22,327,9,105,95,254,168,131,374,286,347,39,35,424,158,55,175,169,420,627,578,312,67,346,194,0,912,1,224,219,65,86,239,892,36,83,518,114,688,320,538,127,634,584,913,439,371,64,616,30,69,24,10,535,187,336,2,228,7,716,289,68,98,601,23,16,31,164,654,208,505,51,258,14,13,170,874,128,44,12,837,103,890,160,115,385,137,345,50,185,143,116,756,251,141,101,96,190,747,333,125,202,5,166,708,133,21,637,570,242,237,46,835,189,165,638,149,610,706,100,751,48,577 }, { 5,61,29,58,311,2,45,209,80,52,454,227,243,106,17,496,592,869,1,151,255,334,75,667,287,70,738,549,171,48,46,483,663,74,155,14,50,163,207,666,290,6,186,119,32,27,378,21,220,659,263,112,136,84,742,307,833,7,400,780,469,767,62,64,72,513,113,148,262,56,409,270,161,331,315,635,425,89,19,38,495,631,3,76,73,383,887,502,69,66,34,223,128,26,240,54,86,306,87,491,96,67,845,408,135,814,37,4,25,445,181,95,294,24,90,226,103,10,405,237,12,297,141,22,655,129,11,16 }, { 260,244,373,276,44,269,141,228,110,131,574,219,137,30,839,717,224,217,661,36,352,567,406,120,1,116,253,93,318,160,202,341,31,21,88,201,39,190,187,77,372,752,96,180,64,851,268,55,98,317,82,22,258,613,326,86,351,48,51,23,115,295,213,100,539,291,144,860,35,922,864,9,450,261,489,28,365,105,13,177,442,840,515,321,83,166,856,854,49,935,203,530,284,0,274,349,816,69,197,954,251,165,67,10,811,434,247,778,143,385,531,254,968,957,237,498,843,127,384,669,466,824,102,223,32,5,871,800 }, { 99,12,139,79,453,11,277,196,474,51,37,542,111,401,23,94,188,775,33,13,40,102,313,339,961,629,153,431,477,4,38,485,475,300,115,569,134,117,377,157,210,59,14,471,266,15,89,328,880,148,369,57,457,54,413,405,308,403,197,152,128,72,64,165,734,10,3,2,21,17,670,488,719,202,229,82,757,0,5,402,32,41,77,275,177,45,76,29,305,22,342,36,498,1,730,46,494,184,28,318,93,31,529,162,514,6,269,27,482,62,110,873,528,452,179,120,141,137,86,421,317,7,237,129,8,18,361,428 }, { 68,35,16,149,24,71,9,69,0,18,67,118,101,212,65,191,114,230,167,133,124,103,399,140,154,1,50,283,246,398,60,7,64,565,55,695,39,218,336,723,375,302,796,28,108,238,267,705,83,189,330,100,23,486,589,702,562,458,21,443,175,13,361,48,75,345,92,96,22,51,181,237,532,755,46,30,2,115,88,14,10,86,363,650,732,335,12,36,49,54,891,520,217,411,516,141,166,95,412,394,641,180,37,5,906,478,447,223,251,247,264,433,252,389,146,480,98,596,602,545,830,346,664,309,271,121,364,628 }, { 88,274,435,30,613,100,131,829,166,530,382,93,960,795,190,127,856,466,957,187,521,264,473,778,31,254,228,716,406,1,686,39,863,203,410,224,800,457,137,9,160,704,219,438,28,924,944,120,450,144,836,492,299,326,260,44,116,840,98,202,83,96,321,36,0,21,921,55,141,367,341,827,639,385,265,158,128,772,201,49,539,64,258,317,180,110,86,269,851,442,295,125,908,77,662,276,23,669,744,272,373,242,105,82,931,48,35,968,351,168,318,859,115,578,822,33,557,418,371,616,32,625,67,213,217,109,523,365 }, { 167,118,212,18,16,71,60,24,191,375,411,68,363,146,447,101,199,589,271,562,126,302,647,121,815,9,628,566,273,35,575,664,21,92,55,781,621,1,48,777,478,0,149,936,818,108,520,150,354,154,446,847,463,124,346,132,264,98,107,7,65,522,156,28,759,13,22,23,39,49,932,727,882,5,14,223,32,640,608,467,100,51,604,125,695,10,69,724,806,246,221,50,140,195,517,67,252,96,768,279,293,31,360,848,88,166,105,691,95,682,674,46,535,103,2,175,649,109,159,598,458,265,329,364,914,12,653,33 }, { 141,64,86,177,128,597,77,269,95,180,237,352,304,291,275,147,588,372,102,194,125,947,13,678,49,875,202,349,120,437,115,4,59,137,153,751,197,40,208,342,465,954,67,23,5,318,135,32,216,660,470,534,196,182,98,31,22,612,90,38,312,448,107,7,10,581,165,353,192,172,707,51,262,498,494,117,33,21,17,1,389,76,203,14,46,565,563,65,569,546,391,330,285,284,277,210,205,139,134,26,25,20,19,12,9,6,3,620,217,11,326,97,853,629,259,278,232,789,380,365,294,289,244,55,43,0,247,111 }, { 18,289,701,65,240,194,90,403,523,214,421,283,475,389,217,102,862,202,847,437,494,453,650,64,697,874,51,352,751,401,817,33,84,0,899,13,597,5,196,805,32,23,11,954,95,3,27,22,24,757,875,141,671,312,108,21,153,19,306,114,118,247,450,288,77,17,730,56,4,12,177,942,273,958,814,117,519,86,61,128,859,207,835,193,880,123,249,838,28,120,342,49,134,300,2,6,801,216,719,57,457,576,864,304,125,302,124,14,615,372,16,210,40,237,60,577,504,119,770,608,752,62,10,9,643,48,1,15 }, { 51,23,13,202,115,21,12,5,32,128,403,453,141,401,165,308,120,318,457,15,475,4,269,64,1,0,197,10,719,494,99,2,450,37,48,730,3,180,523,77,7,18,386,14,9,6,16,59,22,217,260,125,11,17,90,177,341,237,117,421,153,24,221,899,33,352,317,102,28,326,137,247,82,817,961,19,40,365,402,391,569,27,629,57,95,49,25,31,8,216,210,110,758,304,72,29,93,54,351,26,38,291,98,20,134,61,196,76,56,45,44,241,275,139,372,349,509,36,65,342,350,615,678,285,89,214,50,670 }, { 98,223,393,125,31,791,834,116,271,1,93,202,697,44,64,167,127,293,5,541,51,446,801,77,450,212,48,284,807,234,120,23,765,21,318,13,421,18,195,948,639,551,132,360,730,770,141,142,562,146,163,96,386,49,963,144,668,354,591,197,346,128,260,221,0,198,82,165,416,269,494,670,367,949,817,147,33,178,522,70,32,535,455,719,137,453,326,203,842,22,102,687,61,156,55,121,407,4,315,2,325,105,403,883,110,329,217,342,95,692,10,781,615,463,798,12,958,291,351,7,17,39,878,586,113,196,28,68 }, { 15,4,40,11,23,165,13,51,110,93,120,32,82,77,125,33,197,141,260,202,59,10,0,21,102,64,180,5,57,31,453,22,386,12,269,8,318,128,403,134,3,139,95,475,457,730,44,9,49,719,326,117,203,1,115,351,98,450,17,352,28,99,116,217,494,523,210,373,391,961,37,177,90,144,137,2,342,18,153,317,401,56,854,14,48,65,237,341,36,758,421,291,111,277,402,365,509,30,7,922,242,105,275,372,349,24,86,901,801,899,898,300,39,308,817,72,6,670,16,45,752,498,27,38,76,304,170,615 }, { 15,1,0,13,2,5,901,7,23,6,9,341,8,3,4,51,961,12,115,10,898,180,82,569,134,31,22,141,351,202,457,120,44,269,165,77,260,365,403,401,318,317,14,33,217,11,854,93,28,30,453,18,137,37,386,21,110,64,719,36,498,352,128,450,16,117,922,475,509,49,177,55,111,391,40,730,523,99,326,98,102,629,758,153,32,39,642,372,24,873,752,116,291,308,421,125,373,95,143,482,203,817,494,35,899,196,86,304,349,17,244,38,237,65,275,247,242,59,105,402,210,638,48,615,144,342,148,127 }, { 234,416,77,315,5,639,202,325,147,113,198,49,450,455,61,142,329,178,21,0,427,470,494,342,58,32,557,22,318,230,725,43,858,112,120,70,102,13,48,263,20,344,260,884,425,817,128,798,115,290,105,518,291,137,95,904,23,403,64,141,491,159,241,845,523,31,121,33,319,97,320,392,246,196,153,17,173,104,10,39,663,269,117,592,501,125,51,347,72,30,163,28,253,170,408,194,376,107,18,265,544,326,352,270,341,4,738,615,534,475,595,98,259,66,631,449,301,922,158,76,134,720,512,312,9,180,859,690 }, { 146,60,271,126,16,156,360,199,18,121,167,640,522,132,24,446,354,591,71,463,118,340,150,92,598,273,441,195,107,212,22,0,407,10,5,21,108,467,28,279,586,575,423,566,727,191,101,493,649,534,68,95,608,517,55,35,32,783,653,9,408,48,49,508,363,296,607,698,246,13,668,33,64,117,109,356,98,314,39,658,140,105,7,362,660,447,809,411,955,93,31,621,50,303,298,153,347,12,158,125,65,953,713,264,163,350,359,141,124,14,143,51,939,478,149,115,36,75,4,781,581,225,207,102,77,30,562,44 }, { 4,11,361,300,77,56,377,368,14,59,40,161,51,128,33,200,210,23,378,27,54,495,102,554,38,494,453,17,21,12,202,80,444,108,53,757,37,46,78,13,245,457,342,390,139,133,123,386,84,523,32,605,196,862,527,736,803,99,73,57,19,630,561,475,3,542,509,421,317,250,181,136,111,277,269,450,197,472,183,48,26,485,730,297,62,714,402,381,403,391,880,122,719,341,318,306,145,25,5,514,256,61,899,546,106,90,50,34,383,833,236,775,497,165,129,85,401,366,184,469,436,838,358,328,316,291,275,241 }, { 141,351,217,82,352,120,854,260,64,15,180,372,1,922,269,317,36,137,752,373,13,21,349,51,898,450,77,202,110,23,318,160,93,115,291,128,365,48,197,177,901,96,5,165,244,864,10,86,457,4,40,237,523,247,33,579,341,32,304,11,661,125,83,143,498,326,817,2,203,275,437,69,102,954,717,16,59,961,35,386,851,730,22,475,28,253,31,7,57,98,95,134,144,391,12,6,719,117,210,116,17,196,139,0,3,37,494,473,403,114,49,30,29,164,899,704,559,153,90,72,55,9,45,509,482,453,393,230 }, { 15,77,13,1,0,102,23,33,2,4,51,5,10,291,7,9,3,450,6,217,117,120,177,317,341,260,11,12,817,342,365,115,8,134,21,153,180,16,18,22,349,40,165,82,14,64,141,453,372,31,457,523,901,196,197,326,275,352,210,961,719,730,28,304,475,403,569,44,128,32,899,93,59,269,401,24,17,49,752,98,318,110,36,629,216,30,386,125,95,494,90,137,48,351,308,116,111,57,139,37,86,99,498,65,615,247,482,144,39,237,221,20,96,19,244,421,300,758,203,670,194,509,38,854,402,873,437,391 }, { 15,23,13,77,141,260,137,120,51,202,180,115,1,365,217,0,341,450,269,291,317,318,5,197,128,21,9,177,373,351,110,352,165,2,12,523,7,64,349,326,10,48,36,901,32,33,22,403,854,82,90,96,4,922,16,37,28,18,752,457,40,386,244,372,102,494,6,308,8,160,86,24,30,14,401,49,661,817,453,719,421,402,11,704,961,475,237,873,342,55,3,39,730,391,59,196,93,221,117,143,216,615,898,44,498,275,253,210,304,35,285,95,125,31,98,17,139,509,72,153,811,482,89,83,144,899,99,576 }, { 348,174,85,138,6,280,74,355,233,192,204,636,580,353,343,289,673,66,65,91,81,104,712,750,25,42,214,792,95,64,681,173,194,32,715,135,90,312,29,879,172,825,63,235,835,86,22,87,145,370,5,256,7,222,415,52,0,874,426,97,500,519,17,26,237,43,4,288,36,18,10,389,20,33,560,76,21,61,40,544,45,59,249,888,77,577,746,232,28,102,2,72,49,568,123,287,56,525,448,751,180,11,337,526,707,671,226,27,19,247,24,319,117,48,422,114,12,69,108,84,208,597,37,1,861,67,889,58 }, { 152,452,497,59,216,4,269,188,77,11,79,339,128,529,94,471,318,141,202,588,32,76,377,177,678,33,111,291,349,90,5,102,21,137,51,72,12,179,542,38,99,64,257,184,37,1,245,217,460,196,48,372,115,947,148,45,402,474,40,89,342,210,17,352,205,288,3,153,769,13,117,10,2,134,292,54,275,304,139,875,498,431,23,405,241,403,247,317,569,229,401,453,494,285,358,180,197,86,300,57,0,476,961,6,954,308,36,143,524,165,277,475,316,597,14,95,237,15,7,221,341,58,157,735,129,266,214,421 }, { 417,253,244,499,141,10,559,564,110,8,260,352,728,143,180,951,120,642,638,661,752,922,341,373,811,137,269,901,717,197,93,206,498,44,165,31,116,203,160,854,384,351,36,873,762,326,704,268,217,1,64,115,282,317,959,55,144,15,365,82,898,968,509,164,86,479,318,13,851,22,21,332,473,434,51,202,77,940,911,569,23,125,450,864,824,237,261,9,242,615,372,617,127,48,201,102,128,4,33,5,96,506,0,391,117,98,28,401,386,40,295,105,32,758,531,276,338,37,83,35,349,59,533,153,177,629,11,12 }, { 77,13,23,51,177,102,33,115,59,4,40,0,141,128,90,210,202,137,64,22,269,291,217,10,196,28,153,117,318,7,49,2,14,216,134,18,180,16,6,11,9,24,403,1,275,197,3,95,36,86,125,165,247,342,31,352,494,19,32,402,12,139,453,317,20,237,98,65,15,349,44,475,26,285,17,30,120,111,57,93,21,372,105,27,25,719,194,457,341,203,304,386,260,391,730,116,421,365,35,29,5,99,326,123,498,208,39,569,509,244,288,752,450,143,678,144,110,523,401,308,82,214,300,351,43,37,48,164 }, { 1,2,22,50,67,14,36,5,46,28,103,12,0,38,83,114,65,168,194,7,69,133,86,95,24,49,218,29,54,21,55,96,109,160,51,10,584,16,128,6,9,23,48,158,18,75,756,37,35,105,169,32,389,289,159,323,238,181,52,244,202,13,503,646,164,137,532,141,239,115,361,480,185,64,17,143,789,283,124,708,253,505,946,597,3,717,45,776,58,170,108,269,70,735,312,874,285,610,68,782,189,318,424,71,531,31,308,237,320,171,4,892,72,402,99,328,220,418,251,420,394,19,180,577,487,401,347,344 }, { 17,106,119,378,742,255,306,136,207,240,84,383,62,790,80,655,61,45,5,56,311,3,209,504,440,667,76,151,32,58,263,483,179,29,2,833,292,548,214,123,129,425,186,454,128,243,205,738,445,64,21,245,148,52,38,14,26,249,57,27,328,19,90,6,4,555,11,34,59,54,162,202,184,507,469,141,592,229,48,215,887,710,152,73,86,40,161,72,618,460,266,257,491,77,358,211,227,287,25,869,183,318,297,50,290,495,10,216,130,614,155,1,476,177,137,361,12,315,37,112,33,22,46,95,113,269,194,171 }, { 141,128,202,3,5,2,1,269,64,318,6,33,17,102,15,180,0,196,137,10,153,7,120,352,197,13,77,117,51,134,403,14,165,12,23,402,11,93,9,342,260,82,110,21,494,19,22,237,31,351,4,125,86,475,457,450,326,27,44,32,203,40,36,95,291,961,453,115,25,285,143,111,678,98,341,37,139,99,523,817,49,57,752,498,45,386,18,38,217,8,116,65,16,244,28,144,317,365,56,719,373,901,194,854,79,898,277,59,29,576,26,421,30,569,401,730,947,177,164,864,48,72,391,922,24,873,94,349 }, { 38,514,328,377,11,57,266,248,41,880,313,471,556,152,361,4,485,99,305,757,403,157,12,102,339,54,369,40,211,130,542,457,3,37,188,14,139,23,13,153,494,117,33,475,775,229,507,381,300,196,77,453,452,59,555,162,488,184,277,585,236,477,440,629,62,128,51,111,421,134,402,183,215,961,670,79,548,123,342,210,202,89,401,527,474,94,65,587,719,543,432,181,45,17,257,291,80,64,72,21,619,108,32,413,828,46,5,29,0,95,2,275,129,308,10,56,504,205,86,618,155,76,177,49,431,569,90,497 }, { 68,520,167,101,264,118,478,562,0,9,664,777,936,604,212,100,191,252,154,18,124,806,265,16,759,21,48,1,71,375,88,724,628,24,329,35,682,411,410,363,166,302,815,447,65,419,589,55,23,39,647,149,917,909,821,382,125,942,98,346,925,772,13,701,146,96,223,51,108,31,10,221,271,22,60,28,321,44,92,905,69,30,676,639,49,593,364,882,274,694,521,907,64,105,5,158,67,621,781,812,126,133,553,189,848,897,213,686,95,32,121,404,522,199,103,116,156,50,140,83,429,706,763,273,115,165,127,77 }, { 230,689,699,213,466,831,352,217,30,443,418,854,144,201,840,855,251,203,957,822,96,530,1,539,93,36,137,800,317,83,190,128,326,669,752,351,748,494,88,206,160,31,473,859,335,202,141,44,321,253,735,498,269,435,116,367,187,86,35,927,332,180,237,69,98,778,244,285,219,82,131,576,228,617,208,922,866,930,372,100,120,64,2,934,403,349,531,702,48,21,731,817,274,23,5,10,13,406,365,224,947,824,795,345,898,291,382,295,223,692,318,286,238,39,341,276,863,77,615,166,260,625,678,51,28,67,410,125 }, { 77,33,102,117,134,153,196,291,13,51,15,23,82,64,40,202,128,120,0,141,260,351,450,22,4,95,59,137,269,342,177,386,318,326,11,115,10,210,65,373,86,180,217,49,403,1,165,275,28,18,453,57,36,125,98,352,494,523,139,197,14,31,854,475,2,194,216,9,7,817,21,719,93,6,730,24,457,237,90,12,116,16,44,349,110,3,5,402,99,961,317,114,372,19,48,32,285,105,96,17,365,341,300,143,8,203,401,247,164,108,421,25,752,144,26,30,20,391,39,111,304,109,758,50,221,208,37,289 }, { 11,40,33,51,542,328,13,117,38,14,23,139,153,134,54,102,111,12,485,377,775,37,99,403,231,277,401,719,369,3,475,453,514,4,629,308,211,880,457,291,305,89,266,152,130,2,57,196,961,6,488,215,5,176,59,555,471,313,72,300,477,183,62,184,79,0,507,248,115,21,670,339,249,548,361,1,165,292,29,197,229,77,556,474,236,386,421,157,413,188,452,17,758,41,162,391,449,587,32,46,123,428,509,52,247,569,136,899,757,523,210,753,155,129,76,50,237,64,730,720,476,383,312,440,275,90,45,342 }, { 77,64,141,202,33,102,128,153,2,117,269,6,23,318,1,13,0,134,137,51,5,180,3,196,10,7,40,165,15,14,352,197,86,291,237,115,403,95,17,177,22,217,36,139,210,9,120,19,125,342,494,275,82,475,457,49,453,16,12,31,4,65,21,402,11,143,260,194,110,93,450,25,28,351,317,111,498,326,27,18,349,752,44,341,59,164,386,26,285,116,365,98,719,208,32,391,300,509,401,523,99,20,24,38,114,244,373,730,55,48,901,372,203,312,961,8,277,160,678,304,34,37,57,854,56,546,29,144 }, { 15,4,93,5,13,21,11,1,23,32,110,141,64,82,180,2,33,40,3,98,352,120,6,10,0,12,77,7,341,197,37,51,102,351,269,854,95,17,202,31,9,752,901,44,165,117,48,318,153,291,134,137,115,365,237,196,372,59,498,260,349,450,14,128,90,36,317,244,899,22,342,922,437,125,143,873,453,16,160,72,105,482,179,817,19,89,401,457,57,661,403,523,177,164,45,308,864,373,253,245,8,898,49,421,569,223,76,719,28,61,18,247,139,56,96,27,490,210,468,111,494,475,144,38,961,391,304,25 }, { 1,2,50,46,14,67,103,38,24,83,133,29,52,96,75,28,114,5,36,238,65,54,108,171,70,0,58,18,69,181,160,532,236,7,22,412,433,754,283,55,163,220,480,361,487,124,12,223,545,45,328,394,21,398,16,155,9,366,48,35,956,6,154,87,323,646,309,514,112,186,822,137,17,109,149,418,745,175,547,86,37,285,68,800,866,10,429,732,516,25,208,302,51,32,118,334,281,99,531,71,61,194,537,458,23,891,389,19,151,675,409,336,128,168,13,400,307,95,262,832,227,49,273,420,3,115,484,64 }, { 258,276,860,201,843,295,137,160,567,116,261,144,268,943,284,202,187,935,662,203,699,131,219,224,44,141,127,36,326,96,98,31,318,269,244,964,23,93,384,489,55,21,434,332,13,403,51,120,1,617,918,352,908,367,110,206,180,365,254,197,492,473,871,442,48,82,10,143,800,260,39,574,28,944,299,940,282,253,9,115,494,418,341,125,855,77,8,49,128,836,535,165,100,576,30,523,385,105,822,217,395,959,564,22,531,911,37,83,393,851,717,64,817,752,421,716,5,317,901,551,373,859,0,170,291,599,533,251 }, { 7,2,14,87,46,52,278,92,16,140,75,29,135,294,262,70,38,35,172,171,409,24,60,58,69,5,97,112,66,314,1,163,571,71,50,461,155,267,232,330,18,220,54,334,357,126,380,307,21,74,12,230,48,309,186,675,32,37,298,331,226,246,151,45,774,107,64,337,25,324,6,67,606,189,622,20,448,150,43,61,0,400,22,849,287,10,68,9,86,563,28,95,227,583,192,394,620,103,36,764,572,108,128,335,83,55,587,550,13,145,600,549,536,65,141,852,366,49,415,90,26,236,526,950,17,4,181,72 }, { 13,23,51,115,2,33,77,0,1,10,4,7,217,5,9,141,102,6,3,180,11,40,317,22,15,64,14,197,352,202,16,12,341,269,365,165,18,318,177,17,59,153,453,196,752,291,32,117,308,237,125,403,31,128,8,36,401,24,28,349,372,49,498,137,475,247,95,304,143,569,901,21,98,468,457,134,44,139,19,90,421,86,210,120,386,629,93,37,116,482,494,57,110,873,342,55,961,275,111,391,546,35,509,244,203,30,27,99,29,437,48,20,260,65,719,216,734,25,38,54,450,326,50,351,46,864,105,253 }, { 74,145,204,66,138,42,25,6,337,174,525,222,192,29,26,544,746,287,415,632,85,609,135,7,353,280,112,580,87,396,712,355,64,122,81,104,2,45,173,673,416,648,172,43,792,226,52,22,97,651,151,194,70,65,0,19,32,20,715,95,825,348,5,624,233,113,86,635,91,879,294,10,644,235,1,90,500,36,573,560,49,636,243,58,63,21,331,426,61,75,389,27,445,14,69,750,28,289,46,38,17,888,311,312,18,24,140,186,76,283,141,12,874,16,232,278,72,461,707,53,4,526,597,255,665,180,114,881 }, { 77,217,33,102,317,291,202,23,13,51,141,15,275,269,318,115,342,180,21,4,196,352,64,128,11,494,32,5,137,403,40,2,0,125,3,177,10,98,365,349,12,7,372,6,341,453,165,197,153,475,48,752,22,237,31,117,9,95,59,93,16,90,120,247,308,450,49,221,244,36,28,18,144,86,14,134,326,421,203,44,17,304,24,116,523,260,110,864,210,498,401,901,1,35,241,386,82,127,817,39,72,437,160,105,65,143,730,719,351,216,457,402,30,350,293,164,37,859,96,367,139,284,19,579,576,391,285,373 }, { 187,258,871,219,442,574,908,839,926,160,116,44,137,224,276,201,36,860,131,202,613,228,144,531,406,93,31,902,567,385,843,318,203,268,800,98,662,856,494,23,190,120,127,418,30,295,533,836,1,284,96,822,244,64,944,717,86,851,55,13,21,51,22,840,434,269,251,367,489,326,48,110,141,699,816,260,39,384,261,371,473,83,206,254,859,10,669,492,28,317,373,128,49,365,450,77,180,863,559,530,82,829,341,918,253,32,9,197,125,351,332,165,143,943,728,535,67,831,576,855,940,403,217,716,105,274,69,959 }, { 1,372,23,5,141,21,744,13,291,77,225,349,144,48,459,96,839,260,304,269,442,335,691,352,32,30,622,203,303,284,330,64,45,521,180,317,217,160,88,752,418,120,93,190,948,166,954,340,919,686,342,244,228,202,201,189,137,110,321,914,411,447,781,772,254,51,765,31,656,264,237,167,724,478,842,437,274,127,125,69,44,662,466,435,351,326,82,9,897,410,253,716,286,678,479,299,238,197,68,7,2,934,223,100,70,58,154,98,682,393,967,960,922,856,805,762,475,402,365,341,336,285,247,221,177,169,163,131 }, { 66,222,74,135,87,29,145,2,337,294,52,172,138,331,6,7,25,226,42,97,632,70,192,112,353,609,525,415,461,204,287,500,26,174,75,43,324,1,58,32,220,5,232,544,580,85,620,635,278,45,746,64,426,568,448,396,262,122,173,151,69,20,95,19,61,526,140,65,889,86,307,14,104,280,21,46,81,355,92,38,872,22,387,651,186,648,113,194,416,72,163,673,90,24,35,155,49,16,330,37,792,0,888,243,17,36,76,861,10,48,849,67,644,227,50,4,89,853,334,63,27,314,312,12,825,712,91,298 }, { 45,17,106,209,255,119,186,5,263,207,454,29,2,48,425,243,21,496,62,290,3,270,400,408,52,155,136,659,171,14,56,513,50,80,84,32,378,46,61,655,666,742,221,58,383,38,1,54,311,306,240,721,181,440,502,430,334,129,72,536,227,123,76,790,592,214,89,328,281,555,34,787,241,148,64,215,663,287,587,37,11,405,162,27,237,504,57,90,130,152,541,179,12,211,548,41,36,552,184,4,741,115,431,292,449,869,229,96,77,507,223,128,183,40,7,86,51,249,205,245,161,6,738,236,103,151,59,10 }, { 213,88,260,120,93,373,141,30,100,450,166,36,372,321,459,473,264,180,110,326,1,225,144,704,717,351,82,855,530,269,466,352,217,265,190,22,274,131,96,539,165,86,457,291,28,244,64,187,318,752,39,349,661,330,9,160,202,219,77,410,197,44,908,254,116,49,137,968,276,317,125,406,31,521,523,435,15,98,228,128,32,299,35,662,293,143,115,21,934,778,224,33,856,923,876,854,689,403,371,341,10,935,851,498,437,8,922,48,642,776,903,839,836,730,613,365,268,242,55,0,944,899,492,898,615,385,304,285 }, { 266,57,152,381,471,313,369,99,229,12,339,62,157,77,4,37,188,40,475,162,38,3,452,775,129,184,403,17,59,128,11,432,202,111,453,33,56,183,291,401,216,361,328,102,136,402,79,54,440,14,139,880,123,494,51,23,514,277,507,130,757,474,377,21,94,529,177,548,421,349,64,76,211,90,117,89,72,308,13,318,383,5,141,210,134,556,342,153,305,497,257,555,119,485,84,269,275,106,670,2,115,477,488,45,196,41,300,205,32,542,10,543,304,431,86,180,504,19,27,82,179,36,629,249,46,50,237,245 }, { 352,217,317,141,752,372,365,180,341,15,349,77,864,21,291,244,115,13,120,269,1,498,5,901,579,98,144,64,23,48,482,351,51,237,102,201,82,437,125,137,318,4,2,247,202,0,31,854,203,143,253,260,32,177,160,490,10,96,110,44,22,494,251,33,128,403,9,3,898,717,164,28,197,72,93,11,873,450,36,165,386,95,373,6,223,661,30,12,49,922,342,206,523,16,457,127,109,468,308,391,116,531,332,473,187,39,88,35,730,453,326,221,7,719,69,86,105,100,83,851,475,90,350,230,678,421,101,304 }, { 14,514,369,880,102,403,377,51,719,485,153,23,453,401,457,11,40,13,328,12,57,4,33,38,629,236,670,54,730,117,111,361,961,59,37,134,99,758,757,165,2,46,386,412,421,391,277,29,308,543,477,494,188,600,6,196,21,542,197,139,300,739,475,52,899,79,509,523,488,775,583,283,231,7,803,552,32,5,402,89,828,3,507,176,77,50,15,155,211,64,17,569,215,115,18,381,237,305,266,202,90,34,342,194,128,62,555,389,242,125,108,65,0,471,338,136,56,548,506,221,181,133,10,440,114,248,95,1 }, { 107,172,7,359,126,92,14,135,314,278,60,150,298,46,392,279,232,192,2,441,356,330,357,16,32,380,97,534,423,581,35,526,38,448,493,132,52,288,246,660,5,121,66,24,230,324,572,21,387,226,462,259,247,95,220,146,140,77,18,508,147,262,90,48,312,707,20,71,603,54,33,195,550,362,86,236,108,739,199,830,23,64,43,29,895,802,451,22,36,28,929,294,606,50,87,70,501,13,808,177,55,1,194,178,711,316,4,0,102,590,366,49,893,600,37,582,309,872,267,117,388,241,620,115,786,939,571,360 }, { 59,4,90,45,216,13,25,0,177,23,77,51,27,95,72,26,115,65,12,91,210,123,275,37,389,19,102,33,11,49,22,18,194,5,214,21,85,53,48,202,343,291,31,57,6,128,42,746,93,73,58,44,32,196,283,81,319,61,141,249,153,64,138,117,422,355,40,348,139,403,789,145,788,300,247,240,134,74,34,804,619,370,104,86,38,1,304,180,524,494,217,20,597,544,318,352,323,233,174,114,76,17,475,280,204,588,342,285,14,3,43,725,287,7,888,636,235,52,29,63,337,232,122,784,125,397,817,678 }, { 5,315,416,49,455,639,202,350,77,408,21,197,137,450,402,13,61,509,329,113,713,344,569,347,401,48,0,841,494,318,734,749,64,70,308,95,903,120,342,884,237,557,32,194,546,115,845,1,23,165,663,128,873,102,291,518,22,58,817,391,498,263,17,33,221,269,403,923,260,105,241,125,51,196,312,39,10,31,153,234,112,523,158,18,4,265,12,141,9,159,928,623,326,207,25,177,310,3,2,859,98,28,65,30,163,11,19,275,491,290,6,117,541,16,15,124,76,72,27,922,210,44,341,349,134,773,147,24 }, { 130,47,381,390,59,90,200,472,214,714,65,289,6,122,874,85,64,29,751,648,52,50,74,875,247,194,624,249,288,26,312,437,32,217,630,881,4,123,95,78,835,352,196,665,519,33,57,711,524,954,108,42,19,77,22,153,597,416,412,0,145,444,27,243,25,14,183,304,117,453,51,256,141,730,102,177,134,236,315,680,86,112,34,11,115,235,287,237,113,45,283,151,317,588,579,99,3,752,216,342,813,128,445,864,180,56,46,28,18,73,12,23,114,13,389,53,644,719,21,396,58,17,372,947,137,316,10,250 }, { 51,453,23,719,13,730,165,457,37,197,99,12,386,401,475,961,4,17,11,64,59,308,54,115,57,38,328,758,391,6,5,2,899,3,753,403,32,523,670,10,509,40,33,421,629,120,21,65,19,22,0,202,125,95,569,117,90,558,29,26,514,494,1,775,128,134,14,450,361,34,9,86,194,177,350,269,72,27,25,7,880,757,111,62,153,316,236,141,50,56,260,217,196,867,546,161,130,106,77,48,41,31,16,8,317,152,468,242,221,136,734,80,89,968,949,862,814,801,717,704,495,469,440,428,412,383,378,326 }, { 15,13,1,5,23,2,7,0,6,3,12,51,4,180,115,21,9,165,457,197,141,352,11,14,202,217,10,37,8,32,341,120,22,117,752,269,16,77,134,961,901,719,318,48,317,365,33,110,93,31,569,18,102,28,40,260,17,509,128,44,153,137,82,498,59,629,351,72,386,403,36,49,401,453,730,308,196,450,89,873,30,523,125,99,391,326,177,98,64,247,494,854,24,291,95,475,38,86,482,39,203,922,372,349,116,90,144,57,35,758,55,864,221,468,244,210,421,139,817,76,373,899,54,105,19,304,342,96 }, { 0,9,35,28,68,24,67,65,1,16,18,114,69,103,50,101,149,22,175,124,55,39,12,218,133,96,154,189,5,83,21,71,23,7,336,433,251,13,49,75,118,335,2,51,48,486,30,14,10,283,181,745,115,223,137,54,230,109,418,37,345,64,128,141,108,281,99,36,60,100,202,956,537,163,532,480,221,766,302,596,487,95,252,346,58,158,46,180,217,361,237,70,398,86,269,160,31,32,105,657,443,140,285,125,87,212,166,167,502,6,88,375,165,323,831,317,754,29,318,439,77,98,364,38,197,429,44,765 }, { 28,105,22,320,109,49,301,0,9,170,95,1,35,55,127,65,24,168,98,159,713,16,512,31,395,36,623,2,7,293,740,14,338,347,424,185,286,12,44,23,21,169,124,5,158,68,67,928,13,371,18,299,242,125,51,289,175,916,64,761,479,374,39,737,685,154,48,272,6,114,599,116,10,86,141,37,194,83,149,506,327,312,841,202,763,237,50,900,870,538,284,115,131,420,346,137,654,385,456,165,187,762,30,276,239,32,308,69,143,269,429,96,570,71,128,180,933,160,164,46,197,221,401,634,965,219,101,318 }, { 77,13,51,102,4,59,23,33,202,210,115,40,403,177,128,196,141,153,117,64,494,269,318,134,475,217,342,0,291,11,90,453,22,402,137,15,216,139,10,180,275,86,95,65,57,6,36,18,523,1,125,21,317,365,197,49,28,421,32,14,352,25,19,7,2,899,730,719,391,341,152,24,401,48,27,17,12,901,247,123,114,16,9,111,99,26,349,285,576,50,20,3,386,372,326,260,194,120,110,351,283,482,293,242,165,96,29,37,30,817,801,498,457,450,393,373,299,237,214,203,615,569,116,93,34,82,958,805 }, { 13,23,77,51,33,141,115,102,0,217,10,2,6,4,7,64,22,1,11,177,180,40,3,14,202,269,9,291,352,15,165,197,17,128,317,153,196,5,318,18,372,117,16,28,59,36,19,137,95,210,237,247,125,49,86,349,341,304,134,365,24,275,12,31,27,453,403,752,25,143,308,26,57,20,901,120,475,44,401,457,29,498,90,139,65,8,391,93,342,494,216,509,164,98,99,35,55,386,244,111,32,45,37,21,260,38,110,56,450,105,39,730,402,523,46,437,82,30,719,569,203,961,873,326,285,194,116,421 }, { 456,116,492,268,949,867,203,51,719,8,391,918,791,457,730,499,13,386,23,206,685,125,31,551,170,870,93,417,401,10,22,479,506,338,940,44,509,143,64,692,670,558,453,0,473,197,523,758,629,341,165,1,564,55,899,762,308,961,421,959,36,638,115,569,801,180,642,86,299,164,28,37,141,965,498,559,9,5,120,237,95,546,260,873,599,137,253,12,244,903,901,2,817,752,728,128,352,450,105,202,7,615,127,365,958,21,301,49,951,403,740,326,239,898,373,922,475,6,854,242,15,3,318,4,269,98,65,99 }, { 17,237,106,62,180,45,136,32,498,64,115,41,255,129,546,752,864,197,21,227,241,490,352,482,57,123,292,350,247,509,449,162,365,468,214,38,23,13,4,476,148,76,437,155,507,141,165,77,3,720,317,290,270,873,211,164,72,153,209,117,5,659,54,48,249,217,341,186,710,33,40,14,12,496,119,11,519,90,183,618,139,179,37,328,579,221,431,248,372,405,130,59,99,400,263,205,425,2,358,349,901,51,177,171,89,428,50,454,304,207,542,1,457,308,734,721,391,316,29,569,94,243,143,339,196,313,128,111 }, { 1,5,180,15,2,4,0,352,3,13,901,341,7,752,6,141,217,23,365,317,115,197,21,51,165,269,12,11,9,202,31,33,77,569,44,93,318,137,110,120,36,10,22,372,260,498,116,64,32,873,125,48,102,308,8,349,98,482,291,386,401,14,373,326,28,237,37,55,86,134,203,457,391,16,117,177,253,144,509,421,127,153,40,206,403,961,864,468,221,494,437,453,18,17,196,304,143,128,96,854,450,72,247,35,579,89,642,758,82,342,160,629,719,282,811,59,351,922,730,95,638,523,210,546,332,661,49,734 }, { 141,205,497,216,269,152,588,59,452,128,4,76,352,875,188,77,79,11,94,678,947,339,954,217,471,372,90,529,72,318,247,64,32,89,177,12,288,37,1,304,349,202,5,51,291,33,474,102,111,23,115,21,99,179,864,38,148,377,13,460,431,498,437,316,180,2,961,40,358,542,137,490,405,241,464,317,3,45,54,7,184,196,17,10,402,752,245,342,210,14,873,48,143,285,153,257,197,308,292,0,36,569,769,237,134,482,139,275,165,468,341,629,413,734,86,476,365,6,300,851,117,751,494,401,270,229,453,29 }, { 247,64,317,217,237,437,180,498,349,115,752,579,304,372,864,482,291,141,352,468,197,177,13,391,164,490,23,546,33,365,77,153,72,216,954,597,277,10,708,269,134,569,275,51,695,509,318,179,0,678,244,140,312,640,117,76,629,196,751,128,36,953,674,260,102,901,32,21,22,225,401,86,717,143,92,873,351,16,133,114,191,386,253,165,69,59,9,458,341,202,149,82,649,35,453,398,166,100,95,93,90,125,15,373,330,923,316,48,854,586,213,486,230,922,5,411,823,734,189,139,103,65,50,24,18,12,830,167 }, { 2,1,5,7,6,3,77,0,141,13,180,15,217,64,33,23,102,10,352,14,117,9,11,197,165,40,269,17,291,4,115,134,12,153,341,317,752,372,237,51,349,22,498,202,318,16,457,128,196,36,177,365,32,21,59,19,125,901,342,8,86,120,139,93,45,961,57,95,38,143,509,28,29,391,111,210,27,260,873,244,82,137,18,386,164,37,719,25,48,31,304,49,864,98,402,275,569,110,351,629,253,546,26,41,90,494,50,730,56,523,453,44,54,144,24,99,30,403,678,76,898,450,437,55,954,482,308,277 }, { 11,40,38,328,542,33,339,313,12,377,157,775,485,99,51,471,41,369,23,37,475,57,54,457,14,117,13,188,305,629,102,403,79,4,139,514,880,961,111,266,719,152,248,474,134,453,401,153,211,342,477,21,2,59,361,89,587,277,94,29,308,196,64,32,413,77,229,210,184,215,402,128,431,381,46,670,5,247,197,165,556,757,386,115,300,50,17,391,803,494,875,490,730,177,162,450,421,275,202,0,6,1,257,76,72,65,48,19,10,129,569,236,130,15,7,555,901,898,588,86,9,543,488,90,452,749,619,507 }, { 77,102,33,196,40,51,202,23,153,128,117,13,342,64,134,141,4,59,0,269,210,177,22,318,137,403,65,86,10,475,139,453,95,115,28,99,11,165,217,36,180,197,49,402,291,125,1,352,18,15,494,421,194,275,31,300,110,120,57,90,93,12,237,401,317,6,457,14,2,82,24,114,260,9,386,44,285,108,361,98,16,7,21,349,326,216,5,116,730,341,372,19,133,719,203,48,32,391,39,25,143,111,105,67,576,752,670,961,899,308,498,37,351,304,20,30,283,901,523,365,27,244,208,55,3,164,485,8 }, { 472,34,80,495,250,469,176,389,527,17,14,161,53,231,4,128,56,283,216,106,84,57,27,483,177,59,119,503,436,45,585,297,194,29,378,3,42,62,269,136,26,40,11,2,862,678,619,33,73,236,255,514,719,200,25,6,64,240,179,141,52,102,789,361,618,129,597,5,153,611,349,205,65,245,803,402,210,457,123,383,90,304,667,318,814,504,328,133,130,51,32,48,684,108,714,412,215,13,139,19,95,77,47,275,99,12,311,211,165,1,432,207,322,196,117,61,23,524,152,115,369,183,134,114,573,54,162,46 }, { 752,352,317,180,141,217,365,269,244,341,498,115,253,901,1,372,202,21,318,4,5,23,700,717,13,137,2,349,197,864,10,873,143,7,482,0,51,3,64,11,67,308,531,12,8,6,28,237,22,31,468,579,533,291,160,221,35,30,96,48,55,33,9,961,120,49,44,39,32,247,83,69,450,326,260,77,36,98,851,509,165,37,16,457,437,110,93,88,82,14,345,822,765,638,421,219,190,131,128,114,203,144,99,800,401,844,453,125,494,475,373,351,241,206,170,164,148,134,127,116,105,100,86,40,38,18,811,19 }, { 9,39,101,265,18,333,520,329,100,593,553,364,310,252,167,16,68,604,0,363,404,118,166,121,254,158,272,24,60,271,212,286,639,327,159,35,146,1,109,30,455,411,793,105,557,49,132,647,31,71,621,21,656,354,438,627,676,688,98,48,682,28,156,538,190,22,5,55,23,195,65,44,848,264,51,446,857,709,127,374,781,447,191,344,865,625,821,13,124,96,93,7,578,125,419,907,360,463,32,116,126,37,274,777,88,731,108,67,154,92,95,36,199,12,137,131,10,562,128,326,664,203,382,50,806,242,921,435 }, { 15,1,901,180,2,4,5,3,0,752,7,6,341,13,115,317,365,23,217,141,9,197,352,165,51,21,137,11,36,202,12,33,22,873,308,77,269,10,64,86,498,569,31,372,55,93,40,120,160,44,509,318,349,482,638,8,117,37,116,164,102,32,28,401,110,128,196,144,206,244,153,457,468,951,17,291,16,203,96,260,811,143,373,642,125,134,437,386,546,268,247,177,14,48,758,717,719,391,579,72,421,89,661,629,111,730,559,961,221,59,403,523,304,851,35,30,169,854,494,127,82,326,450,251,898,417,475,734 }, { 131,39,829,166,613,827,716,578,9,100,224,310,406,30,98,616,228,1,254,856,219,438,938,190,31,846,265,931,0,127,96,625,274,924,44,371,101,385,116,252,272,863,51,137,88,21,333,731,557,36,23,404,48,223,125,49,264,160,187,737,242,105,28,258,144,93,13,530,158,944,382,284,395,203,812,593,518,442,5,456,836,128,326,293,68,329,403,35,202,816,77,115,83,909,688,86,890,478,120,64,22,639,16,165,276,393,455,871,410,201,286,299,33,576,960,656,24,217,95,159,110,32,367,421,492,221,55,102 }, { 17,64,62,141,106,136,751,292,129,352,41,38,954,86,476,214,217,128,177,32,237,947,180,162,123,209,710,269,519,247,90,864,157,77,318,99,57,76,59,4,437,40,179,358,11,45,618,119,313,5,304,211,597,148,875,23,249,197,130,95,507,37,54,3,216,457,248,58,210,115,288,12,425,678,186,164,328,72,454,339,245,102,80,498,312,165,372,139,155,2,152,56,33,21,655,243,720,183,207,14,29,241,117,266,290,471,137,84,51,188,305,275,205,449,7,263,48,542,13,270,742,171,752,509,61,317,349,369 }, { 42,25,235,650,736,65,605,630,233,343,123,256,122,85,26,416,6,389,63,141,249,368,444,194,511,174,544,19,108,597,348,524,138,90,27,183,32,370,304,525,84,56,53,283,789,445,18,78,280,91,130,947,588,619,45,355,17,680,73,4,0,222,112,3,813,119,145,64,678,297,250,80,21,573,523,86,214,216,102,76,11,746,40,33,269,240,29,289,624,177,323,450,57,24,561,77,152,114,184,74,287,28,396,665,648,378,372,137,37,5,390,106,70,22,847,51,49,349,874,47,881,23,817,432,337,243,153,124 }, { 184,229,152,432,266,452,57,497,381,619,17,313,471,257,59,129,369,339,4,12,205,99,157,77,3,5,45,128,123,106,62,202,162,32,21,216,40,136,11,188,119,249,402,349,2,403,14,37,38,54,64,291,618,524,102,475,76,177,80,90,214,33,79,141,453,23,210,111,245,372,137,27,318,269,217,494,775,86,94,139,10,1,19,115,51,401,56,769,183,361,84,529,474,277,757,72,48,880,6,247,29,209,710,179,377,89,41,292,285,328,13,588,180,342,130,556,36,477,308,275,460,378,61,197,196,0,165,421 }, { 137,202,160,131,860,567,318,36,295,141,843,39,800,93,30,105,187,224,276,201,261,943,964,98,49,269,219,851,116,9,22,473,1,352,203,127,822,100,206,699,144,268,662,244,253,10,717,535,332,120,44,258,143,31,64,450,704,96,859,190,180,115,55,365,531,326,95,217,28,110,564,752,86,373,284,228,317,21,77,341,13,48,434,221,197,51,911,940,159,23,384,533,260,494,559,935,291,901,88,109,574,282,128,442,367,308,959,617,5,83,489,299,251,728,170,164,165,177,492,406,926,417,293,401,349,871,125,968 }, { 125,64,493,0,49,165,35,293,55,93,18,98,9,325,68,10,279,137,31,48,453,389,194,197,147,13,788,14,132,95,107,77,391,371,342,174,61,43,581,105,28,22,5,259,319,104,758,671,590,128,44,32,20,767,761,457,146,121,725,465,198,126,757,289,116,100,23,21,110,763,612,12,663,199,142,120,102,101,7,427,4,356,37,941,963,867,848,498,156,88,86,58,51,33,690,558,376,180,2,864,163,955,70,623,804,422,657,202,1,40,534,90,649,470,798,522,392,352,945,502,386,359,237,221,203,177,159,144 }, { 15,33,4,77,13,102,23,40,32,5,11,349,51,177,21,141,117,93,202,59,110,153,64,291,318,196,31,217,269,115,10,180,82,137,1,8,44,3,98,125,134,0,165,22,12,128,351,17,95,116,2,304,120,139,403,457,210,197,49,341,453,144,372,450,494,86,48,352,386,523,36,90,719,898,6,275,30,365,57,730,28,9,317,247,326,854,76,373,475,7,72,37,421,817,638,901,401,111,961,342,899,216,402,277,260,18,237,758,569,203,99,629,437,535,39,61,16,96,752,14,300,208,922,704,105,83,308,143 }, { 110,854,253,811,352,141,951,661,244,642,180,752,143,498,384,269,559,317,922,10,911,160,351,533,365,373,206,902,638,873,332,261,345,260,137,717,116,843,31,417,120,44,959,531,217,341,535,201,125,36,699,860,82,55,564,434,926,318,268,940,197,901,164,574,864,276,251,824,295,876,127,450,64,617,943,93,258,776,15,282,326,165,546,817,855,851,203,96,187,144,728,83,1,372,601,219,224,762,237,284,509,21,170,169,499,98,391,479,115,768,482,473,406,86,898,662,349,48,202,131,51,5,0,896,871,401,238,228 }, { 2,29,70,75,220,52,112,331,145,1,163,26,74,324,6,69,58,307,19,409,278,287,38,226,46,223,394,87,25,294,606,50,66,14,632,135,583,151,42,67,45,27,396,357,171,380,675,138,5,21,113,267,262,97,24,7,309,764,635,53,537,222,103,48,335,500,83,32,122,16,550,186,96,17,73,334,849,155,189,644,852,802,37,61,54,64,571,140,35,12,582,651,461,486,853,108,36,80,18,133,451,315,624,65,337,785,573,366,445,72,86,774,92,89,297,400,10,114,95,416,587,648,462,172,71,600,820,238 }, { 23,13,77,51,115,177,64,141,33,102,4,217,202,40,128,269,291,59,0,180,10,2,6,7,318,11,196,14,137,90,32,22,95,153,352,210,9,1,117,15,165,16,197,49,3,125,86,237,349,18,403,216,19,17,247,21,317,304,342,24,341,134,475,453,12,275,25,36,28,20,98,494,372,57,31,93,65,44,110,27,26,120,139,365,752,111,37,35,326,164,116,402,901,260,457,30,288,421,105,56,498,29,144,391,82,203,5,401,308,285,719,386,99,143,48,39,351,55,194,437,312,450,96,523,76,509,244,316 }, { 340,897,691,478,914,658,724,382,363,812,698,682,100,156,166,521,264,447,909,411,1,404,88,354,303,438,96,296,274,772,39,656,418,921,9,30,410,144,23,744,848,639,664,435,21,586,919,13,271,31,335,254,51,5,850,98,367,225,960,77,203,759,621,190,48,127,676,120,32,668,33,83,4,67,44,36,272,217,69,291,131,284,286,360,821,101,285,116,242,18,223,686,102,265,905,842,317,329,93,68,82,822,195,128,125,576,692,351,103,64,238,115,652,475,349,765,326,141,966,578,110,118,0,260,403,201,163,105 }, { 310,18,9,326,265,252,121,51,159,77,195,105,101,120,363,33,24,354,271,102,272,709,167,98,16,13,132,639,23,158,260,55,333,327,704,450,35,170,60,202,49,557,125,93,411,254,1,364,95,455,146,817,28,520,338,494,7,286,137,156,109,39,21,14,48,128,116,64,40,31,859,320,118,212,141,360,890,318,293,4,523,615,269,576,169,20,165,153,75,196,329,373,210,177,92,69,0,301,291,781,479,371,217,627,407,403,342,127,71,44,36,910,374,5,50,668,647,351,936,682,578,538,593,553,203,185,180,110 }, { 57,313,471,99,369,12,339,157,266,152,38,475,328,453,775,37,403,401,514,40,188,342,139,77,11,59,377,361,229,474,33,4,51,880,277,54,3,211,14,102,62,381,23,111,162,196,130,529,556,305,757,275,128,79,115,629,13,402,421,507,308,485,210,129,123,184,177,494,41,477,153,488,117,542,452,248,300,216,202,236,134,94,670,431,89,64,17,183,440,569,136,555,72,76,734,432,457,543,961,257,215,291,304,10,413,15,205,548,90,56,2,21,46,165,318,247,349,197,86,32,0,283,412,141,36,828,386,82 }, { 16,24,35,60,140,71,92,7,14,230,189,108,18,69,46,150,388,246,278,2,172,68,1,451,38,330,135,126,236,309,149,443,50,267,121,565,67,582,21,75,48,462,52,563,594,314,29,399,66,191,877,103,572,55,232,366,97,696,357,380,733,167,83,220,517,5,28,674,74,12,65,0,54,9,118,262,335,146,516,32,37,653,915,22,36,133,251,96,324,87,273,394,64,199,723,223,107,10,486,458,711,13,6,95,163,571,86,726,448,212,641,192,345,70,181,132,23,49,114,550,98,20,271,606,298,633,99,603 }, { 206,417,940,959,93,473,728,559,499,203,137,202,8,450,564,31,44,120,269,260,318,141,116,326,244,253,10,127,268,143,22,125,98,817,434,1,373,144,128,615,51,638,23,384,692,523,341,64,922,0,851,13,489,110,352,105,9,951,717,86,28,386,367,403,299,704,642,242,55,551,901,36,958,282,859,160,77,49,291,494,801,968,30,180,492,365,911,661,498,276,854,165,164,873,37,762,456,197,21,317,12,15,5,7,569,285,918,421,752,629,576,479,115,95,2,349,96,401,758,899,393,170,898,217,457,391,48,39 }, { 15,1,2,13,0,5,23,7,4,3,6,51,9,217,77,341,115,10,8,11,33,349,12,317,291,180,177,14,102,16,365,120,22,901,304,165,457,21,372,260,197,32,18,40,403,453,31,202,82,961,719,475,28,247,523,117,450,64,93,141,730,110,30,352,351,752,569,44,401,153,17,386,196,59,308,24,134,36,854,494,318,899,48,137,342,326,125,629,90,49,128,437,37,817,95,275,922,421,498,758,98,210,111,203,99,237,391,116,216,57,482,144,373,39,35,20,19,468,139,615,55,221,288,898,873,509,244,86 }, { 2,1,14,5,50,48,46,290,21,45,29,32,263,155,207,52,38,425,171,76,408,72,449,17,292,227,89,58,513,400,428,119,476,7,61,54,67,720,75,241,243,186,502,655,69,221,36,148,24,96,6,306,3,214,106,37,0,103,223,10,179,281,16,83,350,64,90,129,430,464,181,663,666,22,413,405,18,240,710,84,262,790,123,431,28,12,741,163,115,460,255,536,56,128,35,334,141,9,220,65,205,51,86,659,99,249,23,541,95,245,618,209,519,202,70,592,270,237,528,62,27,217,133,4,394,137,114,675 }, { 132,121,354,167,146,463,271,195,668,446,98,223,407,360,18,212,522,447,1,781,60,48,591,411,156,562,586,363,664,21,777,393,199,293,125,807,936,9,23,590,163,16,13,658,5,126,541,55,101,941,107,259,621,191,51,834,786,68,647,765,31,150,929,759,284,35,71,49,24,465,221,118,520,7,92,883,116,608,279,727,535,70,96,44,687,478,105,50,346,697,467,963,281,33,10,566,22,581,626,93,77,296,493,4,102,108,115,640,147,75,39,770,87,32,914,127,144,598,178,0,117,273,12,2,37,783,691,932 }, { 131,578,371,219,224,716,105,616,737,385,187,761,258,916,254,159,49,910,9,623,98,127,836,924,272,286,442,39,28,688,890,320,627,518,293,0,944,871,574,242,31,395,22,201,327,44,116,158,276,109,908,301,860,284,36,51,23,137,95,926,713,512,30,160,125,333,170,239,96,21,456,347,228,13,86,64,128,1,68,101,839,202,506,424,295,662,938,144,55,168,24,567,48,843,406,83,65,185,613,438,203,268,35,165,492,244,299,902,221,384,16,141,115,166,827,93,10,829,37,364,763,261,169,269,5,656,434,685 }, { 302,467,484,97,453,6,398,124,69,36,51,14,421,298,1,66,273,87,74,523,81,426,2,403,67,168,18,386,886,756,701,801,158,13,65,0,26,23,475,24,758,86,22,108,719,25,547,615,401,159,117,423,150,730,847,563,154,75,19,646,29,7,505,817,189,278,457,165,42,458,717,572,267,138,782,531,429,153,135,450,134,49,700,208,958,671,715,622,336,244,172,143,114,95,85,63,60,52,650,197,46,899,140,92,160,28,10,791,885,718,327,314,12,5,610,109,43,703,673,670,370,341,326,289,38,35,805,879 }, { 190,30,778,530,539,88,100,625,382,1,960,410,731,274,96,840,957,435,321,795,748,264,669,438,466,39,166,131,36,418,144,265,9,44,228,213,23,219,224,921,223,160,406,251,31,863,83,98,310,116,21,613,13,557,203,51,128,0,252,367,335,137,254,5,924,521,284,352,829,48,765,856,258,475,827,69,201,93,49,909,404,716,238,101,616,822,33,421,32,456,593,217,125,127,944,752,67,286,276,679,931,831,329,403,816,158,77,812,221,772,317,639,37,35,28,242,120,268,578,50,230,966,686,494,187,551,478,285 }, { 141,202,128,2,269,1,64,5,180,3,318,33,197,6,352,15,7,102,77,0,134,13,137,10,196,153,165,120,117,14,17,11,12,82,110,4,9,237,23,291,260,494,93,51,403,217,21,498,752,450,342,341,31,32,351,22,326,125,402,457,317,143,86,36,115,19,203,40,111,961,285,16,48,475,98,116,44,678,365,95,8,37,57,28,244,27,18,901,49,45,864,569,349,373,386,391,453,59,523,144,719,139,509,25,854,372,38,24,56,898,194,164,947,79,29,817,94,253,99,873,954,730,55,65,597,61,26,546 }, { 44,201,567,489,116,662,224,268,131,219,434,295,187,144,31,276,699,384,137,110,442,258,36,160,228,261,367,613,93,30,64,120,908,244,284,203,260,141,202,385,1,9,269,940,39,855,253,918,98,96,373,22,406,856,326,105,206,143,318,10,217,127,55,523,115,77,125,717,617,86,49,13,836,51,28,23,574,332,128,83,190,180,871,839,371,393,944,352,317,21,164,473,935,197,450,341,959,0,177,911,840,254,531,165,291,716,418,899,800,88,829,282,827,494,48,492,661,854,5,351,100,82,299,851,822,15,860,365 }, { 51,12,23,15,99,37,13,10,453,165,117,38,0,197,629,569,82,115,401,120,64,134,22,474,457,11,110,719,31,93,260,9,14,475,111,32,153,79,1,94,21,40,308,128,125,8,28,5,18,54,403,351,3,44,180,202,89,450,328,33,961,2,139,36,4,49,77,45,141,523,326,386,730,48,17,217,30,431,148,405,317,237,29,98,16,341,775,413,196,365,352,55,318,72,758,116,6,59,24,7,477,898,734,509,58,39,203,95,372,482,86,854,19,391,421,402,269,144,494,90,102,291,922,817,57,373,899,27 }, { 135,7,172,2,92,140,66,52,97,74,324,14,226,29,232,46,38,380,87,262,314,357,278,330,16,298,571,448,35,126,60,220,620,606,75,6,24,192,107,69,246,230,331,1,5,267,294,70,622,353,222,853,550,563,71,572,583,138,150,600,189,500,25,43,50,309,21,526,32,872,12,174,54,58,37,20,893,802,22,48,145,86,64,580,462,95,67,18,888,42,950,65,387,36,171,108,451,112,10,501,26,726,335,441,103,785,83,359,204,582,279,337,461,49,0,72,423,45,443,409,61,68,356,28,392,163,673,114 }, { 125,386,391,23,963,60,51,949,165,221,21,13,541,393,118,719,150,197,326,758,421,791,517,801,566,558,308,48,362,7,834,670,453,551,173,401,203,102,43,20,5,71,36,457,251,77,697,279,140,867,33,126,115,32,92,149,422,743,367,232,193,0,770,4,98,509,40,674,81,18,341,11,783,192,577,546,397,16,494,510,508,217,189,104,705,610,330,2,596,105,823,293,202,117,10,314,796,64,862,629,475,468,281,246,242,38,403,29,474,298,31,27,14,858,414,95,942,779,773,569,523,430,317,301,172,134,116,91 }, { 85,6,42,138,235,25,222,174,525,256,746,26,289,64,280,214,544,65,32,337,90,204,355,348,74,312,95,415,145,122,233,609,416,66,194,19,29,630,835,63,22,87,45,237,874,5,605,353,112,86,519,343,135,17,648,76,736,70,287,249,180,681,0,288,21,580,27,123,444,4,226,192,52,247,81,1,56,751,216,78,58,75,49,91,792,23,48,53,183,396,108,59,61,28,3,636,624,2,208,84,370,368,12,207,37,114,10,151,153,389,197,172,51,673,72,33,671,597,18,115,125,31,730,573,179,141,73,250 }, { 1,14,50,24,5,67,46,2,69,103,18,54,58,48,16,38,83,96,0,35,28,502,21,36,45,181,155,12,61,7,223,513,430,22,270,65,108,9,75,10,37,133,540,29,32,290,71,52,17,171,238,114,218,72,236,55,99,309,807,70,149,328,89,433,163,227,834,68,64,23,189,51,666,6,766,765,221,115,474,86,60,366,552,541,488,13,487,243,425,95,592,536,76,780,141,477,767,186,128,663,267,251,3,794,49,741,137,418,263,202,160,207,545,27,543,920,335,428,388,408,400,150,760,148,124,106,19,269 }, { 811,351,642,951,180,752,110,638,253,10,352,854,197,82,365,564,873,341,499,55,143,244,535,36,498,559,901,417,22,661,141,9,28,282,165,30,206,898,373,35,509,260,115,922,728,8,39,332,49,317,31,44,762,964,93,15,911,533,203,160,1,217,120,391,137,24,116,33,105,102,479,943,77,569,717,338,134,117,968,125,965,164,64,473,127,196,153,531,384,269,601,308,98,37,959,23,177,13,867,109,617,291,864,482,169,21,372,242,546,843,434,824,692,40,32,4,551,299,758,5,468,11,629,903,12,89,949,791 }, { 51,23,13,453,403,12,475,115,4,15,165,202,523,719,21,457,386,99,308,37,401,2,730,5,197,32,494,0,33,1,120,450,10,59,102,128,17,14,117,3,961,77,153,9,217,569,11,196,134,899,421,40,318,391,247,90,6,629,64,7,16,57,210,48,341,177,141,269,38,260,402,180,22,468,29,27,758,317,291,817,25,19,72,18,56,361,326,133,304,54,221,757,236,34,26,288,300,275,670,365,514,509,125,237,36,65,139,137,108,45,76,52,28,498,351,801,82,805,576,114,89,61,352,41,615,24,8,854 }, { 120,13,23,141,77,51,260,217,202,326,1,137,291,269,93,102,82,21,203,450,351,15,180,110,165,318,352,5,128,177,373,48,854,197,64,922,523,317,96,36,349,32,0,386,372,144,33,2,9,125,752,115,59,12,210,7,457,16,817,90,403,244,367,14,898,237,160,28,35,342,719,6,275,10,18,494,304,37,30,341,50,39,24,498,730,365,391,22,473,901,4,86,223,285,247,116,31,704,453,678,83,221,661,216,44,69,61,615,201,421,65,402,8,475,268,401,11,468,49,29,98,88,899,300,242,68,3,418 }, { 1,5,22,12,0,2,36,21,28,48,10,14,86,32,54,50,37,7,49,9,23,65,51,55,202,96,95,13,24,208,128,3,137,323,67,17,6,99,4,16,168,18,38,194,83,115,114,281,58,45,64,318,141,745,402,46,269,31,160,480,77,103,503,105,11,403,164,69,35,218,181,72,133,29,822,433,735,430,75,180,223,89,109,584,244,341,197,361,289,165,657,169,401,239,757,177,389,98,124,217,851,238,159,33,158,956,30,59,143,70,102,39,308,44,494,754,40,253,90,155,61,766,163,540,221,76,270,756 }, { 219,127,98,258,23,308,301,51,910,401,276,616,284,170,395,293,105,165,22,13,327,242,512,125,201,944,115,900,374,320,109,924,964,763,272,239,567,28,860,629,391,131,116,386,55,197,935,453,843,341,9,943,743,365,506,206,457,261,758,295,36,180,670,31,95,237,538,535,662,44,224,456,185,558,332,64,911,479,0,143,169,569,492,634,10,841,317,421,867,338,282,253,49,144,685,740,384,110,901,468,187,734,719,86,417,844,509,268,12,564,141,286,713,762,918,475,299,120,1,578,164,137,159,403,870,168,551,498 }, { 64,180,237,5,80,165,61,58,498,250,297,197,186,2,752,864,34,445,95,869,881,17,311,391,231,115,29,151,546,549,3,312,247,483,153,469,45,27,22,365,334,73,26,136,933,62,56,495,32,52,243,215,21,90,472,592,396,509,288,651,48,738,106,53,490,482,161,211,11,316,287,177,13,369,635,378,141,86,262,667,119,663,216,128,179,40,19,209,50,164,719,457,145,23,10,352,176,241,196,527,666,171,833,269,383,125,758,14,46,70,341,507,317,873,579,464,255,400,37,875,405,210,117,33,143,331,84,6 }, { 77,13,102,23,64,33,141,2,115,51,1,0,10,7,177,217,6,269,180,40,3,14,202,128,22,15,318,291,196,5,197,165,153,9,117,352,210,4,237,95,17,134,16,11,125,137,86,18,317,139,12,31,93,59,28,36,49,341,24,275,304,19,349,365,110,44,342,143,403,27,120,29,719,752,457,498,164,372,111,45,203,453,82,25,569,391,8,494,216,144,98,21,247,386,475,26,401,402,30,312,37,99,57,65,20,901,38,678,244,116,326,260,56,308,450,32,35,509,300,34,961,597,194,730,48,629,55,351 }, { 15,120,450,51,23,13,202,523,153,196,260,457,719,386,326,4,730,128,318,141,21,11,64,403,453,33,77,32,475,269,95,5,494,125,102,165,48,12,98,1,115,2,401,117,116,10,0,180,40,197,817,7,9,308,99,899,3,352,137,90,16,37,6,18,14,237,22,17,59,217,421,402,134,8,291,49,31,961,82,28,177,670,341,351,342,247,61,758,221,194,19,391,30,317,44,93,214,365,24,57,27,20,275,25,241,216,312,285,29,288,65,576,349,629,70,72,26,39,304,498,36,96,569,123,210,46,289,854 }, { 2,5,1,29,45,14,58,207,263,425,52,32,46,76,186,72,292,50,7,61,476,655,408,227,48,38,155,21,720,89,17,75,243,119,6,449,171,148,306,70,241,163,106,334,214,592,54,400,36,179,90,64,790,663,24,666,84,3,16,67,69,240,10,464,56,405,496,128,0,710,74,86,270,129,22,290,460,519,255,209,220,18,141,428,223,123,659,205,96,65,19,513,83,37,4,12,27,25,112,103,115,358,66,23,9,202,95,262,249,221,51,151,28,26,767,59,35,77,350,87,137,780,245,40,409,99,237,618 }, { 15,4,13,11,5,23,21,32,1,40,141,3,33,2,180,17,197,64,12,269,31,352,44,117,165,102,202,120,37,318,153,0,6,137,51,10,196,341,134,22,7,49,77,752,59,217,128,48,260,203,125,237,901,82,93,317,115,365,498,90,14,110,342,111,450,95,177,873,72,326,61,8,494,244,457,57,45,19,36,210,139,386,96,144,56,89,509,143,98,76,372,275,719,27,9,160,403,94,351,349,546,854,704,678,817,391,947,253,453,304,99,569,864,308,401,247,29,70,216,758,717,670,475,474,961,116,523,221 }, { 214,76,5,129,710,249,618,123,45,460,2,257,17,179,769,205,245,519,207,61,184,106,162,29,209,90,119,32,1,58,6,14,255,292,183,128,77,229,64,21,141,3,655,48,27,38,52,19,263,57,59,4,40,497,151,25,202,152,464,72,7,26,80,99,102,306,311,269,33,115,288,130,318,524,86,54,177,790,62,358,50,243,452,137,46,10,84,186,454,0,425,51,12,148,619,11,210,56,23,556,22,240,112,266,402,36,217,216,37,432,476,136,227,65,70,403,738,155,237,95,111,194,381,139,241,317,180,13 }, { 51,23,141,1,202,13,120,21,326,15,269,137,180,165,318,197,352,5,128,48,260,2,77,0,217,12,33,102,7,403,450,203,93,9,32,110,386,115,16,14,64,6,36,4,82,523,373,457,125,18,494,237,291,351,24,342,196,96,37,453,475,817,3,752,391,177,244,615,50,144,28,854,730,210,35,719,99,30,8,317,341,401,160,31,10,44,901,86,221,98,421,22,349,402,576,365,116,922,153,308,39,704,40,72,20,285,17,59,498,372,367,393,661,49,899,67,95,551,70,55,90,275,29,247,89,83,65,69 }, { 7,135,2,172,97,87,66,29,52,14,112,70,58,232,337,92,46,226,74,43,262,192,331,461,20,409,16,307,5,294,107,155,334,186,171,278,140,38,151,32,849,324,415,35,75,21,25,45,609,24,227,6,145,1,298,222,60,448,61,64,620,353,387,126,37,86,69,287,549,356,173,48,400,330,644,10,314,583,18,12,22,113,220,526,54,128,359,49,853,36,95,0,76,525,163,67,568,50,65,872,28,104,72,243,138,90,137,587,71,357,4,141,17,246,544,26,230,888,177,194,380,122,474,311,315,635,83,631 }, { 574,187,926,860,384,258,531,434,269,110,160,244,141,253,116,871,533,940,261,717,699,959,902,219,661,224,201,373,143,36,911,352,137,260,268,31,851,617,817,728,10,318,523,180,206,295,332,144,811,489,44,843,922,64,251,662,816,120,450,55,127,93,276,855,535,839,98,131,752,951,284,559,824,164,406,642,854,203,1,864,202,317,237,228,365,345,776,498,326,567,442,197,125,282,341,367,96,21,217,417,13,943,86,351,83,679,115,908,564,954,473,82,800,896,165,968,23,128,35,669,48,5,22,170,901,873,169,385 }, { 354,156,296,586,1,98,850,163,223,698,379,291,64,44,31,937,48,340,96,349,182,125,237,120,658,77,284,39,30,367,23,385,221,195,293,18,202,144,105,774,128,771,687,541,342,197,116,49,371,121,118,93,5,626,360,16,692,591,453,421,386,352,318,242,153,117,36,10,795,759,260,141,463,372,326,102,87,33,697,11,4,931,446,13,35,948,103,958,899,827,781,752,664,638,558,551,497,475,457,415,304,269,217,205,201,179,166,140,131,127,126,113,107,100,92,89,88,72,55,37,24,883,203,70,21,7,914,846 }, { 250,34,472,80,495,483,194,469,141,176,17,64,53,161,33,814,4,667,527,73,27,231,84,56,833,269,14,102,297,585,283,503,59,597,119,106,77,862,255,128,789,11,90,153,209,389,95,887,57,76,3,240,58,23,678,61,236,40,202,134,113,117,151,51,123,304,342,136,369,137,22,237,86,65,45,32,62,445,412,311,200,573,129,436,803,328,19,10,611,196,177,133,491,214,514,72,36,947,26,5,52,139,402,378,318,504,114,0,216,180,287,322,13,381,396,358,629,475,285,46,28,2,383,179,130,112,738,247 }, { 97,140,66,172,7,192,314,81,92,426,74,232,298,462,501,43,508,330,69,135,279,6,230,189,24,48,21,885,104,14,448,861,38,712,126,173,715,572,60,563,246,267,16,91,633,423,71,526,52,36,357,29,362,387,18,204,63,443,32,568,324,681,879,441,138,107,67,22,20,0,150,517,85,636,607,12,825,5,893,2,174,278,65,37,149,28,726,86,87,35,779,380,560,42,125,565,95,750,83,124,46,1,49,370,251,653,77,64,877,25,4,10,221,54,33,61,672,40,23,451,98,102,31,9,51,120,348,915 }, { 44,31,116,144,268,434,489,367,918,492,384,948,393,127,98,9,940,22,206,105,203,0,855,332,49,93,395,959,28,456,617,911,293,137,1,299,39,125,282,202,51,141,473,55,963,120,417,326,23,95,159,21,599,109,276,730,242,13,36,10,131,8,272,284,253,551,219,30,318,523,2,352,165,512,403,269,18,64,5,7,899,244,16,301,616,450,158,115,12,170,559,935,160,924,143,260,791,386,86,692,201,421,128,457,24,719,728,499,373,37,261,916,110,197,578,48,951,239,286,576,811,494,308,35,96,564,14,498 }, { 202,128,141,3,51,64,15,269,5,120,33,2,102,13,403,318,1,23,196,197,153,10,165,17,0,137,82,6,110,117,180,260,453,93,352,12,475,14,125,7,351,450,494,22,11,523,457,402,31,326,77,342,86,99,386,237,9,32,36,21,19,4,134,44,27,203,18,730,37,115,8,373,95,817,421,719,40,291,139,401,49,143,341,98,285,57,111,116,25,961,498,28,391,38,854,317,144,26,752,56,16,217,308,65,277,899,365,898,509,59,45,79,922,48,72,30,41,678,757,569,24,177,615,34,29,864,873,244 }, { 127,98,31,105,395,293,28,9,512,299,22,44,0,49,763,599,242,685,109,284,320,159,276,95,1,116,456,870,55,286,900,125,492,36,713,506,158,51,23,935,393,24,327,16,35,239,623,144,201,13,2,65,272,21,39,7,338,12,168,141,18,202,424,5,268,14,170,347,137,86,489,841,68,367,918,301,269,64,374,185,124,165,48,567,479,221,403,662,37,963,308,131,30,401,6,318,67,616,948,115,83,197,237,434,160,295,96,169,128,421,203,154,10,143,538,194,916,352,101,371,253,928,910,261,180,164,244,737 }, { 7,24,97,124,2,69,66,1,14,92,18,6,140,67,20,71,43,16,21,118,29,23,149,52,150,51,32,81,5,429,189,48,36,484,172,273,38,60,65,28,22,25,74,83,46,91,13,0,298,314,12,420,610,154,42,108,398,701,467,135,35,505,173,221,576,104,421,168,336,423,37,232,403,302,143,185,847,267,137,115,10,703,158,251,308,508,330,75,68,49,86,61,26,253,202,230,107,401,64,799,388,128,99,443,102,72,607,165,426,453,570,387,547,326,105,125,85,109,517,386,95,138,615,87,126,192,671,63 }, { 1,349,64,303,284,442,622,202,691,141,652,447,682,67,717,917,340,237,154,352,269,919,752,547,429,411,197,293,260,44,335,180,160,863,238,201,191,167,318,9,751,730,98,453,33,418,956,475,360,69,77,765,217,140,96,31,153,120,87,724,664,389,323,268,206,116,922,888,102,948,854,842,805,196,127,399,586,658,873,851,850,796,781,695,657,385,330,244,149,137,0,662,367,351,82,947,774,551,498,363,225,146,125,35,212,909,899,848,807,776,772,770,759,726,604,576,541,523,480,450,403,393,372,332,329,327,301,296 }, { 1,2,141,15,7,10,180,3,5,6,64,0,13,197,77,269,33,11,352,165,9,102,14,4,349,12,291,341,23,237,134,752,22,120,117,202,498,128,36,217,318,115,51,17,317,40,153,93,365,110,342,961,82,31,864,901,125,137,59,143,196,372,16,86,21,260,111,44,873,32,49,947,457,95,57,244,326,8,351,37,28,569,954,203,19,373,678,18,139,450,29,30,48,386,72,27,79,45,854,391,144,509,55,546,94,99,164,98,116,20,76,83,253,56,898,922,38,25,24,39,61,177,210,719,58,523,494,402 }, { 139,99,12,453,196,277,775,475,40,401,215,33,51,111,130,23,11,77,313,211,14,38,266,129,474,477,37,328,339,369,153,719,162,152,54,231,3,308,57,700,117,403,305,188,629,102,880,457,569,183,62,514,229,961,157,556,555,115,176,41,177,471,248,13,507,670,342,4,542,257,17,123,291,236,72,79,304,134,452,89,34,184,90,2,59,76,383,488,94,421,80,32,361,128,440,377,202,119,56,316,21,494,46,165,757,288,45,543,197,528,730,585,249,431,136,5,0,432,52,210,402,120,485,29,1,529,548,536 }, { 77,102,33,141,128,202,23,64,51,59,269,153,4,40,115,177,13,196,318,117,291,210,0,137,134,403,22,90,217,342,10,95,180,494,18,49,11,1,475,65,32,6,16,352,216,36,15,139,86,7,194,24,402,275,14,28,9,2,21,19,125,453,165,20,25,120,57,237,3,260,26,341,317,114,349,197,326,214,48,31,12,5,82,17,300,111,421,308,365,523,450,98,110,93,247,304,351,457,285,498,39,27,312,123,44,152,99,401,37,615,373,108,372,170,143,116,68,67,56,96,719,678,361,29,961,205,35,133 }, { 7,14,2,58,46,16,70,112,87,38,52,135,5,155,29,66,97,294,172,32,20,334,24,92,186,35,128,227,18,171,6,21,107,37,64,75,780,666,400,61,140,43,60,48,220,232,0,23,141,177,1,54,202,307,13,592,461,115,22,77,12,45,50,51,126,163,137,409,10,315,192,270,25,845,69,90,269,76,72,513,28,113,74,210,49,262,243,9,95,89,71,318,402,631,86,884,298,40,431,102,4,275,290,278,17,324,217,19,180,151,36,237,230,67,356,291,352,314,65,403,59,33,26,609,387,226,285,330 }, { 15,13,1,5,2,23,3,0,365,10,7,4,341,51,11,6,9,115,180,317,14,33,77,12,217,102,40,197,21,153,165,17,64,8,117,141,569,22,901,134,32,16,202,352,37,36,457,291,128,31,269,125,237,18,139,196,44,453,391,177,372,28,349,59,719,93,482,629,86,509,961,318,873,498,99,55,752,386,19,401,210,143,48,137,120,342,50,38,49,29,27,403,24,30,758,111,110,57,475,95,203,730,46,98,260,116,90,45,523,494,326,54,105,72,96,65,546,402,351,242,277,164,67,450,734,253,83,26 }, { 2,1,75,29,52,14,69,220,67,262,46,38,70,87,103,6,74,24,83,267,25,226,357,366,394,96,26,189,451,112,606,486,135,145,388,324,294,108,335,278,50,66,42,238,163,58,16,331,150,71,19,149,545,222,35,236,18,418,696,133,114,7,218,582,5,36,45,433,516,537,60,380,171,138,641,600,65,550,251,151,21,54,309,603,853,223,181,12,27,287,28,0,739,565,22,17,785,48,86,68,140,461,594,37,97,10,32,423,458,95,160,733,337,583,61,122,307,281,336,64,571,186,273,85,55,774,632,172 }, { 9,105,18,101,39,557,16,890,1,252,272,100,265,938,21,326,23,51,301,49,0,68,24,60,264,13,35,310,254,159,737,363,167,593,137,127,121,166,98,846,118,827,156,48,202,30,333,31,55,5,411,395,128,329,132,146,578,44,520,512,242,77,731,682,170,320,371,120,71,916,518,450,373,28,821,286,33,447,327,212,354,271,32,195,639,125,7,364,95,704,102,65,616,385,615,36,688,203,64,12,110,523,455,96,141,197,75,910,4,116,836,506,88,165,93,604,404,22,318,931,2,10,260,86,338,817,40,905 }, { 80,209,667,61,45,17,106,483,255,6,833,151,454,29,5,738,378,2,887,742,112,311,27,119,26,469,495,113,491,161,58,145,396,19,25,84,73,70,315,207,814,76,56,136,42,64,32,1,243,62,52,306,614,287,128,445,14,74,383,53,631,3,90,240,34,141,179,86,297,4,72,148,496,65,250,611,214,138,527,46,194,123,137,186,21,655,95,66,549,50,881,292,592,790,48,87,7,11,129,263,205,122,22,440,361,59,222,573,307,38,202,227,75,269,57,85,10,358,245,644,684,54,200,862,651,425,36,171 }, { 23,13,51,5,21,115,12,202,15,1,141,32,2,165,0,269,180,197,401,7,4,3,9,457,308,403,453,6,341,37,318,10,719,14,48,120,128,352,33,77,22,137,11,730,217,523,40,386,99,16,260,31,475,569,18,64,450,317,28,237,391,90,17,494,421,365,177,59,125,8,102,72,93,30,629,247,961,24,221,117,44,153,498,758,351,291,196,509,899,402,817,49,304,134,76,89,210,98,326,82,482,45,57,110,38,36,752,901,39,139,468,20,96,372,116,216,19,349,203,288,29,61,95,275,546,670,27,576 }, { 99,12,453,277,139,474,369,339,51,38,157,196,37,775,401,188,23,475,111,328,11,313,471,153,40,629,266,79,54,4,477,33,102,59,14,57,248,880,152,342,13,457,305,542,117,377,403,514,94,308,115,229,569,488,961,210,300,211,431,41,89,734,361,485,275,670,134,128,184,381,3,72,529,2,556,719,402,64,413,21,15,215,46,177,757,165,77,197,236,32,62,421,155,50,130,17,162,202,5,45,587,52,507,10,183,555,82,247,490,129,588,123,405,148,216,76,141,7,0,1,181,29,432,6,730,90,468,452 }, { 7,92,232,126,97,298,387,140,107,16,60,246,14,66,35,462,150,441,104,357,314,359,279,330,633,423,380,172,230,199,24,121,38,392,356,71,132,192,451,324,22,146,893,508,493,568,289,65,560,95,0,5,32,74,189,830,2,135,21,173,18,603,64,46,43,707,20,501,52,362,90,214,712,550,877,86,607,28,426,312,48,36,29,10,69,278,12,194,49,37,1,6,672,874,204,81,267,68,526,108,835,259,733,895,388,500,779,649,448,915,61,125,149,443,50,55,54,399,590,70,72,939,572,191,124,711,517,167 }, { 13,23,318,202,77,177,51,269,33,102,141,115,494,4,90,403,210,153,40,196,117,32,59,128,11,137,342,134,217,291,64,21,12,475,352,31,341,14,2,98,93,10,7,95,700,49,317,275,216,20,19,16,44,22,365,116,6,453,110,247,144,180,96,9,24,17,5,82,0,498,402,349,300,127,48,3,125,57,111,87,28,86,1,203,197,35,25,401,18,165,351,326,139,60,43,26,36,450,873,864,551,473,393,373,372,288,678,576,285,37,523,120,70,65,817,67,752,697,529,421,415,386,304,214,164,152,123,61 }, { 13,77,2,23,141,6,0,1,217,115,7,3,180,5,10,51,33,14,197,269,352,64,102,177,9,291,15,4,317,40,17,165,22,11,341,202,318,237,196,117,153,349,16,365,28,210,372,752,134,19,18,128,304,498,36,247,12,125,59,139,95,8,275,457,86,31,27,49,21,24,29,391,342,569,509,25,93,45,143,901,137,32,244,403,26,57,38,719,111,873,386,120,44,864,20,37,546,56,494,39,961,164,758,401,30,453,110,475,35,730,98,65,216,437,34,203,41,326,99,402,300,253,82,90,55,46,194,351 }, { 15,4,110,13,120,93,11,23,5,21,32,1,40,180,10,82,165,2,3,33,197,141,51,37,0,48,901,102,12,31,6,7,125,117,352,77,752,341,144,153,351,196,9,237,64,134,498,143,17,269,457,342,59,202,115,98,365,450,318,22,44,401,291,873,8,244,217,475,57,391,253,14,72,349,854,372,55,36,509,89,898,403,90,719,19,386,697,139,111,546,661,27,260,61,56,177,96,569,482,961,16,638,332,758,494,28,864,148,76,45,241,79,350,308,247,437,421,70,474,559,221,210,41,164,160,137,453,275 }, { 15,1,13,2,0,23,4,5,3,7,6,51,77,9,341,10,115,291,11,33,217,8,12,102,177,365,317,14,165,16,22,120,349,40,180,197,31,457,901,453,18,21,450,153,961,141,719,260,523,32,44,82,64,117,304,28,93,372,110,17,210,475,59,30,134,352,386,342,569,401,752,275,196,730,90,403,326,202,36,49,629,125,817,216,98,308,247,269,351,24,203,494,899,37,95,111,139,482,758,373,391,19,48,116,237,922,509,57,144,86,137,498,854,421,128,670,873,898,253,437,65,300,55,99,20,704,244,615 }, { 20,43,198,325,904,104,173,147,234,422,66,97,426,319,861,77,376,712,416,725,427,945,0,7,5,470,450,192,142,32,707,178,330,819,639,38,202,22,500,21,784,583,414,2,324,230,858,61,889,49,315,113,671,81,455,18,392,74,207,232,52,24,329,107,342,33,560,13,140,595,10,715,291,120,102,95,48,1,64,359,693,600,879,16,798,58,312,494,4,14,344,835,764,306,105,526,290,40,23,289,259,90,159,158,884,577,246,37,9,170,204,681,138,29,239,194,112,12,17,31,318,72,28,226,70,397,153,65 }, { 105,28,0,9,49,301,159,127,512,16,170,623,24,109,35,395,158,98,68,1,65,22,55,31,761,371,713,916,18,293,286,7,242,124,347,95,338,737,327,44,39,21,2,14,272,424,154,36,506,685,23,168,101,125,299,51,12,479,48,13,870,763,374,284,64,385,320,599,5,67,202,71,276,116,131,141,185,137,836,456,175,344,239,37,900,187,30,10,577,538,6,616,289,740,60,518,118,86,169,83,364,912,219,96,50,115,928,128,935,165,318,149,747,221,346,32,114,69,810,254,237,627,269,308,144,393,201,492 }, { 213,466,689,88,230,435,321,30,699,795,201,831,352,144,217,443,854,530,840,190,539,957,418,1,96,203,382,855,251,100,669,410,335,93,83,748,367,44,662,960,31,934,36,206,141,752,351,317,822,128,731,116,778,120,284,274,131,98,228,927,332,187,69,438,521,800,21,242,160,224,48,372,219,310,137,735,686,557,326,285,237,576,127,922,5,859,269,260,13,494,264,82,523,403,35,244,202,615,166,39,616,551,345,930,180,67,253,921,299,966,2,10,9,258,23,473,365,692,265,197,866,32,276,51,816,617,856,223 }, { 130,453,196,47,57,4,236,14,59,412,51,711,381,730,153,77,202,108,128,361,23,46,283,402,210,11,300,719,13,117,38,803,200,401,183,78,34,475,54,342,318,27,369,432,275,2,757,133,503,472,12,3,585,134,62,862,161,529,37,328,457,56,390,494,102,73,176,50,440,322,111,670,65,52,377,899,181,629,17,114,33,136,99,266,123,40,514,339,291,53,250,84,177,21,188,216,389,217,386,139,32,961,155,480,162,754,832,714,894,739,383,657,269,152,106,603,543,527,523,497,277,485,838,137,86,64,48,758 }, { 1,2,14,50,5,38,46,36,22,67,103,0,114,65,29,12,28,218,54,7,133,83,86,96,69,21,75,208,24,6,52,168,194,389,10,128,51,160,55,17,23,48,18,181,238,45,37,32,95,16,283,532,58,137,503,202,49,124,171,361,480,13,735,9,289,109,782,285,3,115,70,756,141,169,484,584,35,244,717,64,402,4,328,220,163,646,158,803,505,19,253,789,164,185,108,25,155,487,236,269,143,946,394,318,610,401,335,105,433,403,851,87,800,223,866,309,420,61,27,180,597,99,366,308,59,754,514,418 }, { 6,74,26,19,165,453,391,197,14,138,730,29,357,70,51,457,1,50,108,125,500,509,27,145,386,112,366,52,46,235,133,262,13,308,47,331,2,719,78,42,309,75,603,25,223,394,785,23,600,218,38,163,115,114,17,558,34,53,220,128,487,58,236,122,65,130,766,401,498,96,409,307,45,85,66,444,899,73,516,632,64,711,54,630,412,196,5,103,21,180,894,113,221,137,624,241,237,594,773,758,867,629,433,390,475,820,546,12,648,67,32,153,285,606,99,545,745,569,644,324,583,3,181,675,903,283,802,670 }, { 10,9,30,376,0,68,55,39,18,43,20,49,174,104,88,501,120,342,450,858,28,2,137,523,470,453,197,757,603,37,414,165,31,325,730,729,671,595,455,222,204,77,64,58,22,21,17,13,5,194,110,95,389,318,260,177,128,102,97,33,1,904,725,7,788,568,387,90,54,46,32,14,11,259,98,147,61,817,392,518,961,958,922,899,873,854,819,805,785,739,719,713,661,615,550,534,528,494,477,475,474,465,457,449,386,372,355,351,349,337,298,294,291,289,269,262,247,196,173,171,155,135,122,105,94,56,48,36 }, { 15,23,13,1,202,0,51,77,5,9,341,141,137,120,4,260,115,2,351,21,128,7,12,450,82,901,197,180,269,318,10,8,11,22,403,32,854,33,165,40,6,18,3,16,37,494,523,457,102,177,28,64,352,453,14,317,922,217,36,365,48,421,401,719,475,291,30,110,59,24,569,817,93,961,308,730,17,752,125,117,898,31,342,153,196,285,44,99,576,86,275,642,49,90,402,39,143,139,98,221,386,244,116,373,55,57,629,144,210,661,349,134,203,859,899,95,498,35,482,372,72,237,253,105,216,96,111,758 }, { 272,131,105,578,219,159,371,49,616,716,9,224,320,286,737,623,187,910,385,28,258,98,761,127,254,347,916,424,22,109,627,158,713,95,924,239,0,242,836,39,201,31,301,912,944,442,125,170,116,327,293,44,538,688,374,23,55,168,276,36,64,284,51,871,185,395,35,506,221,512,518,202,890,137,101,13,860,169,68,574,479,86,908,10,24,333,16,1,65,144,269,364,308,228,344,141,21,338,567,30,577,165,128,160,747,18,763,124,839,926,299,261,456,268,295,164,662,406,197,67,312,175,7,928,421,685,154,810 }, { 457,51,13,23,961,719,12,453,629,99,401,57,515,3,4,165,11,45,62,41,14,17,2,569,37,77,33,32,5,0,40,59,1,308,76,115,197,38,72,79,730,21,474,102,7,475,6,54,9,64,403,10,56,775,237,477,202,29,152,188,341,328,90,509,111,89,215,128,880,734,339,247,757,134,386,84,421,317,313,217,129,94,22,318,157,34,130,117,361,210,670,555,369,365,285,269,266,186,181,153,123,24,899,485,120,542,25,391,758,514,468,277,270,243,227,196,180,179,155,148,137,52,50,49,46,18,471,236 }, { 202,318,5,120,450,494,77,33,102,260,21,1,128,13,165,403,523,23,269,342,12,326,817,32,475,141,402,64,2,17,82,457,180,137,48,730,125,291,197,453,37,93,51,615,922,719,386,210,15,177,854,351,98,7,899,576,275,6,44,25,961,4,196,117,115,285,95,14,217,31,391,352,237,65,38,29,27,20,758,40,10,9,153,194,367,116,110,105,50,49,35,16,139,498,341,61,163,39,30,11,349,293,216,144,108,99,76,58,54,43,0,203,3,134,113,70,959,958,940,933,923,900,855,841,750,725,704,639 }, { 141,269,352,180,217,202,349,64,160,137,317,318,372,494,752,418,244,954,864,437,753,237,13,341,291,165,717,22,197,115,304,260,365,93,36,21,351,247,120,922,77,82,48,498,32,5,579,144,10,23,342,373,33,854,95,128,0,391,164,143,125,98,482,51,403,28,326,898,386,76,72,1,951,678,638,453,201,86,110,30,457,312,253,221,163,96,44,475,102,901,719,421,196,134,190,166,131,100,88,474,401,203,859,597,521,509,466,459,435,393,321,284,228,108,65,59,40,4,851,576,350,308,288,241,216,214,179,99 }, { 70,145,29,112,74,26,2,75,287,52,220,226,632,87,294,6,135,307,163,66,19,396,278,138,635,409,25,151,58,113,1,122,331,222,5,97,42,644,324,461,27,849,500,69,651,45,7,172,262,853,337,53,648,573,624,64,334,445,171,21,67,186,32,73,297,46,38,416,14,17,140,80,61,50,436,155,884,223,24,22,85,48,380,852,92,65,86,889,12,315,36,774,571,103,549,37,10,95,243,491,83,16,72,665,227,89,357,394,76,309,35,106,54,675,808,267,474,250,609,71,881,209,133,606,96,232,583,400 }, { 351,82,317,141,752,898,901,180,352,341,15,365,1,498,217,115,33,253,32,143,10,160,55,0,854,5,197,269,21,77,4,36,137,23,64,2,110,482,169,873,120,244,96,7,89,13,349,86,164,102,72,93,372,148,922,40,16,345,90,531,9,83,437,22,251,35,260,457,546,165,202,6,864,48,291,51,28,719,59,238,18,308,247,128,11,304,117,12,569,237,65,961,817,509,450,535,196,95,125,730,523,468,144,98,49,3,899,661,342,318,373,153,579,734,14,490,116,203,134,559,391,312,130,123,109,84,76,326 }, { 39,9,310,254,101,252,265,272,100,0,557,30,49,688,455,105,190,166,329,627,159,286,625,709,327,333,18,68,158,404,520,578,131,438,731,16,553,24,98,364,31,676,35,118,593,1,518,48,344,44,167,23,65,21,93,604,829,795,127,60,890,96,88,616,22,363,656,51,242,28,419,716,125,124,846,71,274,36,264,613,13,137,95,116,212,938,109,224,827,411,154,910,160,639,371,664,128,5,374,144,530,395,228,170,219,865,67,10,203,759,121,83,301,382,320,737,55,682,37,647,86,271,793,7,821,115,916,285 }, { 2,58,29,151,52,186,70,5,549,75,1,112,45,400,61,163,113,227,307,315,311,287,220,46,7,14,155,74,243,87,409,66,27,80,209,631,845,780,69,262,135,48,50,171,767,496,869,454,331,6,491,17,334,278,106,32,19,64,614,21,73,145,26,294,24,592,67,25,38,659,223,16,97,255,172,72,226,502,852,128,37,140,721,666,89,667,290,36,103,324,86,849,267,76,141,54,35,83,65,207,22,148,96,270,12,635,10,4,95,92,738,474,18,445,119,611,425,137,431,263,114,396,663,0,122,133,90,237 }, { 141,217,269,352,317,180,23,13,21,115,77,349,202,137,51,64,372,165,197,32,365,752,318,291,341,5,237,102,15,177,498,33,48,244,304,128,125,4,864,253,39,30,44,11,247,22,9,0,31,901,308,403,1,717,201,342,49,10,98,16,7,221,95,144,40,88,494,90,12,28,117,93,678,120,68,326,100,203,86,96,468,2,475,206,116,546,457,160,437,8,873,210,127,110,76,65,55,37,418,386,350,72,18,453,223,143,24,153,851,351,260,284,579,576,401,268,482,196,35,421,82,3,402,166,101,954,391,83 }, { 68,35,101,149,124,154,0,65,9,175,24,398,28,16,189,71,118,429,55,346,67,114,7,345,18,230,399,364,133,14,252,722,39,283,1,547,140,69,108,484,302,694,100,439,103,46,705,83,166,267,389,2,458,92,336,50,212,289,21,246,375,251,419,109,36,520,329,158,22,637,12,60,952,48,265,236,702,596,96,806,30,732,5,826,604,64,194,49,412,701,388,88,420,191,535,264,562,167,886,23,796,168,51,650,238,570,782,868,86,13,218,95,917,768,38,10,32,309,404,706,37,54,221,602,125,159,105,676 }, { 66,7,29,112,52,97,2,192,20,151,74,43,145,173,222,135,226,525,415,172,644,104,337,544,353,580,32,45,25,287,186,609,58,70,204,155,14,5,21,712,122,87,227,174,331,61,849,549,426,90,355,81,334,560,6,232,416,243,632,46,0,92,324,177,64,113,673,624,107,59,37,635,216,140,396,138,22,500,16,38,4,707,128,65,48,307,17,77,86,137,91,35,12,721,665,789,141,24,294,884,85,42,414,194,115,526,72,311,825,11,126,262,597,76,89,10,28,75,1,387,209,60,304,171,51,147,651,40 }, { 31,125,44,299,116,22,170,55,242,456,599,685,36,870,64,393,492,268,1,479,164,86,558,28,506,144,10,740,23,206,903,9,2,0,963,237,127,546,301,13,434,143,367,5,169,93,51,239,12,654,965,384,137,498,7,923,203,918,489,98,180,95,391,141,762,115,352,417,638,841,253,6,105,14,951,8,940,165,197,844,128,948,457,401,959,244,160,308,282,185,21,312,109,286,202,332,341,49,168,386,752,269,538,365,4,37,24,512,911,473,873,509,551,634,499,318,719,3,208,395,708,217,450,421,96,901,35,16 }, { 188,11,79,12,99,377,542,94,339,33,474,37,40,139,111,102,453,4,51,775,475,277,13,471,23,196,629,153,431,401,117,210,134,266,152,403,115,38,961,128,59,300,57,77,880,342,157,485,313,569,3,229,202,14,177,275,477,54,308,184,488,328,21,89,72,670,32,64,2,76,10,402,15,90,165,369,148,141,5,162,318,405,17,269,257,205,216,413,757,129,62,361,0,494,734,41,421,179,45,452,197,217,291,120,82,22,130,386,123,1,50,237,358,125,381,497,498,6,137,285,36,180,48,482,372,29,46,341 }, { 658,698,340,303,31,363,919,98,44,156,296,850,586,668,354,87,914,120,163,30,127,70,23,385,51,48,1,478,125,49,77,774,223,260,291,82,691,349,13,854,225,217,116,39,10,724,21,922,898,447,351,293,201,75,9,269,284,759,541,480,281,268,221,165,621,141,442,622,411,371,318,187,153,115,105,102,65,777,93,64,33,652,352,202,744,453,433,398,330,191,180,177,137,128,117,95,69,35,931,638,40,5,888,372,146,140,100,88,565,457,450,335,326,317,219,190,159,158,134,36,32,22,518,482,401,394,276,947 }, { 15,82,4,197,13,33,1,23,901,21,5,11,10,165,32,0,120,180,2,40,3,51,110,77,642,7,8,351,326,115,6,386,365,217,457,9,117,401,12,37,102,260,523,134,719,758,569,22,36,59,317,730,31,57,342,898,961,450,453,153,17,141,291,137,475,55,177,48,116,90,196,93,44,403,14,64,352,629,54,372,817,28,143,18,269,139,16,958,96,202,494,349,421,275,752,210,128,49,94,86,244,29,498,899,801,318,851,38,670,72,615,474,304,148,41,89,25,19,308,482,160,373,253,70,61,30,277,125 }, { 15,4,11,13,23,5,21,180,141,32,202,269,3,40,1,352,318,17,12,64,33,165,197,31,2,0,51,120,128,117,326,59,457,10,153,196,134,817,6,48,125,93,237,82,44,137,450,77,494,403,49,203,386,752,37,523,7,22,961,217,260,8,115,110,341,57,177,498,719,90,615,9,317,102,365,139,14,730,901,210,98,402,72,453,19,116,65,18,111,391,45,56,95,351,27,899,99,349,293,291,300,475,86,28,36,401,25,55,144,244,275,509,247,216,38,678,76,61,393,29,372,576,485,373,30,253,551,468 }, { 91,233,370,718,85,6,81,25,65,256,63,235,42,138,511,397,123,26,343,74,650,87,249,643,355,544,18,64,194,510,636,45,174,280,90,22,108,348,681,104,1,84,86,114,389,4,415,66,19,0,673,283,214,141,122,524,289,56,53,193,208,95,240,750,297,29,119,605,27,573,445,436,736,10,14,11,287,597,32,630,49,24,192,57,5,17,204,475,103,61,102,70,947,152,51,588,23,16,183,77,619,730,523,453,444,59,561,2,813,701,874,323,75,33,28,804,129,96,403,368,21,9,145,177,396,255,693,611 }, { 23,51,202,13,21,128,318,141,403,120,450,137,48,494,269,5,1,165,125,64,32,260,15,523,102,475,115,12,14,457,31,33,197,77,817,44,98,453,2,308,95,49,99,16,7,180,18,93,326,37,221,6,4,352,421,401,116,291,61,386,203,82,59,36,9,40,30,24,719,117,110,20,217,153,730,17,615,351,402,237,50,854,10,196,39,19,342,3,922,25,96,341,35,28,22,11,105,177,90,72,58,38,317,247,54,961,805,576,207,68,57,46,349,210,134,86,704,75,70,899,373,65,901,670,0,391,89,45 }, { 365,180,317,752,341,217,115,352,901,482,372,498,291,15,253,244,141,13,1,579,269,349,7,5,21,4,318,23,351,82,0,2,51,77,93,125,10,898,89,160,202,44,6,854,165,3,96,308,221,148,137,332,247,197,33,11,304,851,531,144,120,494,40,717,468,251,403,72,177,391,32,12,546,453,421,260,203,437,961,574,258,533,48,509,55,922,880,661,615,373,261,134,241,873,475,345,949,867,734,728,699,569,490,473,434,295,288,237,219,143,127,110,27,17,16,187,153,117,876,350,99,36,9,947,128,86,64,679 }, { 115,498,901,197,341,468,13,352,482,546,165,509,237,569,9,873,64,23,365,22,180,95,391,317,758,558,49,752,734,109,28,105,217,51,844,86,837,143,629,131,254,876,12,159,158,719,39,406,308,148,141,679,117,490,83,637,457,10,708,166,36,706,102,89,35,505,168,442,372,125,55,530,221,37,208,669,535,332,272,153,103,98,903,401,261,219,768,114,33,864,364,187,169,345,4,574,434,258,242,224,67,30,3,253,961,868,164,228,816,77,843,120,438,384,351,230,134,128,100,99,2,753,50,44,31,584,347,170 }, { 23,13,51,202,141,21,180,165,5,197,125,1,115,269,32,120,12,128,318,64,15,137,523,2,33,386,7,260,14,403,48,457,102,4,450,6,93,99,82,401,719,9,730,110,16,31,237,77,326,308,421,98,453,352,37,221,475,90,44,117,30,0,18,144,899,153,10,817,3,203,391,196,11,59,351,40,217,494,177,17,341,134,116,39,8,24,95,752,498,402,20,509,615,61,28,96,19,247,961,291,36,72,365,86,317,285,241,76,49,373,38,29,25,342,70,304,58,57,242,546,576,22,350,349,901,629,801,551 }, { 214,289,90,174,874,280,355,138,65,85,64,6,751,81,312,194,249,835,233,348,636,875,91,343,288,519,32,0,524,247,415,104,29,370,681,750,74,204,22,95,217,437,235,86,123,25,352,192,42,597,954,256,77,18,673,63,864,752,671,306,87,353,746,287,712,237,397,389,115,588,222,177,180,145,580,715,21,141,59,474,317,207,66,56,49,52,33,28,579,45,544,10,84,61,784,102,4,511,202,693,57,40,24,117,173,76,319,240,208,5,216,26,304,134,291,205,114,525,72,17,153,577,168,11,108,422,718,498 }, { 15,4,11,5,13,23,21,32,33,1,37,31,2,141,3,180,64,102,44,12,49,196,120,77,40,6,17,7,153,117,352,134,0,82,269,197,51,22,93,10,752,260,165,217,98,317,137,365,342,202,901,318,95,341,450,115,48,30,9,128,177,351,125,523,110,498,854,291,237,89,90,8,817,45,59,14,57,86,457,873,326,373,372,72,61,922,139,56,275,482,36,864,391,96,898,386,111,403,144,27,38,509,899,453,70,116,29,58,253,244,76,160,475,437,304,316,210,16,41,569,308,300,203,719,288,221,546,148 }, { 217,33,15,13,117,196,153,134,23,51,77,141,0,2,64,115,102,10,4,5,7,6,180,3,1,11,165,352,202,22,9,40,317,269,197,14,128,318,341,237,17,177,16,291,12,95,365,120,125,18,752,28,453,372,59,137,498,349,49,36,31,24,403,32,110,98,210,386,19,457,401,8,391,901,475,44,86,260,342,304,143,247,308,730,93,275,244,494,164,719,21,864,65,509,57,961,523,25,90,105,546,139,216,55,38,482,569,402,35,29,450,99,873,421,48,670,45,27,26,326,20,37,437,39,629,579,56,203 }, { 15,33,77,4,102,117,40,115,134,11,153,13,217,21,1,5,317,196,32,23,3,2,59,12,291,341,365,51,139,120,177,180,372,349,48,141,260,17,342,110,6,197,37,7,72,482,90,165,111,57,352,93,898,752,0,326,457,210,82,854,901,450,269,202,14,36,64,125,523,373,10,137,89,922,203,719,498,730,961,569,244,817,143,44,318,8,76,304,277,403,253,275,31,494,128,386,308,160,22,247,56,899,148,144,453,468,61,638,579,300,96,437,221,116,873,38,485,94,99,237,216,9,27,49,45,19,86,401 }, { 15,13,217,2,1,23,0,4,5,3,317,51,341,7,6,8,115,9,365,202,10,11,291,12,22,33,269,31,82,180,308,457,120,28,901,30,18,77,197,450,351,21,961,40,221,372,523,165,730,318,719,854,141,102,64,453,110,260,14,569,93,117,44,16,817,36,32,349,386,498,482,98,403,898,196,134,35,153,24,49,125,752,579,326,899,237,128,137,247,401,342,48,475,177,39,304,661,20,922,509,494,19,116,59,37,203,468,95,329,144,758,55,17,65,244,86,111,391,90,118,437,113,91,122,143,629,864,99 }, { 135,66,2,7,192,337,97,52,14,20,673,355,29,43,104,107,331,226,415,376,353,222,294,147,74,112,46,172,560,155,32,5,324,470,609,173,174,21,825,16,64,58,298,145,92,707,38,232,77,35,356,4,10,414,22,525,287,262,171,888,86,632,544,595,635,568,178,90,48,580,87,334,202,597,72,37,60,587,474,6,151,95,307,49,177,59,25,0,142,17,858,61,409,128,1,12,721,583,318,259,362,500,141,126,269,198,102,319,70,494,13,230,853,45,227,54,849,612,400,65,204,186,33,819,246,76,644,279 }, { 195,132,146,142,271,167,121,363,878,178,687,647,786,212,354,77,522,929,60,202,411,120,35,234,147,259,101,360,520,626,446,781,98,0,450,668,5,199,55,771,562,23,16,706,777,49,936,18,621,604,48,158,318,639,13,31,407,22,125,21,591,590,465,481,159,534,51,109,198,419,24,126,364,191,141,7,682,551,252,28,20,806,634,156,105,14,447,948,494,107,10,116,39,43,1,269,260,33,265,128,640,291,93,403,137,326,95,203,421,379,102,765,9,82,692,110,416,32,883,664,553,455,694,475,842,523,293,239 }, { 202,77,20,318,104,66,269,291,494,102,177,43,128,0,342,216,173,5,2,97,52,450,234,22,7,33,750,29,112,319,74,275,90,337,32,49,198,210,678,544,147,204,58,24,141,789,21,349,64,18,304,16,10,14,580,120,192,194,325,13,416,142,403,500,196,61,59,137,115,86,712,153,113,12,226,174,415,40,23,81,4,28,70,525,402,1,9,230,72,35,178,214,636,46,11,6,904,37,95,87,48,217,355,597,334,31,798,39,17,38,427,186,222,65,376,117,426,285,36,135,51,208,353,673,155,792,172,260 }, { 107,362,612,359,414,356,97,392,683,259,819,43,298,660,465,147,581,729,173,779,7,595,501,20,319,470,534,858,246,376,279,126,230,14,5,178,427,232,493,35,92,49,132,426,885,60,32,104,387,0,786,423,66,38,21,121,878,22,16,146,861,441,95,357,560,830,142,2,199,61,172,10,81,707,150,70,590,422,207,48,140,46,58,929,52,324,603,192,18,508,202,314,77,37,347,33,263,13,135,28,241,12,23,29,125,1,345,124,102,98,74,64,568,24,198,380,40,4,687,626,105,607,117,72,177,577,65,318 }, { 6,19,13,26,453,165,457,386,51,23,14,74,401,391,308,758,719,603,47,867,29,138,2,70,730,27,366,309,108,324,197,1,25,196,743,711,78,235,262,130,42,475,133,50,115,145,670,487,112,58,53,52,85,17,421,894,96,34,412,5,331,516,509,163,33,500,569,629,482,388,45,468,153,218,128,64,341,283,594,545,444,65,125,600,217,114,236,754,75,899,73,785,630,137,95,38,801,328,895,103,961,550,901,200,11,350,558,117,4,220,180,54,46,745,3,134,433,766,287,739,122,223,317,226,390,241,21,357 }, { 179,205,72,245,317,247,152,180,216,490,76,752,352,79,217,59,864,94,498,4,497,452,89,148,11,875,111,141,405,115,188,21,468,588,873,197,579,471,365,464,37,645,372,482,5,77,64,431,341,237,10,529,349,1,12,23,2,474,128,134,316,339,291,36,32,51,38,413,437,629,954,734,308,99,13,143,48,102,165,14,288,90,377,749,184,401,460,542,33,428,3,7,269,449,961,569,901,350,86,40,257,244,202,0,270,117,6,304,54,241,402,45,137,221,457,403,177,9,164,139,318,17,528,15,453,421,358,769 }, { 107,359,7,314,392,298,387,279,581,32,232,60,14,126,97,493,534,150,356,121,423,362,172,92,259,147,441,95,35,501,22,357,21,16,246,590,0,380,786,49,18,465,13,64,132,5,28,146,178,10,508,779,23,140,48,24,71,939,929,660,51,135,607,324,603,115,230,43,46,241,38,192,683,462,247,66,612,568,941,835,819,77,12,550,90,36,560,199,4,312,33,9,893,347,330,65,59,52,20,519,2,278,50,626,58,202,37,345,771,294,117,40,102,70,470,451,156,448,350,316,707,236,173,288,31,75,54,672 }, { 156,354,586,271,195,591,668,132,48,360,340,121,23,21,463,446,1,5,13,18,658,296,407,51,146,70,698,883,626,55,60,221,777,163,32,363,379,621,590,562,58,49,167,467,647,522,150,61,118,24,411,781,115,447,223,767,786,7,16,31,87,308,687,22,9,259,279,212,44,17,518,346,71,10,371,45,98,2,919,241,761,33,12,93,64,39,541,37,608,35,774,341,759,75,664,941,663,125,846,581,401,120,638,566,303,68,936,260,0,932,199,105,634,270,706,30,453,141,102,95,86,110,107,771,273,535,82,727 }, { 23,51,13,453,4,475,0,12,457,10,2,115,401,15,11,403,5,1,40,99,14,59,961,165,569,629,9,32,77,37,308,3,719,7,57,421,21,64,17,494,6,22,33,102,18,202,177,128,730,197,523,670,139,141,899,16,90,341,8,56,217,210,402,48,24,386,125,27,318,95,45,86,72,775,269,758,50,65,19,76,111,38,317,180,89,62,342,54,46,734,28,247,41,29,36,509,237,26,880,196,352,365,275,468,120,216,153,152,108,25,137,757,349,221,181,117,277,49,477,123,34,291,304,801,82,31,678,597 }, { 48,125,221,21,165,23,197,13,763,423,508,193,98,293,457,391,5,867,693,386,441,81,18,16,51,92,60,314,64,683,401,49,237,96,104,43,430,35,397,558,241,180,126,523,105,32,758,140,38,72,510,308,474,356,230,95,279,102,501,784,517,663,858,541,31,633,498,718,149,127,91,422,97,418,118,900,159,144,115,511,44,203,246,366,24,223,480,453,361,350,218,160,71,22,701,719,393,40,173,124,963,421,370,148,69,643,93,743,598,493,298,253,191,170,164,116,7,1,939,730,120,74,33,20,326,63,192,269 }, { 202,5,450,77,120,132,494,195,523,318,326,1,260,146,121,271,167,576,203,0,817,615,18,21,403,692,234,604,354,142,49,13,35,23,7,212,20,14,2,682,158,252,147,137,101,102,128,32,33,265,48,16,291,551,342,419,364,60,22,966,475,43,107,9,178,363,51,639,17,10,687,12,821,6,859,159,520,416,97,848,805,31,360,269,109,93,198,329,259,39,55,64,562,786,402,92,82,553,878,70,61,647,455,180,411,95,315,191,4,842,105,239,165,822,638,115,98,634,24,453,346,126,99,156,899,199,522,28 }, { 39,166,9,101,404,158,333,30,0,190,310,252,274,68,438,419,100,344,88,49,254,124,694,865,154,530,656,364,577,28,810,265,65,35,131,455,159,857,16,21,24,793,22,539,212,777,105,625,747,677,709,562,95,48,286,1,329,703,18,228,71,125,272,36,109,13,10,289,538,219,676,706,778,51,31,98,557,86,23,175,60,553,406,55,962,671,840,118,224,168,221,83,669,67,213,382,96,570,64,960,346,327,170,613,731,191,242,44,115,759,439,957,627,748,114,634,264,688,593,37,251,137,320,127,7,520,167,518 }, { 15,110,4,120,11,5,1,23,13,165,93,21,10,2,32,40,180,82,197,3,51,6,33,0,7,125,351,901,391,352,77,9,115,260,102,341,117,217,317,134,31,141,752,453,12,48,8,153,386,509,873,203,457,401,196,37,898,372,59,326,475,55,14,202,569,57,498,403,719,17,64,308,237,494,318,269,94,90,253,961,22,44,730,36,697,342,177,482,56,474,137,89,72,421,349,38,670,576,139,111,30,28,210,148,96,758,143,734,629,16,244,160,128,18,291,41,805,247,25,19,84,373,245,61,488,579,205,523 }, { 2,29,52,1,26,58,6,262,5,50,14,70,103,46,19,38,309,27,96,112,67,516,75,163,133,331,218,145,108,223,17,236,45,83,287,25,487,74,114,171,785,409,357,113,238,24,433,151,53,36,388,220,739,34,545,396,307,532,583,675,61,600,181,42,65,73,764,160,635,21,603,394,12,80,594,186,150,324,894,632,3,7,334,99,54,137,315,891,69,445,37,412,323,48,745,537,18,283,87,458,138,822,308,243,155,765,86,711,895,398,285,28,651,366,226,115,766,849,294,23,480,820,51,221,297,22,732,209 }, { 120,77,260,141,51,13,217,23,317,1,450,291,15,202,137,326,373,110,177,180,21,269,165,318,128,197,352,115,349,64,32,203,5,342,351,0,102,48,341,96,854,93,82,523,2,244,457,9,160,752,386,36,922,12,365,372,37,898,7,304,275,403,86,10,210,253,817,16,704,28,83,90,901,498,143,6,615,4,719,22,494,237,18,661,730,473,30,24,308,50,221,40,76,72,55,8,59,35,11,33,391,285,67,89,144,125,61,961,99,39,401,14,3,475,247,402,44,31,70,453,49,509,642,153,208,482,17,216 }, { 444,183,291,297,358,196,554,255,56,59,123,269,33,605,108,122,153,177,275,210,77,57,341,117,130,128,475,467,730,152,134,42,403,4,50,880,19,381,315,401,51,65,421,216,630,349,283,21,503,235,133,85,23,11,719,368,46,202,99,494,432,229,40,14,29,561,665,339,670,480,736,588,523,453,102,15,899,650,326,256,249,236,197,125,318,2,775,757,711,624,396,365,328,524,78,64,3,529,194,18,13,0,250,12,6,690,25,445,266,48,511,402,285,26,789,678,260,242,165,120,343,769,543,488,409,390,369,366 }, { 23,13,51,12,165,14,120,153,38,197,117,37,99,401,134,386,453,54,128,202,141,196,64,5,328,40,237,21,137,139,15,260,33,2,719,475,125,133,180,457,0,46,403,242,77,236,6,208,1,36,96,32,4,391,361,115,308,52,194,629,17,569,730,477,86,102,546,817,450,19,10,758,961,933,923,903,558,160,11,29,22,18,3,188,111,79,114,108,65,48,95,291,56,349,157,94,41,338,221,89,82,34,59,277,177,49,317,304,506,372,351,50,26,421,217,44,31,7,72,341,352,350,316,312,207,183,143,130 }, { 95,64,348,33,467,56,343,174,554,511,77,312,233,120,108,180,0,561,6,355,543,13,306,370,197,165,859,25,18,29,297,256,91,63,899,237,49,770,650,412,235,85,138,19,42,523,65,671,90,102,22,9,32,368,194,40,23,10,4,576,426,416,204,161,153,117,116,86,26,27,104,448,775,721,719,457,450,344,326,275,217,72,24,605,730,283,245,196,98,76,17,5,577,519,123,835,475,192,81,78,353,588,386,365,269,260,222,220,214,179,170,141,134,125,119,105,97,66,51,28,11,881,273,242,172,746,707,643 }, { 120,51,260,326,450,202,23,77,141,203,93,13,137,318,21,1,82,165,110,15,523,5,351,269,197,64,102,373,128,33,217,48,180,386,32,291,457,125,817,352,922,854,403,115,144,116,177,349,210,12,96,196,615,475,7,719,372,367,237,40,730,2,342,704,4,98,391,10,275,59,494,453,401,0,37,6,421,317,50,16,90,36,44,752,308,9,498,160,31,393,18,899,221,341,14,3,30,45,402,8,898,304,83,692,99,24,551,72,947,247,216,28,961,153,864,678,661,473,88,509,70,22,285,17,576,300,76,35 }, { 15,4,11,13,5,23,21,32,1,64,93,33,2,3,180,40,22,37,141,10,82,0,6,77,102,44,31,352,7,120,117,165,341,12,48,49,110,197,98,134,9,752,17,901,153,498,342,269,196,115,291,365,128,260,36,317,137,51,95,59,217,318,237,202,349,72,8,509,391,14,873,177,16,523,86,922,386,247,143,304,210,125,29,45,57,457,453,90,854,482,403,111,579,160,244,18,569,437,89,61,253,76,27,899,351,864,275,450,719,56,758,116,875,961,277,468,164,148,25,817,401,316,84,139,546,490,216,46 }, { 15,341,13,141,23,33,217,4,77,180,1,102,40,317,5,137,0,365,202,51,11,21,351,854,9,269,82,10,115,372,32,64,922,901,22,117,260,352,197,153,128,36,28,196,752,134,165,59,318,349,3,120,2,12,30,177,244,37,450,143,291,31,86,457,48,139,160,16,8,7,898,247,253,125,523,18,49,44,57,403,304,55,730,569,961,6,111,110,14,96,498,494,17,308,719,72,39,237,642,386,475,90,98,24,342,45,401,817,326,873,661,76,277,95,509,105,421,210,93,811,453,717,144,391,99,89,164,221 }, { 272,105,131,327,286,320,578,109,22,28,219,239,224,159,9,616,371,49,95,623,538,98,716,910,713,127,258,737,187,185,385,761,424,168,170,64,55,254,347,169,928,916,0,158,164,1,924,31,23,301,51,293,39,627,374,125,913,201,44,836,242,912,36,395,13,116,65,479,634,24,442,654,86,346,284,276,35,312,137,308,512,160,115,194,420,10,175,2,154,7,338,21,128,16,944,83,143,456,12,67,601,202,762,141,908,124,535,289,574,871,688,165,401,900,5,763,96,892,933,384,317,506,237,860,14,37,68,30 }, { 16,68,35,71,18,60,118,24,191,126,92,101,150,212,167,154,302,175,9,346,55,0,273,7,124,108,107,375,628,28,566,14,722,149,815,199,589,439,882,575,520,363,121,562,246,467,21,364,1,806,279,140,22,49,48,252,517,695,65,230,345,847,647,97,621,411,69,146,336,46,653,39,10,109,694,604,535,5,189,768,399,446,637,50,441,2,755,419,125,298,608,43,314,423,13,649,158,706,463,398,100,67,818,508,38,12,37,20,826,95,354,264,23,32,169,166,132,271,105,96,221,674,83,51,932,429,356,54 }, { 20,470,147,43,904,376,798,427,325,595,142,178,858,198,319,0,97,173,414,22,259,61,422,819,77,945,202,14,32,5,362,49,426,392,107,207,887,725,660,481,263,465,234,104,450,534,494,861,95,28,18,33,120,10,612,64,344,105,13,30,324,39,21,455,817,115,46,146,102,31,132,4,246,356,318,65,158,66,260,40,7,48,523,581,9,35,159,315,113,729,23,230,125,347,112,38,128,878,359,59,36,60,12,239,600,182,237,192,153,342,196,683,98,16,170,2,306,298,357,54,279,101,70,560,501,345,199,845 }, { 51,23,13,12,99,453,33,202,128,64,153,102,15,196,37,403,141,40,120,117,475,38,134,115,14,137,77,401,139,10,0,165,318,269,82,308,21,2,5,197,54,3,180,260,22,31,494,421,17,86,93,1,95,44,111,457,277,237,402,450,9,110,18,6,98,719,125,65,351,32,28,217,49,342,326,328,730,629,352,386,285,361,221,11,50,36,19,341,48,569,177,41,59,8,194,27,24,89,79,523,29,775,4,961,365,7,670,291,144,373,210,114,46,317,391,34,116,509,757,203,236,108,30,26,817,55,498,57 }, { 383,136,17,62,84,440,119,504,56,240,548,3,80,129,378,123,106,128,555,205,4,184,507,59,162,11,14,183,57,361,249,38,202,469,152,64,179,495,483,90,32,215,257,214,245,130,209,54,161,27,250,503,328,229,618,211,5,73,402,45,12,306,318,40,34,514,790,76,452,77,65,26,86,297,141,19,53,497,742,269,814,283,37,33,255,311,194,436,667,114,177,61,217,803,95,207,266,2,50,432,769,757,236,102,21,527,36,556,46,22,10,72,115,41,494,611,381,29,196,99,216,210,151,248,445,137,0,576 }, { 70,652,48,5,638,846,1,21,163,340,888,767,221,125,761,349,260,562,269,303,518,658,591,586,13,698,623,23,883,774,98,87,49,31,9,371,296,223,51,763,850,863,120,541,360,346,141,634,64,535,39,30,2,0,845,7,622,156,318,195,44,95,202,900,32,12,931,379,6,558,768,293,271,115,777,401,58,354,818,61,55,17,132,668,450,308,385,914,351,919,93,922,391,457,128,22,590,212,291,77,807,762,758,252,159,101,663,352,538,372,100,446,75,520,18,937,284,96,146,626,326,127,118,116,771,522,463,69 }, { 66,135,74,97,278,6,172,69,324,140,267,808,462,14,550,204,7,357,138,87,189,85,298,75,29,2,500,52,335,38,25,92,582,802,174,571,572,841,563,42,380,1,24,314,21,350,16,451,67,46,280,220,501,443,150,620,230,103,486,423,35,353,622,60,83,226,71,192,32,889,26,22,65,903,95,5,48,232,330,64,108,86,565,792,641,580,36,448,70,509,197,222,43,348,558,426,241,726,125,262,0,877,893,50,872,81,309,63,233,950,37,749,18,388,149,145,12,91,237,10,355,606,294,246,114,508,673,28 }, { 51,23,33,102,13,128,40,196,202,77,64,65,139,141,99,12,14,453,117,153,475,403,134,10,86,137,4,11,22,0,318,269,115,401,36,114,108,21,38,5,120,180,421,165,402,59,28,15,95,82,210,37,2,177,494,31,342,9,260,217,277,523,386,3,308,450,6,457,730,17,133,18,719,24,46,361,1,352,49,194,143,111,54,50,351,197,300,94,44,237,341,164,365,221,389,67,32,48,283,19,485,291,29,236,27,854,93,961,758,110,326,817,317,285,125,275,90,52,45,34,26,7,391,181,57,8,752,670 }, { 88,264,435,100,166,274,772,921,478,382,909,639,438,960,521,96,897,410,30,1,466,190,530,778,265,321,682,691,418,144,724,329,686,39,9,447,93,31,914,131,404,203,44,411,765,335,593,475,795,367,98,625,254,664,120,213,613,403,0,744,539,116,83,656,363,238,5,48,13,576,77,812,805,110,23,21,141,966,69,125,616,829,326,286,201,82,35,520,225,51,821,127,604,285,284,165,260,217,33,36,310,731,340,842,223,102,137,101,615,64,831,252,228,49,10,67,224,557,219,443,692,406,272,268,910,506,197,351 }, { 440,62,136,548,504,56,84,3,555,383,507,129,361,128,123,162,4,17,59,119,184,14,202,183,152,161,402,495,328,57,205,514,527,229,215,80,27,257,38,11,378,73,757,497,472,240,211,130,503,452,803,54,469,77,53,34,494,381,318,283,266,250,106,12,102,33,245,210,432,64,403,19,40,880,236,90,5,556,179,21,412,377,2,32,200,300,99,196,269,585,153,488,141,51,275,216,45,37,117,249,529,194,214,372,76,862,177,134,133,313,26,421,0,139,471,41,305,65,248,483,13,114,678,23,217,50,72,775 }, { 911,617,959,332,206,253,244,141,282,120,110,384,951,143,352,260,269,10,160,373,717,531,811,417,940,55,728,661,533,36,434,450,93,137,559,203,473,498,642,116,180,326,855,261,295,44,268,638,922,854,752,31,499,164,318,351,201,535,144,851,564,341,365,64,8,115,165,197,843,1,217,317,704,864,187,699,567,127,202,873,237,251,22,258,574,824,98,86,968,860,489,23,817,82,125,21,169,509,926,219,13,276,15,601,28,345,9,372,51,901,349,943,871,5,367,291,776,308,131,391,96,523,105,83,386,902,338,35 }, { 120,260,450,141,77,15,1,23,351,326,137,64,373,82,203,33,13,291,51,21,217,523,269,177,102,128,922,165,110,197,854,5,318,457,180,352,48,32,125,144,93,817,160,202,386,96,50,7,372,36,349,304,210,2,342,730,115,898,719,16,0,196,247,494,59,10,9,473,22,4,403,116,18,86,67,341,752,615,95,75,901,317,275,704,24,475,453,437,367,208,164,163,143,37,90,899,244,98,12,3,365,968,551,300,237,206,55,35,29,6,801,805,678,576,401,393,391,288,268,216,194,99,72,61,58,49,39,242 }, { 15,0,1,2,5,51,9,23,7,13,6,901,12,3,8,180,4,141,82,115,14,10,341,120,197,33,93,730,21,40,125,401,260,202,102,22,110,64,569,719,457,165,37,961,898,453,18,351,31,28,203,16,137,352,217,450,77,326,11,403,629,308,128,196,32,30,36,269,44,98,116,318,365,99,475,373,670,237,24,899,854,523,391,95,421,49,48,317,177,221,817,153,55,117,752,39,86,144,38,642,105,922,242,291,54,143,17,134,494,498,244,59,661,96,473,65,160,509,139,170,247,89,114,90,638,20,704,482 }, { 104,7,97,107,356,560,66,232,707,359,298,568,289,324,712,392,192,38,14,426,173,65,95,64,172,387,22,43,92,32,357,362,214,20,259,526,90,0,330,380,126,246,501,49,5,86,893,74,500,194,874,147,135,612,230,10,204,779,52,2,729,808,550,140,35,835,21,28,314,77,312,60,16,465,132,715,279,423,414,600,885,802,683,18,81,24,36,13,636,861,150,33,178,29,819,519,288,4,31,58,660,448,121,534,12,168,61,48,581,278,70,37,146,102,441,23,46,199,142,6,751,249,76,319,202,189,124,237 }, { 6,66,1,2,74,67,29,14,24,69,83,135,25,458,52,150,108,451,75,38,103,380,267,278,7,87,26,42,324,36,357,138,602,114,97,19,85,238,594,273,65,149,398,335,172,46,160,204,70,18,711,550,50,16,309,220,71,732,96,696,5,133,603,12,891,86,174,28,280,500,418,467,226,32,22,21,222,189,27,60,124,423,486,547,895,302,733,236,532,388,208,64,63,0,35,17,13,298,95,262,45,906,336,646,582,37,145,194,571,20,531,112,23,58,140,516,484,48,886,218,118,115,99,81,462,429,54,55 }, { 51,23,13,453,12,115,202,21,403,401,5,4,457,719,475,37,99,165,32,308,64,3,1,2,523,10,730,0,128,17,197,15,141,494,11,22,14,6,269,961,7,318,120,386,77,899,18,247,421,450,817,48,16,117,59,90,33,125,217,9,19,153,180,629,26,758,237,24,177,28,221,95,57,341,40,25,38,54,569,391,27,260,402,29,216,317,36,72,291,102,56,134,365,45,76,49,468,304,352,137,210,203,34,89,196,342,82,275,194,349,437,46,123,326,50,20,8,670,482,86,509,139,498,316,53,61,576,288 }, { 57,59,77,4,381,11,412,369,210,291,421,283,803,53,250,542,377,14,339,471,275,108,99,670,19,300,453,403,23,27,401,368,40,51,202,361,775,21,12,554,236,183,402,813,33,342,38,378,475,503,46,37,444,10,736,390,152,90,56,561,285,153,134,123,117,650,73,899,523,281,0,529,494,63,386,880,432,162,514,128,58,605,102,817,743,690,495,349,277,256,196,137,111,79,18,9,801,235,139,78,867,391,200,119,758,130,42,26,480,389,719,714,467,341,80,269,122,730,221,216,188,177,161,133,114,45,29,22 }, { 15,1,5,2,0,7,23,6,13,51,9,3,180,115,12,457,4,8,14,141,901,719,197,33,21,82,961,365,22,120,165,341,31,351,64,202,308,77,37,401,260,117,16,153,28,11,110,93,730,10,32,44,269,137,217,569,18,98,102,49,128,317,453,125,30,36,99,523,48,352,134,752,450,196,386,318,326,40,95,24,758,898,17,116,629,39,373,203,86,72,899,237,403,59,177,35,873,90,89,55,291,105,817,144,734,475,244,139,421,65,498,76,247,494,20,38,854,349,160,253,509,372,96,482,221,216,615,143 }, { 64,237,180,95,312,197,146,32,90,247,316,929,352,126,165,288,317,132,304,13,60,490,77,217,955,522,92,314,86,22,4,23,7,5,21,626,40,14,11,12,652,498,291,177,232,164,199,33,10,482,51,141,115,150,633,462,579,340,216,16,529,128,37,360,638,388,121,359,143,468,275,59,107,49,534,125,202,658,509,269,888,267,1,598,581,588,76,17,467,451,296,28,751,660,441,349,194,29,31,71,698,279,253,45,640,57,48,546,134,117,18,2,830,647,372,102,65,437,493,351,98,733,622,423,273,241,309,137 }, { 1,23,13,51,120,15,202,180,5,21,260,141,0,326,2,137,7,77,197,450,269,33,165,318,9,128,352,110,48,6,102,523,12,115,342,317,4,32,16,386,14,403,373,203,817,36,18,217,64,96,37,457,93,752,82,28,341,494,24,615,3,22,291,351,401,8,475,10,308,453,421,391,901,221,196,59,719,730,854,30,177,90,160,365,402,125,35,498,31,285,99,39,11,244,237,72,20,899,44,40,704,86,17,922,83,50,210,349,569,576,98,95,67,76,372,509,49,143,116,253,961,65,144,89,55,551,661,29 }, { 14,46,2,16,24,75,69,35,220,52,7,38,1,140,267,29,71,50,309,60,87,92,70,171,189,67,18,54,163,262,335,108,230,58,366,103,150,5,675,236,181,112,223,278,409,537,21,83,294,48,155,68,12,486,149,37,571,582,96,0,246,334,135,186,443,45,328,28,32,133,641,97,451,151,388,64,307,126,25,9,502,760,394,281,357,22,65,66,774,36,10,55,172,114,61,6,565,462,461,251,552,563,400,74,820,330,238,218,600,72,99,86,606,314,17,380,430,227,587,433,20,13,23,583,516,545,121,115 }, { 127,98,31,44,299,276,284,9,935,293,116,599,49,0,456,201,492,28,39,105,144,371,662,22,159,125,272,137,242,131,737,489,393,567,268,395,51,1,761,578,367,202,158,30,109,918,916,685,219,254,203,616,23,434,36,21,55,141,295,95,13,24,16,187,93,385,128,18,96,948,48,269,763,160,318,64,5,165,86,101,244,326,115,518,35,286,836,261,37,512,7,10,68,327,623,716,384,120,403,253,688,110,333,224,2,890,457,143,100,197,12,386,252,301,320,258,963,310,65,14,237,924,221,170,494,421,83,699 }, { 53,573,445,297,436,73,6,27,151,113,26,250,491,19,614,145,611,200,315,112,45,396,881,138,80,42,58,70,34,684,25,631,17,222,287,106,74,472,122,61,624,714,690,235,5,90,32,65,255,64,648,29,14,66,95,85,322,2,209,243,549,311,644,22,1,52,665,280,47,161,86,76,87,194,312,651,3,667,133,416,75,307,114,128,78,62,137,51,57,4,226,141,50,136,46,862,483,49,289,884,119,440,632,814,12,21,176,237,148,56,236,283,174,36,135,63,123,337,10,453,33,412,84,469,214,59,108,23 }, { 90,788,804,32,115,693,494,81,84,56,725,403,119,21,18,681,99,77,202,526,65,240,214,576,64,817,91,0,784,350,241,102,397,342,690,848,104,61,24,945,318,69,825,453,421,365,210,134,123,117,33,20,707,402,60,293,263,207,194,114,49,888,370,97,43,673,671,523,726,326,125,510,879,773,718,715,701,462,283,249,180,153,59,57,51,11,887,835,814,111,23,4,889,468,289,247,221,95,89,86,66,120,719,325,192,899,730,683,595,422,757,486,484,426,351,312,306,302,285,275,260,238,216,203,196,177,174,165 }, { 24,7,14,149,71,16,18,108,65,69,28,154,189,35,2,140,124,92,68,150,118,175,429,302,0,66,273,67,336,38,55,97,251,46,60,36,547,1,267,484,22,458,230,29,83,6,9,388,86,650,172,314,95,109,114,52,135,21,64,886,602,74,505,10,232,5,20,12,596,823,705,398,32,103,49,101,420,570,236,531,289,533,50,298,168,169,48,133,462,451,380,23,882,246,283,51,799,13,43,25,185,797,194,847,75,357,278,158,37,439,346,594,330,733,399,423,610,164,192,535,701,104,345,467,143,443,125,137 }, { 68,0,101,9,212,65,124,35,154,189,69,149,114,230,67,39,252,100,1,336,702,329,16,265,520,83,103,191,264,755,64,589,88,562,28,705,30,24,283,167,118,18,777,732,478,12,21,723,71,166,23,49,175,133,398,335,596,55,664,218,237,429,389,532,818,604,364,50,158,115,484,289,246,352,238,410,141,22,759,419,323,375,345,36,13,10,806,128,51,547,796,269,213,5,48,722,140,247,321,96,565,480,164,180,251,330,803,553,37,676,95,143,202,86,75,490,443,7,936,724,99,2,190,694,346,197,782,917 }, { 5,2,186,61,29,52,45,58,311,17,171,80,227,209,48,155,1,106,243,496,50,46,334,454,592,21,513,14,502,255,869,666,151,663,262,223,75,207,38,32,270,667,62,6,27,738,659,119,56,3,807,54,780,287,378,84,721,74,220,290,96,163,483,72,263,89,67,549,103,281,136,37,583,76,430,181,536,7,70,408,12,394,64,787,73,675,148,495,469,69,161,400,409,36,833,86,65,34,19,474,587,742,767,221,26,324,128,4,309,115,24,83,306,425,25,22,431,10,241,760,90,141,764,541,133,240,95,383 }, { 15,1,13,2,5,3,4,0,341,7,6,23,10,11,14,12,9,33,51,17,165,153,197,365,569,180,77,40,102,8,115,117,21,901,64,217,317,22,141,16,128,32,457,196,31,134,28,36,291,18,177,139,137,237,719,961,37,57,120,111,352,349,386,59,202,453,629,86,752,19,758,38,93,873,269,44,391,372,49,143,95,342,730,30,475,498,509,260,210,318,125,110,304,55,27,29,403,82,48,24,277,72,482,275,116,494,25,450,98,54,351,76,90,326,41,79,373,99,899,546,523,194,144,474,94,56,203,39 }, { 13,23,15,51,0,1,10,4,2,5,77,9,115,3,12,14,22,102,11,197,33,457,7,961,165,453,403,40,59,6,21,475,494,18,719,64,180,28,202,569,32,401,31,37,17,16,8,210,177,341,523,120,141,386,730,49,217,99,44,318,57,450,308,36,629,421,125,93,153,342,90,117,24,111,498,139,269,237,30,196,817,291,134,317,326,98,95,365,899,260,352,19,48,82,275,391,72,38,89,110,509,482,86,873,216,76,349,148,247,79,27,54,116,474,65,203,901,615,55,45,351,128,758,137,304,752,94,50 }, { 15,13,0,1,23,2,10,102,5,9,33,7,4,3,6,77,51,115,12,11,341,217,196,40,14,117,153,18,317,569,22,8,457,365,523,16,342,180,197,165,120,719,453,961,59,134,730,21,64,141,260,31,901,401,291,899,386,28,139,82,210,177,349,269,49,24,482,202,17,372,817,44,450,93,629,111,32,125,351,326,300,352,37,318,110,128,30,36,475,95,579,468,57,308,19,137,38,98,247,437,304,275,20,65,752,237,498,391,494,758,615,90,86,373,854,116,277,99,72,96,48,421,203,45,216,105,898,89 }, { 166,39,274,190,438,310,30,333,530,100,252,656,625,539,265,404,778,88,101,455,9,0,557,960,593,329,254,131,1,676,382,709,724,158,553,840,731,228,98,31,669,23,68,219,264,48,21,748,957,812,406,49,224,127,44,13,344,36,272,286,51,159,520,419,105,96,116,125,613,83,5,93,795,124,213,28,863,22,223,35,478,10,816,352,293,69,67,829,16,827,258,616,364,160,64,242,639,578,120,167,128,65,518,217,321,154,32,137,187,604,180,4,679,435,118,18,251,212,144,86,95,759,141,77,410,793,371,37 }, { 734,94,148,308,79,111,413,468,89,37,431,115,179,401,569,197,629,341,188,13,873,474,490,365,72,12,11,134,205,245,317,117,4,247,358,59,40,152,509,51,482,901,961,76,99,528,23,180,10,498,217,216,477,339,77,139,102,38,165,55,749,421,196,743,579,143,33,542,428,391,875,752,471,497,54,1,452,153,177,21,488,588,3,64,141,349,453,485,670,277,291,457,2,128,5,57,403,36,475,529,184,540,202,48,377,90,7,372,14,50,405,210,437,15,758,402,464,386,352,300,157,6,17,0,45,794,9,342 }, { 539,228,224,219,190,816,840,871,30,669,530,957,258,748,863,406,93,187,778,531,160,213,88,466,839,36,131,137,116,202,728,679,926,120,44,352,39,321,373,318,274,276,851,31,574,442,860,144,730,217,201,203,613,251,856,55,559,533,944,141,435,1,450,242,230,22,127,86,110,64,800,28,49,326,473,9,260,752,268,254,166,418,717,567,456,98,96,776,902,385,968,100,719,180,269,616,317,918,351,83,827,492,10,625,931,494,125,831,908,197,21,365,372,82,371,35,77,716,854,795,689,295,704,5,332,345,244,291 }, { 801,393,125,791,386,730,23,551,51,21,144,116,48,203,98,221,175,165,949,93,575,31,126,13,958,326,697,601,421,345,788,293,367,22,963,541,110,455,60,608,670,273,197,44,463,4,32,677,623,127,33,259,834,35,948,453,375,133,107,120,77,40,223,0,407,342,68,719,121,43,14,446,621,590,523,373,308,102,49,16,899,1,815,475,199,770,725,191,493,804,96,36,319,141,101,92,39,146,690,71,55,7,118,38,805,352,649,735,615,602,533,531,480,323,279,246,208,201,196,180,160,105,64,743,589,132,117,598 }, { 13,23,77,51,115,141,33,217,4,2,177,6,0,102,40,7,64,11,10,14,3,1,180,269,22,202,9,59,16,15,17,352,318,128,18,197,291,247,32,165,196,153,117,134,317,19,5,90,341,125,237,24,137,210,36,28,304,349,403,49,12,95,86,25,275,372,453,365,31,308,752,216,342,20,143,139,475,93,27,98,498,57,26,401,21,120,386,391,457,326,8,569,316,494,421,111,65,901,203,110,105,30,260,468,288,164,437,241,45,48,29,35,99,44,482,719,82,402,509,144,37,244,55,546,56,285,961,293 }, { 2,52,29,70,112,7,58,14,75,87,46,220,307,186,171,163,151,1,334,262,135,278,66,5,69,155,294,97,38,140,74,16,45,172,287,549,92,227,400,24,849,226,331,113,61,324,25,48,852,32,35,21,37,6,461,67,409,50,19,12,644,315,267,145,26,243,223,311,27,64,60,54,232,122,71,18,83,17,571,583,189,86,36,853,103,72,65,394,380,587,780,774,309,20,43,22,357,42,96,314,298,128,209,335,536,95,474,767,675,270,337,76,80,89,330,222,0,90,721,290,230,10,137,108,246,126,28,448 }, { 321,88,213,435,466,100,689,382,30,230,1,795,352,410,96,217,699,921,190,831,521,530,443,36,83,686,144,418,840,264,438,854,128,251,539,957,44,141,180,557,752,335,69,223,317,960,31,265,48,137,855,116,934,201,98,748,160,669,909,93,166,203,812,731,403,21,274,351,593,39,778,206,367,772,219,64,228,131,455,202,9,284,5,372,35,326,238,127,23,735,82,51,656,285,67,158,310,125,639,800,221,187,224,332,269,120,365,576,494,13,897,252,345,822,478,765,349,702,77,268,421,242,208,110,318,859,101,237 }, { 363,520,411,354,101,195,668,132,447,9,156,905,364,664,121,146,360,23,18,759,781,1,98,765,271,51,96,676,252,264,13,777,5,31,586,621,591,478,223,167,848,21,100,691,936,551,33,393,857,70,48,883,125,682,77,16,39,687,948,821,44,367,116,93,24,407,265,127,593,834,110,49,842,522,296,4,293,166,626,812,865,64,404,203,333,102,538,212,36,638,40,55,446,50,647,118,291,656,897,144,639,60,771,697,128,403,379,67,35,692,541,165,463,163,604,453,658,199,590,69,791,286,7,32,12,317,217,724 }, { 51,23,13,453,401,475,12,403,457,730,719,21,5,308,99,115,2,32,11,4,3,421,961,1,165,15,629,899,0,670,37,10,6,17,197,9,33,18,22,523,569,64,40,202,28,19,56,26,7,57,27,16,72,48,196,194,24,59,494,177,153,45,36,139,77,386,210,128,117,65,758,34,8,391,341,817,468,217,54,29,450,275,221,76,757,509,350,141,134,90,89,46,38,291,180,880,237,102,304,216,775,734,546,402,361,277,137,130,129,67,41,25,14,247,148,62,901,498,477,283,262,260,133,123,74,42,801,365 }, { 72,76,89,205,179,90,245,528,148,54,184,37,12,431,38,308,152,4,257,59,474,316,428,401,464,57,460,749,32,288,358,405,229,23,477,645,743,99,11,21,51,115,497,77,217,1,794,79,157,14,5,629,540,488,453,216,45,449,17,155,2,221,770,165,48,670,421,569,328,266,50,452,197,341,181,3,128,769,10,365,137,64,13,317,587,241,36,457,734,188,247,0,339,313,7,536,350,471,9,202,94,468,524,509,721,482,141,46,129,102,773,697,33,432,40,180,270,237,281,619,741,381,86,361,961,543,476,720 }, { 376,43,147,470,20,595,173,107,858,97,319,142,427,819,414,178,729,362,426,325,5,259,7,32,861,392,61,798,246,14,104,198,230,560,885,324,77,21,422,904,356,0,465,126,357,48,707,234,38,330,22,49,207,35,501,612,66,13,202,95,534,359,298,2,10,577,76,28,16,70,113,64,132,4,17,481,318,715,102,60,58,18,784,59,120,40,72,11,90,29,500,23,74,279,879,146,33,1,112,660,387,56,52,45,315,81,232,9,494,177,140,36,115,37,153,600,57,199,217,31,12,121,347,51,403,878,671,164 }, { 202,269,141,494,318,51,137,403,128,77,453,4,475,217,678,349,421,5,342,352,96,102,291,177,372,317,64,341,180,21,2,40,10,59,32,752,33,11,61,3,515,120,304,36,0,365,6,31,13,22,7,39,30,95,125,260,237,12,717,275,115,28,23,98,244,482,268,105,947,851,402,805,203,194,144,954,576,450,351,48,859,289,283,86,65,55,49,44,795,197,82,90,498,312,285,241,201,182,165,160,57,56,14,411,293,284,9,822,326,899,523,931,921,897,863,854,839,821,735,691,668,579,569,442,360,251,214,207 }, { 77,202,318,102,494,33,128,269,23,13,51,196,153,177,117,342,134,291,403,0,141,137,64,15,349,82,22,351,203,49,275,615,373,21,551,393,473,217,95,859,31,210,4,475,402,1,352,65,11,10,450,120,32,180,86,285,36,18,2,7,3,453,12,260,6,28,98,14,125,39,421,48,90,5,372,40,194,59,44,165,817,16,9,115,326,341,523,17,678,216,30,197,317,116,576,96,127,237,61,93,300,24,365,124,70,401,105,730,214,160,114,304,289,110,329,20,704,163,35,386,208,899,144,692,244,67,50,719 }, { 253,951,352,110,811,499,244,854,10,638,642,752,559,180,143,141,564,8,260,341,498,417,922,661,901,197,206,165,911,373,137,93,282,873,351,384,15,959,55,332,120,762,717,728,269,160,898,82,473,64,326,164,36,365,203,22,704,533,317,509,31,479,86,968,116,318,115,202,531,1,268,217,33,535,28,44,9,617,237,13,434,4,261,23,77,940,125,5,372,11,851,864,40,32,338,21,102,0,569,386,30,96,482,349,169,824,421,51,105,546,12,401,242,758,576,391,35,127,98,170,2,117,144,844,295,457,24,291 }, { 141,23,13,5,4,269,352,51,180,21,317,115,202,217,1,197,2,11,365,318,32,341,3,6,372,137,7,498,77,64,349,291,48,752,33,0,165,237,9,15,22,12,901,221,253,16,144,244,143,403,93,28,401,30,453,110,475,24,304,40,39,120,125,494,421,203,308,72,160,569,18,386,177,35,102,482,31,14,260,44,10,36,391,95,473,373,153,49,468,864,247,117,873,128,100,88,59,134,69,546,241,76,717,89,86,196,17,37,437,166,509,351,164,98,854,67,8,90,704,629,82,851,450,96,811,367,326,284 }, { 252,101,18,9,0,68,16,118,329,35,364,24,39,167,60,333,265,109,158,553,71,212,677,28,419,604,100,793,49,286,159,154,191,105,55,310,272,694,327,455,124,810,806,48,22,166,254,593,21,7,374,344,1,520,146,121,538,5,917,65,346,706,857,634,92,562,23,627,404,126,925,13,98,185,51,108,30,14,907,271,169,709,31,942,95,10,446,96,149,628,557,125,375,170,175,67,688,199,363,132,639,239,190,656,107,621,320,12,912,638,137,36,150,44,815,302,50,463,865,221,438,32,37,578,671,439,848,131 }, { 28,109,158,9,168,49,39,175,35,159,22,0,55,185,65,289,272,67,95,194,114,346,333,577,169,584,254,1,344,327,105,570,286,336,24,83,86,30,747,68,627,374,124,505,69,101,810,610,837,439,36,154,535,133,103,7,310,16,14,835,131,756,601,345,2,429,874,149,389,50,799,793,252,347,283,208,547,51,251,46,23,100,128,10,189,312,164,424,912,21,484,5,64,688,637,12,190,578,455,96,239,420,13,518,143,634,137,419,533,364,18,398,166,48,709,320,218,538,127,160,170,230,323,125,71,37,98,202 }, { 15,13,1,5,2,3,4,341,11,23,0,33,6,51,7,12,40,115,10,9,77,102,14,197,365,180,17,901,21,217,317,196,165,32,569,22,141,8,64,961,453,457,16,153,59,117,18,352,31,202,125,37,139,291,401,629,28,386,269,134,719,177,475,237,93,318,120,730,44,48,372,110,24,111,899,36,210,403,19,57,523,391,349,752,326,49,38,128,308,342,260,494,498,116,95,509,98,137,30,873,304,758,90,801,27,56,86,203,615,144,275,45,482,450,65,670,373,54,41,50,734,94,143,25,82,244,105,79 }, { 173,693,18,104,422,20,102,0,77,49,61,5,784,560,526,707,226,32,13,33,397,64,193,344,134,117,91,66,21,153,715,263,81,95,172,232,207,196,31,11,6,65,510,42,25,414,197,180,135,48,29,22,10,43,72,819,4,470,324,40,85,546,86,887,347,51,319,204,57,28,27,426,359,283,498,376,138,128,90,194,392,643,879,701,474,87,74,59,52,38,9,387,681,7,862,597,192,814,847,718,713,334,291,270,217,165,125,83,37,56,23,202,177,141,122,825,241,509,330,942,817,523,370,269,115,98,84,44 }, { 23,51,386,308,13,401,221,421,801,949,719,165,468,730,21,770,341,125,697,453,867,14,115,670,457,6,391,403,1,475,958,523,450,117,102,197,629,365,33,569,607,7,2,758,120,66,899,515,743,134,217,791,342,97,16,326,67,733,74,350,150,773,749,260,202,52,29,18,9,501,456,805,809,734,482,56,0,317,135,4,906,458,153,3,380,103,645,579,558,490,24,93,83,388,196,108,817,11,99,903,685,177,69,32,561,267,236,335,5,180,594,696,554,451,642,576,564,559,546,349,291,238,122,89,87,76,75,73 }, { 49,0,24,16,105,159,28,9,35,158,68,320,18,109,239,55,65,170,124,7,1,154,301,347,71,95,14,286,518,101,2,344,327,272,127,118,39,21,60,374,890,98,577,623,12,149,22,5,916,338,512,168,36,713,395,23,31,67,51,371,13,48,185,175,125,137,10,424,169,64,202,737,479,30,747,538,6,761,37,108,128,346,242,32,740,293,131,46,50,302,654,69,44,252,419,289,810,86,114,92,83,616,141,385,846,299,164,254,364,506,403,677,310,671,375,191,221,116,938,318,634,100,165,439,115,143,333,96 }, { 2,5,29,45,207,58,61,1,76,292,32,655,263,14,476,52,72,6,119,17,306,70,186,7,106,46,179,214,790,90,148,243,720,38,227,50,240,112,151,710,255,592,84,89,64,48,25,464,75,241,209,21,129,74,155,460,358,3,128,454,496,425,36,77,19,22,141,738,10,115,56,26,86,16,123,66,408,311,27,245,0,249,95,65,205,287,519,290,618,40,24,177,549,171,202,87,4,59,163,307,54,334,237,51,23,62,269,12,102,37,18,449,869,137,80,69,113,28,99,33,67,13,135,180,318,315,769,288 }, { 125,21,115,95,715,197,49,165,64,56,66,32,6,278,13,33,713,681,808,350,204,237,120,408,263,241,172,135,81,22,324,87,509,74,0,85,97,4,90,86,468,65,888,353,174,558,391,841,192,180,23,950,872,645,571,554,650,580,141,5,2,412,283,467,341,673,59,138,38,108,903,177,91,51,7,511,370,164,75,31,620,475,203,893,170,98,712,104,44,19,885,10,1,561,426,415,308,63,403,196,153,117,102,84,389,128,27,825,569,210,77,347,53,123,386,316,159,143,835,194,900,448,93,11,546,232,18,572 }, { 612,325,427,202,107,494,5,403,470,147,518,376,64,362,49,21,392,788,465,98,14,342,125,623,318,178,48,31,845,804,534,858,423,70,690,595,414,278,93,422,269,453,7,660,102,77,33,693,61,953,767,798,819,581,307,298,234,198,116,110,97,39,32,30,10,237,4,671,663,389,289,194,128,43,0,20,904,725,761,711,678,509,501,493,366,319,236,232,220,174,104,99,95,88,87,68,55,44,38,37,18,9,900,293,13,715,441,315,105,291,163,141,391,112,848,397,22,763,713,558,846,835,828,822,757,657,557,546 }, { 32,76,21,72,14,241,449,50,292,2,350,5,1,155,48,221,46,38,89,179,270,45,476,90,54,720,214,430,148,464,17,281,129,460,37,205,413,741,181,36,245,519,29,227,52,290,257,184,405,12,123,710,3,528,162,7,773,243,541,10,358,0,288,431,67,57,249,536,316,152,99,96,23,106,171,51,513,4,743,308,618,128,137,6,115,64,474,477,103,408,86,207,769,229,263,9,328,83,133,180,59,183,119,552,794,787,540,114,217,488,425,218,62,11,421,659,77,645,760,721,22,524,202,58,400,401,141,770 }, { 24,154,149,28,124,16,35,0,71,7,14,68,175,108,65,18,55,92,109,302,118,9,336,570,484,398,69,140,60,2,420,67,189,22,101,46,150,185,158,346,230,1,439,169,252,273,168,419,289,39,49,38,505,251,83,345,701,535,799,610,637,267,21,36,97,10,650,50,95,12,429,246,103,533,114,388,458,133,5,48,399,314,86,6,671,375,159,66,364,29,236,329,962,703,105,547,23,51,172,601,333,283,64,265,886,126,96,194,52,13,232,722,32,20,389,54,37,677,164,100,143,125,327,602,75,917,344,286 }, { 5,14,1,50,48,2,46,38,67,54,45,103,24,270,21,96,513,155,290,83,58,61,281,69,32,36,181,72,502,0,29,171,17,12,16,7,76,263,37,18,28,52,227,35,425,207,89,666,22,221,243,133,541,663,65,10,741,218,408,223,114,536,108,474,75,9,186,6,592,552,51,23,99,238,328,115,309,794,540,3,433,834,86,292,760,477,148,449,428,64,476,128,400,528,119,655,55,236,241,106,202,141,765,766,487,70,13,163,137,366,95,71,587,697,488,720,179,160,19,418,807,308,659,149,27,90,431,4 }, { 961,13,569,37,197,23,474,94,148,79,12,629,401,111,901,341,15,51,165,405,734,873,99,4,413,188,134,89,10,11,358,152,179,117,308,115,40,59,72,468,245,139,457,33,153,247,365,477,205,277,339,317,77,758,5,38,498,76,579,453,216,180,0,3,542,762,36,490,2,177,102,143,482,217,196,471,14,452,128,437,55,1,54,304,22,210,9,377,64,638,202,17,21,488,349,431,300,775,528,485,32,7,141,318,372,86,8,509,157,45,291,497,137,184,6,864,402,670,275,880,403,110,543,328,529,875,90,657 }, { 102,33,51,77,23,40,128,202,64,13,141,139,196,318,403,153,269,117,99,137,22,4,453,134,59,115,12,10,11,475,0,14,86,65,95,180,15,2,120,1,210,494,342,28,18,165,352,6,36,49,177,217,300,260,82,719,401,421,24,402,386,21,5,457,7,197,730,3,125,37,450,19,291,48,523,17,351,237,27,114,326,93,50,111,38,341,317,25,285,98,26,277,110,54,194,46,9,391,361,275,16,44,31,961,32,308,96,349,899,34,133,854,569,29,485,757,108,105,283,67,144,373,57,509,678,498,221,116 }, { 24,35,1,67,0,28,18,16,103,9,68,69,50,65,83,149,12,5,71,133,14,7,22,114,75,96,2,55,189,218,108,48,21,54,223,175,281,251,181,23,46,58,37,124,101,51,336,238,36,70,13,154,118,163,418,10,99,60,745,766,137,537,39,128,38,335,202,141,487,49,361,64,32,45,115,486,155,765,283,109,502,345,230,140,87,430,171,29,269,398,30,267,95,221,543,92,86,820,236,217,6,412,285,17,160,302,77,177,596,61,318,180,458,488,31,52,540,165,352,4,237,105,920,545,125,657,705,273 }, { 384,617,940,911,959,855,332,206,282,434,244,253,141,268,352,93,120,144,10,269,137,110,160,201,417,36,143,450,116,203,260,44,811,31,717,951,55,295,318,64,187,261,373,567,202,276,489,258,326,498,98,642,559,180,473,127,22,728,860,217,1,661,219,499,86,23,851,638,8,197,692,341,13,531,165,224,351,523,817,115,9,854,164,125,752,365,28,533,367,51,922,15,564,131,21,96,317,128,82,5,662,699,843,105,871,372,615,237,0,83,386,30,864,509,242,800,901,284,291,551,77,2,776,349,7,704,37,574 }, { 93,30,203,473,326,704,137,652,450,31,800,269,848,160,127,190,274,144,254,219,187,625,349,303,166,352,120,372,116,521,224,110,131,752,435,88,217,202,141,260,291,77,367,156,340,228,822,744,5,382,197,296,658,438,180,863,410,44,730,698,578,317,418,1,859,165,850,829,735,494,102,795,616,159,264,921,98,960,373,36,100,23,13,341,128,21,64,258,10,0,523,330,318,39,717,321,778,709,7,968,125,919,942,177,49,86,158,9,365,225,901,478,105,686,531,33,924,888,851,96,2,363,371,442,385,747,691,615 }, { 53,73,27,250,26,200,19,297,630,714,472,611,42,122,235,25,17,34,6,436,65,684,106,680,690,80,14,256,113,322,57,813,85,108,64,45,59,648,283,4,161,194,573,445,236,389,128,862,444,114,624,390,469,78,56,51,141,133,2,90,22,84,11,176,491,0,18,255,495,453,416,32,3,412,23,47,145,137,63,29,665,123,95,269,46,378,62,61,614,483,86,361,814,10,5,605,136,396,216,177,112,50,249,619,730,77,129,119,503,13,432,202,179,12,719,285,318,24,597,102,151,183,76,21,130,742,37,209 }, { 15,2,1,5,7,3,0,6,141,180,10,4,13,33,11,352,77,197,9,217,14,134,64,12,341,317,365,165,752,40,498,372,269,102,23,17,115,117,291,8,349,22,51,153,196,59,32,237,16,901,36,120,21,260,202,342,961,128,569,143,82,57,864,37,45,318,873,110,93,111,457,18,72,391,386,76,28,86,351,125,137,509,95,31,56,954,326,450,79,48,27,854,139,29,482,19,38,44,546,89,373,99,49,244,90,55,84,719,523,94,403,35,177,54,579,453,277,24,164,922,41,253,30,203,730,61,20,58 }, { 254,530,960,613,39,829,688,221,406,190,166,475,827,438,30,9,669,269,180,23,98,51,31,228,21,541,202,274,141,840,318,131,938,105,48,158,127,125,96,44,846,137,453,49,393,219,352,116,13,1,679,421,856,625,286,317,36,308,100,333,310,403,115,890,144,217,791,101,931,616,569,10,386,551,401,0,876,272,910,55,258,88,102,77,327,656,224,629,252,64,468,731,160,385,860,518,926,28,697,344,326,159,33,5,197,93,944,627,128,165,816,293,574,455,187,765,371,364,843,404,242,120,22,284,95,32,345,506 }, { 39,9,166,28,158,35,101,30,175,364,68,168,190,0,67,346,194,100,49,88,131,36,333,420,274,310,570,344,404,252,83,289,706,109,55,69,208,1,86,160,137,610,96,65,967,251,438,352,637,336,114,16,577,159,128,254,756,154,345,219,22,64,230,799,228,810,95,24,51,747,224,185,141,818,149,584,768,202,103,419,429,21,826,752,124,530,857,31,656,10,13,169,323,505,237,143,865,562,189,165,793,238,694,535,23,217,874,455,164,116,105,7,197,127,44,547,125,286,180,213,868,539,71,2,703,272,498,115 }, { 62,555,548,56,3,507,161,440,34,215,527,136,514,162,361,4,211,17,130,328,383,757,14,84,183,123,205,152,494,11,184,57,585,38,236,202,377,59,54,504,452,129,402,128,176,556,229,880,80,372,300,381,495,40,33,378,37,469,106,266,472,119,12,214,497,248,102,803,403,342,249,73,53,77,245,412,313,51,196,27,153,543,257,485,210,471,76,283,488,99,305,200,421,13,139,157,23,349,432,79,45,90,339,32,117,240,46,179,714,457,292,108,134,250,719,318,41,217,64,21,22,369,710,188,72,133,277,453 }, { 126,107,92,356,493,279,359,7,246,97,298,362,392,441,508,60,199,35,423,16,146,132,121,14,43,230,501,232,939,20,649,150,173,5,779,660,414,607,672,314,590,259,534,21,66,140,729,683,387,191,18,71,941,955,953,32,104,49,48,22,38,0,46,319,640,95,819,172,147,167,24,357,28,10,2,13,858,603,324,195,68,598,12,1,345,595,426,61,64,653,522,407,612,470,4,885,77,23,52,236,125,37,33,702,31,687,581,6,118,74,98,711,399,212,40,75,70,376,465,517,360,135,271,105,102,50,192,156 }, { 291,141,349,373,372,82,15,260,351,120,922,854,326,217,318,77,450,1,352,898,93,269,523,102,202,21,203,144,13,64,23,304,5,752,137,437,32,51,473,98,704,247,180,177,317,237,197,342,59,457,947,817,494,316,76,33,719,615,300,961,12,36,968,954,475,386,367,268,165,115,86,83,69,67,48,39,22,2,851,341,275,210,201,110,662,576,418,403,391,365,284,241,194,116,105,96,88,54,44,31,7,730,485,205,125,40,117,875,873,864,661,579,498,490,482,468,393,332,308,244,221,190,185,169,160,128,109,100 }, { 141,217,352,115,269,180,317,752,341,244,13,291,21,77,23,197,365,5,372,165,51,64,237,349,48,9,4,304,482,102,32,864,28,318,247,137,11,202,308,33,39,98,7,3,1,498,351,125,2,468,437,110,10,82,490,253,120,100,88,954,515,177,93,901,31,12,401,201,0,49,922,72,203,569,55,30,6,342,260,143,22,117,898,717,44,89,35,153,144,854,128,36,386,350,101,68,196,40,373,221,134,96,206,873,391,316,288,241,164,160,105,16,90,579,403,326,645,629,523,421,284,116,65,61,961,59,24,18 }, { 78,47,390,108,130,711,813,19,453,412,27,283,730,444,690,196,250,123,236,128,389,503,200,650,183,14,59,4,26,65,472,133,73,34,381,297,153,51,177,57,269,11,53,318,33,216,719,17,194,630,680,322,619,114,113,368,714,46,684,803,432,56,77,29,657,6,480,141,117,3,445,22,603,122,42,235,84,361,90,899,13,64,23,102,249,2,754,524,605,457,99,63,0,475,349,789,40,38,588,210,18,152,106,134,678,436,24,10,25,597,50,529,291,594,401,52,245,95,402,894,129,266,86,471,339,119,523,137 }, { 250,297,34,80,472,495,311,64,53,17,667,61,148,27,56,483,469,136,90,73,141,161,45,243,194,3,106,597,527,176,128,751,352,151,436,62,86,874,738,4,209,153,833,491,881,614,396,32,383,84,26,76,445,231,95,5,659,14,887,237,29,378,573,431,947,196,405,58,23,255,119,117,65,11,113,59,33,719,134,814,292,287,57,177,721,240,12,585,611,247,269,51,22,283,200,498,2,583,304,180,19,145,312,165,678,205,202,10,835,349,72,217,114,514,40,555,315,588,137,130,37,875,389,197,207,179,0,13 }, { 51,23,551,421,453,13,33,102,77,21,326,153,401,958,308,120,615,196,5,48,202,221,115,692,523,791,403,899,342,4,801,475,210,805,260,107,450,291,966,93,730,576,32,117,842,541,468,18,1,16,203,116,110,697,60,96,126,121,386,68,31,40,2,494,259,125,463,407,137,154,24,704,427,373,218,180,92,10,575,244,35,104,64,175,302,628,351,318,197,160,98,71,817,770,743,670,612,12,859,158,17,590,199,650,7,945,815,752,346,949,851,717,642,597,473,439,402,367,253,252,217,146,56,44,6,3,36,847 }, { 98,223,393,363,411,834,478,664,1,691,791,284,156,447,724,914,759,697,293,354,541,807,51,586,421,48,948,668,765,848,264,195,9,163,658,23,801,18,125,551,21,386,96,340,772,909,682,963,730,698,31,453,360,13,371,949,905,770,520,5,621,781,221,744,271,296,116,202,647,857,132,70,118,335,821,44,656,842,367,897,719,121,167,446,32,69,457,450,318,101,100,670,379,638,127,634,144,137,410,761,662,217,846,758,146,401,932,615,75,777,883,538,87,165,33,225,936,591,286,93,166,269,197,812,326,141,105,919 }, { 232,7,107,92,14,46,135,172,359,220,314,278,60,5,171,192,2,526,16,620,21,262,52,75,35,32,126,294,29,872,24,132,18,77,246,87,448,571,230,48,1,54,12,58,38,236,50,606,247,86,23,70,177,112,461,298,121,380,97,71,37,888,217,392,66,279,150,356,155,64,13,20,441,108,678,304,751,572,147,226,115,334,140,61,291,785,153,739,579,43,451,178,146,186,947,437,387,394,90,51,330,195,194,875,307,216,352,597,587,357,117,0,269,181,45,603,349,210,199,137,415,128,267,95,366,315,156,31 }, { 32,76,2,241,21,14,292,1,476,72,48,5,45,720,50,179,270,214,46,89,90,29,148,129,464,155,17,290,519,38,227,460,205,123,245,350,243,358,52,184,54,257,171,710,249,408,7,400,186,221,405,513,3,36,162,618,12,106,37,288,181,57,502,413,0,263,10,428,316,99,281,207,6,229,4,58,152,64,115,425,430,769,67,741,119,59,22,128,659,308,773,183,23,202,96,86,431,83,75,62,141,9,524,51,16,103,328,645,69,237,497,255,209,217,130,11,24,496,666,28,137,403,528,18,247,536,452,77 }, { 15,77,33,102,13,23,51,117,4,32,11,202,40,90,0,1,5,141,153,247,177,128,134,214,288,21,137,269,17,453,3,318,291,403,8,110,82,180,10,59,165,494,22,6,342,197,457,351,64,475,260,9,93,2,120,523,326,48,31,217,115,57,421,386,12,373,44,196,16,19,719,730,25,139,96,352,341,36,961,49,210,317,349,203,125,194,401,18,275,7,24,28,98,817,285,898,365,95,308,901,450,30,99,661,372,86,223,65,854,615,922,402,56,899,697,758,208,103,14,237,116,105,569,37,304,221,704,638 }, { 66,74,135,69,6,380,278,267,97,14,2,29,1,75,24,87,324,52,150,38,335,138,357,189,204,172,67,103,25,388,85,7,462,220,83,423,108,550,149,71,603,42,733,571,696,174,26,582,140,36,458,565,16,808,895,802,486,46,238,35,19,70,298,21,18,114,65,226,22,86,60,418,32,251,192,92,64,451,280,273,500,309,95,594,222,501,12,50,5,145,563,398,353,0,889,28,443,48,607,711,641,517,112,262,336,348,37,125,580,596,906,705,622,572,10,160,81,43,63,54,58,133,792,68,620,124,165,294 }, { 152,471,4,339,59,188,79,77,11,377,128,94,529,102,33,202,402,111,12,99,51,216,542,452,291,40,474,342,210,196,13,141,184,64,403,37,453,153,134,318,17,177,117,494,23,961,139,5,32,76,431,3,300,257,205,757,497,115,401,275,269,10,229,179,72,475,21,2,86,90,14,57,89,349,1,0,180,157,285,277,148,629,137,266,197,38,36,304,45,217,485,6,498,678,129,405,700,95,569,245,437,734,247,460,22,413,313,352,19,372,775,308,421,292,880,48,237,143,769,503,358,873,488,54,7,618,710,386 }, { 15,1,196,0,33,13,2,77,5,10,9,102,217,23,7,6,3,12,117,14,4,134,177,153,40,11,457,291,210,275,22,730,16,115,18,165,21,386,341,719,120,82,180,64,197,51,141,523,317,8,569,365,450,202,32,961,372,260,28,349,342,125,352,95,37,31,899,351,17,128,318,269,48,110,49,403,19,93,901,59,475,401,72,326,24,139,36,65,111,61,237,758,494,90,99,30,854,304,817,44,482,137,391,56,509,898,437,25,308,752,98,38,629,247,76,922,421,86,57,373,670,26,253,70,203,221,801,579 }, { 209,106,17,207,45,255,119,655,5,742,306,378,61,62,136,425,263,80,311,84,240,29,790,2,58,56,186,32,3,383,738,243,454,592,869,76,151,14,179,129,290,123,48,72,440,148,21,52,292,64,90,504,287,667,214,46,1,128,54,408,507,50,476,34,27,833,549,57,38,548,155,227,162,86,241,19,70,152,89,205,6,334,171,26,496,483,112,183,181,141,130,400,249,59,245,266,184,555,663,75,270,358,77,229,361,37,215,95,445,4,297,10,211,25,33,666,519,881,11,257,202,73,710,269,237,40,221,180 }, { 120,450,260,817,523,15,23,1,51,326,98,13,202,82,125,64,5,351,318,21,31,269,457,32,116,93,115,165,102,77,33,12,95,922,719,30,494,110,44,615,128,48,14,180,141,36,2,730,61,9,137,342,403,899,197,86,49,10,704,551,386,237,8,203,96,83,67,37,7,177,291,352,90,22,18,16,402,196,153,373,179,144,76,39,17,6,961,854,475,898,692,401,241,207,148,105,100,65,50,20,453,349,344,3,217,901,678,341,293,263,247,210,99,88,69,45,40,11,958,801,317,132,126,107,35,24,752,661 }, { 116,268,492,918,93,206,203,940,23,51,551,417,523,499,473,959,22,421,8,125,791,692,730,120,31,401,949,10,0,13,899,165,44,386,450,260,867,453,64,9,629,115,36,719,559,341,728,170,55,137,599,299,197,615,569,180,457,28,391,141,1,326,685,301,564,479,475,338,506,86,509,105,638,202,95,817,308,242,253,762,244,2,373,801,670,127,901,21,49,870,951,5,558,237,143,269,37,752,239,12,642,922,403,873,7,352,4,758,365,318,128,18,965,456,32,320,221,14,805,512,317,498,961,16,704,98,33,898 }, { 15,13,165,23,197,4,0,1,180,12,11,117,5,8,82,901,719,341,2,120,51,9,523,260,509,7,3,730,141,386,10,450,351,6,33,752,758,134,115,498,352,961,317,365,153,898,14,899,854,64,217,922,873,22,569,326,93,128,817,31,269,237,291,202,21,110,391,37,801,615,28,318,17,457,44,16,77,18,32,98,99,36,49,30,349,401,453,403,102,38,373,958,35,629,116,40,137,125,55,19,482,203,304,242,86,546,474,96,24,144,65,308,475,139,143,247,210,402,89,54,69,177,196,48,485,661,83,734 }, { 14,24,69,66,7,108,2,398,267,150,67,97,189,29,149,74,38,71,36,6,83,52,273,388,140,1,135,18,46,172,602,65,28,124,429,302,154,380,336,451,547,16,278,114,732,68,484,324,75,733,92,175,103,118,22,462,0,25,251,357,86,596,55,160,87,705,594,35,60,531,133,467,423,711,236,95,650,109,458,443,298,21,886,5,50,138,26,12,505,238,168,309,314,42,32,10,646,220,49,70,335,192,232,906,420,204,48,20,64,37,43,603,13,19,533,96,85,23,565,51,330,226,550,221,570,208,283,54 }, { 330,335,96,839,523,662,367,443,615,418,141,403,717,244,692,576,922,372,1,352,269,217,752,349,64,498,36,854,966,180,822,831,954,873,864,317,284,291,776,201,318,144,69,98,351,678,7,21,5,160,77,203,83,82,442,137,551,2,260,223,622,187,494,44,13,385,128,202,23,475,75,341,901,48,31,437,238,304,247,230,765,93,373,120,393,22,67,251,371,293,125,661,342,859,285,898,163,365,30,32,450,29,110,459,326,934,51,10,197,842,851,399,246,189,800,421,237,0,37,116,221,165,16,579,127,9,321,88 }, { 184,257,205,90,245,229,769,524,152,432,497,619,17,57,5,452,32,45,381,266,106,2,59,21,179,4,292,217,313,460,288,1,214,129,14,76,77,3,128,216,48,207,471,339,157,141,710,11,202,38,64,519,369,6,61,209,12,37,119,79,99,123,29,317,72,188,7,62,255,33,58,162,269,247,40,54,102,115,177,51,618,372,476,318,10,89,137,86,249,148,241,263,180,316,352,402,50,403,655,155,19,210,23,94,136,291,308,349,358,237,453,377,111,56,139,425,365,27,341,46,143,277,401,153,588,221,0,186 }, { 7,14,16,46,107,32,35,24,70,60,23,307,172,5,18,2,38,87,92,58,13,21,20,10,177,51,202,77,135,48,37,128,0,97,232,115,171,112,126,43,9,220,140,318,12,141,102,71,852,155,4,54,291,22,90,1,269,52,163,33,137,298,192,28,66,64,217,356,61,132,294,278,359,147,349,461,95,29,45,609,448,121,259,186,314,76,474,304,362,17,108,6,150,415,59,400,780,146,36,342,31,275,67,86,246,402,334,279,678,75,247,50,620,30,409,502,39,372,72,49,230,40,494,227,69,465,872,68 }, { 140,66,97,172,92,7,267,189,14,314,16,69,298,380,60,135,451,230,150,35,24,71,74,357,423,232,330,38,324,246,192,443,278,563,2,572,877,550,462,126,448,52,893,508,67,501,6,568,29,21,603,46,565,607,83,388,204,633,22,279,18,149,723,733,399,65,48,1,95,64,526,915,5,32,726,28,75,36,841,25,350,87,138,108,68,500,895,10,43,0,251,808,125,104,12,426,49,81,50,20,37,309,517,674,86,802,174,107,103,653,173,582,220,226,85,387,26,55,712,903,241,197,121,237,262,54,711,191 }, { 121,167,354,212,132,407,191,107,147,146,271,199,101,446,126,647,195,35,259,18,16,60,55,20,590,465,43,411,68,363,178,198,142,562,9,427,463,92,640,14,346,7,727,798,941,520,364,325,815,5,581,13,1,621,21,23,522,534,0,589,279,158,28,806,706,125,439,109,98,97,118,48,22,694,955,393,604,362,150,932,608,51,105,33,252,165,234,265,108,49,598,156,96,419,818,10,467,197,154,493,12,765,376,120,70,786,169,777,967,102,687,38,202,32,682,246,64,39,31,447,781,612,58,159,61,260,40,450 }, { 76,90,460,205,179,257,245,32,288,184,21,45,769,358,316,524,229,241,152,5,57,48,497,2,476,148,720,619,452,266,72,155,1,17,38,432,14,54,243,290,292,227,449,381,12,4,89,247,50,29,313,645,270,59,350,11,129,216,51,217,106,157,221,128,99,58,37,471,64,188,77,214,408,339,141,115,186,3,369,23,52,202,79,46,428,425,308,6,317,464,7,255,405,162,413,33,171,519,496,372,365,341,269,401,10,0,94,36,137,875,318,263,237,62,588,352,123,474,181,431,40,177,291,180,102,61,207,618 }, { 147,259,427,178,798,581,878,786,198,534,465,325,929,142,362,20,376,43,107,771,35,481,132,470,234,5,626,146,590,279,97,522,49,70,77,345,21,199,640,450,612,202,13,48,14,102,150,0,33,725,595,846,941,23,22,7,58,195,423,660,501,121,687,126,518,260,117,904,120,858,953,39,342,60,455,1,196,165,125,158,105,159,246,92,28,153,10,31,360,315,346,271,761,683,603,212,18,298,128,711,167,379,318,113,623,817,95,32,291,61,16,134,72,359,108,221,197,115,98,163,767,523,493,191,329,30,87,50 }, { 473,778,450,203,855,144,93,617,30,704,141,466,530,330,372,459,201,326,934,321,88,839,254,36,505,403,128,559,83,120,523,217,86,213,131,613,717,110,332,728,344,251,264,352,686,434,82,39,578,317,206,35,625,435,44,795,840,961,539,274,244,116,137,55,662,265,228,863,577,406,96,924,601,564,417,384,351,341,225,95,49,28,800,418,21,831,719,531,367,219,202,31,64,822,224,335,960,968,922,854,829,688,365,197,22,160,410,165,873,752,716,518,456,347,242,125,731,269,180,948,498,478,349,237,98,77,33,9 }, { 523,475,899,730,453,51,23,403,719,13,421,457,33,386,196,817,801,4,120,117,153,11,450,260,102,202,515,361,670,165,758,494,125,108,128,961,283,236,99,21,3,880,5,401,32,59,77,543,615,10,6,318,402,221,183,137,650,57,40,7,2,1,90,847,412,247,241,210,207,115,12,208,181,150,133,114,63,42,467,775,389,342,111,56,39,31,30,28,22,9,0,576,558,304,229,216,177,152,123,113,47,29,25,958,554,391,629,968,967,966,965,964,963,962,960,959,957,956,955,954,953,952,951,950,949,948,947,946 }, { 1,5,15,2,13,0,7,23,10,3,317,341,6,9,4,365,11,115,33,180,217,77,17,64,197,165,102,117,141,40,14,21,51,32,134,12,8,291,901,752,16,569,22,509,352,237,482,372,143,18,498,153,457,59,128,349,269,125,202,177,961,546,31,391,342,196,45,36,873,57,38,28,37,86,48,386,24,19,139,318,111,95,29,44,403,27,719,304,120,41,110,629,93,72,164,275,61,55,253,99,56,90,49,137,730,210,864,758,35,260,76,50,579,116,94,300,221,26,25,277,326,98,54,475,453,30,79,244 }, { 19,119,40,4,27,84,77,56,202,73,102,59,757,33,485,26,300,210,504,494,128,80,862,23,402,63,42,139,880,342,129,32,5,361,25,13,196,51,12,11,2,99,21,6,153,469,123,10,710,53,65,618,64,161,117,736,90,38,22,106,17,803,95,76,0,45,37,14,548,813,250,245,108,297,453,378,162,57,113,460,403,611,255,205,256,383,217,1,235,114,86,742,209,152,292,630,576,240,343,790,667,475,16,48,133,122,18,136,134,85,115,15,283,34,179,436,180,78,29,9,200,605,561,318,49,269,684,495 }, { 32,20,13,21,2,38,5,43,29,23,61,12,52,115,90,6,202,37,64,48,95,207,51,81,66,7,25,49,17,74,26,76,178,147,98,46,362,54,22,63,19,14,0,259,128,577,125,97,58,91,77,56,182,65,197,465,376,27,141,427,316,1,241,291,113,878,217,247,312,137,120,4,858,481,142,595,165,31,237,93,230,379,534,482,180,116,86,72,42,11,44,203,263,470,356,352,279,102,84,40,33,687,626,835,786,107,683,260,18,318,24,414,298,468,367,326,304,216,117,105,99,3,933,612,415,347,501,344 }, { 339,188,11,377,79,4,99,94,12,542,102,111,474,37,51,33,471,453,152,40,475,342,77,403,59,196,277,139,153,57,134,117,13,775,229,128,401,38,880,23,210,64,184,202,431,115,961,157,300,3,266,72,485,402,89,629,21,54,15,129,177,76,14,162,32,17,216,10,148,275,269,5,757,452,361,477,141,90,205,313,569,494,2,65,179,120,257,381,421,237,197,405,86,488,328,36,318,48,22,137,165,413,50,308,0,1,341,130,82,95,49,457,161,543,245,18,304,260,62,45,285,180,291,41,529,498,125,56 }, { 128,283,503,34,318,529,432,176,495,275,231,412,527,291,402,161,381,202,59,3,389,469,177,803,53,585,216,14,269,57,200,17,73,472,27,56,250,136,678,4,152,51,862,361,80,245,11,789,619,194,123,719,401,23,714,84,507,210,77,12,65,322,106,99,436,130,129,46,62,2,13,38,162,369,236,108,33,183,133,457,153,64,483,211,297,741,514,403,114,18,629,961,378,555,440,119,383,597,475,29,453,229,40,165,240,215,196,655,611,556,21,249,117,54,667,134,102,308,814,19,50,86,391,22,0,197,95,26 }, { 15,217,13,341,317,141,365,115,23,51,180,349,291,1,120,77,260,269,202,137,21,5,450,352,373,110,0,372,64,33,36,128,177,4,318,351,102,9,197,2,304,854,10,901,7,12,32,165,326,752,40,244,922,160,96,22,523,117,11,48,16,86,661,90,457,82,386,494,403,308,59,28,55,253,247,18,498,134,8,143,153,221,14,6,83,30,196,93,3,37,615,453,401,898,421,817,24,95,961,285,475,719,873,17,35,39,391,730,125,67,237,49,98,811,704,642,717,216,203,69,482,99,342,402,851,50,57,569 }, { 13,961,15,4,11,12,457,51,3,37,2,197,5,10,569,99,115,23,6,72,89,14,0,1,134,7,59,33,40,38,165,111,196,76,405,79,139,117,148,498,873,339,719,300,277,485,17,471,157,152,128,21,94,431,32,177,188,509,474,64,45,54,482,730,153,36,629,386,41,22,28,141,901,864,18,180,77,523,9,401,678,437,102,304,210,308,16,775,579,48,31,317,179,413,365,758,352,57,24,341,86,752,546,137,58,318,245,44,27,402,95,899,19,108,269,216,202,49,184,110,93,954,880,56,55,452,358,8 }, { 15,13,1,2,0,5,10,23,33,9,7,3,4,6,12,102,115,14,11,217,51,117,77,40,569,153,341,196,317,18,457,22,8,16,961,197,719,180,64,365,165,730,120,134,21,141,899,202,82,31,523,291,125,372,386,28,17,139,93,349,128,304,269,177,110,482,32,342,111,37,318,95,453,579,36,901,59,24,352,450,44,437,137,403,49,260,401,210,237,247,326,817,494,98,99,57,752,19,48,203,30,86,351,485,758,116,402,391,26,898,308,38,27,25,275,801,498,854,65,56,629,76,90,300,922,468,144,35 }, { 76,292,5,214,45,32,2,519,710,460,129,179,29,1,90,58,123,249,464,207,205,618,17,14,245,257,72,61,48,263,106,21,358,425,769,241,119,52,184,6,162,186,50,46,38,7,655,148,209,243,128,255,3,155,288,183,290,64,141,454,227,89,77,476,54,115,4,25,59,19,57,229,36,202,269,408,152,99,70,151,130,86,177,75,592,216,720,62,318,12,217,40,26,10,37,27,496,306,33,247,524,311,316,56,497,350,84,51,137,171,790,102,270,23,0,112,11,22,16,452,334,237,432,402,96,180,95,449 }, { 76,32,72,21,38,4,54,89,57,17,179,12,14,99,148,45,23,59,51,90,488,3,11,241,401,2,428,37,543,152,205,528,453,128,5,421,13,115,129,77,10,474,245,184,350,670,449,413,1,569,137,79,403,629,475,328,308,221,155,464,0,361,123,743,202,460,214,257,33,40,64,794,292,165,405,770,805,41,476,62,162,270,229,358,86,285,36,402,775,316,341,94,197,50,576,106,431,720,46,29,540,217,139,773,119,838,48,15,216,181,657,177,290,514,288,7,457,227,961,9,22,102,247,828,6,141,365,180 }, { 98,223,393,1,834,284,791,264,697,724,293,909,772,905,541,478,51,821,807,363,897,48,682,421,765,447,411,730,801,410,163,948,386,96,9,31,963,23,21,691,664,453,125,5,382,100,13,521,949,551,656,44,116,770,686,670,639,221,39,367,914,265,166,144,719,335,812,848,371,0,101,842,318,321,127,88,252,520,662,329,354,32,759,438,33,698,93,202,593,201,286,156,450,658,281,115,165,49,401,120,604,586,82,2,22,36,225,217,77,744,10,498,141,102,615,180,118,435,69,30,921,404,326,197,433,475,83,70 }, { 341,13,23,509,762,638,569,242,901,629,165,8,197,873,10,961,506,456,391,499,116,338,180,457,492,206,12,51,115,268,143,365,951,1,93,965,642,867,417,37,2,253,546,64,5,203,3,498,758,752,719,0,401,15,352,44,31,7,36,244,86,4,141,386,734,237,6,22,308,730,55,844,164,918,473,326,125,82,564,949,898,551,940,791,120,38,9,260,523,137,661,373,559,110,14,854,959,615,317,11,54,33,102,692,269,99,351,903,89,870,740,217,708,170,824,40,801,728,864,817,717,160,128,28,117,776,479,77 }, { 818,230,755,443,352,420,1,2,244,50,14,5,38,46,29,36,114,218,65,96,22,133,52,181,58,0,17,28,21,103,75,54,45,86,67,175,48,171,7,12,323,137,24,285,208,51,487,6,283,18,10,70,23,155,32,83,194,361,3,503,163,389,328,128,223,37,803,532,16,19,168,735,69,13,124,61,202,160,186,433,9,115,484,27,236,514,238,782,95,25,754,108,64,657,112,141,281,220,412,289,55,756,401,394,584,151,308,49,545,851,822,4,227,717,866,334,269,646,403,402,26,400,87,35,745,366,99,143 }, { 481,878,32,202,5,21,23,269,13,318,494,142,77,51,70,1,182,557,141,137,33,291,58,178,415,465,61,48,590,259,922,115,2,929,640,403,207,884,4,260,120,87,817,626,534,349,342,102,195,0,132,351,59,427,252,109,35,7,961,678,345,247,153,72,845,158,169,49,12,10,6,196,112,798,450,687,279,841,713,475,457,128,40,146,28,3,416,290,265,75,767,854,771,947,795,753,704,637,631,597,592,581,546,509,493,354,352,341,326,316,288,285,241,237,212,197,159,90,54,52,46,38,37,36,17,14,39,9 }, { 15,1,5,4,2,13,11,341,0,3,7,12,10,6,21,365,9,180,32,134,317,197,33,23,37,117,40,165,17,77,217,498,8,752,153,901,64,102,569,141,873,51,14,961,196,115,59,110,352,509,22,128,57,111,120,143,125,72,38,48,372,36,291,308,349,99,139,31,90,202,260,269,457,44,16,89,76,49,55,401,342,237,27,93,177,94,82,18,45,29,326,28,19,386,221,351,137,86,277,546,391,41,50,35,403,453,54,164,318,719,474,629,373,203,98,95,475,854,253,304,148,24,450,244,56,758,542,300 }, { 25,26,119,42,19,6,27,45,122,84,469,4,17,790,814,113,80,76,59,73,483,2,29,611,128,32,202,40,1,77,90,862,106,56,209,33,240,0,684,136,102,14,292,416,5,311,11,504,196,318,123,680,378,255,12,129,161,22,690,151,53,117,63,179,667,10,85,72,61,115,65,210,402,396,57,141,64,614,134,757,153,137,62,18,99,445,51,269,66,177,7,3,24,710,256,648,36,655,235,38,23,306,58,618,70,491,48,454,21,403,742,361,49,34,86,494,275,383,342,28,300,145,13,74,112,52,297,245 }, { 14,7,24,2,1,16,69,6,38,67,108,22,65,28,124,0,46,18,29,86,66,35,83,5,71,398,36,12,168,289,140,95,610,189,150,149,10,21,92,756,52,302,23,109,97,20,584,25,50,267,194,64,49,51,32,60,103,55,505,13,429,172,128,273,420,158,37,458,19,547,118,48,75,115,137,74,135,9,185,164,143,388,154,202,26,701,650,251,133,336,17,114,169,68,230,236,43,54,141,244,671,253,703,105,208,90,3,160,159,278,99,462,314,403,380,87,389,175,357,324,484,318,232,708,125,799,451,886 }, { 128,51,202,23,141,120,403,15,64,13,318,82,10,269,99,33,12,197,475,453,260,153,137,165,196,0,3,402,351,5,494,1,22,14,110,117,180,102,93,17,2,31,37,38,125,9,326,450,49,21,86,44,401,457,7,6,36,352,115,18,77,523,237,28,134,95,285,386,421,719,32,48,342,98,11,54,203,730,57,341,961,373,139,8,854,361,757,111,898,45,4,40,308,194,65,16,922,277,41,880,678,116,291,24,498,19,27,391,143,56,217,899,59,569,30,79,365,775,50,503,208,55,144,817,61,105,901,94 }, { 16,24,35,18,71,68,9,0,65,189,1,7,133,50,69,149,60,28,103,101,108,537,67,118,230,75,114,23,335,55,167,21,124,92,12,191,181,433,13,39,140,5,14,48,223,64,212,96,51,218,443,281,487,154,141,163,22,217,99,37,70,565,2,115,49,267,58,54,394,766,46,246,545,83,30,128,10,330,820,202,32,361,137,622,125,238,237,100,121,77,165,412,175,87,143,352,399,171,317,86,126,745,146,486,418,177,36,291,269,318,283,336,105,302,398,695,4,98,197,180,31,345,251,271,109,309,430,38 }, { 50,2,1,46,14,29,38,52,171,67,5,58,103,96,36,24,218,133,223,83,114,236,45,70,54,181,163,186,108,155,75,28,65,238,334,151,18,433,160,745,328,0,366,112,532,48,516,17,514,61,832,400,281,21,227,22,760,19,6,69,754,766,412,12,7,309,545,409,27,361,283,137,16,220,675,480,55,86,765,822,502,552,32,10,307,99,956,285,25,113,9,398,323,37,51,800,26,388,394,64,891,128,124,243,549,828,3,458,194,208,35,646,95,262,23,311,150,966,820,866,894,149,13,115,87,430,80,287 }, { 21,32,5,76,72,14,17,2,3,38,54,89,45,51,1,12,23,4,10,48,90,137,36,148,221,401,22,0,421,179,115,86,99,543,11,453,13,37,128,270,46,241,285,29,290,64,428,57,6,361,202,59,540,50,403,328,114,475,528,65,155,449,77,308,794,569,181,7,805,27,40,141,292,133,33,576,263,129,514,205,341,9,413,350,208,19,838,629,323,28,430,480,119,657,474,214,741,123,245,402,102,720,15,770,476,408,494,56,425,106,269,62,207,775,243,152,477,670,180,318,197,405,165,95,58,281,18,697 }, { 434,384,268,144,940,855,617,206,959,911,332,116,93,203,137,489,282,244,141,120,36,44,160,269,253,367,110,450,10,127,202,276,417,219,98,258,326,131,260,31,64,373,201,9,187,318,692,473,22,224,523,817,143,86,352,1,55,30,23,51,28,295,567,105,559,499,261,717,811,0,125,951,180,8,115,13,217,128,551,39,165,49,96,341,284,77,21,851,728,564,662,498,317,386,752,48,351,531,5,642,365,197,83,661,237,615,800,291,242,15,170,164,494,82,95,638,704,349,37,854,228,7,32,24,935,968,35,16 }, { 2,5,1,15,7,13,0,10,6,3,180,217,23,9,141,11,317,4,341,17,352,117,197,14,77,33,64,165,134,365,115,12,102,752,237,40,498,153,291,32,372,51,22,21,8,349,901,269,16,196,457,45,569,128,36,143,59,57,509,125,27,38,19,342,86,202,864,873,120,31,546,318,110,37,28,961,29,164,177,95,48,244,111,137,93,391,18,719,139,44,49,82,386,629,54,24,482,56,99,26,453,260,50,579,76,25,304,35,98,253,326,41,55,277,210,72,275,30,730,437,90,523,403,203,351,61,79,450 }, { 113,25,2,29,6,833,45,61,145,7,32,74,151,0,42,1,210,128,177,5,19,4,72,14,64,106,655,59,22,122,26,112,174,66,40,77,738,209,525,402,138,90,148,20,483,104,684,141,51,76,17,27,425,18,21,416,23,10,202,95,16,255,52,13,115,624,318,137,102,311,33,269,85,81,49,887,87,746,544,491,275,86,119,790,454,690,65,24,9,222,216,665,291,117,80,204,58,243,134,48,476,814,217,46,349,287,70,28,285,43,348,36,84,342,11,757,194,91,207,315,31,38,73,153,192,355,135,300 }, { 116,268,918,551,203,692,31,940,403,791,421,206,417,93,499,523,299,44,8,473,23,51,805,22,13,450,120,475,202,0,959,730,386,125,599,326,137,9,10,401,899,105,1,576,817,559,453,564,165,393,494,21,28,36,456,5,127,949,64,670,728,638,391,242,685,2,260,762,457,197,180,615,569,141,170,253,308,963,49,115,341,492,55,143,719,479,873,37,18,4,86,7,77,506,48,244,801,867,95,318,269,901,512,98,951,33,6,301,958,642,338,30,352,870,39,221,365,12,16,395,373,24,237,629,164,102,159,239 }, { 107,612,126,132,362,146,259,199,279,660,493,590,121,20,939,683,534,43,147,941,376,35,595,953,649,581,60,470,640,955,356,522,5,97,195,150,407,49,465,16,92,14,7,687,359,298,22,858,246,0,13,360,21,48,18,427,271,167,423,191,10,441,325,392,32,598,929,28,33,31,178,414,1,77,232,173,55,230,156,125,24,68,23,95,345,4,904,626,105,212,319,98,786,783,70,61,202,142,44,702,58,71,40,314,37,198,51,64,2,623,163,159,819,93,446,158,59,346,357,12,501,118,260,46,663,116,120,102 }, { 15,13,1,2,0,23,5,4,3,77,102,33,10,51,6,7,9,115,341,12,11,217,342,317,14,117,40,22,365,180,120,8,569,18,196,165,457,141,21,210,197,64,177,31,291,153,16,961,59,523,817,453,719,450,134,730,93,260,352,44,269,275,49,386,401,32,901,110,82,28,17,629,125,349,139,475,899,24,128,37,326,111,752,95,202,36,318,403,372,498,216,90,308,247,30,98,482,137,86,237,116,615,300,48,65,203,19,57,351,55,391,509,99,38,734,922,468,244,144,221,854,304,579,373,39,143,758,148 }, { 53,27,161,17,469,73,378,527,136,250,383,19,862,495,62,26,56,200,297,106,84,585,440,80,34,14,436,128,119,45,4,3,472,123,129,813,504,240,483,361,59,444,205,65,611,5,202,548,108,255,742,514,283,78,814,113,179,162,690,57,402,183,38,555,714,6,245,390,122,54,42,803,184,25,61,33,630,318,209,12,194,64,77,684,11,141,328,757,503,269,99,236,2,102,389,51,22,618,176,152,257,453,47,21,48,210,86,680,40,381,148,133,217,880,650,215,46,10,130,377,18,0,412,497,23,114,13,229 }, { 209,45,17,106,207,119,5,255,454,243,263,425,290,655,306,186,84,29,62,61,2,408,136,58,742,378,21,56,311,240,3,592,48,32,383,50,52,80,227,790,270,46,171,14,72,440,148,287,334,76,659,400,666,179,504,496,869,64,155,241,129,1,123,54,38,214,738,75,663,162,90,141,89,221,151,292,57,358,237,507,513,130,34,548,152,70,205,37,128,183,211,184,667,41,229,328,476,266,115,555,181,86,549,405,6,281,163,269,215,12,96,245,11,220,502,720,257,36,313,430,288,180,833,40,202,165,449,27 }, { 152,4,452,59,128,471,529,339,79,216,11,188,377,77,291,202,318,94,102,402,32,33,99,5,90,51,269,76,349,12,184,257,542,474,17,177,111,141,37,21,342,210,23,205,275,678,13,72,403,38,285,3,2,40,64,229,588,57,10,769,494,48,134,45,372,196,117,217,129,6,497,1,148,460,757,245,453,475,0,137,153,157,89,139,7,115,961,292,179,498,304,524,266,197,14,629,431,477,405,775,288,437,180,15,165,214,237,86,401,308,119,123,54,22,221,120,9,162,27,619,300,62,317,316,31,488,277,880 }, { 15,1,2,5,0,7,3,4,6,13,23,115,9,12,51,180,8,317,197,10,961,901,11,22,77,21,752,33,202,141,110,341,14,16,217,134,120,102,31,165,365,40,93,269,457,352,64,44,28,18,37,351,260,117,569,82,308,125,32,196,49,36,153,719,128,482,318,99,17,401,326,137,450,403,203,111,177,730,386,291,55,873,523,373,98,30,237,24,453,89,48,95,221,475,39,59,116,372,349,105,144,139,509,143,72,96,758,391,898,494,854,86,342,899,210,629,57,468,247,90,304,65,148,83,817,421,160,20 }, { 951,752,638,811,642,253,351,180,10,197,341,901,873,352,110,244,143,762,165,8,898,55,564,141,15,365,854,499,82,137,417,498,509,36,535,922,479,559,206,661,373,317,282,115,31,22,338,160,93,569,164,260,717,217,391,86,533,33,44,1,28,9,242,965,728,120,116,77,64,968,21,102,203,125,37,117,506,30,13,386,5,4,531,269,40,911,153,23,0,169,384,2,326,372,105,196,851,170,134,109,704,332,268,349,96,127,48,291,32,758,237,318,24,177,202,35,11,961,401,39,308,83,3,629,51,210,12,434 }, { 6,197,350,74,262,841,509,26,47,115,13,196,583,903,165,4,235,138,50,308,21,130,749,324,675,19,38,331,391,145,711,569,33,75,241,453,734,64,153,223,52,558,236,468,99,220,34,70,112,11,117,546,237,125,3,27,32,1,42,134,409,51,78,25,163,29,14,648,23,645,180,820,46,2,85,108,65,773,802,624,122,394,341,785,22,730,95,386,606,57,412,247,923,316,66,498,357,221,630,133,457,59,853,90,53,226,873,632,48,113,719,629,45,889,17,307,141,766,69,12,37,444,83,171,54,600,5,765 }, { 125,391,165,867,558,386,221,758,23,457,21,51,13,197,401,308,963,115,961,97,719,77,791,743,451,603,949,48,180,670,770,341,89,120,730,352,291,148,450,426,607,304,7,403,393,66,64,350,316,217,134,135,14,421,74,247,177,50,380,24,696,236,172,87,629,10,141,475,144,35,901,801,523,453,138,509,467,456,241,210,150,98,18,565,357,267,103,582,545,342,301,278,237,216,20,16,99,69,903,650,551,412,389,283,81,32,298,739,543,498,370,365,317,309,300,260,170,140,116,85,52,37,33,30,25,5,273,203 }, { 14,1,46,2,24,16,38,50,5,69,58,35,7,75,18,67,54,48,0,155,513,171,163,61,103,45,29,52,430,270,37,223,21,70,12,28,9,780,32,267,60,290,83,227,71,36,666,767,22,189,140,807,10,72,96,65,108,181,64,186,220,309,17,335,92,394,23,592,243,89,536,663,115,281,51,6,474,55,68,112,141,400,128,133,87,13,425,99,741,236,95,675,278,230,76,221,114,86,263,113,820,552,502,27,269,202,49,760,537,149,262,328,408,90,366,137,150,207,77,357,315,307,218,241,19,148,25,66 }, { 23,51,13,115,453,12,0,2,4,10,403,1,202,5,401,475,15,21,457,59,77,165,9,3,37,99,32,11,197,719,308,6,14,64,7,569,17,629,961,318,180,22,33,494,120,18,730,141,40,102,269,217,177,57,16,128,523,450,341,8,90,421,386,237,28,48,125,19,117,31,247,402,72,210,899,221,260,291,134,89,342,317,365,509,38,24,391,216,352,468,817,153,54,36,45,49,27,196,56,326,82,65,76,304,349,139,50,25,86,275,44,137,482,372,670,498,26,734,546,62,95,758,29,41,46,93,351,79 }, { 129,84,17,27,56,495,80,378,19,548,123,162,161,53,469,618,73,26,504,106,40,257,205,59,3,183,184,862,4,136,62,6,128,202,14,77,11,65,769,5,527,108,45,57,383,361,2,497,250,249,200,130,23,34,22,90,402,483,245,240,12,51,214,38,0,139,25,99,64,318,102,152,32,210,300,10,297,757,21,494,880,775,114,710,111,33,54,29,460,403,452,36,42,133,18,61,86,141,436,177,814,269,13,194,119,179,49,28,342,453,217,95,115,514,229,556,76,137,37,1,742,283,485,401,503,488,475,24 }, { 28,109,49,9,22,67,168,158,39,185,159,420,1,55,0,83,35,95,194,272,86,105,69,103,36,114,169,327,50,254,208,175,65,584,286,323,535,346,251,345,797,30,131,756,374,12,333,533,128,2,218,68,96,133,344,160,101,23,64,289,7,597,189,24,646,577,874,896,13,5,601,51,46,503,531,837,16,238,747,627,115,14,347,10,98,310,789,137,124,21,202,127,164,578,54,799,141,154,230,532,547,31,312,708,285,480,37,810,637,596,48,143,336,100,389,835,252,439,237,38,518,912,219,424,44,239,253,868 }, { 242,391,456,116,23,13,492,8,51,341,401,165,93,206,499,457,867,338,268,569,417,509,386,22,1,762,479,638,10,629,918,758,64,551,203,730,901,719,12,31,197,791,115,5,86,14,125,949,0,559,37,2,642,951,873,959,237,961,692,55,170,752,870,120,44,180,940,9,141,564,523,3,308,36,7,4,15,899,450,365,728,137,21,473,253,898,558,143,128,453,740,164,801,260,903,6,685,202,403,670,965,54,114,28,854,326,817,844,352,95,82,498,11,923,244,98,299,922,239,110,38,317,105,599,373,661,160,99 }, { 211,162,248,130,556,57,507,4,305,266,183,41,152,361,11,229,129,471,62,38,377,313,300,514,77,339,184,157,381,59,128,452,99,3,328,40,202,123,54,210,440,494,369,555,342,136,117,542,402,757,64,548,139,23,196,188,880,457,775,33,153,56,14,102,432,13,177,205,257,497,17,12,37,291,51,89,403,215,961,111,141,90,349,216,488,269,485,803,477,180,165,115,10,475,437,383,79,197,95,21,84,134,503,421,86,453,318,308,1,670,76,194,719,618,106,32,629,15,730,65,22,5,245,94,214,45,482,288 }, { 92,7,97,298,140,16,126,232,314,60,246,279,35,173,230,71,107,14,43,508,423,150,779,653,441,607,66,189,359,501,24,362,20,172,104,387,356,21,48,38,18,399,199,330,5,674,192,877,81,191,729,517,74,672,426,939,560,633,0,267,2,649,69,121,149,392,324,135,462,22,95,29,46,52,125,598,37,723,707,49,10,357,68,345,6,32,830,98,64,1,702,380,118,28,900,12,695,251,861,885,493,783,603,146,65,715,61,55,278,36,236,273,138,33,75,25,31,124,175,221,293,83,165,763,712,451,414,319 }, { 15,1,2,5,0,7,13,6,23,9,3,12,180,4,51,115,8,901,457,117,14,165,22,341,82,120,141,10,37,197,961,31,21,11,202,351,64,260,77,365,110,16,134,28,217,93,269,33,44,36,569,18,719,308,450,317,128,102,125,137,32,629,153,98,401,55,352,30,318,373,49,116,898,730,48,17,752,523,196,237,386,24,95,86,326,403,291,99,453,40,39,72,38,177,89,203,873,391,144,247,349,498,899,59,734,90,475,372,54,494,421,143,482,304,854,105,758,35,210,65,76,244,160,216,221,83,45,546 }, { 403,18,0,102,25,523,64,6,91,85,42,74,342,32,24,13,51,306,95,49,22,33,475,151,681,880,421,128,899,750,397,214,122,757,730,77,28,519,288,247,23,5,817,805,317,879,861,673,273,177,145,21,120,52,283,81,275,701,577,453,104,59,202,193,697,636,401,287,249,216,207,196,180,165,138,125,123,118,90,84,60,48,43,587,260,389,16,10,4,1,351,326,318,933,804,635,498,280,237,197,186,172,153,148,137,134,117,99,61,29,9,671,289,958,838,814,579,312,238,124,65,56,847,719,654,650,457,424 }, { 56,65,554,33,561,18,84,123,63,64,343,194,0,90,49,22,6,27,19,289,240,129,73,659,431,214,475,523,370,368,233,899,701,287,257,95,85,28,102,183,736,650,467,256,153,25,207,124,108,80,32,24,120,26,389,874,718,635,51,525,891,752,751,730,648,614,498,496,450,249,237,209,184,177,162,114,59,45,29,235,77,42,817,497,444,137,112,74,53,352,511,681,630,643,196,947,942,847,764,719,696,651,615,610,603,602,543,457,412,386,337,326,312,288,262,260,247,227,226,179,152,139,134,119,117,105,86,76 }, { 127,98,31,293,299,395,44,9,105,0,49,599,284,28,276,116,242,685,159,456,22,763,125,935,272,492,158,1,623,393,109,144,201,39,36,95,18,51,24,320,137,23,286,55,16,512,916,489,202,21,662,301,268,367,327,371,35,761,567,13,434,65,7,101,918,616,2,5,141,737,506,870,12,64,131,68,30,48,900,948,86,128,295,10,219,239,269,910,403,627,338,578,143,14,37,124,160,203,318,384,170,244,165,261,96,347,254,713,963,168,457,237,187,93,67,154,421,221,253,401,344,424,164,479,6,386,83,855 }, { 1,14,5,2,46,50,38,58,171,61,45,155,7,48,69,270,290,24,21,29,75,52,16,67,54,666,32,663,227,72,502,0,425,223,18,592,89,17,35,243,37,207,76,186,103,263,36,163,96,83,741,6,408,10,400,22,181,28,9,428,12,536,64,221,220,70,262,281,23,267,115,106,65,807,292,309,119,148,474,449,394,128,141,86,241,3,655,430,51,189,476,140,431,541,587,95,334,738,675,90,114,13,780,108,71,720,19,133,27,202,335,413,4,767,112,77,25,405,513,179,659,99,218,787,55,180,528,151 }, { 23,51,13,453,457,12,719,401,961,4,629,730,99,475,115,2,11,14,403,17,40,5,15,165,1,3,64,0,10,57,33,21,77,569,32,50,37,308,7,386,9,16,38,670,197,59,41,217,128,494,46,6,758,62,22,775,65,45,18,86,48,29,72,899,514,361,328,139,102,247,153,54,56,421,468,79,523,95,108,757,196,52,19,317,117,482,342,341,24,734,509,210,202,180,177,237,488,402,114,36,134,880,76,498,90,275,111,34,28,291,67,20,474,120,743,125,82,391,130,752,490,437,405,318,277,27,141,89 }, { 968,967,966,965,964,963,962,961,960,959,958,957,956,955,954,953,952,951,950,949,948,947,946,945,944,943,942,941,940,939,938,937,936,935,934,933,932,931,930,929,928,927,926,925,924,923,922,921,920,919,918,917,916,915,914,913,912,911,910,909,908,907,906,905,904,903,902,901,900,899,898,897,896,895,894,893,892,891,890,889,888,887,886,885,884,883,882,881,880,879,878,877,876,875,874,873,872,871,870,869,868,867,866,865,864,863,862,861,860,859,858,857,856,855,854,853,852,851,850,849,848,847,846,845,844,843,842,841 }, { 2,1,29,103,75,52,14,67,46,309,6,83,70,238,38,24,108,220,218,133,74,96,262,36,114,87,388,26,50,25,366,236,69,160,112,5,65,58,66,394,19,145,226,7,532,135,163,42,18,45,150,545,458,433,891,331,357,594,17,28,412,27,294,418,86,278,21,124,398,149,732,894,324,537,283,223,273,222,71,12,606,739,16,646,547,138,267,48,696,171,137,151,0,175,602,800,22,37,487,181,99,208,32,194,287,785,336,64,23,13,113,55,95,335,54,97,323,154,61,711,128,68,302,118,10,308,600,484 }, { 7,92,71,97,140,60,150,16,298,24,189,230,14,149,423,35,508,314,18,43,279,232,66,399,273,246,251,38,607,69,126,172,517,674,2,173,28,375,74,467,104,68,0,809,20,823,336,118,267,175,135,108,191,154,21,345,501,796,36,52,125,653,29,81,330,107,124,362,356,6,387,55,359,46,779,302,192,22,5,575,48,67,877,462,10,388,441,9,566,723,783,221,1,65,49,398,101,37,278,702,83,91,357,705,392,12,109,121,236,426,380,32,212,695,443,86,596,103,868,608,560,165,830,167,13,558,25,541 }, { 51,23,202,120,141,13,1,260,128,21,269,450,77,137,318,48,115,165,15,32,102,5,197,64,180,494,82,351,326,125,291,817,12,349,342,98,523,403,203,93,7,33,854,352,2,31,14,719,457,6,110,144,44,4,386,177,730,96,116,308,99,221,9,217,10,153,17,210,922,453,18,16,402,237,90,704,37,36,117,25,421,11,615,95,20,898,373,30,475,40,401,391,19,317,8,3,304,498,576,69,285,901,275,223,293,247,196,86,899,134,83,341,127,59,45,39,365,216,692,372,50,0,801,752,367,163,139,100 }, { 77,102,33,13,177,23,51,141,202,64,40,128,115,4,269,59,318,6,217,137,210,291,0,7,2,1,180,196,14,22,10,95,153,11,117,125,165,15,86,352,197,134,90,403,216,275,3,16,9,18,237,453,494,342,49,31,19,139,25,65,28,5,17,317,349,93,36,304,475,26,82,12,98,44,341,27,120,365,57,24,20,110,372,386,21,247,457,719,194,402,498,116,29,730,99,260,8,143,144,523,164,114,569,48,32,111,326,285,208,391,401,244,30,509,312,961,300,752,56,160,105,203,34,450,546,67,482,170 }, { 101,9,363,676,264,18,411,682,604,905,520,821,271,167,621,647,364,121,252,404,118,39,166,848,781,265,100,16,382,664,447,212,777,478,354,146,907,812,132,446,360,724,0,60,463,759,24,329,23,1,88,71,35,936,68,857,195,21,48,593,865,639,932,156,897,31,98,96,51,191,13,286,333,125,656,49,694,30,254,105,591,55,806,562,109,158,44,438,419,272,521,124,154,407,274,5,65,310,553,28,144,691,33,116,159,127,93,32,77,22,67,50,410,37,538,108,706,393,115,83,36,92,12,199,327,223,10,418 }, { 144,203,326,382,166,96,822,418,438,93,859,88,921,1,367,141,744,269,349,110,576,473,83,77,410,23,966,21,403,120,692,39,494,274,521,317,291,217,615,523,855,303,817,13,639,264,800,32,100,909,691,225,36,478,914,765,506,5,498,652,44,435,265,321,260,160,910,551,404,137,48,772,202,897,453,450,208,101,960,254,31,863,342,286,190,51,30,593,831,616,419,730,682,98,340,372,341,197,69,33,9,625,724,848,686,284,466,704,656,223,180,102,335,125,617,352,285,363,0,662,244,530,919,812,393,374,351,318 }, { 21,13,180,23,32,115,48,125,197,191,165,51,5,199,237,146,12,225,18,16,93,901,350,271,22,241,375,0,71,118,408,49,447,264,126,1,167,31,24,522,302,98,65,64,575,864,569,92,566,247,744,86,58,391,352,713,212,141,60,44,9,4,88,562,459,308,303,203,202,100,45,37,17,2,818,463,360,316,919,897,698,586,478,363,293,221,213,103,72,40,691,909,608,558,509,166,68,35,727,340,517,217,724,629,546,467,446,341,304,156,120,108,11,640,288,110,7,734,296,150,591,914,346,354,321,317,269,114 }, { 15,13,23,51,102,0,8,77,1,5,12,33,9,4,2,10,180,82,165,197,115,110,18,403,202,22,120,326,457,7,11,351,260,898,141,342,14,373,401,901,961,64,36,386,3,291,453,31,16,40,28,93,21,6,352,59,44,99,27,341,450,217,719,49,117,48,125,475,128,37,391,308,153,95,269,24,318,177,854,730,203,615,421,98,30,32,38,137,922,317,498,704,523,57,817,509,56,569,629,116,899,133,83,365,758,105,752,144,661,196,304,638,494,134,300,670,206,402,221,210,208,86,535,143,65,532,109,35 }, { 77,33,102,64,202,141,128,51,40,196,23,13,117,318,269,153,134,1,177,115,10,342,137,180,210,2,0,95,6,139,403,86,14,22,15,7,217,291,4,352,165,197,36,59,237,275,3,11,5,494,65,125,49,9,453,475,16,19,28,18,120,82,216,17,402,31,93,110,260,326,12,341,194,349,401,203,98,25,99,27,24,457,44,317,365,498,372,26,351,285,719,143,386,450,300,21,752,391,116,29,312,38,114,304,111,244,164,961,509,57,247,569,523,144,308,373,901,34,421,96,56,160,437,35,20,678,32,8 }, { 174,104,544,151,624,74,525,25,644,66,29,177,636,416,0,204,750,122,216,6,81,45,186,222,319,138,2,145,287,112,665,192,64,59,243,7,77,32,355,22,715,128,784,17,173,20,311,135,789,280,52,33,549,113,879,4,227,21,194,90,5,141,491,102,86,42,95,43,137,58,12,27,496,275,65,529,614,11,348,678,304,651,402,580,712,503,269,422,49,37,14,318,210,673,396,202,792,10,18,500,869,36,148,85,426,247,405,681,19,226,97,825,72,16,196,40,61,609,597,115,24,217,233,51,28,881,91,153 }, { 372,141,304,352,947,954,291,177,217,269,349,128,318,437,498,77,678,202,864,64,102,115,86,210,873,137,751,597,247,13,180,5,275,32,16,35,21,950,752,92,197,83,87,7,457,160,776,70,33,24,179,36,317,245,165,126,107,569,288,717,95,402,237,23,263,108,774,156,546,509,340,37,18,12,946,342,872,75,800,244,114,103,851,735,365,341,146,121,99,60,579,312,120,1,195,354,296,140,888,71,51,260,223,418,758,622,537,473,363,196,98,69,10,526,48,820,817,765,704,586,450,316,246,208,148,96,90,50 }, { 200,161,714,53,73,27,472,383,17,440,34,585,62,56,136,250,106,78,527,322,19,862,361,4,3,514,80,84,390,14,176,179,236,378,162,377,129,548,202,47,469,495,217,26,11,494,128,757,555,453,402,412,130,880,328,507,257,183,51,45,5,38,300,184,123,497,54,12,57,33,444,59,556,283,205,245,108,485,297,209,803,152,342,40,119,99,318,452,2,46,102,211,23,196,64,229,65,77,215,684,21,814,6,240,0,153,368,403,90,730,475,13,117,133,61,37,317,305,32,255,813,22,504,181,503,29,436,95 }, { 32,76,72,21,38,14,241,89,54,428,449,5,45,148,37,181,90,179,2,17,221,350,12,292,46,129,48,476,155,1,794,99,477,205,720,3,770,50,464,773,4,540,308,36,57,460,270,245,413,743,184,214,741,328,115,23,123,474,137,257,10,358,11,0,281,431,29,488,421,405,162,51,288,59,64,401,710,536,430,152,290,128,218,519,22,316,697,552,7,587,86,670,361,487,6,227,13,52,618,133,249,543,77,106,62,165,769,141,243,202,403,229,114,453,263,67,475,745,341,119,197,207,497,285,9,40,180,920 }, { 128,141,202,64,102,33,23,77,51,13,196,318,269,153,2,3,180,165,40,137,5,15,1,6,403,10,117,139,197,86,352,134,14,17,0,19,494,210,120,342,22,7,402,237,453,291,177,475,125,115,93,217,95,21,12,82,260,110,36,457,11,65,341,450,31,25,27,194,99,9,4,326,498,275,961,349,26,49,111,401,317,44,203,391,351,277,38,28,386,18,421,37,752,164,16,143,29,285,98,24,48,678,114,116,32,373,509,300,244,208,54,719,56,59,365,57,8,50,546,144,20,523,30,569,372,898,90,308 }, { 39,137,96,840,30,202,9,0,613,88,406,669,100,141,180,576,160,28,49,530,403,1,269,22,228,822,829,679,856,190,244,166,219,352,816,966,765,827,36,55,68,83,128,274,418,23,318,98,44,442,35,10,253,258,51,863,77,31,317,251,21,876,158,494,475,213,95,65,116,254,859,268,125,48,13,16,931,187,367,131,805,574,105,5,365,800,102,177,93,115,33,224,127,242,120,110,291,924,217,960,144,64,842,616,165,531,385,351,101,159,276,839,778,203,201,492,109,67,24,284,748,860,345,692,295,421,272,456 }, { 180,352,141,752,1,901,269,365,115,5,217,2,15,4,317,23,197,7,13,341,0,244,3,253,6,51,498,202,21,318,31,372,873,165,44,77,98,9,33,10,116,137,237,93,482,125,64,864,105,12,32,48,349,509,128,131,22,120,579,11,143,8,102,569,717,37,391,177,260,127,308,110,28,30,291,450,40,559,49,39,401,160,203,144,14,437,373,564,72,24,453,403,386,546,421,96,326,16,95,36,148,661,951,247,533,494,219,109,201,159,55,961,251,475,728,468,642,117,254,221,134,18,811,153,210,82,345,224 }, { 1,67,28,50,46,2,103,83,14,65,114,24,0,38,133,69,36,55,18,75,9,54,124,29,22,283,7,218,5,238,16,154,35,52,96,160,480,109,108,547,12,68,398,429,646,323,181,732,175,220,21,361,171,71,335,236,389,418,70,394,48,49,149,86,58,866,531,87,309,366,37,484,208,328,251,118,194,6,10,302,412,487,420,189,336,23,168,545,800,51,803,433,185,137,128,163,754,39,45,505,169,285,596,486,13,503,533,60,101,155,95,64,32,289,570,223,158,267,927,140,745,516,17,115,514,346,956,99 }, { 180,352,365,317,115,217,752,901,341,1,253,141,873,2,15,4,0,5,197,3,244,308,951,31,7,498,318,44,6,372,291,165,269,202,98,137,120,127,160,36,116,373,105,260,482,13,131,33,509,110,51,125,77,39,569,349,304,437,9,11,8,450,96,64,22,21,391,221,23,93,638,717,28,219,12,421,10,403,187,83,17,102,49,661,564,851,401,128,247,811,351,523,117,535,546,468,224,201,86,35,559,48,16,148,494,134,143,579,968,922,854,817,800,551,475,55,801,758,728,615,196,177,153,144,14,32,30,533 }, { 32,5,21,347,13,95,49,713,51,48,197,23,107,60,126,64,237,180,153,77,165,241,33,379,850,1,263,296,196,195,4,121,134,132,102,28,115,22,117,217,0,291,16,841,929,928,652,534,660,39,493,247,31,279,18,50,36,626,150,90,76,40,407,883,509,362,349,260,9,356,125,10,177,92,441,340,259,35,24,752,351,199,65,11,71,809,546,953,933,854,312,75,61,56,37,30,7,598,207,44,423,372,298,522,783,590,354,156,645,608,591,939,937,638,498,450,437,391,359,303,273,86,57,342,316,59,640,446 }, { 341,365,180,901,317,115,752,15,873,217,564,82,951,197,110,165,0,1,141,351,4,3,482,352,6,372,2,12,269,13,10,559,253,854,5,468,7,244,282,23,535,18,898,14,661,417,349,308,318,102,33,509,125,811,704,36,143,77,964,28,498,326,237,137,51,533,692,638,38,475,31,22,9,642,867,391,30,8,202,120,203,966,758,373,338,206,24,569,291,922,494,403,332,144,116,49,44,697,55,450,386,128,943,842,768,728,706,405,346,299,295,261,260,258,242,160,148,39,27,26,19,17,11,50,48,46,843,634 }, { 45,17,106,21,227,209,62,243,5,155,32,3,290,38,255,119,54,270,14,2,207,181,587,48,263,12,794,29,46,552,540,186,659,37,430,408,770,496,721,50,454,136,84,52,221,425,56,76,308,828,99,697,400,328,115,123,741,80,488,1,528,474,401,57,218,281,41,129,541,513,421,36,487,128,10,787,61,241,378,477,543,64,51,742,306,133,240,413,11,72,428,4,165,734,23,152,655,453,211,34,920,311,59,90,236,137,214,58,162,629,431,179,832,341,6,366,583,89,77,202,313,361,383,317,514,86,745,365 }, { 16,24,35,18,50,7,71,75,60,14,69,0,9,1,189,108,68,67,21,181,28,12,48,223,92,5,23,140,46,103,51,133,13,2,267,230,54,163,149,65,22,335,70,281,10,32,55,96,87,37,64,171,128,394,114,141,502,58,115,486,236,99,820,98,766,202,38,137,83,309,118,246,269,49,36,95,125,191,155,167,121,430,39,218,101,77,6,150,237,126,641,774,31,318,221,487,180,443,177,433,251,545,220,565,388,29,86,72,352,399,165,217,552,112,61,105,537,17,852,45,44,30,212,175,124,89,307,102 }, { 127,308,293,98,165,395,258,219,13,286,23,629,401,51,115,301,569,197,457,276,512,391,509,105,616,239,924,338,22,734,170,55,961,295,31,758,169,910,272,567,116,763,201,320,944,341,143,261,237,506,180,479,873,365,141,185,206,36,242,86,374,762,498,546,913,131,44,64,923,327,843,601,386,332,492,160,125,860,317,654,964,900,284,95,28,634,943,164,137,10,901,282,224,740,468,456,144,109,841,558,719,268,120,417,535,384,299,844,482,903,110,93,9,1,935,662,578,217,253,928,730,187,393,2,752,244,531,434 }, { 748,957,840,213,669,539,466,88,30,251,863,321,217,679,190,137,93,144,317,530,352,831,228,230,160,617,800,689,219,203,816,96,418,202,36,473,258,406,141,871,326,83,855,752,120,854,778,82,44,100,187,201,1,435,224,351,345,719,335,116,110,443,274,28,310,55,21,450,332,382,822,574,86,931,494,531,365,31,839,128,39,180,341,367,898,23,613,498,372,731,860,9,410,926,197,704,5,817,131,69,35,125,434,166,22,944,318,924,856,268,64,48,567,244,206,291,922,523,269,32,876,717,98,49,13,349,169,859 }, { 5,48,21,14,1,2,54,50,36,430,38,32,181,270,45,281,12,72,17,67,46,0,290,218,99,22,28,83,76,155,24,541,37,10,513,89,114,65,58,133,61,103,96,488,51,221,425,263,3,9,328,29,23,487,697,207,741,115,18,86,745,160,428,474,148,408,6,16,502,7,64,171,137,794,108,52,920,477,842,227,55,236,552,543,13,119,514,361,449,202,238,828,536,128,308,292,476,243,592,90,241,186,179,666,285,4,27,655,663,480,421,401,106,208,141,165,433,528,532,19,834,95,283,197,11,180,720,403 }, { 13,23,51,115,217,33,77,0,4,2,9,317,102,141,7,11,1,10,180,5,40,202,22,197,3,6,352,365,12,269,341,165,14,18,16,28,64,15,59,318,177,403,752,31,24,196,308,32,372,125,128,291,498,137,17,247,153,21,49,401,453,349,98,117,44,8,95,237,901,36,86,93,494,342,475,30,482,210,468,457,304,873,569,90,105,143,421,391,386,37,509,39,134,139,110,116,35,275,244,144,120,326,55,961,19,546,203,46,864,27,719,221,111,65,164,253,285,216,127,402,730,50,437,38,67,20,288,54 }, { 13,23,165,15,37,54,134,12,117,38,457,51,64,197,99,115,153,89,961,719,33,10,82,509,14,128,120,237,3,196,308,86,141,328,0,1,629,72,450,277,139,102,523,386,351,77,8,401,65,4,546,95,155,202,180,21,2,498,391,40,352,7,5,32,11,6,730,474,31,475,110,137,899,854,453,922,569,291,114,108,22,898,44,9,177,403,148,49,361,342,285,260,514,269,93,17,758,901,210,864,479,59,34,29,28,67,217,494,318,236,179,90,76,56,50,18,242,417,528,488,206,98,413,94,817,789,468,402 }, { 5,21,32,14,2,48,17,3,1,12,72,38,45,54,51,10,36,22,76,23,0,89,540,13,137,86,37,4,430,270,50,114,11,221,99,285,115,64,6,61,46,361,29,181,290,65,58,403,208,155,28,133,480,281,148,128,323,453,657,401,514,541,754,421,697,202,90,9,7,475,241,263,40,56,328,308,95,59,207,576,805,165,838,513,57,27,402,19,425,18,775,488,119,283,218,741,428,341,24,141,77,33,794,408,227,197,102,194,52,179,832,55,180,494,269,365,449,164,236,350,745,318,171,859,244,474,108,880 }, { 202,318,77,291,128,275,102,33,269,342,177,210,402,678,141,403,494,40,20,196,0,137,7,23,49,32,64,216,4,416,104,139,285,59,352,43,61,66,13,304,234,90,22,475,319,450,11,349,117,300,113,5,153,58,947,17,112,21,6,115,120,70,544,38,16,142,2,315,194,134,95,18,498,9,74,597,237,51,329,884,25,12,453,864,24,789,173,415,639,859,155,277,52,81,86,222,178,10,48,560,14,230,665,198,97,31,355,557,65,1,186,105,817,111,39,226,57,546,121,29,147,28,15,87,60,96,265,523 }, { 1,24,46,2,14,67,69,75,103,38,35,50,52,83,29,108,18,16,71,220,149,394,309,236,189,70,96,133,171,54,68,366,28,58,5,238,181,163,87,7,433,0,335,60,218,114,251,487,65,267,537,36,328,418,223,9,486,55,516,262,112,150,155,12,388,48,21,45,675,175,336,22,409,118,37,186,281,140,412,696,6,124,25,514,151,294,61,99,154,10,334,32,17,273,92,135,160,283,760,278,458,227,766,64,307,19,86,361,398,230,552,641,532,400,137,565,23,502,345,51,13,95,765,26,66,72,128,399 }, { 15,1,5,2,13,0,7,23,6,3,180,12,51,4,9,115,457,165,197,21,8,14,141,901,37,752,117,16,77,10,32,120,202,11,317,217,110,961,22,33,365,341,82,269,719,93,352,31,102,18,128,153,134,28,260,48,569,64,137,40,318,196,386,351,509,17,44,30,326,125,730,308,450,49,177,36,95,453,89,72,98,99,203,873,523,401,498,403,59,291,116,38,24,629,372,90,349,76,55,391,373,144,758,494,237,244,96,482,475,54,854,39,468,143,45,139,105,221,247,86,899,50,148,253,35,210,304,421 }, { 28,65,124,14,0,154,24,67,69,55,175,7,9,429,46,2,109,35,149,336,68,1,189,83,114,251,108,16,133,398,484,103,36,18,38,22,50,267,420,140,283,289,71,570,158,236,389,101,505,230,86,346,185,39,12,169,168,799,194,118,49,596,29,732,782,302,309,5,533,52,252,95,388,419,535,21,439,458,705,75,797,160,412,6,10,54,531,218,92,345,208,96,159,610,48,60,64,323,756,105,37,23,646,238,51,128,329,886,547,278,13,650,637,32,172,135,364,164,143,584,602,115,701,601,137,333,399,443 }, { 162,403,56,775,129,880,161,527,99,3,17,40,33,475,23,4,361,128,196,14,200,183,34,202,102,184,548,402,383,53,130,153,757,494,27,257,108,453,38,12,136,117,51,485,123,64,57,65,19,585,141,73,13,139,421,134,229,106,11,80,556,469,670,84,59,152,62,78,714,412,378,77,5,495,21,54,236,488,497,2,6,90,514,86,111,730,22,180,26,46,507,440,95,269,37,472,115,32,401,45,283,452,618,0,328,47,18,29,266,390,10,211,165,899,250,24,300,862,719,504,133,543,197,318,277,50,176,457 }, { 151,29,112,2,58,311,186,52,70,113,315,45,66,74,61,631,5,87,287,243,491,209,1,869,6,227,614,135,7,307,75,80,27,145,496,226,25,454,17,14,549,26,845,19,32,46,73,106,294,163,155,64,255,659,849,667,632,644,592,72,220,331,21,334,222,172,42,69,400,48,76,138,396,337,148,635,50,86,611,445,128,171,97,122,141,95,738,119,16,37,38,4,207,67,425,290,409,53,24,65,262,89,90,12,297,278,192,461,137,22,624,36,20,483,881,84,292,684,43,10,833,56,651,655,114,263,204,115 }, { 6,74,75,1,70,66,138,29,25,85,26,42,87,220,52,2,135,226,222,802,324,112,145,357,103,19,278,108,380,67,114,309,235,14,500,69,451,133,606,280,38,24,582,83,65,262,163,86,97,394,294,267,486,96,50,36,889,388,603,641,58,256,32,895,238,223,853,45,122,594,46,537,64,21,204,150,27,335,792,102,7,115,337,218,13,418,71,33,160,632,5,189,696,571,308,461,95,565,16,545,331,125,4,137,134,153,113,117,17,35,558,54,287,149,22,171,18,711,174,630,247,63,12,23,0,194,462,90 }, { 15,13,23,51,1,120,0,180,202,5,260,9,2,102,450,115,77,7,141,12,21,269,318,197,137,523,403,6,165,326,33,351,341,817,110,901,342,128,365,36,14,4,16,457,308,401,18,494,8,48,32,59,64,82,352,22,475,10,217,386,730,317,28,93,37,3,373,854,453,719,752,31,615,24,44,30,421,291,11,210,221,39,899,99,96,961,55,86,98,40,116,177,402,922,160,898,244,203,35,576,17,569,117,509,144,391,90,49,372,704,349,153,873,285,498,253,275,125,89,143,300,196,72,247,67,95,629,127 }, { 5,45,17,14,46,2,50,48,186,181,227,61,29,38,155,281,54,52,80,106,400,209,21,58,3,171,243,487,540,32,328,311,103,218,133,430,255,62,67,12,828,454,36,56,536,236,27,1,207,496,787,119,697,366,114,37,19,108,6,760,513,541,600,587,592,84,745,842,99,920,96,502,151,76,13,26,270,583,263,86,221,115,83,832,666,51,23,136,34,334,65,10,290,72,308,137,663,869,739,361,514,25,721,738,794,4,659,543,89,401,667,11,64,576,378,148,22,24,834,0,474,357,73,483,754,516,41,53 }, { 18,16,35,60,68,121,265,158,159,24,329,105,9,132,167,252,327,709,101,55,286,39,21,71,146,49,7,109,374,23,22,126,604,107,419,333,271,14,28,1,48,0,191,120,92,212,20,310,272,890,553,118,5,326,137,199,260,455,51,95,446,320,13,32,450,259,170,627,621,639,2,10,195,647,128,98,364,301,557,463,43,37,239,77,576,848,64,100,351,82,102,125,65,285,202,12,354,6,363,346,178,344,197,165,493,407,147,29,523,242,907,96,538,932,403,33,279,916,97,704,36,31,402,520,318,156,912,846 }, { 467,650,389,108,283,56,412,123,177,216,670,619,349,269,33,475,899,775,453,503,789,401,678,65,543,51,196,403,730,128,84,23,194,523,13,421,719,576,457,11,597,153,880,141,249,847,3,801,117,817,57,133,18,0,202,114,59,24,150,32,386,64,40,95,291,4,183,450,130,524,162,5,554,152,90,22,9,361,134,236,102,17,27,120,304,19,961,629,210,432,21,770,86,16,14,10,77,165,46,28,594,381,377,240,137,26,229,494,947,372,602,342,318,275,125,98,630,743,701,605,184,103,97,63,50,49,958,444 }, { 514,11,377,328,361,3,4,880,507,403,485,57,130,14,757,152,38,102,300,211,556,215,54,176,236,62,229,56,494,40,585,555,266,34,183,59,342,12,162,440,453,548,51,37,77,402,488,305,184,196,542,421,775,471,123,527,210,369,313,33,457,136,719,23,202,231,13,128,153,381,629,452,803,543,129,412,157,17,248,339,111,84,139,497,475,205,99,119,32,828,188,177,961,349,383,117,46,89,79,730,216,504,277,401,161,134,308,291,322,76,249,283,72,65,64,21,2,22,670,503,241,41,257,90,108,618,472,94 }, { 3,555,62,266,507,215,130,440,99,514,229,152,471,40,57,139,403,12,56,548,305,33,475,38,313,775,361,14,123,211,880,328,196,102,23,556,381,184,136,757,377,77,277,54,183,494,453,421,4,11,205,349,291,129,162,452,34,236,84,17,369,37,59,485,497,111,401,402,51,153,157,477,585,13,670,128,117,339,176,161,41,488,248,202,383,300,457,249,119,76,432,46,342,134,79,188,89,214,2,474,72,527,961,21,32,308,719,543,165,177,257,730,412,133,413,64,283,216,210,245,106,618,803,90,15,629,115,460 }, { 120,318,450,260,77,15,202,13,817,51,269,5,33,494,922,128,1,326,102,23,403,523,137,141,21,177,351,40,342,48,291,82,854,153,125,64,7,615,32,196,22,704,210,402,98,4,475,12,373,115,93,2,96,453,285,44,275,349,36,61,31,116,216,859,197,117,49,28,16,899,678,203,165,59,90,180,139,50,24,6,144,217,95,898,692,170,110,45,18,17,10,0,730,352,72,37,207,457,576,341,237,35,20,9,661,372,194,961,223,214,958,949,811,805,791,551,424,391,365,244,242,221,208,160,127,99,89,76 }, { 23,1,15,51,13,2,5,0,7,6,180,12,9,115,21,3,197,165,4,457,386,120,141,33,202,453,14,730,523,719,401,37,40,32,341,8,31,403,260,82,450,352,16,48,110,269,317,77,217,308,44,137,22,102,18,365,318,901,93,351,421,117,475,752,11,326,28,391,49,98,153,498,128,99,64,30,569,10,899,509,36,196,961,24,221,59,39,89,177,758,854,134,494,116,17,629,90,817,670,468,86,247,72,95,35,105,96,203,482,55,373,125,372,873,144,210,922,291,38,244,237,898,54,50,20,349,615,65 }, { 15,180,351,317,82,115,365,217,141,898,10,854,901,197,143,77,23,752,341,352,33,110,13,36,64,102,51,4,1,260,253,244,120,9,21,5,22,40,498,55,165,137,117,28,11,873,372,922,482,134,59,0,72,153,196,160,32,48,202,3,2,961,90,12,35,811,164,291,177,349,31,86,30,308,7,125,509,642,450,128,6,139,17,96,210,237,89,951,523,342,457,93,730,57,37,39,661,16,83,437,373,546,269,49,18,14,531,8,717,318,111,45,24,569,247,76,533,719,221,67,326,282,468,386,203,52,44,38 }, { 104,289,707,66,712,173,97,214,90,64,426,20,874,414,568,43,65,32,194,715,7,204,312,560,74,500,192,835,324,0,38,376,819,861,147,319,95,636,22,86,729,21,470,879,288,5,107,526,52,81,178,2,751,49,10,519,142,595,427,247,77,356,232,249,4,750,237,597,28,885,784,36,889,858,51,202,802,14,135,298,115,13,59,524,808,1,330,325,23,92,180,359,392,31,24,583,681,61,18,259,172,48,177,123,825,798,37,357,12,208,33,174,387,362,140,102,35,76,40,17,137,198,11,216,600,16,671,91 }, { 84,65,56,18,194,249,0,108,123,643,847,554,63,524,416,141,453,24,26,403,22,511,467,630,475,128,73,137,33,9,80,899,95,64,370,76,45,16,133,42,289,19,650,214,27,240,730,719,210,196,119,114,49,494,402,304,102,90,32,11,10,588,561,283,235,202,523,183,25,736,609,580,576,500,457,433,357,349,343,209,124,60,57,39,28,3,1,757,150,23,368,670,51,597,947,813,667,659,529,431,291,287,243,236,233,216,179,177,153,134,122,117,112,89,85,72,31,30,6,421,389,165,125,895,874,619,519,361 }, { 21,350,308,13,346,197,826,352,101,841,570,68,165,509,23,115,100,694,749,569,903,51,212,401,9,0,221,734,391,154,777,252,88,124,610,265,237,39,558,125,48,30,217,230,421,35,289,468,64,55,535,475,213,546,175,909,1,403,382,166,589,28,645,812,419,180,32,706,98,593,410,703,759,141,317,629,65,241,83,194,818,773,22,321,752,689,923,341,962,96,671,699,158,95,16,329,429,854,264,724,190,439,31,722,316,72,900,144,10,93,247,49,831,676,372,24,223,36,553,269,293,69,365,490,191,5,639,251 }, { 92,16,60,24,7,71,126,18,35,140,330,14,246,46,50,267,121,146,236,108,75,220,199,571,394,68,309,150,132,107,314,448,230,54,232,633,5,366,118,2,21,9,278,38,388,37,87,64,1,181,328,12,641,55,70,672,582,726,48,526,0,622,172,516,563,86,69,32,103,10,133,36,156,167,28,65,101,135,195,52,171,950,149,22,830,189,99,649,191,451,67,13,29,262,294,606,83,545,58,517,462,271,23,572,95,163,696,128,675,594,620,392,514,77,785,45,155,192,217,653,335,279,522,212,237,51,177,565 }, { 15,82,898,365,33,77,341,180,115,901,21,10,102,197,55,5,4,351,13,165,117,36,11,1,217,23,317,141,40,752,120,153,450,134,253,12,2,260,143,196,873,51,89,457,32,3,177,352,349,854,372,244,160,59,7,719,961,64,202,96,6,110,291,137,523,498,111,0,210,482,28,31,30,17,951,125,318,22,128,509,139,811,730,386,169,304,9,391,37,164,48,326,269,203,93,373,237,148,535,342,72,569,704,308,247,38,533,49,98,922,86,734,109,14,45,275,216,95,817,403,44,437,57,899,661,41,39,968 }, { 16,24,35,71,18,68,108,140,189,69,103,60,267,50,149,118,230,7,1,133,191,92,46,167,9,75,246,0,2,443,309,236,486,335,14,54,212,330,218,516,65,67,38,394,641,21,181,55,28,101,48,83,399,366,563,412,545,114,220,696,388,51,328,13,23,5,64,458,273,124,126,12,238,487,52,345,37,537,87,121,29,915,723,150,175,32,302,154,163,361,146,375,674,22,10,171,271,96,514,251,86,433,70,336,36,571,622,223,906,796,237,726,398,602,283,39,262,115,702,565,891,58,695,562,199,128,894,49 }, { 60,20,16,43,7,71,18,92,118,14,35,628,608,68,154,28,375,126,175,107,0,279,150,173,22,356,97,149,566,55,153,169,49,140,69,33,13,230,117,38,23,10,362,51,2,77,783,414,421,109,298,246,359,196,125,124,446,102,104,386,722,66,21,1,601,575,621,326,439,429,12,392,134,32,882,192,74,345,551,533,419,185,336,191,4,232,37,273,595,81,189,791,314,202,158,917,576,467,570,6,5,302,48,422,115,801,319,197,165,677,535,925,420,387,9,423,399,251,517,515,403,291,199,260,694,553,64,40 }, { 187,258,871,295,434,489,219,201,224,268,839,384,699,940,110,261,116,160,131,44,36,574,228,144,141,93,137,567,406,244,926,120,98,253,260,373,64,442,206,269,127,908,318,55,31,911,959,855,617,10,1,531,332,523,202,613,203,661,326,352,860,217,717,367,276,21,51,143,180,96,23,105,13,450,22,385,533,284,662,197,851,86,77,251,30,115,83,9,48,816,164,282,811,317,365,39,856,165,351,843,669,473,899,341,125,922,902,752,291,817,372,918,345,417,177,728,82,293,242,951,498,968,854,386,559,15,349,49 }, { 66,97,7,172,192,712,232,204,324,387,74,426,448,526,104,173,107,568,560,43,356,825,808,500,729,135,359,52,707,92,32,95,330,20,636,64,65,22,140,38,138,81,298,2,289,715,885,5,802,392,29,49,14,174,0,889,91,86,226,348,90,750,861,6,357,280,314,312,126,214,246,792,353,10,36,24,380,580,21,835,37,28,414,58,230,69,222,595,362,194,673,16,278,12,77,85,33,46,874,18,819,61,60,681,147,858,888,612,600,13,241,25,501,102,48,35,67,189,87,71,40,4,583,519,779,1,237,150 }, { 15,1,5,341,4,13,0,3,2,134,33,12,11,7,10,77,6,9,21,23,40,197,8,32,365,37,17,901,111,102,51,117,180,317,961,153,217,165,59,14,22,16,82,141,31,457,94,202,115,291,453,403,196,57,36,372,475,318,719,28,349,18,401,72,269,99,48,386,110,498,64,494,120,352,93,351,54,139,27,509,474,177,45,44,30,670,90,421,326,76,56,89,128,898,642,629,304,260,450,19,482,137,29,55,391,873,342,24,49,730,203,62,373,143,210,79,752,41,39,758,661,817,157,152,98,523,579,402 }, { 0,24,35,28,124,68,9,154,65,16,109,149,55,175,158,71,39,252,7,419,14,108,101,346,168,22,185,289,429,49,18,420,169,67,439,671,703,336,302,1,159,92,610,962,484,118,333,95,69,2,677,398,344,100,364,810,272,345,105,46,329,114,60,535,265,327,577,30,10,189,21,12,254,286,133,194,83,23,140,793,553,86,36,50,570,637,13,103,5,722,310,51,374,230,48,38,64,32,747,706,505,701,273,251,150,164,601,455,166,627,143,634,125,283,424,239,458,799,128,246,267,388,547,6,137,96,37,538 }, { 7,92,14,16,46,140,220,60,35,24,2,126,38,87,75,278,71,172,262,135,52,314,107,54,294,246,394,150,18,50,330,29,309,267,230,171,1,70,232,108,21,5,121,620,97,236,69,622,32,572,563,950,366,409,58,199,12,48,64,328,37,571,189,146,448,132,66,68,155,872,112,192,461,67,441,181,675,279,13,298,28,226,0,451,23,163,423,606,9,582,128,20,86,526,36,334,307,55,380,462,888,357,335,61,43,10,22,45,83,337,331,186,353,359,103,726,133,633,95,51,65,202,72,74,785,114,141,149 }, { 92,7,126,16,314,172,60,140,35,135,278,14,232,2,107,246,46,150,330,24,66,38,71,230,52,380,97,298,279,448,563,192,357,262,199,121,87,18,582,309,462,441,29,75,74,132,220,5,146,451,526,324,423,50,21,550,69,32,68,226,508,1,70,37,633,64,12,108,606,267,48,572,493,54,189,726,366,0,392,359,22,95,43,58,571,603,28,10,20,86,236,55,171,600,36,9,388,163,65,607,387,6,67,49,294,649,830,583,356,362,90,622,394,620,167,259,939,149,443,83,580,114,25,103,118,672,61,45 }, { 235,26,53,297,6,436,73,113,27,445,42,25,250,611,90,19,65,214,648,614,85,624,289,64,122,200,491,684,416,32,17,194,45,665,145,34,80,95,573,151,112,322,86,680,714,315,630,106,690,14,29,472,255,141,396,56,312,57,22,247,76,209,4,128,61,288,123,84,352,249,11,874,108,3,138,5,217,256,70,119,59,74,0,835,283,161,114,751,269,597,525,389,136,77,51,10,40,115,287,47,2,52,78,176,881,62,13,524,519,23,137,33,133,28,46,177,746,311,18,236,12,63,180,453,237,631,179,243 }, { 352,141,752,854,36,1,351,217,230,244,661,110,816,258,160,224,180,219,82,201,269,567,144,295,260,373,922,93,120,203,489,64,35,202,406,317,206,699,137,116,268,871,717,10,839,251,434,228,864,253,326,96,21,131,9,30,83,384,44,442,39,450,574,69,332,48,318,418,728,898,55,127,187,642,365,86,276,88,28,341,831,498,22,901,443,100,367,523,128,531,940,213,5,689,748,190,860,679,0,31,811,843,559,164,7,669,143,662,851,77,564,372,165,335,98,800,261,2,959,349,284,170,115,291,824,345,50,855 }, { 126,60,16,35,107,18,191,121,68,92,279,446,598,463,375,43,167,493,7,20,118,199,212,566,14,150,97,28,575,608,589,55,407,101,246,154,146,24,346,21,0,175,48,71,362,815,354,49,628,132,939,5,467,22,649,10,9,1,356,259,147,271,149,783,439,140,23,108,32,109,230,376,683,125,13,621,345,441,363,31,51,647,612,273,124,562,173,695,768,105,38,252,2,727,169,818,640,195,755,590,637,158,722,364,104,37,953,535,12,44,64,66,359,33,202,806,298,46,419,98,221,95,77,185,660,399,653,520 }, { 1,15,2,5,4,3,13,0,23,11,7,6,341,115,77,51,10,9,12,33,180,197,102,40,217,165,141,365,901,21,317,32,202,8,14,64,177,22,269,352,59,17,291,31,569,318,125,210,16,93,386,453,196,457,401,18,494,403,153,752,37,28,475,961,117,110,498,120,342,523,139,116,629,44,326,134,349,203,98,372,49,128,275,57,308,48,237,391,719,30,509,24,95,36,86,19,421,260,758,247,90,730,615,216,137,373,450,873,111,482,144,29,899,304,817,670,25,300,143,801,55,20,244,82,45,27,39,242 }, { 51,23,13,202,21,5,403,137,32,141,318,128,1,120,165,125,12,48,15,475,269,180,453,197,115,64,401,33,2,7,450,6,523,308,260,421,221,4,494,37,386,99,16,14,196,457,730,237,93,817,102,77,61,82,352,9,719,98,110,10,20,899,326,19,18,3,117,90,17,391,402,95,0,341,31,11,217,25,961,629,351,96,134,72,49,153,30,26,569,801,203,372,40,509,24,50,317,285,27,758,116,349,342,70,59,58,76,39,44,291,89,57,45,29,854,28,22,144,177,35,194,576,86,670,54,365,678,247 }, { 131,716,371,224,737,385,219,254,616,924,836,187,258,98,761,916,944,127,39,105,442,578,9,49,272,31,688,44,116,242,137,871,908,159,395,518,890,28,293,284,574,202,623,51,160,23,0,201,276,36,827,938,839,22,333,125,456,299,286,144,109,438,158,13,95,910,64,30,829,228,327,166,101,1,860,926,613,96,86,512,846,310,21,295,10,406,55,318,252,320,93,843,128,301,627,567,203,165,48,662,492,100,268,37,531,457,221,190,434,403,68,384,421,239,393,261,902,35,533,169,170,120,110,260,244,308,5,506 }, { 15,5,1,2,3,4,7,0,6,11,13,10,180,197,12,217,341,141,33,134,77,17,165,9,352,40,365,32,317,64,498,752,102,21,117,901,59,14,237,8,23,291,349,36,864,269,372,153,57,37,82,961,22,115,569,196,120,509,873,342,202,48,51,351,110,16,93,45,31,457,125,19,76,72,111,244,27,260,128,143,318,79,546,56,139,28,18,86,44,98,90,391,94,61,55,854,95,38,386,29,482,898,49,99,89,253,210,177,137,730,450,35,221,84,25,304,954,758,326,922,474,403,203,20,373,50,247,523 }, { 66,74,192,173,222,226,174,7,29,712,52,204,353,43,20,500,2,138,145,97,104,673,426,355,6,64,560,87,0,580,331,172,414,90,32,25,337,65,22,49,135,825,861,112,280,5,287,81,95,525,86,21,707,42,38,792,415,85,750,889,356,36,324,819,10,632,232,45,526,330,1,107,544,91,319,140,746,151,294,194,58,92,28,14,67,289,4,636,115,37,17,12,262,715,470,16,155,59,27,61,233,387,298,18,376,568,216,26,122,69,77,113,24,23,888,70,13,114,51,75,448,729,11,609,102,348,312,33 }, { 786,259,5,534,590,493,465,929,581,21,279,941,49,13,612,132,32,362,23,147,61,48,35,121,939,626,683,146,178,107,771,687,408,347,713,345,58,427,126,70,18,60,4,197,878,150,344,640,379,1,195,841,33,120,263,356,51,509,522,260,28,22,0,115,55,10,376,663,207,350,199,16,423,142,407,221,156,246,623,595,241,105,31,903,298,11,71,68,95,92,64,17,40,450,441,90,167,308,165,518,44,783,316,247,953,360,351,98,30,102,82,65,159,955,290,87,817,134,20,182,39,24,230,117,59,501,315,569 }, { 278,14,135,2,140,16,267,69,92,24,7,46,35,189,38,52,71,29,60,75,357,172,87,309,66,380,262,74,324,230,462,220,1,451,150,335,226,571,108,18,97,50,443,606,563,103,67,246,550,6,641,126,330,70,388,366,5,83,149,68,21,486,48,314,25,12,54,565,298,394,600,622,32,423,294,232,37,582,236,222,572,28,65,251,603,36,192,64,58,145,0,171,331,55,950,853,95,133,86,22,10,114,112,399,620,138,448,26,163,353,508,500,583,96,45,877,238,42,726,9,785,121,279,181,696,72,19,223 }, { 165,13,308,391,197,23,401,509,758,457,569,51,629,734,180,115,873,317,901,961,3,453,719,29,46,546,80,34,2,482,217,468,181,867,48,106,45,341,52,17,14,287,297,5,730,445,386,552,428,62,221,186,15,11,171,56,50,12,38,365,250,328,133,61,211,540,153,215,119,53,41,903,670,58,743,311,99,305,231,176,27,236,4,54,130,881,403,151,6,600,57,136,84,40,764,787,114,475,862,472,469,73,32,26,33,400,227,137,21,1,255,196,270,281,155,65,752,635,440,405,326,161,110,549,477,430,396,592 }, { 1,14,22,2,28,7,67,168,65,24,49,0,35,46,55,50,95,69,12,159,36,105,16,114,109,158,5,83,194,103,38,133,239,169,9,289,164,185,18,424,6,21,10,708,124,170,320,283,312,389,29,68,51,23,420,143,189,347,505,336,37,175,835,892,86,149,108,64,874,54,13,577,251,48,32,654,756,547,96,71,115,301,286,128,154,202,236,344,160,253,484,638,52,75,208,230,747,610,308,39,218,533,137,140,267,141,374,3,345,31,127,237,799,98,601,597,244,272,323,125,398,401,118,17,327,99,412,101 }, { 34,453,130,196,322,3,14,236,361,47,51,377,11,730,514,711,4,412,153,57,161,440,485,102,176,59,162,108,17,62,283,757,202,56,136,38,328,880,77,494,184,12,719,128,402,403,200,23,78,117,27,475,21,300,40,381,54,472,33,53,183,152,129,99,2,714,452,13,585,803,80,210,862,555,383,73,46,123,37,139,84,670,556,503,548,6,507,421,5,111,527,29,19,342,229,457,26,775,134,318,469,133,115,90,106,257,277,401,250,497,205,1,543,266,211,542,629,899,45,488,215,217,65,72,275,339,432,32 }, { 48,18,23,21,35,60,16,24,156,51,13,71,121,221,5,132,46,141,163,7,1,43,271,202,115,92,411,178,340,137,447,308,32,363,150,698,125,223,195,781,541,318,147,142,28,22,0,108,360,621,401,241,2,463,354,49,658,586,67,303,269,97,20,761,50,296,146,70,65,763,867,691,638,182,647,93,82,10,767,167,31,914,670,290,128,107,75,61,225,98,64,4,120,14,12,758,110,29,949,457,316,165,105,95,293,30,668,932,180,39,446,724,743,666,421,391,372,351,114,96,86,66,591,352,33,942,922,459 }, { 13,165,629,457,961,569,23,197,341,401,41,758,901,719,17,509,51,115,38,421,62,54,157,12,32,45,117,57,37,339,328,106,188,14,365,734,99,546,488,477,76,873,2,453,308,542,248,72,10,184,40,721,214,211,4,386,305,479,474,152,3,243,90,139,11,5,1,153,313,21,468,134,471,217,148,129,123,179,77,89,670,255,162,130,94,7,391,136,59,102,111,536,196,828,247,237,743,428,6,514,277,556,128,33,475,155,266,229,29,528,209,720,413,241,64,361,476,183,9,0,519,405,317,202,181,805,775,431 }, { 77,141,2,102,33,1,64,6,5,3,7,269,202,128,180,23,318,14,0,10,13,291,352,153,40,197,165,137,237,51,17,177,15,217,117,115,196,9,86,4,139,134,11,19,22,12,210,403,16,342,95,125,36,457,317,21,498,752,349,275,143,59,341,120,27,93,82,18,28,111,494,110,164,38,25,365,901,475,391,57,8,203,509,260,31,961,49,453,386,48,678,351,326,56,37,719,402,99,401,546,372,569,44,65,304,864,32,730,300,194,26,45,244,873,277,29,285,41,208,597,20,253,160,523,24,98,54,312 }, { 212,68,154,124,562,101,191,0,9,375,118,520,167,149,818,65,16,722,302,21,777,35,24,71,604,350,100,806,252,478,346,264,664,841,1,759,265,48,13,695,429,55,701,329,51,23,724,398,589,18,936,115,882,484,755,88,749,69,903,125,189,410,22,221,535,382,108,308,166,917,411,39,28,223,67,92,509,32,10,197,64,5,694,650,114,558,95,246,60,909,7,83,241,96,165,363,391,593,98,230,321,103,364,826,553,925,639,49,458,734,628,419,336,447,768,399,140,105,175,37,886,682,905,674,821,404,109,812 }, { 48,23,51,98,125,541,598,259,293,13,807,126,21,115,221,493,963,223,35,31,670,386,121,0,107,770,165,144,90,203,116,719,949,783,727,279,590,197,32,326,10,284,146,49,401,407,132,64,199,16,955,342,97,39,834,1,194,453,191,522,427,114,105,92,30,14,7,465,393,763,271,50,725,615,195,108,22,77,44,9,640,291,20,202,269,941,767,671,591,498,467,360,147,128,28,704,551,389,289,33,150,141,60,43,697,534,362,589,58,325,621,523,475,403,260,237,218,210,140,137,127,109,102,87,83,46,36,867 }, { 21,23,13,5,1,586,32,48,167,51,781,31,647,33,271,165,49,141,591,44,115,522,77,197,221,22,360,18,93,146,391,558,105,932,217,447,118,153,961,352,60,900,317,761,196,459,0,363,260,241,82,4,12,698,463,7,291,98,27,247,815,156,120,36,623,35,10,191,628,95,65,46,17,50,922,341,202,45,411,64,521,372,102,16,934,308,269,663,410,351,326,14,116,686,349,225,110,457,29,2,509,71,621,854,701,475,354,342,159,158,132,127,24,478,446,321,246,199,640,848,777,759,371,318,316,273,223,126 }, { 2,29,61,52,7,1,5,14,58,70,45,425,6,290,112,738,32,207,46,72,66,186,87,76,655,38,243,263,74,151,21,75,16,227,25,50,135,17,148,64,89,255,292,128,24,106,155,141,315,476,209,226,90,26,833,19,113,27,306,115,48,454,549,592,18,4,163,307,0,20,119,77,10,86,36,270,54,177,35,171,720,22,65,137,496,202,40,887,59,179,95,294,790,23,69,269,220,172,631,334,9,67,449,28,408,318,483,311,145,13,97,845,84,287,240,214,51,37,43,241,405,33,49,102,663,80,12,180 }, { 39,265,9,333,100,310,411,254,363,101,447,404,18,272,98,639,264,166,1,286,203,327,682,676,31,905,156,520,821,16,93,656,593,30,625,354,105,24,438,44,664,688,23,116,51,557,0,326,329,21,812,195,49,190,159,35,759,60,478,125,118,121,48,364,132,627,13,167,33,110,921,242,68,274,158,96,127,252,137,668,77,5,731,578,692,102,795,865,131,435,165,22,604,586,271,473,455,382,146,120,10,88,144,65,64,966,212,71,67,128,83,691,897,160,576,551,36,724,615,223,82,50,647,7,95,197,621,115 }, { 6,26,2,25,74,1,29,19,42,138,51,108,114,70,324,14,23,386,133,103,5,96,85,13,719,75,453,52,27,66,730,602,220,38,309,65,388,457,58,17,112,122,50,128,323,357,64,235,280,238,670,421,135,165,150,475,7,523,197,32,145,278,87,500,899,401,550,3,218,273,758,208,113,86,83,603,532,222,115,711,12,137,21,895,394,46,24,163,53,45,97,67,125,283,28,458,236,117,34,11,262,294,90,36,801,792,141,516,484,341,302,33,802,297,204,57,95,4,756,594,226,256,134,480,891,545,99,450 }, { 20,43,356,414,49,595,858,359,819,107,392,319,97,7,422,470,376,612,173,5,246,0,427,14,683,147,197,22,660,95,230,347,945,713,32,344,92,61,830,362,325,259,33,31,21,12,4,904,707,623,126,509,18,2,77,357,232,165,140,105,102,729,196,153,426,117,408,841,518,98,64,10,17,16,501,663,560,76,44,104,38,558,125,391,23,324,178,134,46,54,29,13,40,51,330,120,493,279,168,581,263,180,158,116,241,455,159,81,28,903,298,90,900,66,465,441,423,202,198,30,534,237,58,24,3,52,887,845 }, { 68,35,0,101,65,9,124,154,175,114,336,67,28,69,149,189,103,133,1,24,39,83,50,230,55,345,16,429,251,7,283,218,252,346,18,389,547,71,118,364,100,2,238,140,646,109,46,22,12,439,166,289,36,23,49,484,30,399,14,51,732,13,86,930,532,398,64,96,54,323,694,88,21,722,158,265,5,75,38,48,329,181,705,212,194,952,480,361,419,443,208,302,868,782,520,10,95,108,503,128,191,115,246,237,335,267,637,37,167,160,137,723,702,141,806,565,309,105,264,831,826,701,604,535,60,330,562,375 }, { 23,13,51,115,15,5,202,12,1,165,2,0,21,197,453,457,4,318,269,10,32,7,141,9,6,401,3,180,14,403,37,11,341,77,22,719,120,569,217,475,308,177,33,18,260,365,17,961,64,59,99,16,317,237,48,28,629,128,450,730,90,117,137,386,352,523,31,40,494,291,102,247,8,421,509,72,24,498,125,391,196,76,49,44,57,221,36,93,468,203,326,30,45,153,210,899,89,304,216,482,372,38,110,95,82,19,275,134,402,758,342,139,349,98,901,678,752,670,873,546,734,27,56,351,65,817,61,86 }, { 121,195,407,126,60,271,146,199,167,16,107,493,98,132,191,223,35,279,1,212,20,362,727,92,48,43,18,21,150,522,446,259,393,467,5,783,590,598,360,640,612,939,649,354,71,246,7,156,834,68,49,125,293,24,0,147,55,608,591,163,14,376,534,31,660,541,463,683,807,97,13,345,589,23,953,668,562,22,32,818,221,108,955,118,284,96,581,595,10,50,28,470,765,695,575,346,116,2,37,61,356,535,566,95,12,51,105,101,70,281,64,273,423,230,202,441,44,9,755,75,697,653,465,38,768,173,175,77 }, { 31,44,299,116,393,492,144,268,918,367,456,434,105,489,22,948,127,384,963,9,98,28,0,49,125,242,293,206,395,940,36,512,55,51,203,1,855,93,911,617,159,95,272,23,959,332,763,301,137,21,13,141,64,109,86,282,10,170,120,286,320,551,202,417,599,239,165,685,7,2,616,5,128,730,143,457,352,719,48,39,8,253,160,37,692,326,327,386,450,421,158,269,12,276,18,506,791,473,115,24,16,244,391,164,558,318,403,338,623,131,219,14,523,401,284,30,197,499,900,951,308,479,221,260,728,169,910,935 }, { 23,457,51,401,13,758,719,165,629,453,961,730,197,901,386,569,308,670,391,3,29,14,12,739,231,34,52,153,832,828,115,341,2,40,46,514,176,365,5,21,33,0,838,181,4,328,45,54,555,130,509,494,540,734,552,583,215,196,507,227,11,211,99,117,361,180,38,10,1,351,894,134,27,26,186,50,48,543,152,749,369,202,62,236,421,102,600,468,403,171,161,155,57,9,528,17,880,753,36,477,19,440,903,488,377,22,585,108,37,7,6,697,899,757,523,475,576,326,67,479,469,281,867,805,801,659,657,587 }, { 105,131,22,36,127,115,180,341,201,219,272,31,365,169,98,1,44,317,9,64,239,187,141,197,498,143,873,320,752,286,901,352,86,164,160,258,327,244,224,185,109,159,217,13,535,253,538,144,116,0,374,276,261,776,170,28,83,634,531,2,569,533,269,616,95,896,251,824,482,165,37,55,128,282,10,5,578,49,546,654,947,913,371,384,295,208,8,860,21,137,202,954,312,284,30,23,567,509,125,574,39,285,318,268,206,203,843,623,33,708,12,77,716,385,837,7,638,120,237,301,254,308,293,16,951,3,395,15 }, { 6,1,2,29,14,25,52,38,74,66,26,65,67,114,42,19,108,5,69,83,46,388,75,86,324,135,103,7,17,27,85,380,36,24,70,150,278,87,138,97,594,886,357,267,50,51,18,484,650,23,458,45,646,21,732,398,95,208,64,96,273,13,238,0,124,22,711,550,12,532,323,302,28,220,160,37,335,63,32,194,421,133,262,451,602,283,386,309,730,10,172,467,453,235,168,3,401,782,115,610,670,48,719,81,145,16,20,500,137,226,58,280,165,603,244,866,141,308,222,197,189,112,547,53,99,73,475,180 }, { 51,453,386,23,719,730,670,13,758,6,457,401,899,475,629,19,2,29,569,47,26,165,14,894,421,130,801,236,197,108,412,27,74,1,308,754,5,50,17,961,133,45,52,285,523,711,657,78,324,196,128,137,65,34,115,25,99,138,357,59,480,42,114,46,361,867,53,739,58,4,743,403,603,366,11,859,38,262,12,594,202,22,235,153,64,391,218,0,516,487,10,145,200,3,33,444,70,117,901,57,223,134,54,745,390,112,283,95,123,309,96,21,66,803,220,86,341,18,365,402,176,37,328,77,488,73,322,250 }, { 252,121,18,101,16,9,167,132,271,60,146,419,364,35,265,363,212,0,158,604,329,682,68,647,109,848,907,191,520,463,39,24,333,28,446,159,821,55,621,553,118,126,593,411,49,71,407,23,286,634,105,195,354,107,404,857,13,676,374,310,259,22,538,562,92,100,31,10,21,793,199,1,327,639,108,48,98,806,51,7,709,346,522,932,166,147,5,590,96,137,254,465,272,20,150,694,64,706,12,14,203,169,95,36,124,77,2,116,360,44,865,402,125,154,128,33,627,576,185,810,455,156,822,777,37,326,127,842 }, { 283,503,128,432,269,529,63,26,275,789,193,678,318,389,102,122,291,77,59,177,256,6,862,342,25,18,235,57,216,445,27,4,573,605,349,65,11,85,403,523,643,84,813,630,494,397,233,40,56,73,475,202,138,416,210,718,42,32,133,415,381,736,453,412,511,19,619,91,240,255,80,22,64,114,23,289,194,0,17,123,561,87,174,152,343,81,436,66,300,297,148,95,78,3,217,51,803,510,370,341,139,137,130,49,45,119,396,372,90,237,544,141,74,476,129,86,21,650,421,378,352,209,196,33,288,247,402,701 }, { 2,75,29,52,87,74,226,69,220,1,278,135,46,262,70,267,14,380,6,66,324,38,357,294,7,394,222,140,145,97,331,25,335,189,24,67,92,16,112,853,571,26,42,309,163,50,138,35,550,582,103,172,83,96,337,451,71,108,150,5,58,486,785,537,21,60,298,19,462,583,600,461,171,32,230,48,65,366,45,500,606,54,774,12,18,36,149,223,114,37,443,641,133,632,287,563,64,409,85,22,764,388,314,238,151,950,95,61,27,307,155,86,28,415,565,17,246,423,43,572,113,0,186,609,251,396,10,802 }, { 97,298,172,140,69,66,7,189,267,92,501,314,60,423,135,24,232,81,71,16,43,150,462,74,14,330,192,517,173,426,733,149,251,35,885,273,6,279,38,18,221,67,278,508,83,607,2,91,380,52,125,448,124,29,387,458,87,20,36,443,230,861,108,915,711,302,104,21,568,526,723,324,12,68,48,5,362,1,336,335,0,28,22,46,541,126,357,103,25,451,877,726,246,398,565,50,138,879,175,963,65,86,165,809,391,715,197,705,191,118,117,42,712,386,204,160,823,674,54,107,467,399,441,633,831,572,563,236 }, { 475,421,805,899,403,453,958,615,817,51,801,523,120,401,670,730,450,326,494,23,576,202,386,629,569,260,115,365,697,77,165,110,153,351,318,24,117,13,317,0,341,221,16,704,137,5,196,342,308,757,543,22,719,197,11,4,457,20,9,302,484,758,300,10,7,217,6,193,901,391,91,361,1,791,515,862,291,273,118,102,66,38,36,2,402,125,114,661,643,352,474,134,82,33,133,756,642,511,48,373,240,847,735,608,480,172,135,52,43,21,14,859,244,116,29,370,124,754,180,35,42,898,886,851,842,811,770,558 }, { 7,128,20,14,177,97,16,112,43,202,269,77,107,66,415,318,2,135,141,275,147,38,18,58,35,52,307,173,10,356,298,29,210,414,172,32,6,0,137,192,24,291,70,22,102,494,9,87,334,13,104,60,115,64,40,678,342,46,49,186,33,217,5,121,48,90,23,21,4,155,86,232,403,59,28,74,132,37,227,324,319,61,362,402,36,126,95,92,431,337,178,400,609,1,376,71,51,294,665,631,392,151,549,105,81,359,353,304,230,196,67,349,15,134,544,311,285,278,884,352,259,76,427,262,194,50,496,171 }, { 24,14,7,28,2,16,0,22,124,1,65,35,108,168,149,67,109,69,71,18,46,55,158,49,289,12,92,95,185,38,6,169,5,420,83,10,189,154,159,584,140,150,36,68,429,164,21,671,484,50,398,60,105,175,29,302,143,703,239,103,86,23,64,344,424,32,51,9,336,251,230,273,577,114,747,133,37,118,194,66,13,48,267,97,128,835,505,52,170,137,320,892,253,115,236,570,388,347,374,125,286,54,20,345,202,458,314,638,246,654,610,25,75,708,17,172,312,96,135,677,141,19,221,3,650,799,547,601 }, { 26,80,122,73,27,25,42,684,19,209,445,573,667,17,680,690,106,6,255,297,611,483,4,495,59,119,250,45,84,378,113,469,65,436,128,311,85,64,29,53,200,56,648,396,235,61,742,11,136,76,383,77,0,86,32,161,62,22,814,361,256,14,12,5,137,123,40,389,194,491,503,813,283,269,862,21,3,95,112,454,179,63,141,129,33,177,233,57,202,803,2,102,70,10,34,240,402,18,416,624,275,145,605,614,52,358,504,665,527,343,133,114,108,139,50,881,151,58,205,51,790,24,210,38,174,49,216,285 }, { 107,259,465,362,376,595,534,660,683,470,581,147,612,20,858,43,427,49,5,178,246,786,0,35,97,356,279,878,21,423,929,61,142,14,230,126,70,132,146,904,590,325,319,493,22,199,48,32,501,392,298,953,95,77,414,640,347,345,359,798,31,13,198,7,173,58,64,121,105,711,28,125,150,344,12,518,10,941,713,603,4,60,33,450,1,481,92,202,98,120,687,55,207,23,16,18,626,197,102,522,819,163,232,771,113,577,17,318,37,65,357,263,40,324,422,260,623,59,44,663,408,702,494,441,68,455,845,237 }, { 131,30,190,856,228,406,224,530,88,863,219,778,274,944,613,539,816,258,187,100,435,871,39,160,321,840,44,116,31,166,93,625,137,36,957,531,127,442,213,669,466,716,385,1,144,839,492,202,827,829,96,382,908,242,662,731,9,254,120,367,276,456,371,960,203,795,201,98,730,574,83,13,924,410,800,926,326,21,217,851,318,523,836,717,268,473,931,352,533,418,23,49,141,28,260,110,77,22,86,310,567,494,457,64,10,55,244,737,251,373,728,128,299,125,105,0,51,48,679,822,489,5,616,265,295,284,615,102 }, { 113,311,611,6,491,80,667,25,209,45,26,27,684,42,122,73,85,396,255,145,106,17,614,29,648,297,690,19,454,61,64,624,4,5,416,445,112,32,2,138,76,65,74,151,483,90,174,66,665,119,22,287,1,59,86,378,128,833,194,573,881,141,70,52,0,525,742,214,315,243,544,680,14,87,216,469,11,746,179,250,495,887,95,12,10,222,21,348,814,289,280,204,84,72,436,77,123,56,33,114,177,235,53,137,102,81,161,631,136,46,790,503,58,240,292,208,200,153,36,202,63,7,186,50,135,57,49,37 }, { 15,0,1,5,23,9,51,13,2,7,12,120,115,77,260,82,180,341,202,4,450,141,10,8,351,197,21,901,6,817,403,137,102,14,64,22,165,342,457,269,93,16,3,32,11,110,37,128,318,177,401,40,494,18,365,523,854,453,33,36,421,352,475,217,28,210,922,31,569,898,317,125,44,719,30,730,59,86,144,24,48,203,961,17,49,373,116,98,99,308,326,117,752,386,576,153,55,291,39,629,899,95,221,196,139,642,661,402,237,143,244,134,160,90,509,670,391,65,498,349,89,54,127,57,805,275,253,758 }, { 219,127,258,98,395,924,421,276,293,697,944,567,201,284,453,401,242,512,308,51,860,475,23,105,295,131,137,272,770,301,843,670,116,299,578,386,935,125,261,13,763,31,576,456,791,115,44,492,403,221,662,268,9,730,801,269,202,49,365,964,55,805,616,159,699,943,22,141,506,224,327,206,541,21,551,144,39,393,165,326,0,842,535,203,36,743,910,28,170,332,318,282,494,949,716,253,569,197,1,143,10,341,533,5,160,615,457,391,916,317,911,187,737,286,384,93,24,599,109,371,180,900,783,244,352,12,623,48 }, { 15,352,752,317,180,217,854,141,351,82,1,898,36,341,260,115,23,13,365,21,120,110,10,33,291,922,64,901,372,77,349,160,143,244,51,137,32,498,661,269,5,4,202,304,197,48,253,40,237,102,450,457,373,318,11,22,35,482,251,67,55,9,719,165,59,117,72,153,177,196,12,83,28,961,579,247,326,45,96,17,864,69,523,2,468,125,0,86,730,811,128,817,134,93,90,148,144,437,37,111,403,342,76,57,546,230,704,345,308,139,89,58,873,29,203,164,531,50,30,3,275,559,127,855,629,473,8,56 }, { 129,123,257,184,162,17,205,249,183,769,80,119,497,229,106,5,45,130,84,90,59,152,3,99,128,4,618,27,57,77,245,40,62,452,556,378,19,214,460,136,14,12,240,56,26,2,202,432,6,33,61,266,11,209,402,403,64,21,269,102,381,25,141,29,504,76,139,318,54,73,305,34,217,619,179,1,10,32,177,38,361,207,475,383,37,483,22,210,255,115,494,58,196,524,65,23,710,775,53,306,153,742,86,180,421,36,469,137,117,15,51,216,48,134,313,0,111,72,161,285,288,7,757,250,880,503,151,372 }, { 102,33,128,64,77,23,51,202,141,269,13,137,40,10,196,22,0,86,117,153,403,318,342,210,65,1,115,139,15,95,134,475,453,180,165,2,177,217,14,6,494,291,197,99,36,4,59,49,28,5,7,11,402,120,12,114,194,3,18,9,19,31,125,237,82,352,17,16,21,110,275,401,44,260,24,285,719,349,25,93,326,457,164,351,111,300,216,27,317,421,133,26,37,203,143,312,116,108,8,277,498,730,365,678,341,98,244,20,386,523,308,105,29,752,372,32,485,450,901,391,361,57,283,48,30,208,96,38 }, { 7,14,172,107,92,2,16,135,46,35,232,294,60,97,87,5,278,24,126,29,220,52,38,21,262,66,192,202,58,20,70,48,43,171,359,54,32,448,356,337,37,353,226,112,75,298,1,526,18,12,872,132,64,409,140,22,155,387,334,128,121,392,357,318,307,461,331,0,150,314,49,146,61,415,86,69,71,620,673,230,494,380,324,6,362,355,330,45,259,77,888,137,10,13,246,95,186,141,74,23,50,279,147,194,28,25,51,9,4,609,151,177,55,849,145,199,31,115,102,550,597,59,36,216,90,17,441,222 }, { 576,403,615,805,523,475,326,817,494,421,120,51,450,859,137,202,453,260,670,402,77,23,551,401,386,33,958,318,704,342,269,197,196,0,165,480,373,323,65,153,899,753,629,10,803,697,102,7,569,59,4,2,351,90,12,13,962,677,110,9,801,118,40,6,95,5,128,28,143,730,446,124,122,114,14,917,306,207,82,621,407,86,16,164,115,154,64,842,886,848,735,661,484,397,302,247,174,149,141,71,60,1,719,216,104,81,925,628,457,208,168,49,25,22,844,824,685,338,175,109,259,810,236,933,932,854,804,788 }, { 141,352,202,269,137,217,180,372,349,9,18,0,51,115,23,13,16,365,221,318,165,317,2,494,752,7,125,120,77,98,20,10,64,49,341,291,22,901,95,260,854,351,308,55,30,28,403,144,93,44,922,873,326,223,82,48,39,35,21,14,197,203,24,153,33,102,753,498,473,156,88,65,386,32,717,275,268,31,196,177,817,730,704,678,661,482,450,437,393,373,288,241,195,132,121,118,110,105,101,36,1,947,475,237,5,253,244,206,201,168,164,158,143,128,961,954,864,751,615,576,551,546,523,509,489,453,442,421 }, { 23,202,51,141,13,165,1,21,5,180,197,269,318,137,48,128,15,7,403,120,12,102,125,64,2,33,14,326,523,450,260,93,37,16,386,32,9,4,237,6,115,352,77,203,457,153,196,82,18,117,0,110,421,494,453,401,40,24,817,98,351,475,99,221,730,144,391,31,3,44,96,291,30,719,308,36,39,341,342,11,217,35,8,899,50,20,402,854,615,922,116,160,72,28,17,22,45,10,373,317,89,88,61,59,285,509,752,365,372,58,19,901,46,139,70,349,25,177,65,86,293,90,247,498,54,576,758,898 }, { 25,151,145,6,122,174,29,138,74,665,42,416,113,614,45,746,525,287,348,311,396,544,85,66,26,81,280,243,624,355,52,222,32,64,65,680,4,59,19,0,491,2,22,90,7,204,194,104,77,216,112,445,1,61,5,128,86,177,651,91,214,17,95,209,611,141,648,297,80,415,21,102,87,233,454,33,27,43,881,503,20,137,636,573,10,18,14,117,289,76,58,869,202,153,337,496,186,196,789,106,315,11,40,28,135,49,667,269,192,36,13,57,12,115,134,750,70,208,63,72,73,46,597,529,51,48,684,173 }, { 166,190,382,254,30,100,731,829,438,264,274,88,795,131,613,578,716,625,9,93,921,616,435,404,265,1,530,203,31,44,960,36,39,827,160,127,272,326,98,924,96,473,224,23,410,116,252,77,144,310,137,856,105,219,101,33,83,0,863,110,800,13,812,51,128,406,478,228,125,521,120,639,21,49,836,102,593,217,242,28,897,772,931,5,688,957,286,115,64,141,691,269,656,317,321,10,494,159,187,197,291,86,363,576,944,67,22,450,201,523,55,411,373,82,822,557,260,456,704,329,367,225,276,48,202,268,213,32 }, { 132,21,379,5,32,13,23,195,626,51,48,121,70,1,850,296,687,883,156,771,61,49,407,95,146,125,105,55,652,4,98,761,77,58,33,518,260,18,623,586,349,340,120,82,523,522,354,163,24,16,0,293,45,87,786,165,929,75,64,888,763,535,308,102,31,698,40,269,202,159,37,35,9,845,622,207,663,153,117,900,608,386,817,591,351,347,310,241,221,199,170,158,115,76,65,59,28,22,706,223,774,640,629,461,415,116,101,71,303,60,941,638,427,421,401,391,372,197,196,127,299,937,854,768,475,453,450,403 }, { 254,9,272,0,49,688,39,101,578,131,159,518,158,327,333,105,286,68,716,224,252,28,890,344,616,310,846,829,219,827,228,613,24,35,364,16,30,18,938,371,406,166,419,65,455,22,95,627,793,709,98,910,124,154,51,100,31,127,48,1,21,385,190,23,320,242,137,187,374,347,258,36,44,13,301,404,109,856,116,170,125,118,96,160,442,656,424,865,438,931,67,168,64,55,239,623,128,737,265,924,553,221,202,10,71,677,86,83,88,916,60,329,293,538,7,577,512,5,761,395,912,421,212,144,816,944,506,346 }, { 16,35,60,20,7,18,126,68,14,43,92,107,118,101,55,71,28,121,9,154,0,97,109,24,621,150,2,191,419,252,5,202,279,363,917,22,21,124,364,169,439,604,199,49,346,446,175,158,12,167,575,48,38,13,493,246,185,10,362,32,95,51,259,375,1,39,598,628,932,566,421,6,23,64,29,108,146,925,61,46,356,494,318,132,140,345,694,149,359,147,65,407,329,376,125,403,697,273,302,212,96,69,137,50,848,25,467,298,77,453,173,230,570,826,221,66,70,143,677,535,265,608,551,58,815,128,907,100 }, { 15,1,13,2,341,5,0,11,4,3,10,7,33,23,12,6,117,21,9,40,17,901,197,8,134,77,22,37,365,14,32,165,317,153,102,180,217,457,202,51,961,569,141,128,115,318,38,31,64,19,16,291,137,269,196,372,111,59,44,36,25,352,349,57,99,18,509,72,30,27,752,120,93,54,45,41,342,48,110,49,453,498,79,177,28,719,94,403,402,386,89,82,474,29,285,139,86,482,56,237,361,95,55,391,26,277,116,873,34,210,76,758,326,50,39,143,90,328,260,308,247,125,898,164,24,494,401,421 }, { 78,444,47,19,26,390,813,130,108,453,711,27,412,730,65,122,680,283,690,113,51,235,236,73,128,630,196,297,14,250,123,53,194,183,200,133,64,445,368,90,719,3,381,42,23,389,269,6,472,650,249,56,475,32,59,4,57,45,34,648,605,624,503,114,17,25,736,256,22,803,141,318,153,315,95,214,0,684,119,99,18,432,216,899,85,289,46,457,243,33,11,436,480,50,322,177,29,152,129,54,13,657,304,285,84,52,401,117,881,255,714,202,665,597,2,961,12,339,38,361,77,524,115,58,24,145,670,402 }, { 2,29,7,52,66,61,45,112,738,113,74,14,5,151,6,315,20,592,70,128,32,425,16,25,1,222,87,135,177,43,64,491,186,59,38,655,21,72,76,46,290,90,243,141,115,77,631,58,106,19,337,207,145,137,4,24,454,833,97,0,26,40,227,311,402,192,36,27,89,210,35,292,269,48,86,10,202,209,496,18,217,22,102,226,138,17,887,204,122,65,318,33,28,104,172,51,255,13,23,42,148,644,216,790,307,287,174,180,92,69,291,95,49,415,75,416,483,549,179,275,263,270,107,9,334,869,214,155 }, { 145,112,74,66,26,6,29,70,396,287,138,87,135,222,226,25,644,151,42,19,122,307,651,624,635,337,648,45,2,113,294,58,85,632,849,5,416,75,52,172,61,573,445,27,1,315,884,665,64,7,53,204,32,461,95,17,97,297,174,163,436,220,280,525,192,65,792,73,14,186,86,609,881,353,36,311,549,72,243,22,194,331,148,500,235,80,69,46,680,278,38,312,48,90,21,106,37,409,491,128,10,114,614,631,209,67,415,227,50,108,237,250,580,155,76,141,171,544,262,24,620,12,43,133,611,4,334,389 }, { 92,126,60,16,7,24,35,232,71,14,150,140,121,246,314,146,172,132,199,107,18,267,46,278,572,230,108,451,330,236,380,388,462,135,68,38,830,633,392,279,97,2,448,309,649,517,672,32,357,21,5,75,9,118,22,55,167,87,582,192,526,594,366,156,359,298,191,195,64,653,28,50,189,324,563,13,220,0,1,66,467,12,10,423,441,149,733,52,262,877,48,29,70,95,49,516,133,36,54,508,407,360,354,598,550,101,69,37,58,65,271,640,711,212,571,86,345,895,696,273,125,522,23,90,603,72,739,163 }, { 13,115,569,734,219,341,127,365,197,509,629,23,98,538,873,901,286,762,55,206,258,165,253,332,170,169,638,535,180,391,116,276,844,31,44,12,546,0,395,164,1,293,10,752,911,36,964,143,282,37,384,512,237,498,308,616,301,740,5,141,352,8,261,9,2,943,654,317,120,284,38,338,913,601,295,244,105,7,3,201,468,924,125,923,910,144,239,21,4,479,482,242,6,86,131,417,961,185,22,64,758,374,110,841,533,401,93,160,15,944,434,82,951,567,843,268,14,564,837,299,272,719,28,860,109,11,351,935 }, { 151,58,396,53,287,74,27,73,297,549,29,651,145,70,445,112,113,315,436,26,331,6,573,250,75,45,334,52,307,17,5,34,80,163,2,138,19,491,61,881,220,409,631,262,1,614,632,226,171,106,611,186,32,200,66,50,62,311,25,46,845,767,500,21,135,644,243,223,87,14,48,42,64,3,472,108,324,76,122,161,635,684,65,294,56,38,136,95,72,255,114,849,780,278,209,37,90,852,84,714,7,51,89,148,624,237,383,36,207,236,502,22,12,133,86,322,659,227,119,69,222,11,4,96,309,263,179,33 }, { 214,289,90,874,104,751,64,835,312,249,204,65,750,288,875,348,519,174,247,194,74,715,81,138,32,280,524,784,192,636,319,437,879,0,95,85,6,681,217,173,954,91,29,177,86,597,792,77,317,671,422,22,115,864,888,52,202,752,216,673,588,712,18,123,180,233,306,43,355,304,352,20,76,693,579,66,4,5,25,51,21,343,59,237,2,28,61,426,235,577,33,10,397,316,707,287,145,370,24,102,49,291,17,108,84,945,222,97,57,208,56,401,42,526,560,13,730,40,402,23,117,207,474,7,484,72,494,36 }, { 9,39,166,28,35,158,49,30,101,175,439,0,346,1,364,64,88,274,100,168,36,67,404,310,333,952,159,55,345,505,190,706,254,420,86,237,23,336,68,22,251,344,51,69,194,114,164,131,570,208,180,756,10,799,143,399,109,83,50,115,141,967,438,768,584,868,128,752,105,95,103,189,286,252,352,5,323,2,230,65,596,289,137,498,7,702,165,13,12,577,503,535,160,125,202,48,547,455,244,610,96,21,16,253,169,857,217,154,797,646,656,228,197,530,747,149,810,124,930,272,865,597,98,185,31,24,389,625 }, { 341,901,15,1,365,10,569,0,2,5,180,4,3,115,6,31,7,197,9,13,22,317,951,165,44,629,143,23,253,401,116,244,762,55,93,242,479,752,30,217,51,37,141,28,873,137,638,36,202,203,12,21,86,386,421,77,24,758,11,268,453,318,269,110,33,576,64,811,352,326,164,16,494,506,498,308,670,82,717,642,351,206,120,338,170,261,32,125,40,851,805,260,102,859,8,403,54,661,961,291,144,105,965,98,35,898,482,391,373,153,509,492,958,117,17,499,615,38,824,559,456,384,854,457,282,89,564,237 }, { 202,450,120,77,260,318,494,128,102,817,15,269,51,13,342,403,23,291,5,523,137,326,21,141,33,1,922,32,82,351,48,854,177,859,402,64,196,70,615,31,475,40,4,153,285,59,0,12,22,10,2,9,95,98,61,90,28,210,30,17,453,194,117,139,8,352,96,49,275,35,678,899,113,349,165,65,180,6,730,93,692,115,58,704,217,37,203,719,116,576,125,50,457,75,44,421,163,216,36,134,7,39,3,416,14,67,197,25,373,110,341,207,112,86,386,87,56,127,99,11,223,551,365,300,105,16,19,237 }, { 241,32,13,115,197,180,165,316,64,288,125,21,23,237,247,141,95,16,22,92,167,522,191,546,498,391,341,28,752,177,586,4,48,509,447,118,459,90,5,352,59,901,264,225,304,350,35,199,126,363,18,217,24,410,468,691,246,841,744,10,478,102,77,649,386,117,86,49,317,308,302,212,146,33,71,954,156,72,46,674,93,31,0,640,411,923,903,645,686,271,698,2,521,140,602,591,120,36,375,68,12,864,321,695,873,758,340,336,318,269,179,143,65,897,772,446,880,839,682,366,190,57,30,818,781,303,953,388 }, { 16,24,35,71,60,14,267,18,46,140,69,1,7,108,189,2,92,50,75,230,309,68,236,38,335,220,394,54,366,52,486,21,150,149,246,48,29,87,67,5,571,388,9,181,133,0,103,443,28,163,537,171,55,223,126,545,121,70,12,96,262,328,565,83,32,118,65,516,58,218,37,191,330,563,64,167,22,114,13,51,23,238,251,622,281,278,487,294,399,99,696,115,36,10,582,135,514,86,6,128,517,950,675,674,273,98,101,594,172,49,72,146,95,314,451,155,45,409,212,433,221,345,141,66,247,97,733,125 }, { 15,898,180,197,901,341,638,165,33,10,115,77,365,1,4,217,317,5,102,117,253,13,951,752,3,134,2,762,153,569,37,21,0,196,40,11,244,23,6,82,7,120,143,291,32,141,137,51,31,873,55,12,351,44,260,349,352,401,372,479,177,93,22,342,116,36,9,629,308,59,758,450,386,210,854,139,110,111,482,457,164,17,922,421,961,202,719,269,203,373,247,523,28,125,160,48,437,64,326,242,57,704,509,304,14,318,730,498,403,506,148,817,670,8,90,453,494,282,144,72,127,275,579,221,206,899,54,89 }, { 523,193,18,84,730,817,90,56,65,240,214,475,453,196,33,719,4,233,202,32,51,153,289,152,123,421,11,194,403,129,99,96,386,249,135,102,40,27,23,361,847,352,59,511,91,457,177,370,134,128,117,510,13,561,75,753,643,388,278,247,204,115,494,450,415,304,77,524,217,216,64,6,5,3,174,701,880,659,609,437,433,432,381,287,260,257,165,139,120,111,87,74,66,1,402,372,318,269,21,899,183,63,141,650,605,770,743,735,718,667,629,611,569,544,543,348,306,288,209,207,162,95,93,86,61,57,49,48 }, { 151,29,112,74,222,66,145,2,287,624,52,6,416,45,7,113,186,25,122,665,549,337,87,204,243,5,135,644,311,58,884,226,138,396,61,32,192,70,42,525,415,614,315,19,64,491,651,26,4,227,174,609,544,20,21,43,14,27,128,22,172,632,0,59,209,65,353,97,631,72,1,85,580,86,17,445,80,454,307,104,90,334,81,496,177,46,635,141,255,48,37,77,75,10,155,869,659,76,294,106,49,73,11,95,38,36,115,673,69,18,216,712,148,173,792,33,331,102,280,12,16,24,137,881,89,297,91,28 }, { 13,2,23,0,77,5,217,7,1,6,33,3,15,51,10,115,141,102,180,64,4,9,40,317,11,197,14,117,165,153,341,22,352,237,17,365,134,269,291,125,16,202,12,196,372,59,349,177,752,498,128,28,18,32,318,8,36,95,457,19,86,49,210,143,391,901,24,342,21,304,569,31,509,137,139,120,27,386,57,25,164,98,29,111,401,403,45,26,244,864,482,546,110,44,961,308,38,275,453,37,35,93,48,402,247,629,20,50,46,719,873,55,475,65,56,30,72,579,203,523,99,253,494,468,170,54,116,76 }, { 28,67,0,65,1,114,103,83,69,50,9,55,2,109,124,46,133,24,14,35,22,154,36,68,38,547,389,218,7,283,323,16,54,18,12,160,194,420,49,251,175,5,75,185,238,39,289,429,158,96,208,168,532,29,86,480,505,531,484,189,503,169,149,797,782,361,21,101,570,52,346,71,181,336,927,533,48,95,37,108,51,596,10,252,23,159,128,799,105,285,418,64,118,535,335,398,732,6,70,803,419,137,220,13,866,171,756,394,30,32,309,328,140,115,87,60,230,433,345,141,58,439,831,402,610,366,99,754 }, { 121,271,132,167,146,18,363,101,411,621,354,212,520,60,9,647,932,446,806,16,195,407,463,777,364,562,35,360,522,68,55,1,98,118,31,252,706,694,191,0,24,107,936,664,676,604,199,48,126,781,23,590,156,28,591,150,21,447,39,125,5,109,264,49,759,265,96,22,404,33,13,10,100,44,51,905,259,71,346,857,682,116,223,848,941,7,92,154,93,105,108,478,77,467,286,821,166,64,638,907,765,691,628,279,178,14,203,102,12,30,120,393,158,159,593,834,724,419,147,50,293,163,815,786,367,70,634,2 }, { 26,6,85,122,396,624,42,25,573,445,174,416,665,19,680,648,138,145,348,881,64,436,214,113,235,65,297,544,194,90,45,746,525,280,112,289,74,233,32,53,27,355,29,222,287,389,17,151,86,80,95,813,81,73,256,5,249,141,283,91,597,0,343,76,22,66,87,204,415,874,209,312,690,524,611,255,288,63,644,123,243,70,614,216,4,128,2,77,119,61,370,106,52,491,315,58,10,56,651,21,12,519,18,14,835,59,250,352,247,114,49,179,636,205,684,619,311,57,84,28,337,667,177,108,11,208,503,240 }, { 146,16,199,24,71,18,126,60,92,121,271,156,360,953,640,108,132,674,35,246,118,273,32,354,195,649,7,314,150,458,522,95,517,167,446,191,21,140,340,463,22,388,68,107,566,575,241,727,10,345,591,359,296,48,586,14,407,28,5,608,149,672,594,602,660,1,467,363,212,13,9,823,49,267,101,225,124,55,232,37,653,0,392,877,50,447,330,702,12,809,462,441,230,508,46,668,189,77,303,236,733,23,698,621,115,423,411,399,298,97,350,247,72,796,451,64,658,217,69,589,309,51,928,264,168,102,163,133 }, { 51,23,13,453,475,730,719,899,403,202,401,21,15,64,523,115,95,457,33,12,141,308,32,102,4,128,40,19,11,421,5,117,386,3,99,22,153,125,26,817,120,25,6,961,165,1,180,196,17,197,494,57,134,221,0,194,2,237,260,7,670,48,27,365,37,629,450,49,170,65,14,569,137,342,236,38,352,10,56,29,20,16,468,316,241,402,391,77,177,350,84,34,283,269,217,82,9,247,546,351,318,42,59,372,903,841,558,317,129,86,47,46,41,28,18,326,615,341,90,291,164,801,509,119,76,63,54,24 }, { 151,396,53,113,73,445,145,6,27,297,573,26,287,315,112,436,74,58,138,491,45,70,881,19,614,34,250,61,29,549,611,80,17,631,632,5,307,2,200,644,32,222,64,25,52,106,42,1,243,87,66,75,845,226,311,186,334,849,95,122,472,322,294,21,651,714,255,684,48,171,331,194,65,161,209,14,128,86,72,141,46,624,50,135,22,635,262,227,85,108,136,7,220,90,76,163,235,176,114,312,280,62,409,10,337,4,148,56,454,283,237,12,469,37,51,780,214,667,236,3,767,133,36,89,495,155,0,23 }, { 223,774,1,888,385,260,98,863,202,269,421,730,96,349,697,453,141,393,622,834,318,751,87,418,791,765,801,922,163,21,335,352,5,7,120,13,291,854,64,23,717,851,293,30,284,372,31,678,371,217,947,351,70,51,32,137,48,77,128,82,442,450,44,49,36,752,125,386,541,931,304,873,0,498,22,2,201,276,807,317,10,670,180,102,6,75,237,39,373,33,69,770,144,177,95,17,16,160,116,100,842,203,197,968,949,221,115,275,165,494,475,127,898,58,963,523,403,12,954,537,45,50,433,872,652,526,268,241 }, { 60,16,126,92,121,35,150,246,7,598,279,199,191,167,441,107,71,97,146,195,271,18,298,24,407,356,517,230,1,14,98,508,423,140,674,132,359,223,653,212,48,68,399,783,345,21,314,108,607,43,467,232,362,649,118,392,189,20,5,0,149,702,727,55,22,695,28,446,672,69,66,49,493,10,50,388,809,273,2,522,31,46,640,293,125,9,13,95,101,267,173,501,393,834,877,38,575,67,32,75,37,796,346,779,608,12,156,589,236,566,163,96,221,104,360,375,535,64,711,463,23,175,755,172,414,562,953,354 }, { 22,105,28,1,239,95,55,170,320,301,127,36,98,31,49,109,9,2,0,168,35,67,185,169,12,14,86,512,7,44,395,159,5,194,293,312,114,64,83,928,713,740,65,24,23,623,21,299,10,338,16,51,242,50,125,141,933,420,13,237,37,164,844,286,143,69,175,584,892,202,48,6,46,371,103,133,269,116,685,39,916,137,115,160,599,208,272,128,96,284,158,737,762,638,180,244,276,187,763,308,165,841,761,479,505,401,347,424,318,389,30,352,870,18,131,32,197,219,965,327,538,54,456,900,506,253,385,874 }, { 2,292,6,119,29,207,76,61,306,45,5,790,17,240,32,58,106,1,151,476,710,14,214,209,25,179,84,52,70,64,90,7,112,26,311,19,618,72,128,129,27,255,123,655,460,59,249,141,86,4,80,40,113,22,115,46,10,245,464,205,145,243,263,358,77,56,36,74,65,315,504,454,148,3,186,95,0,519,50,177,75,202,21,269,38,257,66,42,137,23,16,769,51,738,48,136,33,162,18,184,62,241,99,227,24,318,194,87,491,37,11,12,57,425,833,180,402,49,237,89,287,216,13,720,102,54,631,138 }, { 51,221,23,115,254,438,48,421,530,541,13,21,401,613,308,39,688,386,125,840,228,551,453,960,827,1,166,96,406,326,393,627,670,158,49,697,656,829,846,770,333,856,404,5,180,30,863,190,202,669,518,890,219,83,159,98,50,131,33,102,310,217,165,137,743,77,32,101,31,752,679,15,105,615,468,391,341,317,0,224,9,498,352,258,286,455,364,187,778,197,344,44,865,539,457,482,272,128,116,37,28,949,403,876,385,963,373,709,931,719,64,574,68,35,160,274,268,616,345,442,95,492,450,293,843,839,22,261 }, { 5,1,22,21,2,12,14,36,48,0,54,86,32,10,28,50,65,37,38,23,51,17,7,208,3,9,114,45,281,13,4,137,323,46,24,6,99,95,18,49,58,55,115,480,72,202,96,745,285,194,181,67,64,16,270,89,133,218,83,168,403,11,430,29,61,155,128,160,503,361,540,223,77,244,221,389,318,757,164,103,141,283,76,402,502,401,59,859,920,40,341,543,290,31,803,269,513,735,124,165,308,33,75,253,421,143,838,754,69,90,180,197,125,102,19,494,453,475,966,105,27,289,109,584,576,569,765,148 }, { 182,23,363,284,296,447,340,98,1,291,698,367,93,668,658,156,144,21,269,70,433,379,31,318,478,354,203,44,691,335,180,13,223,125,116,937,586,411,326,110,107,48,18,421,664,724,273,197,141,51,692,195,87,5,67,914,687,486,759,349,551,386,375,268,232,149,102,60,35,33,115,795,251,69,65,49,415,364,77,771,626,163,453,281,165,127,121,24,10,360,806,791,393,336,39,475,372,217,850,662,942,682,518,484,361,359,221,196,146,133,128,117,75,64,22,12,7,883,591,457,132,16,647,153,120,68,801,670 }, { 45,498,17,106,546,115,32,62,873,41,197,180,509,54,129,468,243,255,123,752,165,155,38,341,13,241,292,217,720,449,57,136,536,734,569,148,51,476,248,428,214,139,76,369,221,482,328,237,542,365,72,89,339,181,23,227,350,64,90,211,117,11,519,270,290,405,721,587,457,21,901,50,128,741,710,141,552,313,430,162,2,540,130,202,15,102,528,247,488,317,209,157,77,48,14,3,391,152,431,308,629,4,618,743,281,179,5,183,33,40,12,37,358,361,266,46,86,961,828,471,773,372,421,543,249,507,119,10 }, { 32,95,64,237,92,180,246,22,241,197,125,115,312,652,126,638,49,316,13,21,5,165,288,534,7,4,48,0,28,23,498,392,296,107,888,340,90,303,658,626,247,70,441,10,16,365,953,468,260,230,546,18,24,774,12,379,883,98,490,482,863,31,877,508,391,141,51,830,933,354,9,517,347,150,314,385,177,132,65,146,645,40,653,76,33,2,341,217,14,269,44,698,263,156,195,850,649,633,199,120,360,359,563,923,509,216,128,86,60,733,873,267,35,1,442,168,330,293,929,545,11,622,591,87,77,641,437,660 }, { 15,33,341,217,13,77,141,4,317,102,23,40,115,180,365,351,117,21,5,352,854,1,137,197,11,10,153,51,82,901,32,134,59,64,202,196,36,244,269,22,922,165,2,291,260,177,752,143,0,120,898,48,3,318,12,9,372,253,128,457,31,569,28,37,160,30,247,86,139,55,44,72,7,57,349,110,90,237,498,342,304,111,719,579,450,96,8,730,403,308,811,49,523,164,386,35,125,482,437,17,6,14,961,39,98,494,116,93,275,642,401,210,95,221,76,277,105,717,373,203,216,38,873,899,18,817,326,509 }, { 120,260,1,15,141,217,352,13,77,82,93,351,110,23,180,317,349,51,202,21,854,326,165,64,269,128,137,5,291,304,752,36,373,372,922,450,318,177,203,197,115,48,457,10,342,2,0,898,102,160,12,16,901,22,125,386,86,9,144,32,96,35,719,28,7,365,341,244,275,494,210,730,18,95,83,661,4,403,237,523,498,247,143,864,473,90,14,961,437,33,817,40,37,8,678,482,253,579,569,98,72,24,50,475,391,67,69,954,717,288,164,65,49,6,206,216,55,17,134,947,899,576,308,76,316,196,490,402 }, { 23,13,51,115,77,217,141,177,33,202,4,64,269,102,0,128,10,2,7,318,40,59,32,14,6,11,352,22,9,291,90,247,180,237,137,1,165,16,317,21,210,197,117,153,196,18,125,49,403,3,95,15,17,349,341,304,12,372,216,365,342,19,36,134,453,86,98,28,308,24,31,244,494,93,275,143,475,57,401,44,48,5,498,457,241,120,203,20,8,105,144,221,25,326,110,752,29,65,523,164,37,55,30,719,421,402,139,39,160,27,116,260,26,96,35,300,437,961,82,569,38,45,901,99,72,253,678,316 }, { 478,264,724,520,682,98,1,772,905,664,759,821,9,223,21,48,411,604,909,447,363,23,265,100,13,410,897,166,5,907,293,31,88,329,252,39,101,0,51,125,639,848,32,167,96,647,691,807,781,541,686,382,284,521,44,321,777,393,621,274,118,212,18,676,116,163,69,271,936,834,221,593,812,16,24,914,30,10,127,765,115,37,49,354,335,217,144,68,93,386,105,404,586,22,33,4,83,70,806,165,553,697,932,60,77,50,744,463,71,64,286,421,254,281,435,102,35,12,656,371,191,225,963,446,121,213,201,763 }, { 29,20,128,7,43,77,174,74,2,23,32,416,52,102,66,491,104,113,81,33,13,6,51,342,222,202,173,14,0,21,525,59,137,45,192,141,319,5,318,64,10,210,22,291,631,18,72,122,90,145,269,196,151,86,61,58,16,665,4,177,40,355,204,153,134,402,28,285,42,738,544,135,48,216,25,275,115,85,24,65,217,9,12,87,76,833,415,226,179,198,38,138,114,49,97,84,243,337,315,311,287,36,426,869,422,172,89,255,17,209,784,112,454,317,425,35,349,117,95,27,494,208,91,194,503,232,30,11 }, { 2,1,5,14,58,7,52,29,46,61,290,45,75,38,592,425,50,270,70,16,32,163,24,155,21,186,171,72,6,227,69,334,263,207,220,17,243,663,48,18,89,76,0,67,400,655,738,35,408,54,112,87,148,36,64,449,66,23,106,22,307,10,262,128,292,74,409,115,119,135,9,476,90,65,141,278,37,767,103,83,86,28,720,140,95,780,255,96,25,405,27,77,3,241,51,12,13,306,20,97,666,179,223,40,19,177,4,428,92,151,496,209,172,26,502,113,84,202,790,137,60,431,833,240,659,331,217,324 }, { 80,483,209,106,6,26,17,495,255,833,378,469,113,742,27,25,19,814,119,445,161,887,45,42,76,667,61,64,491,151,90,573,73,235,84,29,65,32,136,614,179,383,128,112,145,297,122,2,527,396,214,62,56,240,85,5,53,862,194,648,123,311,611,624,207,141,58,86,315,95,14,22,306,292,34,4,454,436,59,684,790,0,1,289,440,250,129,738,205,70,416,361,3,249,245,57,269,287,665,52,108,402,202,46,12,177,11,114,216,21,137,36,10,200,33,115,72,180,74,138,50,28,318,247,312,51,585,148 }, { 98,223,393,834,1,354,195,791,697,447,293,284,360,541,781,807,51,664,591,156,421,411,48,801,163,883,948,668,765,386,18,586,132,121,23,963,363,125,21,446,551,759,31,621,949,770,407,777,271,658,146,730,167,670,13,116,936,453,5,367,296,478,144,371,221,96,70,9,44,202,105,719,127,687,379,49,118,55,60,698,101,842,626,318,771,217,647,212,691,137,281,638,340,165,75,522,463,706,724,32,93,401,39,364,269,16,520,562,35,141,77,50,265,914,450,33,203,197,268,498,264,69,857,335,22,317,103,905 }, { 679,876,36,816,141,144,93,137,752,406,669,228,180,269,96,251,332,21,1,48,352,203,351,202,855,160,831,318,345,498,83,5,116,187,120,617,201,64,317,902,258,261,840,23,839,613,473,110,864,466,190,574,219,32,860,13,873,418,450,326,539,926,748,856,260,44,51,384,704,143,50,295,531,197,489,843,661,206,10,944,778,530,217,567,871,88,82,268,901,800,128,822,125,372,365,86,957,31,30,165,37,442,244,728,224,768,851,373,854,505,625,863,386,367,276,55,827,237,115,922,349,420,274,523,223,169,72,61 }, { 15,13,2,1,341,5,23,3,0,4,7,11,10,6,51,12,14,9,33,165,115,569,197,180,17,365,217,153,77,64,196,102,22,21,40,453,317,8,32,901,141,457,117,961,134,31,18,37,16,386,629,291,719,110,28,44,475,177,120,93,269,202,86,237,372,24,95,19,125,59,49,403,57,401,352,318,48,349,730,36,111,326,137,128,98,38,82,391,27,139,65,30,873,275,242,203,54,260,29,45,494,55,25,342,210,450,99,56,46,116,509,498,482,752,373,50,351,899,523,308,247,90,143,35,437,76,72,26 }, { 202,13,23,51,403,21,494,5,141,128,48,269,450,125,120,523,64,12,318,180,165,453,95,475,15,33,817,32,197,1,137,115,102,7,260,899,4,37,10,99,2,98,326,93,49,196,730,719,221,457,77,16,237,9,31,22,401,6,421,14,386,308,0,117,134,18,352,40,82,20,19,177,615,59,44,61,402,17,391,203,116,110,27,25,90,341,351,153,30,28,285,105,217,3,291,8,958,854,96,24,50,805,922,54,961,758,576,39,26,801,247,347,509,46,757,342,317,365,498,11,194,72,670,210,38,139,275,170 }, { 16,24,71,146,60,18,92,199,126,118,246,35,121,108,140,167,132,230,649,271,360,267,7,9,640,388,150,156,232,191,133,522,273,68,236,101,107,212,0,672,55,446,953,14,149,458,674,330,46,67,314,566,95,189,602,633,392,562,195,64,591,103,21,467,39,354,69,463,407,114,247,98,32,5,50,172,10,1,733,399,278,366,49,36,653,309,412,65,823,22,28,915,288,877,316,124,75,345,340,264,37,12,594,516,135,563,598,451,225,86,38,572,830,125,31,30,359,517,115,571,363,164,726,398,48,237,116,251 }, { 269,141,177,678,202,77,318,947,128,349,33,291,40,102,352,210,498,137,954,120,205,864,216,64,196,597,304,275,217,494,461,23,402,115,342,90,13,403,450,300,95,49,197,111,14,326,22,139,237,10,0,125,873,372,182,751,86,117,615,7,44,195,36,31,83,67,752,356,153,98,46,96,59,252,109,97,800,357,285,774,523,550,208,609,569,546,391,247,116,93,66,24,19,18,17,15,6,5,3,2,30,922,414,373,180,159,147,105,20,485,75,859,854,392,376,317,298,288,277,260,143,134,107,39,28,735,415,409 }, { 16,71,24,92,35,60,18,191,167,108,246,126,150,118,140,68,7,273,121,149,212,21,388,14,399,314,517,267,796,230,48,146,823,199,271,458,1,467,189,695,877,674,345,9,55,97,46,702,101,575,602,594,733,841,0,350,22,375,107,95,232,28,236,462,32,566,69,298,50,672,13,2,5,727,133,451,154,302,125,653,463,23,446,124,10,589,223,132,64,67,175,38,37,49,98,65,354,423,398,103,649,172,562,755,75,66,336,221,197,903,508,915,809,363,359,51,380,411,309,608,237,330,412,241,12,640,509,36 }, { 2,14,75,46,29,52,1,70,171,69,163,220,58,38,112,24,16,7,409,67,262,223,35,334,155,186,5,151,267,394,54,307,87,140,103,309,50,45,83,189,400,18,71,60,92,335,760,227,502,48,21,181,108,61,96,537,12,820,25,278,6,852,113,549,66,357,366,32,287,587,17,37,19,536,27,606,36,150,135,97,74,64,26,380,486,65,0,552,583,28,230,281,600,294,787,582,849,68,149,133,675,22,315,311,236,72,474,243,114,10,324,571,238,86,226,764,9,55,780,218,145,209,80,462,328,95,430,767 }, { 265,166,252,100,404,9,329,382,520,593,812,39,88,274,604,101,264,0,553,1,639,676,438,865,664,333,310,68,30,656,167,821,118,363,411,96,23,682,18,158,48,21,478,364,190,105,286,51,98,49,254,435,759,724,647,13,212,16,907,272,124,921,159,31,223,419,125,905,557,5,447,93,154,321,44,393,83,410,327,455,848,35,67,621,293,271,127,191,71,530,354,344,32,24,60,625,213,418,242,109,131,36,69,33,221,144,765,28,121,806,65,50,777,116,22,238,960,146,834,781,897,697,778,165,163,466,115,948 }, { 16,35,60,18,24,68,158,71,0,7,55,118,109,14,49,22,159,105,9,28,329,126,344,92,20,107,10,154,553,265,2,191,101,95,424,23,21,5,327,121,13,1,286,239,43,747,51,419,48,455,108,374,168,39,272,677,137,169,124,149,12,199,310,150,46,128,38,279,320,37,709,170,346,6,64,98,167,202,31,185,252,67,810,65,36,125,917,175,577,97,212,32,942,44,518,29,925,628,86,301,69,146,375,132,538,575,913,890,566,403,634,439,333,61,33,50,326,147,165,120,66,446,102,273,421,96,493,116 }, { 13,15,23,51,0,1,2,5,77,4,10,115,3,6,9,197,7,177,202,165,961,22,11,12,457,318,217,180,31,14,21,141,33,403,40,102,32,120,453,269,8,341,59,18,16,28,44,17,64,291,93,210,719,37,352,401,110,569,49,317,134,117,90,203,475,260,365,30,450,386,494,36,730,523,125,326,196,153,24,498,98,275,901,111,99,421,308,137,349,817,48,139,752,82,72,95,116,237,86,304,391,247,873,19,509,76,372,216,482,629,57,342,899,128,373,39,758,89,65,864,351,437,105,55,221,38,144,96 }, { 160,251,137,93,317,36,180,1,345,120,352,752,617,318,217,332,202,96,365,531,269,498,10,901,141,83,851,341,55,143,64,816,35,968,679,800,260,473,351,230,144,21,373,244,717,82,831,201,876,533,110,372,295,559,258,418,206,203,50,28,704,855,237,349,22,669,86,261,48,898,115,860,253,926,482,9,406,748,197,67,854,873,574,7,434,564,839,69,661,450,15,902,164,228,2,219,843,268,125,187,98,5,728,16,922,165,221,613,335,109,224,442,367,384,868,77,539,840,871,291,822,417,579,116,31,918,44,326 }, { 42,25,6,59,85,611,233,128,122,26,4,27,19,343,91,269,614,318,45,177,283,503,138,680,77,80,73,11,216,573,145,102,445,297,0,402,235,210,275,209,174,63,202,389,84,14,803,311,18,33,529,396,255,648,416,280,40,65,256,483,10,64,2,57,678,1,667,624,250,81,24,348,304,17,196,76,194,5,544,454,114,789,151,285,133,90,74,106,51,29,690,12,349,141,61,123,119,152,137,32,355,9,52,56,7,153,525,21,237,28,13,881,36,22,87,436,111,576,300,117,605,495,370,361,291,53,23,494 }, { 95,64,81,91,32,237,51,65,180,7,347,74,343,207,204,511,498,577,38,197,348,56,312,128,23,20,370,49,104,43,18,138,22,233,124,86,0,90,554,28,10,681,453,21,14,280,87,750,202,141,25,546,561,29,306,115,63,16,636,241,172,165,147,85,52,24,11,467,650,580,353,192,84,6,13,713,194,673,500,283,9,368,718,151,145,72,57,33,355,263,19,544,475,412,324,318,269,235,173,140,125,108,102,4,933,174,899,519,42,643,879,751,525,403,278,247,221,217,148,123,120,112,111,97,75,73,61,59 }, { 326,202,120,817,260,450,494,318,403,137,704,859,128,523,77,576,5,615,553,51,342,291,23,13,1,421,234,475,142,15,48,269,178,968,147,16,21,33,639,922,285,20,49,351,7,854,682,70,58,363,265,373,198,252,402,401,158,82,416,60,132,55,455,354,0,68,102,24,2,329,141,35,101,64,18,6,121,43,95,325,165,31,9,848,798,341,36,12,805,195,32,14,411,10,146,107,75,912,569,116,96,793,424,374,167,156,98,125,17,670,692,163,604,465,25,965,629,349,115,907,427,61,457,65,621,86,71,520 }, { 43,20,107,356,362,595,126,92,7,359,319,858,392,493,422,246,441,259,173,683,414,49,97,5,819,279,21,104,60,16,230,35,945,232,0,612,376,48,660,121,32,199,147,132,649,22,18,71,14,663,61,423,470,13,146,672,81,623,298,1,105,693,125,159,408,58,427,98,51,165,501,263,729,95,68,4,24,12,325,779,140,55,23,953,426,28,560,72,804,715,241,581,767,314,939,885,202,118,40,204,102,33,37,17,955,192,713,70,221,598,397,77,2,387,251,344,64,44,31,10,941,75,6,465,603,534,46,761 }, { 42,25,6,77,210,483,690,29,102,33,122,342,0,27,4,59,177,40,19,91,300,680,18,21,648,153,196,26,475,202,117,494,128,119,790,48,22,2,343,85,145,56,36,24,32,757,81,1,684,106,292,269,28,833,9,814,151,402,137,84,45,134,70,64,23,139,112,464,396,73,655,115,52,20,614,14,10,403,50,216,63,13,358,233,370,86,7,5,76,37,17,12,485,72,65,397,476,291,57,51,80,611,209,881,665,491,179,99,74,49,416,11,667,624,453,174,148,113,95,235,138,275,61,742,544,341,510,746 }, { 31,44,299,116,599,393,456,144,492,125,22,268,242,367,28,963,9,0,105,489,948,434,301,918,36,127,384,1,95,55,49,170,98,512,109,506,206,51,320,23,940,93,558,13,900,86,203,2,10,239,64,5,959,457,141,395,143,7,293,282,855,911,137,202,12,253,165,8,417,159,338,21,24,332,115,401,498,327,551,286,719,197,352,16,791,617,269,391,128,120,870,37,763,244,180,479,14,168,386,308,65,164,39,421,473,160,6,18,692,841,403,276,499,326,730,48,951,272,685,523,713,365,169,903,450,424,559,35 }, { 410,521,686,367,321,662,201,772,144,335,88,934,1,98,96,921,264,284,897,274,435,443,909,744,692,203,225,551,120,393,33,960,639,44,418,382,190,217,260,93,64,523,442,197,77,9,100,30,237,166,102,948,244,31,326,765,475,438,165,615,82,10,791,473,717,351,238,206,125,12,805,498,466,213,69,842,617,268,778,899,576,127,116,110,37,5,318,187,0,699,530,303,230,855,854,822,817,613,403,269,39,35,32,21,2,489,141,23,291,704,160,478,131,966,539,905,851,768,730,352,272,247,180,175,137,36,22,922 }, { 878,142,178,234,786,132,195,929,416,202,146,147,77,639,522,259,687,167,271,450,481,771,626,212,590,465,49,534,455,427,198,5,315,407,120,0,360,318,48,640,325,23,125,329,113,35,883,22,562,163,346,70,581,13,21,31,98,591,1,61,121,199,107,798,279,150,818,159,20,260,379,668,354,446,44,557,494,269,43,32,10,371,293,95,55,105,141,386,58,33,344,884,64,158,467,116,768,102,93,18,16,362,342,817,60,30,518,191,296,128,711,99,223,39,535,87,170,291,777,97,51,75,402,783,7,156,363,347 }, { 254,39,131,578,272,9,716,310,827,829,0,224,518,166,616,333,613,846,228,938,101,30,49,252,105,890,100,219,404,406,371,159,190,265,98,286,158,688,127,68,438,385,455,931,327,910,31,242,856,1,187,709,28,924,737,258,23,329,16,21,557,51,137,96,656,625,125,44,442,116,24,18,48,35,36,13,160,88,65,731,124,863,274,22,95,293,344,395,5,93,109,553,816,128,299,627,530,916,364,761,836,301,154,284,871,118,202,676,201,144,83,276,165,419,944,456,203,10,55,512,32,7,320,724,520,60,115,593 }, { 699,854,230,855,473,450,831,704,351,137,217,498,352,800,251,202,160,144,253,203,201,418,206,317,332,752,443,141,1,96,36,180,326,82,822,372,93,244,83,494,335,35,365,817,69,859,237,689,898,21,617,864,318,901,44,702,384,922,954,349,345,341,98,10,48,64,824,367,187,128,295,873,284,120,67,531,579,269,7,86,5,22,678,268,2,261,840,927,957,930,28,735,13,291,31,559,947,116,143,30,851,669,373,723,23,16,260,959,661,125,868,717,403,9,748,437,110,50,213,115,223,539,55,615,466,946,285,533 }, { 403,475,202,453,77,318,51,402,494,23,13,33,342,102,128,576,269,141,137,450,120,899,421,523,196,4,117,40,90,275,153,365,349,59,177,291,65,210,64,217,84,0,134,670,15,372,95,197,401,817,1,180,805,341,237,96,260,194,3,285,139,114,99,18,873,326,615,503,393,386,317,293,125,24,11,389,165,70,216,800,752,745,730,719,697,678,657,277,115,108,87,83,69,36,32,21,859,111,457,901,788,323,300,283,266,130,118,86,76,57,12,352,351,9,7,6,2,842,725,541,361,329,312,221,168,124,49,945 }, { 144,23,291,268,197,182,202,116,98,44,264,284,415,96,70,100,125,367,141,203,39,110,905,411,1,107,93,363,120,180,296,658,82,310,447,692,897,238,361,190,77,664,260,105,88,520,48,478,166,682,118,576,340,30,18,966,51,865,13,349,379,403,795,551,921,326,687,301,254,581,223,101,676,457,404,156,812,195,242,213,208,9,165,364,323,269,65,60,615,498,21,765,621,271,137,128,917,914,890,855,481,217,154,102,68,232,883,593,523,354,131,948,318,219,691,842,846,771,272,252,0,626,382,149,87,824,822,791 }, { 15,23,13,77,1,51,202,120,180,115,141,260,5,0,21,9,137,450,269,128,12,2,318,365,7,197,326,351,48,102,341,177,342,352,523,217,291,403,165,6,64,110,32,373,4,317,18,16,37,36,901,22,14,10,494,90,457,28,854,453,82,24,386,817,40,33,308,8,11,475,401,752,96,922,93,3,244,30,275,719,730,349,210,421,86,160,99,17,898,285,31,961,50,39,569,44,221,59,704,49,117,35,372,237,153,55,143,899,391,253,203,116,134,615,576,144,196,402,65,125,629,98,247,482,83,20,873,509 }, { 0,95,18,577,32,207,64,193,29,784,65,887,715,102,52,61,671,138,49,91,74,180,104,701,237,693,474,280,403,241,804,847,22,263,6,174,344,583,453,862,475,77,85,643,500,397,38,37,306,498,494,312,289,2,81,33,5,681,942,510,370,27,283,422,316,192,25,155,347,84,901,319,113,576,24,835,355,348,43,933,814,353,72,194,240,204,42,19,298,650,523,125,86,718,173,247,51,721,389,124,879,490,707,291,153,141,58,54,17,889,202,97,402,1,546,342,134,482,36,511,421,805,750,673,426,196,120,117 }, { 101,9,0,252,68,364,166,100,265,124,154,329,39,16,419,212,24,404,71,118,191,676,158,35,88,18,274,553,520,382,65,562,694,28,962,677,671,60,55,30,333,302,706,149,167,604,375,49,109,857,21,703,967,917,865,1,264,593,806,344,310,438,346,190,48,254,96,105,439,23,22,701,812,13,125,175,777,67,925,51,159,656,83,589,570,7,455,95,628,289,108,98,31,286,10,5,221,429,69,810,826,336,36,435,92,131,557,639,722,32,168,793,638,272,273,14,44,128,126,114,50,170,146,37,238,127,484,634 }, { 16,24,191,71,167,118,212,18,35,68,149,375,101,108,302,589,60,92,755,9,21,562,674,124,154,246,0,273,48,1,126,363,398,411,55,7,447,146,458,350,841,695,140,65,818,150,388,199,628,345,478,264,22,13,189,647,95,271,602,32,69,823,267,121,28,50,67,796,14,346,23,650,49,175,5,621,520,664,51,882,399,10,903,133,815,777,252,98,100,197,649,64,115,781,46,847,314,517,566,221,509,223,103,575,12,953,125,114,236,230,354,37,336,2,39,96,107,308,640,749,463,936,165,724,462,886,604,237 }, { 69,14,2,24,46,267,71,189,38,29,67,278,52,35,135,1,103,108,149,75,309,16,388,83,150,7,60,87,18,236,74,66,220,335,68,251,262,6,50,140,582,357,451,324,133,28,226,366,238,516,172,565,65,36,25,486,114,70,336,0,92,55,594,5,443,458,273,175,54,418,96,571,97,394,906,733,21,26,124,380,12,118,9,218,58,22,154,641,606,398,86,230,48,222,160,37,19,705,42,596,331,550,112,10,412,138,95,45,399,181,294,171,163,145,64,462,32,831,600,603,345,696,517,711,602,545,894,302 }, { 13,23,1,4,115,51,2,0,5,3,11,180,33,7,77,10,15,9,341,141,6,365,12,102,217,202,197,317,40,22,165,269,352,318,59,403,64,901,17,21,14,32,752,28,31,49,177,308,457,401,498,453,8,18,873,128,291,494,16,125,117,475,569,196,95,509,36,93,237,153,24,98,372,137,961,386,349,37,139,44,30,326,210,134,342,48,719,482,391,90,120,55,111,86,110,247,203,39,421,116,523,304,260,450,19,546,629,65,105,734,730,27,275,57,468,402,758,143,35,864,351,38,54,144,244,216,300,373 }, { 447,1,698,411,125,98,31,21,363,5,919,848,48,44,691,144,759,293,225,914,459,120,13,478,354,156,4,116,922,32,23,127,64,668,163,857,371,202,49,82,30,839,284,586,70,17,223,93,865,664,621,340,165,87,51,39,421,321,260,897,110,551,88,724,330,264,335,318,221,77,3,2,821,772,744,442,190,242,195,634,520,360,201,682,963,916,898,854,685,372,351,349,291,269,217,180,141,105,102,96,95,75,59,40,686,622,949,938,687,658,228,909,100,931,867,638,446,407,761,558,463,456,342,310,237,197,166,90 }, { 854,351,180,82,217,352,141,752,898,317,15,244,1,922,21,36,10,64,77,115,260,372,365,35,110,22,291,28,13,341,40,48,120,901,349,4,864,5,661,32,23,160,304,498,237,137,33,11,269,51,202,143,373,93,144,59,164,96,326,98,83,450,318,165,203,102,253,230,55,45,197,2,247,201,67,128,579,17,125,86,76,177,69,37,57,0,16,31,44,728,117,72,27,9,52,116,251,482,342,817,457,7,523,811,367,559,50,719,12,134,961,717,494,187,127,105,49,3,90,873,569,899,418,196,18,316,6,61 }, { 13,1,5,0,4,10,33,23,9,2,82,11,3,77,120,6,21,7,40,12,102,8,51,31,117,260,351,134,22,16,153,110,64,450,93,32,196,457,523,115,28,165,18,719,98,59,44,730,30,17,326,386,116,197,898,854,217,961,180,177,291,36,49,817,125,48,342,95,141,90,317,341,922,57,758,202,373,899,139,14,365,352,349,24,203,37,372,901,801,615,128,275,318,269,210,453,39,144,111,237,401,391,72,55,137,105,752,403,86,38,569,494,642,704,99,475,509,498,661,304,811,277,61,247,65,873,308,551 }, { 51,403,475,23,13,21,12,494,453,115,99,1,5,523,817,202,7,421,49,22,64,450,899,95,221,32,0,120,308,730,6,180,37,141,48,2,20,10,401,128,44,31,14,753,125,402,3,719,260,11,9,318,801,40,33,19,17,4,386,289,237,105,90,86,16,457,326,36,361,269,170,102,76,39,38,30,165,26,25,961,341,958,576,365,247,240,197,117,98,89,77,61,35,34,350,137,93,82,805,782,756,701,671,670,569,503,484,468,413,405,352,317,241,217,216,214,208,179,134,8,281,316,270,144,83,68,945,901 }, { 752,180,352,864,498,317,141,217,237,39,365,115,901,30,88,930,579,230,0,83,101,9,197,372,482,873,128,546,64,100,341,36,1,166,437,927,702,35,213,96,23,13,175,285,68,252,269,349,251,28,689,190,69,868,443,735,304,21,562,723,457,137,399,759,509,244,831,419,10,274,77,321,539,165,818,67,530,201,219,194,228,840,418,345,410,93,131,144,86,570,143,48,154,854,247,646,224,866,49,12,699,669,402,596,954,212,203,208,160,158,800,31,177,694,358,24,117,51,957,406,382,202,22,346,134,7,438,16 }, { 16,24,35,71,7,0,18,28,60,14,22,158,109,68,154,118,124,92,168,2,55,149,159,49,747,185,169,424,1,108,105,95,10,577,150,344,175,126,20,239,65,9,677,69,5,67,302,6,12,21,671,46,329,38,107,97,164,23,51,43,286,375,170,48,50,125,140,327,64,320,39,420,29,36,701,374,289,83,101,273,570,37,143,32,13,347,137,191,345,189,230,86,66,553,265,638,128,202,429,455,252,54,272,703,403,246,535,103,52,221,421,654,398,279,98,194,121,114,310,336,467,584,298,165,25,453,346,96 }, { 15,341,23,13,0,51,77,1,141,202,33,4,137,9,260,115,120,180,102,269,351,40,11,291,5,318,82,7,2,21,10,901,197,12,22,128,854,922,165,450,16,117,352,59,8,177,217,28,3,64,457,349,90,32,36,403,37,110,18,30,14,401,6,17,523,134,898,365,317,453,48,752,57,31,719,386,817,308,196,421,153,93,24,244,139,86,143,475,730,569,39,99,494,961,373,55,642,44,49,498,285,96,210,253,275,661,125,342,35,237,203,372,95,899,326,144,402,247,629,160,98,391,61,304,576,221,216,208 }, { 68,35,24,149,18,71,16,118,189,108,14,7,101,154,0,9,230,175,140,336,69,124,65,267,28,114,67,133,302,46,55,398,251,375,345,2,1,236,458,103,388,83,399,596,60,50,283,38,92,346,732,412,602,36,22,212,309,21,273,39,650,722,246,12,109,48,172,429,29,218,191,906,75,52,364,443,5,86,167,547,54,10,135,252,49,64,238,95,330,37,278,723,96,23,705,516,520,439,628,891,13,51,366,565,158,915,930,232,562,30,868,6,335,637,696,150,952,194,451,484,32,220,100,694,702,886,389,168 }, { 308,13,197,115,391,165,546,509,125,629,569,237,749,468,23,9,558,28,903,338,217,801,734,317,352,401,740,254,341,49,36,180,22,386,51,39,159,901,873,95,365,490,506,530,168,961,498,131,166,438,64,482,247,219,579,83,185,109,93,752,656,187,345,439,613,857,457,688,316,101,86,21,158,627,258,843,89,829,637,312,10,55,679,105,967,224,170,251,574,332,406,221,175,228,48,758,902,261,960,505,44,31,876,116,37,12,868,840,72,424,347,1,371,98,15,518,274,141,32,827,333,77,190,892,816,272,253,143 }, { 90,64,217,32,115,128,141,216,77,312,86,597,95,59,4,33,247,875,13,172,352,197,147,237,177,288,102,437,210,22,97,5,194,137,202,37,57,11,182,208,153,76,61,14,304,134,117,65,40,751,23,291,947,10,864,342,196,21,362,49,356,178,60,45,874,317,0,54,48,612,165,107,51,259,588,752,324,192,819,298,275,180,20,678,372,307,289,173,43,120,112,415,285,207,164,72,36,35,707,44,7,359,89,46,802,414,156,2,789,729,579,168,123,104,98,92,55,24,712,524,125,87,70,66,470,387,465,148 }, { 1,22,28,105,36,95,67,49,2,55,239,0,5,12,83,170,50,9,159,312,86,109,7,114,320,21,208,14,103,69,35,168,301,31,164,64,194,23,892,127,169,323,160,654,98,51,141,65,48,158,10,96,143,133,37,505,13,218,584,38,6,46,751,54,115,24,185,244,347,128,424,44,824,202,253,503,597,16,269,32,237,238,39,137,286,180,512,420,3,352,740,533,29,646,165,638,251,242,318,338,623,175,125,4,18,776,395,797,480,285,713,197,531,116,532,30,928,68,341,401,293,371,99,933,124,789,844,272 }, { 18,9,16,101,159,68,252,35,24,105,0,60,310,265,49,39,890,329,320,71,455,118,272,557,7,55,167,28,327,121,286,1,137,170,98,364,271,100,518,333,301,65,14,520,51,23,254,13,212,553,21,604,5,363,109,202,938,128,239,709,30,31,127,95,419,64,22,125,578,846,132,191,616,2,154,158,146,124,371,48,647,395,92,67,621,12,242,627,10,916,411,344,424,116,44,403,32,108,512,338,446,737,374,326,166,86,149,793,36,120,688,421,69,827,318,93,293,126,346,731,20,463,37,260,639,450,848,264 }, { 129,123,249,618,214,257,460,205,769,184,17,5,245,162,106,45,90,119,76,183,128,2,209,229,61,80,179,497,6,59,130,1,64,202,99,3,152,27,77,19,710,14,207,84,4,306,40,12,29,141,255,57,240,62,26,452,10,790,58,25,269,177,619,556,21,524,38,266,32,742,217,56,136,86,102,519,7,137,115,432,318,33,292,311,11,151,22,402,48,0,216,51,37,378,288,23,210,54,655,667,381,95,36,34,113,65,72,194,403,139,50,305,111,361,504,483,46,833,285,15,494,180,475,317,112,16,263,275 }, { 51,719,23,453,899,457,730,13,475,386,670,4,523,15,401,961,11,12,196,99,153,403,32,3,57,117,21,33,450,59,775,165,40,115,130,421,236,77,308,202,128,120,134,758,108,6,65,391,217,90,64,125,177,197,0,361,5,34,26,260,2,19,1,629,300,183,47,216,54,141,328,817,78,123,22,17,180,342,801,7,95,27,37,241,210,214,269,221,14,10,56,237,275,242,194,494,317,558,412,25,743,73,38,247,48,102,28,488,381,318,9,82,29,326,291,711,288,137,53,304,129,46,277,402,339,283,266,24 }, { 173,192,66,204,104,74,636,560,426,825,20,7,43,289,750,707,712,97,861,414,214,348,65,715,81,500,90,138,95,64,835,32,312,174,319,22,526,194,280,874,792,52,0,580,91,681,232,29,6,819,330,889,673,879,5,888,86,77,568,519,422,85,376,288,135,729,387,172,370,2,222,33,38,61,10,21,784,355,49,353,107,249,324,25,69,24,18,42,36,577,226,28,356,102,140,76,448,59,92,751,207,115,671,40,325,4,237,31,359,247,524,343,180,470,145,147,397,16,392,153,117,13,120,26,177,597,125,45 }, { 23,51,13,202,21,141,5,1,165,120,269,180,48,12,197,32,15,2,318,115,403,125,128,260,450,137,7,9,523,64,82,33,352,93,386,326,0,6,308,4,453,401,421,102,237,37,457,475,31,14,110,351,77,16,3,221,341,391,99,494,30,44,18,117,8,11,817,203,98,730,17,217,39,719,153,899,373,40,196,24,10,61,498,402,72,365,509,50,90,854,569,317,116,28,144,247,134,19,291,59,96,752,45,285,961,89,615,922,342,58,49,25,35,36,22,349,177,20,546,241,57,670,88,54,29,105,576,65 }, { 200,78,34,322,472,27,390,714,161,136,19,59,283,444,250,128,236,176,862,108,47,62,527,14,57,412,53,813,73,3,381,17,453,711,56,585,210,4,46,361,77,196,440,26,65,129,51,153,130,432,383,730,216,183,297,803,690,402,401,45,469,202,133,389,123,529,5,495,162,33,90,275,318,754,194,12,378,177,291,32,257,102,38,719,117,184,114,789,480,13,23,11,106,48,503,814,2,61,629,84,684,54,475,245,21,657,555,231,40,678,152,99,300,507,137,119,80,0,436,113,457,369,650,6,403,86,22,523 }, { 347,33,204,498,66,546,681,56,174,5,426,95,135,348,97,172,353,864,49,22,928,923,873,808,73,263,241,10,568,370,27,197,180,77,554,207,81,580,102,21,42,237,368,32,751,526,192,134,117,19,0,350,86,63,715,448,468,115,380,123,76,25,4,29,64,44,31,36,6,91,7,511,40,645,387,85,74,861,408,298,80,736,69,173,872,13,501,355,108,712,138,153,87,61,28,17,901,18,467,72,673,59,620,343,232,161,233,312,800,509,324,278,125,45,30,14,650,636,90,3,451,415,577,500,65,561,165,70 }, { 131,224,219,187,385,442,258,836,371,944,871,908,737,924,254,127,98,31,827,716,574,44,39,829,116,201,613,276,839,616,242,860,926,284,137,228,395,144,293,36,96,9,1,578,406,30,456,0,299,567,93,21,13,125,202,23,843,160,166,49,51,64,856,105,846,902,203,761,935,938,662,492,128,295,159,83,48,916,438,268,190,100,115,269,5,403,310,272,318,489,367,110,77,141,931,28,10,531,55,326,165,918,688,32,86,576,22,699,88,158,120,717,530,261,244,143,421,341,434,217,2,512,197,960,625,164,37,333 }, { 1,4,5,2,13,180,3,15,7,141,6,115,23,352,901,341,51,0,217,317,197,77,752,365,33,21,11,165,12,269,32,9,202,102,291,177,318,93,40,372,247,10,137,31,349,498,22,120,8,308,403,44,17,873,569,110,401,203,116,59,125,36,457,28,326,196,48,304,14,37,494,386,373,98,144,134,153,128,90,64,117,475,758,260,509,72,18,16,206,55,49,523,86,237,210,95,961,629,421,482,453,30,391,253,450,951,719,342,139,638,730,576,39,864,275,268,579,241,19,82,221,24,546,437,89,57,127,811 }, { 370,91,681,636,397,718,510,74,81,240,355,66,84,582,278,289,214,511,701,138,90,18,782,6,104,288,5,65,64,32,693,117,247,77,63,192,56,0,814,306,750,673,312,233,85,40,453,847,671,415,11,643,317,207,134,72,61,42,33,102,4,942,519,343,123,115,27,1,86,25,348,249,22,580,537,461,396,352,153,75,484,784,475,403,304,194,21,10,235,29,3,193,119,583,287,196,114,76,59,52,319,256,124,26,23,13,874,579,389,610,462,302,238,17,710,817,597,353,129,96,51,48,217,164,89,835,804,751 }, { 15,13,23,4,197,51,165,1,2,120,180,341,0,260,386,5,8,82,12,7,9,3,141,450,317,153,11,10,391,217,6,351,326,115,64,77,14,457,117,901,498,523,854,509,291,110,134,730,401,758,33,961,237,352,22,202,898,125,922,93,21,365,308,196,31,44,615,269,128,817,99,453,801,28,203,899,116,373,873,752,629,18,40,55,349,137,98,37,318,372,403,36,49,475,569,32,38,86,546,95,16,661,143,704,102,719,30,342,59,39,35,17,642,304,494,482,48,24,638,144,177,300,194,139,958,29,54,492 }, { 32,76,292,2,5,476,45,214,72,29,1,241,14,519,464,460,21,179,48,129,290,90,17,710,148,205,123,263,249,50,58,358,52,425,186,243,408,46,257,618,207,38,245,184,89,227,155,769,162,270,171,350,3,7,288,119,61,6,106,57,316,64,54,400,449,128,183,229,255,75,4,141,36,496,115,152,524,655,99,209,720,334,497,62,12,202,59,77,37,86,10,405,0,56,51,221,130,666,23,25,40,592,22,181,237,269,11,247,432,137,16,217,454,84,27,452,428,24,663,619,19,513,318,177,659,26,67,341 }, { 13,569,115,165,509,197,629,734,17,873,23,659,106,457,180,45,41,32,961,901,38,536,341,428,62,155,587,474,391,54,21,431,99,546,255,51,243,528,308,365,136,241,37,468,405,89,123,129,14,482,181,2,211,401,139,72,12,148,542,719,221,117,794,214,76,749,498,449,350,317,292,157,743,540,29,758,328,152,552,188,162,11,3,119,720,488,339,770,413,237,227,179,50,248,48,209,697,313,90,741,476,130,4,477,128,1,773,519,277,40,421,507,46,266,57,249,33,245,361,137,153,202,453,369,471,64,133,358 }, { 68,101,24,35,71,16,154,124,9,0,149,118,175,65,302,18,108,375,346,28,55,92,252,364,212,429,191,7,439,60,694,39,520,14,398,806,100,22,109,329,166,167,484,273,336,604,67,69,419,189,562,21,826,589,1,701,695,345,95,140,230,265,246,49,10,264,48,158,114,637,755,168,103,917,133,46,628,2,64,722,126,650,399,88,404,535,125,768,570,289,150,458,13,706,83,30,50,36,388,32,420,23,267,12,185,5,882,674,818,96,169,51,676,925,37,363,283,602,86,105,38,221,333,967,159,286,942,553 }, { 0,9,68,35,1,65,101,230,69,28,124,23,83,39,141,154,67,13,21,352,212,217,51,30,100,252,88,16,336,115,48,175,864,103,24,317,189,5,180,114,166,128,96,443,36,399,10,12,238,64,329,562,264,478,177,32,18,265,752,77,55,22,321,372,291,218,160,702,149,520,167,50,437,304,202,498,247,137,118,269,99,49,596,365,589,221,759,486,349,197,165,382,346,323,410,2,664,480,223,419,213,777,604,433,418,75,7,4,335,482,15,547,532,37,251,363,237,125,936,72,143,755,341,553,308,190,109,201 }, { 909,265,100,410,382,812,88,593,321,213,1,30,252,166,676,639,264,435,466,230,689,39,9,48,724,352,478,21,98,553,96,329,190,223,101,23,274,51,217,13,83,5,921,310,699,438,795,125,69,821,905,530,293,752,759,35,36,656,557,128,144,393,443,520,0,541,284,521,604,137,419,32,682,831,141,455,317,418,664,855,854,251,31,165,772,221,404,386,93,201,180,203,33,686,421,335,539,840,115,55,127,44,957,160,285,158,28,344,68,67,367,77,202,345,254,697,102,669,562,897,807,702,765,286,10,351,64,269 }, { 113,61,904,43,0,204,848,453,389,315,788,198,174,5,22,899,222,59,37,102,33,207,422,290,288,128,97,329,306,46,31,30,77,470,817,523,159,58,40,942,122,65,725,690,324,291,104,64,263,450,426,20,54,337,304,247,205,196,153,134,117,105,95,49,408,757,615,351,326,194,115,82,28,18,9,177,137,32,350,887,372,347,331,325,217,90,48,2,701,344,342,320,316,158,317,804,376,341,819,319,849,685,666,600,580,579,553,501,498,403,392,365,357,349,330,301,270,262,242,237,180,112,76,44,39,36,7,147 }, { 24,16,141,71,18,0,352,269,75,108,140,7,60,35,330,12,199,217,65,9,486,28,498,864,87,246,64,92,68,50,318,267,126,954,118,115,55,230,70,5,146,177,950,545,13,372,197,752,271,101,98,14,133,77,180,641,349,317,99,36,726,458,23,537,487,156,102,437,22,10,622,165,21,563,516,832,202,2,341,149,48,565,86,457,304,273,220,237,116,44,674,526,117,100,39,33,120,49,37,365,360,830,58,137,103,291,135,522,181,166,121,88,54,51,412,167,284,223,46,15,394,1,696,852,463,361,264,212 }, { 271,167,121,60,199,146,191,463,18,446,212,132,575,126,598,354,407,16,955,727,640,566,1,608,195,35,562,279,522,21,48,107,98,71,118,783,223,493,150,467,68,589,24,5,360,781,92,156,363,591,411,668,447,55,13,534,818,101,23,9,108,346,581,647,777,590,49,621,0,259,125,362,936,664,939,7,273,28,31,22,51,163,32,807,10,535,834,221,147,520,246,33,293,541,50,37,586,14,815,375,393,4,116,12,105,96,70,2,44,77,39,93,252,149,281,441,46,158,75,61,759,154,97,649,95,423,364,140 }, { 15,115,217,317,365,341,180,13,141,33,23,260,120,4,82,110,102,351,51,40,854,77,372,137,352,21,64,1,5,32,36,10,197,117,898,752,11,901,269,202,922,165,59,9,160,244,0,661,373,134,2,143,22,48,457,349,153,253,450,12,386,196,318,482,247,326,128,308,177,55,72,90,498,523,7,125,961,719,93,28,37,86,3,291,811,509,237,96,57,873,16,437,89,579,391,730,111,203,31,864,18,6,615,35,468,210,216,14,569,275,139,164,304,17,342,76,899,403,221,494,642,316,817,251,30,531,717,95 }, { 173,97,356,7,43,387,107,426,104,729,414,359,232,20,560,392,595,885,858,861,707,819,66,81,612,5,49,22,362,319,126,192,230,32,660,330,0,74,357,92,246,147,784,715,14,324,298,172,470,879,95,263,2,422,259,16,427,38,314,207,683,61,376,140,21,681,35,6,29,397,91,60,18,241,10,279,28,64,52,77,24,830,500,493,31,636,33,37,501,12,4,86,779,204,135,58,577,370,65,568,441,40,199,48,526,13,98,581,712,105,534,125,325,17,102,72,44,347,750,138,120,70,59,46,465,25,45,30 }, { 15,23,13,82,120,51,110,93,31,33,116,98,95,196,453,4,165,40,197,260,117,0,386,2,180,217,12,1,351,11,77,5,8,134,102,9,141,326,457,115,341,291,3,153,10,401,21,450,317,523,854,202,352,14,7,391,898,6,64,961,373,719,22,125,475,901,28,922,615,403,18,177,269,498,203,237,44,349,99,758,509,32,30,318,128,37,817,16,899,629,308,57,365,670,36,421,49,139,275,661,730,111,569,137,24,39,48,86,704,144,801,752,35,17,65,109,494,342,558,38,372,551,221,216,170,46,55,638 }, { 100,9,120,260,30,827,795,373,264,77,137,166,202,326,127,578,1,39,254,82,704,318,217,450,18,101,395,737,351,0,731,291,265,317,156,349,341,31,716,105,102,93,141,197,55,33,968,98,269,5,296,128,478,131,24,851,252,371,342,32,859,938,921,44,616,411,403,404,385,924,144,109,165,40,456,274,180,10,494,836,16,512,854,410,299,195,110,68,28,7,518,442,36,438,286,242,13,244,167,96,363,850,379,656,521,284,95,523,125,64,658,615,340,116,67,922,212,115,447,187,937,935,916,724,936,856,822,372 }, { 14,24,2,67,69,46,28,108,1,65,38,83,7,398,18,0,124,154,114,103,36,50,267,133,29,55,236,189,149,35,16,547,52,68,429,175,283,71,336,9,160,118,309,22,302,251,109,458,646,75,6,140,388,86,135,484,278,412,12,596,5,389,650,172,531,54,238,60,218,420,602,96,21,66,208,87,886,220,194,505,782,150,185,169,92,64,10,891,168,95,25,101,797,335,289,533,570,532,74,906,37,230,48,357,49,273,262,323,366,696,346,158,23,516,443,39,32,799,70,565,58,705,137,51,13,439,418,128 }, { 66,69,14,267,189,24,71,7,150,172,140,97,149,16,60,380,135,462,2,35,67,74,388,92,38,18,451,278,108,29,83,68,251,6,357,52,46,1,230,443,36,324,423,298,458,65,273,28,336,517,314,823,232,192,398,330,711,118,594,103,87,0,75,565,175,55,335,399,705,124,22,86,25,21,603,448,906,568,204,95,48,12,50,236,5,563,309,43,550,10,154,138,64,32,345,302,37,596,893,20,133,572,54,467,114,126,607,42,26,160,246,220,733,375,809,226,429,526,501,723,9,895,49,808,70,500,602,915 }, { 15,1,13,5,2,341,4,365,3,0,23,10,11,7,12,180,6,117,9,17,33,21,134,115,77,14,32,217,197,102,317,165,8,141,457,153,64,40,901,37,51,128,22,961,569,291,202,196,16,31,269,177,352,36,137,38,873,372,28,93,19,351,59,55,349,111,44,509,342,498,752,18,48,125,318,99,304,139,120,386,143,237,116,308,72,401,86,391,110,30,95,54,629,27,482,210,76,45,164,24,89,79,29,90,453,403,25,719,57,275,203,216,82,98,41,758,579,277,247,46,260,49,523,244,26,285,326,144 }, { 1,22,12,5,28,36,0,21,2,86,49,48,95,55,37,23,10,50,9,7,96,13,202,32,51,105,14,54,208,168,65,115,128,24,83,16,160,67,4,141,137,31,64,99,318,3,269,194,109,6,323,18,164,159,17,114,35,170,239,281,402,285,180,11,238,745,69,584,103,197,165,480,158,45,341,181,169,403,77,244,44,46,38,218,143,98,433,289,401,30,223,58,717,125,657,503,352,217,851,33,177,185,29,946,597,757,708,39,365,312,317,72,800,253,75,789,102,678,124,418,133,237,59,956,90,127,308,430 }, { 123,605,630,63,108,736,444,65,650,368,19,561,619,389,122,216,25,114,183,177,26,53,27,813,133,42,102,194,84,445,249,899,297,56,421,349,90,401,33,597,588,250,137,78,73,130,11,730,51,283,45,524,629,235,59,57,14,141,196,153,32,40,343,255,719,134,117,467,304,119,76,17,13,0,152,6,436,77,390,4,323,511,678,475,457,136,64,594,342,23,403,256,12,129,503,218,208,86,62,61,5,416,233,372,52,3,469,184,275,381,106,947,789,554,214,112,680,450,95,309,217,18,9,529,432,291,269,80 }, { 127,39,9,254,98,395,371,31,0,385,836,44,1,30,299,284,100,166,116,578,131,187,272,28,935,49,293,276,21,125,23,16,219,310,599,51,737,442,827,48,242,616,137,18,101,908,5,144,13,846,24,265,456,716,35,512,96,252,93,88,202,22,201,68,159,36,158,7,77,55,224,924,938,141,492,203,128,190,688,269,518,258,32,333,64,37,318,228,2,65,829,326,274,244,761,165,12,115,67,286,120,931,217,110,367,404,105,839,33,102,567,83,268,916,662,95,438,14,86,50,944,109,574,557,69,327,625,10 }, { 2,29,61,45,151,6,655,112,207,52,25,425,32,833,76,7,70,106,1,113,14,119,292,790,58,26,72,5,887,64,209,128,17,90,255,315,66,19,145,4,186,306,243,476,115,59,483,27,77,74,21,177,311,38,87,86,40,263,141,738,46,290,36,23,148,454,287,10,240,95,42,22,84,16,137,0,179,202,135,33,631,491,814,75,227,51,269,89,50,210,65,214,20,12,80,222,48,318,24,28,49,13,11,216,18,155,358,102,99,56,464,122,37,644,138,549,710,54,180,337,205,117,496,67,172,869,123,720 }, { 2,17,5,29,27,3,6,401,45,58,51,26,23,19,53,52,14,34,46,453,151,133,366,13,61,236,50,218,114,1,73,99,308,487,603,108,21,25,181,670,287,421,297,80,115,396,48,74,56,137,171,412,764,445,202,38,281,62,457,42,65,629,516,480,475,341,113,549,64,573,600,386,57,403,894,250,106,730,54,436,651,491,86,145,12,334,208,155,832,128,328,614,361,262,165,283,84,32,719,323,745,200,90,141,37,36,711,657,631,67,760,754,583,739,635,569,7,594,488,315,161,10,285,59,402,758,243,430 }, { 22,170,31,301,127,1,98,44,28,36,239,105,55,299,512,293,86,395,116,685,242,841,9,95,125,338,599,900,2,0,5,654,23,320,169,109,13,456,870,49,64,185,763,10,51,7,237,12,141,144,164,479,143,965,312,35,137,923,21,268,115,14,933,492,128,168,393,284,506,67,286,762,276,83,37,244,6,114,202,160,180,928,24,352,634,194,367,201,197,159,308,165,269,253,558,844,401,538,48,65,208,272,935,391,584,50,420,341,365,131,203,913,318,16,498,3,489,327,96,4,457,374,317,892,386,32,434,638 }, { 14,21,50,48,5,2,1,32,270,46,38,290,76,72,45,155,54,17,263,181,408,207,425,281,29,430,221,67,36,96,292,89,449,52,428,37,476,513,241,83,103,119,0,171,7,541,720,528,3,12,10,24,227,148,22,58,179,61,536,502,214,243,655,6,413,90,9,350,23,218,106,51,16,86,69,129,65,186,28,133,115,114,99,431,552,400,760,794,464,64,474,128,433,123,328,460,18,405,137,487,306,84,108,477,245,710,35,236,205,4,13,787,27,238,308,587,309,770,141,540,19,56,790,240,95,223,488,202 }, { 17,119,106,378,240,383,136,84,62,80,306,790,56,504,742,3,440,207,209,128,255,483,123,45,5,667,61,32,57,64,179,27,129,14,205,548,297,4,245,2,214,311,141,90,11,76,833,655,184,151,29,361,59,469,152,249,26,38,162,19,58,215,328,257,73,495,161,34,54,229,269,202,250,266,292,21,12,402,514,555,216,113,194,887,130,1,445,503,507,183,6,25,318,237,186,72,52,814,710,618,99,10,86,211,148,452,263,243,65,137,37,40,41,23,36,33,155,497,13,403,53,95,313,227,494,180,77,738 }, { 13,1,2,15,23,5,115,0,51,10,4,3,6,341,7,11,365,217,180,317,9,33,197,77,165,40,22,12,14,102,64,141,117,153,196,453,457,8,202,901,17,21,269,18,128,28,125,569,31,386,59,318,32,16,134,349,352,291,372,237,36,719,403,752,475,873,961,730,509,391,177,137,24,401,95,57,44,37,93,498,120,308,139,494,110,98,326,111,247,86,304,30,482,49,143,48,55,629,210,260,758,523,19,351,65,450,72,116,46,76,342,29,275,203,50,170,105,164,89,82,734,242,27,38,54,144,899,90 }, { 772,335,662,96,367,744,897,1,303,686,264,521,652,340,116,520,141,31,919,201,966,260,888,203,44,64,905,321,144,225,269,98,691,658,349,284,410,698,692,363,120,88,848,717,863,187,551,914,909,418,576,202,646,443,850,639,523,69,404,336,958,293,128,730,131,615,274,382,296,166,960,948,258,228,224,219,751,486,160,125,82,411,191,765,244,223,475,453,352,326,100,318,676,596,67,351,899,703,403,389,435,947,589,498,102,33,954,291,265,156,922,854,402,93,759,664,447,372,212,137,478,329,724,562,530,286,217,942 }, { 1,28,5,0,36,24,65,83,50,14,67,22,12,96,2,48,218,114,281,54,18,21,9,133,55,103,46,181,37,58,160,38,16,7,99,10,223,69,238,32,430,433,502,45,35,51,766,49,108,86,23,124,361,155,487,765,532,283,75,137,270,115,17,838,163,109,480,95,13,61,6,543,154,754,513,70,29,72,202,540,822,657,323,920,398,89,68,64,141,966,3,221,208,285,128,290,956,547,488,269,236,175,168,429,194,474,800,646,171,39,412,775,52,308,531,866,149,880,389,4,180,403,318,842,834,402,217,185 }, { 138,174,348,42,25,6,145,81,544,280,525,74,85,26,648,204,355,287,396,91,233,66,636,104,122,746,416,29,64,65,90,45,0,235,194,681,87,22,222,651,95,624,573,32,214,289,750,415,343,445,192,52,112,86,17,370,19,5,135,881,7,151,2,337,113,605,243,63,389,256,49,59,10,4,673,680,77,18,297,61,312,76,614,97,72,249,283,11,524,70,353,33,27,28,216,114,874,173,311,57,43,21,14,597,36,1,141,102,58,24,217,12,436,665,80,172,715,792,148,123,619,56,133,20,491,75,784,117 }, { 24,16,35,68,0,18,158,28,71,159,49,7,55,154,109,14,22,60,105,124,344,65,118,424,9,239,95,1,320,2,149,577,286,170,92,169,108,347,12,21,327,374,175,185,67,10,272,5,101,51,48,23,302,455,39,6,671,301,46,13,69,310,20,518,64,150,36,346,50,32,137,202,709,677,191,126,98,125,375,168,538,289,164,38,37,128,638,30,703,747,890,273,127,634,31,419,140,143,439,86,403,114,252,83,962,654,221,762,623,338,115,29,212,103,701,570,308,107,512,189,54,97,167,230,479,345,312,913 }, { 854,699,230,352,93,689,144,251,160,137,855,202,617,203,217,36,669,332,450,120,473,351,831,201,213,752,326,800,206,141,258,748,82,418,345,30,180,816,957,318,840,190,443,228,44,35,863,968,10,1,219,871,704,317,64,22,679,83,466,539,498,224,55,96,898,31,116,406,851,384,86,244,295,28,873,98,817,531,187,822,864,373,494,131,559,372,530,901,574,365,69,127,839,735,128,268,67,533,442,868,860,922,88,269,927,859,9,367,613,253,564,930,567,261,260,728,39,237,109,284,276,164,730,489,166,926,125,776 }, { 15,13,5,1,2,23,3,0,317,51,115,4,10,11,7,6,217,33,9,77,17,14,341,165,102,117,180,365,134,40,197,153,64,22,12,32,196,21,8,141,391,110,752,372,291,498,352,125,569,16,36,901,202,59,260,28,237,482,349,18,269,457,961,120,318,93,57,509,37,29,128,177,49,31,19,401,48,453,342,38,719,873,45,55,629,111,24,44,143,468,386,50,54,403,86,139,27,308,304,95,210,546,730,475,46,137,98,247,35,72,90,99,82,76,437,494,864,30,326,758,96,52,275,116,402,277,164,56 }, { 104,173,20,319,43,66,426,355,712,77,97,0,202,7,198,74,580,204,174,500,32,5,59,2,102,337,90,325,226,234,4,52,22,450,904,155,222,376,861,21,750,33,192,414,194,147,324,342,889,58,544,636,18,291,416,112,784,81,334,64,707,95,331,422,639,715,36,400,14,141,560,792,65,29,177,49,37,315,427,28,57,10,120,24,1,40,48,107,673,11,494,318,230,61,524,128,196,16,12,470,632,232,138,115,329,455,113,142,186,153,819,294,17,525,526,70,117,87,25,247,587,105,269,583,588,158,171,348 }, { 23,13,51,5,15,1,2,115,0,141,12,7,4,21,6,165,32,3,269,9,10,457,202,180,197,14,77,11,37,453,22,318,352,120,33,719,217,341,401,403,16,961,17,40,308,18,31,28,8,48,64,475,569,730,260,365,59,128,247,317,137,177,90,93,237,102,99,629,523,44,386,117,36,450,110,153,30,752,899,38,349,72,134,98,509,498,49,326,901,125,24,391,196,421,57,82,291,76,95,19,203,494,89,45,817,304,468,221,139,210,758,351,546,65,373,372,96,54,482,734,144,116,86,39,29,216,402,288 }, { 15,1,13,0,2,5,4,23,3,317,115,51,7,6,341,9,8,365,217,22,10,33,77,31,457,197,44,901,18,12,28,180,11,120,165,202,961,102,719,569,40,308,21,730,20,260,351,523,141,36,401,64,482,82,55,49,450,453,403,269,93,318,16,30,498,468,342,14,372,352,110,61,817,125,137,386,117,70,899,25,898,291,509,196,494,475,24,629,854,39,153,349,98,32,134,221,391,416,234,758,59,37,237,95,86,19,91,48,27,177,247,326,903,17,734,873,89,128,421,105,922,57,111,143,638,300,304,90 }, { 15,1,3,2,0,4,10,5,9,13,82,12,8,11,16,7,31,23,351,898,365,93,44,854,22,64,21,457,217,180,6,141,317,730,110,318,18,752,719,352,341,51,961,28,269,33,260,77,922,120,202,291,98,55,372,197,349,901,105,165,30,450,14,817,494,523,403,899,128,125,453,95,36,115,116,475,386,326,49,401,111,94,811,642,758,479,474,391,373,203,201,187,153,144,137,38,37,24,102,59,421,282,206,48,569,342,275,216,210,864,846,801,795,692,661,597,559,442,253,244,230,196,177,170,143,127,123,89 }, { 2,5,14,1,29,50,38,46,45,17,52,58,114,133,171,218,21,181,48,186,36,6,155,3,19,65,487,12,32,54,27,61,480,323,70,22,51,86,361,137,96,0,208,115,285,227,283,151,23,412,10,281,28,108,37,236,112,328,7,334,163,400,25,4,223,26,67,75,657,194,18,103,128,24,13,514,745,99,401,202,308,532,59,803,389,16,760,11,243,72,64,80,106,9,502,83,832,113,453,56,552,421,403,503,402,95,735,341,956,69,124,782,366,90,141,409,77,57,160,822,433,89,209,244,40,76,177,484 }, { 68,101,0,9,212,124,154,65,149,35,16,100,118,24,252,71,562,589,189,336,114,167,265,191,39,329,398,88,67,429,1,264,478,69,166,484,55,30,777,18,399,520,759,13,818,722,175,419,230,48,283,664,796,115,23,28,375,724,346,140,133,103,410,21,705,806,64,51,701,604,83,246,7,345,158,389,60,36,382,302,14,2,108,50,755,5,695,694,237,702,547,917,92,639,411,936,732,213,267,238,32,404,190,10,364,321,289,49,180,553,447,247,650,72,218,46,593,925,468,458,96,905,596,217,95,546,223,439 }, { 14,2,1,22,46,67,7,65,28,24,0,69,38,168,50,36,83,289,5,12,16,29,35,55,86,114,103,133,109,49,18,158,95,108,6,194,584,124,185,610,52,169,10,159,189,105,51,23,21,484,283,9,505,389,236,128,239,267,420,164,13,547,143,54,32,64,71,115,149,75,37,140,251,68,48,208,160,253,708,309,137,96,154,244,312,170,782,202,320,412,577,175,308,424,25,141,336,429,218,344,60,892,835,874,347,398,401,531,230,17,278,388,92,135,797,638,732,237,3,323,39,19,286,99,747,4,66,403 }, { 23,13,51,15,0,10,115,1,4,2,9,961,457,77,11,5,453,12,33,3,403,14,40,102,197,7,22,165,59,475,64,6,37,401,21,569,719,18,308,99,32,17,177,730,16,141,523,8,341,31,629,217,180,117,386,202,153,196,120,57,28,49,111,125,95,139,899,494,128,421,72,65,210,317,36,342,391,90,19,93,89,44,86,269,365,24,291,237,110,76,318,873,509,482,54,48,300,498,247,134,450,82,275,260,352,98,27,137,326,38,304,758,148,50,79,817,45,670,372,30,179,29,203,734,152,116,349,216 }, { 15,1,0,2,5,9,7,23,13,51,901,8,6,12,3,4,180,10,719,341,120,14,31,115,22,141,898,197,82,260,93,21,28,44,457,37,217,125,202,16,153,351,64,110,401,18,11,33,36,961,569,30,77,49,352,450,98,269,139,317,117,116,32,40,453,326,308,128,523,318,365,203,137,730,24,629,854,403,102,39,237,165,55,291,99,475,95,196,48,86,498,134,752,899,373,391,817,244,38,105,242,421,922,59,144,386,57,143,35,349,54,509,482,372,65,253,221,177,304,494,247,638,17,170,72,127,164,114 }, { 100,252,265,88,724,101,382,410,48,676,213,909,321,9,593,0,812,329,553,21,352,1,30,230,166,39,419,520,23,51,264,217,221,478,689,435,190,664,13,604,466,677,694,125,752,777,36,98,699,639,83,759,96,35,158,68,128,562,141,223,344,274,310,69,455,115,5,180,404,317,656,364,203,293,831,438,175,308,443,401,333,31,144,570,154,854,105,137,212,346,49,857,530,418,840,855,201,55,921,28,539,421,557,806,821,127,124,67,251,10,634,165,936,22,610,795,16,286,957,167,541,32,962,905,682,686,241,44 }, { 58,171,2,46,5,50,14,29,186,1,52,45,334,151,400,38,155,61,103,96,67,227,502,281,223,54,48,17,83,181,552,69,70,309,75,163,24,549,21,311,27,366,80,536,243,113,218,787,106,36,112,433,765,430,209,133,12,6,236,487,19,780,675,394,766,238,587,545,32,37,767,807,834,7,108,114,328,287,315,65,262,820,16,496,583,26,18,454,513,0,3,600,220,25,474,86,307,73,28,35,255,869,537,631,22,72,89,491,409,357,64,270,828,267,189,845,160,221,10,592,137,119,99,659,128,516,541,785 }, { 23,202,120,141,51,13,318,269,21,128,260,165,137,197,180,326,1,450,5,77,33,82,15,48,93,64,110,351,32,125,403,203,102,523,854,386,352,457,922,115,7,2,12,494,373,817,615,196,342,153,221,217,16,6,210,144,402,453,36,4,391,14,37,730,9,96,475,291,98,0,99,901,3,421,551,177,18,40,401,237,752,349,31,898,86,719,341,24,704,285,117,11,308,393,116,35,61,160,8,30,65,90,59,44,275,10,241,50,39,216,509,372,67,72,961,247,22,899,28,569,293,83,139,801,473,76,95,46 }, { 341,197,901,10,13,569,23,638,15,479,8,873,961,180,165,143,12,115,0,1,951,509,116,37,642,365,499,498,242,253,5,36,898,4,752,2,352,141,268,206,51,55,401,391,7,22,3,417,506,492,82,9,93,11,137,456,338,244,457,64,317,120,110,629,351,546,431,33,21,386,31,86,260,217,164,6,758,965,28,762,474,918,661,326,551,153,125,14,719,94,421,854,203,801,373,269,44,16,730,202,615,237,844,791,811,523,450,40,18,128,864,282,117,111,148,824,940,102,959,17,139,559,170,32,958,867,968,38 }, { 23,1,21,51,202,13,15,141,120,5,180,2,197,165,7,269,352,48,12,318,260,326,137,33,386,403,9,450,0,32,6,4,115,128,14,16,523,457,102,37,110,82,93,18,217,3,64,221,752,421,203,453,237,125,77,153,351,494,308,475,196,401,719,31,44,391,373,817,24,730,8,342,30,36,11,40,341,901,96,50,99,615,98,116,117,39,10,22,498,317,17,59,35,160,144,86,28,20,854,961,291,244,177,899,72,402,509,90,922,350,349,95,29,247,285,19,127,661,365,372,49,569,758,65,576,241,898,61 }, { 2,29,58,50,262,52,53,27,6,151,14,1,171,5,287,34,324,17,74,46,26,113,309,396,45,223,61,334,96,73,635,445,583,38,19,75,67,103,80,357,70,331,181,573,112,785,236,675,163,281,549,145,366,54,108,315,760,218,220,491,453,297,12,138,62,250,133,436,51,409,200,487,600,128,502,37,64,106,114,651,48,83,394,24,25,820,433,59,766,307,23,155,36,614,311,65,66,137,57,4,765,186,69,21,99,202,56,13,3,587,165,767,7,631,238,86,780,115,283,161,322,545,221,42,32,739,400,47 }, { 13,51,23,141,202,115,217,77,317,4,269,33,5,11,318,352,0,102,180,2,64,10,341,7,21,9,137,3,40,128,32,6,22,291,752,15,197,12,365,1,165,31,125,28,498,177,16,403,494,237,18,308,44,59,372,98,349,24,93,48,244,386,49,90,30,342,95,901,475,39,120,196,14,117,457,116,453,17,247,391,153,8,143,482,36,304,203,110,509,326,450,260,37,134,144,210,468,523,86,221,401,569,873,546,719,139,253,35,160,127,285,105,373,421,961,864,576,82,367,437,351,55,579,19,216,275,402,164 }, { 1,24,67,50,69,103,35,18,16,14,28,0,5,83,9,54,223,2,96,58,181,12,46,68,48,65,108,133,71,281,149,22,7,163,21,114,36,75,38,55,155,502,238,37,189,99,70,218,45,10,430,433,236,60,765,251,171,61,175,540,23,820,32,51,418,270,29,487,513,52,124,118,336,17,64,49,920,154,13,141,115,545,72,267,221,537,745,290,86,488,309,128,335,39,227,89,328,160,95,834,361,6,101,486,514,543,112,137,474,394,186,202,388,109,150,140,552,807,412,283,307,345,87,780,366,398,77,516 }, { 13,23,51,141,202,115,77,269,64,217,102,128,318,33,32,291,177,180,137,10,352,4,21,16,197,0,11,22,9,7,165,90,40,494,125,2,210,247,14,18,153,49,59,31,6,95,317,28,196,349,24,304,5,341,403,342,98,237,117,120,372,44,3,275,35,86,48,1,93,752,36,15,241,12,475,144,30,19,17,216,110,365,260,116,326,134,82,105,143,308,203,20,39,402,386,221,901,127,72,498,437,244,453,76,401,65,38,96,285,316,160,55,351,25,288,482,164,57,139,457,678,490,201,523,509,391,83,817 }, { 115,365,180,317,873,498,752,482,341,569,217,901,13,197,352,546,468,1,864,457,509,579,165,23,143,21,15,2,185,36,7,148,12,134,332,22,351,9,261,51,16,5,10,0,346,93,30,141,868,734,372,253,345,116,474,94,77,876,76,28,896,679,384,203,160,39,37,6,98,14,391,109,530,187,843,177,86,629,33,637,11,437,18,4,902,574,434,144,120,44,31,837,72,613,295,169,349,505,228,190,102,95,49,48,706,406,405,96,83,961,617,597,254,237,926,903,717,531,420,258,164,110,860,268,661,477,464,449 }, { 184,257,229,205,432,497,152,619,452,17,381,57,266,524,5,45,90,106,313,471,245,32,128,129,59,4,214,2,339,119,769,77,369,12,123,21,14,99,157,3,202,38,710,1,618,216,64,217,292,188,162,76,11,40,249,141,62,51,33,19,372,102,179,37,209,23,27,6,111,318,29,61,403,86,460,349,207,54,269,402,10,48,139,115,36,136,79,137,7,255,72,80,177,519,291,453,529,401,288,58,0,153,475,377,247,306,25,56,26,94,210,22,84,494,50,790,89,775,474,361,328,148,241,588,285,317,678,277 }, { 13,23,1,2,0,51,10,5,115,4,15,3,365,7,9,33,11,180,77,6,217,341,22,102,317,40,197,14,12,64,141,165,18,8,17,31,202,28,125,16,269,21,117,901,453,196,177,59,153,36,128,475,318,569,32,24,352,291,403,134,93,401,98,44,752,237,391,372,49,509,457,961,873,308,498,386,95,342,349,116,137,37,139,494,19,30,210,247,143,304,86,629,48,203,111,55,57,719,523,110,482,546,120,38,65,54,326,421,216,730,50,99,899,758,402,260,105,275,39,72,450,96,144,35,25,242,29,437 }, { 626,70,687,771,379,767,846,518,878,49,937,591,82,761,31,786,481,407,845,195,590,351,98,44,163,557,13,120,125,48,87,883,371,623,360,817,450,260,178,522,21,5,854,523,116,326,105,291,142,4,296,929,884,259,127,0,132,922,615,77,713,293,217,197,165,22,146,64,931,608,465,457,349,196,32,941,455,279,621,315,202,201,126,110,40,16,11,10,391,666,467,446,373,354,346,144,58,33,581,763,512,916,535,795,768,658,558,447,344,150,92,51,28,24,9,265,212,93,586,562,180,156,147,134,117,1,783,663 }, { 264,909,410,897,772,1,686,521,478,914,98,335,96,284,691,639,382,44,744,321,724,100,765,438,223,662,88,144,475,367,31,265,125,116,921,9,682,656,166,363,127,225,21,201,842,0,447,905,393,48,443,421,5,82,329,252,120,805,411,51,821,13,919,69,834,948,934,664,33,23,435,551,274,77,217,131,268,7,93,854,418,520,340,110,30,213,141,453,165,101,39,791,260,922,403,238,698,898,351,102,593,433,64,203,83,303,286,293,197,32,960,812,697,523,466,285,180,692,404,658,35,873,254,163,352,553,190,615 }, { 13,23,2,51,1,5,115,0,10,77,15,217,7,6,180,33,3,317,40,4,141,102,9,197,11,341,14,64,165,22,365,17,117,196,352,202,12,269,153,16,291,237,453,128,457,498,752,32,18,134,177,59,21,125,386,318,901,28,8,372,31,349,391,403,95,475,36,137,569,49,308,961,401,509,482,143,98,19,24,44,730,86,120,719,139,546,402,342,93,304,110,29,210,421,873,45,38,629,57,260,326,247,111,275,30,523,55,90,450,46,116,253,50,37,244,65,494,105,99,468,758,25,170,48,96,216,35,27 }, { 141,269,77,115,13,318,64,202,177,23,137,217,102,291,5,51,180,48,21,352,0,32,7,16,33,18,11,2,197,128,4,15,10,752,24,244,14,494,317,165,96,9,3,349,247,237,93,35,28,12,6,49,44,1,421,60,20,403,36,341,95,22,475,372,326,308,275,196,144,90,40,39,117,31,678,954,901,304,284,268,221,203,110,98,89,68,46,365,153,134,76,67,576,453,432,402,381,342,179,125,118,86,72,71,69,59,50,17,498,160,164,143,120,111,82,961,873,851,401,377,335,288,285,241,223,210,121,116 }, { 23,13,51,15,0,10,453,2,115,1,40,961,33,11,14,4,9,457,22,401,77,102,7,5,569,475,197,12,64,3,21,165,59,719,629,6,196,18,177,386,37,32,17,111,153,57,117,139,31,16,28,730,308,99,38,141,8,403,36,128,670,391,217,210,72,90,523,79,482,341,202,237,45,474,180,125,41,509,46,494,304,275,48,54,95,94,899,29,277,134,120,76,758,65,44,247,498,24,291,148,89,468,86,49,437,82,56,30,402,143,365,349,317,93,50,757,269,734,342,98,352,450,678,62,188,19,152,328 }, { 1,22,36,5,12,0,105,28,2,49,31,21,95,9,86,55,13,23,128,7,141,98,170,44,115,239,37,48,127,83,160,4,180,164,51,202,10,269,3,96,6,208,159,137,67,244,320,197,312,50,318,352,64,285,301,125,341,32,165,109,116,217,14,402,708,39,365,16,654,35,30,242,317,169,168,99,253,15,678,11,69,751,569,54,531,752,8,901,947,338,735,77,24,238,143,323,498,158,65,401,17,237,293,946,18,717,740,597,93,512,638,286,403,395,892,144,347,308,299,424,457,185,418,713,194,221,757,824 }, { 100,252,101,88,265,0,382,759,329,410,724,9,213,321,553,676,419,593,166,39,21,30,909,694,562,520,68,13,812,264,23,435,677,230,35,352,478,48,190,154,689,212,1,217,570,51,466,639,124,221,83,806,604,175,699,826,703,125,98,308,55,671,664,346,32,158,610,706,96,962,274,31,317,289,344,69,438,49,28,831,917,115,656,455,936,404,165,116,208,777,310,5,854,857,16,201,128,36,333,752,194,67,24,71,144,795,391,197,589,141,818,364,921,131,44,86,203,251,748,105,65,22,180,557,149,702,350,855 }, { 539,88,840,190,30,321,530,957,435,748,669,778,144,96,100,466,418,863,410,203,228,213,382,274,795,406,613,131,36,822,1,83,326,856,219,352,335,494,251,230,679,31,224,960,44,831,855,141,859,944,217,9,367,160,201,137,625,128,166,93,258,662,120,800,521,403,116,98,187,28,576,752,816,269,202,557,39,931,21,265,686,616,443,921,10,180,731,438,689,523,473,125,871,317,23,77,197,457,827,55,264,35,617,692,254,33,719,260,86,966,817,32,829,206,276,127,242,475,456,284,51,615,252,0,854,238,492,551 }, { 7,97,173,92,232,298,314,107,387,729,356,43,359,126,246,140,362,441,501,426,392,230,560,20,14,707,885,104,16,66,330,779,172,683,60,35,493,861,22,357,5,0,95,49,81,279,38,568,18,24,21,74,192,71,414,830,423,259,324,2,121,526,125,633,508,32,672,52,319,10,150,48,28,147,29,46,715,347,6,64,199,380,189,61,858,69,660,33,204,135,649,713,36,595,1,98,37,879,31,146,132,75,819,263,784,443,408,607,448,54,12,663,138,68,58,117,102,70,13,267,65,55,712,91,153,77,399,165 }, { 14,2,7,58,46,1,38,16,75,5,70,52,24,155,29,45,220,35,163,69,50,171,61,186,87,227,18,270,92,48,666,54,32,290,140,21,278,592,513,307,67,112,262,6,66,60,37,0,135,243,97,767,64,425,23,89,71,72,409,400,128,845,113,17,334,36,22,172,20,10,315,115,76,141,9,28,51,12,663,103,86,74,77,207,13,65,177,90,263,83,267,202,95,137,43,269,151,294,189,27,25,431,19,49,428,430,68,40,223,536,852,106,738,324,226,655,474,780,96,502,496,217,114,108,318,230,102,148 }, { 447,411,664,363,647,478,936,621,354,271,98,781,759,223,777,1,360,18,691,668,48,932,167,156,132,121,212,195,591,446,724,520,118,586,146,21,23,463,31,293,9,264,393,16,51,914,13,125,807,101,49,834,284,44,60,163,682,24,848,221,658,541,5,105,35,71,68,55,96,39,116,562,407,32,905,604,22,252,772,0,33,765,522,69,10,963,67,191,93,100,638,676,166,340,364,120,281,698,608,286,821,404,50,115,382,144,77,265,697,64,28,102,909,126,410,30,628,82,662,95,367,7,815,127,744,335,40,296 }, { 14,2,1,46,67,65,38,7,69,36,29,24,83,28,50,0,22,103,5,6,52,124,108,484,168,12,114,86,75,133,208,18,16,194,236,283,289,389,21,610,10,109,756,160,25,267,35,23,51,95,32,309,55,505,135,584,71,13,185,66,547,128,189,37,732,54,96,48,169,646,17,49,412,9,420,158,87,19,323,115,278,244,26,64,218,164,70,143,253,74,238,140,220,398,172,45,137,58,149,262,797,141,92,308,4,3,503,302,202,60,68,388,154,159,118,650,531,90,516,366,150,285,105,532,335,251,671,429 }, { 386,421,51,791,801,697,958,730,453,23,165,551,221,670,615,326,401,391,576,403,13,102,457,899,805,523,842,770,48,24,450,475,0,203,125,949,541,719,566,77,193,115,308,197,21,18,398,153,33,393,317,117,43,202,137,743,120,300,7,124,467,5,91,108,9,71,342,291,118,42,32,16,97,134,85,279,61,260,173,289,281,517,494,14,859,817,196,60,809,758,692,36,882,25,194,388,20,373,302,140,65,547,429,273,851,717,458,412,122,104,95,509,233,81,492,318,6,362,832,110,69,92,49,149,35,508,298,608 }, { 319,104,945,422,81,20,715,43,0,879,693,681,306,32,784,74,173,207,61,7,22,52,397,671,414,904,887,636,240,95,6,115,835,192,5,707,91,426,18,2,76,29,819,330,316,263,56,85,138,84,28,232,577,365,64,97,113,519,312,725,526,17,344,370,204,49,202,214,329,24,38,560,403,750,66,494,10,804,500,241,25,105,289,718,159,587,523,77,124,102,86,861,348,498,450,292,51,288,90,117,140,65,899,510,168,347,158,16,448,45,817,237,107,324,33,9,194,180,120,318,92,790,40,280,21,356,320,874 }, { 2,29,70,1,52,262,75,112,26,145,46,163,309,58,103,67,14,50,6,220,96,74,38,394,223,331,357,19,83,238,45,69,5,324,171,287,27,409,151,25,366,307,24,583,218,537,133,108,632,42,267,396,451,53,36,433,87,114,65,17,113,635,186,764,550,545,226,600,138,675,388,66,37,21,61,54,48,181,122,516,12,606,294,236,418,73,35,189,18,80,86,486,487,651,135,155,150,7,32,16,137,644,243,739,281,222,445,334,278,380,573,149,849,106,227,582,603,160,335,34,64,283,696,648,765,624,297,72 }, { 771,929,786,941,590,626,687,259,465,178,70,878,132,5,13,21,534,146,49,518,279,48,107,35,379,493,31,147,125,767,105,108,87,195,221,481,126,121,44,163,22,623,23,127,61,581,407,362,0,150,165,937,427,58,846,345,371,142,883,467,167,761,120,33,10,640,98,75,591,360,391,1,663,271,77,30,199,4,845,763,522,60,185,102,291,7,349,159,156,137,128,246,450,51,308,296,293,239,32,11,158,423,558,557,342,269,116,39,260,112,17,386,232,502,441,281,196,153,95,37,12,783,953,612,535,401,197,15 }, { 5,186,45,2,61,29,50,227,52,400,58,17,46,48,171,209,14,155,106,243,80,311,38,1,430,281,496,54,502,536,255,181,454,513,103,96,592,760,3,334,207,21,666,67,119,552,587,869,663,62,151,541,27,32,583,309,721,84,56,37,659,218,133,366,221,136,83,540,6,834,72,36,223,270,667,290,738,12,328,34,807,89,287,263,474,19,487,262,236,238,148,76,75,115,69,425,240,378,99,26,394,24,766,433,483,128,114,306,70,549,65,324,600,675,828,357,764,53,780,108,545,73,137,161,7,833,90,765 }, { 0,95,453,64,32,389,494,817,342,207,312,365,577,690,194,403,848,237,202,316,180,671,5,482,757,61,490,805,102,289,498,450,65,835,475,523,113,49,401,241,887,115,120,263,329,21,17,18,576,22,33,137,344,13,318,402,77,3,1,899,11,48,347,4,210,141,118,125,90,51,933,942,260,23,645,874,306,308,117,134,597,615,27,247,12,196,24,122,19,6,2,751,697,743,317,468,291,25,16,288,177,730,629,28,86,84,349,770,421,214,611,592,491,483,476,425,56,36,670,300,275,153,217,621,350,39,71,60 }, { 23,13,51,202,115,15,5,1,12,4,2,77,403,165,0,21,10,318,453,32,457,33,128,197,9,7,6,141,3,401,475,59,177,269,14,11,308,17,37,494,22,719,217,99,64,341,180,117,18,90,40,102,120,16,317,730,961,569,48,365,28,421,386,352,629,8,38,523,450,237,31,291,402,125,210,137,247,216,19,391,196,57,221,36,509,326,260,72,93,24,349,275,153,203,49,95,498,342,304,899,45,134,82,44,76,30,468,372,98,89,27,817,25,139,86,110,758,65,54,29,111,546,351,116,241,46,20,482 }, { 119,292,6,45,306,76,2,26,240,209,17,61,710,106,5,80,29,19,27,25,214,84,113,32,64,618,129,255,128,1,179,90,123,4,59,65,151,14,58,667,40,460,311,56,504,22,245,86,249,207,0,790,141,205,42,95,77,483,3,833,10,112,115,202,7,23,18,887,137,194,11,52,57,36,62,136,269,476,177,162,99,33,491,21,257,73,769,454,12,70,38,28,402,13,24,145,16,48,72,318,184,196,614,445,122,102,53,114,49,117,153,210,548,285,46,54,464,134,180,51,396,50,297,183,315,243,237,814 }, { 15,1,23,13,51,180,0,2,120,5,7,9,450,523,33,12,115,260,197,102,165,6,202,77,4,21,141,14,457,351,403,341,16,901,8,326,82,308,365,3,269,18,36,137,93,318,48,128,386,59,31,37,719,217,453,401,730,817,22,110,44,475,64,317,352,10,32,28,421,494,40,30,116,98,11,899,342,373,752,196,24,615,221,177,86,291,49,854,203,39,99,509,961,96,144,569,898,55,922,35,391,210,117,244,629,125,349,498,873,17,50,247,372,89,160,758,237,670,300,95,127,143,153,65,285,402,90,801 }, { 6,138,222,280,74,85,66,226,337,87,42,204,235,25,145,294,64,135,95,174,609,29,112,415,256,26,65,525,792,461,353,32,580,22,52,122,746,172,630,544,289,70,348,416,237,287,19,278,49,312,86,605,75,10,108,2,0,194,192,5,620,1,7,21,90,97,736,220,63,45,632,500,114,214,61,355,36,151,233,396,180,58,69,24,125,141,72,28,14,648,27,519,673,889,872,624,241,444,288,18,343,197,48,426,33,207,133,665,263,232,113,73,347,91,17,568,448,316,103,208,165,128,104,53,380,12,81,498 }, { 39,9,333,101,0,158,252,310,254,272,455,68,49,627,327,344,159,286,419,364,18,16,709,329,24,688,105,265,109,30,100,553,118,374,35,557,166,124,190,154,677,131,65,578,912,71,793,22,60,518,1,538,51,167,21,23,98,28,212,48,95,438,604,625,13,404,7,31,96,55,127,520,36,731,137,890,857,125,320,616,694,656,806,716,44,577,5,10,170,224,67,83,829,168,242,219,228,128,191,14,239,827,88,86,301,347,12,424,160,747,810,37,115,64,846,346,371,613,69,910,221,33,149,2,562,93,865,676 }, { 21,32,14,5,38,76,72,2,48,54,270,45,1,17,50,46,221,290,181,89,36,430,3,741,428,218,408,155,37,540,281,449,0,10,12,148,179,90,241,263,207,29,292,133,425,22,477,328,99,51,697,421,114,67,770,487,115,476,23,4,528,227,65,28,6,119,243,488,214,720,552,541,86,474,24,52,350,64,61,7,9,137,11,186,103,536,401,129,745,413,106,58,83,96,920,308,236,13,57,513,123,18,842,464,543,361,245,160,56,59,205,128,655,431,514,358,828,285,171,108,460,55,62,400,27,16,453,40 }, { 137,269,141,202,120,450,260,318,494,922,351,291,82,77,5,326,678,352,704,854,128,523,1,817,21,15,64,349,180,342,32,13,475,90,177,947,7,372,61,51,49,23,165,95,403,11,207,115,312,102,4,48,197,237,402,719,203,50,96,308,30,6,2,373,205,86,70,69,67,36,210,241,105,898,859,851,615,208,194,217,901,285,25,453,216,182,163,87,65,46,45,8,0,457,31,307,139,112,58,37,12,3,117,968,158,127,20,730,386,273,199,178,168,147,126,108,60,28,18,16,10,9,954,795,597,275,247,134 }, { 16,68,71,24,149,35,191,118,167,212,18,124,101,246,108,399,189,154,140,92,267,9,60,375,65,458,695,302,133,67,398,589,7,0,69,230,114,562,702,1,705,103,55,915,755,283,21,388,602,336,412,48,14,175,273,650,50,345,823,674,411,46,121,146,28,363,236,447,39,10,64,672,22,664,478,796,264,309,330,271,100,520,647,37,95,218,199,12,906,23,565,36,83,32,252,777,88,166,628,126,5,13,125,49,75,2,366,51,96,86,732,486,346,54,815,237,733,429,98,891,759,516,633,818,115,443,723,238 }, { 28,109,0,9,67,22,1,55,65,114,103,158,39,49,83,194,168,69,35,420,185,289,36,50,208,24,68,133,2,124,505,251,218,175,86,46,7,389,323,154,95,169,159,346,12,547,160,14,756,101,646,16,570,105,30,5,799,189,533,38,531,96,503,238,596,252,128,64,535,23,54,18,21,344,51,782,272,336,610,419,283,532,345,333,480,13,100,10,37,137,327,115,789,584,149,286,230,361,48,75,285,181,202,29,254,374,164,429,927,141,71,896,143,671,930,577,32,237,140,810,244,484,439,31,131,601,402,310 }, { 325,147,427,198,178,142,798,202,259,5,376,20,534,43,465,450,904,318,234,470,858,77,725,455,120,581,329,315,70,97,61,929,105,878,786,113,362,260,58,557,481,403,660,14,639,21,173,0,170,49,159,494,319,269,48,23,344,523,128,107,301,595,1,845,518,416,33,884,817,324,320,13,326,199,22,475,402,158,37,270,132,51,40,38,35,32,7,95,590,121,4,422,239,141,104,66,146,347,112,615,263,230,126,75,28,307,76,207,704,414,360,265,195,9,922,453,356,298,19,17,137,72,342,290,102,87,50,395 }, { 28,0,65,109,9,35,55,175,124,67,289,24,39,158,68,114,14,336,570,154,420,1,22,7,185,168,69,133,194,49,16,429,149,101,46,505,83,189,2,103,169,346,50,252,484,36,547,389,610,283,18,756,95,419,159,535,345,251,86,71,105,12,108,398,100,230,30,140,439,333,533,344,584,703,21,208,272,286,671,38,5,327,267,10,64,601,23,254,51,96,118,810,13,48,164,782,265,128,364,236,29,143,160,837,329,374,677,54,577,218,310,637,399,60,37,962,797,92,166,323,793,705,32,238,732,75,6,596 }, { 141,180,115,269,13,23,4,1,352,5,202,318,51,317,2,217,21,752,365,77,3,7,165,341,197,32,0,137,11,308,10,6,901,33,15,9,31,22,177,102,403,64,401,12,30,44,498,237,291,48,143,244,93,349,569,40,494,28,8,39,253,125,372,90,221,98,453,304,386,482,873,509,203,120,110,116,18,59,49,457,144,128,95,247,391,864,326,117,16,421,37,153,14,196,475,36,629,134,105,210,260,961,373,160,164,55,719,546,437,216,734,35,468,350,201,17,139,96,89,579,473,72,758,717,111,24,743,275 }, { 15,0,1,2,9,23,13,5,7,51,12,6,4,8,901,33,3,180,14,197,10,341,115,77,102,93,120,141,260,22,21,82,457,899,31,64,453,28,165,16,450,18,523,11,351,475,202,36,110,37,203,401,125,30,352,898,44,403,961,730,719,116,128,569,421,365,196,49,40,98,32,217,137,373,269,39,308,237,144,55,854,153,177,318,317,86,326,24,17,117,95,629,48,817,752,59,300,670,498,99,391,494,386,291,134,38,105,90,642,342,922,873,242,143,244,253,393,473,221,50,247,372,57,349,139,65,111,661 }, { 6,74,138,66,75,85,25,324,42,380,278,135,26,500,87,226,1,220,97,29,70,222,889,841,52,350,19,606,280,235,294,394,112,571,69,853,21,38,145,335,903,267,582,65,550,309,14,172,792,509,32,2,197,64,749,262,237,174,241,357,122,95,461,486,808,67,337,256,537,96,103,115,774,546,204,63,125,27,391,22,558,462,83,451,7,238,630,5,308,802,24,165,108,734,46,163,140,950,648,641,92,45,13,298,189,416,583,525,150,72,923,86,600,48,114,53,331,221,388,12,620,180,468,426,90,645,746,348 }, { 51,23,13,453,12,115,403,4,457,401,165,475,15,0,1,10,11,37,59,5,99,40,3,308,64,197,32,2,33,202,17,9,719,77,629,730,7,14,22,6,961,21,569,523,494,421,386,18,120,141,57,125,177,318,269,102,237,128,90,38,899,341,45,450,111,76,16,180,217,19,36,31,134,117,247,49,670,139,72,28,210,95,291,196,402,153,41,25,24,89,509,216,260,8,93,86,54,221,82,137,65,468,758,26,56,44,27,317,391,352,817,365,304,62,349,123,498,48,34,326,275,152,775,342,114,372,300,757 }, { 788,180,319,21,5,83,32,498,314,547,526,17,693,61,817,48,11,4,27,510,33,12,848,77,288,104,24,160,0,814,120,64,3,804,153,134,117,56,519,342,196,102,207,725,326,690,523,450,69,40,403,95,899,306,60,958,90,961,942,801,500,232,174,155,84,43,38,115,945,457,386,595,475,615,247,887,715,671,494,482,365,192,13,312,202,165,10,9,81,51,566,65,71,119,113,861,835,802,770,757,756,746,743,729,692,683,629,587,583,551,550,525,449,426,422,418,414,324,291,260,221,217,214,186,170,125,123,105 }, { 15,1,2,13,23,4,5,3,0,11,7,6,341,51,10,9,12,33,77,115,102,40,217,14,197,180,165,141,365,901,569,317,202,64,22,21,8,16,59,32,403,31,17,269,177,318,475,18,196,386,453,352,153,93,401,120,125,117,28,291,457,494,210,110,37,961,629,326,128,391,237,260,139,49,44,349,98,372,116,719,342,36,523,95,57,86,111,137,19,24,203,450,308,752,30,275,38,730,134,90,509,304,373,247,300,144,48,498,27,45,20,758,482,65,143,72,105,55,99,35,670,76,873,402,615,82,29,817 }, { 101,520,18,167,9,118,212,604,364,16,60,694,252,0,264,917,24,68,146,55,363,562,35,191,121,166,265,806,329,71,676,100,706,647,411,271,39,907,628,621,925,21,419,848,404,28,682,942,48,1,815,154,777,446,109,132,124,5,821,463,49,857,158,13,199,905,967,23,932,126,88,108,22,346,96,382,354,759,51,575,125,105,98,92,32,522,65,286,333,31,447,812,639,7,553,664,566,727,159,593,30,10,149,150,865,156,375,14,897,936,407,95,638,274,478,175,439,272,67,221,634,302,50,2,12,107,144,44 }, { 13,23,51,115,33,217,77,141,64,0,4,102,202,9,2,317,7,269,180,21,291,352,32,16,10,128,5,11,318,6,177,40,341,3,18,22,165,197,137,15,14,153,247,237,125,28,24,12,59,196,365,31,349,117,90,752,49,403,372,98,221,93,308,17,95,44,86,342,48,494,1,304,210,498,30,36,120,475,453,134,401,241,244,386,143,275,19,391,901,72,110,35,39,203,144,326,116,260,164,20,437,457,37,402,509,421,8,482,55,523,105,82,96,316,65,350,450,864,139,216,25,76,285,29,27,579,546,127 }, { 66,135,172,74,97,204,278,6,138,324,7,174,87,192,85,448,140,353,29,232,280,620,500,52,802,92,25,226,808,38,568,380,889,42,298,69,426,580,792,314,571,330,2,872,348,95,26,572,622,43,563,32,526,222,893,22,14,65,5,21,81,64,673,24,75,267,950,1,355,885,220,70,357,726,145,104,86,63,888,91,387,189,16,46,289,294,126,71,501,20,107,233,60,19,48,462,335,67,173,28,45,194,49,241,550,235,230,37,90,0,312,83,18,415,61,58,36,262,12,35,112,633,10,72,150,712,246,343 }, { 97,24,2,69,66,423,298,6,29,7,267,172,74,52,14,189,67,38,25,607,150,149,83,71,1,36,18,135,733,467,81,0,140,501,426,517,21,33,398,278,160,118,124,809,42,154,26,19,462,85,273,92,20,46,429,302,117,60,336,568,508,204,28,192,715,232,770,705,165,65,16,153,596,173,102,279,50,91,87,175,43,23,448,45,12,861,386,37,13,63,421,104,48,51,324,388,314,197,134,711,138,32,531,526,330,681,712,443,22,451,75,608,185,4,949,697,221,882,636,236,370,196,54,420,5,309,885,458 }, { 158,9,0,68,39,333,109,344,49,101,24,16,35,159,124,154,254,272,310,793,252,327,419,65,627,286,71,22,364,455,18,374,105,577,747,28,30,168,912,118,677,55,95,185,709,100,688,149,60,175,671,131,190,346,166,265,518,578,538,329,169,703,424,1,212,21,7,694,962,289,706,439,347,191,108,51,810,48,10,634,23,67,14,616,239,553,170,302,557,98,320,125,31,2,570,857,625,13,5,36,12,128,375,86,137,127,114,37,716,88,44,913,420,92,83,69,96,50,64,224,638,562,242,301,167,890,731,160 }, { 15,10,33,77,197,4,180,341,365,115,13,102,23,317,141,117,217,5,1,901,11,40,253,165,134,153,21,752,244,143,32,36,352,51,638,137,2,196,12,55,3,873,569,951,372,82,37,120,291,177,7,59,898,349,6,64,0,509,31,342,269,22,351,498,260,308,160,93,14,139,854,44,202,28,86,48,457,17,482,90,401,450,111,719,72,203,116,125,110,523,128,961,164,57,304,922,9,386,318,38,730,326,49,762,535,275,391,277,629,210,242,373,99,98,148,96,734,817,95,89,237,717,247,30,479,45,758,54 }, { 100,382,166,478,265,264,404,274,593,438,88,39,921,724,98,639,682,1,363,411,447,435,905,812,821,9,96,30,897,31,656,23,223,252,254,310,664,410,116,190,51,144,329,691,21,520,393,44,127,101,0,909,48,125,13,625,333,284,557,521,418,286,367,960,772,5,93,77,321,118,105,83,948,616,272,530,33,293,203,795,156,765,676,68,466,102,67,551,131,604,120,242,49,35,16,354,848,421,18,32,553,730,69,158,335,165,759,791,110,731,914,163,613,115,10,386,217,24,36,778,834,65,395,4,578,238,842,364 }, { 19,283,436,297,53,26,813,122,42,432,503,27,605,25,736,73,390,235,389,128,630,123,250,529,63,256,80,65,108,445,690,573,269,789,106,444,216,113,381,412,6,14,133,680,200,78,318,650,177,678,17,194,57,114,619,368,4,349,84,472,59,112,85,275,291,56,18,378,714,40,32,396,183,102,11,152,33,416,136,495,341,236,46,403,130,161,90,243,561,255,184,24,129,597,0,742,86,45,469,76,145,862,401,285,249,141,947,665,13,179,51,524,287,50,527,803,233,117,684,12,304,148,205,29,719,23,139,61 }, { 202,128,494,141,33,269,137,36,51,0,13,102,180,6,2,1,196,65,4,86,402,95,29,475,403,117,59,40,457,77,450,15,210,177,134,49,22,21,18,291,153,12,3,260,114,90,817,386,318,120,25,16,32,23,11,961,922,576,237,217,194,165,115,14,7,453,342,216,873,373,197,164,64,719,874,854,789,757,751,704,597,558,391,372,326,304,301,300,285,275,208,203,159,133,110,105,99,93,81,74,70,66,52,48,47,42,41,34,28,26,24,10,5,139,76,958,899,801,730,615,551,160,963,901,752,657,584,421 }, { 18,60,16,68,167,191,101,118,212,121,35,126,199,146,647,520,55,9,628,806,621,71,24,107,575,346,363,132,446,463,364,0,566,92,562,28,271,411,252,1,727,21,815,48,407,150,604,598,694,279,932,154,608,49,589,493,439,22,5,7,124,109,706,419,10,108,13,354,14,23,640,467,375,96,273,158,848,302,955,535,175,195,39,818,534,105,125,100,221,522,676,264,777,12,51,50,159,329,32,265,65,259,362,917,98,20,826,783,149,37,31,581,95,169,43,67,97,46,223,147,907,166,590,64,246,36,2,967 }, { 352,230,531,160,36,748,854,217,93,669,728,137,251,689,871,699,373,228,574,258,202,752,351,717,559,120,144,268,318,260,219,203,269,201,831,533,839,567,539,187,840,213,816,489,679,82,1,317,851,332,44,141,55,295,855,206,30,617,863,418,83,345,926,96,180,443,800,473,116,10,143,326,110,35,406,564,131,224,22,860,276,64,450,28,98,9,21,190,957,466,822,968,244,164,31,434,856,169,384,661,69,898,0,365,730,824,284,125,442,253,128,372,873,498,88,530,922,776,261,165,494,48,237,86,68,940,39,927 }, { 15,13,51,23,0,77,8,4,5,1,202,33,10,11,165,180,82,22,12,110,115,9,102,197,40,59,342,403,141,120,351,326,7,453,373,31,386,18,93,457,260,49,2,401,318,475,128,28,901,64,269,291,44,494,36,854,719,21,177,14,30,523,961,16,898,57,3,349,421,125,922,99,341,32,730,98,137,203,56,217,317,450,117,615,76,391,498,275,24,352,569,365,95,6,105,308,144,37,196,899,86,65,153,39,535,90,210,629,116,704,247,83,208,237,48,661,752,638,509,17,758,402,133,551,143,139,817,244 }, { 101,9,100,0,88,217,252,68,39,35,352,562,175,30,115,230,752,213,265,419,13,317,197,166,180,154,237,83,212,158,124,64,321,777,382,208,1,336,410,65,194,759,329,694,36,141,826,289,23,365,724,341,429,128,509,69,165,570,345,676,909,96,346,756,553,21,593,372,854,702,498,55,799,264,399,67,86,190,28,468,589,768,51,364,308,144,677,755,689,323,125,722,482,610,547,391,333,137,789,812,189,546,49,32,952,310,247,274,131,72,16,344,98,10,671,351,435,386,251,478,285,244,901,167,160,484,706,164 }, { 32,64,95,147,288,21,90,5,519,470,49,61,0,356,22,48,115,362,97,247,312,141,835,387,560,57,56,4,182,128,20,237,178,59,18,11,31,13,107,214,202,28,298,217,44,76,316,7,65,43,259,180,819,874,51,40,23,216,173,330,207,197,150,25,2,86,729,324,120,376,279,140,612,392,595,104,72,66,29,6,352,37,12,210,678,414,172,683,779,490,482,317,291,165,134,102,81,77,58,45,33,26,195,864,795,304,858,87,54,660,427,707,878,465,357,501,232,753,205,177,170,126,117,91,19,597,230,212 }, { 24,16,14,35,7,18,69,1,50,46,75,5,2,58,163,67,54,70,0,71,28,502,60,48,38,12,9,21,189,103,155,140,267,223,281,108,37,171,430,92,394,65,68,22,230,513,83,10,23,181,32,55,309,87,45,36,236,51,335,29,220,149,307,99,61,133,112,141,64,13,780,52,6,115,128,227,270,72,89,852,537,328,17,150,474,49,807,114,767,221,552,186,96,290,95,20,246,366,77,443,400,137,202,86,269,486,666,388,237,540,25,278,477,217,4,536,218,765,177,19,125,180,165,126,113,318,251,39 }, { 195,18,354,265,252,411,39,9,363,167,101,682,271,132,16,121,60,1,333,203,21,593,35,146,520,156,364,447,639,360,212,5,24,327,23,627,668,310,404,13,48,664,286,100,538,0,777,676,77,98,821,7,68,33,692,446,865,93,158,576,159,116,115,647,966,883,551,407,272,107,51,687,120,591,463,326,137,71,102,857,31,781,421,37,586,30,44,329,379,50,125,374,166,105,92,96,621,709,142,65,36,127,562,475,109,403,14,126,118,70,346,223,479,199,805,450,190,43,20,191,936,905,656,128,254,12,2,202 }, { 4,115,13,5,23,141,51,180,2,202,1,217,11,269,318,3,77,341,7,6,317,33,365,0,21,12,352,197,165,9,15,32,102,10,137,40,177,308,752,64,291,31,22,901,349,372,28,8,59,403,90,494,30,237,498,44,120,37,401,125,48,39,14,93,17,244,49,457,569,509,128,153,16,386,98,143,304,36,873,475,196,391,117,482,342,253,210,203,110,453,116,247,373,221,326,24,216,18,144,72,421,260,95,55,134,450,961,576,86,139,719,105,468,35,164,82,57,127,160,89,864,678,523,351,88,275,67,546 }, { 7,71,24,14,16,35,140,92,189,149,150,108,60,68,18,230,97,69,66,314,273,267,458,388,336,38,2,65,232,251,175,399,118,46,398,172,67,28,462,246,36,55,375,0,705,1,21,124,154,22,298,302,135,95,451,733,877,126,594,423,345,64,467,101,9,74,517,29,48,86,602,236,6,20,191,83,596,52,330,380,32,357,43,5,10,674,50,12,133,49,429,723,103,711,212,346,104,192,114,107,915,278,167,387,37,443,324,309,121,823,54,125,96,633,566,221,796,484,75,109,547,603,13,23,289,809,575,607 }, { 1,22,31,5,36,12,105,44,2,86,21,170,98,180,127,0,55,141,64,23,7,352,28,13,9,128,116,125,164,239,4,301,49,115,6,95,197,37,3,160,242,51,341,752,202,83,498,269,10,96,165,144,48,253,244,285,901,217,320,365,208,569,137,8,338,299,318,395,293,109,654,93,512,143,32,50,237,317,159,402,864,11,15,708,776,873,169,201,14,35,99,67,638,39,954,30,844,531,479,678,77,69,456,740,533,16,403,308,268,120,751,951,33,961,947,457,286,238,401,276,482,203,601,17,506,312,509,18 }, { 97,66,192,7,560,52,20,2,135,74,43,173,324,104,580,414,226,107,147,750,204,29,174,500,376,568,825,707,222,0,356,470,77,32,331,194,90,38,729,16,819,298,92,172,355,22,60,64,888,595,357,232,24,18,259,712,202,353,426,81,5,362,262,874,427,526,49,330,14,178,95,885,387,21,10,138,37,861,142,6,33,102,86,28,889,4,359,65,312,36,858,126,59,1,112,792,673,337,58,151,177,91,35,113,319,291,9,115,145,13,636,501,342,448,278,140,12,87,61,71,583,294,751,465,237,246,230,325 }, { 101,0,68,9,252,154,124,364,166,35,39,100,24,65,419,16,149,694,71,265,329,28,439,158,346,88,30,289,212,404,55,671,703,562,570,49,274,175,429,21,706,589,18,553,118,375,1,722,67,302,22,109,962,190,677,382,333,108,60,23,967,191,168,95,69,48,344,14,51,336,114,254,676,610,484,13,398,10,83,92,7,520,310,857,818,125,264,593,189,64,133,185,826,438,12,32,159,865,221,103,535,50,194,695,286,105,36,604,96,169,420,230,283,701,167,241,131,140,2,350,656,115,272,5,239,637,812,98 }, { 39,100,127,30,737,836,9,254,856,31,166,190,98,395,0,385,88,931,625,131,373,264,863,93,827,28,228,120,44,125,1,219,116,137,110,382,371,55,13,101,731,299,260,144,908,442,21,77,265,23,456,64,203,51,599,242,33,187,49,326,310,22,224,578,202,5,450,36,272,18,276,16,141,795,82,105,916,284,165,274,318,48,95,512,944,35,716,478,24,935,258,201,616,851,32,557,102,96,252,109,68,269,128,351,435,492,83,724,86,67,7,10,704,293,772,59,921,329,846,156,924,286,197,438,717,4,291,244 }, { 17,5,45,21,14,2,48,3,32,155,106,227,186,181,38,29,61,209,62,46,328,133,400,80,243,54,56,52,1,51,832,23,19,50,99,255,114,430,6,84,543,536,12,514,401,236,27,37,137,361,552,453,119,136,34,311,58,218,171,221,76,72,4,754,115,281,108,13,285,496,65,454,629,513,41,207,308,540,421,26,290,805,480,541,488,920,657,202,475,11,487,787,128,86,89,569,57,739,151,838,502,36,270,59,403,208,90,10,7,721,474,22,263,745,576,0,457,659,592,663,587,25,161,129,165,148,323,894 }, { 131,613,224,856,228,406,716,274,827,30,100,219,190,39,166,863,88,931,924,829,944,31,382,44,625,9,127,1,442,385,187,98,116,731,93,578,258,254,530,816,137,871,160,616,960,96,36,310,265,0,371,203,144,836,410,438,264,435,795,125,242,21,202,120,201,531,276,908,51,921,128,23,101,49,839,846,28,737,48,326,5,83,778,13,110,64,284,105,35,492,272,10,557,33,938,115,299,77,252,158,456,367,268,669,217,260,165,213,32,177,22,800,352,473,86,102,69,197,574,321,318,567,141,935,593,403,55,180 }, { 352,217,752,141,954,864,64,372,437,269,180,115,498,177,349,776,579,291,317,247,77,947,873,717,304,318,678,237,179,23,197,128,33,0,35,165,13,275,68,210,457,341,459,1,67,410,32,143,365,65,244,202,102,9,160,140,137,225,569,12,36,18,125,75,51,134,93,751,15,546,509,86,708,482,928,713,330,312,201,164,144,100,10,7,521,268,246,44,24,21,16,558,55,851,682,342,260,245,120,117,101,98,39,28,726,363,116,110,30,189,72,478,83,744,953,841,824,672,563,358,166,114,92,31,5,386,196,69 }, { 141,217,317,180,352,365,115,341,5,372,23,13,752,498,253,244,15,1,237,2,51,197,269,0,7,165,21,202,64,349,77,6,137,143,4,318,3,9,901,546,33,177,308,11,32,10,160,12,48,49,482,30,22,125,468,98,373,247,120,102,93,31,864,110,509,260,531,391,28,44,494,437,36,450,569,90,40,490,453,326,221,219,203,16,128,96,82,386,164,72,873,291,251,224,187,117,403,401,210,39,131,116,24,18,473,144,86,37,629,148,105,8,533,951,758,475,421,228,139,170,134,95,65,35,734,704,617,275 }, { 5,2,45,17,14,29,48,1,21,58,181,38,50,61,3,133,46,155,171,186,114,52,32,27,281,19,6,218,36,236,227,54,361,151,51,12,754,209,26,400,80,137,514,243,65,106,552,487,13,480,334,23,285,86,412,328,108,4,283,502,311,37,56,99,323,22,745,657,208,202,25,62,72,128,115,838,760,59,430,7,34,536,64,70,454,11,76,10,28,255,119,803,194,787,67,421,0,576,57,859,496,103,84,96,18,532,75,165,89,453,389,223,24,920,401,163,73,113,308,828,402,77,739,112,287,148,457,513 }, { 6,25,2,119,790,29,113,76,26,45,483,655,887,42,292,32,19,4,59,128,151,207,1,306,84,17,814,106,240,90,112,209,61,145,14,177,77,64,65,52,833,27,122,179,491,210,70,0,72,311,115,40,255,58,614,74,85,7,214,202,710,22,5,57,469,21,141,11,123,80,476,95,36,396,33,10,24,269,38,137,102,66,425,23,416,49,194,86,275,504,13,216,56,402,318,46,358,18,138,28,460,624,9,148,50,174,129,618,51,205,87,75,16,291,186,12,217,249,222,287,454,20,54,99,243,315,117,114 }, { 23,13,51,115,2,4,5,0,141,180,7,11,217,3,33,77,6,1,202,9,317,10,102,197,21,269,40,352,341,32,12,165,16,22,64,318,365,28,128,15,14,18,752,137,59,24,291,308,177,125,31,17,403,498,237,494,372,98,49,117,901,93,196,30,44,153,457,349,8,37,120,134,90,116,247,342,36,482,401,95,35,210,143,221,86,453,260,203,144,475,326,48,244,110,391,386,55,304,873,39,19,569,961,421,105,509,719,546,450,253,864,216,20,402,29,523,72,57,50,139,25,730,373,468,275,65,82,629 }, { 23,13,51,202,21,141,115,5,165,318,32,12,403,197,453,1,269,120,15,128,2,180,475,125,308,457,401,7,48,6,386,64,0,730,4,9,719,137,3,10,523,18,33,14,37,421,16,99,494,11,260,450,341,221,17,196,93,77,40,217,22,117,90,95,237,899,31,391,247,352,326,28,24,102,19,153,30,317,98,961,817,134,82,44,25,59,8,241,110,49,365,20,26,291,27,61,177,36,351,498,509,569,402,39,203,758,29,72,57,45,629,350,54,116,316,96,752,50,38,349,67,901,65,46,342,304,285,58 }, { 39,9,100,30,31,127,44,88,0,276,98,131,1,385,254,442,166,49,908,116,187,190,935,201,219,284,827,299,28,224,144,829,96,228,36,274,137,141,101,21,265,716,382,48,51,258,202,23,352,22,125,836,93,856,613,128,839,158,371,264,578,395,13,55,16,180,662,244,269,252,217,567,492,110,310,35,64,77,272,83,268,410,931,203,120,326,752,260,68,318,18,489,293,574,625,160,24,33,115,86,159,924,242,373,165,438,5,450,69,102,616,213,197,918,863,321,295,717,291,82,731,177,456,317,406,7,599,737 }, { 22,109,49,28,159,185,95,9,105,131,272,327,254,1,67,286,36,39,35,168,86,83,55,169,505,158,224,374,420,127,584,208,98,219,312,578,31,347,535,601,0,69,708,424,44,114,103,30,160,627,346,64,141,194,187,518,175,96,239,345,616,892,10,128,164,143,896,116,137,50,12,5,2,237,228,913,533,13,23,7,21,371,320,597,688,538,751,912,352,323,251,716,165,115,634,202,258,197,498,637,37,531,180,797,874,51,253,768,48,101,890,16,189,201,613,24,752,385,14,170,285,365,406,789,244,218,46,133 }, { 5,1,21,2,48,14,12,32,22,36,0,17,54,10,38,3,37,86,50,45,65,28,51,72,281,23,4,6,58,114,89,46,137,13,270,99,430,11,7,208,76,202,181,61,115,403,155,9,133,18,540,64,361,221,29,323,480,285,49,128,24,95,218,401,657,421,290,745,19,576,194,55,308,754,59,453,513,920,148,880,96,341,502,52,16,475,77,67,842,40,283,859,318,197,402,494,171,141,474,244,543,757,165,775,90,541,27,33,180,57,83,227,164,217,428,328,269,108,425,569,514,207,31,143,223,263,102,503 }, { 141,352,269,372,351,217,854,82,752,922,318,180,954,260,317,15,349,1,202,64,120,898,717,77,67,35,864,291,69,365,137,851,437,36,22,5,247,86,373,4,457,450,244,165,189,163,140,68,13,237,901,115,128,304,23,21,341,98,125,177,51,93,32,28,961,160,96,494,110,95,10,0,719,253,661,523,326,767,83,730,275,44,386,418,40,12,817,210,19,17,102,59,45,18,7,579,498,482,615,403,144,11,6,3,203,76,822,475,49,48,31,33,293,284,268,228,187,947,899,587,583,485,474,367,342,300,245,100 }, { 144,613,203,406,669,418,326,137,228,96,679,494,160,816,1,817,822,36,317,859,840,83,856,876,855,217,251,219,863,831,944,202,576,365,539,93,800,5,345,530,77,128,44,957,748,141,13,839,30,23,21,778,143,341,115,473,617,332,201,64,120,190,492,456,829,531,349,367,716,258,98,48,578,116,180,924,403,187,31,515,966,692,574,442,131,86,931,719,523,450,9,224,351,291,860,752,82,28,10,244,51,371,22,276,39,102,125,730,261,50,851,269,827,335,318,871,704,916,268,110,898,69,67,498,206,177,615,805 }, { 15,13,23,51,202,1,21,33,5,269,180,217,2,141,308,12,120,0,352,165,7,221,115,117,48,32,6,318,197,4,153,9,260,82,196,453,134,457,3,40,386,523,730,110,14,719,77,401,31,403,450,137,326,37,102,341,16,351,8,128,752,11,475,93,18,498,317,44,365,391,64,30,98,237,72,10,49,421,22,99,901,494,509,28,24,899,17,125,39,817,569,854,116,203,59,291,177,89,961,95,36,244,629,758,105,247,90,372,241,864,349,546,670,898,96,35,144,86,65,350,373,50,139,304,61,160,922,615 }, { 23,115,13,51,77,0,1,4,365,2,141,341,5,33,202,217,11,10,317,9,180,102,3,7,6,15,269,22,318,197,165,64,352,12,40,494,403,21,28,31,128,308,125,32,453,59,177,18,291,16,401,475,901,14,24,752,237,93,342,137,349,457,569,44,8,17,372,30,153,98,120,95,49,210,36,498,196,117,110,509,482,421,116,247,386,873,304,37,391,39,629,244,48,139,90,203,143,134,55,86,523,450,326,468,260,275,57,961,144,719,65,35,402,216,730,221,19,253,373,46,50,734,437,678,576,96,758,551 }, { 531,373,728,160,943,559,717,260,93,269,332,206,533,244,352,384,261,535,964,564,120,110,10,253,295,137,365,318,141,55,143,959,180,617,36,851,911,843,197,661,203,873,282,1,752,940,341,699,968,901,82,417,326,21,144,450,22,351,317,434,64,642,498,855,824,574,202,926,473,860,800,896,164,23,28,898,8,51,13,258,15,116,35,816,567,127,187,237,776,9,951,219,601,268,115,811,165,217,201,864,131,98,406,854,77,523,251,902,922,125,48,345,44,31,16,704,96,499,86,83,489,871,367,299,177,72,817,24 }, { 1,31,36,170,55,86,22,44,127,5,301,64,98,164,2,116,740,105,299,12,10,242,237,125,169,338,9,0,21,143,7,512,23,28,841,128,141,13,239,51,395,180,654,208,293,685,37,144,870,923,95,6,599,83,197,115,160,456,900,352,67,498,506,253,165,638,49,3,268,492,137,965,4,479,14,393,763,269,244,185,708,202,109,341,96,365,50,762,509,933,276,48,284,951,367,505,864,751,752,546,320,601,597,35,8,569,634,312,323,217,558,201,391,824,317,401,308,901,457,32,837,159,535,93,873,54,114,38 }, { 13,23,51,115,32,141,77,177,202,33,64,269,90,4,102,318,128,40,59,21,217,291,137,180,352,210,95,10,48,0,22,5,196,494,15,7,237,14,117,49,18,216,197,125,342,98,31,304,11,9,165,153,403,317,247,86,752,134,28,275,349,16,24,116,365,341,2,6,76,44,453,17,12,20,30,300,221,93,39,143,139,36,1,19,3,402,326,386,312,105,457,65,244,194,8,576,498,901,308,110,99,72,372,120,401,203,50,25,241,144,61,26,208,96,678,450,160,615,421,391,127,114,57,46,37,35,27,947 }, { 202,260,120,450,318,51,269,77,23,351,1,326,13,128,82,137,141,21,33,15,494,102,523,817,5,403,110,165,922,64,203,197,854,125,32,180,177,291,48,153,196,93,116,12,342,98,352,373,40,4,115,7,475,144,349,36,217,90,2,453,386,16,0,285,95,44,615,237,59,49,31,457,704,6,898,210,24,58,96,86,30,719,117,70,401,216,8,275,28,22,14,402,17,247,50,39,29,18,421,99,37,20,10,391,304,61,25,752,341,730,678,9,365,859,576,473,139,45,961,692,293,661,498,317,214,132,35,76 }, { 899,523,102,730,33,153,196,117,719,23,475,51,817,13,15,403,453,5,4,342,77,494,40,120,21,11,450,202,421,59,457,12,805,165,139,134,26,19,17,2,1,300,386,801,961,57,32,27,7,6,3,880,197,99,361,757,670,128,125,72,58,56,48,45,37,14,318,64,49,770,247,82,576,260,884,775,635,629,509,485,456,402,391,180,177,141,95,89,84,76,70,62,61,54,53,38,29,25,758,401,269,262,583,409,365,341,331,217,52,968,967,966,965,964,963,962,960,959,958,957,956,955,954,953,952,951,950,949 }, { 202,494,403,475,523,817,453,450,318,402,120,576,51,13,77,102,342,33,260,128,23,326,5,899,15,4,82,615,210,269,137,351,291,59,196,141,90,730,40,386,285,214,177,21,719,389,49,11,65,61,30,22,48,153,117,457,114,12,3,98,64,44,39,31,1,922,194,216,84,349,165,95,32,28,10,0,757,197,421,474,123,38,961,887,805,690,629,551,401,283,263,207,139,125,118,113,58,848,503,115,41,880,275,24,17,422,319,104,942,854,803,801,704,671,509,416,400,393,372,334,237,227,217,186,180,151,134,96 }, { 2,29,52,112,66,87,70,151,135,7,226,58,74,307,186,294,172,287,549,644,334,5,14,97,46,75,45,227,331,113,145,6,25,315,155,337,222,1,61,192,32,243,163,311,64,220,38,400,43,262,171,69,21,37,624,461,20,884,122,849,631,416,26,16,48,86,27,24,42,22,19,278,138,92,353,635,36,609,232,0,128,140,10,500,324,50,17,72,665,59,12,95,76,90,409,209,35,4,396,491,614,65,18,496,415,54,721,568,592,67,632,49,141,137,80,28,89,204,659,869,60,106,426,845,448,177,207,115 }, { 1,349,652,5,260,291,77,39,342,102,120,23,100,888,13,269,64,340,264,51,303,698,32,2,202,21,9,296,33,98,70,385,163,638,318,137,327,87,293,58,50,128,48,195,69,774,141,75,121,7,658,850,326,96,371,284,223,931,863,759,132,126,92,71,221,678,203,82,551,961,937,615,575,563,494,105,83,67,55,36,30,27,17,771,418,115,90,31,156,914,687,393,372,12,6,3,622,144,922,898,854,731,691,478,403,367,363,352,351,333,310,286,170,146,0,950,230,93,95,49,919,954,947,865,851,765,751,719 }, { 1,5,2,13,4,23,7,3,15,0,6,180,51,115,141,341,11,77,269,352,21,901,217,197,365,33,12,32,177,752,317,202,318,165,40,9,102,10,291,93,8,569,31,22,349,498,120,90,44,110,401,59,37,304,326,48,17,64,372,403,196,117,16,98,14,457,210,453,125,494,28,36,386,629,247,153,475,30,308,260,134,873,116,253,373,450,18,237,244,482,203,49,128,961,275,137,144,216,509,523,421,391,143,342,24,719,105,95,55,72,76,89,39,206,437,139,468,57,579,758,730,864,546,127,221,96,734,19 }, { 14,7,16,46,24,2,35,70,92,58,5,38,75,18,140,60,87,171,220,54,1,155,69,307,50,21,163,48,71,32,112,0,37,12,23,278,780,502,126,9,61,52,186,172,135,45,28,64,29,13,67,227,20,107,22,115,97,513,51,10,267,72,68,270,128,230,89,314,666,330,246,141,6,232,189,36,400,177,66,108,290,150,17,309,55,430,767,334,77,474,121,262,103,243,409,223,137,83,43,113,202,592,217,461,49,95,315,571,65,181,394,357,86,281,269,774,294,236,380,852,536,845,76,90,25,102,298,4 }, { 226,135,87,2,29,66,74,52,294,278,222,220,75,7,172,145,331,70,324,262,97,6,25,112,138,337,140,42,1,92,461,26,69,38,500,58,357,14,380,5,287,16,46,571,232,620,808,632,267,163,32,24,35,583,853,774,43,314,609,45,171,21,298,353,19,802,95,60,151,415,448,409,64,67,192,22,65,396,85,525,37,174,307,189,872,204,20,71,50,12,330,86,622,61,48,27,36,186,394,764,113,54,335,563,114,108,309,150,950,72,155,17,10,572,122,635,544,103,96,606,28,893,246,18,49,230,550,334 }, { 15,33,77,117,134,153,102,4,40,196,1,217,21,11,291,13,32,5,177,202,51,115,3,23,141,2,48,317,180,349,59,137,372,128,17,269,342,210,341,96,57,64,365,120,247,12,216,82,221,139,318,110,6,260,93,90,352,898,450,165,10,36,31,197,275,523,7,37,72,494,203,244,457,56,351,579,125,111,8,237,817,326,403,0,752,98,922,961,901,160,277,22,719,730,144,44,206,14,386,899,86,45,482,437,304,373,143,89,569,9,116,453,475,308,253,300,61,105,76,27,638,164,95,49,490,29,18,94 }, { 217,15,317,82,351,141,260,854,13,77,23,120,51,922,115,1,21,180,110,137,365,341,352,372,269,349,898,291,36,202,64,5,32,450,318,373,177,128,752,96,304,523,93,33,48,165,326,197,102,0,10,40,901,9,4,160,498,247,90,244,661,203,22,59,482,2,12,143,86,437,386,83,457,28,473,30,67,253,961,11,35,16,221,24,125,117,391,39,7,811,494,88,37,8,69,719,559,3,817,704,237,216,76,72,61,14,873,403,18,642,31,899,210,164,45,730,717,49,179,134,139,851,475,421,251,223,100,56 }, { 190,373,31,30,863,908,120,88,110,127,260,442,856,318,254,326,717,935,131,836,228,93,187,44,39,385,299,100,968,274,219,203,82,166,224,197,116,661,276,77,1,217,98,269,86,450,51,371,36,128,180,829,137,372,341,160,704,141,64,435,202,49,395,144,9,23,918,410,28,22,730,778,244,242,351,55,737,523,827,177,851,625,944,382,272,530,317,115,349,352,96,613,492,291,954,32,931,744,716,125,268,258,284,253,686,48,615,515,367,247,21,33,456,165,321,795,10,567,466,225,83,839,102,578,521,919,817,752 }, { 23,13,308,115,401,51,165,9,391,21,629,254,125,159,773,197,743,569,49,468,217,438,656,627,341,89,39,558,221,32,317,386,509,350,28,95,530,228,457,867,109,166,406,876,679,48,669,364,219,158,365,346,168,912,810,101,170,105,72,64,143,30,347,258,967,237,148,90,688,274,131,670,272,185,749,843,33,12,10,187,55,175,141,4,734,758,242,196,190,453,261,518,224,902,747,286,482,164,37,333,241,2,439,102,0,424,420,393,706,613,338,153,67,372,351,68,40,310,120,816,634,332,840,35,320,88,86,289 }, { 49,5,165,125,21,173,43,623,104,193,422,102,13,7,91,18,95,22,0,192,141,64,48,197,900,693,558,105,51,23,32,232,391,387,314,98,31,116,20,779,202,81,92,319,408,241,16,126,38,77,494,33,784,643,474,11,221,28,712,138,862,663,595,403,350,879,29,510,27,633,180,140,729,397,172,44,4,858,237,61,718,501,359,71,60,58,511,448,370,356,750,490,482,347,344,316,308,177,93,37,24,498,293,115,158,145,72,65,40,830,246,207,63,85,107,841,569,468,414,352,330,326,269,203,69,14,12,2 }, { 4,1,2,5,13,23,77,115,15,3,0,341,7,51,6,11,33,202,102,217,12,180,10,141,9,40,21,317,318,177,365,901,197,269,32,165,352,22,59,8,64,31,291,14,494,403,93,17,401,569,752,16,453,37,342,210,110,153,275,18,475,44,125,196,90,28,308,326,386,98,120,117,116,372,457,128,349,36,95,629,49,421,237,48,139,203,260,244,450,498,137,134,304,30,24,523,144,247,373,719,216,57,391,961,86,482,143,253,39,730,509,111,55,221,817,96,615,19,65,873,351,758,99,670,437,72,50,734 }, { 843,295,93,120,160,206,36,943,567,373,384,332,268,137,261,141,201,260,110,10,203,531,144,55,64,617,434,197,258,699,116,244,282,318,559,564,964,269,44,352,911,717,253,860,202,180,31,326,533,1,940,143,473,417,728,661,276,351,959,187,22,341,851,535,219,871,855,28,367,127,82,131,115,450,365,86,901,752,926,317,21,51,98,48,77,165,23,105,224,96,968,662,217,13,8,902,574,489,125,817,349,800,523,515,83,704,49,811,498,164,494,39,5,393,228,32,291,251,128,9,12,898,642,576,69,67,873,839 }, { 192,81,43,173,426,879,7,715,172,104,712,91,636,526,232,825,568,97,560,5,95,681,448,66,49,861,32,387,370,74,20,750,33,204,22,707,330,729,718,140,61,0,6,356,397,69,21,117,422,347,135,359,38,92,102,263,348,64,174,4,414,153,888,237,138,319,76,298,40,13,885,52,2,107,86,500,25,196,784,595,77,819,241,180,134,58,207,85,29,42,31,355,65,577,72,18,28,1,343,48,392,23,10,126,89,324,37,189,344,233,314,11,933,71,14,511,16,408,115,673,46,498,45,671,125,60,858,246 }, { 475,453,403,51,33,102,494,23,196,13,202,153,117,77,0,318,128,757,421,22,342,730,899,817,18,805,65,15,958,450,134,4,402,24,36,59,269,40,49,210,401,1,28,697,670,64,11,114,291,48,16,576,108,386,523,141,57,177,21,20,86,165,133,95,90,120,365,317,326,260,221,180,137,31,10,115,752,99,498,457,391,361,352,70,50,32,349,113,9,6,3,864,838,770,743,373,351,338,268,242,206,125,116,109,5,283,253,84,17,961,801,791,546,372,341,237,217,214,205,194,163,143,96,72,69,68,30,14 }, { 141,269,260,318,352,202,120,351,349,137,854,82,1,851,922,5,180,372,291,64,32,947,21,15,77,752,494,13,48,304,33,7,51,717,23,217,373,177,128,678,450,115,237,326,317,70,898,36,403,704,312,4,160,102,86,90,968,247,95,87,196,49,275,244,197,22,165,67,96,35,288,203,817,735,125,342,144,93,16,216,163,50,44,31,83,954,2,69,597,457,241,59,153,961,221,110,98,39,30,9,8,901,661,551,523,473,442,386,367,284,210,864,117,61,12,0,800,29,24,863,859,730,719,475,453,385,316,293 }, { 15,1,2,13,5,4,3,0,23,7,6,115,217,12,180,197,9,51,21,11,352,961,8,10,165,77,457,341,141,317,22,14,901,33,31,117,93,120,102,40,134,752,202,365,260,16,37,269,569,110,32,44,28,318,64,18,17,48,351,719,153,386,177,82,291,36,196,98,873,450,49,125,59,128,498,403,72,326,482,30,523,401,99,854,308,203,24,453,89,137,95,391,509,111,349,86,139,730,372,247,144,55,210,116,342,494,304,475,373,148,922,90,105,237,661,35,579,899,143,221,39,19,629,275,421,758,244,468 }, { 166,39,274,404,101,252,190,30,333,9,310,0,100,438,656,158,265,88,68,625,329,530,553,419,344,539,254,455,793,778,21,48,759,228,49,676,1,131,960,709,557,731,520,154,23,35,382,13,124,364,604,677,105,28,272,16,286,406,212,31,51,18,613,219,224,593,840,159,167,125,36,98,65,518,669,865,118,24,44,96,213,748,264,777,115,83,175,22,86,538,957,221,127,55,327,5,10,857,694,688,137,258,795,410,806,627,95,71,577,289,128,116,578,32,50,242,69,724,187,352,562,346,616,67,33,827,846,191 }, { 28,0,1,9,22,65,12,83,67,55,109,50,24,5,36,49,39,96,35,238,16,18,2,21,114,124,69,37,7,218,48,23,323,103,158,160,168,54,51,128,285,154,13,68,185,137,14,194,99,141,95,169,181,418,289,420,202,433,86,30,75,480,175,10,505,105,115,32,402,281,223,389,269,208,646,503,745,64,133,46,180,657,159,800,531,547,251,956,101,429,4,318,31,149,163,6,70,346,58,532,822,533,484,757,797,165,335,252,197,735,570,352,283,361,71,98,29,118,3,535,927,766,221,217,38,799,237,308 }, { 15,1,2,0,23,5,51,13,7,6,9,180,12,115,3,457,197,8,719,21,730,4,120,901,141,202,14,33,165,341,453,386,82,31,260,351,365,523,308,64,37,22,44,401,450,32,40,16,93,77,110,10,98,961,403,36,102,899,28,217,11,125,352,196,48,318,137,317,475,153,18,269,49,569,116,752,99,326,421,128,24,30,221,95,39,203,117,873,144,817,629,758,177,55,86,35,494,509,898,373,59,237,105,17,65,291,96,89,498,670,482,247,253,134,468,38,143,54,244,72,90,372,160,854,127,210,391,801 }, { 9,39,166,49,30,28,0,158,22,131,180,100,219,35,352,190,345,228,1,752,88,498,115,141,274,317,482,109,83,128,930,251,36,217,95,365,230,55,101,160,254,165,224,159,168,23,341,13,105,31,208,187,258,927,310,197,69,137,333,901,864,364,64,185,269,86,344,505,252,202,404,68,286,873,539,372,96,669,438,51,10,164,67,5,868,346,244,637,439,2,7,21,748,323,406,418,318,16,237,44,272,50,840,706,420,265,127,98,946,735,793,768,579,169,125,530,175,148,327,857,702,678,238,116,12,48,533,335 }, { 61,311,80,209,45,29,5,58,2,151,454,106,17,6,667,243,255,738,52,592,70,496,287,74,483,1,833,112,549,27,207,119,26,315,32,227,378,19,64,14,138,25,84,263,75,742,186,631,113,21,136,56,48,887,62,46,7,307,469,72,76,145,50,73,66,161,128,495,148,425,814,651,491,4,34,95,869,86,38,87,3,334,240,290,383,396,845,42,53,306,12,171,65,141,163,445,135,155,11,22,54,297,90,331,179,226,655,632,37,614,361,292,663,89,400,13,36,23,10,137,294,666,99,659,250,220,59,51 }, { 31,44,299,22,125,599,456,685,116,28,492,393,170,242,144,268,963,301,506,1,95,558,367,36,239,55,489,0,918,109,206,23,105,9,10,434,127,51,384,13,86,286,948,479,98,64,841,5,338,2,93,12,203,498,164,7,512,168,21,143,165,49,903,940,320,401,391,137,8,37,900,417,352,141,115,128,546,253,457,959,237,14,185,197,308,169,202,395,282,421,374,911,180,740,332,293,386,6,24,312,855,538,509,752,244,473,65,928,762,160,638,617,341,269,961,867,949,730,654,403,551,499,965,523,48,719,16,453 }, { 187,258,926,839,574,860,93,219,406,228,871,160,531,224,137,902,201,120,116,36,203,144,669,268,318,131,442,567,816,295,434,908,851,533,843,44,384,717,202,800,559,373,489,728,141,332,855,206,261,276,1,260,269,251,617,326,180,317,385,940,110,613,217,959,55,31,450,352,968,365,115,197,64,699,679,244,98,96,83,23,10,840,341,77,492,473,899,856,831,661,143,127,190,918,752,539,21,284,418,13,943,748,662,911,564,530,48,165,291,523,704,128,345,125,822,351,169,954,86,349,367,922,776,535,177,51,824,22 }, { 7,107,24,60,349,232,16,51,18,75,9,291,87,23,71,269,92,126,77,141,64,177,307,150,461,35,220,14,330,37,121,0,46,279,115,947,267,132,32,12,172,55,112,309,13,10,448,278,202,21,70,2,372,210,852,678,441,304,28,5,328,217,147,54,48,786,660,259,359,318,155,90,334,181,180,140,872,108,22,163,102,31,409,314,394,352,341,281,171,68,30,622,294,236,20,423,49,626,33,760,186,58,687,415,50,39,407,128,43,771,365,197,237,1,400,929,498,888,590,366,342,270,192,135,100,76,61,675 }, { 15,1,2,0,5,7,13,6,3,4,115,23,180,9,12,901,51,8,341,961,365,197,10,22,141,82,33,351,14,11,77,120,31,202,457,165,217,308,134,352,28,64,102,21,269,569,110,18,260,317,40,44,16,37,36,719,93,318,237,137,99,177,450,30,125,128,386,49,752,153,55,498,17,391,98,24,111,403,32,39,196,117,401,116,373,898,730,523,326,291,453,95,854,509,304,247,86,59,372,546,482,349,143,475,899,203,244,494,139,35,48,642,253,811,144,105,210,160,758,421,148,629,221,90,164,65,127,638 }, { 23,51,13,202,5,12,115,21,141,165,1,32,2,318,197,15,403,180,453,7,6,3,401,269,4,0,128,308,37,10,99,457,14,11,9,120,64,22,48,341,137,386,494,475,17,77,16,719,18,217,125,31,352,523,421,59,730,90,153,365,391,237,177,317,28,40,450,260,72,221,33,8,569,93,509,961,44,19,89,102,291,98,247,326,498,76,24,49,817,899,758,30,57,629,117,61,36,110,29,139,20,210,402,82,304,196,95,45,351,752,38,285,116,203,134,349,241,96,468,54,216,901,482,576,546,25,275,342 }, { 2,1,77,64,141,6,3,7,0,33,102,5,10,13,23,14,269,180,15,217,165,291,352,40,117,197,9,17,115,202,237,4,128,11,22,341,12,153,349,134,196,16,51,86,318,317,177,36,19,125,137,95,342,18,752,8,28,365,31,210,457,143,139,498,59,372,21,164,57,304,82,120,45,27,38,275,24,49,110,391,386,111,93,44,244,901,260,509,56,32,41,450,98,65,99,351,30,961,55,37,403,864,569,494,29,678,48,312,453,326,546,203,20,25,54,401,79,373,402,61,253,26,46,62,719,76,475,523 }, { 345,531,332,269,717,260,373,317,728,752,351,180,352,533,10,365,498,82,160,251,244,36,901,143,217,341,93,55,1,141,873,864,898,35,9,564,64,851,951,22,417,137,253,28,617,169,67,69,120,559,854,197,601,482,318,546,115,768,21,96,83,661,261,876,110,372,237,164,144,535,574,203,800,206,16,86,349,31,824,699,50,48,831,902,843,860,434,968,125,221,579,959,700,679,384,926,922,295,7,51,23,291,148,418,230,202,24,943,468,896,201,5,776,77,839,44,258,954,816,13,811,940,844,637,473,868,822,308 }, { 92,16,189,7,77,60,388,140,33,153,196,102,35,117,230,134,150,733,314,24,14,71,21,915,246,1,108,594,97,18,32,48,66,126,69,517,121,462,64,22,98,13,399,723,65,5,291,95,67,451,674,267,232,217,653,298,2,23,38,223,104,711,83,0,197,90,36,423,149,46,125,49,167,28,68,195,20,172,120,251,86,12,289,214,508,115,386,633,236,133,10,50,350,458,191,165,330,51,107,31,260,6,43,55,271,841,450,457,273,326,796,146,509,221,603,380,237,702,9,194,4,202,199,103,52,357,29,74 }, { 234,142,178,202,639,5,49,450,77,70,786,416,929,48,259,455,21,0,878,147,315,481,198,329,427,318,1,125,105,120,61,113,534,846,58,344,12,132,95,518,465,325,22,31,163,557,494,13,159,32,761,767,128,590,146,37,798,195,269,711,371,291,402,265,50,342,158,362,260,39,98,221,884,687,30,64,279,137,2,167,10,771,165,35,640,626,522,403,293,310,102,23,817,347,170,28,581,99,141,236,127,150,107,51,271,87,763,623,845,212,7,18,423,194,17,523,112,345,663,33,44,376,239,199,121,391,116,75 }, { 81,715,192,712,681,636,104,173,750,91,370,0,74,95,718,22,7,825,879,20,49,560,43,64,422,172,397,66,138,207,784,86,500,65,28,18,707,204,414,10,577,174,319,426,32,38,312,888,348,330,4,526,289,52,355,61,511,861,347,33,237,29,102,232,448,31,21,353,835,124,5,6,2,643,36,85,97,117,153,77,306,59,134,819,140,673,671,24,40,120,165,729,568,240,135,280,324,105,125,98,344,519,233,387,194,288,196,693,474,241,214,701,44,107,583,314,260,450,847,287,69,25,872,587,343,84,9,817 }, { 23,13,51,15,0,10,9,115,1,453,2,961,4,77,5,457,11,40,33,401,3,7,475,197,102,14,569,165,22,59,12,6,719,32,64,21,99,730,57,17,177,18,37,8,217,386,403,196,28,308,16,31,141,139,111,341,523,120,125,180,153,117,629,391,210,36,45,237,72,899,49,95,202,128,485,247,38,482,24,48,44,509,90,27,260,450,30,19,137,317,365,41,65,291,269,89,134,342,86,304,498,421,474,82,79,148,54,277,758,318,352,46,76,56,326,468,29,670,349,494,275,351,437,300,93,50,546,873 }, { 64,297,5,80,445,61,95,311,250,312,472,34,237,86,45,180,738,17,151,58,22,667,869,247,2,14,73,288,194,106,53,21,128,197,352,177,32,29,186,469,833,217,52,165,287,255,3,1,495,391,396,243,176,137,90,546,125,56,161,141,136,592,48,10,209,27,0,231,76,751,62,11,437,315,119,887,115,334,179,23,84,498,651,207,77,4,864,145,13,881,389,304,6,59,49,631,372,65,16,240,164,153,112,378,549,483,584,527,316,26,862,509,409,752,51,7,875,18,933,171,269,196,457,283,241,148,114,19 }, { 71,16,24,18,60,35,7,92,118,154,68,149,150,14,175,28,124,55,302,97,0,273,126,108,429,140,230,43,375,2,246,109,20,628,69,336,189,9,101,66,38,298,107,65,439,22,517,346,279,345,1,467,419,21,67,169,399,49,48,46,158,847,420,10,570,185,232,251,6,653,29,252,441,314,12,566,637,191,5,535,51,52,508,423,364,533,722,36,32,398,172,74,882,674,917,168,121,95,39,23,621,83,221,159,105,50,505,356,13,701,96,37,484,694,962,173,608,604,135,267,86,104,64,826,329,103,363,236 }, { 195,360,156,591,687,771,163,626,70,883,146,132,586,371,407,379,354,48,846,121,293,13,296,31,761,98,18,767,49,105,385,44,279,522,668,21,1,55,23,125,5,518,271,127,590,878,340,10,608,223,33,807,167,259,77,447,116,75,60,658,102,446,265,929,115,128,35,457,221,87,786,301,284,4,95,51,165,395,39,481,698,541,781,291,178,664,372,150,252,777,557,64,30,24,16,153,120,40,558,535,281,107,465,763,638,783,663,393,101,937,9,467,58,196,217,144,61,401,212,199,117,299,941,32,22,817,260,118 }, { 13,77,202,318,23,51,33,269,141,64,137,32,291,0,128,102,21,494,4,10,403,217,177,342,5,196,9,349,117,22,153,134,98,95,115,59,31,120,753,18,16,40,48,28,90,372,317,237,49,450,1,86,65,244,352,475,194,11,180,165,142,100,44,125,76,12,116,93,523,275,127,121,24,20,453,365,341,61,859,401,144,82,402,210,198,178,147,88,37,17,2,351,234,105,7,6,326,197,110,30,203,143,922,854,851,427,325,259,118,107,101,72,55,704,421,260,114,36,208,329,265,38,164,864,752,717,558,498 }, { 192,81,172,173,7,426,97,232,861,715,43,879,66,712,104,387,330,568,825,74,526,893,91,298,885,448,636,681,140,92,49,560,6,204,135,779,22,5,95,572,707,64,125,726,750,14,370,563,314,20,324,10,362,29,174,246,713,0,718,356,107,138,25,397,85,63,18,38,71,21,441,98,58,500,230,31,501,32,319,408,69,729,189,13,663,422,24,784,359,241,858,165,16,347,263,77,357,623,673,26,888,2,12,353,900,141,23,52,126,37,33,622,278,830,197,48,233,40,443,355,44,42,45,267,87,19,61,237 }, { 14,2,1,67,6,24,69,66,7,29,38,108,36,65,83,124,46,52,150,86,25,484,28,302,74,22,388,18,267,398,458,103,50,273,168,97,12,5,16,0,650,135,26,19,160,75,172,189,21,10,208,32,289,278,380,547,782,95,610,140,51,602,118,37,114,451,429,357,42,71,23,324,505,194,149,420,48,143,92,87,17,13,421,115,60,54,70,35,584,96,756,462,20,238,109,185,27,164,64,45,220,244,253,594,3,154,99,138,43,283,335,701,133,309,128,403,797,49,58,732,550,202,169,646,401,423,218,847 }, { 202,77,33,13,102,128,51,318,23,64,494,4,141,196,59,0,115,403,40,22,269,210,177,153,137,117,32,90,10,475,291,21,342,15,11,134,352,95,18,65,49,217,86,16,180,36,197,453,165,275,57,1,402,9,194,48,24,341,719,28,105,6,123,349,317,285,523,125,120,372,216,14,450,365,20,457,2,237,7,82,576,98,3,421,12,5,260,247,110,730,116,44,31,901,752,300,8,208,30,498,351,96,93,139,678,164,46,19,401,386,308,817,615,214,50,35,961,758,859,326,160,17,503,391,293,242,221,203 }, { 269,318,141,291,77,202,349,217,947,304,33,177,102,851,372,352,753,260,351,120,5,137,854,752,494,275,403,32,922,22,180,475,21,317,30,10,954,31,64,44,418,365,49,28,48,450,39,23,95,341,661,373,82,11,4,36,93,13,61,128,7,6,3,2,859,51,0,197,800,576,96,59,901,69,165,40,203,144,247,1,86,898,12,76,70,160,498,437,342,237,125,9,433,330,238,103,98,67,453,312,864,367,326,253,87,58,361,221,99,90,888,717,678,579,65,774,241,115,50,45,968,951,704,615,473,277,244,134 }, { 6,74,138,85,66,222,226,87,42,280,25,135,26,792,500,294,75,29,220,204,70,174,337,145,235,112,278,853,461,19,52,97,1,32,122,38,808,2,256,172,64,889,69,324,380,774,620,802,609,525,7,95,353,21,571,5,65,580,746,415,22,108,140,96,14,241,24,331,63,45,544,287,67,237,267,125,262,92,394,348,103,86,163,632,426,90,194,606,165,630,550,58,53,36,233,76,91,192,357,28,27,17,141,189,416,72,582,486,81,49,114,16,622,113,78,115,10,928,444,537,872,462,46,605,83,350,335,150 }, { 9,0,105,39,101,18,16,68,310,24,333,272,252,127,98,518,846,938,28,371,1,916,35,158,286,737,455,31,301,265,327,100,395,616,49,30,254,7,578,55,23,827,118,512,109,44,329,21,65,890,60,320,242,116,137,709,170,51,385,125,48,761,166,14,5,2,13,71,293,131,520,627,154,159,299,557,344,836,12,553,364,93,202,96,167,88,623,128,36,124,506,64,688,212,604,924,910,931,120,284,50,144,10,419,22,165,219,32,37,95,77,110,121,326,67,403,404,203,442,197,187,6,141,676,276,260,239,33 }, { 2,14,1,67,46,24,108,29,83,69,38,103,52,75,133,236,309,36,114,28,50,18,398,135,6,65,458,278,7,238,74,87,160,388,124,220,732,0,267,262,66,149,532,335,283,25,412,71,16,5,96,55,547,154,70,273,602,22,302,418,429,218,516,366,646,150,336,357,86,696,175,26,189,54,12,68,118,226,35,172,324,58,582,19,486,208,9,21,594,109,531,112,45,484,140,596,251,60,95,323,17,10,32,37,194,394,64,650,48,168,163,145,42,571,97,222,23,420,505,27,181,92,389,533,606,171,361,99 }, { 22,1,28,105,95,49,55,67,168,159,239,65,14,320,35,0,2,36,114,7,170,109,83,12,169,347,194,50,301,69,9,24,5,424,164,185,103,133,654,46,312,420,16,127,10,175,158,64,584,21,23,51,98,143,31,86,286,13,37,289,6,336,389,48,283,505,96,124,68,38,638,512,160,208,39,141,202,18,115,189,128,395,54,623,874,338,237,713,547,44,272,308,740,137,149,371,125,251,32,30,518,345,844,535,180,3,293,928,756,916,242,29,835,165,538,708,327,323,99,737,484,221,401,218,533,374,253,154 }, { 66,7,172,97,232,92,314,568,298,140,192,380,135,330,74,324,387,448,357,14,526,126,38,246,204,16,426,107,572,52,2,808,712,501,359,60,69,278,29,230,32,779,441,500,35,95,550,5,21,22,893,6,43,563,392,104,267,46,24,150,362,64,726,138,189,423,173,65,825,71,356,20,462,279,0,12,802,87,86,174,560,10,81,18,49,37,226,830,633,25,48,28,90,289,58,36,67,75,707,91,508,241,312,1,85,451,220,70,443,199,214,636,50,108,83,61,54,222,121,353,262,125,280,45,888,750,237,42 }, { 2,29,52,50,46,14,5,1,6,26,133,114,58,218,366,70,19,108,45,27,112,17,236,137,75,38,262,25,74,13,283,516,53,487,223,151,145,208,96,48,51,412,287,163,23,401,323,285,86,65,171,61,36,220,21,480,594,42,128,80,331,73,103,754,181,115,12,739,113,3,532,4,194,54,602,635,186,99,202,409,675,745,34,308,583,307,357,309,782,396,150,57,361,7,764,165,66,735,324,64,966,457,453,90,24,386,445,11,484,32,389,141,629,59,87,244,155,956,711,670,421,22,545,832,758,334,328,573 }, { 6,74,1,25,29,42,75,26,66,2,70,138,52,19,85,220,103,388,38,14,226,87,135,324,67,357,108,112,235,69,238,603,222,65,550,500,96,114,145,594,83,309,133,516,27,36,150,451,218,294,262,532,711,51,58,602,280,13,163,50,380,63,137,97,802,23,122,278,458,64,5,394,86,53,606,696,792,46,891,160,461,267,732,12,7,204,582,113,308,453,24,545,889,386,331,45,21,165,398,486,391,115,32,423,401,95,337,758,632,17,208,3,853,457,256,537,335,78,630,141,307,189,641,37,646,444,670,10 }, { 22,28,109,49,9,105,131,95,1,36,159,39,86,185,31,98,272,169,127,55,44,219,83,254,286,208,141,128,35,327,352,160,30,180,116,0,224,202,115,239,13,535,187,137,5,96,12,374,317,269,2,244,837,312,752,67,531,21,533,253,237,197,64,217,51,143,168,158,578,251,318,505,37,258,165,285,365,10,7,23,498,201,538,371,901,320,50,424,347,678,48,69,164,776,708,601,341,597,616,345,228,170,873,238,634,6,947,3,482,93,125,144,518,242,946,913,864,716,4,735,8,627,221,420,100,688,910,323 }, { 203,822,77,859,326,576,23,403,39,817,137,100,102,473,494,691,411,291,33,177,704,70,523,217,447,96,367,478,18,373,160,13,363,265,1,658,615,93,966,520,310,144,30,692,800,578,342,182,180,120,90,51,254,296,40,158,682,333,9,354,921,349,273,127,121,101,83,60,59,24,731,264,115,821,364,44,268,260,752,857,810,272,196,166,153,131,118,48,16,457,156,67,506,481,450,415,230,15,0,593,968,914,212,937,829,395,365,351,242,225,224,219,194,187,146,141,132,117,110,87,82,49,36,35,22,905,901,656 }, { 15,33,117,77,102,134,153,4,115,196,13,40,217,11,341,1,23,5,317,3,365,2,291,21,32,12,349,569,177,59,51,342,0,6,372,139,7,37,901,210,10,180,17,90,111,629,48,275,82,120,197,244,304,141,14,253,137,57,202,247,401,638,308,457,300,9,719,961,482,437,260,277,351,579,31,44,93,216,165,269,36,125,450,72,523,453,89,38,352,94,730,854,116,752,18,817,143,98,386,64,56,96,318,16,468,55,160,148,61,54,76,22,485,110,403,99,221,922,19,474,79,127,65,105,588,27,490,128 }, { 15,13,23,51,0,8,197,180,1,165,9,33,82,5,4,10,12,120,2,102,386,115,260,475,7,351,141,110,77,901,326,14,21,18,11,217,22,457,40,93,898,453,373,36,450,341,16,6,125,31,64,854,352,719,401,117,32,391,28,730,3,291,177,203,24,961,523,202,59,317,403,99,49,44,210,922,615,37,237,111,801,153,128,498,342,629,196,509,30,899,569,421,304,752,48,758,817,276,258,137,269,130,393,98,365,57,116,65,338,144,55,704,134,349,105,206,661,551,308,242,38,95,494,275,86,546,318,56 }, { 23,51,1,13,21,141,5,180,15,2,202,120,7,0,197,165,12,9,6,4,115,48,352,269,403,386,33,260,318,93,3,32,457,110,37,137,14,450,475,16,82,128,523,453,102,31,18,326,125,421,8,77,44,221,391,64,308,730,401,341,217,153,11,117,98,719,498,196,30,351,99,40,752,494,24,237,317,39,72,28,36,10,59,203,49,373,365,17,116,817,90,899,96,509,22,569,35,901,144,961,615,342,45,50,291,177,86,89,244,661,55,134,20,54,854,65,873,801,402,160,95,247,38,350,629,127,105,29 }, { 15,1,0,2,5,3,7,4,6,8,13,10,341,23,9,180,51,82,120,77,31,110,197,961,115,12,22,93,116,165,569,730,202,217,365,752,457,453,719,102,125,44,351,30,403,141,352,33,11,260,523,317,291,475,28,21,450,318,64,898,401,98,899,386,203,36,210,40,177,269,16,242,638,421,326,153,349,372,18,817,494,854,117,275,342,59,111,196,14,137,629,49,134,55,39,143,70,32,37,139,95,758,244,958,498,801,87,24,922,86,670,253,144,170,208,90,105,615,373,873,391,308,247,482,216,61,393,304 }, { 559,661,922,564,373,141,260,533,244,332,269,317,642,143,10,93,110,295,728,752,261,876,531,351,206,843,120,345,203,352,180,811,253,384,36,197,144,434,717,901,959,365,498,55,567,1,943,9,28,535,817,22,160,873,902,341,326,911,35,82,601,860,39,30,679,489,824,704,417,926,217,251,940,699,574,137,617,854,201,816,116,282,898,115,44,372,855,258,237,473,662,509,187,169,864,499,349,284,125,31,468,224,21,669,64,318,164,546,951,395,964,839,450,8,219,170,776,638,268,851,23,131,98,482,367,299,48,730 }, { 15,5,1,2,23,0,13,7,6,51,3,180,12,9,115,4,165,719,197,457,21,8,14,33,901,22,37,141,82,341,120,10,730,202,16,110,32,31,386,11,317,153,117,752,260,351,453,217,401,18,352,77,308,93,961,48,28,44,134,569,365,391,49,269,102,523,128,98,196,758,137,99,498,36,40,30,450,64,403,17,318,509,24,89,95,475,629,854,72,125,221,177,86,873,326,247,96,899,817,898,39,38,421,139,116,291,482,55,494,59,105,203,210,144,65,468,29,20,237,54,349,90,148,372,244,734,35,45 }, { 198,234,5,0,325,77,416,202,61,32,147,49,639,20,43,21,315,22,450,113,95,455,142,427,48,318,230,207,342,18,494,13,329,904,577,725,64,178,28,10,70,58,344,470,102,403,128,819,269,263,104,137,1,319,112,246,17,23,347,291,7,65,887,798,120,12,241,4,36,858,107,237,66,76,376,817,39,422,316,72,97,33,945,105,2,51,90,141,290,884,557,253,9,518,251,671,11,173,86,31,115,27,159,158,194,3,24,312,289,362,260,259,192,859,414,426,16,14,306,523,37,126,475,712,576,310,453,98 }, { 447,411,264,363,676,9,664,682,821,812,759,478,897,166,100,905,354,156,1,382,98,265,404,724,39,18,691,656,668,101,520,195,23,144,223,21,865,271,438,593,639,848,31,96,13,5,51,521,125,586,48,127,604,88,909,30,252,765,393,647,360,77,33,121,167,781,367,44,621,132,93,0,410,274,286,118,203,254,120,272,105,102,293,446,116,83,32,658,68,310,371,284,777,115,364,4,834,16,948,69,333,163,24,212,190,40,340,329,551,914,117,49,110,153,70,165,146,35,296,418,10,67,842,242,883,326,697,238 }, { 24,71,35,14,69,149,189,108,267,18,16,68,46,2,7,67,140,388,60,38,236,83,251,1,133,118,309,230,336,52,103,29,458,278,28,65,135,175,150,50,172,92,273,55,0,154,75,443,114,9,705,124,399,66,565,398,412,602,335,366,36,101,823,596,451,74,220,345,375,302,594,330,696,516,87,238,6,891,21,218,5,12,54,262,48,96,86,22,582,357,324,97,191,64,70,232,283,723,95,10,37,160,831,732,346,246,563,380,32,25,109,486,733,167,58,314,212,226,192,13,429,99,547,23,181,126,572,394 }, { 35,16,7,20,14,60,18,121,24,43,107,68,109,126,199,326,92,120,77,907,2,147,23,259,265,475,403,260,553,1,13,523,132,252,12,146,71,55,33,0,5,859,191,318,817,38,6,450,82,202,848,402,9,286,51,21,329,159,494,419,351,28,465,327,102,10,158,48,682,374,576,198,178,97,32,421,272,621,269,615,590,279,128,941,22,446,167,142,70,493,4,310,604,581,19,105,640,463,453,407,153,694,64,810,150,108,90,29,534,427,212,346,285,709,638,557,793,137,101,39,37,25,291,165,118,95,58,50 }, { 30,131,276,187,613,442,44,228,39,31,190,839,935,224,116,856,219,88,9,406,201,908,574,100,244,127,567,137,36,98,110,144,1,93,202,863,258,141,829,260,28,284,49,120,269,295,318,716,21,827,254,661,166,160,203,373,299,55,385,0,22,662,352,944,13,82,530,77,253,86,268,23,96,717,489,64,180,51,326,274,778,918,48,351,492,5,752,197,83,206,125,128,450,115,217,860,32,242,931,578,293,213,102,924,494,851,95,10,101,836,105,272,143,291,699,371,35,434,165,843,864,367,403,159,177,418,261,68 }, { 98,223,1,393,812,834,421,697,48,265,593,791,51,410,100,382,293,284,21,23,125,96,541,213,656,88,801,453,31,321,230,765,730,386,221,13,689,9,264,670,639,163,217,5,909,807,116,144,44,352,137,286,551,30,770,948,39,252,699,466,438,435,201,401,127,93,842,475,203,165,921,478,180,166,949,724,367,963,831,36,128,404,455,805,141,676,854,202,2,317,318,772,840,190,32,418,251,855,105,35,333,77,83,197,102,335,49,443,576,957,719,351,539,308,69,55,82,310,115,0,120,557,752,329,403,269,686,669 }, { 98,616,219,127,258,51,293,512,924,395,105,421,272,276,308,201,401,284,763,116,23,301,295,453,327,567,944,31,44,843,261,13,268,860,170,770,115,125,569,900,131,386,144,935,456,55,578,365,320,143,341,662,137,109,28,403,434,242,221,36,203,670,286,141,10,326,22,629,21,943,95,9,743,685,160,384,623,506,180,49,206,949,533,719,734,558,282,299,185,159,244,64,8,0,110,964,911,169,32,4,224,551,202,475,11,187,910,617,492,901,253,841,716,1,489,269,959,940,165,699,615,374,855,332,237,713,86,371 }, { 253,951,352,110,811,244,206,141,180,332,854,642,282,10,143,638,417,752,559,533,498,260,55,661,911,499,717,120,351,959,535,93,564,160,873,531,137,341,269,197,922,384,373,36,365,728,261,617,901,8,44,82,116,165,31,317,164,64,203,217,509,824,115,473,968,268,144,326,704,434,295,601,86,15,345,851,864,237,943,251,450,169,1,843,201,762,13,372,22,258,308,125,898,96,98,202,127,855,940,4,33,489,21,28,187,9,40,546,117,83,569,338,964,51,5,32,479,391,276,23,102,318,482,349,219,153,128,817 }, { 49,254,272,159,9,158,627,131,327,39,518,688,0,578,28,286,68,105,101,347,424,374,364,344,224,22,333,616,65,219,35,24,124,154,716,890,95,577,16,371,320,109,810,538,228,168,310,793,747,127,30,419,613,829,827,187,385,239,846,170,21,1,98,18,36,71,938,406,910,252,31,55,346,175,23,289,51,190,48,258,86,185,83,912,100,623,301,166,128,149,125,67,118,96,44,137,64,242,13,737,857,160,703,671,694,455,202,442,169,60,856,10,761,924,221,709,116,706,634,114,439,677,194,479,7,570,212,395 }, { 105,272,22,131,327,374,286,320,109,224,219,28,239,95,98,578,9,169,127,185,538,159,187,616,55,258,371,36,634,623,64,164,49,713,86,910,716,385,168,654,170,420,424,1,10,312,737,201,35,254,293,284,51,23,143,13,44,761,141,601,160,395,933,31,928,916,276,301,924,208,116,67,346,237,137,347,535,39,194,242,0,442,836,83,762,165,584,338,638,505,892,244,251,175,345,114,740,12,391,944,837,128,158,202,197,479,261,253,908,352,912,125,531,96,308,295,144,24,21,30,7,269,268,2,751,323,228,5 }, { 691,478,340,724,658,914,698,1,363,744,772,156,411,447,682,909,303,284,296,264,354,919,335,98,9,21,686,664,225,223,586,410,96,367,382,897,51,13,521,33,848,765,125,144,23,32,120,759,48,69,662,260,44,31,166,40,93,77,5,4,551,668,35,269,30,82,191,167,163,318,351,87,404,371,102,88,812,438,165,70,39,385,293,116,65,64,656,364,101,622,286,948,254,271,393,321,141,75,11,18,854,842,443,433,118,100,418,274,202,421,16,774,67,326,329,905,149,922,110,37,386,201,12,197,127,49,203,907 }, { 16,24,71,35,18,108,140,60,92,267,68,189,7,230,191,246,149,14,118,167,388,46,69,236,458,399,674,212,273,9,133,1,126,150,21,309,330,50,101,55,2,48,103,121,67,906,602,5,0,345,723,412,232,172,271,146,565,28,516,696,702,75,38,65,451,32,796,12,37,594,633,154,278,733,375,366,302,199,124,314,36,336,398,443,823,64,695,54,135,114,29,22,95,97,462,915,52,563,582,251,705,575,891,589,175,10,83,566,572,13,220,223,23,467,218,830,163,363,394,66,562,132,107,446,641,517,49,86 }, { 9,127,0,395,371,98,39,31,737,49,512,385,272,44,28,293,299,101,836,761,158,252,254,16,242,1,284,159,116,18,518,35,276,310,333,24,187,51,21,599,137,30,301,22,131,68,286,23,219,327,202,125,616,48,442,935,456,578,916,5,109,166,685,55,265,7,65,100,688,128,105,201,36,890,623,96,144,13,908,329,12,2,846,64,37,95,141,344,455,318,403,124,93,492,154,32,404,14,203,269,938,627,67,258,118,224,170,244,326,110,268,165,367,763,86,60,827,221,716,160,924,553,120,419,489,662,10,83 }, { 16,18,60,68,35,101,252,0,118,71,9,419,28,24,109,364,604,191,126,167,55,121,329,92,7,158,265,39,212,22,346,14,925,49,107,694,185,169,621,146,439,333,628,124,199,150,942,21,159,48,154,553,706,175,108,575,279,677,10,962,20,105,100,848,917,815,446,363,907,132,5,793,271,375,43,149,23,65,13,566,520,806,286,810,95,166,593,374,302,51,1,97,634,598,404,407,12,31,2,272,493,46,467,727,463,562,589,125,326,327,310,50,967,96,682,168,37,344,140,608,203,98,38,647,821,246,362,67 }, { 116,268,203,692,93,206,940,31,551,417,473,959,499,44,202,523,559,8,137,120,450,728,299,494,403,22,51,576,0,326,564,817,10,260,13,23,127,1,899,9,105,421,125,615,318,492,638,98,386,918,141,393,341,269,253,21,791,5,28,2,144,64,37,244,805,762,373,180,128,401,599,55,901,242,352,30,165,197,453,642,730,475,170,873,115,49,569,36,4,859,7,143,391,498,86,48,308,922,752,39,395,719,365,951,285,6,457,456,958,12,110,402,704,384,367,95,512,949,18,24,16,515,479,221,32,948,801,282 }, { 225,1,744,919,21,459,914,48,691,284,330,385,141,96,98,335,622,166,5,293,51,32,120,223,948,340,260,443,203,88,286,30,831,372,50,363,351,269,82,64,934,70,658,9,190,127,403,352,13,115,418,682,411,371,87,144,393,909,521,922,776,272,102,90,69,61,839,23,15,4,774,349,327,321,268,244,202,197,100,93,551,75,848,662,523,442,478,373,206,201,180,125,76,59,45,36,33,963,538,410,274,237,163,156,821,303,264,772,724,450,382,367,958,954,899,898,865,864,859,854,765,752,730,668,664,506,494,475 }, { 5,1,14,2,36,50,28,0,48,281,21,67,24,54,22,83,218,12,38,18,65,181,58,45,114,133,430,32,17,46,96,10,9,103,37,160,502,61,155,99,270,55,72,7,29,513,16,51,108,487,238,23,543,745,86,3,290,6,540,89,361,115,834,13,52,202,221,433,842,488,480,137,236,76,69,328,223,64,838,514,49,532,35,666,474,128,171,283,766,536,227,124,966,308,75,19,552,95,70,208,775,141,323,27,541,822,697,425,754,765,4,285,207,148,657,109,318,412,243,263,77,592,832,663,741,186,807,576 }, { 450,137,704,202,326,120,260,851,318,968,494,269,457,182,403,291,351,349,77,678,141,23,310,373,817,859,576,661,523,890,60,128,82,64,795,110,854,70,515,96,5,159,285,1,961,341,13,717,9,421,922,203,180,95,244,55,379,658,577,347,105,75,49,822,687,115,363,800,557,301,160,36,937,475,411,67,59,237,18,16,354,195,864,771,615,520,424,415,344,83,68,51,28,0,805,447,386,364,268,232,107,101,90,86,7,668,481,342,271,786,735,901,897,846,751,731,719,638,621,586,518,402,296,253,239,208,197,165 }, { 15,4,33,77,40,13,102,11,23,5,32,21,110,117,217,51,93,153,59,1,247,134,115,141,64,202,120,2,372,180,3,10,12,31,82,291,177,116,139,125,269,196,8,317,17,22,165,137,98,351,318,36,44,128,203,197,28,0,352,48,260,349,898,144,57,403,450,437,6,719,341,72,304,111,457,523,90,365,494,9,326,49,37,730,7,210,39,86,30,14,475,95,386,453,638,961,854,373,76,401,901,237,277,752,56,342,160,817,244,758,402,308,899,143,89,206,216,569,421,615,61,535,45,18,316,127,164,579 }, { 23,13,51,1,15,5,2,7,0,21,180,6,115,12,141,9,165,3,197,457,202,4,14,352,719,48,33,32,16,269,37,217,341,8,11,401,120,318,308,22,386,77,31,18,128,752,40,110,260,10,28,453,730,93,137,498,901,403,391,153,82,317,365,117,44,102,17,523,961,569,64,450,509,72,99,49,134,36,758,59,98,221,24,629,89,30,351,475,196,326,125,177,494,291,90,421,237,29,899,203,35,39,247,864,817,95,372,96,349,20,116,854,65,38,54,160,19,144,57,86,244,304,873,55,342,373,350,316 }, { 219,258,127,276,98,944,395,201,567,284,131,293,935,860,116,662,295,224,737,105,578,576,242,403,843,371,137,551,272,456,512,421,51,31,475,716,202,697,261,44,492,187,924,616,268,9,49,326,206,254,144,299,39,385,22,115,916,805,93,699,308,203,943,159,160,761,836,763,125,23,13,0,332,453,401,386,36,120,28,770,141,21,327,615,384,393,282,958,221,318,494,367,365,143,217,128,434,64,692,940,10,244,110,617,301,911,55,964,730,320,5,966,523,86,719,623,457,96,95,1,269,317,24,670,197,859,842,286 }, { 16,35,60,18,7,92,20,14,118,0,68,126,71,28,154,24,107,43,158,22,2,109,49,55,677,168,185,1,97,6,121,12,21,175,10,5,159,703,150,202,169,105,191,942,95,38,494,279,37,137,23,13,9,329,230,140,628,48,69,420,32,553,124,326,167,128,403,120,747,101,74,51,108,925,31,65,66,621,246,475,29,46,36,576,344,52,419,25,575,81,104,98,375,173,570,421,346,39,265,199,86,50,671,269,424,362,58,318,54,450,44,149,125,143,817,566,615,302,61,439,260,453,170,165,493,402,67,286 }, { 728,531,160,93,373,574,559,717,120,860,533,295,269,260,318,926,851,434,258,36,902,137,251,332,617,141,201,261,699,206,384,940,968,843,816,345,352,244,187,839,564,55,776,661,144,959,871,116,64,219,44,473,489,268,535,203,10,567,31,911,498,143,896,110,679,450,523,224,824,800,197,164,276,601,351,406,662,202,873,752,943,317,365,169,855,228,704,282,131,180,253,326,82,954,1,669,125,854,367,901,98,217,165,417,817,341,86,442,831,8,898,642,284,13,127,876,237,21,947,864,22,83,23,748,418,115,946,868 }, { 28,9,0,1,22,109,49,39,83,55,12,158,67,96,69,5,35,30,65,95,168,323,159,128,185,238,21,50,36,105,2,24,160,23,194,208,103,7,68,169,137,218,141,48,37,505,16,420,51,13,202,86,251,285,18,114,269,31,115,531,124,10,289,418,101,402,797,154,433,32,99,175,64,866,735,252,180,646,272,100,286,480,503,54,333,533,244,14,344,131,352,44,318,127,98,327,6,346,217,570,254,197,237,181,657,800,535,745,374,4,335,75,317,165,281,756,143,584,757,419,532,345,956,365,223,831,403,341 }, { 23,13,51,5,141,21,1,165,202,2,15,32,12,197,115,180,7,0,48,269,120,9,4,6,453,386,403,318,308,401,37,457,14,33,137,352,64,3,125,128,523,16,31,93,391,260,730,719,475,341,450,237,99,18,82,110,11,10,44,77,326,421,8,217,494,40,28,90,102,59,49,17,117,36,98,30,221,899,247,317,22,365,72,153,509,24,196,351,39,498,569,629,752,89,116,134,177,203,20,373,96,961,901,372,817,241,291,45,86,57,19,61,76,304,38,758,468,65,50,160,105,144,55,402,29,244,216,25 }, { 5,21,13,49,23,43,32,20,48,14,7,51,97,107,61,115,38,713,22,24,1,12,70,46,652,955,142,58,16,590,0,626,197,2,640,147,64,279,581,132,350,150,121,303,81,493,340,888,841,104,36,60,87,18,95,345,92,241,296,221,509,98,349,308,622,91,202,195,638,141,125,35,408,407,156,379,269,146,66,28,31,9,786,534,17,128,903,929,518,178,29,354,4,108,105,263,522,687,247,65,259,850,126,44,237,199,54,774,535,271,260,50,347,6,446,318,159,90,10,288,137,783,360,76,223,598,55,586 }, { 9,28,0,39,101,30,49,35,68,1,67,166,175,83,22,158,100,252,141,55,88,69,65,109,36,23,180,217,323,115,64,269,345,103,21,124,10,317,13,251,289,238,364,498,154,352,230,5,419,131,190,31,7,51,194,48,50,346,96,128,439,159,160,105,202,24,274,143,952,95,16,168,12,646,341,254,752,86,868,365,637,596,244,127,137,570,433,318,418,114,864,208,44,37,503,404,372,2,32,344,197,333,116,532,218,77,98,187,237,164,125,723,535,443,480,169,265,901,189,310,221,420,336,873,797,403,402,285 }, { 260,120,450,351,854,82,269,922,5,32,13,125,33,23,202,291,165,21,197,77,137,1,141,203,457,349,318,51,4,326,177,144,180,753,730,275,386,523,817,237,116,217,373,719,403,98,93,31,372,128,241,115,12,899,704,341,304,196,102,44,40,391,48,2,342,898,954,864,801,494,284,208,110,76,59,365,352,285,207,947,758,663,615,599,558,492,482,456,408,350,263,210,201,160,64,57,49,19,18,16,14,11,10,7,6,961,317,361,37,968,752,661,498,475,453,402,323,300,293,268,244,206,154,127,105,96,95,86 }, { 121,16,60,363,35,18,101,20,167,68,621,259,126,191,604,407,107,132,55,364,43,146,199,252,7,14,92,419,590,147,212,71,9,326,5,463,520,21,694,917,465,24,354,446,647,109,13,271,682,0,28,22,120,203,10,97,806,821,48,169,77,279,727,362,2,346,195,581,640,932,178,589,118,115,102,125,23,202,51,439,941,907,848,411,450,33,857,427,634,165,553,154,108,180,39,494,325,185,373,329,142,475,265,818,49,342,158,967,403,260,1,523,374,612,110,962,12,534,955,37,615,376,150,793,692,562,137,638 }, { 23,13,51,5,1,12,2,141,15,21,115,0,202,180,7,32,197,3,165,4,6,9,401,37,269,14,308,457,352,11,318,453,341,386,120,403,10,16,33,22,8,719,18,391,40,31,77,48,217,28,137,17,99,365,523,475,569,128,730,44,93,59,260,102,498,450,90,49,509,24,30,317,110,752,421,64,247,125,72,82,237,221,177,629,98,351,961,494,153,36,89,19,117,758,901,373,196,326,57,38,39,29,20,65,546,304,134,116,95,899,817,139,372,76,35,55,316,241,291,468,482,203,144,210,45,402,873,54 }, { 201,144,206,443,418,332,203,435,330,96,494,326,473,372,335,269,434,268,187,403,822,817,459,1,88,498,564,384,839,382,617,367,83,264,934,559,295,276,30,717,344,521,141,831,321,274,44,202,576,31,9,686,709,190,100,921,699,812,252,55,230,137,208,450,616,457,284,180,128,93,28,859,410,966,228,265,456,352,69,523,318,244,158,795,961,747,735,662,584,531,421,855,213,168,960,225,478,959,899,716,578,577,489,466,417,291,223,116,36,35,23,13,954,952,237,800,349,285,77,744,866,772,752,346,197,166,98,32 }, { 44,276,31,116,201,284,662,567,131,489,144,268,295,434,918,30,9,39,98,137,187,219,299,224,935,367,49,384,385,36,93,22,28,0,244,261,141,127,492,699,203,110,254,1,202,836,160,442,253,258,105,96,64,269,393,51,128,371,125,23,716,55,86,318,326,10,908,120,206,940,855,77,143,190,827,13,21,228,352,217,100,35,159,48,165,115,272,944,373,948,260,617,829,102,197,166,578,737,83,16,332,293,95,717,450,24,523,88,180,403,109,18,177,37,164,5,899,242,959,613,730,285,291,15,7,616,911,473 }, { 520,664,478,604,759,264,167,1,724,777,9,647,411,682,48,806,936,363,101,223,265,410,21,68,118,252,100,907,848,447,772,98,96,781,0,212,88,905,16,821,39,925,917,23,329,909,382,18,166,942,125,191,639,221,13,24,51,676,124,932,321,897,621,628,521,5,71,154,69,31,30,815,686,293,541,49,284,271,60,593,765,55,32,812,404,435,335,807,163,562,44,834,553,35,691,65,364,763,105,83,146,28,127,274,10,158,7,190,393,64,238,213,419,67,701,421,354,33,22,254,697,149,116,272,201,115,77,144 }, { 70,23,87,21,60,75,163,182,267,92,291,120,115,107,146,379,195,132,446,795,937,246,126,121,98,71,48,18,7,415,931,566,232,133,51,24,125,371,821,668,535,411,401,340,318,308,221,116,77,44,40,32,11,4,281,850,293,563,537,407,273,217,202,199,140,13,5,807,197,64,591,385,33,883,386,626,687,891,823,820,770,766,754,743,670,658,633,627,615,598,551,545,541,458,394,392,372,364,361,349,342,338,333,330,301,284,283,268,264,216,210,105,102,100,95,49,35,31,866,774,597,498,335,244,238,237,160,2 }, { 39,9,737,127,0,310,98,827,846,395,100,31,371,916,254,265,385,105,272,101,18,30,836,1,242,166,44,512,16,557,116,252,131,578,938,931,137,93,301,28,125,68,333,24,51,404,23,120,286,616,856,35,299,21,55,13,64,202,593,716,128,96,48,326,329,219,260,158,7,110,264,5,688,456,77,203,165,36,49,373,924,761,442,118,863,639,144,518,318,284,228,88,438,60,327,363,12,450,33,190,82,10,411,731,102,65,293,109,455,95,170,908,599,623,494,115,478,187,141,2,14,22,812,685,276,403,935,197 }, { 107,126,279,20,43,356,362,92,7,359,16,598,683,595,246,441,60,392,939,653,399,35,199,319,125,649,97,259,414,71,0,493,121,858,230,150,140,232,191,49,48,14,702,173,575,68,95,298,422,674,18,64,98,590,147,22,612,118,28,24,672,104,819,407,345,146,77,660,695,10,953,375,423,31,945,314,293,33,640,23,115,93,158,44,167,149,132,154,21,783,5,175,81,807,508,376,105,109,59,13,40,391,779,387,237,124,589,470,55,426,4,330,727,729,51,427,169,120,796,223,91,189,446,117,153,541,463,755 }, { 206,417,93,959,728,559,499,473,137,120,8,564,141,244,260,253,450,31,44,10,269,352,203,318,373,143,341,202,638,116,752,180,144,951,940,326,268,110,160,851,115,922,127,98,717,642,384,125,434,64,13,36,51,282,615,704,365,661,197,498,23,901,817,30,762,489,276,692,15,873,165,22,968,86,1,854,128,386,299,105,217,811,55,0,242,421,317,351,523,367,237,911,21,170,49,77,9,349,391,28,509,479,187,177,82,201,576,285,164,898,492,401,96,456,291,569,494,800,338,33,32,5,39,372,12,261,295,293 }, { 259,465,147,581,534,132,590,687,146,427,199,279,941,195,955,640,786,107,178,522,798,121,929,362,150,5,198,325,626,142,35,21,878,376,407,360,167,48,271,1,423,10,70,20,13,126,77,22,125,98,493,31,163,49,212,202,0,105,43,783,33,14,156,345,883,102,612,767,28,97,660,346,470,221,23,450,60,12,771,92,191,379,120,591,2,467,318,9,32,61,4,535,128,153,117,116,562,95,953,18,115,595,159,494,17,371,44,293,818,58,165,51,7,68,354,246,234,269,87,342,845,196,260,72,6,134,481,93 }, { 523,403,817,202,15,899,450,120,51,730,494,421,719,128,457,453,13,23,342,102,401,318,64,196,33,475,141,180,49,5,115,269,308,197,237,221,165,99,4,77,137,95,260,0,757,576,365,316,125,65,48,615,402,326,159,11,671,389,312,289,283,247,210,203,194,148,105,22,21,386,835,12,958,749,743,697,485,351,350,341,300,177,170,158,155,151,136,133,129,127,123,122,119,114,113,112,90,89,86,84,80,72,62,61,59,58,56,45,40,34,27,26,25,19,17,3,901,752,153,134,117,961,922,968,967,966,965,964 }, { 141,559,244,10,661,253,564,143,365,533,752,180,55,110,901,160,922,373,341,317,93,535,352,206,260,531,36,197,332,269,82,642,282,964,498,911,717,261,728,873,943,351,137,64,417,854,120,1,811,9,115,217,898,169,28,165,164,86,384,203,22,15,83,21,959,96,617,499,318,35,31,8,482,295,951,251,345,372,902,5,473,601,144,32,546,843,800,237,13,864,44,509,109,824,67,268,450,391,308,349,23,258,77,567,851,291,202,116,949,615,125,926,954,638,551,569,457,51,326,102,59,434,817,418,958,719,629,523 }, { 219,258,276,127,284,98,935,860,943,843,567,201,137,295,964,131,261,116,535,662,492,44,160,253,31,224,206,203,615,268,144,332,293,692,924,918,384,244,944,326,36,128,434,395,716,737,367,456,187,55,96,403,551,318,911,617,616,385,699,533,115,940,202,365,10,836,576,966,523,959,77,28,21,93,9,120,489,141,1,260,48,371,531,217,143,282,564,125,110,180,51,704,421,299,39,23,64,363,254,393,442,242,494,417,105,822,473,317,578,269,272,697,22,855,102,805,475,13,948,341,0,373,33,285,82,49,932,574 }, { 422,319,0,945,207,887,32,577,693,43,95,20,904,22,344,61,104,804,707,306,426,124,5,725,7,241,153,325,316,49,715,414,113,671,115,239,263,329,173,198,180,102,18,365,117,83,24,33,376,510,942,355,324,140,134,69,21,9,232,77,76,240,237,196,189,177,160,158,36,10,835,292,341,526,334,331,168,92,48,16,330,37,25,204,64,901,595,416,392,347,858,362,244,174,164,149,97,86,60,58,39,31,30,27,790,770,222,65,2,350,40,11,4,814,13,933,424,159,819,397,697,623,610,491,403,387,315,288 }, { 1,22,12,5,2,0,36,21,28,49,105,86,95,37,55,9,7,48,23,32,141,83,10,51,31,96,269,202,13,128,50,4,160,239,208,318,14,168,159,6,3,170,44,67,164,54,115,285,99,35,109,98,244,180,64,137,402,65,24,127,16,352,320,18,197,69,323,30,158,11,169,301,708,678,238,312,77,717,597,39,143,165,584,194,125,17,253,217,341,735,281,114,116,218,654,181,403,237,424,103,347,317,185,177,45,401,15,776,242,29,46,72,68,418,498,433,223,33,569,901,480,531,40,657,365,800,851,8 }, { 15,13,2,1,5,23,3,0,4,7,6,51,115,9,10,12,197,11,14,77,22,217,269,8,165,31,961,33,457,202,32,180,21,341,40,141,120,102,177,16,569,453,28,318,317,17,260,291,44,365,93,37,117,134,110,30,352,18,403,719,153,196,49,401,59,475,901,36,326,98,64,304,386,125,498,730,349,494,450,137,48,247,95,90,523,308,752,24,128,210,111,99,82,139,372,203,873,57,76,116,237,342,72,629,351,391,482,509,19,421,39,144,373,35,55,216,89,275,437,817,20,86,105,56,899,96,38,65 }, { 23,202,77,51,13,120,1,141,15,326,180,269,260,137,318,102,450,5,128,21,110,217,291,165,197,352,115,317,373,2,48,12,7,0,523,33,203,386,403,9,96,64,93,342,6,351,82,32,14,457,177,16,36,817,349,752,494,37,4,475,18,210,901,854,341,285,615,59,275,90,498,50,244,160,391,453,99,308,86,10,365,401,22,719,922,8,221,24,730,28,704,402,421,11,125,83,67,237,661,3,40,898,30,153,35,961,31,196,65,253,39,576,17,44,247,20,569,300,95,49,899,116,509,473,117,143,70,372 }, { 15,1,0,2,51,13,23,5,7,180,9,6,12,4,115,33,197,523,21,120,3,8,14,457,901,165,351,141,450,260,202,365,341,82,16,40,730,31,37,308,719,401,77,93,44,18,10,899,64,453,403,32,137,317,386,217,36,48,110,98,475,102,326,28,22,128,269,30,11,116,569,421,352,318,817,752,24,196,961,221,99,39,49,144,153,629,55,89,17,203,373,35,117,59,801,898,291,873,177,509,86,125,494,244,95,160,482,134,498,854,72,372,96,615,349,468,38,143,758,237,90,127,391,54,342,670,734,247 }, { 16,24,18,92,35,71,60,7,75,126,140,108,50,132,9,21,68,121,14,246,13,0,146,23,267,1,48,128,220,107,70,230,150,32,12,199,118,5,394,181,87,137,537,46,51,133,269,189,141,54,64,22,167,10,202,156,2,330,281,820,171,77,99,291,774,217,177,349,58,65,39,37,103,69,163,28,95,67,622,318,309,633,86,236,101,360,372,6,563,36,195,304,115,38,641,314,30,149,522,232,20,591,352,354,49,545,55,98,571,271,317,526,649,407,672,278,100,640,586,45,223,114,31,678,430,237,388,328 }, { 180,341,901,15,1,365,5,2,0,4,197,7,6,115,3,752,10,13,569,317,873,23,165,8,55,141,9,143,44,93,31,498,217,51,638,253,509,308,352,12,22,401,244,36,116,33,21,11,206,64,144,120,951,391,629,137,16,37,86,372,269,125,734,386,134,110,351,40,18,421,417,260,77,282,117,326,268,499,102,457,164,318,482,373,237,203,170,127,95,35,661,642,82,202,177,559,468,261,201,196,160,221,105,961,32,28,854,551,169,24,349,811,762,728,564,338,14,242,717,291,109,153,139,128,403,312,437,851 }, { 9,0,101,175,35,28,39,68,364,67,252,65,124,289,158,336,154,166,83,55,100,114,439,103,419,69,49,194,346,1,30,189,345,570,109,88,22,168,64,251,50,16,547,36,230,96,596,133,389,868,265,238,149,86,429,24,694,21,128,218,637,399,141,703,23,646,51,826,13,671,208,677,159,706,95,137,7,797,505,610,237,12,115,756,10,404,484,131,768,190,2,333,71,164,18,799,329,323,344,967,283,202,274,420,782,930,48,105,286,140,217,702,480,143,212,54,37,962,269,14,857,185,310,532,254,535,197,118 }, { 64,115,180,197,237,165,391,247,217,352,386,316,304,32,90,13,21,468,95,72,317,76,498,89,365,291,141,125,22,509,349,288,179,86,546,98,372,23,341,225,437,49,116,569,645,796,923,459,18,411,308,177,48,640,4,586,490,16,5,12,591,312,241,933,117,35,65,134,482,752,672,269,164,77,156,302,71,1,264,873,410,321,118,446,360,271,102,59,24,682,674,246,953,88,149,751,51,521,92,823,447,144,864,37,7,11,695,702,166,781,698,662,647,588,458,403,401,363,283,239,216,194,170,153,57,33,28,17 }, { 15,13,1,2,5,23,0,4,7,3,115,6,51,217,9,12,197,10,141,21,11,961,457,180,8,341,77,33,165,22,14,32,31,317,202,120,40,37,177,260,16,102,93,269,901,365,352,28,44,247,318,18,117,110,134,17,386,569,372,719,752,59,48,30,36,498,153,403,196,49,450,291,82,72,125,137,304,128,453,391,730,401,98,873,349,373,523,139,509,24,64,326,39,90,475,111,99,308,899,116,95,89,482,203,351,210,86,922,144,437,629,55,57,421,148,494,342,854,35,76,20,179,817,758,275,105,237,216 }, { 132,199,146,121,407,60,493,279,640,598,534,522,195,581,590,955,360,126,259,107,150,783,362,35,5,156,271,49,167,939,18,16,147,612,941,591,467,21,883,465,423,929,0,10,191,92,22,298,441,356,446,13,70,48,7,31,626,28,77,24,32,296,178,97,212,33,354,108,608,786,623,68,345,586,727,660,71,649,687,102,163,125,9,105,115,683,55,4,463,379,75,23,87,98,14,953,293,159,50,44,818,761,376,61,246,40,64,763,713,109,1,120,117,767,359,427,95,101,20,344,58,43,607,221,575,663,142,153 }, { 28,1,0,22,9,24,65,55,12,5,67,36,96,83,114,50,18,16,2,14,35,103,21,109,49,48,7,218,160,54,124,69,433,37,281,238,23,10,181,51,223,133,137,39,154,745,68,58,99,480,202,13,95,86,75,128,657,115,283,532,285,46,32,163,323,822,38,141,175,547,30,389,766,108,45,168,646,64,194,429,158,169,185,155,361,505,418,70,420,800,531,105,208,502,269,430,6,101,71,866,318,765,402,289,838,398,149,31,251,221,29,484,757,543,4,3,533,308,180,503,17,403,72,754,171,118,217,89 }, { 93,120,957,968,459,77,30,160,352,217,473,110,102,372,202,373,613,291,137,260,190,752,704,141,317,31,318,961,269,177,44,326,203,851,330,863,450,264,321,265,228,224,728,457,304,247,88,924,116,840,800,219,144,365,197,115,28,187,717,49,39,944,559,908,829,406,934,349,213,916,244,131,64,225,36,98,82,9,730,403,342,275,210,180,109,100,86,33,938,855,55,831,521,367,719,10,661,165,922,935,258,839,918,864,669,539,351,274,196,166,83,341,15,959,822,772,617,285,897,531,410,716,686,478,871,251,901,836 }, { 15,0,1,13,9,23,2,5,51,7,12,6,120,4,8,10,102,197,523,901,341,180,14,260,115,82,77,141,33,165,3,16,21,18,202,59,450,22,403,457,110,817,93,475,64,351,11,453,137,37,401,898,421,128,28,40,719,31,961,217,36,48,569,365,30,125,269,308,318,373,203,317,210,32,494,98,44,116,730,352,24,86,49,326,386,117,342,854,95,629,17,153,144,55,391,177,922,899,99,291,237,143,196,39,805,134,221,96,576,670,139,752,35,253,244,661,300,50,57,127,402,65,638,349,19,498,206,111 }, { 206,417,244,499,141,253,44,8,137,559,269,144,93,10,31,728,116,564,203,143,268,352,717,638,120,260,160,752,951,318,384,341,180,282,373,959,434,127,110,197,202,125,851,64,36,901,642,473,498,326,332,115,165,450,201,98,873,242,922,23,22,1,217,261,276,762,55,13,489,86,661,51,317,365,15,940,898,811,82,855,854,704,9,295,0,21,372,164,351,37,968,187,569,367,911,5,576,28,617,401,237,170,615,128,776,349,7,48,105,421,479,386,16,96,95,299,291,12,258,824,864,308,817,2,30,403,49,692 }, { 530,840,254,228,406,829,669,613,827,96,21,48,51,31,23,960,137,224,219,1,166,131,39,98,679,438,310,190,856,116,93,403,274,221,144,127,258,846,36,202,180,938,688,120,318,765,421,385,931,317,475,13,77,816,876,105,44,187,30,115,5,625,203,125,752,442,141,32,367,308,365,284,924,778,341,842,50,28,268,333,242,217,860,160,100,22,616,539,110,88,871,159,37,345,9,165,33,839,332,299,83,574,351,576,68,404,371,10,518,326,82,748,716,863,492,578,401,265,456,102,269,656,128,926,557,531,498,494 }, { 15,13,197,457,0,719,23,8,730,1,82,165,120,134,9,10,5,180,2,141,7,12,115,51,260,901,4,899,351,6,341,352,33,3,22,386,450,31,202,11,117,569,523,269,128,93,18,898,44,110,758,28,752,373,365,64,30,961,77,318,498,873,21,854,111,49,102,37,16,40,99,137,125,317,14,391,55,217,24,116,326,98,403,474,36,494,482,817,509,372,35,661,277,139,922,615,38,801,203,143,291,153,475,86,453,253,629,304,148,437,402,237,48,642,954,564,864,431,244,95,242,144,39,401,72,17,196,958 }, { 68,0,16,24,35,9,252,71,419,18,28,101,154,158,109,124,118,60,39,55,329,364,333,49,65,677,346,22,7,185,265,149,159,175,169,191,810,302,553,100,14,92,344,108,439,671,703,793,105,168,375,286,272,327,374,21,694,706,1,10,67,126,254,634,310,95,212,289,701,2,48,167,150,455,166,627,577,30,747,420,273,538,46,69,962,36,51,23,424,13,12,64,857,429,593,96,5,570,925,86,917,199,37,125,31,50,83,826,628,912,107,239,604,98,638,114,688,221,967,131,709,137,170,336,140,20,589,128 }, { 51,1,23,13,15,180,120,2,5,197,202,141,0,7,21,165,260,326,33,9,4,450,12,102,6,523,48,386,115,403,269,137,457,352,14,318,16,128,110,77,3,40,196,32,18,93,217,82,317,37,341,8,817,96,31,401,453,36,752,342,351,44,719,203,901,28,475,221,421,365,64,730,24,391,153,30,308,373,10,494,22,615,59,11,39,99,98,50,116,899,498,961,177,372,291,35,854,144,509,244,17,49,922,569,86,72,247,65,349,125,160,210,482,127,117,402,20,134,55,873,38,83,898,67,275,88,285,237 }, { 535,253,352,564,365,110,82,180,854,341,10,533,873,55,244,898,752,901,143,642,141,559,498,36,317,951,638,160,661,115,197,282,964,137,531,165,634,351,64,308,164,217,169,206,417,811,86,499,482,28,332,125,373,509,15,569,93,546,83,728,762,965,96,22,468,601,260,911,269,717,9,349,922,109,345,800,291,734,31,23,338,170,1,372,538,629,221,943,8,120,261,44,21,318,743,494,401,128,202,13,822,579,403,251,617,959,719,770,67,864,219,185,127,117,48,286,384,299,730,475,453,402,350,69,421,391,98,39 }, { 31,125,44,116,338,64,242,55,164,36,299,1,237,86,456,10,22,558,506,144,498,492,13,23,762,170,268,143,206,685,93,870,180,844,599,5,903,546,197,115,2,203,509,169,479,165,141,127,0,352,253,393,752,740,8,137,12,51,28,341,391,638,7,244,9,457,160,367,873,98,128,384,951,963,282,202,918,21,269,37,6,105,569,629,434,365,120,301,4,708,318,3,417,489,923,901,719,317,308,401,386,535,217,14,15,734,95,551,634,499,208,533,332,49,758,83,824,961,730,239,776,601,523,751,948,717,864,654 }, { 23,13,51,4,115,202,5,217,77,141,1,11,180,2,317,0,3,7,33,269,318,15,365,341,21,9,102,10,32,6,40,12,352,177,22,197,403,64,165,128,901,59,752,31,494,137,308,291,28,8,18,349,401,16,125,90,30,14,237,498,372,93,37,98,153,49,453,17,36,873,44,475,457,39,342,196,210,24,48,326,569,386,421,247,95,203,120,509,275,116,391,961,117,244,110,143,57,304,144,216,482,719,134,139,468,86,523,55,221,450,67,76,50,253,35,105,260,65,437,373,730,72,859,629,46,692,576,111 }, { 39,9,166,364,68,101,158,333,0,154,562,28,404,30,65,124,252,35,175,274,344,310,190,706,49,289,570,100,168,438,694,419,346,703,826,55,16,24,439,21,88,149,254,577,429,810,109,159,962,857,671,212,455,656,22,610,95,194,1,336,747,13,125,67,36,131,530,865,48,71,625,793,10,589,23,64,841,265,484,539,86,224,558,350,69,237,420,51,835,96,272,105,406,677,165,228,83,18,31,141,114,286,557,221,347,115,137,169,722,778,7,391,98,818,816,308,840,634,709,44,185,128,960,777,143,258,669,60 }, { 15,341,13,33,23,77,141,4,0,351,1,260,102,51,82,9,40,349,854,11,115,217,269,137,180,202,922,5,901,22,10,117,21,365,318,197,120,352,64,12,7,153,177,59,291,32,128,2,165,196,372,36,403,317,457,28,18,8,16,304,30,14,450,31,898,37,3,752,48,134,139,494,421,6,453,401,719,90,86,569,523,110,24,55,475,210,49,44,386,17,730,95,247,244,961,143,125,308,342,817,629,98,498,93,96,76,39,275,509,326,99,285,373,57,237,35,402,160,111,253,105,391,221,116,899,72,127,661 }
8342433ea134385a90f8c7a50f47f5233e8d5a86
f3eed0234b4d0ad2bbb2abd700cf1e2c7a0e8a1d
/AKWF-c/AKWF_0020/AKWF_1929.h
a1ec8e1637fb9da9026f88fced073b28a7c074b4
[ "CC0-1.0" ]
permissive
KristofferKarlAxelEkstrand/AKWF-FREE
b2defa1a2d389d309be6dd2e9f968923daf80d1b
cf8171df36e9fec25416b5f568b72a6e2cb69194
refs/heads/master
2023-07-23T18:22:36.939705
2023-07-10T17:14:40
2023-07-10T17:14:40
145,817,187
359
59
CC0-1.0
2023-07-10T17:14:41
2018-08-23T07:26:56
null
UTF-8
C
false
false
4,672
h
AKWF_1929.h
/* Adventure Kid Waveforms (AKWF) converted for use with Teensy Audio Library * * Adventure Kid Waveforms(AKWF) Open waveforms library * https://www.adventurekid.se/akrt/waveforms/adventure-kid-waveforms/ * * This code is in the public domain, CC0 1.0 Universal (CC0 1.0) * https://creativecommons.org/publicdomain/zero/1.0/ * * Converted by Brad Roy, https://github.com/prosper00 */ /* AKWF_1929 256 samples +-----------------------------------------------------------------------------------------------------------------+ | ** *** | | ** *** ****** | | ** ** ** ** | | ** ** ******* ** * | | * *** **** *** ** * | |* ********** ** ** ** | |* ** ** ** | | ** ** ** *** | | ** ** ** **** *** *| | ** ** ** *** ** **| | ** ** *** *** ** ** | | *** ** ***** ** * | | ****** ** * | | ** ** | | ** ** | +-----------------------------------------------------------------------------------------------------------------+ */ const uint16_t AKWF_1929 [] = { 33569, 36137, 38563, 41002, 43325, 45586, 47731, 49769, 51683, 53457, 55096, 56573, 57909, 59066, 60081, 60909, 61591, 62094, 62451, 62637, 62686, 62575, 62336, 61959, 61468, 60857, 60150, 59347, 58466, 57512, 56501, 55441, 54345, 53224, 52086, 50945, 49806, 48686, 47584, 46517, 45487, 44506, 43573, 42703, 41894, 41154, 40483, 39887, 39366, 38922, 38556, 38269, 38058, 37924, 37865, 37878, 37960, 38108, 38319, 38588, 38909, 39279, 39692, 40142, 40622, 41128, 41652, 42186, 42726, 43263, 43791, 44302, 44790, 45246, 45667, 46041, 46363, 46628, 46830, 46961, 47018, 46993, 46885, 46689, 46401, 46017, 45539, 44965, 44292, 43524, 42660, 41706, 40661, 39531, 38325, 37044, 35698, 34294, 32844, 31353, 29834, 28298, 26755, 25221, 23704, 22220, 20781, 19400, 18092, 16867, 15737, 14717, 13814, 13043, 12411, 11926, 11597, 11431, 11430, 11599, 11940, 12453, 13137, 13991, 15007, 16180, 17505, 18968, 20562, 22272, 24087, 25989, 27966, 29999, 32070, 34162, 36257, 38335, 40378, 42365, 44281, 46106, 47825, 49419, 50873, 52177, 53314, 54279, 55055, 55641, 56030, 56217, 56203, 55988, 55572, 54964, 54167, 53189, 52045, 50742, 49298, 47724, 46038, 44258, 42402, 40486, 38534, 36562, 34590, 32639, 30726, 28872, 27089, 25399, 23813, 22349, 21013, 19820, 18778, 17893, 17167, 16608, 16212, 15978, 15904, 15985, 16212, 16576, 17067, 17670, 18377, 19166, 20027, 20940, 21889, 22857, 23823, 24772, 25688, 26551, 27347, 28061, 28677, 29186, 29572, 29829, 29947, 29924, 29751, 29431, 28959, 28341, 27578, 26678, 25647, 24497, 23236, 21880, 20440, 18934, 17378, 15789, 14186, 12583, 11006, 9467, 7991, 6586, 5284, 4085, 3022, 2092, 1326, 717, 296, 49, 5, 147, 499, 1043, 1792, 2735, 3871, 5195, 6690, 8362, 10176, 12154, 14233, 16463, 18745, 21167, 23578, 26135, 28578, 31271, };
a667e5e70e2ad93197995a46590ee549c60d0185
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/linux-a64/include/linux/seq_file_net.h
32c89bbe24a260754a7d3ee13293daeee9f548e9
[ "Linux-syscall-note", "GPL-2.0-only", "GPL-1.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
674
h
seq_file_net.h
#ifndef __SEQ_FILE_NET_H__ #define __SEQ_FILE_NET_H__ #include <linux/seq_file.h> struct net; extern struct net init_net; struct seq_net_private { #ifdef CONFIG_NET_NS struct net *net; #endif }; int seq_open_net(struct inode *, struct file *, const struct seq_operations *, int); int single_open_net(struct inode *, struct file *file, int (*show)(struct seq_file *, void *)); int seq_release_net(struct inode *, struct file *); int single_release_net(struct inode *, struct file *); static inline struct net *seq_file_net(struct seq_file *seq) { #ifdef CONFIG_NET_NS return ((struct seq_net_private *)seq->private)->net; #else return &init_net; #endif } #endif
407fa8a5fad50cf8009075b8e36266437c298603
ebd47e03503f324a106438e15f8609a78e320dc5
/script/testdata/debugger.c
2bdeb3613e21a4669de4515d68e332db1a16aa3d
[ "MIT" ]
permissive
nervosnetwork/ckb
a82a70b8cd071ce16b9f11356138e0c91b426fbe
b4a71b905dcb5e55776ed58d8d2401df75bac9e0
refs/heads/develop
2023-09-04T08:02:19.158825
2023-09-01T08:27:44
2023-09-01T08:27:44
158,225,088
1,205
267
MIT
2023-09-14T08:24:16
2018-11-19T13:11:16
Rust
UTF-8
C
false
false
187
c
debugger.c
#include "ckb_syscalls.h" #include <stdio.h> int main() { char message[2048]; sprintf(message, "debugger print utf-8 string"); ckb_debug(message); return CKB_SUCCESS; }
9b487b959e9e37714419f968a443ed190c459e91
e3cdfae1dd874479c928dad193b33a4e3b8a623e
/src/convoymenu.c
54d15c205f80590aaa638b4200b971d6c89feb19
[]
no_license
FireEmblemUniverse/fireemblem8u
11493bf94844617b33254110ba006316defb3510
b9ad9bcafd9d4ecb7fc13cc77a464e2a82ac8338
refs/heads/master
2023-09-05T23:39:53.791339
2023-09-04T17:31:47
2023-09-04T17:31:47
121,802,075
118
31
null
2023-09-11T13:08:37
2018-02-16T21:21:50
Assembly
UTF-8
C
false
false
5,139
c
convoymenu.c
#include "global.h" #include "functions.h" #include "variables.h" #include "proc.h" #include "bmcontainer.h" #include "icon.h" #include "fontgrp.h" #include "uimenu.h" #include "bb.h" #include "bmunit.h" #include "bmmenu.h" #include "bmitem.h" #include "hardware.h" #include "popup.h" #include "face.h" #include "scene.h" struct ProcCmd CONST_DATA gProcCmd_ConvoyMenu[] = { PROC_CALL_2(ConvoyMenuProc_StarMenu), PROC_CALL_2(ConvoyMenuProc_MenuEnd), PROC_SLEEP(1), PROC_CALL_2(ConvoyMenuProc_MaybeStartSelectConvoyItem), PROC_CALL_2(ConvoyMenuProc_SendToConvoyReal), PROC_LABEL(0x63), PROC_CALL(ConvoyMenuProc_SetupActiveUnit), PROC_CALL(ConvoyMenuProc_ExecBootlegPopup), PROC_YIELD, PROC_END }; extern EWRAM_DATA u8 gConvoyItemCount; extern const struct MenuDef gSendToConvoyMenuDef; extern const struct MenuDef gConvoyMenuDef; int ConvoyMenuProc_StarMenu(ProcPtr proc) { gConvoyItemCount = GetConvoyItemCount(); LoadIconPalettes(4); if (HasConvoyAccess() && (gConvoyItemCount < 100)) StartMenu(&gSendToConvoyMenuDef, (ProcPtr)proc); else StartMenu(&gConvoyMenuDef, (ProcPtr)proc); return 0; } int ConvoyMenuProc_MenuEnd(ProcPtr proc) { EndSubtitleHelp(); EndMenuItemPanel(); /* this should be item to be sent to convoy */ if (0 == gBmSt.itemUnk2E) { Proc_Goto(proc, 0x63); return 1; } return 0; } int ConvoyMenuProc_MaybeStartSelectConvoyItem(ProcPtr proc) { MaybeStartSelectConvoyItemProc(0, proc); return 0; } int ConvoyMenuProc_SendToConvoyReal(ProcPtr proc) { return AddItemToConvoy(gBmSt.itemUnk2E); } void ConvoyMenuProc_SetupActiveUnit(ProcPtr proc) { gActiveUnit = GetUnit(gActionData.subjectIndex); } void ConvoyMenuProc_ExecBootlegPopup(ProcPtr proc) { if (HasConvoyAccess()) { if (gConvoyItemCount < 100) NewPopup2_SendItem(proc, gActionData.item); else NewPopup2_DropItem(proc, gActionData.item); } else NewPopup2_DropItem(proc, gActionData.item); } void HandleNewItemGetFromDrop(struct Unit* unit, int item, ProcPtr proc) { u8 ret = UnitAddItem(unit, item); if (FALSE != ret) return; gActiveUnit = unit; gBmSt.itemUnk2C = item; StartFace(0, GetUnitPortraitId(unit), 0xB0, 4, 2); SetFaceBlinkControlById(0, 5); ForceMenuItemPanel(proc, unit, 0xF, 0xA); if (HasConvoyAccess() && GetConvoyItemCount() < 100) /* Your inventory is full. Send an item to Supply.[.] */ StartSubtitleHelp(proc, GetStringFromIndex(0x867)); else /* Your inventory is full. Select an item to discard. */ StartSubtitleHelp(proc, GetStringFromIndex(0x866)); SetTalkChoiceResult(2); Proc_StartBlocking(gProcCmd_ConvoyMenu, proc); } int SendToConvoyMenu_Draw(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { return ItemSelectMenu_TextDraw(proc_menu, proc_cmd); } int MenuCommand_DrawExtraItem(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { u16 item = gBmSt.itemUnk2C; struct Text* text = &proc_cmd->text; Text_SetColor(text, TEXT_COLOR_SYSTEM_BLUE); DrawItemMenuLineNoColor(text, item, TILEMAP_LOCATED(gBG0TilemapBuffer, proc_cmd->xTile, proc_cmd->yTile)); BG_EnableSyncByMask(BG0_SYNC_BIT); } u8 SendToConvoyMenu_NormalEffect(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { AddItemToConvoy(gActiveUnit->items[proc_cmd->itemNumber]); gActionData.item = gActiveUnit->items[proc_cmd->itemNumber]; UnitRemoveItem(gActiveUnit, proc_cmd->itemNumber); UnitAddItem(gActiveUnit, gBmSt.itemUnk2C); return MENU_ACT_ENDFACE | MENU_ACT_CLEAR | MENU_ACT_SND6A | MENU_ACT_END | MENU_ACT_SKIPCURSOR; } u8 MenuCommand_SendItemToConvoy(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { AddItemToConvoy(gBmSt.itemUnk2C); gActionData.item = gBmSt.itemUnk2C; return MENU_ACT_ENDFACE | MENU_ACT_CLEAR | MENU_ACT_SND6A | MENU_ACT_END | MENU_ACT_SKIPCURSOR; } u8 SendToConvoyMenu_Selected(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { gActionData.item = gActiveUnit->items[proc_cmd->itemNumber]; gActionData.unk08 = proc_cmd->itemNumber; LoadHelpBoxGfx(NULL, -1); /* maybe draw hand? */ sub_808AA04(0x8, proc_cmd->itemNumber * 0x10 + 0x20, 0x84B, proc_menu); return 0; } u8 SendToConvoyMenu_Selected2(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { gActionData.item = gBmSt.itemUnk2C; gActionData.unk08 = UNIT_ITEM_COUNT; LoadHelpBoxGfx(NULL, -1); /* maybe draw hand? */ sub_808AA04(0x8, proc_cmd->itemNumber * 0x10 + 0x20, 0x84B, proc_menu); return 0; } u8 SendToConvoyMenu_Idle(struct MenuProc* proc_menu, struct MenuItemProc* proc_cmd) { if (1 != GetTalkChoiceResult()) return 0; gKeyStatusPtr->newKeys = 0; if (gActionData.unk08 < UNIT_ITEM_COUNT) { UnitRemoveItem(gActiveUnit, gActionData.unk08); UnitAddItem(gActiveUnit, gBmSt.itemUnk2C); } return MENU_ACT_ENDFACE | MENU_ACT_CLEAR | MENU_ACT_SND6A | MENU_ACT_END | MENU_ACT_SKIPCURSOR; }
8e38bd64f6399195621c65942765ee6590b9adab
7eaf54a78c9e2117247cb2ab6d3a0c20719ba700
/SOFTWARE/A64-TERES/u-boot_new/drivers/usb/musb-new/musb_host.c
9a2cf59d9248364e9c53ab3f504a2980b4f0b216
[ "GPL-2.0-or-later", "LicenseRef-scancode-free-unknown", "Apache-2.0" ]
permissive
OLIMEX/DIY-LAPTOP
ae82f4ee79c641d9aee444db9a75f3f6709afa92
a3fafd1309135650bab27f5eafc0c32bc3ca74ee
refs/heads/rel3
2023-08-04T01:54:19.483792
2023-04-03T07:18:12
2023-04-03T07:18:12
80,094,055
507
92
Apache-2.0
2023-04-03T07:05:59
2017-01-26T07:25:50
C
UTF-8
C
false
false
66,981
c
musb_host.c
/* * MUSB OTG driver host support * * Copyright 2005 Mentor Graphics Corporation * Copyright (C) 2005-2006 by Texas Instruments * Copyright (C) 2006-2007 Nokia Corporation * Copyright (C) 2008-2009 MontaVista Software, Inc. <source@mvista.com> * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ #define __UBOOT__ #ifndef __UBOOT__ #include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <linux/sched.h> #include <linux/slab.h> #include <linux/errno.h> #include <linux/init.h> #include <linux/list.h> #include <linux/dma-mapping.h> #else #include <common.h> #include <usb.h> #include "linux-compat.h" #include "usb-compat.h" #endif #include "musb_core.h" #include "musb_host.h" /* MUSB HOST status 22-mar-2006 * * - There's still lots of partial code duplication for fault paths, so * they aren't handled as consistently as they need to be. * * - PIO mostly behaved when last tested. * + including ep0, with all usbtest cases 9, 10 * + usbtest 14 (ep0out) doesn't seem to run at all * + double buffered OUT/TX endpoints saw stalls(!) with certain usbtest * configurations, but otherwise double buffering passes basic tests. * + for 2.6.N, for N > ~10, needs API changes for hcd framework. * * - DMA (CPPI) ... partially behaves, not currently recommended * + about 1/15 the speed of typical EHCI implementations (PCI) * + RX, all too often reqpkt seems to misbehave after tx * + TX, no known issues (other than evident silicon issue) * * - DMA (Mentor/OMAP) ...has at least toggle update problems * * - [23-feb-2009] minimal traffic scheduling to avoid bulk RX packet * starvation ... nothing yet for TX, interrupt, or bulk. * * - Not tested with HNP, but some SRP paths seem to behave. * * NOTE 24-August-2006: * * - Bulk traffic finally uses both sides of hardware ep1, freeing up an * extra endpoint for periodic use enabling hub + keybd + mouse. That * mostly works, except that with "usbnet" it's easy to trigger cases * with "ping" where RX loses. (a) ping to davinci, even "ping -f", * fine; but (b) ping _from_ davinci, even "ping -c 1", ICMP RX loses * although ARP RX wins. (That test was done with a full speed link.) */ /* * NOTE on endpoint usage: * * CONTROL transfers all go through ep0. BULK ones go through dedicated IN * and OUT endpoints ... hardware is dedicated for those "async" queue(s). * (Yes, bulk _could_ use more of the endpoints than that, and would even * benefit from it.) * * INTERUPPT and ISOCHRONOUS transfers are scheduled to the other endpoints. * So far that scheduling is both dumb and optimistic: the endpoint will be * "claimed" until its software queue is no longer refilled. No multiplexing * of transfers between endpoints, or anything clever. */ static void musb_ep_program(struct musb *musb, u8 epnum, struct urb *urb, int is_out, u8 *buf, u32 offset, u32 len); /* * Clear TX fifo. Needed to avoid BABBLE errors. */ static void musb_h_tx_flush_fifo(struct musb_hw_ep *ep) { struct musb *musb = ep->musb; void __iomem *epio = ep->regs; u16 csr; u16 lastcsr = 0; int retries = 1000; csr = musb_readw(epio, MUSB_TXCSR); while (csr & MUSB_TXCSR_FIFONOTEMPTY) { if (csr != lastcsr) dev_dbg(musb->controller, "Host TX FIFONOTEMPTY csr: %02x\n", csr); lastcsr = csr; csr |= MUSB_TXCSR_FLUSHFIFO; musb_writew(epio, MUSB_TXCSR, csr); csr = musb_readw(epio, MUSB_TXCSR); if (WARN(retries-- < 1, "Could not flush host TX%d fifo: csr: %04x\n", ep->epnum, csr)) return; mdelay(1); } } static void musb_h_ep0_flush_fifo(struct musb_hw_ep *ep) { void __iomem *epio = ep->regs; u16 csr; int retries = 5; /* scrub any data left in the fifo */ do { csr = musb_readw(epio, MUSB_TXCSR); if (!(csr & (MUSB_CSR0_TXPKTRDY | MUSB_CSR0_RXPKTRDY))) break; musb_writew(epio, MUSB_TXCSR, MUSB_CSR0_FLUSHFIFO); csr = musb_readw(epio, MUSB_TXCSR); udelay(10); } while (--retries); WARN(!retries, "Could not flush host TX%d fifo: csr: %04x\n", ep->epnum, csr); /* and reset for the next transfer */ musb_writew(epio, MUSB_TXCSR, 0); } /* * Start transmit. Caller is responsible for locking shared resources. * musb must be locked. */ static inline void musb_h_tx_start(struct musb_hw_ep *ep) { u16 txcsr; /* NOTE: no locks here; caller should lock and select EP */ if (ep->epnum) { txcsr = musb_readw(ep->regs, MUSB_TXCSR); txcsr |= MUSB_TXCSR_TXPKTRDY | MUSB_TXCSR_H_WZC_BITS; musb_writew(ep->regs, MUSB_TXCSR, txcsr); } else { txcsr = MUSB_CSR0_H_SETUPPKT | MUSB_CSR0_TXPKTRDY; musb_writew(ep->regs, MUSB_CSR0, txcsr); } } static inline void musb_h_tx_dma_start(struct musb_hw_ep *ep) { u16 txcsr; /* NOTE: no locks here; caller should lock and select EP */ txcsr = musb_readw(ep->regs, MUSB_TXCSR); txcsr |= MUSB_TXCSR_DMAENAB | MUSB_TXCSR_H_WZC_BITS; if (is_cppi_enabled()) txcsr |= MUSB_TXCSR_DMAMODE; musb_writew(ep->regs, MUSB_TXCSR, txcsr); } static void musb_ep_set_qh(struct musb_hw_ep *ep, int is_in, struct musb_qh *qh) { if (is_in != 0 || ep->is_shared_fifo) ep->in_qh = qh; if (is_in == 0 || ep->is_shared_fifo) ep->out_qh = qh; } static struct musb_qh *musb_ep_get_qh(struct musb_hw_ep *ep, int is_in) { return is_in ? ep->in_qh : ep->out_qh; } /* * Start the URB at the front of an endpoint's queue * end must be claimed from the caller. * * Context: controller locked, irqs blocked */ static void musb_start_urb(struct musb *musb, int is_in, struct musb_qh *qh) { u16 frame; u32 len; void __iomem *mbase = musb->mregs; struct urb *urb = next_urb(qh); void *buf = urb->transfer_buffer; u32 offset = 0; struct musb_hw_ep *hw_ep = qh->hw_ep; unsigned pipe = urb->pipe; u8 address = usb_pipedevice(pipe); int epnum = hw_ep->epnum; /* initialize software qh state */ qh->offset = 0; qh->segsize = 0; /* gather right source of data */ switch (qh->type) { case USB_ENDPOINT_XFER_CONTROL: /* control transfers always start with SETUP */ is_in = 0; musb->ep0_stage = MUSB_EP0_START; buf = urb->setup_packet; len = 8; break; #ifndef __UBOOT__ case USB_ENDPOINT_XFER_ISOC: qh->iso_idx = 0; qh->frame = 0; offset = urb->iso_frame_desc[0].offset; len = urb->iso_frame_desc[0].length; break; #endif default: /* bulk, interrupt */ /* actual_length may be nonzero on retry paths */ buf = urb->transfer_buffer + urb->actual_length; len = urb->transfer_buffer_length - urb->actual_length; } dev_dbg(musb->controller, "qh %p urb %p dev%d ep%d%s%s, hw_ep %d, %p/%d\n", qh, urb, address, qh->epnum, is_in ? "in" : "out", ({char *s; switch (qh->type) { case USB_ENDPOINT_XFER_CONTROL: s = ""; break; case USB_ENDPOINT_XFER_BULK: s = "-bulk"; break; #ifndef __UBOOT__ case USB_ENDPOINT_XFER_ISOC: s = "-iso"; break; #endif default: s = "-intr"; break; }; s; }), epnum, buf + offset, len); /* Configure endpoint */ musb_ep_set_qh(hw_ep, is_in, qh); musb_ep_program(musb, epnum, urb, !is_in, buf, offset, len); /* transmit may have more work: start it when it is time */ if (is_in) return; /* determine if the time is right for a periodic transfer */ switch (qh->type) { #ifndef __UBOOT__ case USB_ENDPOINT_XFER_ISOC: #endif case USB_ENDPOINT_XFER_INT: dev_dbg(musb->controller, "check whether there's still time for periodic Tx\n"); frame = musb_readw(mbase, MUSB_FRAME); /* FIXME this doesn't implement that scheduling policy ... * or handle framecounter wrapping */ #ifndef __UBOOT__ if ((urb->transfer_flags & URB_ISO_ASAP) || (frame >= urb->start_frame)) { /* REVISIT the SOF irq handler shouldn't duplicate * this code; and we don't init urb->start_frame... */ qh->frame = 0; goto start; } else { #endif qh->frame = urb->start_frame; /* enable SOF interrupt so we can count down */ dev_dbg(musb->controller, "SOF for %d\n", epnum); #if 1 /* ifndef CONFIG_ARCH_DAVINCI */ musb_writeb(mbase, MUSB_INTRUSBE, 0xff); #endif #ifndef __UBOOT__ } #endif break; default: start: dev_dbg(musb->controller, "Start TX%d %s\n", epnum, hw_ep->tx_channel ? "dma" : "pio"); if (!hw_ep->tx_channel) musb_h_tx_start(hw_ep); else if (is_cppi_enabled() || tusb_dma_omap()) musb_h_tx_dma_start(hw_ep); } } /* Context: caller owns controller lock, IRQs are blocked */ static void musb_giveback(struct musb *musb, struct urb *urb, int status) __releases(musb->lock) __acquires(musb->lock) { dev_dbg(musb->controller, "complete %p %pF (%d), dev%d ep%d%s, %d/%d\n", urb, urb->complete, status, usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe), usb_pipein(urb->pipe) ? "in" : "out", urb->actual_length, urb->transfer_buffer_length ); usb_hcd_unlink_urb_from_ep(musb_to_hcd(musb), urb); spin_unlock(&musb->lock); usb_hcd_giveback_urb(musb_to_hcd(musb), urb, status); spin_lock(&musb->lock); } /* For bulk/interrupt endpoints only */ static inline void musb_save_toggle(struct musb_qh *qh, int is_in, struct urb *urb) { void __iomem *epio = qh->hw_ep->regs; u16 csr; /* * FIXME: the current Mentor DMA code seems to have * problems getting toggle correct. */ if (is_in) csr = musb_readw(epio, MUSB_RXCSR) & MUSB_RXCSR_H_DATATOGGLE; else csr = musb_readw(epio, MUSB_TXCSR) & MUSB_TXCSR_H_DATATOGGLE; usb_settoggle(urb->dev, qh->epnum, !is_in, csr ? 1 : 0); } /* * Advance this hardware endpoint's queue, completing the specified URB and * advancing to either the next URB queued to that qh, or else invalidating * that qh and advancing to the next qh scheduled after the current one. * * Context: caller owns controller lock, IRQs are blocked */ static void musb_advance_schedule(struct musb *musb, struct urb *urb, struct musb_hw_ep *hw_ep, int is_in) { struct musb_qh *qh = musb_ep_get_qh(hw_ep, is_in); struct musb_hw_ep *ep = qh->hw_ep; int ready = qh->is_ready; int status; status = (urb->status == -EINPROGRESS) ? 0 : urb->status; /* save toggle eagerly, for paranoia */ switch (qh->type) { case USB_ENDPOINT_XFER_BULK: case USB_ENDPOINT_XFER_INT: musb_save_toggle(qh, is_in, urb); break; #ifndef __UBOOT__ case USB_ENDPOINT_XFER_ISOC: if (status == 0 && urb->error_count) status = -EXDEV; break; #endif } qh->is_ready = 0; musb_giveback(musb, urb, status); qh->is_ready = ready; /* reclaim resources (and bandwidth) ASAP; deschedule it, and * invalidate qh as soon as list_empty(&hep->urb_list) */ if (list_empty(&qh->hep->urb_list)) { struct list_head *head; struct dma_controller *dma = musb->dma_controller; if (is_in) { ep->rx_reinit = 1; if (ep->rx_channel) { dma->channel_release(ep->rx_channel); ep->rx_channel = NULL; } } else { ep->tx_reinit = 1; if (ep->tx_channel) { dma->channel_release(ep->tx_channel); ep->tx_channel = NULL; } } /* Clobber old pointers to this qh */ musb_ep_set_qh(ep, is_in, NULL); qh->hep->hcpriv = NULL; switch (qh->type) { case USB_ENDPOINT_XFER_CONTROL: case USB_ENDPOINT_XFER_BULK: /* fifo policy for these lists, except that NAKing * should rotate a qh to the end (for fairness). */ if (qh->mux == 1) { head = qh->ring.prev; list_del(&qh->ring); kfree(qh); qh = first_qh(head); break; } case USB_ENDPOINT_XFER_ISOC: case USB_ENDPOINT_XFER_INT: /* this is where periodic bandwidth should be * de-allocated if it's tracked and allocated; * and where we'd update the schedule tree... */ kfree(qh); qh = NULL; break; } } if (qh != NULL && qh->is_ready) { dev_dbg(musb->controller, "... next ep%d %cX urb %p\n", hw_ep->epnum, is_in ? 'R' : 'T', next_urb(qh)); musb_start_urb(musb, is_in, qh); } } static u16 musb_h_flush_rxfifo(struct musb_hw_ep *hw_ep, u16 csr) { /* we don't want fifo to fill itself again; * ignore dma (various models), * leave toggle alone (may not have been saved yet) */ csr |= MUSB_RXCSR_FLUSHFIFO | MUSB_RXCSR_RXPKTRDY; csr &= ~(MUSB_RXCSR_H_REQPKT | MUSB_RXCSR_H_AUTOREQ | MUSB_RXCSR_AUTOCLEAR); /* write 2x to allow double buffering */ musb_writew(hw_ep->regs, MUSB_RXCSR, csr); musb_writew(hw_ep->regs, MUSB_RXCSR, csr); /* flush writebuffer */ return musb_readw(hw_ep->regs, MUSB_RXCSR); } /* * PIO RX for a packet (or part of it). */ static bool musb_host_packet_rx(struct musb *musb, struct urb *urb, u8 epnum, u8 iso_err) { u16 rx_count; u8 *buf; u16 csr; bool done = false; u32 length; int do_flush = 0; struct musb_hw_ep *hw_ep = musb->endpoints + epnum; void __iomem *epio = hw_ep->regs; struct musb_qh *qh = hw_ep->in_qh; int pipe = urb->pipe; void *buffer = urb->transfer_buffer; /* musb_ep_select(mbase, epnum); */ rx_count = musb_readw(epio, MUSB_RXCOUNT); dev_dbg(musb->controller, "RX%d count %d, buffer %p len %d/%d\n", epnum, rx_count, urb->transfer_buffer, qh->offset, urb->transfer_buffer_length); /* unload FIFO */ #ifndef __UBOOT__ if (usb_pipeisoc(pipe)) { int status = 0; struct usb_iso_packet_descriptor *d; if (iso_err) { status = -EILSEQ; urb->error_count++; } d = urb->iso_frame_desc + qh->iso_idx; buf = buffer + d->offset; length = d->length; if (rx_count > length) { if (status == 0) { status = -EOVERFLOW; urb->error_count++; } dev_dbg(musb->controller, "** OVERFLOW %d into %d\n", rx_count, length); do_flush = 1; } else length = rx_count; urb->actual_length += length; d->actual_length = length; d->status = status; /* see if we are done */ done = (++qh->iso_idx >= urb->number_of_packets); } else { #endif /* non-isoch */ buf = buffer + qh->offset; length = urb->transfer_buffer_length - qh->offset; if (rx_count > length) { if (urb->status == -EINPROGRESS) urb->status = -EOVERFLOW; dev_dbg(musb->controller, "** OVERFLOW %d into %d\n", rx_count, length); do_flush = 1; } else length = rx_count; urb->actual_length += length; qh->offset += length; /* see if we are done */ done = (urb->actual_length == urb->transfer_buffer_length) || (rx_count < qh->maxpacket) || (urb->status != -EINPROGRESS); if (done && (urb->status == -EINPROGRESS) && (urb->transfer_flags & URB_SHORT_NOT_OK) && (urb->actual_length < urb->transfer_buffer_length)) urb->status = -EREMOTEIO; #ifndef __UBOOT__ } #endif musb_read_fifo(hw_ep, length, buf); csr = musb_readw(epio, MUSB_RXCSR); csr |= MUSB_RXCSR_H_WZC_BITS; if (unlikely(do_flush)) musb_h_flush_rxfifo(hw_ep, csr); else { /* REVISIT this assumes AUTOCLEAR is never set */ csr &= ~(MUSB_RXCSR_RXPKTRDY | MUSB_RXCSR_H_REQPKT); if (!done) csr |= MUSB_RXCSR_H_REQPKT; musb_writew(epio, MUSB_RXCSR, csr); } return done; } /* we don't always need to reinit a given side of an endpoint... * when we do, use tx/rx reinit routine and then construct a new CSR * to address data toggle, NYET, and DMA or PIO. * * it's possible that driver bugs (especially for DMA) or aborting a * transfer might have left the endpoint busier than it should be. * the busy/not-empty tests are basically paranoia. */ static void musb_rx_reinit(struct musb *musb, struct musb_qh *qh, struct musb_hw_ep *ep) { u16 csr; /* NOTE: we know the "rx" fifo reinit never triggers for ep0. * That always uses tx_reinit since ep0 repurposes TX register * offsets; the initial SETUP packet is also a kind of OUT. */ /* if programmed for Tx, put it in RX mode */ if (ep->is_shared_fifo) { csr = musb_readw(ep->regs, MUSB_TXCSR); if (csr & MUSB_TXCSR_MODE) { musb_h_tx_flush_fifo(ep); csr = musb_readw(ep->regs, MUSB_TXCSR); musb_writew(ep->regs, MUSB_TXCSR, csr | MUSB_TXCSR_FRCDATATOG); } /* * Clear the MODE bit (and everything else) to enable Rx. * NOTE: we mustn't clear the DMAMODE bit before DMAENAB. */ if (csr & MUSB_TXCSR_DMAMODE) musb_writew(ep->regs, MUSB_TXCSR, MUSB_TXCSR_DMAMODE); musb_writew(ep->regs, MUSB_TXCSR, 0); /* scrub all previous state, clearing toggle */ } else { csr = musb_readw(ep->regs, MUSB_RXCSR); if (csr & MUSB_RXCSR_RXPKTRDY) WARNING("rx%d, packet/%d ready?\n", ep->epnum, musb_readw(ep->regs, MUSB_RXCOUNT)); musb_h_flush_rxfifo(ep, MUSB_RXCSR_CLRDATATOG); } /* target addr and (for multipoint) hub addr/port */ if (musb->is_multipoint) { musb_write_rxfunaddr(ep->target_regs, qh->addr_reg); musb_write_rxhubaddr(ep->target_regs, qh->h_addr_reg); musb_write_rxhubport(ep->target_regs, qh->h_port_reg); } else musb_writeb(musb->mregs, MUSB_FADDR, qh->addr_reg); /* protocol/endpoint, interval/NAKlimit, i/o size */ musb_writeb(ep->regs, MUSB_RXTYPE, qh->type_reg); musb_writeb(ep->regs, MUSB_RXINTERVAL, qh->intv_reg); /* NOTE: bulk combining rewrites high bits of maxpacket */ /* Set RXMAXP with the FIFO size of the endpoint * to disable double buffer mode. */ if (musb->double_buffer_not_ok) musb_writew(ep->regs, MUSB_RXMAXP, ep->max_packet_sz_rx); else musb_writew(ep->regs, MUSB_RXMAXP, qh->maxpacket | ((qh->hb_mult - 1) << 11)); ep->rx_reinit = 0; } static bool musb_tx_dma_program(struct dma_controller *dma, struct musb_hw_ep *hw_ep, struct musb_qh *qh, struct urb *urb, u32 offset, u32 length) { struct dma_channel *channel = hw_ep->tx_channel; void __iomem *epio = hw_ep->regs; u16 pkt_size = qh->maxpacket; u16 csr; u8 mode; #ifdef CONFIG_USB_INVENTRA_DMA if (length > channel->max_len) length = channel->max_len; csr = musb_readw(epio, MUSB_TXCSR); if (length > pkt_size) { mode = 1; csr |= MUSB_TXCSR_DMAMODE | MUSB_TXCSR_DMAENAB; /* autoset shouldn't be set in high bandwidth */ if (qh->hb_mult == 1) csr |= MUSB_TXCSR_AUTOSET; } else { mode = 0; csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAMODE); csr |= MUSB_TXCSR_DMAENAB; /* against programmer's guide */ } channel->desired_mode = mode; musb_writew(epio, MUSB_TXCSR, csr); #else if (!is_cppi_enabled() && !tusb_dma_omap()) return false; channel->actual_len = 0; /* * TX uses "RNDIS" mode automatically but needs help * to identify the zero-length-final-packet case. */ mode = (urb->transfer_flags & URB_ZERO_PACKET) ? 1 : 0; #endif qh->segsize = length; /* * Ensure the data reaches to main memory before starting * DMA transfer */ wmb(); if (!dma->channel_program(channel, pkt_size, mode, urb->transfer_dma + offset, length)) { dma->channel_release(channel); hw_ep->tx_channel = NULL; csr = musb_readw(epio, MUSB_TXCSR); csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAENAB); musb_writew(epio, MUSB_TXCSR, csr | MUSB_TXCSR_H_WZC_BITS); return false; } return true; } /* * Program an HDRC endpoint as per the given URB * Context: irqs blocked, controller lock held */ static void musb_ep_program(struct musb *musb, u8 epnum, struct urb *urb, int is_out, u8 *buf, u32 offset, u32 len) { struct dma_controller *dma_controller; struct dma_channel *dma_channel; u8 dma_ok; void __iomem *mbase = musb->mregs; struct musb_hw_ep *hw_ep = musb->endpoints + epnum; void __iomem *epio = hw_ep->regs; struct musb_qh *qh = musb_ep_get_qh(hw_ep, !is_out); u16 packet_sz = qh->maxpacket; dev_dbg(musb->controller, "%s hw%d urb %p spd%d dev%d ep%d%s " "h_addr%02x h_port%02x bytes %d\n", is_out ? "-->" : "<--", epnum, urb, urb->dev->speed, qh->addr_reg, qh->epnum, is_out ? "out" : "in", qh->h_addr_reg, qh->h_port_reg, len); musb_ep_select(mbase, epnum); /* candidate for DMA? */ dma_controller = musb->dma_controller; if (is_dma_capable() && epnum && dma_controller) { dma_channel = is_out ? hw_ep->tx_channel : hw_ep->rx_channel; if (!dma_channel) { dma_channel = dma_controller->channel_alloc( dma_controller, hw_ep, is_out); if (is_out) hw_ep->tx_channel = dma_channel; else hw_ep->rx_channel = dma_channel; } } else dma_channel = NULL; /* make sure we clear DMAEnab, autoSet bits from previous run */ /* OUT/transmit/EP0 or IN/receive? */ if (is_out) { u16 csr; u16 int_txe; u16 load_count; csr = musb_readw(epio, MUSB_TXCSR); /* disable interrupt in case we flush */ int_txe = musb_readw(mbase, MUSB_INTRTXE); musb_writew(mbase, MUSB_INTRTXE, int_txe & ~(1 << epnum)); /* general endpoint setup */ if (epnum) { /* flush all old state, set default */ musb_h_tx_flush_fifo(hw_ep); /* * We must not clear the DMAMODE bit before or in * the same cycle with the DMAENAB bit, so we clear * the latter first... */ csr &= ~(MUSB_TXCSR_H_NAKTIMEOUT | MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAENAB | MUSB_TXCSR_FRCDATATOG | MUSB_TXCSR_H_RXSTALL | MUSB_TXCSR_H_ERROR | MUSB_TXCSR_TXPKTRDY ); csr |= MUSB_TXCSR_MODE; if (usb_gettoggle(urb->dev, qh->epnum, 1)) csr |= MUSB_TXCSR_H_WR_DATATOGGLE | MUSB_TXCSR_H_DATATOGGLE; else csr |= MUSB_TXCSR_CLRDATATOG; musb_writew(epio, MUSB_TXCSR, csr); /* REVISIT may need to clear FLUSHFIFO ... */ csr &= ~MUSB_TXCSR_DMAMODE; musb_writew(epio, MUSB_TXCSR, csr); csr = musb_readw(epio, MUSB_TXCSR); } else { /* endpoint 0: just flush */ musb_h_ep0_flush_fifo(hw_ep); } /* target addr and (for multipoint) hub addr/port */ if (musb->is_multipoint) { musb_write_txfunaddr(mbase, epnum, qh->addr_reg); musb_write_txhubaddr(mbase, epnum, qh->h_addr_reg); musb_write_txhubport(mbase, epnum, qh->h_port_reg); /* FIXME if !epnum, do the same for RX ... */ } else musb_writeb(mbase, MUSB_FADDR, qh->addr_reg); /* protocol/endpoint/interval/NAKlimit */ if (epnum) { musb_writeb(epio, MUSB_TXTYPE, qh->type_reg); if (musb->double_buffer_not_ok) musb_writew(epio, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); else if (can_bulk_split(musb, qh->type)) musb_writew(epio, MUSB_TXMAXP, packet_sz | ((hw_ep->max_packet_sz_tx / packet_sz) - 1) << 11); else musb_writew(epio, MUSB_TXMAXP, qh->maxpacket | ((qh->hb_mult - 1) << 11)); musb_writeb(epio, MUSB_TXINTERVAL, qh->intv_reg); } else { musb_writeb(epio, MUSB_NAKLIMIT0, qh->intv_reg); if (musb->is_multipoint) musb_writeb(epio, MUSB_TYPE0, qh->type_reg); } if (can_bulk_split(musb, qh->type)) load_count = min((u32) hw_ep->max_packet_sz_tx, len); else load_count = min((u32) packet_sz, len); if (dma_channel && musb_tx_dma_program(dma_controller, hw_ep, qh, urb, offset, len)) load_count = 0; if (load_count) { /* PIO to load FIFO */ qh->segsize = load_count; musb_write_fifo(hw_ep, load_count, buf); } /* re-enable interrupt */ musb_writew(mbase, MUSB_INTRTXE, int_txe); /* IN/receive */ } else { u16 csr; if (hw_ep->rx_reinit) { musb_rx_reinit(musb, qh, hw_ep); /* init new state: toggle and NYET, maybe DMA later */ if (usb_gettoggle(urb->dev, qh->epnum, 0)) csr = MUSB_RXCSR_H_WR_DATATOGGLE | MUSB_RXCSR_H_DATATOGGLE; else csr = 0; if (qh->type == USB_ENDPOINT_XFER_INT) csr |= MUSB_RXCSR_DISNYET; } else { csr = musb_readw(hw_ep->regs, MUSB_RXCSR); if (csr & (MUSB_RXCSR_RXPKTRDY | MUSB_RXCSR_DMAENAB | MUSB_RXCSR_H_REQPKT)) ERR("broken !rx_reinit, ep%d csr %04x\n", hw_ep->epnum, csr); /* scrub any stale state, leaving toggle alone */ csr &= MUSB_RXCSR_DISNYET; } /* kick things off */ if ((is_cppi_enabled() || tusb_dma_omap()) && dma_channel) { /* Candidate for DMA */ dma_channel->actual_len = 0L; qh->segsize = len; /* AUTOREQ is in a DMA register */ musb_writew(hw_ep->regs, MUSB_RXCSR, csr); csr = musb_readw(hw_ep->regs, MUSB_RXCSR); /* * Unless caller treats short RX transfers as * errors, we dare not queue multiple transfers. */ dma_ok = dma_controller->channel_program(dma_channel, packet_sz, !(urb->transfer_flags & URB_SHORT_NOT_OK), urb->transfer_dma + offset, qh->segsize); if (!dma_ok) { dma_controller->channel_release(dma_channel); hw_ep->rx_channel = dma_channel = NULL; } else csr |= MUSB_RXCSR_DMAENAB; } csr |= MUSB_RXCSR_H_REQPKT; dev_dbg(musb->controller, "RXCSR%d := %04x\n", epnum, csr); musb_writew(hw_ep->regs, MUSB_RXCSR, csr); csr = musb_readw(hw_ep->regs, MUSB_RXCSR); } } /* * Service the default endpoint (ep0) as host. * Return true until it's time to start the status stage. */ static bool musb_h_ep0_continue(struct musb *musb, u16 len, struct urb *urb) { bool more = false; u8 *fifo_dest = NULL; u16 fifo_count = 0; struct musb_hw_ep *hw_ep = musb->control_ep; struct musb_qh *qh = hw_ep->in_qh; struct usb_ctrlrequest *request; switch (musb->ep0_stage) { case MUSB_EP0_IN: fifo_dest = urb->transfer_buffer + urb->actual_length; fifo_count = min_t(size_t, len, urb->transfer_buffer_length - urb->actual_length); if (fifo_count < len) urb->status = -EOVERFLOW; musb_read_fifo(hw_ep, fifo_count, fifo_dest); urb->actual_length += fifo_count; if (len < qh->maxpacket) { /* always terminate on short read; it's * rarely reported as an error. */ } else if (urb->actual_length < urb->transfer_buffer_length) more = true; break; case MUSB_EP0_START: request = (struct usb_ctrlrequest *) urb->setup_packet; if (!request->wLength) { dev_dbg(musb->controller, "start no-DATA\n"); break; } else if (request->bRequestType & USB_DIR_IN) { dev_dbg(musb->controller, "start IN-DATA\n"); musb->ep0_stage = MUSB_EP0_IN; more = true; break; } else { dev_dbg(musb->controller, "start OUT-DATA\n"); musb->ep0_stage = MUSB_EP0_OUT; more = true; } /* FALLTHROUGH */ case MUSB_EP0_OUT: fifo_count = min_t(size_t, qh->maxpacket, urb->transfer_buffer_length - urb->actual_length); if (fifo_count) { fifo_dest = (u8 *) (urb->transfer_buffer + urb->actual_length); dev_dbg(musb->controller, "Sending %d byte%s to ep0 fifo %p\n", fifo_count, (fifo_count == 1) ? "" : "s", fifo_dest); musb_write_fifo(hw_ep, fifo_count, fifo_dest); urb->actual_length += fifo_count; more = true; } break; default: ERR("bogus ep0 stage %d\n", musb->ep0_stage); break; } return more; } /* * Handle default endpoint interrupt as host. Only called in IRQ time * from musb_interrupt(). * * called with controller irqlocked */ irqreturn_t musb_h_ep0_irq(struct musb *musb) { struct urb *urb; u16 csr, len; int status = 0; void __iomem *mbase = musb->mregs; struct musb_hw_ep *hw_ep = musb->control_ep; void __iomem *epio = hw_ep->regs; struct musb_qh *qh = hw_ep->in_qh; bool complete = false; irqreturn_t retval = IRQ_NONE; /* ep0 only has one queue, "in" */ urb = next_urb(qh); musb_ep_select(mbase, 0); csr = musb_readw(epio, MUSB_CSR0); len = (csr & MUSB_CSR0_RXPKTRDY) ? musb_readb(epio, MUSB_COUNT0) : 0; dev_dbg(musb->controller, "<== csr0 %04x, qh %p, count %d, urb %p, stage %d\n", csr, qh, len, urb, musb->ep0_stage); /* if we just did status stage, we are done */ if (MUSB_EP0_STATUS == musb->ep0_stage) { retval = IRQ_HANDLED; complete = true; } /* prepare status */ if (csr & MUSB_CSR0_H_RXSTALL) { dev_dbg(musb->controller, "STALLING ENDPOINT\n"); status = -EPIPE; } else if (csr & MUSB_CSR0_H_ERROR) { dev_dbg(musb->controller, "no response, csr0 %04x\n", csr); status = -EPROTO; } else if (csr & MUSB_CSR0_H_NAKTIMEOUT) { dev_dbg(musb->controller, "control NAK timeout\n"); /* NOTE: this code path would be a good place to PAUSE a * control transfer, if another one is queued, so that * ep0 is more likely to stay busy. That's already done * for bulk RX transfers. * * if (qh->ring.next != &musb->control), then * we have a candidate... NAKing is *NOT* an error */ musb_writew(epio, MUSB_CSR0, 0); retval = IRQ_HANDLED; } if (status) { dev_dbg(musb->controller, "aborting\n"); retval = IRQ_HANDLED; if (urb) urb->status = status; complete = true; /* use the proper sequence to abort the transfer */ if (csr & MUSB_CSR0_H_REQPKT) { csr &= ~MUSB_CSR0_H_REQPKT; musb_writew(epio, MUSB_CSR0, csr); csr &= ~MUSB_CSR0_H_NAKTIMEOUT; musb_writew(epio, MUSB_CSR0, csr); } else { musb_h_ep0_flush_fifo(hw_ep); } musb_writeb(epio, MUSB_NAKLIMIT0, 0); /* clear it */ musb_writew(epio, MUSB_CSR0, 0); } if (unlikely(!urb)) { /* stop endpoint since we have no place for its data, this * SHOULD NEVER HAPPEN! */ ERR("no URB for end 0\n"); musb_h_ep0_flush_fifo(hw_ep); goto done; } if (!complete) { /* call common logic and prepare response */ if (musb_h_ep0_continue(musb, len, urb)) { /* more packets required */ csr = (MUSB_EP0_IN == musb->ep0_stage) ? MUSB_CSR0_H_REQPKT : MUSB_CSR0_TXPKTRDY; } else { /* data transfer complete; perform status phase */ if (usb_pipeout(urb->pipe) || !urb->transfer_buffer_length) csr = MUSB_CSR0_H_STATUSPKT | MUSB_CSR0_H_REQPKT; else csr = MUSB_CSR0_H_STATUSPKT | MUSB_CSR0_TXPKTRDY; /* flag status stage */ musb->ep0_stage = MUSB_EP0_STATUS; dev_dbg(musb->controller, "ep0 STATUS, csr %04x\n", csr); } musb_writew(epio, MUSB_CSR0, csr); retval = IRQ_HANDLED; } else musb->ep0_stage = MUSB_EP0_IDLE; /* call completion handler if done */ if (complete) musb_advance_schedule(musb, urb, hw_ep, 1); done: return retval; } #ifdef CONFIG_USB_INVENTRA_DMA /* Host side TX (OUT) using Mentor DMA works as follows: submit_urb -> - if queue was empty, Program Endpoint - ... which starts DMA to fifo in mode 1 or 0 DMA Isr (transfer complete) -> TxAvail() - Stop DMA (~DmaEnab) (<--- Alert ... currently happens only in musb_cleanup_urb) - TxPktRdy has to be set in mode 0 or for short packets in mode 1. */ #endif /* Service a Tx-Available or dma completion irq for the endpoint */ void musb_host_tx(struct musb *musb, u8 epnum) { int pipe; bool done = false; u16 tx_csr; size_t length = 0; size_t offset = 0; struct musb_hw_ep *hw_ep = musb->endpoints + epnum; void __iomem *epio = hw_ep->regs; struct musb_qh *qh = hw_ep->out_qh; struct urb *urb = next_urb(qh); u32 status = 0; void __iomem *mbase = musb->mregs; struct dma_channel *dma; bool transfer_pending = false; musb_ep_select(mbase, epnum); tx_csr = musb_readw(epio, MUSB_TXCSR); /* with CPPI, DMA sometimes triggers "extra" irqs */ if (!urb) { dev_dbg(musb->controller, "extra TX%d ready, csr %04x\n", epnum, tx_csr); return; } pipe = urb->pipe; dma = is_dma_capable() ? hw_ep->tx_channel : NULL; dev_dbg(musb->controller, "OUT/TX%d end, csr %04x%s\n", epnum, tx_csr, dma ? ", dma" : ""); /* check for errors */ if (tx_csr & MUSB_TXCSR_H_RXSTALL) { /* dma was disabled, fifo flushed */ dev_dbg(musb->controller, "TX end %d stall\n", epnum); /* stall; record URB status */ status = -EPIPE; } else if (tx_csr & MUSB_TXCSR_H_ERROR) { /* (NON-ISO) dma was disabled, fifo flushed */ dev_dbg(musb->controller, "TX 3strikes on ep=%d\n", epnum); status = -ETIMEDOUT; } else if (tx_csr & MUSB_TXCSR_H_NAKTIMEOUT) { dev_dbg(musb->controller, "TX end=%d device not responding\n", epnum); /* NOTE: this code path would be a good place to PAUSE a * transfer, if there's some other (nonperiodic) tx urb * that could use this fifo. (dma complicates it...) * That's already done for bulk RX transfers. * * if (bulk && qh->ring.next != &musb->out_bulk), then * we have a candidate... NAKing is *NOT* an error */ musb_ep_select(mbase, epnum); musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_H_WZC_BITS | MUSB_TXCSR_TXPKTRDY); return; } if (status) { if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { dma->status = MUSB_DMA_STATUS_CORE_ABORT; (void) musb->dma_controller->channel_abort(dma); } /* do the proper sequence to abort the transfer in the * usb core; the dma engine should already be stopped. */ musb_h_tx_flush_fifo(hw_ep); tx_csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAENAB | MUSB_TXCSR_H_ERROR | MUSB_TXCSR_H_RXSTALL | MUSB_TXCSR_H_NAKTIMEOUT ); musb_ep_select(mbase, epnum); musb_writew(epio, MUSB_TXCSR, tx_csr); /* REVISIT may need to clear FLUSHFIFO ... */ musb_writew(epio, MUSB_TXCSR, tx_csr); musb_writeb(epio, MUSB_TXINTERVAL, 0); done = true; } /* second cppi case */ if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { dev_dbg(musb->controller, "extra TX%d ready, csr %04x\n", epnum, tx_csr); return; } if (is_dma_capable() && dma && !status) { /* * DMA has completed. But if we're using DMA mode 1 (multi * packet DMA), we need a terminal TXPKTRDY interrupt before * we can consider this transfer completed, lest we trash * its last packet when writing the next URB's data. So we * switch back to mode 0 to get that interrupt; we'll come * back here once it happens. */ if (tx_csr & MUSB_TXCSR_DMAMODE) { /* * We shouldn't clear DMAMODE with DMAENAB set; so * clear them in a safe order. That should be OK * once TXPKTRDY has been set (and I've never seen * it being 0 at this moment -- DMA interrupt latency * is significant) but if it hasn't been then we have * no choice but to stop being polite and ignore the * programmer's guide... :-) * * Note that we must write TXCSR with TXPKTRDY cleared * in order not to re-trigger the packet send (this bit * can't be cleared by CPU), and there's another caveat: * TXPKTRDY may be set shortly and then cleared in the * double-buffered FIFO mode, so we do an extra TXCSR * read for debouncing... */ tx_csr &= musb_readw(epio, MUSB_TXCSR); if (tx_csr & MUSB_TXCSR_TXPKTRDY) { tx_csr &= ~(MUSB_TXCSR_DMAENAB | MUSB_TXCSR_TXPKTRDY); musb_writew(epio, MUSB_TXCSR, tx_csr | MUSB_TXCSR_H_WZC_BITS); } tx_csr &= ~(MUSB_TXCSR_DMAMODE | MUSB_TXCSR_TXPKTRDY); musb_writew(epio, MUSB_TXCSR, tx_csr | MUSB_TXCSR_H_WZC_BITS); /* * There is no guarantee that we'll get an interrupt * after clearing DMAMODE as we might have done this * too late (after TXPKTRDY was cleared by controller). * Re-read TXCSR as we have spoiled its previous value. */ tx_csr = musb_readw(epio, MUSB_TXCSR); } /* * We may get here from a DMA completion or TXPKTRDY interrupt. * In any case, we must check the FIFO status here and bail out * only if the FIFO still has data -- that should prevent the * "missed" TXPKTRDY interrupts and deal with double-buffered * FIFO mode too... */ if (tx_csr & (MUSB_TXCSR_FIFONOTEMPTY | MUSB_TXCSR_TXPKTRDY)) { dev_dbg(musb->controller, "DMA complete but packet still in FIFO, " "CSR %04x\n", tx_csr); return; } } if (!status || dma || usb_pipeisoc(pipe)) { if (dma) length = dma->actual_len; else length = qh->segsize; qh->offset += length; if (usb_pipeisoc(pipe)) { #ifndef __UBOOT__ struct usb_iso_packet_descriptor *d; d = urb->iso_frame_desc + qh->iso_idx; d->actual_length = length; d->status = status; if (++qh->iso_idx >= urb->number_of_packets) { done = true; } else { d++; offset = d->offset; length = d->length; } #endif } else if (dma && urb->transfer_buffer_length == qh->offset) { done = true; } else { /* see if we need to send more data, or ZLP */ if (qh->segsize < qh->maxpacket) done = true; else if (qh->offset == urb->transfer_buffer_length && !(urb->transfer_flags & URB_ZERO_PACKET)) done = true; if (!done) { offset = qh->offset; length = urb->transfer_buffer_length - offset; transfer_pending = true; } } } /* urb->status != -EINPROGRESS means request has been faulted, * so we must abort this transfer after cleanup */ if (urb->status != -EINPROGRESS) { done = true; if (status == 0) status = urb->status; } if (done) { /* set status */ urb->status = status; urb->actual_length = qh->offset; musb_advance_schedule(musb, urb, hw_ep, USB_DIR_OUT); return; } else if ((usb_pipeisoc(pipe) || transfer_pending) && dma) { if (musb_tx_dma_program(musb->dma_controller, hw_ep, qh, urb, offset, length)) { if (is_cppi_enabled() || tusb_dma_omap()) musb_h_tx_dma_start(hw_ep); return; } } else if (tx_csr & MUSB_TXCSR_DMAENAB) { dev_dbg(musb->controller, "not complete, but DMA enabled?\n"); return; } /* * PIO: start next packet in this URB. * * REVISIT: some docs say that when hw_ep->tx_double_buffered, * (and presumably, FIFO is not half-full) we should write *two* * packets before updating TXCSR; other docs disagree... */ if (length > qh->maxpacket) length = qh->maxpacket; /* Unmap the buffer so that CPU can use it */ usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); musb_write_fifo(hw_ep, length, urb->transfer_buffer + offset); qh->segsize = length; musb_ep_select(mbase, epnum); musb_writew(epio, MUSB_TXCSR, MUSB_TXCSR_H_WZC_BITS | MUSB_TXCSR_TXPKTRDY); } #ifdef CONFIG_USB_INVENTRA_DMA /* Host side RX (IN) using Mentor DMA works as follows: submit_urb -> - if queue was empty, ProgramEndpoint - first IN token is sent out (by setting ReqPkt) LinuxIsr -> RxReady() /\ => first packet is received | - Set in mode 0 (DmaEnab, ~ReqPkt) | -> DMA Isr (transfer complete) -> RxReady() | - Ack receive (~RxPktRdy), turn off DMA (~DmaEnab) | - if urb not complete, send next IN token (ReqPkt) | | else complete urb. | | --------------------------- * * Nuances of mode 1: * For short packets, no ack (+RxPktRdy) is sent automatically * (even if AutoClear is ON) * For full packets, ack (~RxPktRdy) and next IN token (+ReqPkt) is sent * automatically => major problem, as collecting the next packet becomes * difficult. Hence mode 1 is not used. * * REVISIT * All we care about at this driver level is that * (a) all URBs terminate with REQPKT cleared and fifo(s) empty; * (b) termination conditions are: short RX, or buffer full; * (c) fault modes include * - iff URB_SHORT_NOT_OK, short RX status is -EREMOTEIO. * (and that endpoint's dma queue stops immediately) * - overflow (full, PLUS more bytes in the terminal packet) * * So for example, usb-storage sets URB_SHORT_NOT_OK, and would * thus be a great candidate for using mode 1 ... for all but the * last packet of one URB's transfer. */ #endif /* Schedule next QH from musb->in_bulk and move the current qh to * the end; avoids starvation for other endpoints. */ static void musb_bulk_rx_nak_timeout(struct musb *musb, struct musb_hw_ep *ep) { struct dma_channel *dma; struct urb *urb; void __iomem *mbase = musb->mregs; void __iomem *epio = ep->regs; struct musb_qh *cur_qh, *next_qh; u16 rx_csr; musb_ep_select(mbase, ep->epnum); dma = is_dma_capable() ? ep->rx_channel : NULL; /* clear nak timeout bit */ rx_csr = musb_readw(epio, MUSB_RXCSR); rx_csr |= MUSB_RXCSR_H_WZC_BITS; rx_csr &= ~MUSB_RXCSR_DATAERROR; musb_writew(epio, MUSB_RXCSR, rx_csr); cur_qh = first_qh(&musb->in_bulk); if (cur_qh) { urb = next_urb(cur_qh); if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { dma->status = MUSB_DMA_STATUS_CORE_ABORT; musb->dma_controller->channel_abort(dma); urb->actual_length += dma->actual_len; dma->actual_len = 0L; } musb_save_toggle(cur_qh, 1, urb); /* move cur_qh to end of queue */ list_move_tail(&cur_qh->ring, &musb->in_bulk); /* get the next qh from musb->in_bulk */ next_qh = first_qh(&musb->in_bulk); /* set rx_reinit and schedule the next qh */ ep->rx_reinit = 1; musb_start_urb(musb, 1, next_qh); } } /* * Service an RX interrupt for the given IN endpoint; docs cover bulk, iso, * and high-bandwidth IN transfer cases. */ void musb_host_rx(struct musb *musb, u8 epnum) { struct urb *urb; struct musb_hw_ep *hw_ep = musb->endpoints + epnum; void __iomem *epio = hw_ep->regs; struct musb_qh *qh = hw_ep->in_qh; size_t xfer_len; void __iomem *mbase = musb->mregs; int pipe; u16 rx_csr, val; bool iso_err = false; bool done = false; u32 status; struct dma_channel *dma; musb_ep_select(mbase, epnum); urb = next_urb(qh); dma = is_dma_capable() ? hw_ep->rx_channel : NULL; status = 0; xfer_len = 0; rx_csr = musb_readw(epio, MUSB_RXCSR); val = rx_csr; if (unlikely(!urb)) { /* REVISIT -- THIS SHOULD NEVER HAPPEN ... but, at least * usbtest #11 (unlinks) triggers it regularly, sometimes * with fifo full. (Only with DMA??) */ dev_dbg(musb->controller, "BOGUS RX%d ready, csr %04x, count %d\n", epnum, val, musb_readw(epio, MUSB_RXCOUNT)); musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG); return; } pipe = urb->pipe; dev_dbg(musb->controller, "<== hw %d rxcsr %04x, urb actual %d (+dma %zu)\n", epnum, rx_csr, urb->actual_length, dma ? dma->actual_len : 0); /* check for errors, concurrent stall & unlink is not really * handled yet! */ if (rx_csr & MUSB_RXCSR_H_RXSTALL) { dev_dbg(musb->controller, "RX end %d STALL\n", epnum); /* stall; record URB status */ status = -EPIPE; } else if (rx_csr & MUSB_RXCSR_H_ERROR) { dev_dbg(musb->controller, "end %d RX proto error\n", epnum); status = -EPROTO; musb_writeb(epio, MUSB_RXINTERVAL, 0); } else if (rx_csr & MUSB_RXCSR_DATAERROR) { if (USB_ENDPOINT_XFER_ISOC != qh->type) { dev_dbg(musb->controller, "RX end %d NAK timeout\n", epnum); /* NOTE: NAKing is *NOT* an error, so we want to * continue. Except ... if there's a request for * another QH, use that instead of starving it. * * Devices like Ethernet and serial adapters keep * reads posted at all times, which will starve * other devices without this logic. */ if (usb_pipebulk(urb->pipe) && qh->mux == 1 && !list_is_singular(&musb->in_bulk)) { musb_bulk_rx_nak_timeout(musb, hw_ep); return; } musb_ep_select(mbase, epnum); rx_csr |= MUSB_RXCSR_H_WZC_BITS; rx_csr &= ~MUSB_RXCSR_DATAERROR; musb_writew(epio, MUSB_RXCSR, rx_csr); goto finish; } else { dev_dbg(musb->controller, "RX end %d ISO data error\n", epnum); /* packet error reported later */ iso_err = true; } } else if (rx_csr & MUSB_RXCSR_INCOMPRX) { dev_dbg(musb->controller, "end %d high bandwidth incomplete ISO packet RX\n", epnum); status = -EPROTO; } /* faults abort the transfer */ if (status) { /* clean up dma and collect transfer count */ if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { dma->status = MUSB_DMA_STATUS_CORE_ABORT; (void) musb->dma_controller->channel_abort(dma); xfer_len = dma->actual_len; } musb_h_flush_rxfifo(hw_ep, MUSB_RXCSR_CLRDATATOG); musb_writeb(epio, MUSB_RXINTERVAL, 0); done = true; goto finish; } if (unlikely(dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY)) { /* SHOULD NEVER HAPPEN ... but at least DaVinci has done it */ ERR("RX%d dma busy, csr %04x\n", epnum, rx_csr); goto finish; } /* thorough shutdown for now ... given more precise fault handling * and better queueing support, we might keep a DMA pipeline going * while processing this irq for earlier completions. */ /* FIXME this is _way_ too much in-line logic for Mentor DMA */ #ifndef CONFIG_USB_INVENTRA_DMA if (rx_csr & MUSB_RXCSR_H_REQPKT) { /* REVISIT this happened for a while on some short reads... * the cleanup still needs investigation... looks bad... * and also duplicates dma cleanup code above ... plus, * shouldn't this be the "half full" double buffer case? */ if (dma_channel_status(dma) == MUSB_DMA_STATUS_BUSY) { dma->status = MUSB_DMA_STATUS_CORE_ABORT; (void) musb->dma_controller->channel_abort(dma); xfer_len = dma->actual_len; done = true; } dev_dbg(musb->controller, "RXCSR%d %04x, reqpkt, len %zu%s\n", epnum, rx_csr, xfer_len, dma ? ", dma" : ""); rx_csr &= ~MUSB_RXCSR_H_REQPKT; musb_ep_select(mbase, epnum); musb_writew(epio, MUSB_RXCSR, MUSB_RXCSR_H_WZC_BITS | rx_csr); } #endif if (dma && (rx_csr & MUSB_RXCSR_DMAENAB)) { xfer_len = dma->actual_len; val &= ~(MUSB_RXCSR_DMAENAB | MUSB_RXCSR_H_AUTOREQ | MUSB_RXCSR_AUTOCLEAR | MUSB_RXCSR_RXPKTRDY); musb_writew(hw_ep->regs, MUSB_RXCSR, val); #ifdef CONFIG_USB_INVENTRA_DMA if (usb_pipeisoc(pipe)) { struct usb_iso_packet_descriptor *d; d = urb->iso_frame_desc + qh->iso_idx; d->actual_length = xfer_len; /* even if there was an error, we did the dma * for iso_frame_desc->length */ if (d->status != -EILSEQ && d->status != -EOVERFLOW) d->status = 0; if (++qh->iso_idx >= urb->number_of_packets) done = true; else done = false; } else { /* done if urb buffer is full or short packet is recd */ done = (urb->actual_length + xfer_len >= urb->transfer_buffer_length || dma->actual_len < qh->maxpacket); } /* send IN token for next packet, without AUTOREQ */ if (!done) { val |= MUSB_RXCSR_H_REQPKT; musb_writew(epio, MUSB_RXCSR, MUSB_RXCSR_H_WZC_BITS | val); } dev_dbg(musb->controller, "ep %d dma %s, rxcsr %04x, rxcount %d\n", epnum, done ? "off" : "reset", musb_readw(epio, MUSB_RXCSR), musb_readw(epio, MUSB_RXCOUNT)); #else done = true; #endif } else if (urb->status == -EINPROGRESS) { /* if no errors, be sure a packet is ready for unloading */ if (unlikely(!(rx_csr & MUSB_RXCSR_RXPKTRDY))) { status = -EPROTO; ERR("Rx interrupt with no errors or packet!\n"); /* FIXME this is another "SHOULD NEVER HAPPEN" */ /* SCRUB (RX) */ /* do the proper sequence to abort the transfer */ musb_ep_select(mbase, epnum); val &= ~MUSB_RXCSR_H_REQPKT; musb_writew(epio, MUSB_RXCSR, val); goto finish; } /* we are expecting IN packets */ #ifdef CONFIG_USB_INVENTRA_DMA if (dma) { struct dma_controller *c; u16 rx_count; int ret, length; dma_addr_t buf; rx_count = musb_readw(epio, MUSB_RXCOUNT); dev_dbg(musb->controller, "RX%d count %d, buffer 0x%x len %d/%d\n", epnum, rx_count, urb->transfer_dma + urb->actual_length, qh->offset, urb->transfer_buffer_length); c = musb->dma_controller; if (usb_pipeisoc(pipe)) { int d_status = 0; struct usb_iso_packet_descriptor *d; d = urb->iso_frame_desc + qh->iso_idx; if (iso_err) { d_status = -EILSEQ; urb->error_count++; } if (rx_count > d->length) { if (d_status == 0) { d_status = -EOVERFLOW; urb->error_count++; } dev_dbg(musb->controller, "** OVERFLOW %d into %d\n",\ rx_count, d->length); length = d->length; } else length = rx_count; d->status = d_status; buf = urb->transfer_dma + d->offset; } else { length = rx_count; buf = urb->transfer_dma + urb->actual_length; } dma->desired_mode = 0; #ifdef USE_MODE1 /* because of the issue below, mode 1 will * only rarely behave with correct semantics. */ if ((urb->transfer_flags & URB_SHORT_NOT_OK) && (urb->transfer_buffer_length - urb->actual_length) > qh->maxpacket) dma->desired_mode = 1; if (rx_count < hw_ep->max_packet_sz_rx) { length = rx_count; dma->desired_mode = 0; } else { length = urb->transfer_buffer_length; } #endif /* Disadvantage of using mode 1: * It's basically usable only for mass storage class; essentially all * other protocols also terminate transfers on short packets. * * Details: * An extra IN token is sent at the end of the transfer (due to AUTOREQ) * If you try to use mode 1 for (transfer_buffer_length - 512), and try * to use the extra IN token to grab the last packet using mode 0, then * the problem is that you cannot be sure when the device will send the * last packet and RxPktRdy set. Sometimes the packet is recd too soon * such that it gets lost when RxCSR is re-set at the end of the mode 1 * transfer, while sometimes it is recd just a little late so that if you * try to configure for mode 0 soon after the mode 1 transfer is * completed, you will find rxcount 0. Okay, so you might think why not * wait for an interrupt when the pkt is recd. Well, you won't get any! */ val = musb_readw(epio, MUSB_RXCSR); val &= ~MUSB_RXCSR_H_REQPKT; if (dma->desired_mode == 0) val &= ~MUSB_RXCSR_H_AUTOREQ; else val |= MUSB_RXCSR_H_AUTOREQ; val |= MUSB_RXCSR_DMAENAB; /* autoclear shouldn't be set in high bandwidth */ if (qh->hb_mult == 1) val |= MUSB_RXCSR_AUTOCLEAR; musb_writew(epio, MUSB_RXCSR, MUSB_RXCSR_H_WZC_BITS | val); /* REVISIT if when actual_length != 0, * transfer_buffer_length needs to be * adjusted first... */ ret = c->channel_program( dma, qh->maxpacket, dma->desired_mode, buf, length); if (!ret) { c->channel_release(dma); hw_ep->rx_channel = NULL; dma = NULL; val = musb_readw(epio, MUSB_RXCSR); val &= ~(MUSB_RXCSR_DMAENAB | MUSB_RXCSR_H_AUTOREQ | MUSB_RXCSR_AUTOCLEAR); musb_writew(epio, MUSB_RXCSR, val); } } #endif /* Mentor DMA */ if (!dma) { /* Unmap the buffer so that CPU can use it */ usb_hcd_unmap_urb_for_dma(musb_to_hcd(musb), urb); done = musb_host_packet_rx(musb, urb, epnum, iso_err); dev_dbg(musb->controller, "read %spacket\n", done ? "last " : ""); } } finish: urb->actual_length += xfer_len; qh->offset += xfer_len; if (done) { if (urb->status == -EINPROGRESS) urb->status = status; musb_advance_schedule(musb, urb, hw_ep, USB_DIR_IN); } } /* schedule nodes correspond to peripheral endpoints, like an OHCI QH. * the software schedule associates multiple such nodes with a given * host side hardware endpoint + direction; scheduling may activate * that hardware endpoint. */ static int musb_schedule( struct musb *musb, struct musb_qh *qh, int is_in) { int idle; int best_diff; int best_end, epnum; struct musb_hw_ep *hw_ep = NULL; struct list_head *head = NULL; u8 toggle; u8 txtype; struct urb *urb = next_urb(qh); /* use fixed hardware for control and bulk */ if (qh->type == USB_ENDPOINT_XFER_CONTROL) { head = &musb->control; hw_ep = musb->control_ep; goto success; } /* else, periodic transfers get muxed to other endpoints */ /* * We know this qh hasn't been scheduled, so all we need to do * is choose which hardware endpoint to put it on ... * * REVISIT what we really want here is a regular schedule tree * like e.g. OHCI uses. */ best_diff = 4096; best_end = -1; for (epnum = 1, hw_ep = musb->endpoints + 1; epnum < musb->nr_endpoints; epnum++, hw_ep++) { int diff; if (musb_ep_get_qh(hw_ep, is_in) != NULL) continue; if (hw_ep == musb->bulk_ep) continue; if (is_in) diff = hw_ep->max_packet_sz_rx; else diff = hw_ep->max_packet_sz_tx; diff -= (qh->maxpacket * qh->hb_mult); if (diff >= 0 && best_diff > diff) { /* * Mentor controller has a bug in that if we schedule * a BULK Tx transfer on an endpoint that had earlier * handled ISOC then the BULK transfer has to start on * a zero toggle. If the BULK transfer starts on a 1 * toggle then this transfer will fail as the mentor * controller starts the Bulk transfer on a 0 toggle * irrespective of the programming of the toggle bits * in the TXCSR register. Check for this condition * while allocating the EP for a Tx Bulk transfer. If * so skip this EP. */ hw_ep = musb->endpoints + epnum; toggle = usb_gettoggle(urb->dev, qh->epnum, !is_in); txtype = (musb_readb(hw_ep->regs, MUSB_TXTYPE) >> 4) & 0x3; if (!is_in && (qh->type == USB_ENDPOINT_XFER_BULK) && toggle && (txtype == USB_ENDPOINT_XFER_ISOC)) continue; best_diff = diff; best_end = epnum; } } /* use bulk reserved ep1 if no other ep is free */ if (best_end < 0 && qh->type == USB_ENDPOINT_XFER_BULK) { hw_ep = musb->bulk_ep; if (is_in) head = &musb->in_bulk; else head = &musb->out_bulk; /* Enable bulk RX NAK timeout scheme when bulk requests are * multiplexed. This scheme doen't work in high speed to full * speed scenario as NAK interrupts are not coming from a * full speed device connected to a high speed device. * NAK timeout interval is 8 (128 uframe or 16ms) for HS and * 4 (8 frame or 8ms) for FS device. */ if (is_in && qh->dev) qh->intv_reg = (USB_SPEED_HIGH == qh->dev->speed) ? 8 : 4; goto success; } else if (best_end < 0) { return -ENOSPC; } idle = 1; qh->mux = 0; hw_ep = musb->endpoints + best_end; dev_dbg(musb->controller, "qh %p periodic slot %d\n", qh, best_end); success: if (head) { idle = list_empty(head); list_add_tail(&qh->ring, head); qh->mux = 1; } qh->hw_ep = hw_ep; qh->hep->hcpriv = qh; if (idle) musb_start_urb(musb, is_in, qh); return 0; } #ifdef __UBOOT__ /* check if transaction translator is needed for device */ static int tt_needed(struct musb *musb, struct usb_device *dev) { if ((musb_readb(musb->mregs, MUSB_POWER) & MUSB_POWER_HSMODE) && (dev->speed < USB_SPEED_HIGH)) return 1; return 0; } #endif #ifndef __UBOOT__ static int musb_urb_enqueue( #else int musb_urb_enqueue( #endif struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flags) { unsigned long flags; struct musb *musb = hcd_to_musb(hcd); struct usb_host_endpoint *hep = urb->ep; struct musb_qh *qh; struct usb_endpoint_descriptor *epd = &hep->desc; int ret; unsigned type_reg; unsigned interval; /* host role must be active */ if (!is_host_active(musb) || !musb->is_active) return -ENODEV; spin_lock_irqsave(&musb->lock, flags); ret = usb_hcd_link_urb_to_ep(hcd, urb); qh = ret ? NULL : hep->hcpriv; if (qh) urb->hcpriv = qh; spin_unlock_irqrestore(&musb->lock, flags); /* DMA mapping was already done, if needed, and this urb is on * hep->urb_list now ... so we're done, unless hep wasn't yet * scheduled onto a live qh. * * REVISIT best to keep hep->hcpriv valid until the endpoint gets * disabled, testing for empty qh->ring and avoiding qh setup costs * except for the first urb queued after a config change. */ if (qh || ret) return ret; /* Allocate and initialize qh, minimizing the work done each time * hw_ep gets reprogrammed, or with irqs blocked. Then schedule it. * * REVISIT consider a dedicated qh kmem_cache, so it's harder * for bugs in other kernel code to break this driver... */ qh = kzalloc(sizeof *qh, mem_flags); if (!qh) { spin_lock_irqsave(&musb->lock, flags); usb_hcd_unlink_urb_from_ep(hcd, urb); spin_unlock_irqrestore(&musb->lock, flags); return -ENOMEM; } qh->hep = hep; qh->dev = urb->dev; INIT_LIST_HEAD(&qh->ring); qh->is_ready = 1; qh->maxpacket = usb_endpoint_maxp(epd); qh->type = usb_endpoint_type(epd); /* Bits 11 & 12 of wMaxPacketSize encode high bandwidth multiplier. * Some musb cores don't support high bandwidth ISO transfers; and * we don't (yet!) support high bandwidth interrupt transfers. */ qh->hb_mult = 1 + ((qh->maxpacket >> 11) & 0x03); if (qh->hb_mult > 1) { int ok = (qh->type == USB_ENDPOINT_XFER_ISOC); if (ok) ok = (usb_pipein(urb->pipe) && musb->hb_iso_rx) || (usb_pipeout(urb->pipe) && musb->hb_iso_tx); if (!ok) { ret = -EMSGSIZE; goto done; } qh->maxpacket &= 0x7ff; } qh->epnum = usb_endpoint_num(epd); /* NOTE: urb->dev->devnum is wrong during SET_ADDRESS */ qh->addr_reg = (u8) usb_pipedevice(urb->pipe); /* precompute rxtype/txtype/type0 register */ type_reg = (qh->type << 4) | qh->epnum; switch (urb->dev->speed) { case USB_SPEED_LOW: type_reg |= 0xc0; break; case USB_SPEED_FULL: type_reg |= 0x80; break; default: type_reg |= 0x40; } qh->type_reg = type_reg; /* Precompute RXINTERVAL/TXINTERVAL register */ switch (qh->type) { case USB_ENDPOINT_XFER_INT: /* * Full/low speeds use the linear encoding, * high speed uses the logarithmic encoding. */ if (urb->dev->speed <= USB_SPEED_FULL) { interval = max_t(u8, epd->bInterval, 1); break; } /* FALLTHROUGH */ case USB_ENDPOINT_XFER_ISOC: /* ISO always uses logarithmic encoding */ interval = min_t(u8, epd->bInterval, 16); break; default: /* REVISIT we actually want to use NAK limits, hinting to the * transfer scheduling logic to try some other qh, e.g. try * for 2 msec first: * * interval = (USB_SPEED_HIGH == urb->dev->speed) ? 16 : 2; * * The downside of disabling this is that transfer scheduling * gets VERY unfair for nonperiodic transfers; a misbehaving * peripheral could make that hurt. That's perfectly normal * for reads from network or serial adapters ... so we have * partial NAKlimit support for bulk RX. * * The upside of disabling it is simpler transfer scheduling. */ interval = 0; } qh->intv_reg = interval; /* precompute addressing for external hub/tt ports */ if (musb->is_multipoint) { struct usb_device *parent = urb->dev->parent; #ifndef __UBOOT__ if (parent != hcd->self.root_hub) { #else if (parent) { #endif qh->h_addr_reg = (u8) parent->devnum; #ifndef __UBOOT__ /* set up tt info if needed */ if (urb->dev->tt) { qh->h_port_reg = (u8) urb->dev->ttport; if (urb->dev->tt->hub) qh->h_addr_reg = (u8) urb->dev->tt->hub->devnum; if (urb->dev->tt->multi) qh->h_addr_reg |= 0x80; } #else if (tt_needed(musb, urb->dev)) { u16 hub_port = find_tt(urb->dev); qh->h_addr_reg = (u8) (hub_port >> 8); qh->h_port_reg = (u8) (hub_port & 0xff); } #endif } } /* invariant: hep->hcpriv is null OR the qh that's already scheduled. * until we get real dma queues (with an entry for each urb/buffer), * we only have work to do in the former case. */ spin_lock_irqsave(&musb->lock, flags); if (hep->hcpriv) { /* some concurrent activity submitted another urb to hep... * odd, rare, error prone, but legal. */ kfree(qh); qh = NULL; ret = 0; } else ret = musb_schedule(musb, qh, epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK); if (ret == 0) { urb->hcpriv = qh; /* FIXME set urb->start_frame for iso/intr, it's tested in * musb_start_urb(), but otherwise only konicawc cares ... */ } spin_unlock_irqrestore(&musb->lock, flags); done: if (ret != 0) { spin_lock_irqsave(&musb->lock, flags); usb_hcd_unlink_urb_from_ep(hcd, urb); spin_unlock_irqrestore(&musb->lock, flags); kfree(qh); } return ret; } #ifndef __UBOOT__ /* * abort a transfer that's at the head of a hardware queue. * called with controller locked, irqs blocked * that hardware queue advances to the next transfer, unless prevented */ static int musb_cleanup_urb(struct urb *urb, struct musb_qh *qh) { struct musb_hw_ep *ep = qh->hw_ep; struct musb *musb = ep->musb; void __iomem *epio = ep->regs; unsigned hw_end = ep->epnum; void __iomem *regs = ep->musb->mregs; int is_in = usb_pipein(urb->pipe); int status = 0; u16 csr; musb_ep_select(regs, hw_end); if (is_dma_capable()) { struct dma_channel *dma; dma = is_in ? ep->rx_channel : ep->tx_channel; if (dma) { status = ep->musb->dma_controller->channel_abort(dma); dev_dbg(musb->controller, "abort %cX%d DMA for urb %p --> %d\n", is_in ? 'R' : 'T', ep->epnum, urb, status); urb->actual_length += dma->actual_len; } } /* turn off DMA requests, discard state, stop polling ... */ if (ep->epnum && is_in) { /* giveback saves bulk toggle */ csr = musb_h_flush_rxfifo(ep, 0); /* REVISIT we still get an irq; should likely clear the * endpoint's irq status here to avoid bogus irqs. * clearing that status is platform-specific... */ } else if (ep->epnum) { musb_h_tx_flush_fifo(ep); csr = musb_readw(epio, MUSB_TXCSR); csr &= ~(MUSB_TXCSR_AUTOSET | MUSB_TXCSR_DMAENAB | MUSB_TXCSR_H_RXSTALL | MUSB_TXCSR_H_NAKTIMEOUT | MUSB_TXCSR_H_ERROR | MUSB_TXCSR_TXPKTRDY); musb_writew(epio, MUSB_TXCSR, csr); /* REVISIT may need to clear FLUSHFIFO ... */ musb_writew(epio, MUSB_TXCSR, csr); /* flush cpu writebuffer */ csr = musb_readw(epio, MUSB_TXCSR); } else { musb_h_ep0_flush_fifo(ep); } if (status == 0) musb_advance_schedule(ep->musb, urb, ep, is_in); return status; } static int musb_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status) { struct musb *musb = hcd_to_musb(hcd); struct musb_qh *qh; unsigned long flags; int is_in = usb_pipein(urb->pipe); int ret; dev_dbg(musb->controller, "urb=%p, dev%d ep%d%s\n", urb, usb_pipedevice(urb->pipe), usb_pipeendpoint(urb->pipe), is_in ? "in" : "out"); spin_lock_irqsave(&musb->lock, flags); ret = usb_hcd_check_unlink_urb(hcd, urb, status); if (ret) goto done; qh = urb->hcpriv; if (!qh) goto done; /* * Any URB not actively programmed into endpoint hardware can be * immediately given back; that's any URB not at the head of an * endpoint queue, unless someday we get real DMA queues. And even * if it's at the head, it might not be known to the hardware... * * Otherwise abort current transfer, pending DMA, etc.; urb->status * has already been updated. This is a synchronous abort; it'd be * OK to hold off until after some IRQ, though. * * NOTE: qh is invalid unless !list_empty(&hep->urb_list) */ if (!qh->is_ready || urb->urb_list.prev != &qh->hep->urb_list || musb_ep_get_qh(qh->hw_ep, is_in) != qh) { int ready = qh->is_ready; qh->is_ready = 0; musb_giveback(musb, urb, 0); qh->is_ready = ready; /* If nothing else (usually musb_giveback) is using it * and its URB list has emptied, recycle this qh. */ if (ready && list_empty(&qh->hep->urb_list)) { qh->hep->hcpriv = NULL; list_del(&qh->ring); kfree(qh); } } else ret = musb_cleanup_urb(urb, qh); done: spin_unlock_irqrestore(&musb->lock, flags); return ret; } /* disable an endpoint */ static void musb_h_disable(struct usb_hcd *hcd, struct usb_host_endpoint *hep) { u8 is_in = hep->desc.bEndpointAddress & USB_DIR_IN; unsigned long flags; struct musb *musb = hcd_to_musb(hcd); struct musb_qh *qh; struct urb *urb; spin_lock_irqsave(&musb->lock, flags); qh = hep->hcpriv; if (qh == NULL) goto exit; /* NOTE: qh is invalid unless !list_empty(&hep->urb_list) */ /* Kick the first URB off the hardware, if needed */ qh->is_ready = 0; if (musb_ep_get_qh(qh->hw_ep, is_in) == qh) { urb = next_urb(qh); /* make software (then hardware) stop ASAP */ if (!urb->unlinked) urb->status = -ESHUTDOWN; /* cleanup */ musb_cleanup_urb(urb, qh); /* Then nuke all the others ... and advance the * queue on hw_ep (e.g. bulk ring) when we're done. */ while (!list_empty(&hep->urb_list)) { urb = next_urb(qh); urb->status = -ESHUTDOWN; musb_advance_schedule(musb, urb, qh->hw_ep, is_in); } } else { /* Just empty the queue; the hardware is busy with * other transfers, and since !qh->is_ready nothing * will activate any of these as it advances. */ while (!list_empty(&hep->urb_list)) musb_giveback(musb, next_urb(qh), -ESHUTDOWN); hep->hcpriv = NULL; list_del(&qh->ring); kfree(qh); } exit: spin_unlock_irqrestore(&musb->lock, flags); } static int musb_h_get_frame_number(struct usb_hcd *hcd) { struct musb *musb = hcd_to_musb(hcd); return musb_readw(musb->mregs, MUSB_FRAME); } static int musb_h_start(struct usb_hcd *hcd) { struct musb *musb = hcd_to_musb(hcd); /* NOTE: musb_start() is called when the hub driver turns * on port power, or when (OTG) peripheral starts. */ hcd->state = HC_STATE_RUNNING; musb->port1_status = 0; return 0; } static void musb_h_stop(struct usb_hcd *hcd) { musb_stop(hcd_to_musb(hcd)); hcd->state = HC_STATE_HALT; } static int musb_bus_suspend(struct usb_hcd *hcd) { struct musb *musb = hcd_to_musb(hcd); u8 devctl; if (!is_host_active(musb)) return 0; switch (musb->xceiv->state) { case OTG_STATE_A_SUSPEND: return 0; case OTG_STATE_A_WAIT_VRISE: /* ID could be grounded even if there's no device * on the other end of the cable. NOTE that the * A_WAIT_VRISE timers are messy with MUSB... */ devctl = musb_readb(musb->mregs, MUSB_DEVCTL); if ((devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) musb->xceiv->state = OTG_STATE_A_WAIT_BCON; break; default: break; } if (musb->is_active) { WARNING("trying to suspend as %s while active\n", otg_state_string(musb->xceiv->state)); return -EBUSY; } else return 0; } static int musb_bus_resume(struct usb_hcd *hcd) { /* resuming child port does the work */ return 0; } const struct hc_driver musb_hc_driver = { .description = "musb-hcd", .product_desc = "MUSB HDRC host driver", .hcd_priv_size = sizeof(struct musb), .flags = HCD_USB2 | HCD_MEMORY, /* not using irq handler or reset hooks from usbcore, since * those must be shared with peripheral code for OTG configs */ .start = musb_h_start, .stop = musb_h_stop, .get_frame_number = musb_h_get_frame_number, .urb_enqueue = musb_urb_enqueue, .urb_dequeue = musb_urb_dequeue, .endpoint_disable = musb_h_disable, .hub_status_data = musb_hub_status_data, .hub_control = musb_hub_control, .bus_suspend = musb_bus_suspend, .bus_resume = musb_bus_resume, /* .start_port_reset = NULL, */ /* .hub_irq_enable = NULL, */ }; #endif
99798d068fc634a86ab98702a835dd1f3eb64a59
e65a4dbfbfb0e54e59787ba7741efee12f7687f3
/editors/biew/files/patch-biewlib_sysdep_____os__dep.h
5d1a0b83e4d1e6eac3bcb9fee1a3e9a4fa974119
[ "BSD-2-Clause" ]
permissive
freebsd/freebsd-ports
86f2e89d43913412c4f6b2be3e255bc0945eac12
605a2983f245ac63f5420e023e7dce56898ad801
refs/heads/main
2023-08-30T21:46:28.720924
2023-08-30T19:33:44
2023-08-30T19:33:44
1,803,961
916
918
NOASSERTION
2023-09-08T04:06:26
2011-05-26T11:15:35
null
UTF-8
C
false
false
379
h
patch-biewlib_sysdep_____os__dep.h
--- biewlib/sysdep/__os_dep.h.orig 2009-10-16 13:50:47 UTC +++ biewlib/sysdep/__os_dep.h @@ -364,11 +364,7 @@ extern void __FASTCALL__ __OsRestoreTimer(void); #define FILESIZE_MAX ULONG_MAX #endif -#if __WORDSIZE >= 64 -typedef void* bhandle_t; -#else typedef int bhandle_t; -#endif #define NULL_HANDLE ((bhandle_t)-1) /** Closes opened stream
416f7621b1ad85ee54046d91380953026b43310b
c8abb7c0a610348eb0b8474ce66463584ec5bc98
/Public/Src/Sandbox/Linux/utils.c
e87365e117b1ff794793689a255d9afcc57e3e77
[ "MIT" ]
permissive
microsoft/BuildXL
d31b74ba23057dd251bcd9040390a7e751f04fae
f884dd1e34ed50f76d27d3fb1b8679235995653d
refs/heads/main
2023-08-31T21:19:44.385093
2023-08-30T23:36:57
2023-08-30T23:36:57
152,813,045
436
114
MIT
2023-09-13T09:49:08
2018-10-12T22:16:45
C#
UTF-8
C
false
false
11,974
c
utils.c
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include <stdarg.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "utils.h" #define PATH_SEP_CHAR ':' // CODESYNC: SandboxedLinuxUtilsTest.cs #define EVN_SEP_CHAR_FOR_TEST ';' const char* skip_prefix(const char *src, const char *prefix) { if (src == NULL || prefix == NULL) { return NULL; } while (*src && *prefix && *src == *prefix) { src++; prefix++; } return *prefix ? NULL // prefix is not at '\0' --> no match : src; // prefix is at '\0' --> match, return the current position in src } /** * Create a copy of envp, which is newenvp. * Replace the ith element of the copy with "newKVP". * Return the pointer of newenvp. */ char** replace_KVP_in_envp(const char *const envp[], int env_num, int i, const char *newKVP) { char **newenvp = (char **)malloc((env_num + 1) * sizeof(char*)); if (newenvp == NULL) { return (char**)envp; } memcpy(newenvp, envp, env_num * sizeof(char*)); newenvp[i] = (char*)newKVP; newenvp[env_num] = NULL; // Last element of envp[] should be a null pointer. return newenvp; } const char* add_value_to_env(const char *src, const char *value_to_add, const char *envPrefix) { const char *pSrc = skip_prefix(src, envPrefix); if (!pSrc || strlen(value_to_add) == 0) { return src; } while (*pSrc) { const char *next = skip_prefix(pSrc, value_to_add); if (next && (*next == '\0' || *next == PATH_SEP_CHAR)) { // found a match --> return the original src return src; } else { // keep searching if (next == NULL) next = pSrc; while (*next != '\0' && *next != PATH_SEP_CHAR) next++; if (*next == '\0') { break; } else { pSrc = next + 1; } } } // no match int srcLen = strlen(src); int totalLen = srcLen + strlen(value_to_add) + 1; char *newEnvBuffer = (char *)malloc(totalLen); if (newEnvBuffer == NULL) { return src; } char *pNewEnvBuffer = newEnvBuffer; strcpy(pNewEnvBuffer, src); pNewEnvBuffer += srcLen; char *pLastChar = pNewEnvBuffer-1; if (*pLastChar != PATH_SEP_CHAR && *pLastChar != '=') { *pNewEnvBuffer = PATH_SEP_CHAR; pNewEnvBuffer++; } strcpy(pNewEnvBuffer, value_to_add); return newEnvBuffer; } char* createEnv(char const *envName, const char *envValue) { int envNameLen = strlen(envName); // strlen return the actual len of envName, not includeing '\0' int envValueLen = strlen(envValue); int totalLen = envNameLen + envValueLen + 1 + 1; //1 is for '=', the other 1 is for '\0' char *pKV = (char *)malloc(totalLen); if (pKV == NULL) { return NULL; } char *p = pKV; strcpy(p, envName); p = p + envNameLen; *p = '='; p++; strcpy(p, envValue); p = p + envValueLen; *p = '\0'; return pKV; } char** ensure_env_value(const char *const envp[], char const *envName, const char *envValue) { // Finding env var in envp const char *const *pEnv = envp; const char *const *pEnvFound = NULL; int env_index = 0; int env_num = 0; while (pEnv && *pEnv) { if (skip_prefix(*pEnv, envName)) { env_index = env_num; pEnvFound = pEnv; } ++pEnv; ++env_num; } // env var was found. if (pEnvFound) { const char *next = skip_prefix(*pEnvFound, envName); next = skip_prefix(next, "="); next = skip_prefix(next, envValue); if (next == NULL || *next != '\0') { char *kvp = createEnv(envName, envValue); if(kvp != NULL) { return replace_KVP_in_envp(envp, env_num, env_index, kvp); } } } else { char *kvp = createEnv(envName, envValue); if(kvp != NULL) { char **newenvp = (char **)malloc((env_num + 2) * sizeof(char*)); if (newenvp == NULL) { return (char**)envp; } memcpy(newenvp, envp, env_num * sizeof(char*)); newenvp[env_num] = kvp; newenvp[env_num + 1] = NULL; // Last element of envp[] should be a null pointer. return newenvp; } } return (char**)envp; } char** ensure_paths_included_in_env(const char *const envp[], char const *envPrefix, const char *arg, ...) { // Finding env var in envp const char *const *pEnv = envp; const char *const *pEnvFound = NULL; int env_index = 0; int env_num = 0; while (pEnv && *pEnv) { if (skip_prefix(*pEnv, envPrefix)) { env_index = env_num; pEnvFound = pEnv; } ++pEnv; ++env_num; } va_list varargs; va_start(varargs, arg); const char *pPath = arg; // env var was found. if (pEnvFound) { /** Check if the current path is in env * add_value_to_env returns pEnvFound if path is in it. * Otherwise it returns a new pointer to the env kvp string has the original value plus path. */ const char *result = *pEnvFound; while(!is_null_or_empty(pPath)) { const char *newResult = add_value_to_env(result, pPath, envPrefix); if(newResult != result) { result = newResult; } pPath = va_arg(varargs, char*); } // Case 1 if (result == *pEnvFound) { va_end(varargs); return (char**)envp; } // Case 2 else { va_end(varargs); return replace_KVP_in_envp(envp, env_num, env_index, result); } } // Case 3 else { // Get the total length of paths int totalPathsLen = 0; va_list copy; va_copy(copy, varargs); while(!is_null_or_empty(pPath)) { totalPathsLen += strlen(pPath) + 1; pPath = va_arg(varargs, char*); } int prefixLen = strlen(envPrefix); int len = prefixLen + totalPathsLen; char *newEnv = (char *)malloc(len); if (newEnv == NULL) { va_end(varargs); return (char**)envp; } char *pNewEnv = newEnv; strcpy(pNewEnv, envPrefix); pNewEnv += prefixLen; pPath = arg; while(!is_null_or_empty(pPath)) { strcpy(pNewEnv, pPath); pNewEnv += strlen(pPath); pPath = va_arg(copy, char*); if(!is_null_or_empty(pPath)) { *pNewEnv = PATH_SEP_CHAR; ++pNewEnv; } } char **newenvp = (char **)malloc((env_num + 2) * sizeof(char*)); if (newenvp == NULL) { va_end(varargs); return (char**)envp; } memcpy(newenvp, envp, env_num * sizeof(char*)); newenvp[env_num] = newEnv; newenvp[env_num + 1] = NULL; // Last element of envp[] should be a null pointer. va_end(varargs); return newenvp; } } bool is_null_or_empty(const char *input) { return !input || *input == '\0'; } void copy_result_to_buf_for_test(char **result, char *buf) { while (result && *result) { strcpy(buf, *result); int n = strlen(*result); buf[n] = EVN_SEP_CHAR_FOR_TEST; buf += n + 1; ++result; } // replace the last ';' with '\0' *(buf - 1) = '\0'; } #define LD_PRELOAD_ENV_VAR_PREFIX "LD_PRELOAD=" #define LD_PRELOAD_ENV_VAR_PREFIX_LENGTH 11 const char* scrub_ld_preload(const char *src, const char *value_to_scrub, char *buf) { const char *pSrc = skip_prefix(src, LD_PRELOAD_ENV_VAR_PREFIX); if (!pSrc || !*pSrc) { return src; } // copy "LD_PRELOAD=" into buffer strcpy(buf, LD_PRELOAD_ENV_VAR_PREFIX); // split the rest by ':' and check if each segment matches the path of this library char *pBuf = &buf[LD_PRELOAD_ENV_VAR_PREFIX_LENGTH]; while (*pSrc) { const char *next = skip_prefix(pSrc, value_to_scrub); if (next && (*next == '\0' || *next == PATH_SEP_CHAR)) { // found a match --> just skip it } else { // no match --> copy this segment into buffer if (next == NULL) next = pSrc; while (*next != '\0' && *next != PATH_SEP_CHAR) next++; memcpy(pBuf, pSrc, next - pSrc + 1); pBuf += next - pSrc + 1; } if (*next == '\0') { // reach the end. break; } else { pSrc = next + 1; } } *pBuf = '\0'; return buf; } char** remove_path_from_LDPRELOAD(const char *const envp[], const char *path) { // Finding LD_PRELOAD env var in envp const char *const *pEnv = envp; bool removed = false; bool foundLdPreload = false; const char* result; int env_num = 0; int ldPreloadEnv_index = 0; while (pEnv && *pEnv) { if (skip_prefix(*pEnv, LD_PRELOAD_ENV_VAR_PREFIX) && foundLdPreload == false) { foundLdPreload = true; int len = strlen(*pEnv); char *buf = malloc(len); if (buf == NULL) { return (char**)envp; } result = scrub_ld_preload(*pEnv, path, buf); if (result == buf) { removed = true; ldPreloadEnv_index = env_num; } else { free(buf); } } ++pEnv; ++env_num; } if (removed) { return replace_KVP_in_envp(envp, env_num, ldPreloadEnv_index, result); } return (char**)envp; } // ======================= for testing ======================== const bool add_value_to_env_for_test(const char *src, const char *value_to_add, const char *envPrefix, char *buf) { const char *result = add_value_to_env(src, value_to_add, envPrefix); strcpy(buf, result); return result == src; } const bool ensure_env_value_for_test(const char *const envp[], char const *envName, const char *envValue, char *buf) { char **result = ensure_env_value(envp, envName, envValue); copy_result_to_buf_for_test(result, buf); return result == (char**)envp; } const bool ensure_2_paths_included_in_env_for_test(const char *const envp[], char const *envPrefix, const char *path0, const char *path1, char *buf) { char **result = ensure_paths_included_in_env(envp, envPrefix, path0, path1, NULL); copy_result_to_buf_for_test(result, buf); return result == (char**)envp; } const bool ensure_1_path_included_in_env_for_test(const char *const envp[], char const *envPrefix, const char *path, char *buf) { char **result = ensure_paths_included_in_env(envp, envPrefix, path, NULL); copy_result_to_buf_for_test(result, buf); return result == (char**)envp; } const bool remove_path_from_LDPRELOAD_for_test(const char *const envp[], char *path, char *buf0, char *buf1, char *buf2) { char **result = remove_path_from_LDPRELOAD(envp, path); strcpy(buf0, result[0]); strcpy(buf1, result[1]); strcpy(buf2, result[2]); return result == (char**)envp; } const void scrub_ld_preload_for_test(const char *src, const char *value_to_scrub, char *buf) { const char *result = scrub_ld_preload(src, value_to_scrub, buf); if (result == src) { strcpy(buf, src); } }
c3b4dac149db89611d280c6b9e13da6d46e68895
7c7d6f504bfde6685e761ac5fe0dedf0c60b5479
/cbits/cryptonite_ripemd.c
20b8aa60e03676cd31d07f4d7691a475494fdddf
[ "BSD-3-Clause", "BSD-2-Clause" ]
permissive
haskell-crypto/cryptonite
504a55915321cd771a1dedf402f28c4948b76dfd
d163f69512a3d162baa69a95927f3d6369833f7d
refs/heads/master
2023-02-05T01:38:40.411460
2022-10-03T00:11:46
2022-10-03T00:11:46
21,498,990
224
141
NOASSERTION
2023-06-05T05:24:31
2014-07-04T14:00:07
C
UTF-8
C
false
false
10,524
c
cryptonite_ripemd.c
/* * Copyright (C) 2006-2009 Vincent Hanquez <vincent@snarc.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "cryptonite_ripemd.h" #include "cryptonite_bitfn.h" #include "cryptonite_align.h" #include <string.h> void cryptonite_ripemd160_init(struct ripemd160_ctx *ctx) { memset(ctx, 0, sizeof(*ctx)); ctx->h[0] = 0x67452301; ctx->h[1] = 0xefcdab89; ctx->h[2] = 0x98badcfe; ctx->h[3] = 0x10325476; ctx->h[4] = 0xc3d2e1f0; } #define K1 0x00000000 #define K2 0x5a827999 #define K3 0x6ed9eba1 #define K4 0x8f1bbcdc #define K5 0xa953fd4e #define K6 0x50a28be6 #define K7 0x5c4dd124 #define K8 0x6d703ef3 #define K9 0x7a6d76e9 #define f1(x, y, z) (x ^ y ^ z) #define f2(x, y, z) (z ^ (x & (y ^ z))) #define f3(x, y, z) ((x | ~y) ^ z) #define f4(x, y, z) (y ^ (z & (x ^ y))) #define f5(x, y, z) (x ^ (y | ~z)) #define R(a, b, c, d, e, f, k, i, s) \ a += f(b, c, d) + w[i] + k; a = rol32(a, s) + e; c = rol32(c, 10) static void ripemd160_do_chunk(struct ripemd160_ctx *ctx, uint32_t *buf) { uint32_t a1, b1, c1, d1, e1, a2, b2, c2, d2, e2; #ifdef ARCH_IS_BIG_ENDIAN uint32_t w[16]; cpu_to_le32_array(w, buf, 16); #else uint32_t *w = buf; #endif a1 = ctx->h[0]; b1 = ctx->h[1]; c1 = ctx->h[2]; d1 = ctx->h[3]; e1 = ctx->h[4]; a2 = ctx->h[0]; b2 = ctx->h[1]; c2 = ctx->h[2]; d2 = ctx->h[3]; e2 = ctx->h[4]; /* 5 passes on first state copy */ R(a1, b1, c1, d1, e1, f1, K1, 0, 11); R(e1, a1, b1, c1, d1, f1, K1, 1, 14); R(d1, e1, a1, b1, c1, f1, K1, 2, 15); R(c1, d1, e1, a1, b1, f1, K1, 3, 12); R(b1, c1, d1, e1, a1, f1, K1, 4, 5); R(a1, b1, c1, d1, e1, f1, K1, 5, 8); R(e1, a1, b1, c1, d1, f1, K1, 6, 7); R(d1, e1, a1, b1, c1, f1, K1, 7, 9); R(c1, d1, e1, a1, b1, f1, K1, 8, 11); R(b1, c1, d1, e1, a1, f1, K1, 9, 13); R(a1, b1, c1, d1, e1, f1, K1, 10, 14); R(e1, a1, b1, c1, d1, f1, K1, 11, 15); R(d1, e1, a1, b1, c1, f1, K1, 12, 6); R(c1, d1, e1, a1, b1, f1, K1, 13, 7); R(b1, c1, d1, e1, a1, f1, K1, 14, 9); R(a1, b1, c1, d1, e1, f1, K1, 15, 8); R(e1, a1, b1, c1, d1, f2, K2, 7, 7); R(d1, e1, a1, b1, c1, f2, K2, 4, 6); R(c1, d1, e1, a1, b1, f2, K2, 13, 8); R(b1, c1, d1, e1, a1, f2, K2, 1, 13); R(a1, b1, c1, d1, e1, f2, K2, 10, 11); R(e1, a1, b1, c1, d1, f2, K2, 6, 9); R(d1, e1, a1, b1, c1, f2, K2, 15, 7); R(c1, d1, e1, a1, b1, f2, K2, 3, 15); R(b1, c1, d1, e1, a1, f2, K2, 12, 7); R(a1, b1, c1, d1, e1, f2, K2, 0, 12); R(e1, a1, b1, c1, d1, f2, K2, 9, 15); R(d1, e1, a1, b1, c1, f2, K2, 5, 9); R(c1, d1, e1, a1, b1, f2, K2, 2, 11); R(b1, c1, d1, e1, a1, f2, K2, 14, 7); R(a1, b1, c1, d1, e1, f2, K2, 11, 13); R(e1, a1, b1, c1, d1, f2, K2, 8, 12); R(d1, e1, a1, b1, c1, f3, K3, 3, 11); R(c1, d1, e1, a1, b1, f3, K3, 10, 13); R(b1, c1, d1, e1, a1, f3, K3, 14, 6); R(a1, b1, c1, d1, e1, f3, K3, 4, 7); R(e1, a1, b1, c1, d1, f3, K3, 9, 14); R(d1, e1, a1, b1, c1, f3, K3, 15, 9); R(c1, d1, e1, a1, b1, f3, K3, 8, 13); R(b1, c1, d1, e1, a1, f3, K3, 1, 15); R(a1, b1, c1, d1, e1, f3, K3, 2, 14); R(e1, a1, b1, c1, d1, f3, K3, 7, 8); R(d1, e1, a1, b1, c1, f3, K3, 0, 13); R(c1, d1, e1, a1, b1, f3, K3, 6, 6); R(b1, c1, d1, e1, a1, f3, K3, 13, 5); R(a1, b1, c1, d1, e1, f3, K3, 11, 12); R(e1, a1, b1, c1, d1, f3, K3, 5, 7); R(d1, e1, a1, b1, c1, f3, K3, 12, 5); R(c1, d1, e1, a1, b1, f4, K4, 1, 11); R(b1, c1, d1, e1, a1, f4, K4, 9, 12); R(a1, b1, c1, d1, e1, f4, K4, 11, 14); R(e1, a1, b1, c1, d1, f4, K4, 10, 15); R(d1, e1, a1, b1, c1, f4, K4, 0, 14); R(c1, d1, e1, a1, b1, f4, K4, 8, 15); R(b1, c1, d1, e1, a1, f4, K4, 12, 9); R(a1, b1, c1, d1, e1, f4, K4, 4, 8); R(e1, a1, b1, c1, d1, f4, K4, 13, 9); R(d1, e1, a1, b1, c1, f4, K4, 3, 14); R(c1, d1, e1, a1, b1, f4, K4, 7, 5); R(b1, c1, d1, e1, a1, f4, K4, 15, 6); R(a1, b1, c1, d1, e1, f4, K4, 14, 8); R(e1, a1, b1, c1, d1, f4, K4, 5, 6); R(d1, e1, a1, b1, c1, f4, K4, 6, 5); R(c1, d1, e1, a1, b1, f4, K4, 2, 12); R(b1, c1, d1, e1, a1, f5, K5, 4, 9); R(a1, b1, c1, d1, e1, f5, K5, 0, 15); R(e1, a1, b1, c1, d1, f5, K5, 5, 5); R(d1, e1, a1, b1, c1, f5, K5, 9, 11); R(c1, d1, e1, a1, b1, f5, K5, 7, 6); R(b1, c1, d1, e1, a1, f5, K5, 12, 8); R(a1, b1, c1, d1, e1, f5, K5, 2, 13); R(e1, a1, b1, c1, d1, f5, K5, 10, 12); R(d1, e1, a1, b1, c1, f5, K5, 14, 5); R(c1, d1, e1, a1, b1, f5, K5, 1, 12); R(b1, c1, d1, e1, a1, f5, K5, 3, 13); R(a1, b1, c1, d1, e1, f5, K5, 8, 14); R(e1, a1, b1, c1, d1, f5, K5, 11, 11); R(d1, e1, a1, b1, c1, f5, K5, 6, 8); R(c1, d1, e1, a1, b1, f5, K5, 15, 5); R(b1, c1, d1, e1, a1, f5, K5, 13, 6); /* 5 passes on second state copy */ R(a2, b2, c2, d2, e2, f5, K6, 5, 8); R(e2, a2, b2, c2, d2, f5, K6, 14, 9); R(d2, e2, a2, b2, c2, f5, K6, 7, 9); R(c2, d2, e2, a2, b2, f5, K6, 0, 11); R(b2, c2, d2, e2, a2, f5, K6, 9, 13); R(a2, b2, c2, d2, e2, f5, K6, 2, 15); R(e2, a2, b2, c2, d2, f5, K6, 11, 15); R(d2, e2, a2, b2, c2, f5, K6, 4, 5); R(c2, d2, e2, a2, b2, f5, K6, 13, 7); R(b2, c2, d2, e2, a2, f5, K6, 6, 7); R(a2, b2, c2, d2, e2, f5, K6, 15, 8); R(e2, a2, b2, c2, d2, f5, K6, 8, 11); R(d2, e2, a2, b2, c2, f5, K6, 1, 14); R(c2, d2, e2, a2, b2, f5, K6, 10, 14); R(b2, c2, d2, e2, a2, f5, K6, 3, 12); R(a2, b2, c2, d2, e2, f5, K6, 12, 6); R(e2, a2, b2, c2, d2, f4, K7, 6, 9); R(d2, e2, a2, b2, c2, f4, K7, 11, 13); R(c2, d2, e2, a2, b2, f4, K7, 3, 15); R(b2, c2, d2, e2, a2, f4, K7, 7, 7); R(a2, b2, c2, d2, e2, f4, K7, 0, 12); R(e2, a2, b2, c2, d2, f4, K7, 13, 8); R(d2, e2, a2, b2, c2, f4, K7, 5, 9); R(c2, d2, e2, a2, b2, f4, K7, 10, 11); R(b2, c2, d2, e2, a2, f4, K7, 14, 7); R(a2, b2, c2, d2, e2, f4, K7, 15, 7); R(e2, a2, b2, c2, d2, f4, K7, 8, 12); R(d2, e2, a2, b2, c2, f4, K7, 12, 7); R(c2, d2, e2, a2, b2, f4, K7, 4, 6); R(b2, c2, d2, e2, a2, f4, K7, 9, 15); R(a2, b2, c2, d2, e2, f4, K7, 1, 13); R(e2, a2, b2, c2, d2, f4, K7, 2, 11); R(d2, e2, a2, b2, c2, f3, K8, 15, 9); R(c2, d2, e2, a2, b2, f3, K8, 5, 7); R(b2, c2, d2, e2, a2, f3, K8, 1, 15); R(a2, b2, c2, d2, e2, f3, K8, 3, 11); R(e2, a2, b2, c2, d2, f3, K8, 7, 8); R(d2, e2, a2, b2, c2, f3, K8, 14, 6); R(c2, d2, e2, a2, b2, f3, K8, 6, 6); R(b2, c2, d2, e2, a2, f3, K8, 9, 14); R(a2, b2, c2, d2, e2, f3, K8, 11, 12); R(e2, a2, b2, c2, d2, f3, K8, 8, 13); R(d2, e2, a2, b2, c2, f3, K8, 12, 5); R(c2, d2, e2, a2, b2, f3, K8, 2, 14); R(b2, c2, d2, e2, a2, f3, K8, 10, 13); R(a2, b2, c2, d2, e2, f3, K8, 0, 13); R(e2, a2, b2, c2, d2, f3, K8, 4, 7); R(d2, e2, a2, b2, c2, f3, K8, 13, 5); R(c2, d2, e2, a2, b2, f2, K9, 8, 15); R(b2, c2, d2, e2, a2, f2, K9, 6, 5); R(a2, b2, c2, d2, e2, f2, K9, 4, 8); R(e2, a2, b2, c2, d2, f2, K9, 1, 11); R(d2, e2, a2, b2, c2, f2, K9, 3, 14); R(c2, d2, e2, a2, b2, f2, K9, 11, 14); R(b2, c2, d2, e2, a2, f2, K9, 15, 6); R(a2, b2, c2, d2, e2, f2, K9, 0, 14); R(e2, a2, b2, c2, d2, f2, K9, 5, 6); R(d2, e2, a2, b2, c2, f2, K9, 12, 9); R(c2, d2, e2, a2, b2, f2, K9, 2, 12); R(b2, c2, d2, e2, a2, f2, K9, 13, 9); R(a2, b2, c2, d2, e2, f2, K9, 9, 12); R(e2, a2, b2, c2, d2, f2, K9, 7, 5); R(d2, e2, a2, b2, c2, f2, K9, 10, 15); R(c2, d2, e2, a2, b2, f2, K9, 14, 8); R(b2, c2, d2, e2, a2, f1, K1, 12, 8); R(a2, b2, c2, d2, e2, f1, K1, 15, 5); R(e2, a2, b2, c2, d2, f1, K1, 10, 12); R(d2, e2, a2, b2, c2, f1, K1, 4, 9); R(c2, d2, e2, a2, b2, f1, K1, 1, 12); R(b2, c2, d2, e2, a2, f1, K1, 5, 5); R(a2, b2, c2, d2, e2, f1, K1, 8, 14); R(e2, a2, b2, c2, d2, f1, K1, 7, 6); R(d2, e2, a2, b2, c2, f1, K1, 6, 8); R(c2, d2, e2, a2, b2, f1, K1, 2, 13); R(b2, c2, d2, e2, a2, f1, K1, 13, 6); R(a2, b2, c2, d2, e2, f1, K1, 14, 5); R(e2, a2, b2, c2, d2, f1, K1, 0, 15); R(d2, e2, a2, b2, c2, f1, K1, 3, 13); R(c2, d2, e2, a2, b2, f1, K1, 9, 11); R(b2, c2, d2, e2, a2, f1, K1, 11, 11); d2 += c1 + ctx->h[1]; ctx->h[1] = ctx->h[2] + d1 + e2; ctx->h[2] = ctx->h[3] + e1 + a2; ctx->h[3] = ctx->h[4] + a1 + b2; ctx->h[4] = ctx->h[0] + b1 + c2; ctx->h[0] = d2; } void cryptonite_ripemd160_update(struct ripemd160_ctx *ctx, const uint8_t *data, uint32_t len) { uint32_t index, to_fill; index = (uint32_t) (ctx->sz & 0x3f); to_fill = 64 - index; ctx->sz += len; if (index && len >= to_fill) { memcpy(ctx->buf + index, data, to_fill); ripemd160_do_chunk(ctx, (uint32_t *) ctx->buf); len -= to_fill; data += to_fill; index = 0; } if (need_alignment(data, 4)) { uint32_t tramp[16]; ASSERT_ALIGNMENT(tramp, 4); for (; len >= 64; len -= 64, data += 64) { memcpy(tramp, data, 64); ripemd160_do_chunk(ctx, tramp); } } else { /* process as much 64-block as possible */ for (; len >= 64; len -= 64, data += 64) ripemd160_do_chunk(ctx, (uint32_t *) data); } /* append data into buf */ if (len) memcpy(ctx->buf + index, data, len); } void cryptonite_ripemd160_finalize(struct ripemd160_ctx *ctx, uint8_t *out) { static uint8_t padding[64] = { 0x80, }; uint64_t bits; uint32_t index, padlen; /* add padding and update data with it */ bits = cpu_to_le64(ctx->sz << 3); /* pad out to 56 */ index = (uint32_t) (ctx->sz & 0x3f); padlen = (index < 56) ? (56 - index) : ((64 + 56) - index); cryptonite_ripemd160_update(ctx, padding, padlen); /* append length */ cryptonite_ripemd160_update(ctx, (uint8_t *) &bits, sizeof(bits)); /* output digest */ store_le32(out , ctx->h[0]); store_le32(out+ 4, ctx->h[1]); store_le32(out+ 8, ctx->h[2]); store_le32(out+12, ctx->h[3]); store_le32(out+16, ctx->h[4]); }
5fdad10bca27b6da9789363d5ea293e3faa3bff1
e1d9c54e9925e30e388a255b53a93cccad0b94cb
/kubernetes/model/v1_git_repo_volume_source.h
bb9be1ee5da63bb37c33d89eebe94ec674a0b305
[ "curl", "Apache-2.0" ]
permissive
kubernetes-client/c
dd4fd8095485c083e0f40f2b48159b1609a6141b
5ac5ff25e9809a92a48111b1f77574b6d040b711
refs/heads/master
2023-08-13T10:51:03.702497
2023-08-07T19:18:32
2023-08-07T19:18:32
247,958,425
127
47
Apache-2.0
2023-09-07T20:07:00
2020-03-17T11:59:05
C
UTF-8
C
false
false
1,379
h
v1_git_repo_volume_source.h
/* * v1_git_repo_volume_source.h * * Represents a volume that is populated with the contents of a git repository. Git repo volumes do not support ownership management. Git repo volumes support SELinux relabeling. DEPRECATED: GitRepo is deprecated. To provision a container with a git repo, mount an EmptyDir into an InitContainer that clones the repo using git, then mount the EmptyDir into the Pod&#39;s container. */ #ifndef _v1_git_repo_volume_source_H_ #define _v1_git_repo_volume_source_H_ #include <string.h> #include "../external/cJSON.h" #include "../include/list.h" #include "../include/keyValuePair.h" #include "../include/binary.h" typedef struct v1_git_repo_volume_source_t v1_git_repo_volume_source_t; typedef struct v1_git_repo_volume_source_t { char *directory; // string char *repository; // string char *revision; // string } v1_git_repo_volume_source_t; v1_git_repo_volume_source_t *v1_git_repo_volume_source_create( char *directory, char *repository, char *revision ); void v1_git_repo_volume_source_free(v1_git_repo_volume_source_t *v1_git_repo_volume_source); v1_git_repo_volume_source_t *v1_git_repo_volume_source_parseFromJSON(cJSON *v1_git_repo_volume_sourceJSON); cJSON *v1_git_repo_volume_source_convertToJSON(v1_git_repo_volume_source_t *v1_git_repo_volume_source); #endif /* _v1_git_repo_volume_source_H_ */
50fef6d28b3d72c6b86aa9b2d04581a7e7e954d4
7e41167bfae6d2c38689b7e0993b308e045cbd05
/text_cmds/ed/buf.c
958dc24fbea18364ddc55905cb3528c107b6c1b6
[ "BSD-3-Clause", "curl", "GPL-1.0-or-later", "MIT", "Python-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
holzschu/ios_system
7b18993dbcb33331c353e0257ca54847a5d1b1bb
6a83eb1c6c383a562fbe33a7e97677e88d305b51
refs/heads/master
2023-08-14T09:11:40.627903
2023-04-18T15:12:29
2023-04-18T15:12:29
113,187,304
882
155
BSD-3-Clause
2023-08-19T19:15:35
2017-12-05T13:42:50
C
UTF-8
C
false
false
7,024
c
buf.c
/* buf.c: This file contains the scratch-file buffer routines for the ed line editor. */ /*- * Copyright (c) 1993 Andrew Moore, Talke Studio. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include <sys/cdefs.h> __FBSDID("$FreeBSD: src/bin/ed/buf.c,v 1.22 2002/06/30 05:13:53 obrien Exp $"); #include <sys/file.h> #include <sys/stat.h> #include "ed.h" // from ios_system: #include "ios_error.h" #include <pthread.h> #import <Foundation/Foundation.h> FILE *sfp; /* scratch file pointer */ off_t sfseek; /* scratch file position */ int seek_write; /* seek before writing */ line_t buffer_head; /* incore buffer */ /* get_sbuf_line: get a line of text from the scratch file; return pointer to the text */ char * get_sbuf_line(line_t *lp) { static char *sfbuf = NULL; /* buffer */ static int sfbufsz = 0; /* buffer size */ int len, ct; if (lp == &buffer_head) return NULL; seek_write = 1; /* force seek on write */ /* out of position */ if (sfseek != lp->seek) { sfseek = lp->seek; if (fseeko(sfp, sfseek, SEEK_SET) < 0) { fprintf(thread_stderr, "%s\n", strerror(errno)); errmsg = "cannot seek temp file"; return NULL; } } len = lp->len; REALLOC(sfbuf, sfbufsz, len + 1, NULL); if ((ct = fread(sfbuf, sizeof(char), len, sfp)) < 0 || ct != len) { fprintf(thread_stderr, "%s\n", strerror(errno)); errmsg = "cannot read temp file"; return NULL; } sfseek += len; /* update file position */ sfbuf[len] = '\0'; return sfbuf; } /* put_sbuf_line: write a line of text to the scratch file and add a line node to the editor buffer; return a pointer to the end of the text */ const char * put_sbuf_line(const char *cs) { line_t *lp; int len, ct; const char *s; if ((lp = (line_t *) malloc(sizeof(line_t))) == NULL) { fprintf(thread_stderr, "%s\n", strerror(errno)); errmsg = "out of memory"; return NULL; } /* assert: cs is '\n' terminated */ for (s = cs; *s != '\n'; s++) ; if (s - cs >= LINECHARS) { errmsg = "line too long"; return NULL; } len = s - cs; /* out of position */ if (seek_write) { if (fseeko(sfp, (off_t)0, SEEK_END) < 0) { fprintf(thread_stderr, "%s\n", strerror(errno)); errmsg = "cannot seek temp file"; return NULL; } sfseek = ftello(sfp); seek_write = 0; } /* assert: SPL1() */ if ((ct = fwrite(cs, sizeof(char), len, sfp)) < 0 || ct != len) { sfseek = -1; fprintf(thread_stderr, "%s\n", strerror(errno)); errmsg = "cannot write temp file"; return NULL; } lp->len = len; lp->seek = sfseek; add_line_node(lp); sfseek += len; /* update file position */ return ++s; } /* add_line_node: add a line node in the editor buffer after the current line */ void add_line_node(line_t *lp) { line_t *cp; cp = get_addressed_line_node(current_addr); /* this get_addressed_line_node last! */ INSQUE(lp, cp); addr_last++; current_addr++; } /* get_line_node_addr: return line number of pointer */ long get_line_node_addr(line_t *lp) { line_t *cp = &buffer_head; long n = 0; while (cp != lp && (cp = cp->q_forw) != &buffer_head) n++; if (n && cp == &buffer_head) { errmsg = "invalid address"; return ERR; } return n; } /* get_addressed_line_node: return pointer to a line node in the editor buffer */ line_t * get_addressed_line_node(long n) { static line_t *lp = &buffer_head; static long on = 0; SPL1(); if (n > on) if (n <= (on + addr_last) >> 1) for (; on < n; on++) lp = lp->q_forw; else { lp = buffer_head.q_back; for (on = addr_last; on > n; on--) lp = lp->q_back; } else if (n >= on >> 1) for (; on > n; on--) lp = lp->q_back; else { lp = &buffer_head; for (on = 0; on < n; on++) lp = lp->q_forw; } SPL0(); return lp; } extern __thread int newline_added; char sfn[PATH_MAX] = ""; /* scratch file name */ /* open_sbuf: open scratch file */ int open_sbuf(void) { int fd; int u; isbinary = newline_added = 0; u = umask(077); // getenv($HOME) + "/tmp/" or NSString * NSTemporaryDirectory(void); // the latter, I guess. sprintf(sfn, "%s/ed.XXXXXX", NSTemporaryDirectory().UTF8String); // strcpy(sfn, "/tmp/ed.XXXXXX"); if ((fd = mkstemp(sfn)) == -1 || (sfp = fdopen(fd, "w+")) == NULL) { if (fd != -1) close(fd); perror(sfn); errmsg = "cannot open temp file"; umask(u); return ERR; } umask(u); return 0; } /* close_sbuf: close scratch file */ int close_sbuf(void) { if (sfp) { if (fclose(sfp) < 0) { fprintf(thread_stderr, "%s: %s\n", sfn, strerror(errno)); errmsg = "cannot close temp file"; return ERR; } sfp = NULL; unlink(sfn); } sfseek = seek_write = 0; return 0; } /* quit: remove_lines scratch file and exit */ void quit(int n) { if (sfp) { fclose(sfp); unlink(sfn); } exit(n); } unsigned char ctab[256]; /* character translation table */ /* init_buffers: open scratch buffer; initialize line queue */ void init_buffers(void) { int i = 0; /* Read stdin one character at a time to avoid i/o contention with shell escapes invoked by nonterminal input, e.g., ed - <<EOF !cat hello, world EOF */ setbuffer(thread_stdin, stdinbuf, 1); /* Ensure stdout is line buffered. This avoids bogus delays of output if stdout is piped through utilities to a terminal. */ setvbuf(thread_stdout, NULL, _IOLBF, 0); if (open_sbuf() < 0) quit(2); REQUE(&buffer_head, &buffer_head); for (i = 0; i < 256; i++) ctab[i] = i; } /* translit_text: translate characters in a string */ char * translit_text(char *s, int len, int from, int to) { static int i = 0; unsigned char *us; ctab[i] = i; /* restore table to initial state */ ctab[i = from] = to; for (us = (unsigned char *) s; len-- > 0; us++) *us = ctab[*us]; return s; }
a6a0b4922f5939634ab2484c726df240bc63cc97
b732361d6b3405c3e79ac0a7d8361cf5b329b015
/ext/phalcon/support/helper/json/decode.zep.h
8099968f6cf967f53b9676286dcf24fd5674977e
[ "BSD-3-Clause" ]
permissive
phalcon/cphalcon
4a5b26f47b5c2a4107541d7fd73c595c0d90ed73
fc183e11e8b96c43daf7d893244846206dc2aa73
refs/heads/master
2023-03-07T22:09:48.814291
2023-02-28T16:45:15
2023-02-28T16:45:15
2,854,337
8,135
2,343
BSD-3-Clause
2023-09-12T12:41:13
2011-11-26T05:52:50
PHP
UTF-8
C
false
true
673
h
decode.zep.h
extern zend_class_entry *phalcon_support_helper_json_decode_ce; ZEPHIR_INIT_CLASS(Phalcon_Support_Helper_Json_Decode); PHP_METHOD(Phalcon_Support_Helper_Json_Decode, __invoke); ZEND_BEGIN_ARG_INFO_EX(arginfo_phalcon_support_helper_json_decode___invoke, 0, 0, 1) ZEND_ARG_TYPE_INFO(0, data, IS_STRING, 0) ZEND_ARG_TYPE_INFO(0, associative, _IS_BOOL, 0) ZEND_ARG_TYPE_INFO(0, depth, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, options, IS_LONG, 0) ZEND_END_ARG_INFO() ZEPHIR_INIT_FUNCS(phalcon_support_helper_json_decode_method_entry) { PHP_ME(Phalcon_Support_Helper_Json_Decode, __invoke, arginfo_phalcon_support_helper_json_decode___invoke, ZEND_ACC_PUBLIC) PHP_FE_END };
41880a80e74fbb9bac34931fe96b309caa678652
3e8fbb570f7acb21de7d6ac250a6b11f126c3c90
/src/dsu/main_dst/SeisPipe2D.c
64962407f3e1614a23be4291d0c646f14791bdac
[ "LicenseRef-scancode-other-permissive" ]
permissive
JohnWStockwellJr/SeisUnix
0868431b0ac2f463d858920e6fd72493817e9659
c222c39a2e1040ddf7a789c15276df1e7e520f5a
refs/heads/master
2023-09-04T13:13:39.535821
2023-08-31T03:07:11
2023-08-31T03:07:11
53,870,336
250
134
NOASSERTION
2023-08-31T02:52:20
2016-03-14T15:57:55
C
UTF-8
C
false
false
7,050
c
SeisPipe2D.c
/* * SeisPipe2D.c * * SeisPipe2D slave process * * 09 Oct 1994 Murillo: c */ #include "SeisMig.h" #define LCF 5 /* Length (same for x and y) of McClellan cosine filter */ #define LCF2 2 /* Padding DATA */ #define C1 0.0255199 /* used to improve circular symmetry of McClellan filter */ void etextrap (eTable *et, int nx, float wdxov[], complex q[]); char *sdoc[] ={NULL}; main(int argc, char *argv[]) { int SeisPipe2D (DsuTask *zz); struct timeval tm1, tm2; clock_t clk1, clk2; int tt; int i, j, INFO; DsuTask zz; /* time checking */ gettimeofday(&tm1, (struct timezone*)0); clk1 = clock(); InitLog(&zz, "SeisPipe2D"); /* pvm_setopt(PvmRoute, PvmRouteDirect); */ fprintf(zz.fp_log, "Starting SeisPipe2D Application \n" ); fflush(zz.fp_log); /* CODE TO PROCESS THE DATA HERE */ INFO = SeisPipe2D(&zz); clk2 = clock(); gettimeofday(&tm2, (struct timezone*)0); tt = (tm2.tv_sec - tm1.tv_sec); fprintf(zz.fp_log,"\n\tTiempo Total del ciclo <%d> Seg. \n\n", tt); tt = (clk2 - clk1) / CLOCKS_PER_SEC; fprintf(zz.fp_log,"\n\tTotal CPU time <%d> Seg. \n\n", tt); fclose(zz.fp_log); } /* End of main */ int SeisPipe2D(DsuTask *zz) { int nt,nx,nz,nw,ntpad,ntfft; int it,ix,iz,izz,iw,iw0,iw1,iw2,iw3,iwmin,iwmax; int nfreqs,verbose; float dt,dx,dy,dz,dw; float freqs[4],fw,w,scale,fftscl; float *p, **v, *wdxov,*sx; complex *cpx; float **qx; void *TabInfo; eTable *et; char msg[80]; int info, ToTid, MasterTid; int sz, pz, pei; int SeisIntPars[20]; float SeisFloPars[20]; /* Receive process control information */ MsgLog(zz, "Receiving Control info ... " ); MasterTid = RecvInt(SeisIntPars, 2, -1, MsgCntl); pei = SeisIntPars[0]; ToTid = SeisIntPars[1]; MsgLog(zz, " Ready \n"); /* Receive: efile and other pars ... */ MsgLog(zz, "Receiving parameters ..." ); TabInfo = RecvBytes(-1, MsgTable); RecvFI(SeisFloPars, 10, SeisIntPars, 10, -1, -1); MsgLog(zz, " Ready \n" ); /* get integer parameters */ nt = SeisIntPars[0]; nx = SeisIntPars[1]; nz = SeisIntPars[2]; ntpad = SeisIntPars[3]; verbose = SeisIntPars[4]; sz = SeisIntPars[5]; pz = SeisIntPars[6]; /* get Floating point parameters */ dt = SeisFloPars[0]; dx = SeisFloPars[1]; dz = SeisFloPars[2]; freqs[0] = SeisFloPars[3]; freqs[1] = SeisFloPars[4]; freqs[2] = SeisFloPars[5]; freqs[3] = SeisFloPars[6]; sz = nz / pz; if (pei == (pz - 1)) sz += nz % pz; sprintf(msg, "Receiving Velocity info (pei = %d, sz = %d) ... ", pei, sz); MsgLog(zz,msg); v = alloc2float(nx, sz); for (iz=0; iz<sz; ++iz) RecvFloat(v[iz], nx, -1, MsgVel); MsgLog(zz, " Ready \n" ); /* determine frequency w sampling */ ntfft = npfar(nt+ntpad); nw = ntfft/2+1; dw = 2.0*PI/(ntfft*dt); iwmin = MAX(0,MIN(nw-1,NINT(2.0*PI*freqs[0]/dw))); iwmax = MAX(0,MIN(nw-1,NINT(2.0*PI*freqs[3]/dw))); /* read extrapolator table */ et = ezread(TabInfo); /* pret(zz -> fp_log, et); */ /* allocate workspace */ MsgLog(zz, "Allocating space ... "); qx = alloc2float(nx,sz); sx = alloc1float(nx); wdxov = alloc1float(nx); cpx = alloc1complex(nx); MsgLog(zz, " Ready \n"); sprintf(msg, "Process (%d) starting loop on depth steps(%d,%d)\n", pei, pei*(nz/pz), pei*(nz/pz) + sz); MsgLog(zz, msg); /* Cleanup qx */ for (iz=0; iz<sz; ++iz) for (ix=0; ix<nx; ++ix) qx[iz][ix] = 0.0; /* loop over frequencies w */ for (iw=iwmin,w=iwmin*dw; iw<iwmax; ++iw,w+=dw) { if (verbose && !(iw%1)) { sprintf(msg, "\t%d/%d\n",iw,iwmax); MsgLog(zz, msg); } /* load wavefield */ RecvCplx(cpx, nx, -1, MsgSlice); /* loop over depth steps nz */ for (iz=0; iz<sz; ++iz) { /* compute 2.0*dx/v(x) and zero migrated data */ for (ix=0; ix<nx; ix++) sx[ix] = 2.0*dx/v[iz][ix]; /* make w*dx/v(x) */ for (ix=0; ix<nx; ++ix) wdxov[ix] = w*sx[ix]; /* extrapolate wavefield */ etextrap(et,nx,wdxov,cpx); /* accumulate migrated data */ for (ix=0; ix<nx; ++ix) qx[iz][ix] += cpx[ix].r; } /* Send down the wavefield */ if ( pei != (pz -1)) SendCplx(cpx, nx, ToTid, MsgSlice); } /* End of loop for iw */ for (iz=0; iz<sz; iz++) { izz = pei*(nz/pz) + iz; if (verbose) { sprintf(msg, "Sending values for iz = %d\n",izz); MsgLog(zz, msg); } SendFI(qx[iz], nx, &izz, 1, MasterTid, MsgDepth); } sprintf(msg, "End of processing for (%d)\n",pei); MsgLog(zz, msg); /* free workspace */ free1float(sx); free1float(wdxov); free2float(v); free2float(qx); free1complex(cpx); pvm_exit(); return(0); } void etextrap (eTable *et, int nx, float wdxov[], complex q[]) /***************************************************************************** Extrapolation for one frequency via an extrapolator table ****************************************************************************** Input: et pointer to extrapolator table nx number of samples in wavefield wdxov array[nx] of frequency*dx/velocity values q array[nx] containing current wavefield Output: q array[nx] containing extrapolated wavefield ****************************************************************************** Author: Dave Hale, Colorado School of Mines, 02/19/90 ******************************************************************************/ { int ix,je,iwdxov,ne,nxpad, nwdxov=et->nwdxov,*nh=et->nh,nhmax=et->nhmax; float phase,*pr,*pi,spr,spi,qr,qi,er,ei,wdxovn, dwdxov=et->dwdxov,fwdxov=et->fwdxov,dzodx=et->dzodx; complex **e=et->e; /* allocate workspace */ nxpad = nhmax-1+nx+nhmax-1; pr = alloc1float(nxpad); pi = alloc1float(nxpad); /* zero workspace and adjust pointers for zero padding */ for (ix=0; ix<nxpad; ++ix) pr[ix] = pi[ix] = 0.0; pr += nhmax-1; pi += nhmax-1; /* copy input to zero-padded workspace */ for (ix=0; ix<nx; ++ix) { pr[ix] = q[ix].r; pi[ix] = q[ix].i; } /* loop over output samples */ for (ix=0; ix<nx; ix++) { /* compute pointer to extrapolator coefficients */ wdxovn = (wdxov[ix]-fwdxov)/dwdxov; iwdxov = NINT(wdxovn); if (iwdxov<0) iwdxov = 0; if (iwdxov>=nwdxov) iwdxov = nwdxov-1; ne = nh[iwdxov]; /* extrapolate with focusing term */ spr = pr[ix]; spi = pi[ix]; er = e[iwdxov][0].r; ei = e[iwdxov][0].i; qr = er*spr-ei*spi; qi = er*spi+ei*spr; for (je=1; je<ne; ++je) { spr = pr[ix+je]+pr[ix-je]; spi = pi[ix+je]+pi[ix-je]; er = e[iwdxov][je].r; ei = e[iwdxov][je].i; qr += er*spr-ei*spi; qi += er*spi+ei*spr; } /* extrapolate with shifting term */ phase = -dzodx*wdxov[ix]; er = cos(phase); ei = sin(phase); q[ix].r = qr*er-qi*ei; q[ix].i = qr*ei+qi*er; } /* adjust workspace pointers and free workspace */ pr -= nhmax-1; pi -= nhmax-1; free1float(pr); free1float(pi); }
428aaab3341195188d9588117f8302fe32824ddf
6e8226bff5369d52885ab75c95f78e155d6afb48
/src/wrap/morn_stb_image.c
a777afe6dfb18db6db819fbe3b0e42efee6eb4b8
[ "Apache-2.0" ]
permissive
jingweizhanghuai/Morn
a26fc8747fd82c10a94003759a9adc44a60a8353
b9ee92c26190dec03a6726b9ac9d18fb570b7a70
refs/heads/master
2023-03-03T12:02:06.835741
2023-02-17T14:16:34
2023-02-17T14:16:34
187,427,750
257
64
null
null
null
null
UTF-8
C
false
false
2,011
c
morn_stb_image.c
#include "morn_image.h" #define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_WRITE_IMPLEMENTATION #include "stb_image.h" #include "stb_image_write.h" void mImageLoad(MImage *img,const char *imgname,...) { char filename[256]; va_list val;va_start(val,imgname);vsprintf(filename,imgname,val);va_end(val); int width,height,channel; uint8_t *data = stbi_load(imgname,&width,&height,&channel,0); mImageRedefine(img,channel,height,width); uint8_t **buff; if(channel>=3) {buff=img->data[0];img->data[0]=img->data[2];img->data[2]=buff;} mImageDataInput(img,data); if(channel>=3) {buff=img->data[0];img->data[0]=img->data[2];img->data[2]=buff;} } #define JPG 1 #define PNG 2 #define BMP -1 #ifdef __GNUC__ #define stricmp strcasecmp #endif void mImageSave(MImage *img,const char *imgname,...) { char filename[256]; va_list val;va_start(val,imgname);vsprintf(filename,imgname,val);va_end(val); char *p=(char *)filename+strlen(filename); while(*p!='.') {if(p==filename) {break;} p--;} int type=BMP; if(stricmp(p+1,"jpg" )==0) type=JPG; else if(stricmp(p+1,"jpeg")==0) type=JPG; else if(stricmp(p+1,"png" )==0) type=PNG; if(type==BMP) {mBMPSave(img,filename);return;} uint8_t *data = malloc(img->channel*img->width*img->height); int image_type = DFLT;mPropertyRead(img,"image_type",&image_type); mException((image_type!=MORN_IMAGE_GRAY)&&(image_type!=MORN_IMAGE_RGB)&&(image_type!=MORN_IMAGE_RGBA),EXIT,"invalid image color type"); uint8_t **buff; if(img->channel>=3) {buff=img->data[0];img->data[0]=img->data[2];img->data[2]=buff;} mImageDataOutput(img,data); if(img->channel>=3) {buff=img->data[0];img->data[0]=img->data[2];img->data[2]=buff;} if(type==PNG) stbi_write_png(filename,img->width,img->height,img->channel,data,img->width*img->channel); else if(type==JPG) stbi_write_jpg(filename,img->width,img->height,img->channel,data,100); free(data); }
464cec5ea863ea8463362832e46d679c6df62196
e73547787354afd9b717ea57fe8dd0695d161821
/src/battle/area/kmr_part_3/actor/final_jr_troopa.c
7b5e01411f8cab8ac9d5e8904705768117070345
[]
no_license
pmret/papermario
8b514b19653cef8d6145e47499b3636b8c474a37
9774b26d93f1045dd2a67e502b6efc9599fb6c31
refs/heads/main
2023-08-31T07:09:48.951514
2023-08-21T18:07:08
2023-08-21T18:07:08
287,151,133
904
139
null
2023-09-14T02:44:23
2020-08-13T01:22:57
C
UTF-8
C
false
false
69,853
c
final_jr_troopa.c
#include "../area.h" #include "sprite/npc/JrTroopa.h" #include "sprite/npc/SpikedParaJrTroopa.h" #include "sprite/npc/MageJrTroopa.h" #define NAMESPACE A(final_jr_troopa) // Invalid value used in some scripts here == -91,999,590 // The closest evt variable for this is MapFlag(-1999590), which is way out of range. // Looks like it was supposed to be a value for EVT_FLOAT(), but its likewise out of range. #define INVALID_VAR 0xFA84329A extern EvtScript N(EVS_Init); extern EvtScript N(EVS_Idle); extern EvtScript N(EVS_TakeTurn); extern EvtScript N(EVS_HandleEvent); extern EvtScript N(EVS_HandlePhase); extern EvtScript N(EVS_GetFormAnims); extern EvtScript N(EVS_TryFearReaction); extern EvtScript N(EVS_JrTroopa_Death); extern EvtScript N(EVS_JrTroopa_ReturnHome); extern EvtScript N(EVS_Transform_Flying); extern EvtScript N(EVS_Transform_Mage); extern EvtScript N(EVS_Attack_Leap); extern EvtScript N(EVS_Attack_Swoop); extern EvtScript N(EVS_Attack_SpikeDive); extern EvtScript N(EVS_Attack_MagicSpell); extern EvtScript N(EVS_Attack_LightningBolt); extern EvtScript N(EVS_Move_HealSelf); API_CALLABLE(N(CalculateArcsinDeg)); #include "common/battle/SetAbsoluteStatusOffsets.inc.c" enum N(ActorPartIDs) { PRT_BASE = 1, PRT_FLYING = 2, PRT_MAGE = 3, }; enum N(ActorVars) { AVAR_UnusedBrag = 0, AVAR_SpookReact = 1, AVAL_SpookReact_None = 0, AVAL_SpookReact_Ready = 1, AVAR_DialogueFlags = 2, AVAL_Dialogue_Begin = 1, AVAL_Dialogue_LowHP = 2, AVAR_Form = 3, AVAL_Form_Base = 1, AVAL_Form_Flying = 2, AVAL_Form_Mage = 3, AVAR_HealsLeft = 4, }; enum N(ActorParams) { DMG_LEAP = 8, DMG_SWOOP = 8, DMG_SPIKE_DIVE = 9, DMG_SPELL = 8, DMG_LIGHTNING = 9, }; // keys for getting form-specific anim sets enum { FORM_ANIM_HURT = 0, FORM_ANIM_BURN = 1, FORM_ANIM_FLAIL = 2, FORM_ANIM_TALK = 3, FORM_ANIM_RETURN = 4, FORM_ANIM_IMMUNE = 5, }; s32 N(BaseAnims)[] = { STATUS_KEY_NORMAL, ANIM_JrTroopa_Idle, STATUS_KEY_SLEEP, ANIM_JrTroopa_Sleep, STATUS_KEY_STONE, ANIM_JrTroopa_Still, STATUS_KEY_STOP, ANIM_JrTroopa_Still, STATUS_KEY_PARALYZE, ANIM_JrTroopa_Still, STATUS_KEY_DIZZY, ANIM_JrTroopa_Dizzy, STATUS_END, }; s32 N(FlyingAnims)[] = { STATUS_KEY_NORMAL, ANIM_SpikedParaJrTroopa_Idle, STATUS_KEY_SLEEP, ANIM_SpikedParaJrTroopa_Sleep, STATUS_KEY_STONE, ANIM_SpikedParaJrTroopa_Still, STATUS_KEY_STOP, ANIM_SpikedParaJrTroopa_Still, STATUS_KEY_PARALYZE, ANIM_SpikedParaJrTroopa_Still, STATUS_KEY_DIZZY, ANIM_SpikedParaJrTroopa_Dizzy, STATUS_END, }; s32 N(MageAnims)[] = { STATUS_KEY_NORMAL, ANIM_MageJrTroopa_Idle, STATUS_KEY_SLEEP, ANIM_MageJrTroopa_Sleep, STATUS_KEY_STONE, ANIM_MageJrTroopa_Still, STATUS_KEY_STOP, ANIM_MageJrTroopa_Still, STATUS_KEY_PARALYZE, ANIM_MageJrTroopa_Still, STATUS_KEY_DIZZY, ANIM_MageJrTroopa_Dizzy, STATUS_END, }; s32 N(DefeatedAnims)[] = { STATUS_KEY_NORMAL, ANIM_JrTroopa_Defeated, STATUS_END, }; s32 N(BaseDefenseTable)[] = { ELEMENT_NORMAL, 2, ELEMENT_END, }; s32 N(FlyingDefenseTable)[] = { ELEMENT_NORMAL, 2, ELEMENT_END, }; s32 N(MageDefenseTable)[] = { ELEMENT_NORMAL, 2, ELEMENT_END, }; s32 N(BaseStatusTable)[] = { STATUS_KEY_NORMAL, 100, STATUS_KEY_DEFAULT, 100, STATUS_KEY_SLEEP, 30, STATUS_KEY_POISON, 0, STATUS_KEY_FROZEN, 0, STATUS_KEY_DIZZY, 40, STATUS_KEY_FEAR, 0, STATUS_KEY_STATIC, 0, STATUS_KEY_PARALYZE, 40, STATUS_KEY_SHRINK, 60, STATUS_KEY_STOP, 60, STATUS_TURN_MOD_DEFAULT, 0, STATUS_TURN_MOD_SLEEP, -2, STATUS_TURN_MOD_POISON, 0, STATUS_TURN_MOD_FROZEN, 0, STATUS_TURN_MOD_DIZZY, -2, STATUS_TURN_MOD_FEAR, 0, STATUS_TURN_MOD_STATIC, 0, STATUS_TURN_MOD_PARALYZE, -1, STATUS_TURN_MOD_SHRINK, -1, STATUS_TURN_MOD_STOP, -2, STATUS_END, }; s32 N(FlyingStatusTable)[] = { STATUS_KEY_NORMAL, 100, STATUS_KEY_DEFAULT, 100, STATUS_KEY_SLEEP, 30, STATUS_KEY_POISON, 0, STATUS_KEY_FROZEN, 0, STATUS_KEY_DIZZY, 90, STATUS_KEY_FEAR, 0, STATUS_KEY_STATIC, 0, STATUS_KEY_PARALYZE, 40, STATUS_KEY_SHRINK, 50, STATUS_KEY_STOP, 50, STATUS_TURN_MOD_DEFAULT, 0, STATUS_TURN_MOD_SLEEP, -2, STATUS_TURN_MOD_POISON, 0, STATUS_TURN_MOD_FROZEN, 0, STATUS_TURN_MOD_DIZZY, -1, STATUS_TURN_MOD_FEAR, 0, STATUS_TURN_MOD_STATIC, 0, STATUS_TURN_MOD_PARALYZE, -1, STATUS_TURN_MOD_SHRINK, -1, STATUS_TURN_MOD_STOP, -2, STATUS_END, }; s32 N(MageStatusTable)[] = { STATUS_KEY_NORMAL, 100, STATUS_KEY_DEFAULT, 100, STATUS_KEY_SLEEP, 30, STATUS_KEY_POISON, 0, STATUS_KEY_FROZEN, 0, STATUS_KEY_DIZZY, 40, STATUS_KEY_FEAR, 0, STATUS_KEY_STATIC, 0, STATUS_KEY_PARALYZE, 40, STATUS_KEY_SHRINK, 50, STATUS_KEY_STOP, 50, STATUS_TURN_MOD_DEFAULT, 0, STATUS_TURN_MOD_SLEEP, -2, STATUS_TURN_MOD_POISON, 0, STATUS_TURN_MOD_FROZEN, 0, STATUS_TURN_MOD_DIZZY, -2, STATUS_TURN_MOD_FEAR, 0, STATUS_TURN_MOD_STATIC, 0, STATUS_TURN_MOD_PARALYZE, -1, STATUS_TURN_MOD_SHRINK, -1, STATUS_TURN_MOD_STOP, -2, STATUS_END, }; ActorPartBlueprint N(ActorParts)[] = { { .flags = ACTOR_PART_FLAG_MULTI_TARGET, .index = PRT_BASE, .posOffset = { 0, 0, 0 }, .targetOffset = { 0, 26 }, .opacity = 255, .idleAnimations = N(BaseAnims), .defenseTable = N(BaseDefenseTable), .eventFlags = ACTOR_EVENT_FLAGS_NONE, .elementImmunityFlags = 0, .projectileTargetOffset = { -2, -6 }, }, { .flags = ACTOR_PART_FLAG_INVISIBLE | ACTOR_PART_FLAG_NO_TARGET, .index = PRT_FLYING, .posOffset = { 0, 0, 0 }, .targetOffset = { -5, 32 }, .opacity = 255, .idleAnimations = N(FlyingAnims), .defenseTable = N(FlyingDefenseTable), .eventFlags = ACTOR_EVENT_FLAG_SPIKY_TOP, .elementImmunityFlags = 0, .projectileTargetOffset = { 0, -11 }, }, { .flags = ACTOR_PART_FLAG_INVISIBLE | ACTOR_PART_FLAG_NO_TARGET, .index = PRT_MAGE, .posOffset = { 0, 0, 0 }, .targetOffset = { 0, 28 }, .opacity = 255, .idleAnimations = N(MageAnims), .defenseTable = N(MageDefenseTable), .eventFlags = ACTOR_EVENT_FLAGS_NONE, .elementImmunityFlags = 0, .projectileTargetOffset = { -2, -7 }, }, }; ActorBlueprint NAMESPACE = { .flags = 0, .type = ACTOR_TYPE_JR_TROOPA_6, .level = ACTOR_LEVEL_JR_TROOPA_6, .maxHP = 60, .partCount = ARRAY_COUNT(N(ActorParts)), .partsData = N(ActorParts), .initScript = &N(EVS_Init), .statusTable = N(BaseStatusTable), .escapeChance = 0, .airLiftChance = 0, .hurricaneChance = 0, .spookChance = 0, .upAndAwayChance = 0, .spinSmashReq = 0, .powerBounceChance = 70, .coinReward = 0, .size = { 24, 32 }, .healthBarOffset = { 0, 0 }, .statusIconOffset = { -20, 35 }, .statusTextOffset = { 10, 25 }, }; EvtScript N(EVS_SetupFearReaction) = { EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar2) EVT_IF_FLAG(LVar2, STATUS_FLAGS_IMMOBILIZED) EVT_RETURN EVT_END_IF EVT_CALL(GetBattleFlags, LVar2) EVT_IF_FLAG(LVar2, BS_FLAGS1_PARTNER_ACTING) EVT_CALL(GetMenuSelection, LVar0, LVar1, LVar2) EVT_IF_EQ(LVar2, MOVE_SPOOK) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_SpookReact, AVAL_SpookReact_Ready) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_0263) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 30) EVT_CALL(ShowEmote, 0, EMOTE_QUESTION, -45, 30, EMOTER_POS, LVar0, LVar1, LVar2, 5) EVT_WAIT(30) EVT_END_IF EVT_END_IF EVT_RETURN EVT_END }; EvtScript N(EVS_TransformFX) = { EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_20B9) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar3) EVT_IF_NOT_FLAG(LVar3, STATUS_FLAG_SHRINK) EVT_ADD(LVar1, 16) EVT_ELSE EVT_ADD(LVar1, 6) EVT_END_IF EVT_PLAY_EFFECT(EFFECT_GATHER_ENERGY_PINK, 0, LVar0, LVar1, LVar2, 1, 30, 0) EVT_PLAY_EFFECT(EFFECT_GATHER_ENERGY_PINK, 1, LVar0, LVar1, LVar2, 1, 30, 0) EVT_THREAD EVT_SET(LVar0, 0) EVT_LOOP(32) EVT_WAIT(1) EVT_ADD(LVar0, 45) EVT_CALL(SetActorRotation, ACTOR_SELF, 0, LVar0, 0) EVT_END_LOOP EVT_END_THREAD EVT_WAIT(32) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_JR_TROOPA_TRANSFORM) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 15) EVT_PLAY_EFFECT(EFFECT_ENERGY_ORB_WAVE, 4, LVar0, LVar1, LVar2, 1, 40, 0) EVT_PLAY_EFFECT(EFFECT_WALKING_DUST, 0, LVar0, LVar1, LVar2, -4, 0, 0) EVT_PLAY_EFFECT(EFFECT_WALKING_DUST, 0, LVar0, LVar1, LVar2, -4, 4, 0) EVT_PLAY_EFFECT(EFFECT_WALKING_DUST, 0, LVar0, LVar1, LVar2, 4, 0, 0) EVT_PLAY_EFFECT(EFFECT_WALKING_DUST, 0, LVar0, LVar1, LVar2, 4, 4, 0) EVT_RETURN EVT_END }; EvtScript N(EVS_Cam_FocusOnJrTroopa) = { EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_07) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(SetBattleCamOffsetZ, 38) EVT_CALL(SetBattleCamZoom, 256) EVT_CALL(MoveBattleCamOver, 15) EVT_RETURN EVT_END }; EvtScript N(EVS_Cam_ResetFocus) = { EVT_CALL(EnableBattleStatusBar, TRUE) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MoveBattleCamOver, 12) EVT_RETURN EVT_END }; EvtScript N(EVS_Cam_FocusOnGoompa) = { EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_55) EVT_CALL(MoveBattleCamOver, 30) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_RETURN EVT_END }; s32 N(BaseDefeatedAnims)[] = { STATUS_KEY_NORMAL, ANIM_JrTroopa_Defeated, STATUS_END, }; EvtScript N(EVS_JrTroopa_BaseDeath) = { EVT_SET(LVarA, LVar0) EVT_CALL(HideHealthBar, ACTOR_SELF) EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, LVarA, LVar1) EVT_WAIT(10) EVT_CALL(GetDamageSource, LVar5) EVT_SWITCH(LVar5) EVT_CASE_OR_EQ(DMG_SRC_NEXT_SLAP_LEFT) EVT_CASE_OR_EQ(DMG_SRC_NEXT_FAN_SMACK_LEFT) EVT_CASE_OR_EQ(DMG_SRC_LAST_SLAP_LEFT) EVT_CASE_OR_EQ(DMG_SRC_LAST_FAN_SMACK_LEFT) EVT_CASE_OR_EQ(DMG_SRC_NEXT_SLAP_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_NEXT_FAN_SMACK_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_LAST_SLAP_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_LAST_FAN_SMACK_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_SPIN_SMASH) EVT_END_CASE_GROUP EVT_CASE_DEFAULT EVT_SET(LVar2, 0) EVT_LOOP(24) EVT_CALL(SetActorYaw, ACTOR_SELF, LVar2) EVT_ADD(LVar2, 30) EVT_WAIT(1) EVT_END_LOOP EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_END_SWITCH EVT_LABEL(0) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 10) EVT_ADD(LVar2, 10) EVT_PLAY_EFFECT(EFFECT_BIG_SMOKE_PUFF, LVar0, LVar1, LVar2, 0, 0, 0, 0, 0) EVT_CALL(PlaySound, SOUND_ACTOR_DEATH) EVT_CALL(DropStarPoints, ACTOR_SELF) EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(SetBattleCamZoom, 260) EVT_CALL(SetBattleCamOffsetZ, 15) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 30) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_20E5) EVT_CALL(SetAnimation, ACTOR_SELF, LVarA, ANIM_JrTroopa_Collapse) EVT_WAIT(12) EVT_CALL(SetAnimation, ACTOR_SELF, LVarA, ANIM_JrTroopa_Defeated) EVT_CALL(SetIdleAnimations, ACTOR_SELF, LVarA, EVT_PTR(N(BaseDefeatedAnims))) EVT_WAIT(60) EVT_CALL(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_DMG_APPLY, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_Init) = { EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_UnusedBrag, FALSE) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_DialogueFlags, 0) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_SpookReact, AVAL_SpookReact_None) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_Form, AVAL_Form_Base) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_HealsLeft, 5) EVT_CALL(BindTakeTurn, ACTOR_SELF, EVT_PTR(N(EVS_TakeTurn))) EVT_CALL(BindIdle, ACTOR_SELF, EVT_PTR(N(EVS_Idle))) EVT_CALL(BindHandleEvent, ACTOR_SELF, EVT_PTR(N(EVS_HandleEvent))) EVT_CALL(BindHandlePhase, ACTOR_SELF, EVT_PTR(N(EVS_HandlePhase))) EVT_RETURN EVT_END }; EvtScript N(EVS_Idle) = { EVT_LABEL(0) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVarA) EVT_IF_FLAG(LVarA, STATUS_FLAG_DIZZY | STATUS_FLAG_SLEEP) EVT_CALL(SetTargetOffset, ACTOR_SELF, PRT_FLYING, -15, 28) EVT_CALL(SetProjectileTargetOffset, ACTOR_SELF, PRT_FLYING, 4, -6) EVT_CALL(N(SetAbsoluteStatusOffsets), -25, 27, -1, 27) EVT_ELSE EVT_CALL(SetTargetOffset, ACTOR_SELF, PRT_FLYING, -8, 33) EVT_CALL(SetProjectileTargetOffset, ACTOR_SELF, PRT_FLYING, 0, -6) EVT_CALL(N(SetAbsoluteStatusOffsets), -22, 30, 2, 28) EVT_END_IF EVT_CASE_DEFAULT EVT_CALL(N(SetAbsoluteStatusOffsets), -20, 35, 10, 25) EVT_END_SWITCH EVT_WAIT(1) EVT_GOTO(0) EVT_RETURN EVT_END }; EvtScript N(EVS_HandleEvent) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(GetLastEvent, ACTOR_SELF, LVarA) EVT_SWITCH(LVarA) EVT_CASE_EQ(EVENT_HIT_COMBO) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_Hit) EVT_CASE_EQ(EVENT_HIT) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_Hit) EVT_EXEC_WAIT(N(EVS_SetupFearReaction)) EVT_EXEC_WAIT(N(EVS_TryFearReaction)) EVT_CASE_EQ(EVENT_DEATH) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_Hit) EVT_WAIT(10) EVT_EXEC_WAIT(N(EVS_JrTroopa_Death)) EVT_RETURN EVT_CASE_EQ(EVENT_BURN_HIT) EVT_SET(LVar1, FORM_ANIM_BURN) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_BurnHit) EVT_CASE_EQ(EVENT_BURN_DEATH) EVT_SET(LVar1, FORM_ANIM_BURN) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_BurnHit) EVT_WAIT(10) EVT_EXEC_WAIT(N(EVS_JrTroopa_Death)) EVT_RETURN EVT_CASE_EQ(EVENT_SPIN_SMASH_HIT) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_SpinSmashHit) EVT_CASE_EQ(EVENT_SPIN_SMASH_DEATH) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_SpinSmashHit) EVT_EXEC_WAIT(N(EVS_JrTroopa_Death)) EVT_RETURN EVT_CASE_EQ(EVENT_SHOCK_HIT) EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_CALL(SetPartRotationOffset, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_ShockHit) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_JumpBack) EVT_EXEC_WAIT(N(EVS_JrTroopa_ReturnHome)) EVT_CASE_EQ(EVENT_SHOCK_DEATH) EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_CALL(SetPartRotationOffset, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_ShockHit) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_JumpBack) EVT_EXEC_WAIT(N(EVS_JrTroopa_Death)) EVT_RETURN EVT_CASE_EQ(EVENT_ZERO_DAMAGE) EVT_SET(LVar1, FORM_ANIM_IMMUNE) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_NoDamageHit) EVT_CASE_EQ(EVENT_IMMUNE) EVT_SET(LVar1, FORM_ANIM_IMMUNE) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_NoDamageHit) EVT_EXEC_WAIT(N(EVS_SetupFearReaction)) EVT_EXEC_WAIT(N(EVS_TryFearReaction)) EVT_CASE_EQ(EVENT_SPIKE_TAUNT) EVT_WAIT(10) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar3) EVT_SWITCH(LVar3) EVT_CASE_FLAG(STATUS_FLAG_DIZZY | STATUS_FLAG_SLEEP) EVT_ADD(LVar0, -13) EVT_ADD(LVar1, 37) EVT_CASE_FLAG(STATUS_FLAG_SHRINK) EVT_ADD(LVar0, -1) EVT_ADD(LVar1, 14) EVT_CASE_DEFAULT EVT_ADD(LVar0, -4) EVT_ADD(LVar1, 37) EVT_END_SWITCH EVT_PLAY_EFFECT(EFFECT_LENS_FLARE, 0, LVar0, LVar1, LVar2, 20, 0) EVT_WAIT(20) EVT_CASE_EQ(EVENT_BEGIN_AIR_LIFT) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAGS_IMMOBILIZED) EVT_SET(LVar1, FORM_ANIM_FLAIL) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_CALL(SetAnimation, ACTOR_SELF, LVar0, LVar1) EVT_WAIT(1000) EVT_END_IF EVT_CASE_EQ(EVENT_AIR_LIFT_FAILED) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAGS_IMMOBILIZED) EVT_SET(LVar1, FORM_ANIM_IMMUNE) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_CALL(SetAnimation, ACTOR_SELF, LVar0, LVar1) EVT_WAIT(20) EVT_EXEC_WAIT(N(EVS_Cam_FocusOnJrTroopa)) EVT_SET(LVar1, FORM_ANIM_TALK) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_CALL(SetAnimation, ACTOR_SELF, LVar0, LVar1) EVT_CALL(ActorSpeak, MSG_Menus_019B, ACTOR_SELF, LVar0, -1, -1) EVT_EXEC_WAIT(N(EVS_Cam_ResetFocus)) EVT_END_IF EVT_CASE_EQ(EVENT_SPIKE_CONTACT) EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_Hit) EVT_CASE_EQ(EVENT_END_FIRST_STRIKE) EVT_EXEC_WAIT(N(EVS_JrTroopa_ReturnHome)) EVT_CALL(HPBarToHome, ACTOR_SELF) EVT_CASE_EQ(EVENT_RECOVER_STATUS) EVT_SET_CONST(LVar0, PRT_BASE) EVT_SET_CONST(LVar1, ANIM_JrTroopa_Idle) EVT_EXEC_WAIT(EVS_Enemy_Recover) EVT_CASE_DEFAULT EVT_END_SWITCH EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_TakeTurn) = { EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_IF_NE(LVar0, AVAL_Form_Mage) EVT_CALL(GetActorHP, ACTOR_SELF, LVar1) EVT_CALL(GetEnemyMaxHP, ACTOR_SELF, LVar2) EVT_MUL(LVar1, 100) EVT_DIV(LVar1, LVar2) EVT_IF_EQ(LVar0, AVAL_Form_Base) EVT_IF_LT(LVar1, 65) EVT_EXEC_WAIT(N(EVS_Transform_Flying)) EVT_END_IF EVT_ELSE EVT_IF_LT(LVar1, 35) EVT_EXEC_WAIT(N(EVS_Transform_Mage)) EVT_END_IF EVT_END_IF EVT_END_IF EVT_CALL(GetActorHP, ACTOR_SELF, LVar0) EVT_IF_LT(LVar0, 15) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_DialogueFlags, LVar0) EVT_IF_NOT_FLAG(LVar0, AVAL_Dialogue_LowHP) EVT_BITWISE_OR_CONST(LVar0, AVAL_Dialogue_LowHP) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_DialogueFlags, LVar0) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Talk) EVT_CASE_EQ(AVAL_Form_Mage) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_Talk) EVT_CASE_DEFAULT EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Talk) EVT_END_SWITCH EVT_CALL(ActorSpeak, MSG_CH8_0060, ACTOR_SELF, PRT_BASE, -1, -1) EVT_END_IF EVT_END_IF EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_CALL(RandInt, 100, LVar0) EVT_IF_LT(LVar0, 50) EVT_EXEC_WAIT(N(EVS_Attack_Swoop)) EVT_ELSE EVT_EXEC_WAIT(N(EVS_Attack_SpikeDive)) EVT_END_IF EVT_CASE_EQ(AVAL_Form_Mage) EVT_CALL(RandInt, 100, LVar0) EVT_SWITCH(LVar0) EVT_CASE_LT(60) EVT_EXEC_WAIT(N(EVS_Attack_MagicSpell)) EVT_CASE_LT(80) EVT_EXEC_WAIT(N(EVS_Attack_LightningBolt)) EVT_CASE_DEFAULT EVT_CALL(GetActorHP, ACTOR_SELF, LVar0) EVT_CALL(GetEnemyMaxHP, ACTOR_SELF, LVar1) EVT_IF_NE(LVar0, LVar1) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_HealsLeft, LVar2) EVT_IF_GT(LVar2, 0) EVT_SUB(LVar2, 1) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_HealsLeft, LVar2) EVT_EXEC_WAIT(N(EVS_Move_HealSelf)) EVT_ELSE EVT_EXEC_WAIT(N(EVS_Attack_MagicSpell)) EVT_END_IF EVT_ELSE EVT_EXEC_WAIT(N(EVS_Attack_MagicSpell)) EVT_END_IF EVT_END_SWITCH EVT_CASE_DEFAULT EVT_EXEC_WAIT(N(EVS_Attack_Leap)) EVT_END_SWITCH EVT_RETURN EVT_END }; EvtScript N(EVS_Transform_Flying) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(ActorSpeak, MSG_CH8_005E, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_TiredTalk, ANIM_JrTroopa_TiredTalk) EVT_EXEC_WAIT(N(EVS_TransformFX)) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_BASE, ACTOR_PART_FLAG_NO_TARGET | ACTOR_PART_FLAG_INVISIBLE, TRUE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_BASE, ACTOR_PART_FLAG_MULTI_TARGET, FALSE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_FLYING, ACTOR_PART_FLAG_NO_TARGET | ACTOR_PART_FLAG_INVISIBLE, FALSE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_FLYING, ACTOR_PART_FLAG_MULTI_TARGET, TRUE) EVT_WAIT(10) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(2.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.2)) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(AddGoalPos, ACTOR_SELF, 20, 60, 0) EVT_CALL(FlyToGoal, ACTOR_SELF, 30, 0, EASING_LINEAR) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(ForceHomePos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(HPBarToHome, ACTOR_SELF) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_Form, AVAL_Form_Flying) EVT_CALL(SetStatusTable, ACTOR_SELF, EVT_PTR(N(FlyingStatusTable))) EVT_CALL(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_FLYING, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_Transform_Mage) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(ActorSpeak, MSG_CH8_005F, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Talk, ANIM_SpikedParaJrTroopa_Talk) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MoveBattleCamOver, 120) EVT_EXEC_WAIT(N(EVS_TransformFX)) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_FLYING, ACTOR_PART_FLAG_NO_TARGET | ACTOR_PART_FLAG_INVISIBLE, TRUE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_FLYING, ACTOR_PART_FLAG_MULTI_TARGET, FALSE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_MAGE, ACTOR_PART_FLAG_NO_TARGET | ACTOR_PART_FLAG_INVISIBLE, FALSE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_MAGE, ACTOR_PART_FLAG_MULTI_TARGET, TRUE) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(2.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(0.8)) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 20) EVT_SET(LVar1, 0) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(FallToGoal, ACTOR_SELF, 10) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(ForceHomePos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(HPBarToHome, ACTOR_SELF) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_Form, AVAL_Form_Mage) EVT_CALL(SetStatusTable, ACTOR_SELF, EVT_PTR(N(MageStatusTable))) EVT_CALL(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_FLYING, FALSE) EVT_RETURN EVT_END }; EvtScript N(EVS_Attack_Leap) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(UseBattleCamPreset, BTL_CAM_ENEMY_APPROACH) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(func_8024ECF8, BTL_CAM_MODEY_MINUS_1, BTL_CAM_MODEX_1, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Run) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(5.0)) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SET(LVar0, 20) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, 0, LVar2) EVT_CALL(RunToGoal, ACTOR_SELF, 0, FALSE) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVarF, 0, 0, 8, BS_FLAGS1_10) EVT_SWITCH(LVarF) EVT_CASE_EQ(HIT_RESULT_LUCKY) EVT_THREAD EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Charge) EVT_WAIT(5) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_ChargeTripped) EVT_END_THREAD EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(3.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(0.5)) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 30) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 10, FALSE, TRUE, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Trip) EVT_THREAD EVT_WAIT(3) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Defeated) EVT_END_THREAD EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(3.0)) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVar0, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 20) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(FlyToGoal, ACTOR_SELF, 16, 0, EASING_CUBIC_OUT) EVT_WAIT(10) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(SetActorYaw, ACTOR_SELF, 180) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_ChargeArmsUp) EVT_CALL(SetActorYaw, ACTOR_SELF, 180) EVT_CALL(AddActorDecoration, ACTOR_SELF, PRT_BASE, 0, ACTOR_DECORATION_SWEAT) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(7.0)) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(RunToGoal, ACTOR_SELF, 0, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Idle) EVT_CALL(RemoveActorDecoration, ACTOR_SELF, PRT_BASE, 0) EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_CASE_EQ(HIT_RESULT_MISS) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Run) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(6.0)) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, 50) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, 0, LVar2) EVT_CALL(RunToGoal, ACTOR_SELF, 0, FALSE) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP, SOUND_20E2, 0) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Jump) EVT_WAIT(2) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Midair) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.6)) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 10) EVT_SET(LVar1, 0) EVT_ADD(LVar2, 3) EVT_THREAD EVT_WAIT(8) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Fall) EVT_END_THREAD EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 18, FALSE, TRUE, FALSE) EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_PanicFast) EVT_SUB(LVar0, 20) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 8, FALSE, TRUE, FALSE) EVT_SUB(LVar0, 10) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 5, FALSE, TRUE, FALSE) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Run) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(7.0)) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(RunToGoal, ACTOR_SELF, 0, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Idle) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END_SWITCH EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Run) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(6.0)) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, 50) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, 0, LVar2) EVT_CALL(RunToGoal, ACTOR_SELF, 0, FALSE) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP, SOUND_20E2, 0) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Jump) EVT_WAIT(2) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.6)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Midair) EVT_THREAD EVT_WAIT(8) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Fall) EVT_END_THREAD EVT_CALL(JumpToGoal, ACTOR_SELF, 15, FALSE, TRUE, FALSE) EVT_WAIT(2) EVT_CALL(EnemyDamageTarget, ACTOR_SELF, LVarF, 0, 0, 0, DMG_LEAP, BS_FLAGS1_SP_EVT_ACTIVE) EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, 40) EVT_SET(LVar1, 0) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.8)) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 10, FALSE, TRUE, FALSE) EVT_ADD(LVar0, 30) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 8, FALSE, TRUE, FALSE) EVT_ADD(LVar0, 20) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 6, FALSE, TRUE, FALSE) EVT_SUB(LVar0, 10) EVT_CALL(JumpToGoal, ACTOR_SELF, 4, FALSE, TRUE, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Idle) EVT_WAIT(8) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(7.0)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Run) EVT_CALL(RunToGoal, ACTOR_SELF, 0, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Idle) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_Attack_Swoop) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(UseBattleCamPreset, BTL_CAM_ENEMY_APPROACH) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(func_8024ECF8, BTL_CAM_MODEY_MINUS_1, BTL_CAM_MODEX_1, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(AddGoalPos, ACTOR_SELF, 50, 0, 0) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(6.0)) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -4, EASING_LINEAR) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVarA, 0, 0, 6, BS_FLAGS1_10) EVT_SWITCH(LVarA) EVT_CASE_OR_EQ(HIT_RESULT_MISS) EVT_CASE_OR_EQ(HIT_RESULT_LUCKY) EVT_WAIT(10) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_66) EVT_CALL(func_8024ECF8, BTL_CAM_MODEY_MINUS_1, BTL_CAM_MODEX_1, FALSE) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP, SOUND_PARAGOOMBA_PREDIVE, 0) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(5.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.8)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 10, FALSE, TRUE, FALSE) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_FLY, SOUND_NONE, SOUND_NONE) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_PARAGOOMBA_DIVE) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_SUB(LVar0, 80) EVT_SET(LVar1, 20) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(8.0)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Dive) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -10, EASING_LINEAR) EVT_IF_EQ(LVarA, HIT_RESULT_LUCKY) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVar0, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0) EVT_END_IF EVT_WAIT(10) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(SetActorYaw, ACTOR_SELF, 180) EVT_CALL(AddActorDecoration, ACTOR_SELF, PRT_BASE, 0, ACTOR_DECORATION_SWEAT) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(6.0)) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, 1, EASING_LINEAR) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Idle) EVT_CALL(RemoveActorDecoration, ACTOR_SELF, PRT_BASE, 0) EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_RETURN EVT_END_CASE_GROUP EVT_CASE_DEFAULT EVT_END_SWITCH EVT_WAIT(10) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_66) EVT_CALL(func_8024ECF8, BTL_CAM_MODEY_MINUS_1, BTL_CAM_MODEX_1, FALSE) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP, SOUND_PARAGOOMBA_PREDIVE, 0) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(5.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.8)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 10, FALSE, TRUE, FALSE) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_FLY, SOUND_NONE, SOUND_NONE) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_PARAGOOMBA_DIVE) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(8.0)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Dive) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -10, EASING_LINEAR) EVT_WAIT(2) EVT_CALL(EnemyDamageTarget, ACTOR_SELF, LVar0, 0, 0, 0, DMG_SWOOP, BS_FLAGS1_SP_EVT_ACTIVE) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(AddGoalPos, ACTOR_SELF, 50, 10, 0) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(4.0)) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -10, EASING_LINEAR) EVT_WAIT(10) EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_CALL(YieldTurn) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(6.0)) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, 1, EASING_LINEAR) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Idle) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_Attack_SpikeDive) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 20) EVT_WAIT(20) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_CLOSE_SHELL) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_EnterEgg) EVT_WAIT(10) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_EggIdle) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MoveBattleCamOver, 20) EVT_WAIT(10) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_PARAGOOMBA_DIVE) EVT_CALL(SetActorSounds, ACTOR_SELF, ACTOR_SOUND_JUMP, SOUND_NONE, 0) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVarF, 0, 0, 6, BS_FLAGS1_10) EVT_SWITCH(LVarF) EVT_CASE_OR_EQ(HIT_RESULT_MISS) EVT_CASE_OR_EQ(HIT_RESULT_LUCKY) EVT_THREAD EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(4.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.0)) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 10) EVT_SET(LVar1, 12) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(JumpToGoal, ACTOR_SELF, 20, FALSE, TRUE, FALSE) EVT_END_THREAD EVT_SET(LVar0, 0) EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_LOOP(20) EVT_CALL(GetActorPos, ACTOR_SELF, LVar4, LVar5, LVar6) EVT_CALL(N(CalculateArcsinDeg), LVar1, LVar2, LVar4, LVar5, LVar0) EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, LVar0) EVT_SET(LVar1, LVar4) EVT_SET(LVar2, LVar5) EVT_SET(LVar3, LVar6) EVT_WAIT(1) EVT_END_LOOP EVT_IF_EQ(LVarF, HIT_RESULT_LUCKY) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVarF, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0) EVT_END_IF EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_SUB(LVar1, 40) EVT_SET(LVar2, 10) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_CALL(JumpToGoal, ACTOR_SELF, 14, FALSE, TRUE, FALSE) EVT_END_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_LOOP(14) EVT_CALL(GetActorPos, ACTOR_SELF, LVar4, LVar5, LVar6) EVT_CALL(N(CalculateArcsinDeg), LVar1, LVar2, LVar4, LVar5, LVar0) EVT_SET(LVar7, LVar0) EVT_ADD(LVar7, 180) EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, LVar7) EVT_SET(LVar1, LVar4) EVT_SET(LVar2, LVar5) EVT_SET(LVar3, LVar6) EVT_WAIT(1) EVT_END_LOOP EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_CALL(SetPartRotationOffset, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_OPEN_SHELL) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_ExitEgg) EVT_WAIT(10) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(SetActorYaw, ACTOR_SELF, 180) EVT_CALL(AddActorDecoration, ACTOR_SELF, PRT_FLYING, 0, ACTOR_DECORATION_SWEAT) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(8.0)) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -5, EASING_LINEAR) EVT_CALL(RemoveActorDecoration, ACTOR_SELF, PRT_FLYING, 0) EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END_CASE_GROUP EVT_CASE_DEFAULT EVT_END_SWITCH EVT_CALL(SetPartRotationOffset, ACTOR_SELF, PRT_FLYING, 0, 12, 0) EVT_THREAD EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(4.0)) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.0)) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(JumpToGoal, ACTOR_SELF, 20, FALSE, TRUE, FALSE) EVT_END_THREAD EVT_SET(LVar0, 0) EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_LOOP(20) EVT_CALL(GetActorPos, ACTOR_SELF, LVar4, LVar5, LVar6) EVT_CALL(N(CalculateArcsinDeg), LVar1, LVar2, LVar4, LVar5, LVar0) EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, LVar0) EVT_SET(LVar1, LVar4) EVT_SET(LVar2, LVar5) EVT_SET(LVar3, LVar6) EVT_WAIT(1) EVT_END_LOOP EVT_WAIT(2) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(EnemyDamageTarget, ACTOR_SELF, LVarF, 0, 0, 0, DMG_SPIKE_DIVE, BS_FLAGS1_SP_EVT_ACTIVE) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_ADD(LVar1, 40) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_CALL(JumpToGoal, ACTOR_SELF, 14, FALSE, TRUE, FALSE) EVT_END_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_LOOP(14) EVT_CALL(GetActorPos, ACTOR_SELF, LVar4, LVar5, LVar6) EVT_CALL(N(CalculateArcsinDeg), LVar1, LVar2, LVar4, LVar5, LVar0) EVT_SET(LVar7, LVar0) EVT_ADD(LVar7, 180) EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, LVar7) EVT_SET(LVar1, LVar4) EVT_SET(LVar2, LVar5) EVT_SET(LVar3, LVar6) EVT_WAIT(1) EVT_END_LOOP EVT_CALL(SetPartRotation, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_CALL(SetPartRotationOffset, ACTOR_SELF, PRT_FLYING, 0, 0, 0) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_OPEN_SHELL) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_ExitEgg) EVT_WAIT(10) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(8.0)) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -5, EASING_LINEAR) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; #include "common/CalculateArcsinDeg.inc.c" EvtScript N(EVS_Attack_MagicSpell) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_RaiseStaff) EVT_WAIT(8) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_SPELL_CAST1) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAG_SHRINK) EVT_SET(LVar3, 0) EVT_SET(LVar4, 36) EVT_SETF(LVar5, EVT_FLOAT(1.0)) EVT_ELSE EVT_SET(LVar3, 0) EVT_SET(LVar4, 14) EVT_SETF(LVar5, INVALID_VAR) EVT_END_IF EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, LVar3) EVT_ADD(LVar1, LVar4) EVT_PLAY_EFFECT(EFFECT_GATHER_ENERGY_PINK, 0, LVar0, LVar1, LVar2, LVar5, 30, 0) EVT_WAIT(30) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_SwingStaff) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVarA, DAMAGE_TYPE_NO_CONTACT, 0, 1, BS_FLAGS1_10) EVT_SWITCH(LVarA) EVT_CASE_EQ(HIT_RESULT_MISS) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_SPELL_CAST2) EVT_CALL(GetActorPos, ACTOR_PLAYER, LVar3, LVar4, LVar5) EVT_SUB(LVar3, 120) EVT_ADD(LVar4, 20) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAG_SHRINK) EVT_SET(LVar6, -8) EVT_SET(LVar7, 20) EVT_SETF(LVar8, EVT_FLOAT(1.0)) EVT_ELSE EVT_SET(LVar6, -3) EVT_SET(LVar7, 8) EVT_SETF(LVar8, INVALID_VAR) EVT_END_IF EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, LVar6) EVT_ADD(LVar1, LVar7) EVT_PLAY_EFFECT(EFFECT_SHAPE_SPELL, 0, LVar0, LVar1, LVar2, LVar3, LVar4, LVar5, 30, 0) EVT_WAIT(35) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_CASE_EQ(HIT_RESULT_LUCKY) EVT_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 12) EVT_PLAY_EFFECT(EFFECT_BLAST, 0, LVar0, LVar1, LVar2, EVT_FLOAT(3.0), 30, 0) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_BurnStaff) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_WAIT(40) EVT_SUB(LVar0, 7) EVT_ADD(LVar1, 14) EVT_ADD(LVar2, 4) EVT_PLAY_EFFECT(EFFECT_WALKING_DUST, 2, LVar0, LVar1, LVar2, 0, 0, 0) EVT_WAIT(20) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_Idle) EVT_END_THREAD EVT_WAIT(20) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVar0, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0) EVT_WAIT(40) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END_SWITCH EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_SPELL_CAST2) EVT_CALL(GetActorPos, ACTOR_PLAYER, LVar3, LVar4, LVar5) EVT_ADD(LVar4, 20) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAG_SHRINK) EVT_SET(LVar6, -8) EVT_SET(LVar7, 20) EVT_SETF(LVar8, EVT_FLOAT(1.0)) EVT_ELSE EVT_SET(LVar6, -3) EVT_SET(LVar7, 8) EVT_SETF(LVar8, INVALID_VAR) EVT_END_IF EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, LVar6) EVT_ADD(LVar1, LVar7) EVT_PLAY_EFFECT(EFFECT_SHAPE_SPELL, 0, LVar0, LVar1, LVar2, LVar3, LVar4, LVar5, 15, 0) EVT_WAIT(15) EVT_CALL(EnemyDamageTarget, ACTOR_SELF, LVar0, (DAMAGE_TYPE_MAGIC | DAMAGE_TYPE_NO_CONTACT), 0, 0, DMG_SPELL, BS_FLAGS1_SP_EVT_ACTIVE) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; #include "common/Dist3D.inc.c" // Not used? #include "common/UnkBackgroundFunc3.inc.c" #include "common/SetBackgroundAlpha.inc.c" EvtScript N(EVS_Attack_LightningBolt) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_RaiseStaff) EVT_WAIT(8) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_SPELL_CAST1) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAG_SHRINK) EVT_SET(LVar3, 0) EVT_SET(LVar4, 36) EVT_SETF(LVar5, EVT_FLOAT(1.0)) EVT_ELSE EVT_SET(LVar3, 0) EVT_SET(LVar4, 14) EVT_SETF(LVar5, INVALID_VAR) EVT_END_IF EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, LVar3) EVT_ADD(LVar1, LVar4) EVT_PLAY_EFFECT(EFFECT_GATHER_ENERGY_PINK, 0, LVar0, LVar1, LVar2, LVar5, 30, 0) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MoveBattleCamOver, 60) EVT_WAIT(30) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_BIG_POWER_UP) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_SwingStaff) EVT_CALL(N(UnkBackgroundFunc3)) EVT_CALL(MakeLerp, 0, 200, 60, EASING_COS_IN_OUT) EVT_LABEL(0) EVT_CALL(UpdateLerp) EVT_CALL(N(SetBackgroundAlpha), LVar0) EVT_WAIT(1) EVT_IF_EQ(LVar1, 1) EVT_GOTO(0) EVT_END_IF EVT_CALL(GetActorPos, ACTOR_PLAYER, LVar0, LVar1, LVar2) EVT_CALL(RandInt, 40, LVar1) EVT_ADD(LVar0, LVar1) EVT_ADD(LVar0, 50) EVT_SET(LVar1, 200) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_LIGHTNING_STRIKE) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVarA, DAMAGE_TYPE_NO_CONTACT, 0, 1, BS_FLAGS1_10) EVT_SWITCH(LVarA) EVT_CASE_EQ(HIT_RESULT_MISS) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar3, 0, LVar5) EVT_PLAY_EFFECT(EFFECT_LIGHTNING_BOLT, 0, LVar0, LVar1, LVar2, LVar3, LVar4, LVar5, EVT_FLOAT(1.0), 18, 0) EVT_WAIT(20) EVT_CALL(MakeLerp, 200, 0, 60, EASING_LINEAR) EVT_LABEL(2) EVT_CALL(UpdateLerp) EVT_CALL(N(SetBackgroundAlpha), LVar0) EVT_WAIT(1) EVT_IF_EQ(LVar1, 1) EVT_GOTO(2) EVT_END_IF EVT_WAIT(20) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_CASE_EQ(HIT_RESULT_LUCKY) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_CALL(RandInt, 40, LVar1) EVT_SUB(LVar0, LVar1) EVT_SET(LVar1, 200) EVT_CALL(GetActorPos, ACTOR_SELF, LVar3, LVar4, LVar5) EVT_PLAY_EFFECT(EFFECT_LIGHTNING_BOLT, 0, LVar0, LVar1, LVar2, LVar3, 0, LVar5, EVT_FLOAT(1.0), 18, 0) EVT_THREAD EVT_WAIT(10) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 12) EVT_PLAY_EFFECT(EFFECT_BLAST, 0, LVar0, LVar1, LVar2, EVT_FLOAT(3.0), 30, 0) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_BurnStaff) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_WAIT(40) EVT_SUB(LVar0, 7) EVT_ADD(LVar1, 14) EVT_ADD(LVar2, 4) EVT_PLAY_EFFECT(EFFECT_WALKING_DUST, 2, LVar0, LVar1, LVar2, 0, 0, 0) EVT_WAIT(20) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_Idle) EVT_END_THREAD EVT_WAIT(20) EVT_IF_EQ(LVarA, HIT_RESULT_LUCKY) EVT_CALL(EnemyTestTarget, ACTOR_SELF, LVar0, DAMAGE_TYPE_TRIGGER_LUCKY, 0, 0, 0) EVT_END_IF EVT_CALL(MakeLerp, 200, 0, 60, EASING_LINEAR) EVT_LABEL(2) EVT_CALL(UpdateLerp) EVT_CALL(N(SetBackgroundAlpha), LVar0) EVT_WAIT(1) EVT_IF_EQ(LVar1, 1) EVT_GOTO(2) EVT_END_IF EVT_WAIT(20) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END_SWITCH EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(GetGoalPos, ACTOR_SELF, LVar3, 0, LVar5) EVT_PLAY_EFFECT(EFFECT_LIGHTNING_BOLT, 0, LVar0, LVar1, LVar2, LVar3, LVar4, LVar5, EVT_FLOAT(1.0), 18, 0) EVT_WAIT(14) EVT_CALL(EnemyDamageTarget, ACTOR_SELF, LVar0, (DAMAGE_TYPE_MAGIC | DAMAGE_TYPE_SHOCK | DAMAGE_TYPE_NO_CONTACT), 0, SUPPRESS_EVENT_FLAG_10000, DMG_LIGHTNING, BS_FLAGS1_SP_EVT_ACTIVE) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(MakeLerp, 200, 0, 60, EASING_LINEAR) EVT_LABEL(2) EVT_CALL(UpdateLerp) EVT_CALL(N(SetBackgroundAlpha), LVar0) EVT_WAIT(1) EVT_IF_EQ(LVar1, 1) EVT_GOTO(2) EVT_END_IF EVT_WAIT(20) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_Move_HealSelf) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(SetTargetActor, ACTOR_SELF, ACTOR_PLAYER) EVT_CALL(SetGoalToTarget, ACTOR_SELF) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 30) EVT_WAIT(30) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_RaiseStaff) EVT_WAIT(8) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_SPELL_CAST1) EVT_CALL(GetStatusFlags, ACTOR_SELF, LVar0) EVT_IF_NOT_FLAG(LVar0, STATUS_FLAG_SHRINK) EVT_SET(LVar3, 0) EVT_SET(LVar4, 36) EVT_SETF(LVar5, EVT_FLOAT(1.0)) EVT_ELSE EVT_SET(LVar3, 0) EVT_SET(LVar4, 14) EVT_SETF(LVar5, INVALID_VAR) EVT_END_IF EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar0, LVar3) EVT_ADD(LVar1, LVar4) EVT_PLAY_EFFECT(EFFECT_GATHER_ENERGY_PINK, 0, LVar0, LVar1, LVar2, LVar5, 30, 0) EVT_WAIT(30) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_02F8) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_HEART_BOUNCE) EVT_CALL(GetActorPos, ACTOR_SELF, LVar1, LVar2, LVar3) EVT_ADD(LVar2, 50) EVT_PLAY_EFFECT(EFFECT_SPARKLES, 1, LVar1, LVar2, LVar3, 10, 0) EVT_PLAY_EFFECT(EFFECT_RECOVER, 2, LVar1, LVar2, LVar3, 0, 0) EVT_WAIT(30) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_Idle) EVT_WAIT(10) EVT_CALL(GetEnemyMaxHP, ACTOR_SELF, LVar0) EVT_MUL(LVar0, 17) EVT_DIV(LVar0, 100) EVT_THREAD EVT_WAIT(5) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_206D) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_HEART_BOUNCE) EVT_WAIT(30) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_STAR_BOUNCE_A) EVT_END_THREAD EVT_THREAD EVT_CALL(FreezeBattleState, TRUE) EVT_CALL(HealActor, ACTOR_SELF, LVar0, FALSE) EVT_CALL(FreezeBattleState, FALSE) EVT_END_THREAD EVT_WAIT(30) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_HandlePhase) = { EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_DISABLE) EVT_CALL(GetBattlePhase, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(PHASE_PLAYER_BEGIN) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_DialogueFlags, LVar0) EVT_IF_NOT_FLAG(LVar0, AVAL_Dialogue_Begin) EVT_BITWISE_OR_CONST(LVar0, AVAL_Dialogue_Begin) EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_DialogueFlags, LVar0) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 20) EVT_CALL(ActorSpeak, MSG_CH8_005D, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_PointTalk, ANIM_JrTroopa_PointTalk) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Idle) EVT_END_IF EVT_CASE_EQ(PHASE_ENEMY_BEGIN) EVT_CASE_EQ(PHASE_ENEMY_END) EVT_CASE_EQ(PHASE_PLAYER_BEGIN) //@bug duplicate case, should be PHASE_PLAYER_END EVT_END_SWITCH EVT_CALL(EnableIdleScript, ACTOR_SELF, IDLE_SCRIPT_ENABLE) EVT_CALL(UseIdleAnimation, ACTOR_SELF, TRUE) EVT_RETURN EVT_END }; EvtScript N(EVS_GetFormAnims) = { EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar1) EVT_CASE_EQ(FORM_ANIM_HURT) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, ANIM_SpikedParaJrTroopa_Hurt) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, ANIM_MageJrTroopa_Hurt) EVT_CASE_DEFAULT EVT_SET(LVar1, ANIM_JrTroopa_Hurt) EVT_END_SWITCH EVT_CASE_EQ(FORM_ANIM_BURN) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, ANIM_SpikedParaJrTroopa_BurnHurt) EVT_SET(LVar2, ANIM_SpikedParaJrTroopa_BurnStill) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, ANIM_MageJrTroopa_BurnHurt) EVT_SET(LVar2, ANIM_MageJrTroopa_BurnStill) EVT_CASE_DEFAULT EVT_SET(LVar1, ANIM_JrTroopa_BurnHurt) EVT_SET(LVar2, ANIM_JrTroopa_BurnStill) EVT_END_SWITCH EVT_CASE_EQ(FORM_ANIM_FLAIL) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, ANIM_SpikedParaJrTroopa_Flail) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, ANIM_MageJrTroopa_Flail) EVT_CASE_DEFAULT EVT_SET(LVar1, ANIM_JrTroopa_Flail) EVT_END_SWITCH EVT_CASE_EQ(FORM_ANIM_TALK) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, ANIM_SpikedParaJrTroopa_Talk) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, ANIM_MageJrTroopa_Talk) EVT_CASE_DEFAULT EVT_SET(LVar1, ANIM_JrTroopa_Talk) EVT_END_SWITCH EVT_CASE_EQ(FORM_ANIM_RETURN) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, ANIM_SpikedParaJrTroopa_FlyFast) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, ANIM_MageJrTroopa_Run) EVT_CASE_DEFAULT EVT_SET(LVar1, ANIM_JrTroopa_Run) EVT_END_SWITCH EVT_CASE_DEFAULT EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, ANIM_SpikedParaJrTroopa_Idle) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, ANIM_MageJrTroopa_Idle) EVT_CASE_DEFAULT EVT_SET(LVar1, ANIM_JrTroopa_Idle) EVT_END_SWITCH EVT_END_SWITCH EVT_RETURN EVT_END }; EvtScript N(EVS_JrTroopa_Death) = { EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_CALL(UseBattleCamPreset, BTL_CAM_DEFAULT) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_IF_EQ(LVar1, 0) EVT_GOTO(0) EVT_END_IF EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_FALL_QUICK) EVT_CALL(HideHealthBar, ACTOR_SELF) EVT_CALL(SetGoalPos, ACTOR_SELF, LVar0, 0, LVar2) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(1.2)) EVT_CALL(FallToGoal, ACTOR_SELF, 10) EVT_CALL(SetActorJumpGravity, ACTOR_SELF, EVT_FLOAT(0.8)) EVT_CALL(JumpToGoal, ACTOR_SELF, 8, FALSE, TRUE, FALSE) EVT_CALL(HPBarToCurrent, ACTOR_SELF) EVT_CALL(ShowHealthBar, ACTOR_SELF) EVT_LABEL(0) EVT_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 10) EVT_ADD(LVar2, 10) EVT_LOOP(3) EVT_PLAY_EFFECT(EFFECT_BIG_SMOKE_PUFF, LVar0, LVar1, LVar2, 0, 0, 0, 0, 0) EVT_WAIT(3) EVT_END_LOOP EVT_END_THREAD EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_FLYING, ACTOR_PART_FLAG_INVISIBLE, TRUE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_BASE, ACTOR_PART_FLAG_INVISIBLE, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_DefeatedBegin) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 5) EVT_CALL(SetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_WAIT(15) EVT_CALL(PlaySound, SOUND_ACTOR_DEATH) EVT_CALL(DropStarPoints, ACTOR_SELF) EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(SetBattleCamZoom, 260) EVT_CALL(SetBattleCamOffsetZ, 15) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 30) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_20E5) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Defeated) EVT_WAIT(60) EVT_CALL(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_DMG_APPLY, TRUE) EVT_RETURN EVT_CASE_EQ(AVAL_Form_Mage) EVT_CALL(HideHealthBar, ACTOR_SELF) EVT_CALL(UseIdleAnimation, ACTOR_SELF, FALSE) EVT_CALL(GetDamageSource, LVar5) EVT_SWITCH(LVar5) EVT_CASE_OR_EQ(DMG_SRC_NEXT_SLAP_LEFT) EVT_CASE_OR_EQ(DMG_SRC_NEXT_FAN_SMACK_LEFT) EVT_CASE_OR_EQ(DMG_SRC_LAST_SLAP_LEFT) EVT_CASE_OR_EQ(DMG_SRC_LAST_FAN_SMACK_LEFT) EVT_CASE_OR_EQ(DMG_SRC_NEXT_SLAP_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_NEXT_FAN_SMACK_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_LAST_SLAP_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_LAST_FAN_SMACK_RIGHT) EVT_CASE_OR_EQ(DMG_SRC_SPIN_SMASH) EVT_END_CASE_GROUP EVT_CASE_DEFAULT EVT_SET(LVar2, 0) EVT_LOOP(24) EVT_CALL(SetActorYaw, ACTOR_SELF, LVar2) EVT_ADD(LVar2, 30) EVT_WAIT(1) EVT_END_LOOP EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_END_SWITCH EVT_THREAD EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_ADD(LVar1, 10) EVT_ADD(LVar2, 10) EVT_LOOP(3) EVT_PLAY_EFFECT(EFFECT_BIG_SMOKE_PUFF, LVar0, LVar1, LVar2, 0, 0, 0, 0, 0) EVT_WAIT(3) EVT_END_LOOP EVT_END_THREAD EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_MAGE, ACTOR_PART_FLAG_INVISIBLE, TRUE) EVT_CALL(SetPartFlagBits, ACTOR_SELF, PRT_BASE, ACTOR_PART_FLAG_INVISIBLE, FALSE) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_DefeatedBegin) EVT_CALL(GetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_SUB(LVar0, 5) EVT_CALL(SetActorPos, ACTOR_SELF, LVar0, LVar1, LVar2) EVT_WAIT(15) EVT_CALL(PlaySound, SOUND_ACTOR_DEATH) EVT_CALL(DropStarPoints, ACTOR_SELF) EVT_CALL(SetActorYaw, ACTOR_SELF, 0) EVT_CALL(UseBattleCamPreset, BTL_CAM_PRESET_14) EVT_CALL(SetBattleCamZoom, 260) EVT_CALL(SetBattleCamOffsetZ, 15) EVT_CALL(BattleCamTargetActor, ACTOR_SELF) EVT_CALL(MoveBattleCamOver, 30) EVT_CALL(PlaySoundAtActor, ACTOR_SELF, SOUND_20E5) EVT_CALL(SetAnimation, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Defeated) EVT_CALL(SetIdleAnimations, ACTOR_SELF, PRT_BASE, EVT_PTR(N(DefeatedAnims))) EVT_WAIT(60) EVT_CALL(SetActorFlagBits, ACTOR_SELF, ACTOR_FLAG_NO_DMG_APPLY, TRUE) EVT_RETURN EVT_CASE_DEFAULT EVT_SET(LVar1, FORM_ANIM_HURT) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(N(EVS_JrTroopa_BaseDeath)) EVT_RETURN EVT_END_SWITCH EVT_RETURN EVT_END }; EvtScript N(EVS_JrTroopa_ReturnHome) = { EVT_CALL(ResetAllActorSounds, ACTOR_SELF) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_SET(LVar1, FORM_ANIM_RETURN) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_CALL(SetAnimation, ACTOR_SELF, LVar0, LVar1) EVT_CALL(SetActorSpeed, ACTOR_SELF, EVT_FLOAT(8.0)) EVT_CALL(SetGoalToHome, ACTOR_SELF) EVT_CALL(FlyToGoal, ACTOR_SELF, 0, -5, EASING_LINEAR) EVT_CASE_EQ(AVAL_Form_Mage) EVT_SET(LVar1, FORM_ANIM_RETURN) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_ReturnHome) EVT_CASE_DEFAULT EVT_SET(LVar1, FORM_ANIM_RETURN) EVT_EXEC_WAIT(N(EVS_GetFormAnims)) EVT_EXEC_WAIT(EVS_Enemy_ReturnHome) EVT_END_SWITCH EVT_RETURN EVT_END }; EvtScript N(EVS_TryFearReaction) = { EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_SpookReact, LVar0) EVT_IF_EQ(LVar0, AVAL_SpookReact_Ready) EVT_WAIT(10) EVT_EXEC_WAIT(N(EVS_Cam_FocusOnJrTroopa)) EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_Form, LVar0) EVT_SWITCH(LVar0) EVT_CASE_EQ(AVAL_Form_Flying) EVT_CALL(ActorSpeak, MSG_Menus_019A, ACTOR_SELF, PRT_FLYING, ANIM_SpikedParaJrTroopa_Talk, ANIM_SpikedParaJrTroopa_Idle) EVT_CASE_EQ(AVAL_Form_Mage) EVT_CALL(ActorSpeak, MSG_Menus_019A, ACTOR_SELF, PRT_MAGE, ANIM_MageJrTroopa_Talk, ANIM_MageJrTroopa_PointIdle) EVT_CASE_DEFAULT EVT_CALL(ActorSpeak, MSG_Menus_019A, ACTOR_SELF, PRT_BASE, ANIM_JrTroopa_Talk, ANIM_JrTroopa_Idle) EVT_END_SWITCH EVT_CALL(GetActorVar, ACTOR_SELF, AVAR_UnusedBrag, LVar0) EVT_IF_NE(LVar0, TRUE) EVT_EXEC_WAIT(N(EVS_Cam_ResetFocus)) EVT_END_IF EVT_END_IF EVT_CALL(SetActorVar, ACTOR_SELF, AVAR_SpookReact, AVAL_SpookReact_None) EVT_RETURN EVT_END };
7d1fb070e05bbcb6578246a5e2ea541b93a4c97b
1efd2de8bf77ec00eb2fcaf5749278495946d920
/src/mgmt/tests/mocks.h
385986f6dda86cae58edbb47da95b77f9508917b
[ "BSD-2-Clause", "BSD-2-Clause-Patent" ]
permissive
daos-stack/daos
6f55bf3061fd830d5b8d28506e1295e2d3a27c38
ed5eed5df43a68571afe123132a743824c02637a
refs/heads/master
2023-08-31T21:43:37.606145
2023-08-31T16:38:00
2023-08-31T16:38:00
69,390,670
631
300
NOASSERTION
2023-09-14T18:55:15
2016-09-27T19:21:29
C
UTF-8
C
false
false
4,920
h
mocks.h
/* * (C) Copyright 2019-2022 Intel Corporation. * * SPDX-License-Identifier: BSD-2-Clause-Patent */ /** * Mocks for DAOS mgmt unit tests */ #ifndef __MGMT_TESTS_MOCKS_H__ #define __MGMT_TESTS_MOCKS_H__ #include <gurt/types.h> #include <daos_types.h> #include <daos_security.h> #include "../rpc.h" /* * Mock ds_mgmt_pool_get_acl */ extern int ds_mgmt_pool_get_acl_return; extern daos_prop_t *ds_mgmt_pool_get_acl_return_acl; extern uuid_t ds_mgmt_pool_get_acl_uuid; extern void *ds_mgmt_pool_get_acl_acl_ptr; void mock_ds_mgmt_pool_get_acl_setup(void); void mock_ds_mgmt_pool_get_acl_teardown(void); /* * Mock ds_mgmt_pool_overwrite_acl */ extern int ds_mgmt_pool_overwrite_acl_return; extern uuid_t ds_mgmt_pool_overwrite_acl_uuid; extern struct daos_acl *ds_mgmt_pool_overwrite_acl_acl; extern daos_prop_t *ds_mgmt_pool_overwrite_acl_result; extern void *ds_mgmt_pool_overwrite_acl_result_ptr; void mock_ds_mgmt_pool_overwrite_acl_setup(void); void mock_ds_mgmt_pool_overwrite_acl_teardown(void); /* * Mock ds_mgmt_pool_update_acl */ extern int ds_mgmt_pool_update_acl_return; extern uuid_t ds_mgmt_pool_update_acl_uuid; extern struct daos_acl *ds_mgmt_pool_update_acl_acl; extern daos_prop_t *ds_mgmt_pool_update_acl_result; extern void *ds_mgmt_pool_update_acl_result_ptr; void mock_ds_mgmt_pool_update_acl_setup(void); void mock_ds_mgmt_pool_update_acl_teardown(void); /* * Mock ds_mgmt_pool_delete_acl */ extern int ds_mgmt_pool_delete_acl_return; extern uuid_t ds_mgmt_pool_delete_acl_uuid; extern const char *ds_mgmt_pool_delete_acl_principal; extern daos_prop_t *ds_mgmt_pool_delete_acl_result; extern void *ds_mgmt_pool_delete_acl_result_ptr; void mock_ds_mgmt_pool_delete_acl_setup(void); void mock_ds_mgmt_pool_delete_acl_teardown(void); /* * Mock ds_mgmt_pool_list_cont */ extern int ds_mgmt_pool_list_cont_return; extern struct daos_pool_cont_info *ds_mgmt_pool_list_cont_out; extern uint64_t ds_mgmt_pool_list_cont_nc_out; void mock_ds_mgmt_list_cont_gen_cont(size_t ncont); void mock_ds_mgmt_pool_list_cont_setup(void); void mock_ds_mgmt_pool_list_cont_teardown(void); /* * Mock ds_mgmt_pool_set_prop */ extern int ds_mgmt_pool_set_prop_return; extern daos_prop_t *ds_mgmt_pool_set_prop_result; void mock_ds_mgmt_pool_set_prop_setup(void); void mock_ds_mgmt_pool_set_prop_teardown(void); /* * Mock ds_mgmt_pool_get_prop */ extern int ds_mgmt_pool_get_prop_return; extern daos_prop_t *ds_mgmt_pool_get_prop_in; extern daos_prop_t *ds_mgmt_pool_get_prop_out; void mock_ds_mgmt_pool_get_prop_setup(void); void mock_ds_mgmt_pool_get_prop_teardown(void); /* * Mock ds_mgmt_pool_extend */ extern int ds_mgmt_pool_extend_return; extern uuid_t ds_mgmt_pool_extend_uuid; void mock_ds_mgmt_pool_extend_setup(void); /* * Mock ds_mgmt_pool_query */ extern int ds_mgmt_pool_query_return; extern uuid_t ds_mgmt_pool_query_uuid; extern daos_pool_info_t ds_mgmt_pool_query_info_in; extern daos_pool_info_t ds_mgmt_pool_query_info_out; extern void *ds_mgmt_pool_query_info_ptr; extern d_rank_list_t *ds_mgmt_pool_query_ranks_out; void mock_ds_mgmt_pool_query_setup(void); /* * Mock ds_mgmt_pool_query_targets */ extern int ds_mgmt_pool_query_targets_return; extern uuid_t ds_mgmt_pool_query_targets_uuid; extern daos_target_info_t *ds_mgmt_pool_query_targets_info_out; void mock_ds_mgmt_pool_query_targets_setup(void); void mock_ds_mgmt_pool_query_targets_teardown(void); /* * Mock ds_mgmt_tgt_state_update */ extern int ds_mgmt_target_update_return; extern uuid_t ds_mgmt_target_update_uuid; void mock_ds_mgmt_tgt_update_setup(void); /* * Mock ds_mgmt_evict */ extern int ds_mgmt_pool_evict_return; extern uuid_t ds_mgmt_pool_evict_uuid; void mock_ds_mgmt_pool_evict_setup(void); /* * Mock ds_mgmt_cont_set_owner */ extern int ds_mgmt_cont_set_owner_return; extern uuid_t ds_mgmt_cont_set_owner_pool; extern uuid_t ds_mgmt_cont_set_owner_cont; extern char *ds_mgmt_cont_set_owner_user; extern char *ds_mgmt_cont_set_owner_group; void mock_ds_mgmt_cont_set_owner_setup(void); void mock_ds_mgmt_cont_set_owner_teardown(void); void mock_ds_mgmt_pool_query_targets_gen_infos(uint32_t n_infos); /* * Mock ds_mgmt_upgrade */ extern int ds_mgmt_pool_upgrade_return; extern uuid_t ds_mgmt_pool_upgrade_uuid; void mock_ds_mgmt_pool_upgrade_setup(void); /* * Mock ds_mgmt_dev_manage_led */ extern int ds_mgmt_dev_manage_led_return; extern uuid_t ds_mgmt_dev_manage_led_uuid; void mock_ds_mgmt_dev_manage_led_setup(void); /* * Mock ds_mgmt_dev_replace */ extern int ds_mgmt_dev_replace_return; extern uuid_t ds_mgmt_dev_replace_old_uuid; extern uuid_t ds_mgmt_dev_replace_new_uuid; void mock_ds_mgmt_dev_replace_setup(void); /* * Mock ds_mgmt_dev_set_faulty */ extern int ds_mgmt_dev_set_faulty_return; extern uuid_t ds_mgmt_dev_set_faulty_uuid; void mock_ds_mgmt_dev_set_faulty_setup(void); #endif /* __MGMT_TESTS_MOCKS_H__ */
a4931b276684c1bca1ba1237302ac4c4141aba57
ce99bd11ca505967277f4689c621479c1987698e
/src/game/alloc_window_pieces.c
e0451da9fa96a7f393e7bc4f67af8dfd172107cc
[]
no_license
n64decomp/007
5951258890f15431f273e1503674c5e0402c66e0
c46751089ddc18b12ef7a45b6a3e03de2054c422
refs/heads/master
2022-11-08T23:34:54.021033
2022-10-29T14:41:01
2022-10-29T14:41:01
241,212,109
359
48
null
2020-11-21T23:30:31
2020-02-17T21:31:00
C
UTF-8
C
false
false
726
c
alloc_window_pieces.c
#include <ultra64.h> #include <bondconstants.h> #include <memp.h> #include "alloc_window_pieces.h" #include "unk_0A1DA0.h" void alloc_shattered_window_pieces(void) { s32 i; s32 level = lvlGetCurrentStageToLoad(); SHATTERED_WINDOW_PIECES_BUFFER_LEN = (200 / getPlayerCount()); if ((level == LEVELID_STREETS) || (level == LEVELID_DEPOT)) { SHATTERED_WINDOW_PIECES_BUFFER_LEN = (SHATTERED_WINDOW_PIECES_BUFFER_LEN >> 1); } ptr_shattered_window_pieces = mempAllocBytesInBank(((SHATTERED_WINDOW_PIECES_BUFFER_LEN * 0x68) + 0xF) & ~0xF, 4U); for(i=0; i<SHATTERED_WINDOW_PIECES_BUFFER_LEN; i++) { ptr_shattered_window_pieces[i].piece = 0; } D_80040940 = 0; }
dc51064b88e4d9fb15c18c38330923bddbf395bb
3f7028cc89a79582266a19acbde0d6b066a568de
/mobile/library/common/extensions/filters/http/platform_bridge/c_type_definitions.h
5020326a751d26e4145043cfa24b08a218b56ee6
[ "Apache-2.0", "LicenseRef-scancode-unknown-license-reference" ]
permissive
envoyproxy/envoy
882d3c7f316bf755889fb628bee514bb2f6f66f0
72f129d273fa32f49581db3abbaf4b62e3e3703c
refs/heads/main
2023-08-31T09:20:01.278000
2023-08-31T08:58:36
2023-08-31T08:58:36
65,214,191
21,404
4,756
Apache-2.0
2023-09-14T21:56:37
2016-08-08T15:07:24
C++
UTF-8
C
false
false
2,866
h
c_type_definitions.h
#pragma once #include "envoy/http/filter.h" #include "library/common/extensions/filters/http/platform_bridge/c_types.h" // NOLINT(namespace-envoy) const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusContinue = static_cast<envoy_filter_headers_status_t>(Envoy::Http::FilterHeadersStatus::Continue); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopIteration = static_cast<envoy_filter_headers_status_t>(Envoy::Http::FilterHeadersStatus::StopIteration); const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusStopAllIterationAndBuffer = static_cast<envoy_filter_headers_status_t>( Envoy::Http::FilterHeadersStatus::StopAllIterationAndBuffer); // ResumeIteration is not a status supported by Envoy itself, and only has relevance in Envoy // Mobile's implementation of platform filters. // // Regarding enum values, the C++11 standard (7.2/2) states: // If the first enumerator has no initializer, the value of the corresponding constant is zero. // An enumerator-definition without an initializer gives the enumerator the value obtained by // increasing the value of the previous enumerator by one. // // Creating a new return status like this is brittle, but at least somewhat more resilient to // a new status being added in Envoy, since it won't overlap as long as the new status is added // rather than prepended. const envoy_filter_headers_status_t kEnvoyFilterHeadersStatusResumeIteration = kEnvoyFilterHeadersStatusContinue - 1; const envoy_filter_data_status_t kEnvoyFilterDataStatusContinue = static_cast<envoy_filter_data_status_t>(Envoy::Http::FilterDataStatus::Continue); const envoy_filter_data_status_t kEnvoyFilterDataStatusStopIterationAndBuffer = static_cast<envoy_filter_data_status_t>(Envoy::Http::FilterDataStatus::StopIterationAndBuffer); const envoy_filter_data_status_t kEnvoyFilterDataStatusStopIterationNoBuffer = static_cast<envoy_filter_data_status_t>(Envoy::Http::FilterDataStatus::StopIterationNoBuffer); // See comment above. const envoy_filter_data_status_t kEnvoyFilterDataStatusResumeIteration = kEnvoyFilterDataStatusContinue - 1; const envoy_filter_trailers_status_t kEnvoyFilterTrailersStatusContinue = static_cast<envoy_filter_trailers_status_t>(Envoy::Http::FilterTrailersStatus::Continue); const envoy_filter_trailers_status_t kEnvoyFilterTrailersStatusStopIteration = static_cast<envoy_filter_trailers_status_t>(Envoy::Http::FilterTrailersStatus::StopIteration); // See comment above. const envoy_filter_trailers_status_t kEnvoyFilterTrailersStatusResumeIteration = kEnvoyFilterTrailersStatusContinue - 1; // These values don't exist in Envoy and are essentially arbitrary. const envoy_filter_resume_status_t kEnvoyFilterResumeStatusStopIteration = 1; const envoy_filter_resume_status_t kEnvoyFilterResumeStatusResumeIteration = -1;
32b842ba9c31080a95665dd5f2e18cd5bdef9e94
38bd1cf9e52ea23b43223d53d8139aad52bb1c70
/cpp/webdriver-interactions/interactions.h
97d5a091e56038945cad2dcd24693e9dfa488922
[ "Apache-2.0" ]
permissive
SeleniumHQ/selenium
46d9553e3a45412a7540dd3f7d1f34be6ef42b1b
cc41a883b5138962c6b4408a0fdf4e932bd08071
refs/heads/trunk
2023-09-03T22:56:56.403484
2023-09-02T19:20:45
2023-09-02T19:20:45
7,613,257
30,383
9,671
Apache-2.0
2023-09-14T18:47:42
2013-01-14T21:40:56
Java
UTF-8
C
false
false
2,378
h
interactions.h
/* Licensed to the Software Freedom Conservancy (SFC) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The SFC licenses this file to you 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. */ #ifndef interactions_h #define interactions_h #ifdef _MSC_VER #include "stdafx.h" #include "interaction_utils.h" #endif #include <wchar.h> #ifdef _MSC_VER #define EXPORT __declspec(dllexport) #define WD_RESULT LRESULT #else #define EXPORT #define WD_RESULT int #endif #define WINDOW_HANDLE void* // definitions for mouse buttons // NOTE: These values correspond to GDK mouse button values. // If these values are changed, native events for linux *will* be broken // *unless* interactions_linux_mouse.cpp is updated. #define MOUSEBUTTON_LEFT (1) #define MOUSEBUTTON_MIDDLE (2) #define MOUSEBUTTON_RIGHT (3) #define WD_CLIENT_LEFT_MOUSE_BUTTON 0 #define WD_CLIENT_MIDDLE_MOUSE_BUTTON 1 #define WD_CLIENT_RIGHT_MOUSE_BUTTON 2 #ifdef __cplusplus extern "C" { #endif // Keyboard interactions EXPORT void sendKeys(WINDOW_HANDLE windowHandle, const wchar_t* value, int timePerKey); EXPORT void releaseModifierKeys(WINDOW_HANDLE windowHandle, int timePerKey); EXPORT bool pending_input_events(); EXPORT void stopPersistentEventFiring(); EXPORT void setEnablePersistentHover(bool enablePersistentHover); // Mouse interactions EXPORT WD_RESULT clickAt(WINDOW_HANDLE directInputTo, long x, long y, long button); EXPORT WD_RESULT doubleClickAt(WINDOW_HANDLE directInputTo, long x, long y); EXPORT WD_RESULT mouseDownAt(WINDOW_HANDLE directInputTo, long x, long y, long button); EXPORT WD_RESULT mouseUpAt(WINDOW_HANDLE directInputTo, long x, long y, long button); EXPORT WD_RESULT mouseMoveTo(WINDOW_HANDLE directInputTo, long duration, long fromX, long fromY, long toX, long toY); #ifdef __cplusplus } #endif #endif
ad839de3fc6a746b0fa24bcffeb5bed3b95e5da7
03666e5f961946fc1a0ac67781ac1425562ef0d7
/src/avt/Queries/Queries/avtL2NormBetweenCurvesQuery.C
41b48d4288dd6604244590624657e03b53b71535
[ "BSD-3-Clause", "LicenseRef-scancode-unknown-license-reference" ]
permissive
visit-dav/visit
e9f81b4d4b9b9930a0db9d5282cd1bcabf465e2e
601ae46e0bef2e18425b482a755d03490ade0493
refs/heads/develop
2023-09-06T08:19:38.397058
2023-09-05T21:29:32
2023-09-05T21:29:32
165,565,988
335
120
BSD-3-Clause
2023-09-14T00:53:37
2019-01-13T23:27:26
C
UTF-8
C
false
false
5,800
c
avtL2NormBetweenCurvesQuery.C
// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt // Project developers. See the top-level LICENSE file for dates and other // details. No copyright assignment is required to contribute to VisIt. // ************************************************************************* // // avtL2NormBetweenCurvesQuery.C // // ************************************************************************* // #include <avtL2NormBetweenCurvesQuery.h> #include <Utility.h> #include <string> #include <vector> // **************************************************************************** // Method: avtL2NormBetweenCurvesQuery::avtL2NormBetweenCurvesQuery // // Programmer: Hank Childs // Creation: October 2, 2003 // // **************************************************************************** avtL2NormBetweenCurvesQuery::avtL2NormBetweenCurvesQuery() { } // **************************************************************************** // Method: avtL2NormBetweenCurvesQuery::~avtL2NormBetweenCurvesQuery // // Programmer: Hank Childs // Creation: October 2, 2003 // // **************************************************************************** avtL2NormBetweenCurvesQuery::~avtL2NormBetweenCurvesQuery() { } // **************************************************************************** // Method: avtL2NormBetweenCurvesQuery::CompareCurves // // Purpose: // Computes the L2Norm number of the input curves. // // Notes: // For two curves, c_a and c_b, let f(x) = |c_a(x) - c_b(x)|. // Then the L2-Norm is defined to be the integral of f(x)^2 over x. // // The curves are already broken up into line segments. But those line // segments have differing endpoints across the curves. (Meaning curve // 1 may have a line segment from 0-0.435 in X, but curve 2's has a line // segment that goes from 0-0.546. There are many more permutations of // this -- curve 2 may devote 3 segments to an interval in X that curve // 1 covers in 1 line segment.) // // The easiest way to handle this problem is to create new curves that // have the same number of line segments and have the property that line // segment i for the new curves covers exactly the same interval in X. // // Once we have done that, we can start to consider what the contribution // of each line segment is to the L2-Norm. Over line segment i, the // function f(x) is a line. The line has the form f(x) = mx+b. We also // know two points on the line -- f(x1) = |c1(x1) - c2(x1)| and // f(x2) = |c1(x2) - c2(x2)|. Using these points we can calculate m and b. // // Once we know m and b, we can calculate what f(x)^2 is. It is a // parabola. Finally, once we know f(x)^2, we can calculate the integral // from x1 to x2. // It is: // m*m*x1*x1*x1/3 + mb*x1*x1 + b*b*x1 - m*m*x2*x2*x2/3 + mb*x2*x2 + b*b*x2 // // So our gameplan is to break up the curves into line segments that run // over the same X-intervals, then calculate the function f(x), which is // a line, along that segment, and then determine that line segment's // total contribution to the integral. Once we have considered all of // the line segments, we will have calculated the whole integral. // // Programmer: Hank Childs // Creation: October 3, 2003 // // **************************************************************************** double avtL2NormBetweenCurvesQuery::CompareCurves(int n1, const float *x1, const float *y1, int n2, const float *x2, const float *y2) { std::vector<float> newCurve1Vals; std::vector<float> newCurve2Vals; std::vector<float> usedX; PutOnSameXIntervals(n1, x1, y1, n2, x2, y2, usedX, newCurve1Vals, newCurve2Vals); int total_n_pts = (int)usedX.size(); double integral = 0; for (int i = 0 ; i < total_n_pts-1 ; i++) { // pt1 and pt2 will determine f(x) for the range usedX[i]-[i+1] float pt1[2], pt2[2]; pt1[0] = usedX[i]; pt1[1] = newCurve1Vals[i] - newCurve2Vals[i]; pt2[0] = usedX[i+1]; pt2[1] = newCurve1Vals[i+1] - newCurve2Vals[i+1]; // Calculate the line in f(x) = mx+b notation. // Note that pt1[0] != pt2[0] because we threw out duplicated points. double rise = pt2[1] - pt1[1]; double run = pt2[0] - pt1[0]; double m = rise / run; double b = pt1[1] - m*pt1[0]; integral += m*m*pt2[0]*pt2[0]*pt2[0]/3. + m*b*pt2[0]*pt2[0] + b*b*pt2[0] - m*m*pt1[0]*pt1[0]*pt1[0]/3. - m*b*pt1[0]*pt1[0] - b*b*pt1[0]; } return sqrt(integral); } // **************************************************************************** // Method: avtL2NormBetweenCurvesQuery::CreateMessage // // Purpose: // Creates a message for the L2Norm query. // // Programmer: Hank Childs // Creation: October 3, 2003 // // Modifications: // // Cyrus Harrison, Tue Sep 18 13:45:35 PDT 2007 // Added support for user settable floating point format string // // Kathleen Biagas, Thu Feb 13 15:04:58 PST 2014 // Add Xml results. // // **************************************************************************** std::string avtL2NormBetweenCurvesQuery::CreateMessage(double l2norm) { MapNode result_node; result_node["L2Norm_between_curves"] = l2norm; queryAtts.SetXmlResult(result_node.ToXML()); char msg[1024]; std::string format = "The L2Norm between the two curves is " + queryAtts.GetFloatFormat() +"."; snprintf(msg,1024,format.c_str(), l2norm); std::string m = msg; return m; }
a7cb00a4f128059ee9eed0ea32cf40f43eb399fb
e73547787354afd9b717ea57fe8dd0695d161821
/include/mapfs/flo_22_shape.h
662c6d339b3bb9e8826888a4eef17297cafbf01d
[]
no_license
pmret/papermario
8b514b19653cef8d6145e47499b3636b8c474a37
9774b26d93f1045dd2a67e502b6efc9599fb6c31
refs/heads/main
2023-08-31T07:09:48.951514
2023-08-21T18:07:08
2023-08-21T18:07:08
287,151,133
904
139
null
2023-09-14T02:44:23
2020-08-13T01:22:57
C
UTF-8
C
false
false
1,772
h
flo_22_shape.h
#define MODEL_Root 0x2E #define MODEL_g1 0x2D #define MODEL_g11 0x2C #define MODEL_o110 0x2B #define MODEL_g20 0x2A #define MODEL_o99 0x29 #define MODEL_o98 0x28 #define MODEL_g19 0x27 #define MODEL_o97 0x26 #define MODEL_o93 0x25 #define MODEL_g16 0x24 #define MODEL_o60 0x23 #define MODEL_o59 0x22 #define MODEL_o58 0x21 #define MODEL_g17 0x20 #define MODEL_o92 0x1F #define MODEL_o91 0x1E #define MODEL_o61 0x1D #define MODEL_g15 0x1C #define MODEL_o55 0x1B #define MODEL_o53 0x1A #define MODEL_o52 0x19 #define MODEL_g14 0x18 #define MODEL_o48 0x17 #define MODEL_o46 0x16 #define MODEL_o45 0x15 #define MODEL_o24 0x14 #define MODEL_g5 0x13 #define MODEL_o6 0x12 #define MODEL_o5 0x11 #define MODEL_g3 0x10 #define MODEL_g22 0xF #define MODEL_o106 0xE #define MODEL_o105 0xD #define MODEL_o104 0xC #define MODEL_o107 0xB #define MODEL_g21 0xA #define MODEL_o103 0x9 #define MODEL_o101 0x8 #define MODEL_o100 0x7 #define MODEL_o7 0x6 #define MODEL_o1 0x5 #define MODEL_g4 0x4 #define MODEL_g23 0x3 #define MODEL_o109 0x2 #define MODEL_o108 0x1 #define MODEL_o3 0x0
a804b2ae70fb5c47967045eb142f6b3c6e261c62
dc5b5723f2aebc9abaa125e281b59cb88362996f
/sample/framework/vx_threshold.c
86fe88dc7d3625df8d0c780dbc463429f7db41c9
[ "Apache-2.0" ]
permissive
KhronosGroup/OpenVX-sample-impl
cd3cc630b398a859ff83ce75ff02ff7f8dd45e64
9caba36a541fa6480f9d65d9a78dde208ebe96f9
refs/heads/openvx_1.3
2023-09-05T23:32:05.073687
2023-06-16T19:53:24
2023-06-16T19:53:24
157,795,699
134
55
Apache-2.0
2023-06-16T19:53:25
2018-11-16T01:33:06
C
UTF-8
C
false
false
36,987
c
vx_threshold.c
/* * Copyright (c) 2012-2017 The Khronos Group Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "vx_internal.h" #include "vx_threshold.h" static vx_bool vxIsValidThresholdType(vx_enum thresh_type) { vx_bool ret = vx_false_e; if ((thresh_type == VX_THRESHOLD_TYPE_BINARY) || (thresh_type == VX_THRESHOLD_TYPE_RANGE)) { ret = vx_true_e; } return ret; } static vx_bool vxIsValidThresholdDataType(vx_enum data_type) { vx_bool ret = vx_false_e; if (data_type == VX_TYPE_BOOL || data_type == VX_TYPE_INT8 || data_type == VX_TYPE_UINT8 || data_type == VX_TYPE_INT16 || data_type == VX_TYPE_UINT16 || data_type == VX_TYPE_INT32 || data_type == VX_TYPE_UINT32) { ret = vx_true_e; } return ret; } VX_API_ENTRY vx_status VX_API_CALL vxReleaseThreshold(vx_threshold *t) { return ownReleaseReferenceInt((vx_reference *)t, VX_TYPE_THRESHOLD, VX_EXTERNAL, NULL); } VX_API_ENTRY vx_threshold VX_API_CALL vxCreateThreshold(vx_context context, vx_enum thresh_type, vx_enum data_type) { vx_threshold threshold = NULL; if (ownIsValidContext(context) == vx_true_e) { if (vxIsValidThresholdDataType(data_type) == vx_true_e) { if (vxIsValidThresholdType(thresh_type) == vx_true_e) { threshold = (vx_threshold)ownCreateReference(context, VX_TYPE_THRESHOLD, VX_EXTERNAL, &context->base); if (vxGetStatus((vx_reference)threshold) == VX_SUCCESS && threshold->base.type == VX_TYPE_THRESHOLD) { threshold->thresh_type = thresh_type; threshold->data_type = data_type; switch(data_type) { case VX_TYPE_BOOL: threshold->true_value.U1 = VX_U1_THRESHOLD_TRUE_VALUE; threshold->false_value.U1 = VX_U1_THRESHOLD_FALSE_VALUE; break; case VX_TYPE_INT8: threshold->true_value.U8 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.U8 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; case VX_TYPE_UINT8: threshold->true_value.U8 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.U8 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; case VX_TYPE_UINT16: threshold->true_value.U16 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.U16 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; case VX_TYPE_INT16: threshold->true_value.S16 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.S16 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; case VX_TYPE_INT32: threshold->true_value.S32 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.S32 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; case VX_TYPE_UINT32: threshold->true_value.U32 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.U32 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; default: break; } } } else { VX_PRINT(VX_ZONE_ERROR, "Invalid threshold type\n"); vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid threshold type\n"); threshold = (vx_threshold )ownGetErrorObject(context, VX_ERROR_INVALID_TYPE); } } else { VX_PRINT(VX_ZONE_ERROR, "Invalid data type\n"); vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid data type\n"); threshold = (vx_threshold )ownGetErrorObject(context, VX_ERROR_INVALID_TYPE); } } return threshold; } VX_API_ENTRY vx_status VX_API_CALL vxSetThresholdAttribute(vx_threshold threshold, vx_enum attribute, const void *ptr, vx_size size) { vx_status status = VX_SUCCESS; if (ownIsValidSpecificReference(&threshold->base, VX_TYPE_THRESHOLD) == vx_true_e) { switch (attribute) { case VX_THRESHOLD_THRESHOLD_VALUE: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_BINARY)) { threshold->value.S32 = *(vx_int32 *)ptr; ownWroteToReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_BINARY)) { threshold->value = *(vx_pixel_value_t *)ptr; ownWroteToReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_THRESHOLD_LOWER: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { threshold->lower.S32 = *(vx_int32 *)ptr; ownWroteToReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { threshold->lower = *(vx_pixel_value_t *)ptr; ownWroteToReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_THRESHOLD_UPPER: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { threshold->upper.S32 = *(vx_int32 *)ptr; ownWroteToReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { threshold->upper = *(vx_pixel_value_t *)ptr; ownWroteToReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_TRUE_VALUE: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3)) { threshold->true_value.S32 = *(vx_int32 *)ptr; ownWroteToReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3)) { threshold->true_value = *(vx_pixel_value_t *)ptr; ownWroteToReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_FALSE_VALUE: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3)) { threshold->false_value.S32 = *(vx_int32 *)ptr; ownWroteToReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3)) { threshold->false_value = *(vx_pixel_value_t *)ptr; ownWroteToReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; default: status = VX_ERROR_NOT_SUPPORTED; break; } } else { status = VX_ERROR_INVALID_REFERENCE; } VX_PRINT(VX_ZONE_API, "return %d\n", status); return status; } VX_API_ENTRY vx_status VX_API_CALL vxQueryThreshold(vx_threshold threshold, vx_enum attribute, void *ptr, vx_size size) { vx_status status = VX_SUCCESS; if (ownIsValidSpecificReference(&threshold->base, VX_TYPE_THRESHOLD) == vx_true_e) { switch (attribute) { case VX_THRESHOLD_THRESHOLD_VALUE: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_BINARY)) { *(vx_int32 *)ptr = threshold->value.S32; ownReadFromReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_BINARY)) { *(vx_pixel_value_t *)ptr = threshold->value; ownReadFromReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_THRESHOLD_LOWER: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { *(vx_int32 *)ptr = threshold->lower.S32; ownReadFromReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { *(vx_pixel_value_t *)ptr = threshold->lower; ownReadFromReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_THRESHOLD_UPPER: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { *(vx_int32 *)ptr = threshold->upper.S32; ownReadFromReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3) && (threshold->thresh_type == VX_THRESHOLD_TYPE_RANGE)) { *(vx_pixel_value_t *)ptr = threshold->upper; ownReadFromReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_TRUE_VALUE: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3)) { *(vx_int32 *)ptr = threshold->true_value.S32; ownReadFromReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3)) { *(vx_pixel_value_t *)ptr = threshold->true_value; ownReadFromReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_FALSE_VALUE: if (VX_CHECK_PARAM(ptr, size, vx_int32, 0x3)) { *(vx_int32 *)ptr = threshold->false_value.S32; ownReadFromReference(&threshold->base); } else if(VX_CHECK_PARAM(ptr, size, vx_pixel_value_t, 0x3)) { *(vx_pixel_value_t *)ptr = threshold->false_value; ownReadFromReference(&threshold->base); } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_DATA_TYPE: if (VX_CHECK_PARAM(ptr, size, vx_enum, 0x3)) { *(vx_enum *)ptr = threshold->data_type; } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_TYPE: if (VX_CHECK_PARAM(ptr, size, vx_enum, 0x3)) { *(vx_enum *)ptr = threshold->thresh_type; } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_INPUT_FORMAT: if (VX_CHECK_PARAM(ptr, size, vx_df_image, 0x3)) { *(vx_df_image *)ptr = threshold->input_format; } else { status = VX_ERROR_INVALID_PARAMETERS; } break; case VX_THRESHOLD_OUTPUT_FORMAT: if (VX_CHECK_PARAM(ptr, size, vx_df_image, 0x3)) { *(vx_df_image *)ptr = threshold->output_format; } else { status = VX_ERROR_INVALID_PARAMETERS; } break; default: status = VX_ERROR_NOT_SUPPORTED; break; } } else { status = VX_ERROR_INVALID_REFERENCE; } VX_PRINT(VX_ZONE_API, "return %d\n", status); return status; } static vx_bool vxIsValidThresholdFormat(vx_df_image format) { vx_bool ret = vx_false_e; if (format == VX_DF_IMAGE_U1 || format == VX_DF_IMAGE_U8 || format == VX_DF_IMAGE_S16 || format == VX_DF_IMAGE_U16 || format == VX_DF_IMAGE_S32 || format == VX_DF_IMAGE_U32 ) { ret = vx_true_e; } return ret; } static vx_bool vxIsValidThresholdFormatEx(vx_df_image format) { vx_bool ret = vx_false_e; if (format == VX_DF_IMAGE_RGB || format == VX_DF_IMAGE_RGBX || format == VX_DF_IMAGE_NV12 || format == VX_DF_IMAGE_NV21 || format == VX_DF_IMAGE_UYVY || format == VX_DF_IMAGE_YUYV || format == VX_DF_IMAGE_IYUV || format == VX_DF_IMAGE_YUV4 ) { ret = vx_true_e; } return ret; } VX_API_ENTRY vx_threshold VX_API_CALL vxCreateThresholdForImage(vx_context context, vx_enum thresh_type, vx_df_image input_format, vx_df_image output_format) { vx_threshold threshold = NULL; if (ownIsValidContext(context) == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Invalid context\n"); threshold = NULL; } if (vxIsValidThresholdType(thresh_type) == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Invalid threshold type\n"); vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid threshold type\n"); threshold = (vx_threshold )ownGetErrorObject(context, VX_ERROR_INVALID_TYPE); } if ( ((vxIsValidThresholdFormat (input_format) == vx_false_e) && (vxIsValidThresholdFormatEx(input_format) == vx_false_e)) || ((vxIsValidThresholdFormat (output_format) == vx_false_e) && (vxIsValidThresholdFormatEx(output_format) == vx_false_e)) ) { VX_PRINT(VX_ZONE_ERROR, "Invalid input or output format\n"); vxAddLogEntry(&context->base, VX_ERROR_INVALID_TYPE, "Invalid input or output format\n"); threshold = (vx_threshold )ownGetErrorObject(context, VX_ERROR_INVALID_TYPE); } threshold = (vx_threshold)ownCreateReference(context, VX_TYPE_THRESHOLD, VX_EXTERNAL, &context->base); if (vxGetStatus((vx_reference)threshold) == VX_SUCCESS && threshold->base.type == VX_TYPE_THRESHOLD) { threshold->thresh_type = thresh_type; threshold->input_format = input_format; threshold->output_format = output_format; switch (output_format) { case VX_DF_IMAGE_RGB: { threshold->data_type = VX_TYPE_DF_IMAGE; threshold->true_value.RGB[0] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.RGB[1] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.RGB[2] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.RGB[0] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.RGB[1] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.RGB[2] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_RGBX: { threshold->data_type = VX_TYPE_DF_IMAGE; threshold->true_value.RGBX[0] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.RGBX[1] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.RGBX[2] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.RGBX[3] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.RGBX[0] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.RGBX[1] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.RGBX[2] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.RGBX[3] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_NV12: case VX_DF_IMAGE_NV21: case VX_DF_IMAGE_UYVY: case VX_DF_IMAGE_YUYV: case VX_DF_IMAGE_IYUV: case VX_DF_IMAGE_YUV4: { threshold->data_type = VX_TYPE_DF_IMAGE; threshold->true_value.YUV[0] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.YUV[1] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->true_value.YUV[2] = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.YUV[0] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.YUV[1] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; threshold->false_value.YUV[2] = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_U1: { threshold->data_type = VX_TYPE_BOOL; threshold->true_value.U1 = VX_U1_THRESHOLD_TRUE_VALUE; threshold->false_value.U1 = VX_U1_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_U8: { threshold->data_type = VX_TYPE_UINT8; threshold->true_value.U8 = VX_DEFAULT_THRESHOLD_TRUE_VALUE; threshold->false_value.U8 = VX_DEFAULT_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_S16: { threshold->data_type = VX_TYPE_INT16; threshold->true_value.S16 = VX_S16_THRESHOLD_TRUE_VALUE; threshold->false_value.S16 = VX_S16_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_U16: { threshold->data_type = VX_TYPE_UINT16; threshold->true_value.U16 = VX_U16_THRESHOLD_TRUE_VALUE; threshold->false_value.U16 = VX_U16_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_S32: { threshold->data_type = VX_TYPE_INT32; threshold->true_value.S32 = VX_S32_THRESHOLD_TRUE_VALUE; threshold->false_value.S32 = VX_S32_THRESHOLD_FALSE_VALUE; break; } case VX_DF_IMAGE_U32: { threshold->data_type = VX_TYPE_UINT32; threshold->true_value.U32 = VX_U32_THRESHOLD_TRUE_VALUE; threshold->false_value.U32 = VX_U32_THRESHOLD_FALSE_VALUE; break; } default: { threshold->data_type = VX_TYPE_INVALID; break; } } } return threshold; } VX_API_ENTRY vx_threshold VX_API_CALL vxCreateVirtualThresholdForImage(vx_graph graph, vx_enum thresh_type, vx_df_image input_format, vx_df_image output_format) { vx_threshold threshold = NULL; vx_reference_t *gref = (vx_reference_t *)graph; if (ownIsValidSpecificReference(gref, VX_TYPE_GRAPH) == vx_true_e) { threshold = vxCreateThresholdForImage(gref->context, thresh_type, input_format, output_format); if (vxGetStatus((vx_reference)threshold) == VX_SUCCESS && threshold->base.type == VX_TYPE_THRESHOLD) { threshold->base.scope = (vx_reference_t *)graph; threshold->base.is_virtual = vx_true_e; } else { threshold = (vx_threshold)ownGetErrorObject(graph->base.context, VX_ERROR_INVALID_PARAMETERS); } } return threshold; } VX_API_ENTRY vx_status VX_API_CALL vxCopyThresholdOutput(vx_threshold threshold, vx_pixel_value_t * true_value_ptr, vx_pixel_value_t * false_value_ptr, vx_enum usage, vx_enum user_mem_type) { vx_status status = VX_ERROR_INVALID_REFERENCE; if (ownIsValidSpecificReference(&threshold->base, VX_TYPE_THRESHOLD) == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Invalid reference for threshold\n"); status = VX_ERROR_INVALID_REFERENCE; return status; } if (threshold->base.is_virtual == vx_true_e) { if (threshold->base.is_accessible == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Can not access a virtual threshold\n"); status = VX_ERROR_OPTIMIZED_AWAY; return status; } } #ifdef OPENVX_USE_OPENCL_INTEROP vx_pixel_value_t * true_value_ptr_given = true_value_ptr; vx_pixel_value_t * false_value_ptr_given = false_value_ptr; vx_enum user_mem_type_given = user_mem_type; if (user_mem_type == VX_MEMORY_TYPE_OPENCL_BUFFER) { // get ptr from OpenCL buffer for HOST if (true_value_ptr) { size_t size = 0; cl_mem opencl_buf = (cl_mem)true_value_ptr; cl_int cerr = clGetMemObjectInfo(opencl_buf, CL_MEM_SIZE, sizeof(size_t), &size, NULL); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdOutput: clGetMemObjectInfo(%p) => (%d)\n", opencl_buf, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } true_value_ptr = (vx_pixel_value_t *)clEnqueueMapBuffer(threshold->base.context->opencl_command_queue, opencl_buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, size, 0, NULL, NULL, &cerr); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdOutput: clEnqueueMapBuffer(%p,%d) => %p (%d)\n", opencl_buf, (int)size, true_value_ptr, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } } if (false_value_ptr) { size_t size = 0; cl_mem opencl_buf = (cl_mem)false_value_ptr; cl_int cerr = clGetMemObjectInfo(opencl_buf, CL_MEM_SIZE, sizeof(size_t), &size, NULL); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdOutput: clGetMemObjectInfo(%p) => (%d)\n", opencl_buf, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } false_value_ptr = (vx_pixel_value_t *)clEnqueueMapBuffer(threshold->base.context->opencl_command_queue, opencl_buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, size, 0, NULL, NULL, &cerr); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdOutput: clEnqueueMapBuffer(%p,%d) => %p (%d)\n", opencl_buf, (int)size, false_value_ptr, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } } user_mem_type = VX_MEMORY_TYPE_HOST; } #endif if (VX_MEMORY_TYPE_HOST == user_mem_type) { if (usage == VX_READ_ONLY) { ownSemWait(&threshold->base.lock); vx_size size = sizeof(vx_pixel_value_t); if (true_value_ptr) { memcpy(true_value_ptr, &threshold->true_value, size); } if (false_value_ptr) { memcpy(false_value_ptr, &threshold->false_value, size); } ownSemPost(&threshold->base.lock); ownReadFromReference(&threshold->base); status = VX_SUCCESS; } else if (usage == VX_WRITE_ONLY) { ownSemWait(&threshold->base.lock); vx_size size = sizeof(vx_pixel_value_t); if (true_value_ptr) { memcpy(&threshold->true_value, true_value_ptr, size); } if (false_value_ptr) { memcpy(&threshold->false_value, false_value_ptr, size); } ownSemPost(&threshold->base.lock); ownWroteToReference(&threshold->base); status = VX_SUCCESS; } else { VX_PRINT(VX_ZONE_ERROR, "Wrong parameters for threshold\n"); status = VX_ERROR_INVALID_PARAMETERS; } } else { VX_PRINT(VX_ZONE_ERROR, "Failed to allocate threshold\n"); status = VX_ERROR_NO_MEMORY; } #ifdef OPENVX_USE_OPENCL_INTEROP if (user_mem_type_given == VX_MEMORY_TYPE_OPENCL_BUFFER) { if (true_value_ptr_given) { clEnqueueUnmapMemObject(threshold->base.context->opencl_command_queue, (cl_mem)true_value_ptr_given, true_value_ptr, 0, NULL, NULL); clFinish(threshold->base.context->opencl_command_queue); } if (false_value_ptr_given) { clEnqueueUnmapMemObject(threshold->base.context->opencl_command_queue, (cl_mem)false_value_ptr_given, false_value_ptr, 0, NULL, NULL); clFinish(threshold->base.context->opencl_command_queue); } } #endif return status; } VX_API_ENTRY vx_status VX_API_CALL vxCopyThresholdRange(vx_threshold threshold, vx_pixel_value_t * lower_value_ptr, vx_pixel_value_t * upper_value_ptr, vx_enum usage, vx_enum user_mem_type) { vx_status status = VX_ERROR_INVALID_REFERENCE; if (ownIsValidSpecificReference(&threshold->base, VX_TYPE_THRESHOLD) == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Invalid reference for threshold\n"); status = VX_ERROR_INVALID_REFERENCE; return status; } if (threshold->base.is_virtual == vx_true_e) { if (threshold->base.is_accessible == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Can not access a virtual threshold\n"); status = VX_ERROR_OPTIMIZED_AWAY; return status; } } #ifdef OPENVX_USE_OPENCL_INTEROP vx_pixel_value_t * lower_value_ptr_given = lower_value_ptr; vx_pixel_value_t * upper_value_ptr_given = upper_value_ptr; vx_enum user_mem_type_given = user_mem_type; if (user_mem_type == VX_MEMORY_TYPE_OPENCL_BUFFER) { // get ptr from OpenCL buffer for HOST if (lower_value_ptr) { size_t size = 0; cl_mem opencl_buf = (cl_mem)lower_value_ptr; cl_int cerr = clGetMemObjectInfo(opencl_buf, CL_MEM_SIZE, sizeof(size_t), &size, NULL); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdRange: clGetMemObjectInfo(%p) => (%d)\n", opencl_buf, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } lower_value_ptr = (vx_pixel_value_t *)clEnqueueMapBuffer(threshold->base.context->opencl_command_queue, opencl_buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, size, 0, NULL, NULL, &cerr); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdRange: clEnqueueMapBuffer(%p,%d) => %p (%d)\n", opencl_buf, (int)size, lower_value_ptr, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } } if (upper_value_ptr) { size_t size = 0; cl_mem opencl_buf = (cl_mem)upper_value_ptr; cl_int cerr = clGetMemObjectInfo(opencl_buf, CL_MEM_SIZE, sizeof(size_t), &size, NULL); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdRange: clGetMemObjectInfo(%p) => (%d)\n", opencl_buf, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } upper_value_ptr = (vx_pixel_value_t *)clEnqueueMapBuffer(threshold->base.context->opencl_command_queue, opencl_buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, size, 0, NULL, NULL, &cerr); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdRange: clEnqueueMapBuffer(%p,%d) => %p (%d)\n", opencl_buf, (int)size, upper_value_ptr, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } } user_mem_type = VX_MEMORY_TYPE_HOST; } #endif if (VX_MEMORY_TYPE_HOST == user_mem_type) { if (usage == VX_READ_ONLY) { ownSemWait(&threshold->base.lock); vx_size size = sizeof(vx_pixel_value_t); if (lower_value_ptr) { memcpy(lower_value_ptr, &threshold->lower, size); } if (upper_value_ptr) { memcpy(upper_value_ptr, &threshold->upper, size); } ownSemPost(&threshold->base.lock); ownReadFromReference(&threshold->base); status = VX_SUCCESS; } else if (usage == VX_WRITE_ONLY) { ownSemWait(&threshold->base.lock); vx_size size = sizeof(vx_pixel_value_t); if (lower_value_ptr) { memcpy(&threshold->lower, lower_value_ptr, size); } if (upper_value_ptr) { memcpy(&threshold->upper, upper_value_ptr, size); } ownSemPost(&threshold->base.lock); ownWroteToReference(&threshold->base); status = VX_SUCCESS; } else { VX_PRINT(VX_ZONE_ERROR, "Wrong parameters for threshold\n"); status = VX_ERROR_INVALID_PARAMETERS; } } else { VX_PRINT(VX_ZONE_ERROR, "Failed to allocate threshold\n"); status = VX_ERROR_NO_MEMORY; } #ifdef OPENVX_USE_OPENCL_INTEROP if (user_mem_type_given == VX_MEMORY_TYPE_OPENCL_BUFFER) { if (lower_value_ptr_given) { clEnqueueUnmapMemObject(threshold->base.context->opencl_command_queue, (cl_mem)lower_value_ptr_given, lower_value_ptr, 0, NULL, NULL); clFinish(threshold->base.context->opencl_command_queue); } if (upper_value_ptr_given) { clEnqueueUnmapMemObject(threshold->base.context->opencl_command_queue, (cl_mem)upper_value_ptr_given, upper_value_ptr, 0, NULL, NULL); clFinish(threshold->base.context->opencl_command_queue); } } #endif return status; } VX_API_ENTRY vx_status VX_API_CALL vxCopyThresholdValue(vx_threshold threshold, vx_pixel_value_t * value_ptr, vx_enum usage, vx_enum user_mem_type ) { vx_status status = VX_ERROR_INVALID_REFERENCE; if (ownIsValidSpecificReference(&threshold->base, VX_TYPE_THRESHOLD) == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Invalid reference for threshold\n"); status = VX_ERROR_INVALID_REFERENCE; return status; } if (threshold->base.is_virtual == vx_true_e) { if (threshold->base.is_accessible == vx_false_e) { VX_PRINT(VX_ZONE_ERROR, "Can not access a virtual threshold\n"); status = VX_ERROR_OPTIMIZED_AWAY; return status; } } #ifdef OPENVX_USE_OPENCL_INTEROP vx_pixel_value_t * value_ptr_given = value_ptr; vx_enum user_mem_type_given = user_mem_type; if (user_mem_type == VX_MEMORY_TYPE_OPENCL_BUFFER) { // get ptr from OpenCL buffer for HOST size_t size = 0; cl_mem opencl_buf = (cl_mem)value_ptr; cl_int cerr = clGetMemObjectInfo(opencl_buf, CL_MEM_SIZE, sizeof(size_t), &size, NULL); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdValue: clGetMemObjectInfo(%p) => (%d)\n", opencl_buf, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } value_ptr = (vx_pixel_value_t *)clEnqueueMapBuffer(threshold->base.context->opencl_command_queue, opencl_buf, CL_TRUE, CL_MAP_READ | CL_MAP_WRITE, 0, size, 0, NULL, NULL, &cerr); VX_PRINT(VX_ZONE_CONTEXT, "OPENCL: vxCopyThresholdValue: clEnqueueMapBuffer(%p,%d) => %p (%d)\n", opencl_buf, (int)size, value_ptr, cerr); if (cerr != CL_SUCCESS) { return VX_ERROR_INVALID_PARAMETERS; } user_mem_type = VX_MEMORY_TYPE_HOST; } #endif if (VX_MEMORY_TYPE_HOST == user_mem_type) { if (usage == VX_READ_ONLY) { ownSemWait(&threshold->base.lock); vx_size size = sizeof(vx_pixel_value_t); if (value_ptr) { memcpy(value_ptr, &threshold->value, size); } ownSemPost(&threshold->base.lock); ownReadFromReference(&threshold->base); status = VX_SUCCESS; } else if (usage == VX_WRITE_ONLY) { ownSemWait(&threshold->base.lock); vx_size size = sizeof(vx_pixel_value_t); if (value_ptr) { memcpy(&threshold->value, value_ptr, size); } ownSemPost(&threshold->base.lock); ownWroteToReference(&threshold->base); status = VX_SUCCESS; } else { VX_PRINT(VX_ZONE_ERROR, "Wrong parameters for threshold\n"); status = VX_ERROR_INVALID_PARAMETERS; } } else { VX_PRINT(VX_ZONE_ERROR, "Failed to allocate threshold\n"); status = VX_ERROR_NO_MEMORY; } #ifdef OPENVX_USE_OPENCL_INTEROP if (user_mem_type_given == VX_MEMORY_TYPE_OPENCL_BUFFER) { clEnqueueUnmapMemObject(threshold->base.context->opencl_command_queue, (cl_mem)value_ptr_given, value_ptr, 0, NULL, NULL); clFinish(threshold->base.context->opencl_command_queue); } #endif return status; }
f85d64532a41ac42f5e699bfac0e8d8f2a9227a9
e2990cde74213c8858d1b56adb64fa7e479ec7bc
/auto-gen/composite/test.c
156f719a58b08e2a722bf29881e9593d3382b736
[ "MIT" ]
permissive
huawenyu/Design-Patterns-in-C
2b0c23c16460d2b220f74b23eab64c5defbce3b5
e18e87d39ea894d24f77b2d1e6ca37db231f1908
refs/heads/master
2023-04-10T13:10:39.251309
2023-04-05T16:38:18
2023-04-05T16:38:18
18,507,912
382
123
MIT
2022-08-01T14:08:10
2014-04-07T06:12:51
C
UTF-8
C
false
false
2,568
c
test.c
/** * test.c 2014-05-04 * anonymouse(anonymouse@email) * * Copyright (C) 2000-2014 All Right Reserved * * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY * KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A * PARTICULAR PURPOSE. * * Auto generate for Design Patterns in C */ #include <stdio.h> #include <stdlib.h> #include <mycommon.h> #include <myobj.h> #include <mytrace.h> #include <test_suite.h> #include "primitive.h" #include "row.h" #include "column.h" static int test_main_entry(char *output, size_t sz) { /* Row first(1); // Row1 Column second(2); // | Column third(3); // +-- Col2 Row fourth(4); // | | Row fifth(5); // | +-- 7 first.add(&second); // +-- Col3 first.add(&third); // | | third.add(&fourth); // | +-- Row4 third.add(&fifth); // | | | first.add(&Primitive(6)); // | | +-- 9 second.add(&Primitive(7)); // | +-- Row5 third.add(&Primitive(8)); // | | | fourth.add(&Primitive(9)); // | | +-- 10 fifth.add(&Primitive(10)); // | +-- 8 first.traverse(); // */ struct row *r1, *r4, *r5; struct column *c2, *c3; struct primitive *p6, *p7, *p8, *p9, *p10; r1 = malloc(sizeof(*r1)); row_init(r1, 1); c2 = malloc(sizeof(*c2)); column_init(c2, 2); c3 = malloc(sizeof(*c3)); column_init(c3, 3); r4 = malloc(sizeof(*r4)); row_init(r4, 4); r5 = malloc(sizeof(*r5)); row_init(r5, 5); composite_add(&r1->composite, &c2->composite.component); composite_add(&r1->composite, &c3->composite.component); composite_add(&c3->composite, &r4->composite.component); composite_add(&c3->composite, &r5->composite.component); p6 = malloc(sizeof(*p6)); primitive_init(p6, 6); p7 = malloc(sizeof(*p7)); primitive_init(p7, 7); p8 = malloc(sizeof(*p8)); primitive_init(p8, 8); p9 = malloc(sizeof(*p9)); primitive_init(p9, 9); p10 = malloc(sizeof(*p10)); primitive_init(p10, 10); composite_add(&r1->composite, &p6->component); composite_add(&c2->composite, &p7->component); composite_add(&c3->composite, &p8->component); composite_add(&r4->composite, &p9->component); composite_add(&r5->composite, &p10->component); component_traverse(&r1->composite.component); return 0; } void main_entry_test(void); void main_entry_test(void) { my_test_suite_add(test_main_entry, "Test composite"); }
abaf099c8e361544b8c883525a99b16d34211879
7d232f51e2330a4f537c50ede9c6bc023d656fd4
/src/core/ext/upb-generated/envoy/type/v3/hash_policy.upb.h
f8813bfe69622b21a43a8ee582140012b0561012
[ "BSD-3-Clause", "MPL-2.0", "Apache-2.0" ]
permissive
grpc/grpc
6975af3ba6f07a6fe965b875a0c09abf18999a52
e4d598ab64aa54f1da78c6ed6133b741742d11d4
refs/heads/master
2023-08-31T01:10:22.666618
2023-08-30T22:35:17
2023-08-30T22:35:17
27,729,880
42,330
13,022
Apache-2.0
2023-09-14T21:54:19
2014-12-08T18:58:53
C++
UTF-8
C
false
false
12,168
h
hash_policy.upb.h
/* This file was generated by upbc (the upb compiler) from the input * file: * * envoy/type/v3/hash_policy.proto * * Do not edit -- your changes will be discarded when the file is * regenerated. */ #ifndef ENVOY_TYPE_V3_HASH_POLICY_PROTO_UPB_H_ #define ENVOY_TYPE_V3_HASH_POLICY_PROTO_UPB_H_ #include "upb/generated_code_support.h" // Must be last. #include "upb/port/def.inc" #ifdef __cplusplus extern "C" { #endif typedef struct envoy_type_v3_HashPolicy envoy_type_v3_HashPolicy; typedef struct envoy_type_v3_HashPolicy_SourceIp envoy_type_v3_HashPolicy_SourceIp; typedef struct envoy_type_v3_HashPolicy_FilterState envoy_type_v3_HashPolicy_FilterState; extern const upb_MiniTable envoy_type_v3_HashPolicy_msg_init; extern const upb_MiniTable envoy_type_v3_HashPolicy_SourceIp_msg_init; extern const upb_MiniTable envoy_type_v3_HashPolicy_FilterState_msg_init; /* envoy.type.v3.HashPolicy */ UPB_INLINE envoy_type_v3_HashPolicy* envoy_type_v3_HashPolicy_new(upb_Arena* arena) { return (envoy_type_v3_HashPolicy*)_upb_Message_New(&envoy_type_v3_HashPolicy_msg_init, arena); } UPB_INLINE envoy_type_v3_HashPolicy* envoy_type_v3_HashPolicy_parse(const char* buf, size_t size, upb_Arena* arena) { envoy_type_v3_HashPolicy* ret = envoy_type_v3_HashPolicy_new(arena); if (!ret) return NULL; if (upb_Decode(buf, size, ret, &envoy_type_v3_HashPolicy_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; } UPB_INLINE envoy_type_v3_HashPolicy* envoy_type_v3_HashPolicy_parse_ex(const char* buf, size_t size, const upb_ExtensionRegistry* extreg, int options, upb_Arena* arena) { envoy_type_v3_HashPolicy* ret = envoy_type_v3_HashPolicy_new(arena); if (!ret) return NULL; if (upb_Decode(buf, size, ret, &envoy_type_v3_HashPolicy_msg_init, extreg, options, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; } UPB_INLINE char* envoy_type_v3_HashPolicy_serialize(const envoy_type_v3_HashPolicy* msg, upb_Arena* arena, size_t* len) { char* ptr; (void)upb_Encode(msg, &envoy_type_v3_HashPolicy_msg_init, 0, arena, &ptr, len); return ptr; } UPB_INLINE char* envoy_type_v3_HashPolicy_serialize_ex(const envoy_type_v3_HashPolicy* msg, int options, upb_Arena* arena, size_t* len) { char* ptr; (void)upb_Encode(msg, &envoy_type_v3_HashPolicy_msg_init, options, arena, &ptr, len); return ptr; } typedef enum { envoy_type_v3_HashPolicy_policy_specifier_source_ip = 1, envoy_type_v3_HashPolicy_policy_specifier_filter_state = 2, envoy_type_v3_HashPolicy_policy_specifier_NOT_SET = 0 } envoy_type_v3_HashPolicy_policy_specifier_oneofcases; UPB_INLINE envoy_type_v3_HashPolicy_policy_specifier_oneofcases envoy_type_v3_HashPolicy_policy_specifier_case(const envoy_type_v3_HashPolicy* msg) { const upb_MiniTableField field = {1, UPB_SIZE(4, 8), -1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; return (envoy_type_v3_HashPolicy_policy_specifier_oneofcases)upb_Message_WhichOneofFieldNumber(msg, &field); } UPB_INLINE void envoy_type_v3_HashPolicy_clear_source_ip(envoy_type_v3_HashPolicy* msg) { const upb_MiniTableField field = {1, UPB_SIZE(4, 8), -1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; _upb_Message_ClearNonExtensionField(msg, &field); } UPB_INLINE const envoy_type_v3_HashPolicy_SourceIp* envoy_type_v3_HashPolicy_source_ip(const envoy_type_v3_HashPolicy* msg) { const envoy_type_v3_HashPolicy_SourceIp* default_val = NULL; const envoy_type_v3_HashPolicy_SourceIp* ret; const upb_MiniTableField field = {1, UPB_SIZE(4, 8), -1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); return ret; } UPB_INLINE bool envoy_type_v3_HashPolicy_has_source_ip(const envoy_type_v3_HashPolicy* msg) { const upb_MiniTableField field = {1, UPB_SIZE(4, 8), -1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; return _upb_Message_HasNonExtensionField(msg, &field); } UPB_INLINE void envoy_type_v3_HashPolicy_clear_filter_state(envoy_type_v3_HashPolicy* msg) { const upb_MiniTableField field = {2, UPB_SIZE(4, 8), -1, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; _upb_Message_ClearNonExtensionField(msg, &field); } UPB_INLINE const envoy_type_v3_HashPolicy_FilterState* envoy_type_v3_HashPolicy_filter_state(const envoy_type_v3_HashPolicy* msg) { const envoy_type_v3_HashPolicy_FilterState* default_val = NULL; const envoy_type_v3_HashPolicy_FilterState* ret; const upb_MiniTableField field = {2, UPB_SIZE(4, 8), -1, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); return ret; } UPB_INLINE bool envoy_type_v3_HashPolicy_has_filter_state(const envoy_type_v3_HashPolicy* msg) { const upb_MiniTableField field = {2, UPB_SIZE(4, 8), -1, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; return _upb_Message_HasNonExtensionField(msg, &field); } UPB_INLINE void envoy_type_v3_HashPolicy_set_source_ip(envoy_type_v3_HashPolicy *msg, envoy_type_v3_HashPolicy_SourceIp* value) { const upb_MiniTableField field = {1, UPB_SIZE(4, 8), -1, 0, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; _upb_Message_SetNonExtensionField(msg, &field, &value); } UPB_INLINE struct envoy_type_v3_HashPolicy_SourceIp* envoy_type_v3_HashPolicy_mutable_source_ip(envoy_type_v3_HashPolicy* msg, upb_Arena* arena) { struct envoy_type_v3_HashPolicy_SourceIp* sub = (struct envoy_type_v3_HashPolicy_SourceIp*)envoy_type_v3_HashPolicy_source_ip(msg); if (sub == NULL) { sub = (struct envoy_type_v3_HashPolicy_SourceIp*)_upb_Message_New(&envoy_type_v3_HashPolicy_SourceIp_msg_init, arena); if (sub) envoy_type_v3_HashPolicy_set_source_ip(msg, sub); } return sub; } UPB_INLINE void envoy_type_v3_HashPolicy_set_filter_state(envoy_type_v3_HashPolicy *msg, envoy_type_v3_HashPolicy_FilterState* value) { const upb_MiniTableField field = {2, UPB_SIZE(4, 8), -1, 1, 11, (int)kUpb_FieldMode_Scalar | ((int)UPB_SIZE(kUpb_FieldRep_4Byte, kUpb_FieldRep_8Byte) << kUpb_FieldRep_Shift)}; _upb_Message_SetNonExtensionField(msg, &field, &value); } UPB_INLINE struct envoy_type_v3_HashPolicy_FilterState* envoy_type_v3_HashPolicy_mutable_filter_state(envoy_type_v3_HashPolicy* msg, upb_Arena* arena) { struct envoy_type_v3_HashPolicy_FilterState* sub = (struct envoy_type_v3_HashPolicy_FilterState*)envoy_type_v3_HashPolicy_filter_state(msg); if (sub == NULL) { sub = (struct envoy_type_v3_HashPolicy_FilterState*)_upb_Message_New(&envoy_type_v3_HashPolicy_FilterState_msg_init, arena); if (sub) envoy_type_v3_HashPolicy_set_filter_state(msg, sub); } return sub; } /* envoy.type.v3.HashPolicy.SourceIp */ UPB_INLINE envoy_type_v3_HashPolicy_SourceIp* envoy_type_v3_HashPolicy_SourceIp_new(upb_Arena* arena) { return (envoy_type_v3_HashPolicy_SourceIp*)_upb_Message_New(&envoy_type_v3_HashPolicy_SourceIp_msg_init, arena); } UPB_INLINE envoy_type_v3_HashPolicy_SourceIp* envoy_type_v3_HashPolicy_SourceIp_parse(const char* buf, size_t size, upb_Arena* arena) { envoy_type_v3_HashPolicy_SourceIp* ret = envoy_type_v3_HashPolicy_SourceIp_new(arena); if (!ret) return NULL; if (upb_Decode(buf, size, ret, &envoy_type_v3_HashPolicy_SourceIp_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; } UPB_INLINE envoy_type_v3_HashPolicy_SourceIp* envoy_type_v3_HashPolicy_SourceIp_parse_ex(const char* buf, size_t size, const upb_ExtensionRegistry* extreg, int options, upb_Arena* arena) { envoy_type_v3_HashPolicy_SourceIp* ret = envoy_type_v3_HashPolicy_SourceIp_new(arena); if (!ret) return NULL; if (upb_Decode(buf, size, ret, &envoy_type_v3_HashPolicy_SourceIp_msg_init, extreg, options, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; } UPB_INLINE char* envoy_type_v3_HashPolicy_SourceIp_serialize(const envoy_type_v3_HashPolicy_SourceIp* msg, upb_Arena* arena, size_t* len) { char* ptr; (void)upb_Encode(msg, &envoy_type_v3_HashPolicy_SourceIp_msg_init, 0, arena, &ptr, len); return ptr; } UPB_INLINE char* envoy_type_v3_HashPolicy_SourceIp_serialize_ex(const envoy_type_v3_HashPolicy_SourceIp* msg, int options, upb_Arena* arena, size_t* len) { char* ptr; (void)upb_Encode(msg, &envoy_type_v3_HashPolicy_SourceIp_msg_init, options, arena, &ptr, len); return ptr; } /* envoy.type.v3.HashPolicy.FilterState */ UPB_INLINE envoy_type_v3_HashPolicy_FilterState* envoy_type_v3_HashPolicy_FilterState_new(upb_Arena* arena) { return (envoy_type_v3_HashPolicy_FilterState*)_upb_Message_New(&envoy_type_v3_HashPolicy_FilterState_msg_init, arena); } UPB_INLINE envoy_type_v3_HashPolicy_FilterState* envoy_type_v3_HashPolicy_FilterState_parse(const char* buf, size_t size, upb_Arena* arena) { envoy_type_v3_HashPolicy_FilterState* ret = envoy_type_v3_HashPolicy_FilterState_new(arena); if (!ret) return NULL; if (upb_Decode(buf, size, ret, &envoy_type_v3_HashPolicy_FilterState_msg_init, NULL, 0, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; } UPB_INLINE envoy_type_v3_HashPolicy_FilterState* envoy_type_v3_HashPolicy_FilterState_parse_ex(const char* buf, size_t size, const upb_ExtensionRegistry* extreg, int options, upb_Arena* arena) { envoy_type_v3_HashPolicy_FilterState* ret = envoy_type_v3_HashPolicy_FilterState_new(arena); if (!ret) return NULL; if (upb_Decode(buf, size, ret, &envoy_type_v3_HashPolicy_FilterState_msg_init, extreg, options, arena) != kUpb_DecodeStatus_Ok) { return NULL; } return ret; } UPB_INLINE char* envoy_type_v3_HashPolicy_FilterState_serialize(const envoy_type_v3_HashPolicy_FilterState* msg, upb_Arena* arena, size_t* len) { char* ptr; (void)upb_Encode(msg, &envoy_type_v3_HashPolicy_FilterState_msg_init, 0, arena, &ptr, len); return ptr; } UPB_INLINE char* envoy_type_v3_HashPolicy_FilterState_serialize_ex(const envoy_type_v3_HashPolicy_FilterState* msg, int options, upb_Arena* arena, size_t* len) { char* ptr; (void)upb_Encode(msg, &envoy_type_v3_HashPolicy_FilterState_msg_init, options, arena, &ptr, len); return ptr; } UPB_INLINE void envoy_type_v3_HashPolicy_FilterState_clear_key(envoy_type_v3_HashPolicy_FilterState* msg) { const upb_MiniTableField field = {1, 0, 0, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; _upb_Message_ClearNonExtensionField(msg, &field); } UPB_INLINE upb_StringView envoy_type_v3_HashPolicy_FilterState_key(const envoy_type_v3_HashPolicy_FilterState* msg) { upb_StringView default_val = upb_StringView_FromString(""); upb_StringView ret; const upb_MiniTableField field = {1, 0, 0, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; _upb_Message_GetNonExtensionField(msg, &field, &default_val, &ret); return ret; } UPB_INLINE void envoy_type_v3_HashPolicy_FilterState_set_key(envoy_type_v3_HashPolicy_FilterState *msg, upb_StringView value) { const upb_MiniTableField field = {1, 0, 0, kUpb_NoSub, 9, (int)kUpb_FieldMode_Scalar | ((int)kUpb_FieldRep_StringView << kUpb_FieldRep_Shift)}; _upb_Message_SetNonExtensionField(msg, &field, &value); } extern const upb_MiniTableFile envoy_type_v3_hash_policy_proto_upb_file_layout; #ifdef __cplusplus } /* extern "C" */ #endif #include "upb/port/undef.inc" #endif /* ENVOY_TYPE_V3_HASH_POLICY_PROTO_UPB_H_ */
137ae9230987951d3012e801c0493f5a9f73b5f2
c85df9a1ad627707fc603f40f7df056af16900c9
/source/libs/libwbfs/libwbfs_os.h
045314557a05f549a264f23e687efa86ca98667a
[]
no_license
wiidev/usbloadergx
28b582c2c8231ca7f313a321a134d6784358a770
e25c4e96430524c080767679b0c4a0d7595412a8
refs/heads/enhanced
2023-08-11T18:47:12.728031
2023-01-07T23:30:02
2023-01-07T23:30:02
204,522,898
313
124
null
2023-07-21T17:06:18
2019-08-26T17:05:59
C
UTF-8
C
false
false
848
h
libwbfs_os.h
#ifndef LIBWBFS_GLUE_H #define LIBWBFS_GLUE_H #include <gctypes.h> #include "memory/mem2.h" #define debug_printf(fmt, ...); #include <stdio.h> #define wbfs_fatal(x) do { printf("\nwbfs panic: %s\n\n",x); return; } while(0) #define wbfs_error(x) do { printf("\nwbfs error: %s\n\n",x); } while(0) #include <stdlib.h> #include <malloc.h> #define wbfs_malloc(x) MEM2_alloc(x) #define wbfs_free(x) free(x) #define wbfs_ioalloc(x) MEM2_alloc(((x) + 31) & ~31) #define wbfs_iofree(x) free(x) #define wbfs_be16(x) (*((u16*)(x))) #define wbfs_be32(x) (*((u32*)(x))) #define wbfs_ntohl(x) (x) #define wbfs_htonl(x) (x) #define wbfs_ntohs(x) (x) #define wbfs_htons(x) (x) #include <string.h> #define wbfs_memcmp(x,y,z) memcmp(x,y,z) #define wbfs_memcpy(x,y,z) memcpy(x,y,z) #define wbfs_memset(x,y,z) memset(x,y,z) #endif