bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

GNULib Module gettime Breaks CVS Build On Windows


From: Conrad T. Pino
Subject: GNULib Module gettime Breaks CVS Build On Windows
Date: Tue, 11 May 2004 21:39:46 -0700

Hi All,

Derek Price of the CVS Project http://www.cvshome.org/
recently pulled GNULib updates into CVS source tree and
our Windows build using Visual Studio C++ 6.0 tool set
broke.  This is what we know so far:

http://mail.gnu.org/archive/html/bug-cvs/2004-05/msg00132.html

We can provide an implementation but that's not the current
first choice.  I'm including my current idea for such in
implementation in case it's useful to you.  I believe the
design is correct but it's untested code so far.

Best regards,

Conrad Pino

Handy references:

http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/gnulib/gnulib/lib/gettime.c
http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/gnulib/gnulib/lib/gettimeofday.c

/* gettime -- get the system clock
   Copyright (C) 2002, 2004 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2, or (at your option)
   any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software Foundation,
   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */

/* Written by Paul Eggert.  */
/* Revised for Win32 API by Conrad T. Pino */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif

#include "timespec.h"
#include <windows.h>

/* FILETIME unit is 100 nanoseconds */

const static long div_100_nsec = 10000000;

/* POSIX or Unix Epoch (1-Jan-1970 00:00) in FILETIME units */

const static ULONGLONG ix_epoch = 116444736000000000;

/* Get the system time.  */

int
gettime( struct timespec *ts )
{
        ULONGLONG diff_100_nsec;
        union
        {
                FILETIME                f;
                ULARGE_INTEGER  u;
        } now;

        GetSystemTimeAsFileTime( &now.f );

        diff_100_nsec = now.u.QuadPart - ix_epoch;

        ts->tv_sec = (time_t) ( diff_100_nsec / div_100_nsec );
        ts->tv_nsec = (long) ( ( diff_100_nsec % div_100_nsec ) * 100l );
        return 0;
}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]