示例#1
0
文件: rand.c 项目: Bernd8/quantlib
static int NXSeedRandomInternal( size_t width, void *seed )
{
    static int init = 0;
    int                        *s = (int *) seed;
    union {
        int x;
        char y[4];
    } u;

    if (!init) {
        srand(NXGetSystemTick());
        init = 1;
    }

    if (width > 3)
    {
        do
        {
            *s++ = rand();
        }
        while ((width -= 4) > 3);
    }

    if (width > 0)
    {
        char *p = (char *) s;

        u.x = rand();

        while (width > 0)
            *p++ = u.y[width--];
    }

    return APR_SUCCESS;
}
示例#2
0
APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
                                                    apr_thread_mutex_t *mutex,
                                                    apr_interval_time_t timeout){
    if (NXCondTimedWait(cond->cond, mutex->mutex,
        (timeout*1000)/NXGetSystemTick()) == NX_ETIMEDOUT) {
        return APR_TIMEUP;
    }
    return APR_SUCCESS;
}