Announcement

Collapse
No announcement yet.

Unsigned Quads

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unsigned Quads

    Are unsigned Quads on the wish list? I see that 8-byte signed & unsigned
    integer types are appearing in various Windows header files (maybe they've
    been there a while) though usually via a structure of two 4-byte types.

    On a related note, are the new 64-bit processors and operating systems
    introducing any new fundamental data types or are the 8-byte integers
    about it?

    Thanks!


    ------------------
    Mark Newman
    Mark Newman

  • #2
    Anything like this?

    Code:
    Union QuadFILETIME
      dwLowDateTime  As Dword
      dwHighDateTime As Dword
      qdTime         As Quad
    End Union
    
    '
    '
    '
    'Function CheckAtomicTime(lserv As String,wPort As Long,aTimeOut As Long,Delay As Double, st As SYSTEMTIME) Export As String
    Local buffer    As String
    Local lpbuf     As String
    Local UTCTime   As String
    Local vbdate    As Double
    
    Dim Start       As Dword
    Dim Stopp       As Dword
    Dim QT          As QuadFILETIME
    Dim Pc          As Long
    
    Pc& = SetPriorityClass(GetCurrentProcess(), %HIGH_PRIORITY_CLASS)
    
    lserv = Extract$(Ltrim$(lserv), Any " (")
    
    '51468 99-10-17 05:12:27 15 0 0 888.6 UTC(NIST) *
    'Record your starttime In milliseconds
    Start = TimeGetTime()
    Tcp Open Port wPort At lserv As #hTcp TIMEOUT aTimeOut
    Do
      Tcp Recv #hTcp, 1600, buffer
      lpbuf = lpbuf + buffer
    Loop While Len(buffer)
    Tcp Close #hTcp
    lpbuf = Trim$(lpbuf, $LF)
    Replace $LF With $CRLF In lpbuf
    UTCTime = Trim$(lpbuf, $LF)
    Function = UTCTime
    Delay = TimeGetTime - Delay
    'vbDate = StrToVbDate(Parse$(UTCTime, Any " ",2) + " " + Parse$(UTCTime, Any " ",3))
    'VariantTimeToSystemTime vbDate, st
    Stopp = TimeGetTime()
    
    'Convert your Atomic time into a SYSTEMTIME structure ST
    'FILETIME returns 100's of NANOSECONDS so you have to adjust
    'Delay To reflect this resulotion
    Delay = (Stopp - Start)* 10000
    
    'NIST TIME SERVER (Nuclear)
    '51468 99-10-17 05:12:27 15 0 0 888.6 UTC(NIST) *
    If Right$(UTCTime,2) = "* " Then
       Local UTCDate As String
       Local UTCTimeOnly As String
       UTCDate = Parse$(UTCTime, Any " ",2)
       UTCTimeOnly = Parse$(UTCTime, Any " ",3)
        ' Convert date and time to a SYSTEMTIME structure using a date VARIANT
        vbDate = StrToVbDate(UTCDate + " " + UTCTimeOnly)
        VariantTimeToSystemTime vbDate, st
    ElseIf Len(UTCTime) = 5 Then
         RFC868toSystemTime CvDwd(UTCTime), st
    'ElseIf
       'Internet Time Server
       '"Wed, 13 Oct 1999 15:07:52 -0700"
    ElseIf Len(UTCTime) < 2 Then
        Function = Date$ + " DEBUG:"
        Exit Function
    End If
    
    'convert your Atomic time In ST To FileTime In QT
    SystemTimeToFileTime ST,QT
    'Now Add the delay To the Quad-element that overlay the FILETIME-struct
    QT.qdTime = (QT.qdTime + Delay) - 50000 'subtract 50ms NIST network delay
    'Convert back To SYSTEMTIME
    FileTimeToSystemTime QT,ST
    Delay = Delay \ 10000
    End Function
    '-----------------------------------------------------------------------------------
    ------------------
    Scott
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

    Comment


    • #3
      What I saw was the variable type LARGE_INTEGER while porting parts of WINIOCTL.H to PB format.
      I searched the Win header files and found something similar to this:
      Code:
      struct
      {
         DWORD LowPart
         LONG  HiPart
      }LARGE_INTEGER
      which seems the same as a PB Quad, a signed 8-byte integer. There's also an unsigned version:
      Code:
      struct
      {
         DWORD LowPart
         DWORD HiPart
      }ULARGE_INTEGER
      Actually, I found different implementations of this in several different header files,
      depending on some #ifdefs and such.

      Anyway, I was just suggesting that unsigned Quads be added to the wish list, along
      with any new native 64-bit data types. It's not a big deal to use a TYPE or UNION for
      this, just that a native PB type would be easier!


      ------------------
      Mark Newman
      Mark Newman

      Comment


      • #4
        64-bit unsigned variables are on the wish list already. I'll ask for a tick in your name to be added. Thanks!

        ------------------
        Lance
        PowerBASIC Support
        mailto:[email protected][email protected]</A>
        Lance
        mailto:[email protected]

        Comment

        Working...
        X