curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Embedded platforms (without FPU's), etc.

From: Dennis Clarke <dclarke_at_blastwave.org>
Date: Mon, 2 Apr 2018 09:35:19 -0400

On 02/04/18 05:27 AM, Daniel Stenberg wrote:
> On Sat, 31 Mar 2018, Philip Prindeville wrote:
>
>> Couple of questions.  One is a broader question about tweaking the API
>> so that it uses fewer “doubles” for get curl_easy_getinfo() call, in
>> particular using fixed point since you might be running on a platform
>> such as an embedded router with a MIPS-32 or ARMv6 CPU which doesn’t
>> have floating-point… but is reasonably capable of 64-bit operations
>> (shifting, adding, subtracting, etc).
>
> We've slowly been moving in that direction over time. As Harold
> mentioned, that easily conflicts with other limitation: not having 64
> bit support.
>
> IMO, the most important thing would be to not have floating point
> operations in "the critical path" since most systems still have soft
> float support.
>

This same problem shows up in the openssl codebase also. Recently some
usage of things like "fabs()" fell into the codebase. This was caught
in the openssl-1.1.1 beta code but released out to the world in the
openssl-1.1.0h sources. Seems to happen when people go looking for a
diff in time even though the datatypes in the time structs are just
integers. Not sure where the floating point is used in the curl code
but I suspect it may be related to time calcs ?

For the sake of reference the openssl test ct_test.c was fixed in the
beta release of openssl 1.1.1 :

***************
*** 538,556 ****
    * Tests that the CT_POLICY_EVAL_CTX default time is approximately now.
    * Allow +-10 minutes, as it may compensate for clock skew.
    */
! static int test_default_ct_policy_eval_ctx_time_is_now()
   {
       int success = 0;
       CT_POLICY_EVAL_CTX *ct_policy_ctx = CT_POLICY_EVAL_CTX_new();
       const time_t default_time =
CT_POLICY_EVAL_CTX_get_time(ct_policy_ctx) /
! 1000;
       const time_t time_tolerance = 600; /* 10 minutes */

! if (fabs(difftime(time(NULL), default_time)) > time_tolerance) {
! fprintf(stderr,
! "Default CT_POLICY_EVAL_CTX time is not approximately
now.\n");
           goto end;
- }

       success = 1;
   end:
--- 496,512 ----
    * Tests that the CT_POLICY_EVAL_CTX default time is approximately now.
    * Allow +-10 minutes, as it may compensate for clock skew.
    */
! static int test_default_ct_policy_eval_ctx_time_is_now(void)
   {
       int success = 0;
       CT_POLICY_EVAL_CTX *ct_policy_ctx = CT_POLICY_EVAL_CTX_new();
       const time_t default_time =
CT_POLICY_EVAL_CTX_get_time(ct_policy_ctx) /
! 1000;
       const time_t time_tolerance = 600; /* 10 minutes */

! if (!TEST_time_t_le(abs((int)difftime(time(NULL), default_time)),
! time_tolerance))
           goto end;

       success = 1;
   end:
***************

Lovely .. people are still using difftime for some reason and then
  casting it. Anyways .. it happens.

Dennis

ps: why did umich.edu send that post to curl maillist a dozen times?
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-04-02