From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8c564a80b820db35 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.74.201 with SMTP id w9mr22156445pbv.0.1331056747142; Tue, 06 Mar 2012 09:59:07 -0800 (PST) Path: h9ni46674pbe.0!nntp.google.com!news1.google.com!feed-C.news.volia.net!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.swapon.de!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Any leap year issues caused by Ada yesterday? Date: Tue, 06 Mar 2012 17:59:04 +0000 Organization: A noiseless patient Spider Message-ID: References: <4f4f746a$0$6565$9b4e6d93@newsspool3.arcor-online.net> <20608866.730.1330963171058.JavaMail.geo-discussion-forums@ynbq18> <1t8v4akrmapkl.1xwfi9yxtw2ji$.dlg@40tude.net> <18ghv3yeh1a1k$.1bjwdaps59rt3$.dlg@40tude.net> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="dFCm8HWntFqmDIilBLqEJQ"; logging-data="31581"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/uFsJZw3+1lJ4mOlCjQswcwmkRlpbhOFE=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (darwin) Cancel-Lock: sha1:RJXzxdN0hOw5s+cUrgSwfNBl+yk= sha1:WeKlhBZYDZ90T5e7UFhFdk6WI+c= Content-Type: text/plain; charset=us-ascii Date: 2012-03-06T17:59:04+00:00 List-Id: "Dmitry A. Kazakov" writes: > On Tue, 06 Mar 2012 16:46:35 +0000, Simon Wright wrote: > >> "Dmitry A. Kazakov" writes: >> >>> Under VxWorks you can read the TSC without assembly, there is a library >>> function for that (pentiumTscGet64). >>> >>> type Timestamp is new Unsigned_64; >>> procedure pentiumTscGet64 (Clock : out Timestamp); >>> pragma Import (C, pentiumTscGet64, "pentiumTscGet64"); >>> >>> should do the work. >> >> Not sure if there was an equivalent for PPC. > > AFAIK, PPC has a high resolution real time counter, which is better > designed than Intel's TSC. Yes, the Time Base. Ours was a 32-bit implementation, so you get to read the lower and upper halves of the timebase separately, which would cause problems at rollover. So read the TB using an internal Clock like this function Clock return Time is type Half is (High, Low); type High_Low is array (Half) of Interfaces.Unsigned_32; Upper, Lower, Upper_Again : Interfaces.Unsigned_32; function To_Time is new Ada.Unchecked_Conversion (High_Low, Time); use type Interfaces.Unsigned_32; begin loop System.Machine_Code.Asm ("mftbu %0" & ASCII.LF & ASCII.HT & "mftb %1" & ASCII.LF & ASCII.HT & "mftbu %2", Outputs => (Interfaces.Unsigned_32'Asm_Output ("=r", Upper), Interfaces.Unsigned_32'Asm_Output ("=r", Lower), Interfaces.Unsigned_32'Asm_Output ("=r", Upper_Again)), Volatile => True); exit when Upper_Again = Upper; end loop; return To_Time ((High => Upper, Low => Lower)); end Clock; The timebase ran off the same crystal as the decrementer, so all were internally sync'd. Internally, our synchronised time was (Ada.Calendar.Clock (at last clock interrupt, of course) + high-res time since last clock interrupt). We added the external sync offset on sending a time off-board, and subtracted it on receiving one. (I've never used VxWorks on x86).