pike.git / src / builtin_functions.c

version» Context lines:

pike.git/src/builtin_functions.c:2923:    *! The third syntax can be used to measure time more preciely than one    *! second. It return how many seconds has passed since @[t]. The precision    *! of this function varies from system to system.    *!    *! @seealso    *! @[ctime()], @[localtime()], @[mktime()], @[gmtime()],    *! @[System.gettimeofday], @[gethrtime]    */   PMOD_EXPORT void f_time(INT32 args)   { +  struct timeval ret;    if(!args ||    (TYPEOF(Pike_sp[-args]) == T_INT && Pike_sp[-args].u.integer == 0))    { -  GETTIMEOFDAY(&current_time); +  ACCURATE_GETTIMEOFDAY(&ret); +  pop_n_elems(args); +  push_int(ret.tv_sec); +  +  return;    }else{    if(TYPEOF(Pike_sp[-args]) == T_INT && Pike_sp[-args].u.integer > 1)    {    struct timeval tmp; -  GETTIMEOFDAY(&current_time); +  ACCURATE_GETTIMEOFDAY(&ret);    tmp.tv_sec=Pike_sp[-args].u.integer;    tmp.tv_usec=0; -  my_subtract_timeval(&tmp,&current_time); +  my_subtract_timeval(&tmp,&ret);    pop_n_elems(args);    push_float( - (FLOAT_TYPE)tmp.tv_sec-((FLOAT_TYPE)tmp.tv_usec)/1000000 );    return;    }    }    pop_n_elems(args); -  push_int(current_time.tv_sec); +  INACCURATE_GETTIMEOFDAY(&ret); +  push_int(ret.tv_sec);   }      /*! @decl string crypt(string password)    *! @decl int(0..1) crypt(string typed_password, string crypted_password)    *!    *! This function crypts and verifies a short string (only the first    *! 8 characters are significant).    *!    *! The first syntax crypts the string @[password] into something that    *! is hopefully hard to decrypt.
pike.git/src/builtin_functions.c:4655:    return;    }       if(sizeof(FLOAT_TYPE)<sizeof(double))    delay += FLT_EPSILON*5; /* round up */       t0 = tv = get_real_time();    if (t0 == -1) {    /* Paranoia in case get_real_time fails. */    /* fprintf (stderr, "get_real_time failed in sleep()\n"); */ -  GETTIMEOFDAY (&gtod_t0); +  ACCURATE_GETTIMEOFDAY (&gtod_t0);    gtod_tv = gtod_t0;    }      #define FIX_LEFT() \    if (t0 == -1) { \ -  GETTIMEOFDAY (&gtod_tv); \ +  ACCURATE_GETTIMEOFDAY (&gtod_tv); \    left = delay - ((gtod_tv.tv_sec-gtod_t0.tv_sec) + \    (gtod_tv.tv_usec-gtod_t0.tv_usec)*1e-6); \    } \    else { \    tv = get_real_time(); \    left = delay - (tv - t0) * (1.0 / CPU_TIME_TICKS); \    } \    if (do_microsleep) left-=POLL_SLEEP_LIMIT;       if (!do_microsleep || delay>POLL_SLEEP_LIMIT)
pike.git/src/builtin_functions.c:4683:    for(;;)    {    double left;    /* THREADS_ALLOW may take longer time then POLL_SLEEP_LIMIT */    THREADS_ALLOW();    FIX_LEFT();    if(left>0.0)    sysleep(left);    THREADS_DISALLOW();    if(do_abort_on_signal) { -  GETTIMEOFDAY (&current_time); +  INVALIDATE_CURRENT_TIME();    return;    }    FIX_LEFT();    if(left<=0.0)    break;    check_threads_etc();    } -  GETTIMEOFDAY (&current_time); +  INVALIDATE_CURRENT_TIME();    }       if (do_microsleep) {    if (t0 == -1) {    while (delay> ((gtod_tv.tv_sec-gtod_t0.tv_sec) +    (gtod_tv.tv_usec-gtod_t0.tv_usec)*1e-6)) -  GETTIMEOFDAY (&gtod_tv); +  ACCURATE_GETTIMEOFDAY (&gtod_tv);    }    else {    while (delay> (tv - t0) * (1.0 / CPU_TIME_TICKS))    tv = get_real_time();    }    }       /* fprintf (stderr, "slept %g\n", (tv - t0) * (1.0 / CPU_TIME_TICKS)); */   }