Back to index

php5  5.3.10
Functions
time.c File Reference
#include <config.w32.h>
#include "time.h"
#include "unistd.h"
#include "signal.h"
#include <windows.h>
#include <winbase.h>
#include <mmsystem.h>
#include <errno.h>
#include "php_win32_globals.h"

Go to the source code of this file.

Functions

int getfilesystemtime (struct timeval *time_Info)
 04-Feb-2001
PHPAPI int gettimeofday (struct timeval *time_Info, struct timezone *timezone_Info)
PHPAPI int usleep (unsigned int useconds)
PHPAPI int nanosleep (const struct timespec *rqtp, struct timespec *rmtp)

Function Documentation

int getfilesystemtime ( struct timeval *  time_Info)

04-Feb-2001

Definition at line 36 of file time.c.

{
FILETIME ft;
__int64 ff;

    GetSystemTimeAsFileTime(&ft);   /* 100 ns blocks since 01-Jan-1641 */
                                    /* resolution seems to be 0.01 sec */ 
    ff = *(__int64*)(&ft);
    time_Info->tv_sec = (int)(ff/(__int64)10000000-(__int64)11644473600);
    time_Info->tv_usec = (int)(ff % 10000000)/10;
    return 0;
}

Here is the caller graph for this function:

PHPAPI int gettimeofday ( struct timeval *  time_Info,
struct timezone timezone_Info 
)

Definition at line 51 of file time.c.

{
       __int64 timer;
       LARGE_INTEGER li;
       BOOL b;
       double dt;
       TSRMLS_FETCH();

       /* Get the time, if they want it */
       if (time_Info != NULL) {
              if (PW32G(starttime).tv_sec == 0) {
            b = QueryPerformanceFrequency(&li);
            if (!b) {
                PW32G(starttime).tv_sec = -1;
            }
            else {
                PW32G(freq) = li.QuadPart;
                b = QueryPerformanceCounter(&li);
                if (!b) {
                    PW32G(starttime).tv_sec = -1;
                }
                else {
                    getfilesystemtime(&PW32G(starttime));
                    timer = li.QuadPart;
                    dt = (double)timer/PW32G(freq);
                    PW32G(starttime).tv_usec -= (int)((dt-(int)dt)*1000000);
                    if (PW32G(starttime).tv_usec < 0) {
                        PW32G(starttime).tv_usec += 1000000;
                        --PW32G(starttime).tv_sec;
                    }
                    PW32G(starttime).tv_sec -= (int)dt;
                }
            }
        }
        if (PW32G(starttime).tv_sec > 0) {
            b = QueryPerformanceCounter(&li);
            if (!b) {
                PW32G(starttime).tv_sec = -1;
            }
            else {
                timer = li.QuadPart;
                if (timer < PW32G(lasttime)) {
                    getfilesystemtime(time_Info);
                    dt = (double)timer/PW32G(freq);
                    PW32G(starttime) = *time_Info;
                    PW32G(starttime).tv_usec -= (int)((dt-(int)dt)*1000000);
                    if (PW32G(starttime).tv_usec < 0) {
                        PW32G(starttime).tv_usec += 1000000;
                        --PW32G(starttime).tv_sec;
                    }
                    PW32G(starttime).tv_sec -= (int)dt;
                }
                else {
                    PW32G(lasttime) = timer;
                    dt = (double)timer/PW32G(freq);
                    time_Info->tv_sec = PW32G(starttime).tv_sec + (int)dt;
                    time_Info->tv_usec = PW32G(starttime).tv_usec + (int)((dt-(int)dt)*1000000);
                    if (time_Info->tv_usec >= 1000000) {
                        time_Info->tv_usec -= 1000000;
                        ++time_Info->tv_sec;
                    }
                }
            }
        }
        if (PW32G(starttime).tv_sec < 0) {
            getfilesystemtime(time_Info);
        }

       }
       /* Get the timezone, if they want it */
       if (timezone_Info != NULL) {
              _tzset();
              timezone_Info->tz_minuteswest = _timezone;
              timezone_Info->tz_dsttime = _daylight;
       }
       /* And return */
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI int nanosleep ( const struct timespec rqtp,
struct timespec rmtp 
)

Definition at line 144 of file time.c.

{
       if (rqtp->tv_nsec > 999999999) {
              /* The time interval specified 1,000,000 or more microseconds. */
              errno = EINVAL;
              return -1;
       }
       return usleep( rqtp->tv_sec * 1000000 + rqtp->tv_nsec / 1000  );
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI int usleep ( unsigned int  useconds)

Definition at line 130 of file time.c.

{
       HANDLE timer;
       LARGE_INTEGER due;

       due.QuadPart = -(10 * (__int64)useconds);

       timer = CreateWaitableTimer(NULL, TRUE, NULL);
       SetWaitableTimer(timer, &due, 0, NULL, NULL, 0);
       WaitForSingleObject(timer, INFINITE);
       CloseHandle(timer);
       return 0;
}

Here is the caller graph for this function: