void iip_color_trace_hab::_exec_ushrt( long l_width, long l_height, long l_area_xpos, long l_area_ypos, long l_area_xsize, long l_area_ysize, long l_channels, unsigned short *ushrtp_in, double d_in_max_div, calcu_color_trace_hab *clp_calcu_color_trace_hab, unsigned short *ushrtp_out, double d_out_max_mul ) { long l_start, l_scansize; long xx,yy; double d_red, d_gre, d_blu; double d_hh, d_aa, d_bb; unsigned short *ushrtp_in_x, *ushrtp_out_x; calcu_rgb_to_hsv cl_rgb_to_hab; l_height; l_scansize = l_width * l_channels; l_start = l_area_ypos * l_scansize + l_area_xpos * l_channels; ushrtp_in += l_start; ushrtp_out += l_start; /* histogramを初期化する */ this->cl_hab_hist.init( l_area_xsize, l_area_ysize ); for (yy = 0L; yy < l_area_ysize; ++yy) { /* カウントダウン表示中 */ if (ON == this->get_i_cv_sw()) { pri_funct_cv_run(yy); } ushrtp_in_x = ushrtp_in; ushrtp_out_x = ushrtp_out; for (xx = 0L; xx < l_area_xsize; ++xx) { cl_rgb_to_hab.to_hsv( (double)(ushrtp_in_x[CH_RED])/d_in_max_div, (double)(ushrtp_in_x[CH_GRE])/d_in_max_div, (double)(ushrtp_in_x[CH_BLU])/d_in_max_div, &d_hh, &d_aa, &d_bb ); /* histogramを設定する */ this->cl_hab_hist.add(d_hh,d_aa,d_bb); clp_calcu_color_trace_hab->exec( d_hh, d_aa, d_bb, &d_red, &d_gre, &d_blu ); ushrtp_out_x[CH_RED] = US(d_red * d_out_max_mul); ushrtp_out_x[CH_GRE] = US(d_gre * d_out_max_mul); ushrtp_out_x[CH_BLU] = US(d_blu * d_out_max_mul); ushrtp_in_x += l_channels; ushrtp_out_x += l_channels; } ushrtp_in += l_scansize; ushrtp_out += l_scansize; } }
void MeteoTemp::prepareStep1(bool first) { nextTick = UTime::now() + (first ? 0 : READ_INTERVAL); priority = 3; tickExpectedDuration = US(50); nextStep = 1; }
void MeteoTemp::prepareStep2() { nextTick = UTime::now() + 250000; priority = 0; tickExpectedDuration = US(100); nextStep = 2; }
float UltrasonicSensor::get_distance() { Ultrasonic US(_trigger_pin,_echo_pin); long microsec = US.timing(); float distance = US.CalcDistance(microsec,Ultrasonic::CM); return(distance); }
static int sqlite_callback(void *arg, int argc, char **argv, char **azColName) { struct strbuf *res = arg; int i; /* For second and subsequent results, insert \n */ if (res->string != NULL) res->string = string_cat(res->string, &res->size, &res->len, US"\n", 1); if (argc > 1) { /* For multiple fields, include the field name too */ for (i = 0; i < argc; i++) { uschar *value = US((argv[i] != NULL)? argv[i]:"<NULL>"); res->string = lf_quote(US azColName[i], value, Ustrlen(value), res->string, &res->size, &res->len); } } else { res->string = string_append(res->string, &res->size, &res->len, 1, (argv[0] != NULL)? argv[0]:"<NULL>"); } res->string[res->len] = 0; return 0; }
void PluralRulesTest::testGetSamples() { // TODO: fix samples, re-enable this test. // no get functional equivalent API in ICU4C, so just // test every locale... UErrorCode status = U_ZERO_ERROR; int32_t numLocales; const Locale* locales = Locale::getAvailableLocales(numLocales); double values[1000]; for (int32_t i = 0; U_SUCCESS(status) && i < numLocales; ++i) { PluralRules *rules = PluralRules::forLocale(locales[i], status); if (U_FAILURE(status)) { break; } StringEnumeration *keywords = rules->getKeywords(status); if (U_FAILURE(status)) { delete rules; break; } const UnicodeString* keyword; while (NULL != (keyword = keywords->snext(status))) { int32_t count = rules->getSamples(*keyword, values, LENGTHOF(values), status); if (U_FAILURE(status)) { errln(UNICODE_STRING_SIMPLE("getSamples() failed for locale ") + locales[i].getName() + UNICODE_STRING_SIMPLE(", keyword ") + *keyword); continue; } if (count == 0) { // TODO: Lots of these. // errln(UNICODE_STRING_SIMPLE("no samples for keyword ") + *keyword + UNICODE_STRING_SIMPLE(" in locale ") + locales[i].getName() ); } if (count > LENGTHOF(values)) { errln(UNICODE_STRING_SIMPLE("getSamples()=") + count + UNICODE_STRING_SIMPLE(", too many values, for locale ") + locales[i].getName() + UNICODE_STRING_SIMPLE(", keyword ") + *keyword); count = LENGTHOF(values); } for (int32_t j = 0; j < count; ++j) { if (values[j] == UPLRULES_NO_UNIQUE_VALUE) { errln("got 'no unique value' among values"); } else { UnicodeString resultKeyword = rules->select(values[j]); // if (strcmp(locales[i].getName(), "uk") == 0) { // Debug only. // std::cout << " uk " << US(resultKeyword).cstr() << " " << values[j] << std::endl; // } if (*keyword != resultKeyword) { errln("file %s, line %d, Locale %s, sample for keyword \"%s\": %g, select(%g) returns keyword \"%s\"", __FILE__, __LINE__, locales[i].getName(), US(*keyword).cstr(), values[j], values[j], US(resultKeyword).cstr()); } } } } delete keywords; delete rules; } }
void PluralRulesTest::checkSelect(const LocalPointer<PluralRules> &rules, UErrorCode &status, int32_t line, const char *keyword, ...) { // The varargs parameters are a const char* strings, each being a decimal number. // The formatting of the numbers as strings is significant, e.g. // the difference between "2" and "2.0" can affect which rule matches (which keyword is selected). // Note: rules parameter is a LocalPointer reference rather than a PluralRules * to avoid having // to write getAlias() at every (numerous) call site. if (U_FAILURE(status)) { errln("file %s, line %d, ICU error status: %s.", __FILE__, line, u_errorName(status)); status = U_ZERO_ERROR; return; } if (rules == NULL) { errln("file %s, line %d: rules pointer is NULL", __FILE__, line); return; } va_list ap; va_start(ap, keyword); for (;;) { const char *num = va_arg(ap, const char *); if (strcmp(num, END_MARK) == 0) { break; } // DigitList is a convenient way to parse the decimal number string and get a double. DigitList dl; dl.set(StringPiece(num), status); if (U_FAILURE(status)) { errln("file %s, line %d, ICU error status: %s.", __FILE__, line, u_errorName(status)); status = U_ZERO_ERROR; continue; } double numDbl = dl.getDouble(); const char *decimalPoint = strchr(num, '.'); int fractionDigitCount = decimalPoint == NULL ? 0 : (num + strlen(num) - 1) - decimalPoint; int fractionDigits = fractionDigitCount == 0 ? 0 : atoi(decimalPoint + 1); FixedDecimal ni(numDbl, fractionDigitCount, fractionDigits); UnicodeString actualKeyword = rules->select(ni); if (actualKeyword != UnicodeString(keyword)) { errln("file %s, line %d, select(%s) returned incorrect keyword. Expected %s, got %s", __FILE__, line, num, keyword, US(actualKeyword).cstr()); } } va_end(ap); }
void _show(MENU *m) { int r, c; WINDOW *us; if (Posted(m) || Indriver(m)) { (void) mvderwin(Sub(m), Top(m), 0); us = US(m); getmaxyx(us, r, c); r = min(Height(m), r); c = min(Width(m), c); (void) copywin(Sub(m), us, 0, 0, 0, 0, r-1, c-1, FALSE); _position_cursor(m); } }
bool MM () { double rsTR, rsPR, rsLG; long lsTR, lsPR, lsLG; rsTR = TR (); rsPR = log10C (PR32 (D2B (pow (2, rsTR)), Odd_), rsTR); rsLG = log10C (rsTR, PR32 (D2B (rsTR), Odd_)); lsTR = D2B (rsTR); lsPR = D2B (rsPR); lsLG = D2B (rsLG); unsigned long l = 0xAC1DFACEL; struct int_sqrt q, m; US (l, &q); unsigned long rZ = lsTR + q.sqrt + lsPR + lsLG; if (construct (rZ) == true) { return (true); } else { return (false); }; }
#include "trace.h" #pragma varargck type "t" int64_t #pragma varargck type "U" uint64_t #define NS(x) ((int64_t)x) #define US(x) (NS(x) * 1000ULL) #define MS(x) (US(x) * 1000ULL) #define S(x) (MS(x) * 1000ULL) #define numblocks(a, b) (((a) + (b) - 1) / (b)) #define roundup(a, b) (numblocks((a), (b)) * (b)) enum { OneRound = MS(1)/2LL, MilliRound = US(1)/2LL, }; typedef struct Event Event; typedef struct Task Task; struct Event { Traceevent; int64_t etime; /* length of block to draw */ }; struct Task { int pid; char *name; int nevents; Event *events; int64_t tstart;
static int dnsdb_find(void *handle, uschar *filename, const uschar *keystring, int length, uschar **result, uschar **errmsg, uint *do_cache) { int rc; int size = 256; int ptr = 0; int sep = 0; int defer_mode = PASS; int dnssec_mode = OK; int save_retrans = dns_retrans; int save_retry = dns_retry; int type; int failrc = FAIL; const uschar *outsep = CUS"\n"; const uschar *outsep2 = NULL; uschar *equals, *domain, *found; /* Because we're the working in the search pool, we try to reclaim as much store as possible later, so we preallocate the result here */ uschar *yield = store_get(size); dns_record *rr; dns_answer dnsa; dns_scan dnss; handle = handle; /* Keep picky compilers happy */ filename = filename; length = length; do_cache = do_cache; /* If the string starts with '>' we change the output separator. If it's followed by ';' or ',' we set the TXT output separator. */ while (isspace(*keystring)) keystring++; if (*keystring == '>') { outsep = keystring + 1; keystring += 2; if (*keystring == ',') { outsep2 = keystring + 1; keystring += 2; } else if (*keystring == ';') { outsep2 = US""; keystring++; } while (isspace(*keystring)) keystring++; } /* Check for a modifier keyword. */ for (;;) { if (strncmpic(keystring, US"defer_", 6) == 0) { keystring += 6; if (strncmpic(keystring, US"strict", 6) == 0) { defer_mode = DEFER; keystring += 6; } else if (strncmpic(keystring, US"lax", 3) == 0) { defer_mode = PASS; keystring += 3; } else if (strncmpic(keystring, US"never", 5) == 0) { defer_mode = OK; keystring += 5; } else { *errmsg = US"unsupported dnsdb defer behaviour"; return DEFER; } } else if (strncmpic(keystring, US"dnssec_", 7) == 0) { keystring += 7; if (strncmpic(keystring, US"strict", 6) == 0) { dnssec_mode = DEFER; keystring += 6; } else if (strncmpic(keystring, US"lax", 3) == 0) { dnssec_mode = PASS; keystring += 3; } else if (strncmpic(keystring, US"never", 5) == 0) { dnssec_mode = OK; keystring += 5; } else { *errmsg = US"unsupported dnsdb dnssec behaviour"; return DEFER; } } else if (strncmpic(keystring, US"retrans_", 8) == 0) { int timeout_sec; if ((timeout_sec = readconf_readtime(keystring += 8, ',', FALSE)) <= 0) { *errmsg = US"unsupported dnsdb timeout value"; return DEFER; } dns_retrans = timeout_sec; while (*keystring != ',') keystring++; } else if (strncmpic(keystring, US"retry_", 6) == 0) { int retries; if ((retries = (int)strtol(CCS keystring + 6, CSS &keystring, 0)) < 0) { *errmsg = US"unsupported dnsdb retry count"; return DEFER; } dns_retry = retries; } else break; while (isspace(*keystring)) keystring++; if (*keystring++ != ',') { *errmsg = US"dnsdb modifier syntax error"; return DEFER; } while (isspace(*keystring)) keystring++; } /* Figure out the "type" value if it is not T_TXT. If the keystring contains an = this must be preceded by a valid type name. */ type = T_TXT; if ((equals = Ustrchr(keystring, '=')) != NULL) { int i, len; uschar *tend = equals; while (tend > keystring && isspace(tend[-1])) tend--; len = tend - keystring; for (i = 0; i < nelem(type_names); i++) if (len == Ustrlen(type_names[i]) && strncmpic(keystring, US type_names[i], len) == 0) { type = type_values[i]; break; } if (i >= nelem(type_names)) { *errmsg = US"unsupported DNS record type"; return DEFER; } keystring = equals + 1; while (isspace(*keystring)) keystring++; } /* Initialize the resolver in case this is the first time it has been used. */ dns_init(FALSE, FALSE, dnssec_mode != OK); /* The remainder of the string must be a list of domains. As long as the lookup for at least one of them succeeds, we return success. Failure means that none of them were found. The original implementation did not support a list of domains. Adding the list feature is compatible, except in one case: when PTR records are being looked up for a single IPv6 address. Fortunately, we can hack in a compatibility feature here: If the type is PTR and no list separator is specified, and the entire remaining string is valid as an IP address, set an impossible separator so that it is treated as one item. */ if (type == T_PTR && keystring[0] != '<' && string_is_ip_address(keystring, NULL) != 0) sep = -1; /* SPF strings should be concatenated without a separator, thus make it the default if not defined (see RFC 4408 section 3.1.3). Multiple SPF records are forbidden (section 3.1.2) but are currently not handled specially, thus they are concatenated with \n by default. MX priority and value are space-separated by default. SRV and TLSA record parts are space-separated by default. */ if (!outsep2) switch(type) { case T_SPF: outsep2 = US""; break; case T_SRV: case T_MX: case T_TLSA: outsep2 = US" "; break; } /* Now scan the list and do a lookup for each item */ while ((domain = string_nextinlist(&keystring, &sep, NULL, 0))) { uschar rbuffer[256]; int searchtype = (type == T_CSA)? T_SRV : /* record type we want */ (type == T_MXH)? T_MX : (type == T_ZNS)? T_NS : type; /* If the type is PTR or CSA, we have to construct the relevant magic lookup key if the original is an IP address (some experimental protocols are using PTR records for different purposes where the key string is a host name, and Exim's extended CSA can be keyed by domains or IP addresses). This code for doing the reversal is now in a separate function. */ if ((type == T_PTR || type == T_CSA) && string_is_ip_address(domain, NULL) != 0) { dns_build_reverse(domain, rbuffer); domain = rbuffer; } do { DEBUG(D_lookup) debug_printf("dnsdb key: %s\n", domain); /* Do the lookup and sort out the result. There are four special types that are handled specially: T_CSA, T_ZNS, T_ADDRESSES and T_MXH. The first two are handled in a special lookup function so that the facility could be used from other parts of the Exim code. T_ADDRESSES is handled by looping over the types of A lookup. T_MXH affects only what happens later on in this function, but for tidiness it is handled by the "special". If the lookup fails, continue with the next domain. In the case of DEFER, adjust the final "nothing found" result, but carry on to the next domain. */ found = domain; #if HAVE_IPV6 if (type == T_ADDRESSES) /* NB cannot happen unless HAVE_IPV6 */ { if (searchtype == T_ADDRESSES) searchtype = T_AAAA; else if (searchtype == T_AAAA) searchtype = T_A; rc = dns_special_lookup(&dnsa, domain, searchtype, CUSS &found); } else #endif rc = dns_special_lookup(&dnsa, domain, type, CUSS &found); lookup_dnssec_authenticated = dnssec_mode==OK ? NULL : dns_is_secure(&dnsa) ? US"yes" : US"no"; if (rc == DNS_NOMATCH || rc == DNS_NODATA) continue; if ( rc != DNS_SUCCEED || (dnssec_mode == DEFER && !dns_is_secure(&dnsa)) ) { if (defer_mode == DEFER) { dns_retrans = save_retrans; dns_retry = save_retry; dns_init(FALSE, FALSE, FALSE); /* clr dnssec bit */ return DEFER; /* always defer */ } if (defer_mode == PASS) failrc = DEFER; /* defer only if all do */ continue; /* treat defer as fail */ } /* Search the returned records */ for (rr = dns_next_rr(&dnsa, &dnss, RESET_ANSWERS); rr != NULL; rr = dns_next_rr(&dnsa, &dnss, RESET_NEXT)) { if (rr->type != searchtype) continue; if (*do_cache > rr->ttl) *do_cache = rr->ttl; if (type == T_A || type == T_AAAA || type == T_ADDRESSES) { dns_address *da; for (da = dns_address_from_rr(&dnsa, rr); da; da = da->next) { if (ptr != 0) yield = string_catn(yield, &size, &ptr, outsep, 1); yield = string_cat(yield, &size, &ptr, da->address); } continue; } /* Other kinds of record just have one piece of data each, but there may be several of them, of course. */ if (ptr != 0) yield = string_catn(yield, &size, &ptr, outsep, 1); if (type == T_TXT || type == T_SPF) { if (outsep2 == NULL) { /* output only the first item of data */ yield = string_catn(yield, &size, &ptr, (uschar *)(rr->data+1), (rr->data)[0]); } else { /* output all items */ int data_offset = 0; while (data_offset < rr->size) { uschar chunk_len = (rr->data)[data_offset++]; if (outsep2[0] != '\0' && data_offset != 1) yield = string_catn(yield, &size, &ptr, outsep2, 1); yield = string_catn(yield, &size, &ptr, US ((rr->data)+data_offset), chunk_len); data_offset += chunk_len; } } } else if (type == T_TLSA) { uint8_t usage, selector, matching_type; uint16_t i, payload_length; uschar s[MAX_TLSA_EXPANDED_SIZE]; uschar * sp = s; uschar * p = US rr->data; usage = *p++; selector = *p++; matching_type = *p++; /* What's left after removing the first 3 bytes above */ payload_length = rr->size - 3; sp += sprintf(CS s, "%d%c%d%c%d%c", usage, *outsep2, selector, *outsep2, matching_type, *outsep2); /* Now append the cert/identifier, one hex char at a time */ for (i=0; i < payload_length && sp-s < (MAX_TLSA_EXPANDED_SIZE - 4); i++) sp += sprintf(CS sp, "%02x", (unsigned char)p[i]); yield = string_cat(yield, &size, &ptr, s); } else /* T_CNAME, T_CSA, T_MX, T_MXH, T_NS, T_PTR, T_SOA, T_SRV */ { int priority, weight, port; uschar s[264]; uschar * p = US rr->data; switch (type) { case T_MXH: /* mxh ignores the priority number and includes only the hostnames */ GETSHORT(priority, p); break; case T_MX: GETSHORT(priority, p); sprintf(CS s, "%d%c", priority, *outsep2); yield = string_cat(yield, &size, &ptr, s); break; case T_SRV: GETSHORT(priority, p); GETSHORT(weight, p); GETSHORT(port, p); sprintf(CS s, "%d%c%d%c%d%c", priority, *outsep2, weight, *outsep2, port, *outsep2); yield = string_cat(yield, &size, &ptr, s); break; case T_CSA: /* See acl_verify_csa() for more comments about CSA. */ GETSHORT(priority, p); GETSHORT(weight, p); GETSHORT(port, p); if (priority != 1) continue; /* CSA version must be 1 */ /* If the CSA record we found is not the one we asked for, analyse the subdomain assertions in the port field, else analyse the direct authorization status in the weight field. */ if (Ustrcmp(found, domain) != 0) { if (port & 1) *s = 'X'; /* explicit authorization required */ else *s = '?'; /* no subdomain assertions here */ } else { if (weight < 2) *s = 'N'; /* not authorized */ else if (weight == 2) *s = 'Y'; /* authorized */ else if (weight == 3) *s = '?'; /* unauthorizable */ else continue; /* invalid */ } s[1] = ' '; yield = string_catn(yield, &size, &ptr, s, 2); break; default: break; } /* GETSHORT() has advanced the pointer to the target domain. */ rc = dn_expand(dnsa.answer, dnsa.answer + dnsa.answerlen, p, (DN_EXPAND_ARG4_TYPE)s, sizeof(s)); /* If an overlong response was received, the data will have been truncated and dn_expand may fail. */ if (rc < 0) { log_write(0, LOG_MAIN, "host name alias list truncated: type=%s " "domain=%s", dns_text_type(type), domain); break; } else yield = string_cat(yield, &size, &ptr, s); if (type == T_SOA && outsep2 != NULL) { unsigned long serial, refresh, retry, expire, minimum; p += rc; yield = string_catn(yield, &size, &ptr, outsep2, 1); rc = dn_expand(dnsa.answer, dnsa.answer + dnsa.answerlen, p, (DN_EXPAND_ARG4_TYPE)s, sizeof(s)); if (rc < 0) { log_write(0, LOG_MAIN, "responsible-mailbox truncated: type=%s " "domain=%s", dns_text_type(type), domain); break; } else yield = string_cat(yield, &size, &ptr, s); p += rc; GETLONG(serial, p); GETLONG(refresh, p); GETLONG(retry, p); GETLONG(expire, p); GETLONG(minimum, p); sprintf(CS s, "%c%lu%c%lu%c%lu%c%lu%c%lu", *outsep2, serial, *outsep2, refresh, *outsep2, retry, *outsep2, expire, *outsep2, minimum); yield = string_cat(yield, &size, &ptr, s); } } } /* Loop for list of returned records */ /* Loop for set of A-lookup types */ } while (type == T_ADDRESSES && searchtype != T_A); } /* Loop for list of domains */ /* Reclaim unused memory */ store_reset(yield + ptr + 1); /* If ptr == 0 we have not found anything. Otherwise, insert the terminating zero and return the result. */ dns_retrans = save_retrans; dns_retry = save_retry; dns_init(FALSE, FALSE, FALSE); /* clear the dnssec bit for getaddrbyname */ if (ptr == 0) return failrc; yield[ptr] = 0; *result = yield; return OK; }
US us(float v) { return US(v * 1000000.0); }
#define UB(f) ((f) * 0xFF) #define S(f) ((f) * 0x7FFF) #define US(f) ((f) * 0xFFFF) #define I(f) ((double)(f) * 0x7FFFFFFF) #define UI(f) ((double)(f) * 0xFFFFFFFF) /* GL 2.0 */ /* XXX This list is incomplete. */ DEFINE_TEST(glColor3b,, (B(x), B(y), B(z)), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3d,, (x, y, z), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3f,, (x, y, z), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3i,, (I(x), I(y), I(z)), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3s,, (S(x), S(y), S(z)), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3ub,, (UB(x), UB(y), UB(z)), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3ui,, (UI(x), UI(y), UI(z)), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor3us,, (US(x), US(y), US(z)), "gl_Color", RGB, FLOAT_TYPE, "") DEFINE_TEST(glColor4b,, (B(x), B(y), B(z), B(w)), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4d,, (x, y, z, w), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4f,, (x, y, z, w), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4i,, (I(x), I(y), I(z), I(w)), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4s,, (S(x), S(y), S(z), S(w)), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4ub,, (UB(x), UB(y), UB(z), UB(w)), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4ui,, (UI(x), UI(y), UI(z), UI(w)), "gl_Color", RGBA, FLOAT_TYPE, "") DEFINE_TEST(glColor4us,, (US(x), US(y), US(z), US(w)), "gl_Color",RGBA, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib1d,, (1, x), "attr", R, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib1f,, (1, x), "attr", R, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib1s,, (1, S(x)), "attr * vec4(1.0/32768.0, 1.0, 1.0, 1.0)", R, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib2d,, (1, x, y), "attr", RG, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib2f,, (1, x, y), "attr", RG, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib2s,, (1, S(x), S(y)), "attr * vec4(vec2(1.0/32768.0), 1.0, 1.0)", RG, FLOAT_TYPE, "") DEFINE_TEST(glVertexAttrib3d,, (1, x, y, z), "attr", RGB, FLOAT_TYPE, "")
static void BeginSonarSequence(void) { waiting = false; status = PULSE; GPIOPinWrite(GPIO_PORTD_BASE, GPIO_PIN_2, GPIO_PIN_2); TIME(US(8)); }
void LineSensorReadContinuously(tLineSensor *ls, float s) { LineSensorReadContinuouslyUS(ls, US(s)); }
uschar * rfc2047_decode2(uschar *string, BOOL lencheck, uschar *target, int zeroval, int *lenptr, int *sizeptr, uschar **error) { int size = Ustrlen(string); size_t dlen; uschar *dptr; gstring *yield; uschar *mimeword, *q1, *q2, *endword; *error = NULL; mimeword = decode_mimeword(string, lencheck, &q1, &q2, &endword, &dlen, &dptr); if (!mimeword) { if (lenptr) *lenptr = size; return string; } /* Scan through the string, decoding MIME words and copying intermediate text, building the result as we go. The result may be longer than the input if it is translated into a multibyte code such as UTF-8. That's why we use the dynamic string building code. */ yield = store_get(sizeof(gstring) + ++size); yield->size = size; yield->ptr = 0; yield->s = US(yield + 1); while (mimeword) { #if HAVE_ICONV iconv_t icd = (iconv_t)(-1); #endif if (mimeword != string) yield = string_catn(yield, string, mimeword - string); /* Do a charset translation if required. This is supported only on hosts that have the iconv() function. Translation errors set error, but carry on, using the untranslated data. If there is more than one error, the message passed back refers to the final one. We use a loop to cater for the case of long strings - the RFC puts limits on the length, but it's best to be robust. */ #if HAVE_ICONV *q1 = 0; if (target != NULL && strcmpic(target, mimeword+2) != 0) { icd = iconv_open(CS target, CS(mimeword+2)); if (icd == (iconv_t)(-1)) { *error = string_sprintf("iconv_open(\"%s\", \"%s\") failed: %s%s", target, mimeword+2, strerror(errno), (errno == EINVAL)? " (maybe unsupported conversion)" : ""); } } *q1 = '?'; #endif while (dlen > 0) { uschar *tptr = NULL; /* Stops compiler warning */ int tlen = -1; #if HAVE_ICONV uschar tbuffer[256]; uschar *outptr = tbuffer; size_t outleft = sizeof(tbuffer); /* If translation is required, go for it. */ if (icd != (iconv_t)(-1)) { (void)iconv(icd, (ICONV_ARG2_TYPE)(&dptr), &dlen, CSS &outptr, &outleft); /* If outptr has been adjusted, there is some output. Set up to add it to the output buffer. The function will have adjusted dptr and dlen. If iconv() stopped because of an error, we'll pick it up next time when there's no output. If there is no output, we expect there to have been a translation error, because we know there was at least one input byte. We leave the value of tlen as -1, which causes the rest of the input to be copied verbatim. */ if (outptr > tbuffer) { tptr = tbuffer; tlen = outptr - tbuffer; } else { DEBUG(D_any) debug_printf("iconv error translating \"%.*s\" to %s: " "%s\n", (int)(endword + 2 - mimeword), mimeword, target, strerror(errno)); } } #endif /* No charset translation is happening or there was a translation error; just set up the original as the string to be added, and mark it all used. */ if (tlen == -1) { tptr = dptr; tlen = dlen; dlen = 0; } /* Deal with zero values; convert them if requested. */ if (zeroval != 0) for (int i = 0; i < tlen; i++) if (tptr[i] == 0) tptr[i] = zeroval; /* Add the new string onto the result */ yield = string_catn(yield, tptr, tlen); } #if HAVE_ICONV if (icd != (iconv_t)(-1)) iconv_close(icd); #endif /* Update string past the MIME word; skip any white space if the next thing is another MIME word. */ string = endword + 2; mimeword = decode_mimeword(string, lencheck, &q1, &q2, &endword, &dlen, &dptr); if (mimeword) { uschar *s = string; while (isspace(*s)) s++; if (s == mimeword) string = s; } } /* Copy the remaining characters of the string, zero-terminate it, and return the length as well if requested. */ yield = string_cat(yield, string); if (lenptr) *lenptr = yield->ptr; if (sizeptr) *sizeptr = yield->size; return string_from_gstring(yield); }
void Panama<B>::Iterate(unsigned int count, const word32 *p, word32 *z, const word32 *y) { unsigned int bstart = m_bstart; word32 *const a = m_state; #define c (a+17) #define b ((Stage *)(a+34)) // output #define OA(i) z[i] = ConditionalByteReverse(B::ToEnum(), a[i+9]) #define OX(i) z[i] = y[i] ^ ConditionalByteReverse(B::ToEnum(), a[i+9]) // buffer update #define US(i) {word32 t=b0[i]; b0[i]=ConditionalByteReverse(B::ToEnum(), p[i])^t; b25[(i+6)%8]^=t;} #define UL(i) {word32 t=b0[i]; b0[i]=a[i+1]^t; b25[(i+6)%8]^=t;} // gamma and pi #define GP(i) c[5*i%17] = rotlFixed(a[i] ^ (a[(i+1)%17] | ~a[(i+2)%17]), ((5*i%17)*((5*i%17)+1)/2)%32) // theta and sigma #define T(i,x) a[i] = c[i] ^ c[(i+1)%17] ^ c[(i+4)%17] ^ x #define TS1S(i) T(i+1, ConditionalByteReverse(B::ToEnum(), p[i])) #define TS1L(i) T(i+1, b4[i]) #define TS2(i) T(i+9, b16[i]) while (count--) { if (z) { if (y) { OX(0); OX(1); OX(2); OX(3); OX(4); OX(5); OX(6); OX(7); y += 8; } else { OA(0); OA(1); OA(2); OA(3); OA(4); OA(5); OA(6); OA(7); } z += 8; } word32 *const b16 = b[(bstart+16) % STAGES]; word32 *const b4 = b[(bstart+4) % STAGES]; bstart = (bstart + STAGES - 1) % STAGES; word32 *const b0 = b[bstart]; word32 *const b25 = b[(bstart+25) % STAGES]; if (p) { US(0); US(1); US(2); US(3); US(4); US(5); US(6); US(7); } else { UL(0); UL(1); UL(2); UL(3); UL(4); UL(5); UL(6); UL(7); } GP(0); GP(1); GP(2); GP(3); GP(4); GP(5); GP(6); GP(7); GP(8); GP(9); GP(10); GP(11); GP(12); GP(13); GP(14); GP(15); GP(16); T(0,1); if (p) { TS1S(0); TS1S(1); TS1S(2); TS1S(3); TS1S(4); TS1S(5); TS1S(6); TS1S(7); p += 8; } else { TS1L(0); TS1L(1); TS1L(2); TS1L(3); TS1L(4); TS1L(5); TS1L(6); TS1L(7); } TS2(0); TS2(1); TS2(2); TS2(3); TS2(4); TS2(5); TS2(6); TS2(7); } m_bstart = bstart; }
void Panama<B>::Iterate(size_t count, const word32 *p, word32 *z, const word32 *y) { word32 bstart = m_state[17]; word32 *const aPtr = m_state; word32 cPtr[17]; #define bPtr ((byte *)(aPtr+20)) // reorder the state for SSE2 // a and c: 4 8 12 16 | 3 7 11 15 | 2 6 10 14 | 1 5 9 13 | 0 // xmm0 xmm1 xmm2 xmm3 eax #define a(i) aPtr[((i)*13+16) % 17] // 13 is inverse of 4 mod 17 #define c(i) cPtr[((i)*13+16) % 17] // b: 0 4 | 1 5 | 2 6 | 3 7 #define b(i, j) b##i[(j)*2%8 + (j)/4] // output #define OA(i) z[i] = ConditionalByteReverse(B::ToEnum(), a(i+9)) #define OX(i) z[i] = y[i] ^ ConditionalByteReverse(B::ToEnum(), a(i+9)) // buffer update #define US(i) {word32 t=b(0,i); b(0,i)=ConditionalByteReverse(B::ToEnum(), p[i])^t; b(25,(i+6)%8)^=t;} #define UL(i) {word32 t=b(0,i); b(0,i)=a(i+1)^t; b(25,(i+6)%8)^=t;} // gamma and pi #define GP(i) c(5*i%17) = rotlFixed(a(i) ^ (a((i+1)%17) | ~a((i+2)%17)), ((5*i%17)*((5*i%17)+1)/2)%32) // theta and sigma #define T(i,x) a(i) = c(i) ^ c((i+1)%17) ^ c((i+4)%17) ^ x #define TS1S(i) T(i+1, ConditionalByteReverse(B::ToEnum(), p[i])) #define TS1L(i) T(i+1, b(4,i)) #define TS2(i) T(i+9, b(16,i)) while (count--) { if (z) { if (y) { OX(0); OX(1); OX(2); OX(3); OX(4); OX(5); OX(6); OX(7); y += 8; } else { OA(0); OA(1); OA(2); OA(3); OA(4); OA(5); OA(6); OA(7); } z += 8; } word32 *const b16 = (word32 *)(bPtr+((bstart+16*32) & 31*32)); word32 *const b4 = (word32 *)(bPtr+((bstart+(32-4)*32) & 31*32)); bstart += 32; word32 *const b0 = (word32 *)(bPtr+((bstart) & 31*32)); word32 *const b25 = (word32 *)(bPtr+((bstart+(32-25)*32) & 31*32)); if (p) { US(0); US(1); US(2); US(3); US(4); US(5); US(6); US(7); } else { UL(0); UL(1); UL(2); UL(3); UL(4); UL(5); UL(6); UL(7); } GP(0); GP(1); GP(2); GP(3); GP(4); GP(5); GP(6); GP(7); GP(8); GP(9); GP(10); GP(11); GP(12); GP(13); GP(14); GP(15); GP(16); T(0,1); if (p) { TS1S(0); TS1S(1); TS1S(2); TS1S(3); TS1S(4); TS1S(5); TS1S(6); TS1S(7); p += 8; } else { TS1L(0); TS1L(1); TS1L(2); TS1L(3); TS1L(4); TS1L(5); TS1L(6); TS1L(7); } TS2(0); TS2(1); TS2(2); TS2(3); TS2(4); TS2(5); TS2(6); TS2(7); } m_state[17] = bstart; }