comp.lang.ada
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* Re: Windows file timestamp converted to local time
  2023-10-17 16:28  6%       ` Niklas Holsti
@ 2023-10-17 16:35  0%         ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2023-10-17 16:35 UTC (permalink / raw)


Niklas Holsti <niklas.holsti@tidorum.invalid> writes:

> Ada.Directories.Modification_Time returns a value of type
> Ada.Calendar.Time. However, "the time base associated with the type
> Time of package Calendar is implementation defined" (RM 9.6(23)) so it
> should be documented in the implementation documents, that is in the
> GNAT documentation. Have you looked there?

The GNAT RM says in Implementation Defined Characteristics[1]

"The time base used is that provided by the C library function gettimeofday."

[1] https://docs.adacore.com/live/wave/gnat_rm/html/gnat_rm/gnat_rm/implementation_defined_characteristics.html

^ permalink raw reply	[relevance 0%]

* Re: Windows file timestamp converted to local time
  2023-10-17 14:13  0%     ` Matt Borchers
@ 2023-10-17 16:28  6%       ` Niklas Holsti
  2023-10-17 16:35  0%         ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: Niklas Holsti @ 2023-10-17 16:28 UTC (permalink / raw)


On 2023-10-17 17:13, Matt Borchers wrote:
> On Monday, October 16, 2023 at 2:49:52 PM UTC-4, Niklas Holsti wrote:
>> On 2023-10-16 21:35, Matt Borchers wrote:
>>> Below is the function from System.OS_Lib.
>>> Does anybody know where the C implementation can be found?
>>> Does anybody know where the C implementation of "localtime" is found?
>>>
>>> function File_Time_Stamp (Name : C_File_Name) return OS_Time is
>>> function File_Time (Name : Address) return OS_Time;
>>> pragma Import (C, File_Time, "__gnat_file_time_name");
>>> begin
>>> return File_Time (Name);
>>> end File_Time_Stamp;
>> (This question seems to be a follow-up ("Re:") to some earlier post, but
>> my newsreader does not seem to find or show that earlier post.)
>>
>> What is the problem?
>>
>> Have you tried using the standard Ada services:
>> Ada.Directories.Modification_Time and
>> Ada.Calendar.Time_Zones.Local_Time_Offset?
> 
> Thank you for the suggestion of using "Ada.Directories.Modification_Time".


Happy to help!


> I didn't think to look in that package.


Ada.Directories does, IMO, seem the best place for it, since it should 
not depend on the type of the file -- text, sequential, etc.


> This function adjusts for daylight savings time and returns the time
> as displayed in Windows Explorer.
> 
> There needs to be better comments (and documentation) for these time
> related functions. It is often not clear what time is returned.


Yes, but some of that documentation should not be in the Ada standard, 
but in the compiler's documentation.

Ada.Directories.Modification_Time returns a value of type 
Ada.Calendar.Time. However, "the time base associated with the type Time 
of package Calendar is implementation defined" (RM 9.6(23)) so it should 
be documented in the implementation documents, that is in the GNAT 
documentation. Have you looked there?

^ permalink raw reply	[relevance 6%]

* Re: Windows file timestamp converted to local time
  2023-10-16 18:49  5%   ` Niklas Holsti
  2023-10-17  2:39  0%     ` Randy Brukardt
@ 2023-10-17 14:13  0%     ` Matt Borchers
  2023-10-17 16:28  6%       ` Niklas Holsti
  1 sibling, 1 reply; 200+ results
From: Matt Borchers @ 2023-10-17 14:13 UTC (permalink / raw)


On Monday, October 16, 2023 at 2:49:52 PM UTC-4, Niklas Holsti wrote:
> On 2023-10-16 21:35, Matt Borchers wrote: 
> > Below is the function from System.OS_Lib. 
> > Does anybody know where the C implementation can be found? 
> > Does anybody know where the C implementation of "localtime" is found? 
> > 
> > function File_Time_Stamp (Name : C_File_Name) return OS_Time is 
> > function File_Time (Name : Address) return OS_Time; 
> > pragma Import (C, File_Time, "__gnat_file_time_name"); 
> > begin 
> > return File_Time (Name); 
> > end File_Time_Stamp;
> (This question seems to be a follow-up ("Re:") to some earlier post, but 
> my newsreader does not seem to find or show that earlier post.) 
> 
> What is the problem? 
> 
> Have you tried using the standard Ada services: 
> Ada.Directories.Modification_Time and 
> Ada.Calendar.Time_Zones.Local_Time_Offset?

Thank you for the suggestion of using "Ada.Directories.Modification_Time". I didn't think to look in that package. This function adjusts for daylight savings time and returns the time as displayed in Windows Explorer.

There needs to be better comments (and documentation) for these time related functions. It is often not clear what time is returned. It is safe to assume UTC or local time, but the daylight savings issue caused confusion.

^ permalink raw reply	[relevance 0%]

* Re: Windows file timestamp converted to local time
  2023-10-16 18:49  5%   ` Niklas Holsti
@ 2023-10-17  2:39  0%     ` Randy Brukardt
  2023-10-17 14:13  0%     ` Matt Borchers
  1 sibling, 0 replies; 200+ results
From: Randy Brukardt @ 2023-10-17  2:39 UTC (permalink / raw)


"Niklas Holsti" <niklas.holsti@tidorum.invalid> wrote in message 
news:kp5eucFogqpU1@mid.individual.net...
> On 2023-10-16 21:35, Matt Borchers wrote:
>> Below is the function from System.OS_Lib.
>> Does anybody know where the C implementation can be found?
>> Does anybody know where the C implementation of "localtime" is found?
>>
>>     function File_Time_Stamp (Name : C_File_Name) return OS_Time is
>>        function File_Time (Name : Address) return OS_Time;
>>        pragma Import (C, File_Time, "__gnat_file_time_name");
>>     begin
>>        return File_Time (Name);
>>     end File_Time_Stamp;
>
>
> (This question seems to be a follow-up ("Re:") to some earlier post, but 
> my newsreader does not seem to find or show that earlier post.)
>
> What is the problem?
>
> Have you tried using the standard Ada services: 
> Ada.Directories.Modification_Time and 
> Ada.Calendar.Time_Zones.Local_Time_Offset?

...as those will work on (almost) any target system, while the actual 
implementation is going to be rather OS-dependent. And there never is a good 
reason to use a GNAT-only (or any compiler-specific, for any compiler) 
facility when there is an equivalent standard facility. Most of those 
facilities pre-date the Ada ones.

                Randy.


^ permalink raw reply	[relevance 0%]

* Re: Windows file timestamp converted to local time
  @ 2023-10-16 18:49  5%   ` Niklas Holsti
  2023-10-17  2:39  0%     ` Randy Brukardt
  2023-10-17 14:13  0%     ` Matt Borchers
  0 siblings, 2 replies; 200+ results
From: Niklas Holsti @ 2023-10-16 18:49 UTC (permalink / raw)


On 2023-10-16 21:35, Matt Borchers wrote:
> Below is the function from System.OS_Lib.
> Does anybody know where the C implementation can be found?
> Does anybody know where the C implementation of "localtime" is found?
> 
>     function File_Time_Stamp (Name : C_File_Name) return OS_Time is
>        function File_Time (Name : Address) return OS_Time;
>        pragma Import (C, File_Time, "__gnat_file_time_name");
>     begin
>        return File_Time (Name);
>     end File_Time_Stamp;


(This question seems to be a follow-up ("Re:") to some earlier post, but 
my newsreader does not seem to find or show that earlier post.)

What is the problem?

Have you tried using the standard Ada services: 
Ada.Directories.Modification_Time and 
Ada.Calendar.Time_Zones.Local_Time_Offset?

^ permalink raw reply	[relevance 5%]

* Re: Parameterised 'Image Attributes
  2023-08-19 15:27  3%     ` Jeffrey R.Carter
@ 2023-08-20  7:53  0%       ` G.B.
  0 siblings, 0 replies; 200+ results
From: G.B. @ 2023-08-20  7:53 UTC (permalink / raw)


On 19.08.23 17:27, Jeffrey R.Carter wrote:
> On 2023-08-19 11:14, J-P. Rosen wrote:
>> On 18/08/2023 08:18, Rod Kay wrote:
>>>
>>>     Would it be possible/desirable to allow the 'Image attribute to have formatting parameters ? Something along the lines of ...
>>
>> The intent of the 'Image attribute is to have a quick representation, mainly for debugging purposes. If you want nice formatted output, use the Put procedure on String from Text_IO
> (...)
> The obvious solution is to have a library containing appropriate functions, which can be built around the Put procedures while still being functions. Such functions would need to be generic, unlike attribute functions which are automatically available for all types.
> 
> The conflict between this common need and the minimal functionality provided by 'Image results in such requests. It seems desirable for the language to provide such functions, and extending the 'Image functions seems like a reasonable way for it to do so, regardless of the original intentions for the attribute.

So, also

- See how other languages address formats (good bits,
   bad bits).
- Consider use cases.
- I/O is the program(mer)'s raison d'être. Can we easily Put
   something into a stream without the help of a suitable
   library?

Could there be a language defined type F whose purpose is to support
the description of formats? Objects of type F would "configure"
what 'Image does when computing a representation of a date, a number, ...

   My_Length'Image (Arg => diameter, Format => ___);

Some use cases:
- I18n of number formats (cf ARM F.3), CHF 1'234'000.–
- Handle ubiquitous ISO formats of date-time (as mentioned below;
   also cf. ARM 9.6.1)
- reporting,
- integrate own output with output of other system components
   (a site-wide monitoring system searches outputs, say)
- fill in templates when these do not support formatting
- 'Input an object of type F at run-time, so that program's
   use of 'Image can be changed according to customer's
   local expectations.
- support the formalized exchange of "numerical" data in
   heterogeneous systems, using text streams.

These use cases are about the O of I/O. By symmetry, it would be
nice to have implementations of Ada that support the I part of this
kind of I/O, I think, with work to be split between implementers
and programmers.

   My_Length'Value (Arg => diameter, Format => ___);

Or perhaps multimethods that take a stream and a format
when they need to write a value?


> One library with such functions is the PragmAda Reusable Components (https://github.com/jrcarter/PragmARC). The package PragmARC.Images (https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-images.ads) provides such functions for integer and floating-point types. Function PragmARC.Images.Image is an instantiation for Standard.Integer.
> 
> PragmARC.Date_Handler (https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-date_handler.ads) provides image functions for dates and times; although the language now provides a function for a date-time image, Date_Handler continues to be useful as it provides for customized formats rather than the single format provided by Ada.Calendar.Formatting. Many users also find the semantics of the latter's time-zone parameter to be confusing.
> 
> (ISO/IEC 8652:2023 provides a date-time image function the returns the image for the local time zone, but as there are no compilers* for this version of the language, I don't consider that relevant.


^ permalink raw reply	[relevance 0%]

* Re: Parameterised 'Image Attributes
  @ 2023-08-19 15:27  3%     ` Jeffrey R.Carter
  2023-08-20  7:53  0%       ` G.B.
  0 siblings, 1 reply; 200+ results
From: Jeffrey R.Carter @ 2023-08-19 15:27 UTC (permalink / raw)


On 2023-08-19 11:14, J-P. Rosen wrote:
> On 18/08/2023 08:18, Rod Kay wrote:
>>
>>     Would it be possible/desirable to allow the 'Image attribute to have 
>> formatting parameters ? Something along the lines of ...
>
> The intent of the 'Image attribute is to have a quick representation, mainly for 
> debugging purposes. If you want nice formatted output, use the Put procedure on 
> String from Text_IO.

There is a common problem across many types and problem domains of having a 
function that returns a string of an appropriate length representing a value of 
the type with desired formatting. Common examples include numeric values, dates, 
and times. The resulting string is usually combined with other information into 
a message that may be stored in memory for a while, though it is rare for it not 
to be output eventually. As an example, the message may be put on a protected 
queue for later output by a logging task.

Ada 83 tended not to include anything that the developer could implement; there 
was no math library or image functions for dates or times. The 'Image attribute 
was provided, but is unsuited for most such uses.

The use of the Text_IO generic sub-pkg Put procedures that output to strings is 
not convenient because they are procedures, not functions.

Later versions of Ada included more support for such needs, but not for numeric 
values.

The obvious solution is to have a library containing appropriate functions, 
which can be built around the Put procedures while still being functions. Such 
functions would need to be generic, unlike attribute functions which are 
automatically available for all types.

The conflict between this common need and the minimal functionality provided by 
'Image results in such requests. It seems desirable for the language to provide 
such functions, and extending the 'Image functions seems like a reasonable way 
for it to do so, regardless of the original intentions for the attribute.

One library with such functions is the PragmAda Reusable Components 
(https://github.com/jrcarter/PragmARC). The package PragmARC.Images 
(https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-images.ads) provides 
such functions for integer and floating-point types. Function 
PragmARC.Images.Image is an instantiation for Standard.Integer.

PragmARC.Date_Handler 
(https://github.com/jrcarter/PragmARC/blob/Ada-12/pragmarc-date_handler.ads) 
provides image functions for dates and times; although the language now provides 
a function for a date-time image, Date_Handler continues to be useful as it 
provides for customized formats rather than the single format provided by 
Ada.Calendar.Formatting. Many users also find the semantics of the latter's 
time-zone parameter to be confusing.

(ISO/IEC 8652:2023 provides a date-time image function the returns the image for 
the local time zone, but as there are no compilers* for this version of the 
language, I don't consider that relevant.

(*A compiler for a version of the language implements the entire core language 
of that version of the ARM.)

-- 
Jeff Carter
"The men get one hot meal a day: a bowl of steam."
Take the Money and Run
145

^ permalink raw reply	[relevance 3%]

* Re: Ada interface to Excel file
  @ 2023-04-20 19:08  4% ` Gautier write-only address
  0 siblings, 0 replies; 200+ results
From: Gautier write-only address @ 2023-04-20 19:08 UTC (permalink / raw)


The simplest way by far is to generate the Ada sources
from within Excel by using VBA (a BASIC with a strong Ada flavour,
but still a BASIC) which is part of Excel.
From Excel, you activate VBA with the Alt-F11 shortcut.

You have "modules" which are just editor files and visible from
everywhere else (you have like implicit "with"'s and "use"'s); you
have functions called "Function" and procedures called "Sub".
You can associate a button in the Excel sheet to a Sub.
You declare each variable with "Dim x As Type".
You can also forget to declare variables, with funny outcomes.
The behavious of the type system around parameter passing is also funny.

You find below a few examples.
Now, if you already have your CSV-to-Ada generator, you can export a CSV; that's also easy with VBA.

G.

[somewhere (some module)]
Sub Generate_for_Production()
  Dim anchor As String  '  VBA String is Ada's Unbounded_String
  '  File handles
  Dim fh_ada_spec As Integer
  Dim fh_ada_body As Integer
  ...
  Open ThisWorkbook.Path & "\src\" & pkg_name & _
       ".ads" For Output As #fh_ada_spec
  ...
  For Each ws In Worksheets          '  Scan all worksheets
    For Each r In ws.UsedRange.Rows  '  Scan all used rows
      anchor = r.Cells(1, 1).Value
      If anchor <> "" Then
        ...
      End If
    Next r
  Next ws
  ...
  Close #fh_ada_spec
End Sub

[somewhere else (perhaps another module)]

  Print #fh, "with Ada.Calendar;"
  Print #fh, "with Ada.Unchecked_Conversion;"
  Print #fh, "with Interfaces;"
  Print #fh,
  Print #fh, "package " & name & " is"

[somewhere else]

  If simple_record Then
    Print #fh_ada_spec, "   --  Simple record."
    Print #fh_ada_spec,
    Print #fh_ada_spec, "   type Xyz is record  --  " & paragraph
  Else
    Print #fh_ada_spec, "   type Xyz is new " & parent_name & _
                        "Abc with record  --  " & paragraph
  End If

[somewhere else]

  For i = min_row_offset To max_row_offset
    '  Convert name in cell to Ada name
    field = Ada_Name(r.Cells(i, 3).Value)
    If field = "" Then
      Exit For
    End If
    amount = r.Cells(i, 6).Value
  ...
  Print #fh_ada_body, "      for index in 1 .. " & amount & " loop"
  Print #fh_ada_body, "         declare"

^ permalink raw reply	[relevance 4%]

* Re: Build order with gprbuild
  @ 2023-03-01 20:08  4%   ` Gautier write-only address
  0 siblings, 0 replies; 200+ results
From: Gautier write-only address @ 2023-03-01 20:08 UTC (permalink / raw)


Between normal Ada projects, everything works as you describe (and as expected).
However, in the special case where project B, instead of transforming Ada files into .o files, transforms other kind of files into Ada files that are with-ed by units of project A, things get off the road: project A doesn't see out-of-date Ada files produced by project B.

Here is a full example. Files are reproduced below (they are meant to land into the same directory).
Then you do the following commands:

gprbuild -P fuzzy_gen.gpr
gprbuild -P code_generation.gpr
gnatstudio -P main.gpr

First build launched from GNAT Studio does the following on my machine:

    Compile
    [Ada]          main.adb
    [Fuzzy]        x789.cfg
    Ada file "fuzzy_x789.adb" is up to date
    [Fuzzy]        x456.cfg
    Ada file "fuzzy_x456.adb" is up to date
    [Fuzzy]        x123.cfg
    Ada file "fuzzy_x123.adb" is up to date
    [Ada]          fuzzy_x123.adb
    [Ada]          fuzzy_x456.adb
    [Ada]          fuzzy_x789.adb
    Bind
    [gprbind]      main.bexch
    [Ada]          main.ali
    Link
    [link]         main.adb

Second build has an expected output as well:

    Compile
       [Fuzzy]        x789.cfg
    Ada file "fuzzy_x789.adb" is up to date
       [Fuzzy]        x456.cfg
    Ada file "fuzzy_x456.adb" is up to date
       [Fuzzy]        x123.cfg
    Ada file "fuzzy_x123.adb" is up to date
    gprbuild: "main.exe" up to date

Now, say you modify x123.cfg and save it.
    Compile
       [Fuzzy]        x789.cfg
    Ada file "fuzzy_x789.adb" is up to date
       [Fuzzy]        x456.cfg
    Ada file "fuzzy_x456.adb" is up to date
       [Fuzzy]        x123.cfg
    Converting "x123.cfg" into "fuzzy_x123.adb"...
    gprbuild: "main.exe" up to date

That's *not* what I would like: gprbuild did not detect the out-of-date file "fuzzy_x123.adb" in time.
A second call to gprbuild compiles the changed "fuzzy_x123.adb" and all is well, but it is one step too late.

The files
=========

1) The code generator
=====================

fuzzy_gen.gpr:
-------------

project Fuzzy_Gen is
  for Object_Dir use "obj";
  for Exec_Dir use "gen";
  for Create_Missing_Dirs use "True";
  for Main use ("fuzzy_gen.adb");
end Fuzzy_Gen;

fuzzy_gen.adb:
-------------

with Ada.Calendar,
     Ada.Command_Line,
     Ada.Directories,
     Ada.Text_IO;

procedure Fuzzy_Gen is
  use Ada.Command_Line, Ada.Directories, Ada.Text_IO;

  procedure Convert (arg : String) is
    cfg : constant String := Simple_Name (arg);
    cfg_file_name : constant String := "../" & cfg;
    ada_unit_name : constant String :=
      "fuzzy_" & cfg (cfg'First .. cfg'Last - 4);
    ada_file_name : constant String := ada_unit_name & ".adb";
    cfg_in, ada_out : File_Type;
    use type Ada.Calendar.Time;
  begin
    if Exists (ada_file_name) and then
       Modification_Time (ada_file_name) >=
       Modification_Time (cfg_file_name)
    then
      Put_Line ("Ada file """ & ada_file_name & """ is up to date");
      return;
    end if;
    Put_Line
      ("Converting """ & cfg & """ into """ & ada_file_name & """...");
    Open (cfg_in, In_File, cfg_file_name);
    Create (ada_out, Out_File, ada_file_name);
    Put_Line
      (ada_out, "function " & ada_unit_name & " return String is");
    Put_Line (ada_out, "begin");
    Put_Line (ada_out, "  return """ & Get_Line (cfg_in) & """;");
    Put_Line (ada_out, "end;");
    Close (cfg_in);
    Close (ada_out);
  end Convert;


begin
  if Argument_Count = 0 then
    Put_Line (Current_Error, "config file name missing");
  else
    Convert (Argument (1));
  end if;
end Fuzzy_Gen;

2) The project that generates Ada files ("project B")
=====================================================

code_generation.gpr:
-------------------
project Code_Generation is

   for Languages use ("Fuzzy");
   for Source_Dirs use (".");
   for Object_Dir use "gen";
   for Objects_Linked  ("Fuzzy") use "False";

   package Naming is
      for Body_Suffix ("Fuzzy") use ".cfg";
   end Naming;

   package Compiler is
      for Driver ("Fuzzy") use "fuzzy_gen";
   end Compiler;

end Code_Generation;

x123.cfg:
--------
123

x456.cfg:
--------
456

x789.cfg:
--------
789

3) The main project (project A)
===============================

main.gpr:
--------
with "code_generation.gpr";

project Main is
  for Source_Dirs use (".", "gen");
  for Object_Dir use "obj";
  for Create_Missing_Dirs use "True";
  for Main use ("main.adb");
end Main;

main.adb:
--------
with Ada.Text_IO;
with Fuzzy_X123,
     Fuzzy_X456,
     Fuzzy_X789;

procedure Main is
begin
  Ada.Text_IO.Put
    ("Messages from elsewhere:" &
     " """ & Fuzzy_X123 & '"' &
     " """ & Fuzzy_X456 & '"' &
     " """ & Fuzzy_X789 & '"');
end;

^ permalink raw reply	[relevance 4%]

* Re: Trivial question: how to avoid confusing sec, min, hour and day in a program?
  @ 2021-10-24 10:48  4%     ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2021-10-24 10:48 UTC (permalink / raw)


reinert <reinkor@gmail.com> writes:

> Ada seems to guarantee that Duration covers 24 hours (?). What you do
> when you need to represent for example 5 years?

This must depend on your use case.

I'd imagine you want to arrange for some event to happen 5 years in the
future. The 'natural' way to do this might be, in a task,

   delay until Ada.Calendar.Clock + Duration'({5 years});

but this comes up against two problems: first, as you note, that long a
duration might not work, and second, the computer is almost certain to
have been restarted by then, losing this task.

The second problem could be solved by, e.g., keeping a backed-up
time-ordered queue of events to be processed, with a task that delays
until the next event is due.

As for the first -- I think you may need to make an appropriate
Duration'Last part of your compiler selection criteria.

^ permalink raw reply	[relevance 4%]

* Re: Problem with emacs ada-mode-7.1.4
  @ 2021-07-18  9:26  4%       ` Paul Onions
  0 siblings, 0 replies; 200+ results
From: Paul Onions @ 2021-07-18  9:26 UTC (permalink / raw)


Hi Dmitry,

On Sunday, 18 July 2021 at 10:00:43 UTC+1, Dmitry A. Kazakov wrote:
> https://www.adaic.org/resources/add_content/standards/05rm/html/RM-9-6-1.html#I3765 

That's interesting, so it's in Ada.Calendar.Time_Zones from Ada2005, but that is not one of the packages USEd by gnatcoll-sql_impl.adb.  So I'm guessing it was added to one of the GNAT packages later.

Anyway, I cloned the gnatcoll-db git repository and found a "20-sustained" branch in there.  Switching to it then allowed me to build gnatcoll_sqlite with GNAT CE 2020.  Yay.

However, trying to build gnatcoll_xref failed because it's looking for something called gnatcoll_iconv, which I don't see anywhere in the repository.  Need to go looking for that now (or rather later, when I've more time)...

Paul

^ permalink raw reply	[relevance 4%]

* Ann: HAC v.0.076
@ 2020-10-24  7:38  5% gautier...@hotmail.com
  0 siblings, 0 replies; 200+ results
From: gautier...@hotmail.com @ 2020-10-24  7:38 UTC (permalink / raw)


HAC (HAC Ada Compiler) is a small, quick, open-source Ada compiler, covering a subset of the Ada language.

You find below the changes since the last post about HAC in this forum.
Links to the project and contact (tracing ;-) ) addresses are available from the blog posts cited below.

0.071
  Discrete type range is stored in type definition;  "subtype T1 is T2;"
  
0.072
  Subtype_Indication (e.g. "for B in Boolean loop", "array (States) of Prob")
  https://gautiersblog.blogspot.com/2020/06/hac-v0072-subtype-indication.html
  
0.073
  The VM can be aborted via the Feedback procedure

0.074
  Types: Time and Duration

0.075
  Added Ada.Calendar-like functions
  https://gautiersblog.blogspot.com/2020/10/hac-v0075-time-functions-goodies-for.html

0.076
  Added Ada.Directories-like subprograms
  https://gautiersblog.blogspot.com/2020/10/hac-v0076-adadirectories-like.html

Enjoy!

^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-07  0:19  5%           ` Randy Brukardt
@ 2020-03-07  1:18  6%             ` Optikos
  0 siblings, 0 replies; 200+ results
From: Optikos @ 2020-03-07  1:18 UTC (permalink / raw)


On Friday, March 6, 2020 at 6:19:20 PM UTC-6, Randy Brukardt wrote:
> "Optikos" wrote in message 
> news:6c9347ec-8c2b-4a77-bdd8-a52b6f2d7858@googlegroups.com...
> ...
> >My point is that if Ada 2020's ISO/IEC is officially emitted the way that 
> >so-called
> >Ada 2005's official amendment ISO/IEC8652:1995/Amd1:2007 to official 
> >standard
> >ISO/IEC8652:1995 still in effect, then these binding AIs need to be 
> >pursuant to not
> >only an ISO/IEC8652:2012/Amd1:2020 (or :2021) but also an
> >ISO/IEC8652:2012/Corr1:2020 (or 2021) to be retroactive back to 2012. 
> >Hence,
> >it would be advantageous in this regard for the Ada 2005 model of mere 
> >official
> >amendment to a still-in-effect prior standard to be avoided and the Ada 
> >2012 model
> >to be enacted for Ada 2020.
> 
> My understanding is that ISO has a limit of two modifying documents to any 
> particular Standard before a revision is required. We already have a 
> Corrigendum to the Ada 2012 standard, and adding a separate Corrigendum and 
> Amendment would add two more, which would exceed the limit.
> 
> So I don't believe this idea would be allowed. We might be able to get a 
> waiver (once), but you're suggesting using it as a long-term strategy, and 
> that wouldn't be allowed.
> 
>                                                    Randy.

No, I am not making any such suggestion at all.  Instead, I am suggesting that releasing Ada 2020 as a full-fledged standard instead of merely an amendment (as Ada 2005 was) fixes so many problems and mitigates so many complications, as described above, due to the new edition of the standard wiping the slate clean again without needing to retroactively maintain the Ada 2012 standard anymore.

^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-06 14:42  3%         ` Optikos
@ 2020-03-07  0:19  5%           ` Randy Brukardt
  2020-03-07  1:18  6%             ` Optikos
  0 siblings, 1 reply; 200+ results
From: Randy Brukardt @ 2020-03-07  0:19 UTC (permalink / raw)



"Optikos" <ZUERCHER_Andreas@outlook.com> wrote in message 
news:6c9347ec-8c2b-4a77-bdd8-a52b6f2d7858@googlegroups.com...
...
>My point is that if Ada 2020's ISO/IEC is officially emitted the way that 
>so-called
>Ada 2005's official amendment ISO/IEC8652:1995/Amd1:2007 to official 
>standard
>ISO/IEC8652:1995 still in effect, then these binding AIs need to be 
>pursuant to not
>only an ISO/IEC8652:2012/Amd1:2020 (or :2021) but also an
>ISO/IEC8652:2012/Corr1:2020 (or 2021) to be retroactive back to 2012. 
>Hence,
>it would be advantageous in this regard for the Ada 2005 model of mere 
>official
>amendment to a still-in-effect prior standard to be avoided and the Ada 
>2012 model
>to be enacted for Ada 2020.

My understanding is that ISO has a limit of two modifying documents to any 
particular Standard before a revision is required. We already have a 
Corrigendum to the Ada 2012 standard, and adding a separate Corrigendum and 
Amendment would add two more, which would exceed the limit.

So I don't believe this idea would be allowed. We might be able to get a 
waiver (once), but you're suggesting using it as a long-term strategy, and 
that wouldn't be allowed.

                                                   Randy.


^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-05 23:29  5%       ` Randy Brukardt
@ 2020-03-06 14:42  3%         ` Optikos
  2020-03-07  0:19  5%           ` Randy Brukardt
  0 siblings, 1 reply; 200+ results
From: Optikos @ 2020-03-06 14:42 UTC (permalink / raw)


On Thursday, March 5, 2020 at 5:29:35 PM UTC-6, Randy Brukardt wrote:
> Optikos wrote in message 
> news:f94395b7-f2de-4c49-8edd-b24bfa64cc37@googlegroups.com...
> >On Tuesday, March 3, 2020 at 5:49:35 PM UTC-6, Randy Brukardt wrote:
> >> "Simon Wright" wrote in message
> >> news:lyv9nl8p6w.fsf@pushface.org...
> >> ...
> >> > There was a conversation on Ada-Comment in June last year, in which it
> >> > turned out that compiler implementers may have have been 
> >> > misinterpreting
> >> > the ARM. It was quite confusing.
> >>
> >> Not just a conversation, but also a Binding Interpretation AI (which
> >> therefore applies to Ada 2012 compilers), AI12-0336-1.
> >
> >Shouldn't these Binding AIs that take effect from a past edition of the ISO
> >standard onward (and not merely incorporated into Ada 2020 or Ada
> >202X post-2020) ..be an ISO/IEC corrigendum..?  Allowing errata be
> >permanently published semi-officially in any forum other than
> >cummulatively in an official ISO/IEC corrigendum seems to be against the
> >ISO/IEC rules.
> 
> Not necessarily. ISO has very strict limits on the number of Corrigenda that 
> can be issued for a particular standard; after that the only choice is to 
> update the Standard.
> 
> Remember that from ISO's perspective older standards don't actually exist;

Well, there are a few finer points, for the interested reader.  Remember that so-called Ada 2005 (officially ISO/IEC8652:1995/Amd1:2007) was merely an amendment is ISO/IEC-speak.  If so-called Ada2020 is fashioned likewise as an amendment ISO/IEC8652:2012/Amd1:2020 (or :2021, instead of a new edition as Ada 2012 was as officially ISO/IEC8652:2012), then all the Binding AIs that are retroactive back to Ada 2012 would need an official ISO/IEC corrigendum no later than the official release date of Ada 2020's ISO/IEC standard document.  But if Ada 2020 is released instead as a new edition (say, ISO/IEC8652:2020 or ISO/IEC8652:2021), then this new edition would eclipse the older ISO/IEC8652:2012 as you describe and no harm no foul to a not-corrigendumed ISO/IEC8652:2012 that got left in history because by the corrigendum's due-date it became a moot point due to :2012 no longer being the standard in effect.
 
> only the latest version is relevant to ISO. So the difference between 
> non-Corrigendum Binding Interpretations and Amendments is non-existent to 
> ISO.

Because ISO/IEC amendments, corrigendum, technical reports, and standards are well-regulated published documents, that sentence needs to be reworded to be correct:  So the difference between
1) non-Corrigendum Binding-Interpretation AIs outside of ISO/IEC officially-published documents
and
2) any other recorded vote by the ARG on matters pursuant to the culmination in a forthcoming ISO/IEC document
is non-existent to ISO.

My point is that if Ada 2020's ISO/IEC is officially emitted the way that so-called Ada 2005's official amendment ISO/IEC8652:1995/Amd1:2007 to official standard ISO/IEC8652:1995 still in effect, then these binding AIs need to be pursuant to not only an ISO/IEC8652:2012/Amd1:2020 (or :2021) but also an ISO/IEC8652:2012/Corr1:2020 (or 2021) to be retroactive back to 2012.  Hence, it would be advantageous in this regard for the Ada 2005 model of mere official amendment to a still-in-effect prior standard to be avoided and the Ada 2012 model to be enacted for Ada 2020.

> But as a practical matter, people continue to use older standards and they 
> need corrections (not allowing implementers to fix language bugs would be 
> worse; why would anyone want to implement nonsense?). Such users need 
> guidance as well, as do the implementers.
> 
> For ACATS purposes (which maintains testing all of the older standards 
> except Ada 83), generally non-Corrigendum binding interpretations are 
> optional for older standards, which means that either the original wording 
> or the new wording is allowed. (We prefer the new wording, of course, but 
> there's no mechanism to require it.) OTOH, Amendments are ignored for the 
> purposes of testing older standards -- that's why we classify them 
> differently.

But conversely unlike amendments, a corrigendum ISO/IEC8652:2012/Corr1:202X to ISO/IEC8652:2012 is normative retroactively to 2012 until ISO/IEC8652:2012 is supplanted by an ISO/IEC8652:202Y even if X and Y are different, say, for Ada 2029 being the next official edition of the standard ISO/IEC8652:2029 where Ada 2020 ended up (unwisely in my opinion) being a mere amendment ISO/IEC8652:2012/Amd1:2020 (or :2021) analogous to Ada 2005 being a mere amendment ISO/IEC8652:1995/Amd1:2007.  This retroactive correction via a corrigendum matches this thread's intended normativeness of Binding AIs, whereas ISO/IEC's amendment term-of-art does not, avoiding general-purpose dictionary definitions of amendment, which might also have crept into this thread.

^ permalink raw reply	[relevance 3%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-04 22:33  6%     ` Optikos
  2020-03-05 16:11  5%       ` Optikos
@ 2020-03-05 23:29  5%       ` Randy Brukardt
  2020-03-06 14:42  3%         ` Optikos
  1 sibling, 1 reply; 200+ results
From: Randy Brukardt @ 2020-03-05 23:29 UTC (permalink / raw)


"Optikos" <ZUERCHER_Andreas@outlook.com> wrote in message 
news:f94395b7-f2de-4c49-8edd-b24bfa64cc37@googlegroups.com...
>On Tuesday, March 3, 2020 at 5:49:35 PM UTC-6, Randy Brukardt wrote:
>> "Simon Wright" wrote in message
>> news:lyv9nl8p6w.fsf@pushface.org...
>> ...
>> > There was a conversation on Ada-Comment in June last year, in which it
>> > turned out that compiler implementers may have have been 
>> > misinterpreting
>> > the ARM. It was quite confusing.
>>
>> Not just a conversation, but also a Binding Interpretation AI (which
>> therefore applies to Ada 2012 compilers), AI12-0336-1.
>
>Shouldn't these Binding AIs that take effect from a past edition of the ISO
>standard onward (and not merely incorporated into Ada 2020 or Ada
>202X post-2020) ..be an ISO/IEC corrigendum..?  Allowing errata be
>permanently published semi-officially in any forum other than
>cummulatively in an official ISO/IEC corrigendum seems to be against the
>ISO/IEC rules.

Not necessarily. ISO has very strict limits on the number of Corrigenda that 
can be issued for a particular standard; after that the only choice is to 
update the Standard.

Remember that from ISO's perspective older standards don't actually exist; 
only the latest version is relevant to ISO. So the difference between 
non-Corrigendum Binding Interpretations and Amendments is non-existent to 
ISO.

But as a practical matter, people continue to use older standards and they 
need corrections (not allowing implementers to fix language bugs would be 
worse; why would anyone want to implement nonsense?). Such users need 
guidance as well, as do the implementers.

For ACATS purposes (which maintains testing all of the older standards 
except Ada 83), generally non-Corrigendum binding interpretations are 
optional for older standards, which means that either the original wording 
or the new wording is allowed. (We prefer the new wording, of course, but 
there's no mechanism to require it.) OTOH, Amendments are ignored for the 
purposes of testing older standards -- that's why we classify them 
differently.

                                                 Randy.


^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-04 22:33  6%     ` Optikos
@ 2020-03-05 16:11  5%       ` Optikos
  2020-03-05 23:29  5%       ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Optikos @ 2020-03-05 16:11 UTC (permalink / raw)


On Wednesday, March 4, 2020 at 4:33:12 PM UTC-6, Optikos wrote:
> On Tuesday, March 3, 2020 at 5:49:35 PM UTC-6, Randy Brukardt wrote:
> > "Simon Wright" wrote in message 
> > news:lyv9nl8p6w.fsf@pushface.org...
> > ...
> > > There was a conversation on Ada-Comment in June last year, in which it
> > > turned out that compiler implementers may have have been misinterpreting
> > > the ARM. It was quite confusing.
> > 
> > Not just a conversation, but also a Binding Interpretation AI (which 
> > therefore applies to Ada 2012 compilers), AI12-0336-1.
> 
> Shouldn't these Binding AIs that take effect from a past edition of the ISO standard onward (and not
> merely incorporated into Ada 2020 or Ada 202X post-2020) ••be an ISO/IEC corrigendum••?  Allowing
> errata be permanently published semi-officially in any forum other than cummulatively in an official
> ISO/IEC corrigendum seems to be against the ISO/IEC rules.

I shouldn't have used the term “errata” there because it is a term-of-art for nontechnical grammatical/spelling errors and the minor like.  I should have utilized ‘technical defect’ or some such term instead, because technical defects go in a corrigendum whereas purely-linguistic errors go in errata.  The ambiguity of UTC vis a vis offsets therefrom in past editions of the ISO/IEC Ada standard are a defect in the meaning, not a mere linguistic-/syntactic-oops erratum.

https://blog.ansi.org/2016/09/standards-changes-amendment-corrigendum-errata

^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-03 23:49  5%   ` Randy Brukardt
  2020-03-04 15:19  6%     ` Simon Wright
@ 2020-03-04 22:33  6%     ` Optikos
  2020-03-05 16:11  5%       ` Optikos
  2020-03-05 23:29  5%       ` Randy Brukardt
  1 sibling, 2 replies; 200+ results
From: Optikos @ 2020-03-04 22:33 UTC (permalink / raw)


On Tuesday, March 3, 2020 at 5:49:35 PM UTC-6, Randy Brukardt wrote:
> "Simon Wright" wrote in message 
> news:lyv9nl8p6w.fsf@pushface.org...
> ...
> > There was a conversation on Ada-Comment in June last year, in which it
> > turned out that compiler implementers may have have been misinterpreting
> > the ARM. It was quite confusing.
> 
> Not just a conversation, but also a Binding Interpretation AI (which 
> therefore applies to Ada 2012 compilers), AI12-0336-1.

Shouldn't these Binding AIs that take effect from a past edition of the ISO standard onward (and not merely incorporated into Ada 2020 or Ada 202X post-2020) ••be an ISO/IEC corrigendum••?  Allowing errata be permanently published semi-officially in any forum other than cummulatively in an official ISO/IEC corrigendum seems to be against the ISO/IEC rules.

^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-03 23:49  5%   ` Randy Brukardt
@ 2020-03-04 15:19  6%     ` Simon Wright
  2020-03-04 22:33  6%     ` Optikos
  1 sibling, 0 replies; 200+ results
From: Simon Wright @ 2020-03-04 15:19 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> As Dmitry says, the default Time_Offset on GNAT gives one UTC. If you want 
> CST or CDT (my time zones, which change on this coming Sunday), one needs to 
> use -360 or -300. We've added a new renaming Local_Time_Image to make this 
> relatively easy (dunno if GNAT has it yet).

FSF GCC 10.0.1 20200206 (experimental) doesn't. May make it into GNAT CE
2020.

^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-03 14:53 12% ` Simon Wright
  2020-03-03 17:40  6%   ` Simon Wright
@ 2020-03-03 23:49  5%   ` Randy Brukardt
  2020-03-04 15:19  6%     ` Simon Wright
  2020-03-04 22:33  6%     ` Optikos
  1 sibling, 2 replies; 200+ results
From: Randy Brukardt @ 2020-03-03 23:49 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:lyv9nl8p6w.fsf@pushface.org...
...
> There was a conversation on Ada-Comment in June last year, in which it
> turned out that compiler implementers may have have been misinterpreting
> the ARM. It was quite confusing.

Not just a conversation, but also a Binding Interpretation AI (which 
therefore applies to Ada 2012 compilers), AI12-0336-1.

Essentially, the formal definition of Time_Offset, and the way it was 
actually implemented by every compiler except mine, was completely 
different. We decided to match practice, especially as that matches the way 
the Internet uses time offsets. So that part of the RM was rewritten.

As Dmitry says, the default Time_Offset on GNAT gives one UTC. If you want 
CST or CDT (my time zones, which change on this coming Sunday), one needs to 
use -360 or -300. We've added a new renaming Local_Time_Image to make this 
relatively easy (dunno if GNAT has it yet).

The advantage of this definition is that the base UTC time doesn't jump 
during the year, but if you are interested in local time, you have to 
determine the offset based on the time-of-year.

Your example suggests that GNAT is doing something weird with times that are 
far away from today. That's certainly not intended, sounds like a bug to me. 
Certainly is a bug with the rewritten rules for Time_Image.

                                                   Randy.


^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-03 14:53 12% ` Simon Wright
@ 2020-03-03 17:40  6%   ` Simon Wright
  2020-03-03 23:49  5%   ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Simon Wright @ 2020-03-03 17:40 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> There was a conversation on Ada-Comment in June last year, in which it
> turned out that compiler implementers may have have been misinterpreting
> the ARM. It was quite confusing.

Also, see AI95-00160,
http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ais/ai-00160.txt?rev=1.4&raw=N

^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-02 18:49 12% Ada.Calendar.Formatting.Image (or Time_Of) changing the time Marius Amado-Alves
  2020-03-02 23:08  6% ` Randy Brukardt
@ 2020-03-03 14:53 12% ` Simon Wright
  2020-03-03 17:40  6%   ` Simon Wright
  2020-03-03 23:49  5%   ` Randy Brukardt
  1 sibling, 2 replies; 200+ results
From: Simon Wright @ 2020-03-03 14:53 UTC (permalink / raw)


Marius Amado-Alves <amado.alves@gmail.com> writes:

> Feeding Ada.Calendar.Formatting.Image with an Ada.Calendar.Time_Of the
> year, month, day, seconds on the left, we get the image on the
> right. Some images, marked *, are 1 hour behind.
>
> 2015 1 21 32040 ( 8:54 AM) => 2015-01-21 08:54:00
> 2015 1 21 39240 (10:54 AM) => 2015-01-21 10:54:00
> 2015 7 21 32040 ( 8:54 AM) => 2015-07-21 07:54:00 *
> 2015 7 21 39240 (10:54 AM) => 2015-07-21 09:54:00 *
>
> The different input is the month, January versus July, so it looks
> like a daylight savings thing. Is this expected behaviour? Thanks.
>
> [Compiler = GNAT Community 2018 (20180523-73)]

There was a conversation on Ada-Comment in June last year, in which it
turned out that compiler implementers may have have been misinterpreting
the ARM. It was quite confusing.

Part of the problem is that Ada.Calendar.Clock, implemented over the OS
facilities, may or may not be in local time; and how does it treat times
which are not in the 'now' time zone?

I wrote this:

   with Ada.Calendar.Formatting;
   with Ada.Calendar.Time_Zones;
   with Ada.Text_IO;
   procedure Marius is
      use type Ada.Calendar.Time;
      Earlier : constant Ada.Calendar.Time
        := Ada.Calendar.Time_Of (2015, 1, 21, 32040.0);
      Later : constant Ada.Calendar.Time
        := Ada.Calendar.Time_Of (2015, 7, 21, 32040.0);
      Offset_Earlier : constant Ada.Calendar.Time_Zones.Time_Offset
        := Ada.Calendar.Time_Zones.UTC_Time_Offset (Earlier);
      Offset_Later : constant Ada.Calendar.Time_Zones.Time_Offset
        := Ada.Calendar.Time_Zones.UTC_Time_Offset (Later);
   begin
      Ada.Text_Io.Put_Line ("Earlier");
      Ada.Text_IO.Put_Line
        ("UTC_Time_Offset: " & Offset_Earlier'Image);
      Ada.Text_IO.Put_Line
        ("Time_Zone default: "
           & Ada.Calendar.Formatting.Image (Earlier));
      Ada.Text_IO.Put_Line
        ("Time_Zone  offset: "
           & Ada.Calendar.Formatting.Image (Earlier, Time_Zone => Offset_Earlier));
      Ada.Text_IO.New_Line;
      Ada.Text_IO.Put_Line ("Later");
      Ada.Text_IO.Put_Line
        ("UTC_Time_Offset: " & Offset_Later'Image);
      Ada.Text_IO.Put_Line
        ("Time_Zone default: "
           & Ada.Calendar.Formatting.Image (Later));
      Ada.Text_IO.Put_Line
        ("Time_Zone  offset: "
           & Ada.Calendar.Formatting.Image (Later, Time_Zone => Offset_Later));
   end Marius;

and it appears that with GNAT (current free
versions), macOS Mojave, time zone London, Time_Of does something
mysterious;it seems that Time_Of looks at the time you specify (08:54)
and thinks to itself, "but the date part shows that's in DST, so the
local clock now (in GMT) would be reading 07:54"

   $ ./marius 
   Earlier
   UTC_Time_Offset:  0
   Time_Zone default: 2015-01-21 08:54:00
   Time_Zone  offset: 2015-01-21 08:54:00

   Later
   UTC_Time_Offset:  60
   Time_Zone default: 2015-07-21 07:54:00
   Time_Zone  offset: 2015-07-21 08:54:00

Just for fun, trying a different time zone (this may well NOT be the
same as actually being in that time zone :)

   $ TZ=EST ./marius 
   Earlier
   UTC_Time_Offset: -300
   Time_Zone default: 2015-01-21 13:54:00
   Time_Zone  offset: 2015-01-21 08:54:00

   Later
   UTC_Time_Offset: -300
   Time_Zone default: 2015-07-21 13:54:00
   Time_Zone  offset: 2015-07-21 08:54:00

Same results on Debian (running in a VM on this Macbook).


^ permalink raw reply	[relevance 12%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-03 12:59  6%   ` Marius Amado-Alves
@ 2020-03-03 14:25  9%     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2020-03-03 14:25 UTC (permalink / raw)


On 2020-03-03 13:59, Marius Amado-Alves wrote:

> Thanks. I used the default, which is a zero offset, hence my surprise,

Zero means UTC, AFAIK. To get local time you should pass the result of 
UTC_Time_Offset from Ada.Calendar.Time_Zones.

> but maybe I am misunderstanding something, date and time is such a complex matter.

Nothing complex, just messed up. The design as I understand it, because 
ARM tells nothing about the meaning of Time values, is that you 
interpret the value of Time differently in different time zones. It is 
done by passing the time zone offset, which itself is a function of time 
to add necessary confusion. So Time is kind of simultaneously UTC and 
CET and whatever.

The common, sane (and scientific) understanding is that UTC and CET are 
different times.

One of the consequences of present design is that you, for example, 
could not store local time reading as a compound value. Without a time 
offset it has no sense. You also cannot spell Jan 23, 2100 CET, as you 
do not know which time offset it will possibly have in 80 years. CET is 
a function and not a value. So there is a date and no time.

> (Namely, I dont understand how a "fixed" offset can vary throughout the year.)

Political time jumps twice a year, so the offset does. Formally these 
are two different times, e.g. CET and CEST.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 9%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-02 23:08  6% ` Randy Brukardt
@ 2020-03-03 12:59  6%   ` Marius Amado-Alves
  2020-03-03 14:25  9%     ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Marius Amado-Alves @ 2020-03-03 12:59 UTC (permalink / raw)


Thanks. I used the default, which is a zero offset, hence my surprise, but maybe I am misunderstanding something, date and time is such a complex matter.

(Namely, I dont understand how a "fixed" offset can vary throughout the year.)

^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar.Formatting.Image (or Time_Of) changing the time
  2020-03-02 18:49 12% Ada.Calendar.Formatting.Image (or Time_Of) changing the time Marius Amado-Alves
@ 2020-03-02 23:08  6% ` Randy Brukardt
  2020-03-03 12:59  6%   ` Marius Amado-Alves
  2020-03-03 14:53 12% ` Simon Wright
  1 sibling, 1 reply; 200+ results
From: Randy Brukardt @ 2020-03-02 23:08 UTC (permalink / raw)


What time zone did you give Image? Time zones are dependent on the time 
given, so just giving some constant is insufficient to give the correct 
local time. (A "time zone" is an offset from UTC, so of course it differs 
throughout the year for most localities.)

                   Randy.

"Marius Amado-Alves" <amado.alves@gmail.com> wrote in message 
news:e92d8c8d-a182-4990-b3f6-33c2ab90bce9@googlegroups.com...
> Feeding Ada.Calendar.Formatting.Image with an Ada.Calendar.Time_Of the 
> year, month, day, seconds on the left, we get the image on the right. Some 
> images, marked *, are 1 hour behind.
>
> 2015 1 21 32040 ( 8:54 AM) => 2015-01-21 08:54:00
> 2015 1 21 39240 (10:54 AM) => 2015-01-21 10:54:00
> 2015 7 21 32040 ( 8:54 AM) => 2015-07-21 07:54:00 *
> 2015 7 21 39240 (10:54 AM) => 2015-07-21 09:54:00 *
>
> The different input is the month, January versus July, so it looks like a 
> daylight savings thing. Is this expected behaviour? Thanks.
>
> [Compiler = GNAT Community 2018 (20180523-73)] 



^ permalink raw reply	[relevance 6%]

* Ada.Calendar.Formatting.Image (or Time_Of) changing the time
@ 2020-03-02 18:49 12% Marius Amado-Alves
  2020-03-02 23:08  6% ` Randy Brukardt
  2020-03-03 14:53 12% ` Simon Wright
  0 siblings, 2 replies; 200+ results
From: Marius Amado-Alves @ 2020-03-02 18:49 UTC (permalink / raw)


Feeding Ada.Calendar.Formatting.Image with an Ada.Calendar.Time_Of the year, month, day, seconds on the left, we get the image on the right. Some images, marked *, are 1 hour behind.

2015 1 21 32040 ( 8:54 AM) => 2015-01-21 08:54:00
2015 1 21 39240 (10:54 AM) => 2015-01-21 10:54:00
2015 7 21 32040 ( 8:54 AM) => 2015-07-21 07:54:00 *
2015 7 21 39240 (10:54 AM) => 2015-07-21 09:54:00 *

The different input is the month, January versus July, so it looks like a daylight savings thing. Is this expected behaviour? Thanks.

[Compiler = GNAT Community 2018 (20180523-73)]

^ permalink raw reply	[relevance 12%]

* ANN: dcf-ada 2.0.0 -- A library for document container files, a Zip-based archive format
@ 2019-07-23 21:15  4% onox
  0 siblings, 0 replies; 200+ results
From: onox @ 2019-07-23 21:15 UTC (permalink / raw)


An Ada 2012 library for document container files, a Zip-based archive format standardized in ISO/IEC 21320-1:2015. Document container files are Zip files with several restrictions:

* Only "store" (uncompressed) and "deflate" compression methods are allowed

* Archives may not be encrypted or contain digital signatures

* Archives may not span multiple volumes or be segmented

This library is based on the Zip-Ada library, with extensive modifications:

* Binary and Windows-specific files have been removed with The BFG Repo Cleaner

* Reformatted code to Ada default style guide

* Removed obsolescent features and implementation-defined extensions

* All packages except one that uses Ada.Calendar are preelaborated

* Removed features prohibited by ISO standard

* Removed lots of duplicated code and simplified the API, reducing SLOC from 12k to 4.5k

Although the tools can (un)zip basic .zip files, the purpose of the library is to be able to read container files, including a future binary storage format for 3D meshes.

See the README.md at https://github.com/onox/dcf-ada on how to list or extract files from an archive.

^ permalink raw reply	[relevance 4%]

* Q: Calendar and time zones
@ 2019-04-30  0:58  7% b.mcguinness747
  0 siblings, 0 replies; 200+ results
From: b.mcguinness747 @ 2019-04-30  0:58 UTC (permalink / raw)


Section 9.6.1 of the Reference Manual has a note (39) at the bottom of the page that says: "Calling Split on the results of subtracting Duration(UTC_Time_Offset*60) from Clock provides the components (hours, minutes, and so on) of the UTC time. In the United States, for example, UTC_Time_Offset will generally be negative."

But several versions of Split have a Time_Zone argument that defaults to 0, which I interpret as meaning that they default to reporting the time in UTC.  Moreover, I wrote a test program that seems to report UTC time properly without subtracting a time zone offset:

with Ada.Calendar, Ada.Calendar.Formatting, Ada.Calendar.Time_Zones, Ada.Text_IO;

procedure timetest is
  use Ada.Calendar, Ada.Calendar.Formatting, Ada.Calendar.Time_Zones;

  now         : Time        := Clock;
  zone_offset : Time_Offset := UTC_Time_Offset (now);
begin
  Ada.Text_IO.Put_Line ("Current time:     " & Image (now) & " UTC");
  Ada.Text_IO.Put_Line ("Current time:     " & Image (now, false, zone_offset) & " local");
  Ada.Text_IO.Put_Line ("Time zone offset: " & Time_Offset'Image (zone_offset) & " minutes");
end timetest;

 $ timetest
Current time:     2019-04-30 00:55:19 UTC
Current time:     2019-04-29 20:55:19 local
Time zone offset: -240 minutes

Perhaps the comment refers only to versions of Split that do not take a Time_Zone argument.

It would be helpful if the comment in the Reference Manual was rewritten in future editions to indicate more clearly what it means.

--- Brian McGuinness

^ permalink raw reply	[relevance 7%]

* Re: GNAT Modification_Time limitation
  2018-11-20  1:33  0% ` Keith Thompson
@ 2018-11-20 23:32  7%   ` Randy Brukardt
  0 siblings, 0 replies; 200+ results
From: Randy Brukardt @ 2018-11-20 23:32 UTC (permalink / raw)


"Keith Thompson" <kst-u@mib.org> wrote in message 
news:lnefbgr0rz.fsf@kst-u.example.com...
...
> If you're on a non-POSIX system, there might still be a
> system-specific way to get a more precise timestamp.  (NTFS also
> seems to store timestamps with high precision.)

NTFS has three timestamps (modification, creation, and last access). Only 
the modification has high precision; the others are only good to full 
seconds (or something like that).

FAT file systems (as you might encounter on a camera or USB stick) only have 
precision to 2 seconds. (Which is why we had to deal with this in the 
Janus/Ada build tools fairly early on.)

Also note that the system clock on Windows systems typically only changes 
every 0.01 sec (Dmitry says this can be changed, although I've never seen 
that done). That extends to the file systems and other OS timers as well. 
Most Ada vendors use a Ada.Calendar.Clock that blends the system clock with 
the high performance timer to get useful accuracy of of Ada.Calendar.Time. 
(A customer/collaborator, Tom Moran, originally wrote that code the the 
Janus/Ada implementation of Calendar to fix some timing problem that he had. 
He eventually submitted similar code to AdaCore who added it to their 
Calendar as well.)

Moral: Doing "Make" on a modern machine, especially if you want it to be 
portable, is a tricky job.

                                  Randy.



^ permalink raw reply	[relevance 7%]

* Re: GNAT Modification_Time limitation
  2018-11-19 22:56  6% GNAT Modification_Time limitation Lionel Draghi
  2018-11-20  1:33  0% ` Keith Thompson
@ 2018-11-20  8:08  0% ` briot.emmanuel
  1 sibling, 0 replies; 200+ results
From: briot.emmanuel @ 2018-11-20  8:08 UTC (permalink / raw)


> I am coding a kind of make application, that depends on file's time tag (thanks to Ada.Directories.Modification_Time), and on Ada.Calendar.Clock, both returning Ada.Calendar.Time.


Interesting. I am in the middle of a discussion with AdaCore about gprbuild, which fails to recompile when using an alternative body that happens to have the same time stamp (to the second). gprbuild sees that the modification time appears to be the same, and thus doesn't recompile.

Two points:
   - AdaCore mentioned they made progress recently on timestamp precision and it would likely fix the scenario. I think this is similar to what you reported, so it is likely your issue has been fixed now.

   - I am arguing with AdaCore that checking timestamps is not enough (might not even be useful at all), as Shark8 mentioned. The scenario I have is the following:

       Create a project with one scenario variable. Depending on that variable, chose src1 or src2 for source dirs. In each of these directories, have a file utils.adb with a different content. "touch" these two files so that they have the same timestamp. If you build your application once with one value of the variable, then rebuild with another value, gprbuild does nothing the second time.

I had a similar real case because git created two files with the same timestamp. And then it took me days to understand why some of my tests appeared to be linked with both versions of utils.adb, since I could see in the log file traces from both src1/utils.adb and src2/utils.adb.
Very very confusing.

So I would indeed recommend that you don't bother with timestamps, and only look at file contents (or use timestamp+file path at the very least, or perhaps inodes).

I am interested in hearing more why you want to code a new 'make-like' ?

Now trying to persuade AdaCore that gprbuild's behavior is incorrect...

Emmanuel


^ permalink raw reply	[relevance 0%]

* Re: GNAT Modification_Time limitation
  2018-11-19 22:56  6% GNAT Modification_Time limitation Lionel Draghi
@ 2018-11-20  1:33  0% ` Keith Thompson
  2018-11-20 23:32  7%   ` Randy Brukardt
  2018-11-20  8:08  0% ` briot.emmanuel
  1 sibling, 1 reply; 200+ results
From: Keith Thompson @ 2018-11-20  1:33 UTC (permalink / raw)


Lionel Draghi <lionel.draghi@gmail.com> writes:
> I am coding a kind of make application, that depends on file's time
> tag (thanks to Ada.Directories.Modification_Time), and on
> Ada.Calendar.Clock, both returning Ada.Calendar.Time.
>
> Unfortunately, I came across a GNAT limitation in the
> Modification_Time implementation on Linux : sub-second are ignored,
> and Modification_Time returns
>> Time_Of (Year, Month, Day, Hour, Minute, Second, 0.0);
>
> So, at the same time Clock returns 2018-10-29 20:36:01.47
> while Modification_Time    returns 2018-10-29 20:36:01.00
>
> This prevents me from knowing if a file is modified before or after
> certain time, and thus undermine my efforts.
>
> My workaround was to impair also Clock precision, with an ugly rounding:
>> Time := Ada.Calendar.Clock;
>> New_Time := Time_Of
>>   (Year    => Year (Time),
>>    Month   => Month (Time),
>>    Day     => Day (Time),
>>    Seconds => Day_Duration (Float'Floor (Float (Seconds (Time)))));
>
> But that's not a correct solution either : I have to order lots of
> file creation, and having all files created during the same second
> returning the same time tag also prevent my algorithm from properly
> working.
>
> Any workaround to get a precise file time tag? 
> Or to compare file's time tag with Clock?

It's odd that GNAT's Modification_Time truncates the time to
one-second precision.  A quick experiment on my system (Ubuntu 18.04)
also indicates that it does so, even though the system stores the
timestamp in nanosecond precision.

On Linux 2.6 and later, the underlying stat() system call gives you
a "struct timespec" value for the modification time, as specified
by the current POSIX standard.  (struct timespec represents times
with nanosecond precision.)  A file system isn't required to store
times with that precision, but many do.

If you're on a POSIX system, you should be able to call the stat()
system call and *probably* get a more precise timestamp.

If you're on a non-POSIX system, there might still be a
system-specific way to get a more precise timestamp.  (NTFS also
seems to store timestamps with high precision.)

(And remember that nanosecond precision doesn't necessarily imply
nanosecond accuracy.)

-- 
Keith Thompson (The_Other_Keith) kst@mib.org  <http://www.ghoti.net/~kst>
Will write code for food.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


^ permalink raw reply	[relevance 0%]

* GNAT Modification_Time limitation
@ 2018-11-19 22:56  6% Lionel Draghi
  2018-11-20  1:33  0% ` Keith Thompson
  2018-11-20  8:08  0% ` briot.emmanuel
  0 siblings, 2 replies; 200+ results
From: Lionel Draghi @ 2018-11-19 22:56 UTC (permalink / raw)


I am coding a kind of make application, that depends on file's time tag (thanks to Ada.Directories.Modification_Time), and on Ada.Calendar.Clock, both returning Ada.Calendar.Time.

Unfortunately, I came across a GNAT limitation in the Modification_Time implementation on Linux : sub-second are ignored, and Modification_Time returns 
> Time_Of (Year, Month, Day, Hour, Minute, Second, 0.0);

So, at the same time Clock returns 2018-10-29 20:36:01.47
while Modification_Time    returns 2018-10-29 20:36:01.00

This prevents me from knowing if a file is modified before or after certain time, and thus undermine my efforts.

My workaround was to impair also Clock precision, with an ugly rounding:
> Time := Ada.Calendar.Clock;
> New_Time := Time_Of
>   (Year    => Year (Time),
>    Month   => Month (Time),
>    Day     => Day (Time),
>    Seconds => Day_Duration (Float'Floor (Float (Seconds (Time)))));

But that's not a correct solution either : I have to order lots of file creation, and having all files created during the same second returning the same time tag also prevent my algorithm from properly working.

Any workaround to get a precise file time tag? 
Or to compare file's time tag with Clock?

Thanks,

--
Lionel  


^ permalink raw reply	[relevance 6%]

* Re: A little trouble with very large arrays.
  2018-10-05 19:49  5%       ` Shark8
@ 2018-10-05 20:31  0%         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2018-10-05 20:31 UTC (permalink / raw)


On 2018-10-05 21:49, Shark8 wrote:

> Most of the anticipated usage for where I am right now would be producing FITS files, likely in something that would boil down to a coupling like this:
> 
>    Count      : Positive := 1;
>    Today      : Ada.Calendar.Time renames Ada.Calendar.Clock;
>    New_Image  : Camera_Image renames Normalize( Get_Camera_Image );
>    New_Object : FITS.Object := FITS.Create_w_Defaults( New_Image );
>    --..
>    -- Writes data out to "Observation(YYYY-MM-DD)_00X.FITS".
>    New_Object.Write( Base => "Observation", Date => Today, Count => X );
> 
> I'd rather not tie things to a memory-mapped file at a high level, but it may be that my ideal abstraction is non-tenable.

You still can do this. The object can have any representation, the 
stream attribute will encode/decode it as required by FITS:

    Object : FITS.Image :=
       Create
       (  Base  => "Observation",
          Date  => Clock,
          Image => Get_Camera_Image
       );
begin
    FITS.Image'Write (Stream, Object);

Or without any intermediate objects:

    FITS.Store
    (  File  => Stream,
       Base  => "Observation",
       Date  => Clock,
       Image => Get_Camera_Image
    );

The problem with intermediate objects is copying bulky data like images 
unless you deploy some complex reference-counting schema. Good bindings 
support provide in-place I/O operations.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 0%]

* Re: A little trouble with very large arrays.
  @ 2018-10-05 19:49  5%       ` Shark8
  2018-10-05 20:31  0%         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Shark8 @ 2018-10-05 19:49 UTC (permalink / raw)


> > No, the smallest sensible number of indices is 1, for everything except
> > maybe the first two or three dimensions: eg Image data from a camera, or
> > perhaps topological data from a map (longitude, latitude, elevation).
> 
> FITS images can have more dimensions than that. Further dimensions might 
> be the frequency of the light (spectral imaging); polarisation; time 
> when image was taken; and perhaps a couple more that don't come to mind 
> immediately.

Sure; but even those are a fairly small dimensionality than what the standard allows.
 
> I understand what you tried to do, including having length-one 
> dimensions, but I don't think that it is a sensible approach to handling 
> up to 999 dimensions. I agree with the flattening approach that Dmitry 
> suggested.

That would be rather unfortunate, to be honest. I'd much rather rely on the compiler translating the indexes than have to do so manually. I trust the compiler more than myself; plus letting it take care of keeping track of the mapping (ie FORTRAN convention) is nice.

My ultimate goal was to have some FITS_OBJECT type that had the appropriate data-members be able to simply "write itself to a stream" to output the proper FITS format file.

> 
> If your FITS files are not much larger than your RAM, the fastest 
> approach is probably to "mmap" the file into your virtual address space 
> and then compute the address of any given image pixel with the 
> flattening method. If your FITS files are larger than your RAM, your 
> program should process the file as a stream, which may or may not be 
> practical, depending on what the program should output.

Most of the anticipated usage for where I am right now would be producing FITS files, likely in something that would boil down to a coupling like this:

  Count      : Positive := 1;
  Today      : Ada.Calendar.Time renames Ada.Calendar.Clock;
  New_Image  : Camera_Image renames Normalize( Get_Camera_Image );
  New_Object : FITS.Object := FITS.Create_w_Defaults( New_Image );
  --..
  -- Writes data out to "Observation(YYYY-MM-DD)_00X.FITS".
  New_Object.Write( Base => "Observation", Date => Today, Count => X );

I'd rather not tie things to a memory-mapped file at a high level, but it may be that my ideal abstraction is non-tenable.


> > FITS was developed for handling "image" transport by the astronomy
> > world, back when there were 9-bit bytes and such.
> 
> I know, I used to work in astronomy. What's your point about 9-bit 
> bytes? FITS standard version 4.0 defines "byte" as 8 bits, and allows 
> only 8, 16, 32 and 64-bit pixels. No 9-bit pixels.

Sorry, that was more about Dmitry's suggestion to pretend representation-clauses don't exist; I haven't done anything at a bit-level at all. (And I don't think I need to, except perhaps to mark the Primary-Data array elements as Big-endian [IIRC].)

^ permalink raw reply	[relevance 5%]

* Re: Watchdog-Timer Assignment
  2018-09-22  3:29  6% ` Shark8
@ 2018-09-22 11:56  0%   ` Alex
  0 siblings, 0 replies; 200+ results
From: Alex @ 2018-09-22 11:56 UTC (permalink / raw)


> This?
> 
>     Function Next_Second return Ada.Calendar.Time is
> 	Use Ada.Calendar;
> 	Now       : Time renames Clock;
> 	Second    : Duration renames Seconds(Now);
> 	Trunc     : Constant Natural  := Natural(Second);
> 	Rounded   : Constant Duration := Duration(Trunc);
> 	Year      : Year_Number;
> 	Month     : Month_Number;
> 	Day       : Day_Number;
> 	S         : Duration;
>     Begin
> 	Split(
>           Date    => Now,
>           Year    => Year,
>           Month   => Month,
>           Day     => Day,
>           Seconds => S
>          );
> 	return Time_Of(Year, Month, Day,
> 	  (if Rounded < Second
> 	   then Rounded + 1.0
> 	   else Rounded
> 	  ));
>     End Next_Second;

This I haven't seen! But that might work, I shall try. Even though I do not believe we had to do our own function, but that might work anyways. I will try. Thank you!

^ permalink raw reply	[relevance 0%]

* Re: Watchdog-Timer Assignment
  @ 2018-09-22  3:29  6% ` Shark8
  2018-09-22 11:56  0%   ` Alex
  0 siblings, 1 reply; 200+ results
From: Shark8 @ 2018-09-22  3:29 UTC (permalink / raw)


On Friday, September 21, 2018 at 4:29:10 AM UTC-6, Alex wrote:
> Hello, I have a school assignment (I have heard that this is important to mention) which I need help with.
> 
> You can find my code here: https://ideone.com/LIWmJM
> 
> My assignment is this:
> 
> Modify F3 from Part 1 so that it occasionally takes more than 0.5 seconds to execute.
> 
> Augment the cyclic scheduler from Part 1 with a watchdog task to monitor F3's execution time. When F3 exceeds its deadline (0.5s), the watchdog task should immediately print a warning message. I.e., 0.5s after start of F3, either F3 has finished or the watchdog has printed a message. The watchdog should let F3 finish even if it misses its deadline.
> 
> The watchdog task should be started (released) at the same time as (or just before) F3 starts executing, and from that point measure the time that F3 uses.
> 
> When F3 misses its deadline the cyclic executive should re-synchronize so that F1 is started at whole seconds.
> 
> You should start with this skeleton code: part 2. Examine the code to understand how a task is declared inside an Ada program. Try to modify it in places indicated by the comments. You can also reuse your solution for part 1 as the initial code.
> 
> (P.S The skeleton code "part 2" is more or less an empty Watchdog task-body).
> 
> I have implemented a random delay for f3 so that it occasionally takes more than 0.5 seconds to execute. My biggest issue (I believe) is that (if f3 takes more than 0.5 seconds to execute) f1 is supposed to start over at the next whole second.
> 
> I dont know where I should put that delay for this to happen.
> 
> Thank you in advance!

This?

    Function Next_Second return Ada.Calendar.Time is
	Use Ada.Calendar;
	Now       : Time renames Clock;
	Second    : Duration renames Seconds(Now);
	Trunc     : Constant Natural  := Natural(Second);
	Rounded   : Constant Duration := Duration(Trunc);
	Year      : Year_Number;
	Month     : Month_Number;
	Day       : Day_Number;
	S         : Duration;
    Begin
	Split(
          Date    => Now,
          Year    => Year,
          Month   => Month,
          Day     => Day,
          Seconds => S
         );
	return Time_Of(Year, Month, Day,
	  (if Rounded < Second
	   then Rounded + 1.0
	   else Rounded
	  ));
    End Next_Second;


^ permalink raw reply	[relevance 6%]

* Re: Ann: Ada-Win32 bindings
  2018-08-04  7:10  4% ` Dmitry A. Kazakov
@ 2018-08-04  9:58  0%   ` alby.gamper
  0 siblings, 0 replies; 200+ results
From: alby.gamper @ 2018-08-04  9:58 UTC (permalink / raw)


On Saturday, August 4, 2018 at 5:10:08 PM UTC+10, Dmitry A. Kazakov wrote:
> On 2018-08-04 02:20, alby.gamper@gmail.com wrote:
> 
> > I am pleased to announce the initial release of ADA bindings for the Win32 API
> 
> Since Win32Ada is no more public that is a welcome substitute.
> 
> Alas, to late for me. I already migrated from Win32Ada to hand-written 
> small portions of Win32 API for the projects that used Win32Ada.
> 
> > Note: Their is still a bit of work to do in these bindings, specifically
> > 1) Callbacks / function profiles need to be addressed (currently mapped to System.Address)
> > 2) Handle inline functions ??
> > 3) Better handling of Pre-processor macros ??
> 
> Yes, some are missing, e.g. MAKELANGID.
> 
> 4. A- and W-forms should not be exposed, IMO. E.g. not 
> CreateFileMappingA and CreateFileMapping but two overloaded 
> CreateFileMapping.
> 
> 5. The stuff like LPCSTR should be handled more intelligently. I know it 
> is difficult, but input nul-terminated strings should also allow 
> char_array (or wide equivalent) argument instead of a raw pointer to char.
> 
> 6. NTSTATUS constants
> 
> 7. Some Ada convenience calls, e.g.
> 
> Conversions FILTETIME <-> Ada.Calendar.Time
> 
>     procedure Raise_From_LastError
>               (  ID     : Exception_ID;
>                  Prefix : String     := "";
>                  Error  : Error_Code := GetLastError
>               );
> 
> Conversions NTSTATUS <-> ERROR_CODE etc.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Hi Dmitry

Thanks for your valued response, and I mostly agree with your points, and I will
try and address these points in future release's

Note some items may need to be Hand written, but point 6 and maybe 4 should be
very doable/straight forward. I'm thinking along the lines of using ANTLR to
parse the MACRO/PRE_PROCESSOR definitions/expansions ?

Alex

^ permalink raw reply	[relevance 0%]

* Re: Ann: Ada-Win32 bindings
  @ 2018-08-04  7:10  4% ` Dmitry A. Kazakov
  2018-08-04  9:58  0%   ` alby.gamper
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2018-08-04  7:10 UTC (permalink / raw)


On 2018-08-04 02:20, alby.gamper@gmail.com wrote:

> I am pleased to announce the initial release of ADA bindings for the Win32 API

Since Win32Ada is no more public that is a welcome substitute.

Alas, to late for me. I already migrated from Win32Ada to hand-written 
small portions of Win32 API for the projects that used Win32Ada.

> Note: Their is still a bit of work to do in these bindings, specifically
> 1) Callbacks / function profiles need to be addressed (currently mapped to System.Address)
> 2) Handle inline functions ??
> 3) Better handling of Pre-processor macros ??

Yes, some are missing, e.g. MAKELANGID.

4. A- and W-forms should not be exposed, IMO. E.g. not 
CreateFileMappingA and CreateFileMapping but two overloaded 
CreateFileMapping.

5. The stuff like LPCSTR should be handled more intelligently. I know it 
is difficult, but input nul-terminated strings should also allow 
char_array (or wide equivalent) argument instead of a raw pointer to char.

6. NTSTATUS constants

7. Some Ada convenience calls, e.g.

Conversions FILTETIME <-> Ada.Calendar.Time

    procedure Raise_From_LastError
              (  ID     : Exception_ID;
                 Prefix : String     := "";
                 Error  : Error_Code := GetLastError
              );

Conversions NTSTATUS <-> ERROR_CODE etc.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 4%]

* Re: How to run a GNAT program without starting a terminal session
  2018-07-19  7:20  0%   ` Björn Lundin
@ 2018-07-19 11:30  0%     ` Jerry
  0 siblings, 0 replies; 200+ results
From: Jerry @ 2018-07-19 11:30 UTC (permalink / raw)


On Thursday, July 19, 2018 at 12:20:57 AM UTC-7, björn lundin wrote:
> On 2018-07-19 04:57, Jerry wrote:
> > On Monday, July 16, 2018 at 6:20:50 PM UTC-7, Jerry wrote:
> >> How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?
> >>
> >>
> >> with Ada.Calendar; use Ada.Calendar;
> >> with Common; -- Contains "Beep".
> >>
> >> procedure Run is
> >> begin
> >>     Delay 4.0;
> >>     Common.Beep(1);
> >> end Run;
> >>
> >>
> >> Jerry
> > 
> > It looks like there is no easy answer to the original question, how to run a GNAT program without a terminal, but here is a solution to my immediate problem with some do-dads added. Sorry, it's not Ada. It's Applescript. The Applescript compiler bundles this up nicely as a double-clickable application bundle and does what I want. (The dialog box at the end is a little gratuitous.) afplay plays any audio file.
> > 
> > 
> > delay 30
> > do shell script "afplay '/System/Library/Sounds/Frog.aiff'"
> > delay 15
> > do shell script "afplay '/System/Library/Sounds/Ping.aiff'"
> > delay 13
> > beep
> > delay 1
> > beep
> > delay 1
> > beep
> > say "Stop running Jerry" volume 0.5
> > display dialog "Stop running!" buttons {"OK"} default button 1
> > 
> > 
> > What is this piece of silliness? For some time I have taken seriously the claim that sitting for long periods of time is unhealthy, and consequently I set my computer to announce the time every half hour at which time I am *supposed* to get up and run in place for one minute. I believe that this is a simple version of interval training and can actually cause me to lose a little weight. The problem is that I have to watch an analog on-screen clock to see when to stop and this does not always have a background that makes the clock easy to see, plus I have to stick next to the computer. Using a utility, I launch this program with a simple key combination.
> > 
> > Jerry
> > 
> 
> Ah. Applescript is kind of fun.
> Until you want to do some advance stuff.
> I used to script apple iTunes and iPhote with a python binding to
> applescript. worked better than I thoufht.
> 
> Anyway, your usercase does sound like you want a daemon.
> make it start at boot, and then run forever.
> That is what launchctrl is about.
> 
> But the applescript soulution may be simpler, except for you need to
> start it by yourdelf each time.
> 
> 
> 
> -- 
> --
> Björn

I _want_ to start it myself each time, approximately every 30 minutes, and it is designed to stop running after one minute. See my "running" post above.

The Applescript works perfectly but it's not Ada. :-( And I still don't know how to solve my original problem, how to run Ada program without a terminal session starting.

Jerry

^ permalink raw reply	[relevance 0%]

* Re: How to run a GNAT program without starting a terminal session
  2018-07-19  2:57  0% ` Jerry
@ 2018-07-19  7:20  0%   ` Björn Lundin
  2018-07-19 11:30  0%     ` Jerry
  0 siblings, 1 reply; 200+ results
From: Björn Lundin @ 2018-07-19  7:20 UTC (permalink / raw)


On 2018-07-19 04:57, Jerry wrote:
> On Monday, July 16, 2018 at 6:20:50 PM UTC-7, Jerry wrote:
>> How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?
>>
>>
>> with Ada.Calendar; use Ada.Calendar;
>> with Common; -- Contains "Beep".
>>
>> procedure Run is
>> begin
>>     Delay 4.0;
>>     Common.Beep(1);
>> end Run;
>>
>>
>> Jerry
> 
> It looks like there is no easy answer to the original question, how to run a GNAT program without a terminal, but here is a solution to my immediate problem with some do-dads added. Sorry, it's not Ada. It's Applescript. The Applescript compiler bundles this up nicely as a double-clickable application bundle and does what I want. (The dialog box at the end is a little gratuitous.) afplay plays any audio file.
> 
> 
> delay 30
> do shell script "afplay '/System/Library/Sounds/Frog.aiff'"
> delay 15
> do shell script "afplay '/System/Library/Sounds/Ping.aiff'"
> delay 13
> beep
> delay 1
> beep
> delay 1
> beep
> say "Stop running Jerry" volume 0.5
> display dialog "Stop running!" buttons {"OK"} default button 1
> 
> 
> What is this piece of silliness? For some time I have taken seriously the claim that sitting for long periods of time is unhealthy, and consequently I set my computer to announce the time every half hour at which time I am *supposed* to get up and run in place for one minute. I believe that this is a simple version of interval training and can actually cause me to lose a little weight. The problem is that I have to watch an analog on-screen clock to see when to stop and this does not always have a background that makes the clock easy to see, plus I have to stick next to the computer. Using a utility, I launch this program with a simple key combination.
> 
> Jerry
> 

Ah. Applescript is kind of fun.
Until you want to do some advance stuff.
I used to script apple iTunes and iPhote with a python binding to
applescript. worked better than I thoufht.

Anyway, your usercase does sound like you want a daemon.
make it start at boot, and then run forever.
That is what launchctrl is about.

But the applescript soulution may be simpler, except for you need to
start it by yourdelf each time.



-- 
--
Björn

^ permalink raw reply	[relevance 0%]

* Re: How to run a GNAT program without starting a terminal session
  2018-07-17  1:20  6% How to run a GNAT program without starting a terminal session Jerry
  2018-07-17 12:46  0% ` Björn Lundin
  2018-07-17 18:21  0% ` Shark8
@ 2018-07-19  2:57  0% ` Jerry
  2018-07-19  7:20  0%   ` Björn Lundin
  2 siblings, 1 reply; 200+ results
From: Jerry @ 2018-07-19  2:57 UTC (permalink / raw)


On Monday, July 16, 2018 at 6:20:50 PM UTC-7, Jerry wrote:
> How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?
> 
> 
> with Ada.Calendar; use Ada.Calendar;
> with Common; -- Contains "Beep".
> 
> procedure Run is
> begin
>     Delay 4.0;
>     Common.Beep(1);
> end Run;
> 
> 
> Jerry

It looks like there is no easy answer to the original question, how to run a GNAT program without a terminal, but here is a solution to my immediate problem with some do-dads added. Sorry, it's not Ada. It's Applescript. The Applescript compiler bundles this up nicely as a double-clickable application bundle and does what I want. (The dialog box at the end is a little gratuitous.) afplay plays any audio file.


delay 30
do shell script "afplay '/System/Library/Sounds/Frog.aiff'"
delay 15
do shell script "afplay '/System/Library/Sounds/Ping.aiff'"
delay 13
beep
delay 1
beep
delay 1
beep
say "Stop running Jerry" volume 0.5
display dialog "Stop running!" buttons {"OK"} default button 1


What is this piece of silliness? For some time I have taken seriously the claim that sitting for long periods of time is unhealthy, and consequently I set my computer to announce the time every half hour at which time I am *supposed* to get up and run in place for one minute. I believe that this is a simple version of interval training and can actually cause me to lose a little weight. The problem is that I have to watch an analog on-screen clock to see when to stop and this does not always have a background that makes the clock easy to see, plus I have to stick next to the computer. Using a utility, I launch this program with a simple key combination.

Jerry

^ permalink raw reply	[relevance 0%]

* Re: How to run a GNAT program without starting a terminal session
  @ 2018-07-18  1:33  7%         ` Shark8
  0 siblings, 0 replies; 200+ results
From: Shark8 @ 2018-07-18  1:33 UTC (permalink / raw)


On Tuesday, July 17, 2018 at 3:56:24 PM UTC-6, Jerry wrote:
With
Ada.Calendar.Formatting,
Ada.Text_IO;

Use
Ada.Text_IO;

Procedure Test is
    Task Type Hello( Cycle_Timing : not null access Duration ) is
	Entry Stop;
    end Hello;
    
    Task Body Hello is
	Finished : Boolean := False;
    Begin
	Ada.Text_IO.Put_Line( "Starting Task Hello." );
	loop
	    select
		accept Stop  do
		    null;
		end Stop;
		Finished:= True;
	    OR
		delay Cycle_Timing.all;
	    end select;
	    Exit when Finished;
	    -- TIMED PORTION.
	    Ada.Text_IO.Put_Line( "The time is now: " &
		Ada.Calendar.Formatting.Image(
			Ada.Calendar.Clock
			    )
			  & '.' );
	end loop;
	Ada.Text_IO.Put_Line( "Finishing Task Hello." );
    End Hello;
    

    
    Greeter : Hello( new Duration'(3.0) ); -- 3 second cycle.
Begin
    --Runner;
    
    declare
        -- Wait until the user hits enter...
	Tmp : String renames Get_Line;
    Begin
        -- then stop the Greeter task.
	Greeter.Stop;
    End;
End Test;

^ permalink raw reply	[relevance 7%]

* Re: How to run a GNAT program without starting a terminal session
  2018-07-17 12:46  0% ` Björn Lundin
@ 2018-07-17 21:07  0%   ` Jerry
    0 siblings, 1 reply; 200+ results
From: Jerry @ 2018-07-17 21:07 UTC (permalink / raw)


On Tuesday, July 17, 2018 at 5:46:39 AM UTC-7, björn lundin wrote:
> On 2018-07-17 03:20, Jerry wrote:
> > How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?
> > 
> > 
> > with Ada.Calendar; use Ada.Calendar;
> > with Common; -- Contains "Beep".
> > 
> > procedure Run is
> > begin
> >     Delay 4.0;
> >     Common.Beep(1);
> > end Run;
> > 
> > 
> > Jerry
> > 
> 
> is it supposted to be a daemon?
> check launchctrl
> <https://superuser.com/questions/930389/how-to-start-a-service-using-mac-osxs-launchctl>
> 
> 
> 
> -- 
> --
> Björn

I'm not sure exactly what is meant by a daemon but I think it is a faceless program that runs in the background over an extended period of time. Mine might satisfy that definition--it is faceless and runs until all of the several "delay-beep" pairs are executed, then quits.

Apple's launchctrl might work but it looks very complicated to learn.

Jerry

^ permalink raw reply	[relevance 0%]

* Re: How to run a GNAT program without starting a terminal session
  2018-07-17  1:20  6% How to run a GNAT program without starting a terminal session Jerry
  2018-07-17 12:46  0% ` Björn Lundin
@ 2018-07-17 18:21  0% ` Shark8
  2018-07-19  2:57  0% ` Jerry
  2 siblings, 0 replies; 200+ results
From: Shark8 @ 2018-07-17 18:21 UTC (permalink / raw)


On Monday, July 16, 2018 at 7:20:50 PM UTC-6, Jerry wrote:
> How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?
> 
> 
> with Ada.Calendar; use Ada.Calendar;
> with Common; -- Contains "Beep".
> 
> procedure Run is
> begin
>     Delay 4.0;
>     Common.Beep(1);
> end Run;
> 
> 
> Jerry

Since you're talking about GNAT in particular you can use GNAT's System.OS_Lib package as detailed in the last example here: https://rosettacode.org/wiki/Execute_a_system_command#Ada

^ permalink raw reply	[relevance 0%]

* Re: How to run a GNAT program without starting a terminal session
  2018-07-17  1:20  6% How to run a GNAT program without starting a terminal session Jerry
@ 2018-07-17 12:46  0% ` Björn Lundin
  2018-07-17 21:07  0%   ` Jerry
  2018-07-17 18:21  0% ` Shark8
  2018-07-19  2:57  0% ` Jerry
  2 siblings, 1 reply; 200+ results
From: Björn Lundin @ 2018-07-17 12:46 UTC (permalink / raw)


On 2018-07-17 03:20, Jerry wrote:
> How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?
> 
> 
> with Ada.Calendar; use Ada.Calendar;
> with Common; -- Contains "Beep".
> 
> procedure Run is
> begin
>     Delay 4.0;
>     Common.Beep(1);
> end Run;
> 
> 
> Jerry
> 

is it supposted to be a daemon?
check launchctrl
<https://superuser.com/questions/930389/how-to-start-a-service-using-mac-osxs-launchctl>



-- 
--
Björn


^ permalink raw reply	[relevance 0%]

* How to run a GNAT program without starting a terminal session
@ 2018-07-17  1:20  6% Jerry
  2018-07-17 12:46  0% ` Björn Lundin
                   ` (2 more replies)
  0 siblings, 3 replies; 200+ results
From: Jerry @ 2018-07-17  1:20 UTC (permalink / raw)


How can I get Ada (GNAT) to run a program that has no text I/O without launching a terminal session? Specifically, on macOS, I have the following program. When I double-click it, it runs but first it opens Terminal.app and starts a session. I played with calling it from Applescript but without success. Can I make a bash file that doesn't start a terminal session?


with Ada.Calendar; use Ada.Calendar;
with Common; -- Contains "Beep".

procedure Run is
begin
    Delay 4.0;
    Common.Beep(1);
end Run;


Jerry

^ permalink raw reply	[relevance 6%]

* Re: GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise!
  2018-02-17 12:55  4% GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise! Bojan Bozovic
  2018-02-17 15:17  0% ` Bojan Bozovic
@ 2018-02-18  1:51  5% ` Bojan Bozovic
  1 sibling, 0 replies; 200+ results
From: Bojan Bozovic @ 2018-02-18  1:51 UTC (permalink / raw)


On Saturday, February 17, 2018 at 1:55:49 PM UTC+1, Bojan Bozovic wrote:
> -- code
> 
> with Ada.Calendar;
> with Ada.Text_IO;
> with Ada.Numerics.Real_Arrays;
> use Ada.Calendar;
> use Ada.Text_IO;
> use Ada.Numerics.Real_Arrays;
> 
> procedure Matrix_Mul is
> 
>    package F_IO is new Ada.Text_IO.Fixed_IO (Day_Duration);
>    use F_IO;
> 
>    Start_Time, End_Time : Time;
> 
>    procedure Put (X : Real_Matrix) is
>    begin
>       for I in X'Range (1) loop
>          for J in X'Range (2) loop
>             Put (Float'Image (Float (X (I, J))));
>          end loop;
>          New_Line;
>       end loop;
>    end Put;
> 
>    Matrix_A, Matrix_B, Result : Real_Matrix (1 .. 4, 1 .. 4);
>    Elapsed_Time               : Duration;
>    Sum                        : Float;
> begin
>    Matrix_A :=
>      ((1.0, 1.0, 1.0, 1.0),
>       (2.0, 2.0, 2.0, 2.0),
>       (3.0, 3.0, 3.0, 3.0),
>       (4.0, 4.0, 4.0, 4.0));
>    Matrix_B :=
>      ((16.0, 15.0, 14.0, 13.0),
>       (12.0, 11.0, 10.0, 9.0),
>       (8.0, 7.0, 6.0, 5.0),
>       (4.0, 3.0, 2.0, 1.0));
> 
>    Start_Time := Clock;
>    for Iteration in 1 .. 10_000_000 loop
>       Result := Matrix_A * Matrix_B;
>    end loop;
>    End_Time     := Clock;
>    Elapsed_Time := End_Time - Start_Time;
>    Put (Result);
>    New_Line;
>    Put ("Elapsed Time is ");
>    Put (Elapsed_Time);
>    New_Line;
>    Start_Time := Clock;
>    for Iteration in 1 .. 10_000_000 loop
>       for I in Matrix_A'Range (1) loop
>          for J in Matrix_A'Range (2) loop
>             Sum := 0.0;
>             for K in Matrix_A'Range (2) loop
>                Sum := Sum + Matrix_A (I, K) * Matrix_B (K, J);
>             end loop;
>             Result (I, J) := Sum;
>          end loop;
>       end loop;
>    end loop;
>    End_Time     := Clock;
>    Elapsed_Time := End_Time - Start_Time;
>    Put (Result);
>    New_Line;
>    Put ("Elapsed time is ");
>    Put (Elapsed_Time);
>    New_Line;
> end Matrix_Mul;
> -- end code
> 
> Results: FSF GNAT 7.2.0 x64
> C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -march=skylake matrix_mul.adb -largs -s
> gcc -c -O3 -fopt-info -march=skylake matrix_mul.adb
> matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:40:15: note: basic block vectorized
> matrix_mul.adb:42:26: note: basic block vectorized
> matrix_mul.adb:18:31: note: basic block vectorized
> matrix_mul.adb:49:9: note: basic block vectorized
> C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
> matrix_mul.adb:64:17: note: basic block vectorized
> matrix_mul.adb:18:31: note: basic block vectorized
> matrix_mul.adb:68:9: note: basic block vectorized
> C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
> gnatbind -x matrix_mul.ali
> gnatlink matrix_mul.ali -O3 -fopt-info -march=skylake -s
> 
> C:\Users\Bojan\Documents>matrix_mul
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed Time is      1.338206667
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed time is      0.000000445
> 
> C:\Users\Bojan\Documents>set path=C:\GNAT\2017\BIN;%path%
> 
> Results GPL GNAT/2017 from AdaCore.
> 
> C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -mavx2 matrix_mul.adb -largs -s
> gcc -c -O3 -fopt-info -mavx2 matrix_mul.adb
> matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:40:15: note: basic block vectorized
> matrix_mul.adb:68:9: note: basic block vectorized
> gnatbind -x matrix_mul.ali
> gnatlink matrix_mul.ali -O3 -fopt-info -mavx2 -s
> 
> C:\Users\Bojan\Documents>matrix_mul
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed Time is      2.145337334
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed time is      0.000000444
> 
> C:\Users\Bojan\Documents>gcc --version
> gcc (GCC) 6.3.1 20170510 (for GNAT GPL 2017 20170515)
> Copyright (C) 2016 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> See your AdaCore support agreement for details of warranty and support.
> If you do not have a current support agreement, then there is absolutely
> no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
> 
> Should I submit this as bug to AdaCore? My computer is Intel Core i3-6100U (Skylake AVX2). Please try to reproduce.

Apart from response that they don't offer support on GPL versions of compiler, I got no response. I hope this will be useful to someone.

with Ada.Calendar;
with Ada.Text_IO;
with Ada.Numerics.Real_Arrays;
use Ada.Calendar;
use Ada.Text_IO;
use Ada.Numerics.Real_Arrays;

procedure Matrix_Mul is

   package F_IO is new Ada.Text_IO.Fixed_IO (Day_Duration);
   use F_IO;

   Start_Time, End_Time : Time;
   
   procedure Put (X : Real_Matrix) is
   begin
      for I in X'Range (1) loop
         for J in X'Range (2) loop
            Put (Float'Image (Float (X (I, J))));
         end loop;
         New_Line;
      end loop;
   end Put;


   Matrix_A, Matrix_B, Result : Real_Matrix (1 .. 4, 1 .. 4);
   Elapsed_Time               : Duration;
   Sum                        : Float;
   pragma Volatile (Matrix_A);
   pragma Volatile (Matrix_B);
   pragma Volatile (Result);
   Iterations : constant := 10_000_000;
begin
   Matrix_A :=
     ((1.0, 1.0, 1.0, 1.0),
      (2.0, 2.0, 2.0, 2.0),
      (3.0, 3.0, 3.0, 3.0),
      (4.0, 4.0, 4.0, 4.0));
   Matrix_B :=
     ((16.0, 15.0, 14.0, 13.0),
      (12.0, 11.0, 10.0, 9.0),
      (8.0, 7.0, 6.0, 5.0),
      (4.0, 3.0, 2.0, 1.0));

   Start_Time := Clock;
   for Iteration in 1..Iterations loop
      Result := Matrix_A * Matrix_B;
	end loop;
   End_Time     := Clock;
   Elapsed_Time := End_Time - Start_Time;
   Put (Result);
   New_Line;
   Put ("Elapsed Time is ");
   Put (Elapsed_Time);
   New_Line;
   Start_Time := Clock;
   for Iteration in 1 .. Iterations loop
   
      for I in Matrix_A'Range (1) loop
         for J in Matrix_A'Range (2) loop
            Sum := 0.0;
            for K in Matrix_A'Range (2) loop
               Sum := Sum + Matrix_A (I, K) * Matrix_B (K, J);
            end loop;
            Result (I, J) := Sum;
         end loop;
      end loop;
end loop;
   End_Time     := Clock;
   Elapsed_Time := End_Time - Start_Time;
   Put (Result);
   New_Line;
   Put ("Elapsed time is ");
   Put (Elapsed_Time);
   New_Line;
end Matrix_Mul;

-- end code

C:\Users\Bojan\Documents>gnatmake -O3 -mavx2 matrix_mul -largs -s
gcc -c -O3 -mavx2 matrix_mul.adb
gnatbind -x matrix_mul.ali
gnatlink matrix_mul.ali -O3 -mavx2 -s

C:\Users\Bojan\Documents>matrix_mul
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed Time is      2.134868889
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed time is      0.337315111

This is from GNAT/2017 compiler with these switches above.

^ permalink raw reply	[relevance 5%]

* Re: GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise!
  2018-02-17 15:17  0% ` Bojan Bozovic
@ 2018-02-17 15:49  0%   ` Bojan Bozovic
  0 siblings, 0 replies; 200+ results
From: Bojan Bozovic @ 2018-02-17 15:49 UTC (permalink / raw)


On Saturday, February 17, 2018 at 4:17:41 PM UTC+1, Bojan Bozovic wrote:
> On Saturday, February 17, 2018 at 1:55:49 PM UTC+1, Bojan Bozovic wrote:
> > -- code
> > 
> > with Ada.Calendar;
> > with Ada.Text_IO;
> > with Ada.Numerics.Real_Arrays;
> > use Ada.Calendar;
> > use Ada.Text_IO;
> > use Ada.Numerics.Real_Arrays;
> > 
> > procedure Matrix_Mul is
> > 
> >    package F_IO is new Ada.Text_IO.Fixed_IO (Day_Duration);
> >    use F_IO;
> > 
> >    Start_Time, End_Time : Time;
> > 
> >    procedure Put (X : Real_Matrix) is
> >    begin
> >       for I in X'Range (1) loop
> >          for J in X'Range (2) loop
> >             Put (Float'Image (Float (X (I, J))));
> >          end loop;
> >          New_Line;
> >       end loop;
> >    end Put;
> > 
> >    Matrix_A, Matrix_B, Result : Real_Matrix (1 .. 4, 1 .. 4);
> >    Elapsed_Time               : Duration;
> >    Sum                        : Float;
> > begin
> >    Matrix_A :=
> >      ((1.0, 1.0, 1.0, 1.0),
> >       (2.0, 2.0, 2.0, 2.0),
> >       (3.0, 3.0, 3.0, 3.0),
> >       (4.0, 4.0, 4.0, 4.0));
> >    Matrix_B :=
> >      ((16.0, 15.0, 14.0, 13.0),
> >       (12.0, 11.0, 10.0, 9.0),
> >       (8.0, 7.0, 6.0, 5.0),
> >       (4.0, 3.0, 2.0, 1.0));
> > 
> >    Start_Time := Clock;
> >    for Iteration in 1 .. 10_000_000 loop
> >       Result := Matrix_A * Matrix_B;
> >    end loop;
> >    End_Time     := Clock;
> >    Elapsed_Time := End_Time - Start_Time;
> >    Put (Result);
> >    New_Line;
> >    Put ("Elapsed Time is ");
> >    Put (Elapsed_Time);
> >    New_Line;
> >    Start_Time := Clock;
> >    for Iteration in 1 .. 10_000_000 loop
> >       for I in Matrix_A'Range (1) loop
> >          for J in Matrix_A'Range (2) loop
> >             Sum := 0.0;
> >             for K in Matrix_A'Range (2) loop
> >                Sum := Sum + Matrix_A (I, K) * Matrix_B (K, J);
> >             end loop;
> >             Result (I, J) := Sum;
> >          end loop;
> >       end loop;
> >    end loop;
> >    End_Time     := Clock;
> >    Elapsed_Time := End_Time - Start_Time;
> >    Put (Result);
> >    New_Line;
> >    Put ("Elapsed time is ");
> >    Put (Elapsed_Time);
> >    New_Line;
> > end Matrix_Mul;
> > -- end code
> > 
> > Results: FSF GNAT 7.2.0 x64
> > C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -march=skylake matrix_mul.adb -largs -s
> > gcc -c -O3 -fopt-info -march=skylake matrix_mul.adb
> > matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
> > matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
> > matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
> > matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
> > matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
> > matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
> > matrix_mul.adb:40:15: note: basic block vectorized
> > matrix_mul.adb:42:26: note: basic block vectorized
> > matrix_mul.adb:18:31: note: basic block vectorized
> > matrix_mul.adb:49:9: note: basic block vectorized
> > C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
> > matrix_mul.adb:64:17: note: basic block vectorized
> > matrix_mul.adb:18:31: note: basic block vectorized
> > matrix_mul.adb:68:9: note: basic block vectorized
> > C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
> > gnatbind -x matrix_mul.ali
> > gnatlink matrix_mul.ali -O3 -fopt-info -march=skylake -s
> > 
> > C:\Users\Bojan\Documents>matrix_mul
> >  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
> >  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
> >  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
> >  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> > 
> > Elapsed Time is      1.338206667
> >  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
> >  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
> >  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
> >  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> > 
> > Elapsed time is      0.000000445
> > 
> > C:\Users\Bojan\Documents>set path=C:\GNAT\2017\BIN;%path%
> > 
> > Results GPL GNAT/2017 from AdaCore.
> > 
> > C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -mavx2 matrix_mul.adb -largs -s
> > gcc -c -O3 -fopt-info -mavx2 matrix_mul.adb
> > matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
> > matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
> > matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
> > matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
> > matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
> > matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
> > matrix_mul.adb:40:15: note: basic block vectorized
> > matrix_mul.adb:68:9: note: basic block vectorized
> > gnatbind -x matrix_mul.ali
> > gnatlink matrix_mul.ali -O3 -fopt-info -mavx2 -s
> > 
> > C:\Users\Bojan\Documents>matrix_mul
> >  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
> >  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
> >  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
> >  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> > 
> > Elapsed Time is      2.145337334
> >  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
> >  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
> >  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
> >  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> > 
> > Elapsed time is      0.000000444
> > 
> > C:\Users\Bojan\Documents>gcc --version
> > gcc (GCC) 6.3.1 20170510 (for GNAT GPL 2017 20170515)
> > Copyright (C) 2016 Free Software Foundation, Inc.
> > This is free software; see the source for copying conditions.
> > See your AdaCore support agreement for details of warranty and support.
> > If you do not have a current support agreement, then there is absolutely
> > no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> > PURPOSE.
> > 
> > Should I submit this as bug to AdaCore? My computer is Intel Core i3-6100U (Skylake AVX2). Please try to reproduce.
> 
> Compiler is smart enough to not iterate 10 million times over constant values, but there is still optimization problem.

I don't know how to use pragma Volatile to force  iterations, even though with no 10 million iterations but with single multiplication results are (from AdaCore GNAT/2017 GPL)

C:\Users\Bojan\Documents>matrix_mul
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed Time is      0.000009333
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed time is      0.000000889

I'm submitting this as bug to AdaCore.


^ permalink raw reply	[relevance 0%]

* Re: GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise!
  2018-02-17 12:55  4% GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise! Bojan Bozovic
@ 2018-02-17 15:17  0% ` Bojan Bozovic
  2018-02-17 15:49  0%   ` Bojan Bozovic
  2018-02-18  1:51  5% ` Bojan Bozovic
  1 sibling, 1 reply; 200+ results
From: Bojan Bozovic @ 2018-02-17 15:17 UTC (permalink / raw)


On Saturday, February 17, 2018 at 1:55:49 PM UTC+1, Bojan Bozovic wrote:
> -- code
> 
> with Ada.Calendar;
> with Ada.Text_IO;
> with Ada.Numerics.Real_Arrays;
> use Ada.Calendar;
> use Ada.Text_IO;
> use Ada.Numerics.Real_Arrays;
> 
> procedure Matrix_Mul is
> 
>    package F_IO is new Ada.Text_IO.Fixed_IO (Day_Duration);
>    use F_IO;
> 
>    Start_Time, End_Time : Time;
> 
>    procedure Put (X : Real_Matrix) is
>    begin
>       for I in X'Range (1) loop
>          for J in X'Range (2) loop
>             Put (Float'Image (Float (X (I, J))));
>          end loop;
>          New_Line;
>       end loop;
>    end Put;
> 
>    Matrix_A, Matrix_B, Result : Real_Matrix (1 .. 4, 1 .. 4);
>    Elapsed_Time               : Duration;
>    Sum                        : Float;
> begin
>    Matrix_A :=
>      ((1.0, 1.0, 1.0, 1.0),
>       (2.0, 2.0, 2.0, 2.0),
>       (3.0, 3.0, 3.0, 3.0),
>       (4.0, 4.0, 4.0, 4.0));
>    Matrix_B :=
>      ((16.0, 15.0, 14.0, 13.0),
>       (12.0, 11.0, 10.0, 9.0),
>       (8.0, 7.0, 6.0, 5.0),
>       (4.0, 3.0, 2.0, 1.0));
> 
>    Start_Time := Clock;
>    for Iteration in 1 .. 10_000_000 loop
>       Result := Matrix_A * Matrix_B;
>    end loop;
>    End_Time     := Clock;
>    Elapsed_Time := End_Time - Start_Time;
>    Put (Result);
>    New_Line;
>    Put ("Elapsed Time is ");
>    Put (Elapsed_Time);
>    New_Line;
>    Start_Time := Clock;
>    for Iteration in 1 .. 10_000_000 loop
>       for I in Matrix_A'Range (1) loop
>          for J in Matrix_A'Range (2) loop
>             Sum := 0.0;
>             for K in Matrix_A'Range (2) loop
>                Sum := Sum + Matrix_A (I, K) * Matrix_B (K, J);
>             end loop;
>             Result (I, J) := Sum;
>          end loop;
>       end loop;
>    end loop;
>    End_Time     := Clock;
>    Elapsed_Time := End_Time - Start_Time;
>    Put (Result);
>    New_Line;
>    Put ("Elapsed time is ");
>    Put (Elapsed_Time);
>    New_Line;
> end Matrix_Mul;
> -- end code
> 
> Results: FSF GNAT 7.2.0 x64
> C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -march=skylake matrix_mul.adb -largs -s
> gcc -c -O3 -fopt-info -march=skylake matrix_mul.adb
> matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:40:15: note: basic block vectorized
> matrix_mul.adb:42:26: note: basic block vectorized
> matrix_mul.adb:18:31: note: basic block vectorized
> matrix_mul.adb:49:9: note: basic block vectorized
> C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
> matrix_mul.adb:64:17: note: basic block vectorized
> matrix_mul.adb:18:31: note: basic block vectorized
> matrix_mul.adb:68:9: note: basic block vectorized
> C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
> gnatbind -x matrix_mul.ali
> gnatlink matrix_mul.ali -O3 -fopt-info -march=skylake -s
> 
> C:\Users\Bojan\Documents>matrix_mul
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed Time is      1.338206667
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed time is      0.000000445
> 
> C:\Users\Bojan\Documents>set path=C:\GNAT\2017\BIN;%path%
> 
> Results GPL GNAT/2017 from AdaCore.
> 
> C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -mavx2 matrix_mul.adb -largs -s
> gcc -c -O3 -fopt-info -mavx2 matrix_mul.adb
> matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
> matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
> matrix_mul.adb:40:15: note: basic block vectorized
> matrix_mul.adb:68:9: note: basic block vectorized
> gnatbind -x matrix_mul.ali
> gnatlink matrix_mul.ali -O3 -fopt-info -mavx2 -s
> 
> C:\Users\Bojan\Documents>matrix_mul
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed Time is      2.145337334
>  4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
>  8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
>  1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
>  1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02
> 
> Elapsed time is      0.000000444
> 
> C:\Users\Bojan\Documents>gcc --version
> gcc (GCC) 6.3.1 20170510 (for GNAT GPL 2017 20170515)
> Copyright (C) 2016 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.
> See your AdaCore support agreement for details of warranty and support.
> If you do not have a current support agreement, then there is absolutely
> no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
> PURPOSE.
> 
> Should I submit this as bug to AdaCore? My computer is Intel Core i3-6100U (Skylake AVX2). Please try to reproduce.

Compiler is smart enough to not iterate 10 million times over constant values, but there is still optimization problem.


^ permalink raw reply	[relevance 0%]

* GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise!
@ 2018-02-17 12:55  4% Bojan Bozovic
  2018-02-17 15:17  0% ` Bojan Bozovic
  2018-02-18  1:51  5% ` Bojan Bozovic
  0 siblings, 2 replies; 200+ results
From: Bojan Bozovic @ 2018-02-17 12:55 UTC (permalink / raw)


-- code

with Ada.Calendar;
with Ada.Text_IO;
with Ada.Numerics.Real_Arrays;
use Ada.Calendar;
use Ada.Text_IO;
use Ada.Numerics.Real_Arrays;

procedure Matrix_Mul is

   package F_IO is new Ada.Text_IO.Fixed_IO (Day_Duration);
   use F_IO;

   Start_Time, End_Time : Time;

   procedure Put (X : Real_Matrix) is
   begin
      for I in X'Range (1) loop
         for J in X'Range (2) loop
            Put (Float'Image (Float (X (I, J))));
         end loop;
         New_Line;
      end loop;
   end Put;

   Matrix_A, Matrix_B, Result : Real_Matrix (1 .. 4, 1 .. 4);
   Elapsed_Time               : Duration;
   Sum                        : Float;
begin
   Matrix_A :=
     ((1.0, 1.0, 1.0, 1.0),
      (2.0, 2.0, 2.0, 2.0),
      (3.0, 3.0, 3.0, 3.0),
      (4.0, 4.0, 4.0, 4.0));
   Matrix_B :=
     ((16.0, 15.0, 14.0, 13.0),
      (12.0, 11.0, 10.0, 9.0),
      (8.0, 7.0, 6.0, 5.0),
      (4.0, 3.0, 2.0, 1.0));

   Start_Time := Clock;
   for Iteration in 1 .. 10_000_000 loop
      Result := Matrix_A * Matrix_B;
   end loop;
   End_Time     := Clock;
   Elapsed_Time := End_Time - Start_Time;
   Put (Result);
   New_Line;
   Put ("Elapsed Time is ");
   Put (Elapsed_Time);
   New_Line;
   Start_Time := Clock;
   for Iteration in 1 .. 10_000_000 loop
      for I in Matrix_A'Range (1) loop
         for J in Matrix_A'Range (2) loop
            Sum := 0.0;
            for K in Matrix_A'Range (2) loop
               Sum := Sum + Matrix_A (I, K) * Matrix_B (K, J);
            end loop;
            Result (I, J) := Sum;
         end loop;
      end loop;
   end loop;
   End_Time     := Clock;
   Elapsed_Time := End_Time - Start_Time;
   Put (Result);
   New_Line;
   Put ("Elapsed time is ");
   Put (Elapsed_Time);
   New_Line;
end Matrix_Mul;
-- end code

Results: FSF GNAT 7.2.0 x64
C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -march=skylake matrix_mul.adb -largs -s
gcc -c -O3 -fopt-info -march=skylake matrix_mul.adb
matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
matrix_mul.adb:40:15: note: basic block vectorized
matrix_mul.adb:42:26: note: basic block vectorized
matrix_mul.adb:18:31: note: basic block vectorized
matrix_mul.adb:49:9: note: basic block vectorized
C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
matrix_mul.adb:64:17: note: basic block vectorized
matrix_mul.adb:18:31: note: basic block vectorized
matrix_mul.adb:68:9: note: basic block vectorized
C:/MSYS64/MINGW64/lib/gcc/x86_64-w64-mingw32/7.2.0/adainclude/a-tifiio.adb:706:10: note: basic block vectorized
gnatbind -x matrix_mul.ali
gnatlink matrix_mul.ali -O3 -fopt-info -march=skylake -s

C:\Users\Bojan\Documents>matrix_mul
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed Time is      1.338206667
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed time is      0.000000445

C:\Users\Bojan\Documents>set path=C:\GNAT\2017\BIN;%path%

Results GPL GNAT/2017 from AdaCore.

C:\Users\Bojan\Documents>gnatmake -O3 -fopt-info -mavx2 matrix_mul.adb -largs -s
gcc -c -O3 -fopt-info -mavx2 matrix_mul.adb
matrix_mul.adb:56:41: note: loop turned into non-loop; it never loops.
matrix_mul.adb:56:41: note: loop with 4 iterations completely unrolled
matrix_mul.adb:54:38: note: loop turned into non-loop; it never loops.
matrix_mul.adb:54:38: note: loop with 4 iterations completely unrolled
matrix_mul.adb:53:35: note: loop turned into non-loop; it never loops.
matrix_mul.adb:53:35: note: loop with 4 iterations completely unrolled
matrix_mul.adb:40:15: note: basic block vectorized
matrix_mul.adb:68:9: note: basic block vectorized
gnatbind -x matrix_mul.ali
gnatlink matrix_mul.ali -O3 -fopt-info -mavx2 -s

C:\Users\Bojan\Documents>matrix_mul
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed Time is      2.145337334
 4.00000E+01 3.60000E+01 3.20000E+01 2.80000E+01
 8.00000E+01 7.20000E+01 6.40000E+01 5.60000E+01
 1.20000E+02 1.08000E+02 9.60000E+01 8.40000E+01
 1.60000E+02 1.44000E+02 1.28000E+02 1.12000E+02

Elapsed time is      0.000000444

C:\Users\Bojan\Documents>gcc --version
gcc (GCC) 6.3.1 20170510 (for GNAT GPL 2017 20170515)
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
See your AdaCore support agreement for details of warranty and support.
If you do not have a current support agreement, then there is absolutely
no warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.

Should I submit this as bug to AdaCore? My computer is Intel Core i3-6100U (Skylake AVX2). Please try to reproduce.


^ permalink raw reply	[relevance 4%]

* Re: When to use Bounded_String?
  @ 2017-12-29  0:42  4%         ` Randy Brukardt
  0 siblings, 0 replies; 200+ results
From: Randy Brukardt @ 2017-12-29  0:42 UTC (permalink / raw)


"Mehdi Saada" <00120260a@gmail.com> wrote in message 
news:158d76ca-7061-400e-8077-222bd4e390d2@googlegroups.com...
> Why hasn't GNATCOLL become part of the standard, since it's made
> by Adacore (correct me if I'm wrong), is alleguedly so better than 
> Ada.Strings,
> and since GNAT is now the de-facto only fully-ceritified Ada 2012 compiler 
> ?

(1) Adacore has nothing (directly) to do with the Standard, other than 
financial support of ARG members.
(2) No one has volunteered to do the work of converting the packages into 
the form of Standard. This is a LOT of effort (and I know, having done that 
with what became Ada.Directories and Ada.Calendar.Arithmetic -- which 
started out life as Claw packages).
(3) Parts of GNATColl are very much dependent on GNAT, while the Standard 
remains independent of any particular implementation. (We don't want GNAT to 
be the only Ada 2012 compiler forever!)
(4) It's debatable if GNATColl is really better than Ada.Strings.
(5) In general, we've not wanted many different libraries in the Standard 
that do the same thing. If a replacement for Ada.Strings was to be adopted, 
it would have to provide much better functionality than the existing 
libraries, not just a small performance improvement.

                                        Randy.



^ permalink raw reply	[relevance 4%]

* Read-write mutex sometimes fails on deadlock
@ 2017-10-28 20:02  4% pascal.malaise
  0 siblings, 0 replies; 200+ results
From: pascal.malaise @ 2017-10-28 20:02 UTC (permalink / raw)


Hi,

[long post because it includes the full sources and output, sorry]

I have a package that implements several kinds of mutexes, including a
read-write mutex. Here is the full source (spec and body) with only the
read-write part.

mutexes.ads
-----------

private with Ada.Task_Identification;
-- Mutex (single and Read_Write) management
package Mutexes is

  -- Kind of mutex
  -- Read_Write allows several readers but one writer at a time.
  --  This implementation is fair but somewhat CPU-consuming because
  --  the arrival of a reader while writer(s) are waiting triggers a
  --  re-evaluation to let it pass if it has a higher (task) priority.
  -- Kind of requested access for a Read_Write mutex
  type Access_Kind is (Read, Write);

  -- Mutex object, free at creation
  type Mutex is tagged limited private;

  -- Get access to a mutex.
  -- With RW mutex (Read_Write), simultaneous read are possible,
  --  but there is only one writer at a time and no reader at that time.
  -- If delay is negative, wait until mutex is got,
  -- If delay is null, try and give up if not free,
  -- If delay is positive, try during the specified delay.
  -- Raises Already_Got if the current task if it has already got the RW mutex
  --  for write.
  -- Note that there is no check of "Read then Write" deadlock.
  Already_Got : exception;
  function Get (A_Mutex      : in out Mutex;
                Waiting_Time : in Duration;
                Kind         : in Access_Kind := Read) return Boolean;
  -- Get access to a mutex : infinite wait.
  procedure Get (A_Mutex      : in out Mutex;
                 Kind         : in Access_Kind := Read);
  function Get (A_Mutex : in out Mutex) return Boolean;


  -- Release access to a mutex.
  -- Raises Not_Owner if current task doesn't own the the RW mutex for write
  --  (no check when releasing RW mutex aquired for read).
  Not_Owner : exception;
  procedure Release (A_Mutex : in out Mutex);

  -- Is current task the "owner" (access got) of a simple mutex
  -- Is it the writer in case of a RW mutex
  function Is_Owner (A_Mutex : in Mutex) return Boolean;

private

  -- Read/write mutex
  -- We want to queue all requests (read and write) within the same queue
  --  to ensure fairness (avoid starvation).
  -- But the condition for read is "no writer" (not Writer)
  --  and for write it is "no writer and no reader"
  --  (not Writer and then Readers = 0)
  -- So the guard of the common queue is "no writer", but a writer may pass it
  --  while there are reader. In this case, we would like to requeue it in the
  --  same queue and in the beginning of it; note that "requeue" requeues at
  --  the end :-(. The artifact is to requeue the task, and all other
  --  tasks queueing after it as well, in an alternate queue (Swapping).
  -- Benefit: a new reader may enter while writer(s) are queueing, if its
  --  priority is better. Fairness ++.
  -- Drawback: each new reader while writer(s) are queueing triggers an open
  --  then a swap of the queues. Perfo --.

  -- So there are two queues
  type Queue_Range is mod 2;

  -- The read/write access lock and queues. No time.
  protected type Rw_Mutex_Protect is

    -- Gets the lock. Blocking.
    entry Mutex_Get (Kind : in Access_Kind);

    -- Releases the lock
    procedure Mutex_Release;

    -- Is current task write owner of the lock
    function Mutex_Owns return Boolean;
  private
    -- Number of readers
    Readers : Natural := 0;
    -- Writer identification
    Owner : Ada.Task_Identification.Task_Id;
    -- Numer of times it has got the write lock
    Writer : Natural := 0;

    -- Two queues, one is active at a time
    entry Queues (Queue_Range) (Kind : in Access_Kind);
    Current_Queue : Queue_Range := Queue_Range'First;
    -- The status of the queue:
    -- Swapping or not
    Swapping : Boolean := False;
    -- If not swapping, is the mutex open or not
    -- if swapping, will it be open or not
    Open : Boolean := True;

  end Rw_Mutex_Protect;

  -- The general purpose mutex
  type Mutex is tagged limited record
    Rw_Mutex : Rw_Mutex_Protect;
  end record;
end Mutexes;


mutexes.adb
-----------

with Ada.Text_Io;
package body Mutexes is

  use type Ada.Task_Identification.Task_Id;
  function Image (Id : in Ada.Task_Identification.Task_Id) return String
           renames Ada.Task_Identification.Image;

  Debug_Set : Boolean := False;
  Debug_On : Boolean := False;
  procedure Trace (Id : in Ada.Task_Identification.Task_Id;
                   Msg : in String) is
  begin
    if not Debug_Set then
      -- Initial setup
      Debug_Set := True;
      Debug_On := True;
    end if;
    if Debug_On then
      Ada.Text_Io.Put_Line (Msg & " " & Image (Id));
    end if;
  end Trace;

  -- The protected object which implements the read/write mutex
  protected body Rw_Mutex_Protect is

    -- Gets the lock. Blocking.
    -- Do not let a new request be inserted in the middle of a queue while
    -- we are swapping queues.
    entry Mutex_Get (Kind : in Access_Kind) when not Swapping is
    begin
      -- Are we already the writer
      if Writer /= 0 and then Mutex_Get'Caller = Owner then
        raise Already_Got;
      end if;

      -- Queue the request in the active queue
      Trace (Mutex_Get'Caller, "Read_Write get queueing");
      requeue Queues(Current_Queue) with abort;
    end Mutex_Get;

    -- Releases the lock. No Check of kind but the lock must have been
    -- got.
    procedure Mutex_Release is
    begin
      if Readers > 0 then
        -- There are readers, one of them is releasing the lock
        Readers := Readers - 1;
        if Readers = 0 then
          -- The last reader leaves, so the lock becomes available
          --  for writers
          Trace (Ada.Task_Identification.Current_Task, "Last reader releases");
          Open := True;
        else
          Trace (Ada.Task_Identification.Current_Task, "Reader releases");
        end if;
      elsif Writer /= 0
      and then Ada.Task_Identification.Current_Task = Owner then
        -- The writer is releasing the lock
        if Writer /= 1 then
          Writer := Writer - 1;
          return;
        end if;
        -- Really releasing
        Trace (Ada.Task_Identification.Current_Task, "Writer releases");
        Writer := 0;
        Open := True;
      else
        -- Called while no lock was got or not called by the writer
        raise Not_Owner;
      end if;
    end Mutex_Release;

    function Mutex_Owns return Boolean is
      (Writer /= 0 and then Ada.Task_Identification.Current_Task = Owner);

    -- Two queues, one active at a time
    -- Passes when swapping queues or else when open
    entry Queues (for Queue in Queue_Range) (Kind : in Access_Kind)
          when Queue = Current_Queue
          and then (Swapping or else Open) is
    begin
      if Swapping then
        -- Swapping queueing tasks from one queue to the other
        Trace (Queues'Caller, "Swapping");
        if Queues(Queue)'Count = 0 then
          -- This is the last task: end of swapping
          -- Open remains unchanged (maybe open by a release)
          Swapping := False;
          Current_Queue := Current_Queue + 1;
          Trace (Queues'Caller, "End swapping");
        end if;
        -- Requeue the task on the other queue
        requeue Queues(Queue + 1) with abort;
      else
        -- The queue is open: The lock is either free or allocated to reader(s)
        if Kind = Read then
          Trace (Queues'Caller, "Another reader");
          -- Read lock
          Readers := Readers + 1;
        else
          -- Write lock:
          -- If we are here, it means that the gate is open so no writer
          --  has already got the lock
          -- Either we get the lock (queue is closed until we release)
          -- or we queue (no currently queueing read can pass)
          -- so in both case, the queue is closed
          -- Note that a new request may re-open the queue and enter
          --  before us if it as a better prio
          Open := False;
          if Readers = 0 then
            -- No reader => we get the write lock
            Writer := 1;
            Owner := Queues'Caller;
            Trace (Queues'Caller, "Writer has got lock");
          else
            -- We have to wait until last reader releases the lock
            -- If we are alone, requeue ourself. Otherwise
            --  requeue in the alternate queue this task, then all the other
            --  queueing tasks, so we remain first (if same prios)
            Swapping := Queues(Queue)'Count > 0;
            if Swapping then
              Trace (Queues'Caller, "Start swapping");
              requeue Queues(Queue + 1) with abort;
            else
              Trace (Queues'Caller, "Writer waits for current reader");
              requeue Queues(Queue) with abort;
            end if;
          end if;
        end if;
      end if;
    end Queues;

  end Rw_Mutex_Protect;

  function Get (A_Mutex      : in out Mutex;
                Waiting_Time : in Duration;
                Kind         : in Access_Kind := Read) return Boolean is
    Result : Boolean;
  begin
    if Waiting_Time < 0.0 then
      -- Negative delay : unconditional waiting
      A_Mutex.Rw_Mutex.Mutex_Get (Kind);
      Result := True;
    else
      select
        A_Mutex.Rw_Mutex.Mutex_Get (Kind);
        Result := True;
      or
        delay Waiting_Time;
        Result := False;
      end select;
    end if;
    return Result;
  end Get;

  function Get (A_Mutex : in out Mutex) return Boolean is
    (Get (A_Mutex, -1.0, Read));

  -- Get a mutex : infinite wait
  procedure Get (A_Mutex      : in out Mutex;
                 Kind         : in Access_Kind := Read) is
    Dummy : Boolean;
  begin
    Dummy := Get (A_Mutex, -1.0, Kind);
  end Get;

  -- Release a mutex
  procedure Release (A_Mutex : in out Mutex) is
  begin
    -- Request releasing
    A_Mutex.Rw_Mutex.Mutex_Release;
  end Release;

  -- Does current task own the mutex (for write)
  function Is_Owner (A_Mutex : Mutex) return Boolean is
  begin
    return A_Mutex.Rw_Mutex.Mutex_Owns;
  end Is_Owner;

end Mutexes;



Finally, I have a test program of the read-write mutex, which creates 10 tasks,
each of them taking the mutex, for read or write, during some time. The tasks
randomly terminate, and when all of them are done then the test is OK.


t_read_write.adb
----------------
with Ada.Text_Io, Ada.Command_Line, Ada.Calendar, Ada.Task_Identification,
     Ada.Numerics.Float_Random;
with Gnat.Calendar;
with Mutexes;
-- Test Read-Write mutex
procedure T_Read_Write is
  pragma Priority(10);

  -- True if gnat, otherwise remove usage of Gnat.Calendar
  Has_Gnat : constant Boolean := True;

  -- The number of tasks
  subtype Range_Actor is Natural range 0 .. 10;
  Main_Index : constant Range_Actor := 0;
  subtype Range_Task is Positive range 1 .. Range_Actor'Last;

  -- Date of last output of a task
  Last_Time : Ada.Calendar.Time;
  use type Ada.Calendar.Time;
  -- Delay of inactivity
  Inactivity : constant Duration := 5.0;

  -- Random generator
  Gen : Ada.Numerics.Float_Random.Generator;
  function Random (Mini : in Integer := 0;
                   Maxi : in Integer := 1) return Integer is
    F : Float;
    Res : Integer;
  begin
    F := Float(Mini) + Ada.Numerics.Float_Random.Random(Gen)
                       * Float(Maxi - Mini);
    Res := Integer (F);
    while Res > Maxi and then Res > Mini loop
      Res := Res - 1;
    end loop;
    return Res;
  end Random;

  -- Image of a date 
  function Image (Date : Ada.Calendar.Time) return String is
    Year   : Ada.Calendar.Year_Number;
    Month  : Ada.Calendar.Month_Number;
    Day    : Ada.Calendar.Day_Number;

    Hour       : Gnat.Calendar.Hour_Number;
    Minute     : Gnat.Calendar.Minute_Number;
    Second     : Gnat.Calendar.Second_Number;
    Sub_Second : Gnat.Calendar.Second_Duration;
    function Img (D : Gnat.Calendar.Second_Duration) return String is
      S : constant String := D'Img;
    begin
      return S(3 .. S'Last);
    end Img;
    Dur    : Ada.Calendar.Day_Duration;
    function Img (N : Integer) return String is
      S : constant String := N'Img;
    begin
      if S'Last = 2 then
        -- " d", 1 digit => "0" & d
        return "0" & S(2);
      else
        -- " dd", d
        return S(2 .. S'Last);
      end if;
    end Img;
    
  begin
    if Has_Gnat then
      Gnat.Calendar.Split (Date, Year, Month, Day, Hour, Minute, Second,
                           Sub_Second);
      return Img (Year) & "-" & Img (Month) & "-" & Img (Day) & "T"
           & Img (Hour) & ":" & Img (Minute) & ":" & Img (Second)
           & Img (Sub_Second);

    else
      Ada.Calendar.Split (Date, Year, Month, Day, Dur);
      return Img (Year) & "/" & Img (Month) & "/" & Img (Day) & Dur'Img;
    end if;
  end Image;

  -- Put a task activity
  procedure Put_Line (Index : in Range_Actor; Msg : in String) is
  begin
    Last_Time := Ada.Calendar.Clock;
    declare
      Date : constant String := Image (Last_Time);
      Str : constant String
          := (if Index in Range_Task then Index'Img else "Main")
           & " " & Msg;
    begin
      Ada.Text_Io.Put_Line (Date & " " & Str);
    end;
  end Put_Line;
  Lock : access Mutexes.Mutex;

  -- The client tasks
  task type T is
   pragma Priority(10);
    entry Num (I : in Range_Task);
    entry Done;
  end T;

  function Image (D : Duration) return String is
    Str : constant String := D'Img;
  begin
    return Str (1 .. 4);
  end Image;

  task body T is
    Index : Range_Task;
    Dur : Duration;
    Kind : Mutexes.Access_Kind;
    subtype Str5 is String (1 .. 5);
    Kind_Strs : constant array (Mutexes.Access_Kind) of Str5 := (
      Mutexes.Read  => " Read",
      Mutexes.Write => "Write");
    Res : Boolean;
  begin
    -- Get name
    accept Num (I : in Range_Task) do
      Index := I;
    end Num;
    Put_Line (Index ,
      "Task started, id "
    & Ada.Task_Identification.Image (Ada.Task_Identification.Current_Task));
    -- Work until termination requested in Critical
    loop
      delay 0.01;
      -- Wait from -0.1 to 0.5
      Dur := Duration (Random (-1, 5)) / 10.0;
      -- 10% chances to write
      if Random (0, 9) = 0 then
        Kind := Mutexes.Write;
      else
        Kind := Mutexes.Read;
      end if;
      -- Get lock
      Put_Line (Index, "get " & Kind_Strs(Kind) & " " & Image(Dur));
      Res := Lock.Get (Dur, Kind);
      -- Trace result
      if Res then
        Put_Line (Index, "OK");
      else
        Put_Line (Index, "NOK");
      end if;

      if Res then
        -- Got it: Work (wait) from 0.1 to 0.5
        Put_Line (Index, "waiting");
        delay Duration (Random (1, 5)) / 10.0;
        Put_Line (Index, "waited");

        -- Release lock
        Put_Line (Index, "release");
        Lock.Release;
      end if;

      -- 10% chances to terminate
      exit when Random (0, 9) = 0;
    end loop;
    Put_Line (Index, "terminate");
    -- Ready to end
    accept Done;
  end T;

  Tasks : array (Range_Task) of T;
  Runs  : array (Range_Task) of Boolean;
  Nb_Run : Natural;

-- The main: activate and monitor the tasks
begin
  Lock := new Mutexes.Mutex;

  -- Randomize
  Ada.Numerics.Float_Random.Reset (Gen, 
    Integer (Ada.Calendar.Seconds (Ada.Calendar.Clock)));

  -- Give to each actor it's name
  Put_Line (Main_Index, "Starting");
  Nb_Run := 0;
  for I in Range_Task loop
    Tasks(I).Num (I);
    Runs(I) := True;
    Nb_Run := Nb_Run + 1;
  end loop;

  -- Wait until termination of all tasks
  Main: while Nb_Run /= 0 loop

    -- Try to terminate tasks: wait 1s altogether
    for I in Range_Task loop
      if Runs(I) then
        select
          Tasks(I).Done;
          Runs(I) := False;
          Nb_Run := Nb_Run - 1;
        or
          delay 1.0 / Duration(Nb_Run);
        end select;
      end if;
    end loop;

    -- Monitor activity
    if Ada.Calendar.Clock - Last_Time > Inactivity then
      -- Deadlock detected => abort tasks
      Put_Line (Main_Index, "Deadlock detected, aborting");
      Ada.Command_Line.Set_Exit_Status (1);
      for I in Range_Task loop
        if Runs(I) then
          abort Tasks(I);
          -- This will exit Main
          Nb_Run := Nb_Run - 1;
        end if;
      end loop;
    end if;
  end loop Main;

  Put_Line (Main_Index, "Done");

end T_Read_Write;


Most of the time it works, but from time to time (every 100 to 1000 iterations)
the test fails: the main detects a deadlock because of no output activity during
more than 5 secs, and exits on error.
You can test on Unix with the following scripts (launch "./Loop"):

trw
---
#!/bin/bash
./t_read_write >out 2>err

Loop
----
#!/bin/bash

# Loop until failure
res=0
let n=0+1
while [ $res -eq 0 ] ; do
  echo `date +"%Y-%m-%dT%H:%M:%S"`" Iteration "$n":"
  ./trw
  if [ $? -ne 0 ] ; then
    echo "Failed!"
    exit 1
  fi
  let n=$n+1
done



When everything is OK all the tasks terminate one after the other, but in case
of failure, here is the output:

2017-10-28T21:15:21.139556000 Main Starting
2017-10-28T21:15:21.139602000  1 Task started, id tasks(1)_0000000000E63F10
2017-10-28T21:15:21.139618000  2 Task started, id tasks(2)_0000000000E68040
2017-10-28T21:15:21.139644000  3 Task started, id tasks(3)_0000000000E6B650
2017-10-28T21:15:21.139662000  4 Task started, id tasks(4)_0000000000E6EC60
2017-10-28T21:15:21.139679000  5 Task started, id tasks(5)_0000000000E72270
2017-10-28T21:15:21.139695000  6 Task started, id tasks(6)_0000000000E75880
2017-10-28T21:15:21.139709000  7 Task started, id tasks(7)_0000000000E78E90
2017-10-28T21:15:21.139732000  8 Task started, id tasks(8)_0000000000E7C4A0
2017-10-28T21:15:21.139752000  9 Task started, id tasks(9)_0000000000E7FAB0
2017-10-28T21:15:21.139759000  10 Task started, id tasks(10)_0000000000E830C0
2017-10-28T21:15:21.149687000  1 get  Read  0.0
2017-10-28T21:15:21.149690000  3 get Write  0.1
2017-10-28T21:15:21.149700000  2 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
2017-10-28T21:15:21.149744000  5 get  Read  0.0
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:21.149782000  4 get Write  0.5
Read_Write get queueing tasks(3)_0000000000E6B650
Writer waits for current reader tasks(3)_0000000000E6B650
2017-10-28T21:15:21.149804000  8 get  Read  0.1
2017-10-28T21:15:21.149786000  1 OK
2017-10-28T21:15:21.149769000  6 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:21.149825000  9 get  Read  0.5
2017-10-28T21:15:21.149829000  2 NOK
Read_Write get queueing tasks(9)_0000000000E7FAB0
2017-10-28T21:15:21.149855000  10 get  Read  0.0
2017-10-28T21:15:21.149875000  7 get  Read  0.2
2017-10-28T21:15:21.149816000  1 waiting
Read_Write get queueing tasks(4)_0000000000E6EC60
Read_Write get queueing tasks(8)_0000000000E7C4A0
Read_Write get queueing tasks(6)_0000000000E75880
Read_Write get queueing tasks(5)_0000000000E72270
2017-10-28T21:15:21.149917000  6 NOK
2017-10-28T21:15:21.149926000  5 NOK
Read_Write get queueing tasks(10)_0000000000E830C0
Read_Write get queueing tasks(7)_0000000000E78E90
2017-10-28T21:15:21.149940000  10 NOK
2017-10-28T21:15:21.159909000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:21.159990000  5 get  Read  0.3
Read_Write get queueing tasks(5)_0000000000E72270
2017-10-28T21:15:21.160006000  10 get  Read  0.5
2017-10-28T21:15:21.159993000  6 get  Read  0.0
Read_Write get queueing tasks(6)_0000000000E75880
2017-10-28T21:15:21.160032000  6 NOK
Read_Write get queueing tasks(10)_0000000000E830C0
2017-10-28T21:15:21.170103000  6 get  Read  0.4
Read_Write get queueing tasks(6)_0000000000E75880
2017-10-28T21:15:21.249871000  3 NOK
2017-10-28T21:15:21.249967000  8 NOK
2017-10-28T21:15:21.259960000  2 NOK
2017-10-28T21:15:21.259964000  3 get  Read  0.1
Read_Write get queueing tasks(3)_0000000000E6B650
2017-10-28T21:15:21.260036000  8 get  Read -0.1
Read_Write get queueing tasks(8)_0000000000E7C4A0
2017-10-28T21:15:21.270048000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:21.270066000  2 NOK
2017-10-28T21:15:21.280139000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:21.349953000  1 waited
2017-10-28T21:15:21.349976000  1 release
Last reader releases tasks(1)_0000000000E63F10
Another reader tasks(9)_0000000000E7FAB0
Start swapping tasks(4)_0000000000E6EC60
Swapping tasks(7)_0000000000E78E90
2017-10-28T21:15:21.350007000  9 OK
2017-10-28T21:15:21.350051000  9 waiting
Swapping tasks(5)_0000000000E72270
2017-10-28T21:15:21.360060000  1 get  Read  0.0
Swapping tasks(10)_0000000000E830C0
Swapping tasks(6)_0000000000E75880
Swapping tasks(8)_0000000000E7C4A0
Swapping tasks(2)_0000000000E68040
End swapping tasks(2)_0000000000E68040
Read_Write get queueing tasks(1)_0000000000E63F10
2017-10-28T21:15:21.360109000  3 NOK
2017-10-28T21:15:21.360121000  1 NOK
2017-10-28T21:15:21.370195000  3 get  Read  0.3
Read_Write get queueing tasks(3)_0000000000E6B650
2017-10-28T21:15:21.370204000  1 get Write  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
2017-10-28T21:15:21.370242000  1 NOK
2017-10-28T21:15:21.380223000  2 NOK
2017-10-28T21:15:21.380324000  1 get  Read -0.1
Read_Write get queueing tasks(1)_0000000000E63F10
2017-10-28T21:15:21.390298000  2 get  Read  0.2
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:21.460071000  5 NOK
2017-10-28T21:15:21.470153000  5 get  Read  0.0
Read_Write get queueing tasks(5)_0000000000E72270
2017-10-28T21:15:21.470170000  5 NOK
2017-10-28T21:15:21.480242000  5 get  Read  0.1
Read_Write get queueing tasks(5)_0000000000E72270
2017-10-28T21:15:21.570194000  6 NOK
2017-10-28T21:15:21.580275000  6 get  Read  0.0
Read_Write get queueing tasks(6)_0000000000E75880
2017-10-28T21:15:21.580293000  6 NOK
2017-10-28T21:15:21.580321000  5 NOK
2017-10-28T21:15:21.590365000  2 NOK
2017-10-28T21:15:21.590374000  6 get  Read  0.4
Read_Write get queueing tasks(6)_0000000000E75880
2017-10-28T21:15:21.590401000  5 get  Read  0.2
Read_Write get queueing tasks(5)_0000000000E72270
2017-10-28T21:15:21.600438000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:21.649962000  4 NOK
2017-10-28T21:15:21.660056000  4 get  Read  0.2
Read_Write get queueing tasks(4)_0000000000E6EC60
2017-10-28T21:15:21.660107000  10 NOK
2017-10-28T21:15:21.670184000  10 get  Read  0.0
Read_Write get queueing tasks(10)_0000000000E830C0
2017-10-28T21:15:21.670203000  10 NOK
2017-10-28T21:15:21.670286000  3 NOK
2017-10-28T21:15:21.680277000  10 get  Read -0.1
Read_Write get queueing tasks(10)_0000000000E830C0
2017-10-28T21:15:21.680365000  3 get  Read  0.3
Read_Write get queueing tasks(3)_0000000000E6B650
2017-10-28T21:15:21.750125000  9 waited
2017-10-28T21:15:21.750140000  9 release
Last reader releases tasks(9)_0000000000E7FAB0
Another reader tasks(8)_0000000000E7C4A0
Another reader tasks(1)_0000000000E63F10
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:21.750191000  1 OK
2017-10-28T21:15:21.750202000  6 OK
Another reader tasks(5)_0000000000E72270
2017-10-28T21:15:21.750215000  6 waiting
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:21.750166000  8 OK
2017-10-28T21:15:21.750251000  5 OK
Another reader tasks(4)_0000000000E6EC60
2017-10-28T21:15:21.750264000  5 waiting
2017-10-28T21:15:21.750275000  4 OK
2017-10-28T21:15:21.750286000  2 OK
2017-10-28T21:15:21.750298000  2 waiting
Another reader tasks(10)_0000000000E830C0
2017-10-28T21:15:21.750287000  4 waiting
2017-10-28T21:15:21.750254000  8 waiting
Another reader tasks(3)_0000000000E6B650
2017-10-28T21:15:21.750353000  9 terminate
2017-10-28T21:15:21.750356000  3 OK
2017-10-28T21:15:21.750205000  1 waiting
2017-10-28T21:15:21.750381000  3 waiting
2017-10-28T21:15:21.750338000  10 OK
2017-10-28T21:15:21.750420000  10 waiting
2017-10-28T21:15:21.950478000  3 waited
2017-10-28T21:15:21.950503000  3 release
Reader releases tasks(3)_0000000000E6B650
2017-10-28T21:15:21.960583000  3 get  Read  0.0
Read_Write get queueing tasks(3)_0000000000E6B650
Another reader tasks(3)_0000000000E6B650
2017-10-28T21:15:21.960607000  3 OK
2017-10-28T21:15:21.960615000  3 waiting
2017-10-28T21:15:22.150289000  6 waited
2017-10-28T21:15:22.150308000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:22.150351000  5 waited
2017-10-28T21:15:22.150361000  5 release
Reader releases tasks(5)_0000000000E72270
2017-10-28T21:15:22.150377000  2 waited
2017-10-28T21:15:22.150386000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:22.150411000  4 waited
2017-10-28T21:15:22.150425000  4 release
Reader releases tasks(4)_0000000000E6EC60
2017-10-28T21:15:22.150444000  8 waited
2017-10-28T21:15:22.150453000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:22.150488000  10 waited
2017-10-28T21:15:22.150498000  10 release
Reader releases tasks(10)_0000000000E830C0
2017-10-28T21:15:22.160386000  5 get  Read  0.3
2017-10-28T21:15:22.160388000  6 get  Read  0.3
Read_Write get queueing tasks(5)_0000000000E72270
Another reader tasks(5)_0000000000E72270
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:22.160455000  2 get  Read  0.1
2017-10-28T21:15:22.160498000  4 get  Read  0.2
2017-10-28T21:15:22.160457000  6 OK
2017-10-28T21:15:22.160517000  6 waiting
Read_Write get queueing tasks(2)_0000000000E68040
2017-10-28T21:15:22.160433000  5 OK
2017-10-28T21:15:22.160542000  8 get  Read  0.0
2017-10-28T21:15:22.160547000  5 waiting
Another reader tasks(2)_0000000000E68040
Read_Write get queueing tasks(4)_0000000000E6EC60
Another reader tasks(4)_0000000000E6EC60
2017-10-28T21:15:22.160580000  2 OK
2017-10-28T21:15:22.160611000  4 OK
Read_Write get queueing tasks(8)_0000000000E7C4A0
2017-10-28T21:15:22.160578000  10 get  Read  0.4
2017-10-28T21:15:22.160624000  4 waiting
Another reader tasks(8)_0000000000E7C4A0
Read_Write get queueing tasks(10)_0000000000E830C0
Another reader tasks(10)_0000000000E830C0
2017-10-28T21:15:22.160615000  2 waiting
2017-10-28T21:15:22.160655000  8 OK
2017-10-28T21:15:22.160674000  10 OK
2017-10-28T21:15:22.160692000  8 waiting
2017-10-28T21:15:22.160702000  10 waiting
2017-10-28T21:15:22.250462000  1 waited
2017-10-28T21:15:22.250475000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:22.260551000  1 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:22.260571000  1 OK
2017-10-28T21:15:22.260579000  1 waiting
2017-10-28T21:15:22.260775000  10 waited
2017-10-28T21:15:22.260785000  10 release
Reader releases tasks(10)_0000000000E830C0
2017-10-28T21:15:22.270860000  10 get  Read -0.1
Read_Write get queueing tasks(10)_0000000000E830C0
Another reader tasks(10)_0000000000E830C0
2017-10-28T21:15:22.270879000  10 OK
2017-10-28T21:15:22.270887000  10 waiting
2017-10-28T21:15:22.360594000  6 waited
2017-10-28T21:15:22.360619000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:22.360646000  1 waited
2017-10-28T21:15:22.360658000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:22.360684000  4 waited
2017-10-28T21:15:22.360686000  3 waited
2017-10-28T21:15:22.360696000  4 release
Reader releases tasks(4)_0000000000E6EC60
2017-10-28T21:15:22.360706000  3 release
2017-10-28T21:15:22.360723000  4 terminate
Reader releases tasks(3)_0000000000E6B650
2017-10-28T21:15:22.360743000  2 waited
2017-10-28T21:15:22.360767000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:22.370699000  6 get  Read -0.1
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:22.370720000  6 OK
2017-10-28T21:15:22.370728000  6 waiting
2017-10-28T21:15:22.370735000  1 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:22.370754000  1 OK
2017-10-28T21:15:22.370762000  1 waiting
2017-10-28T21:15:22.370817000  3 get  Read  0.0
Read_Write get queueing tasks(3)_0000000000E6B650
Another reader tasks(3)_0000000000E6B650
2017-10-28T21:15:22.370835000  3 OK
2017-10-28T21:15:22.370838000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:22.370843000  3 waiting
2017-10-28T21:15:22.370866000  2 OK
2017-10-28T21:15:22.370882000  2 waiting
2017-10-28T21:15:22.460633000  5 waited
2017-10-28T21:15:22.460653000  5 release
Reader releases tasks(5)_0000000000E72270
2017-10-28T21:15:22.460667000  5 terminate
2017-10-28T21:15:22.560780000  8 waited
2017-10-28T21:15:22.560798000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:22.570880000  8 get  Read  0.3
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:22.570902000  8 OK
2017-10-28T21:15:22.570911000  8 waiting
2017-10-28T21:15:22.570949000  2 waited
2017-10-28T21:15:22.570959000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:22.581035000  2 get  Read  0.2
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:22.581054000  2 OK
2017-10-28T21:15:22.581062000  2 waiting
2017-10-28T21:15:22.670800000  6 waited
2017-10-28T21:15:22.670856000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:22.680902000  6 get  Read  0.2
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:22.680930000  6 OK
2017-10-28T21:15:22.680938000  6 waiting
2017-10-28T21:15:22.770837000  1 waited
2017-10-28T21:15:22.770857000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:22.770938000  3 waited
2017-10-28T21:15:22.770939000  10 waited
2017-10-28T21:15:22.770951000  3 release
Reader releases tasks(3)_0000000000E6B650
2017-10-28T21:15:22.770965000  10 release
Reader releases tasks(10)_0000000000E830C0
2017-10-28T21:15:22.780936000  1 get  Read  0.1
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:22.780975000  1 OK
2017-10-28T21:15:22.780983000  1 waiting
2017-10-28T21:15:22.781041000  3 get  Read  0.2
Read_Write get queueing tasks(3)_0000000000E6B650
Another reader tasks(3)_0000000000E6B650
2017-10-28T21:15:22.781059000  10 get  Read  0.0
Read_Write get queueing tasks(10)_0000000000E830C0
Another reader tasks(10)_0000000000E830C0
2017-10-28T21:15:22.781059000  3 OK
2017-10-28T21:15:22.781092000  10 OK
2017-10-28T21:15:22.781102000  3 waiting
2017-10-28T21:15:22.781112000  10 waiting
2017-10-28T21:15:22.881010000  6 waited
2017-10-28T21:15:22.881023000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:22.891099000  6 get  Read  0.4
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:22.891118000  6 OK
2017-10-28T21:15:22.891126000  6 waiting
2017-10-28T21:15:22.981185000  3 waited
2017-10-28T21:15:22.981200000  3 release
Reader releases tasks(3)_0000000000E6B650
2017-10-28T21:15:22.991277000  3 get  Read  0.3
Read_Write get queueing tasks(3)_0000000000E6B650
Another reader tasks(3)_0000000000E6B650
2017-10-28T21:15:22.991297000  3 OK
2017-10-28T21:15:22.991305000  3 waiting
2017-10-28T21:15:23.070985000  8 waited
2017-10-28T21:15:23.071001000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:23.081054000  1 waited
2017-10-28T21:15:23.081066000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:23.081078000  8 get  Read  0.4
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:23.081098000  8 OK
2017-10-28T21:15:23.081106000  8 waiting
2017-10-28T21:15:23.081130000  2 waited
2017-10-28T21:15:23.081139000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:23.091142000  1 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:23.091162000  1 OK
2017-10-28T21:15:23.091170000  1 waiting
2017-10-28T21:15:23.091220000  2 get  Read  0.2
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:23.091242000  2 OK
2017-10-28T21:15:23.091250000  2 waiting
2017-10-28T21:15:23.091369000  3 waited
2017-10-28T21:15:23.091379000  3 release
Reader releases tasks(3)_0000000000E6B650
2017-10-28T21:15:23.091391000  3 terminate
2017-10-28T21:15:23.181190000  10 waited
2017-10-28T21:15:23.181206000  10 release
Reader releases tasks(10)_0000000000E830C0
2017-10-28T21:15:23.191284000  10 get  Read  0.4
Read_Write get queueing tasks(10)_0000000000E830C0
Another reader tasks(10)_0000000000E830C0
2017-10-28T21:15:23.191304000  10 OK
2017-10-28T21:15:23.191312000  10 waiting
2017-10-28T21:15:23.291193000  6 waited
2017-10-28T21:15:23.291207000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:23.291316000  2 waited
2017-10-28T21:15:23.291329000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:23.301282000  6 get  Read  0.1
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:23.301302000  6 OK
2017-10-28T21:15:23.301310000  6 waiting
2017-10-28T21:15:23.301406000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:23.301442000  2 OK
2017-10-28T21:15:23.301450000  2 waiting
2017-10-28T21:15:23.381183000  8 waited
2017-10-28T21:15:23.381228000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:23.391314000  8 get  Read  0.2
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:23.391339000  8 OK
2017-10-28T21:15:23.391347000  8 waiting
2017-10-28T21:15:23.501526000  2 waited
2017-10-28T21:15:23.501556000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:23.511639000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:23.511663000  2 OK
2017-10-28T21:15:23.511671000  2 waiting
2017-10-28T21:15:23.591239000  1 waited
2017-10-28T21:15:23.591261000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:23.591417000  8 waited
2017-10-28T21:15:23.591432000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:23.601334000  1 get  Read  0.2
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:23.601356000  1 OK
2017-10-28T21:15:23.601365000  1 waiting
2017-10-28T21:15:23.601513000  8 get  Read  0.5
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:23.601535000  8 OK
2017-10-28T21:15:23.601544000  8 waiting
2017-10-28T21:15:23.691386000  10 waited
2017-10-28T21:15:23.691426000  10 release
Reader releases tasks(10)_0000000000E830C0
2017-10-28T21:15:23.701508000  10 get  Read -0.1
Read_Write get queueing tasks(10)_0000000000E830C0
Another reader tasks(10)_0000000000E830C0
2017-10-28T21:15:23.701530000  10 OK
2017-10-28T21:15:23.701538000  10 waiting
2017-10-28T21:15:23.801385000  6 waited
2017-10-28T21:15:23.801402000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:23.811480000  6 get  Read  0.3
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:23.811501000  6 OK
2017-10-28T21:15:23.811509000  6 waiting
2017-10-28T21:15:23.901439000  1 waited
2017-10-28T21:15:23.901452000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:23.901611000  10 waited
2017-10-28T21:15:23.901623000  10 release
Reader releases tasks(10)_0000000000E830C0
2017-10-28T21:15:23.901637000  10 terminate
2017-10-28T21:15:23.911529000  1 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:23.911553000  1 OK
2017-10-28T21:15:23.911561000  1 waiting
2017-10-28T21:15:23.911744000  2 waited
2017-10-28T21:15:23.911758000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:23.921835000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:23.921856000  2 OK
2017-10-28T21:15:23.921864000  2 waiting
2017-10-28T21:15:24.101621000  8 waited
2017-10-28T21:15:24.101640000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.111575000  6 waited
2017-10-28T21:15:24.111589000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:24.111717000  8 get  Read  0.3
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.111737000  8 OK
2017-10-28T21:15:24.111745000  8 waiting
2017-10-28T21:15:24.121665000  6 get  Read  0.2
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:24.121684000  6 OK
2017-10-28T21:15:24.121692000  6 waiting
2017-10-28T21:15:24.211634000  1 waited
2017-10-28T21:15:24.211658000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:24.221736000  6 waited
2017-10-28T21:15:24.221737000  1 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:24.221767000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:24.221793000  1 OK
2017-10-28T21:15:24.221834000  1 waiting
2017-10-28T21:15:24.221931000  2 waited
2017-10-28T21:15:24.221941000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:24.231875000  6 get  Read  0.1
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:24.231895000  6 OK
2017-10-28T21:15:24.231903000  6 waiting
2017-10-28T21:15:24.232011000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:24.232030000  2 OK
2017-10-28T21:15:24.232037000  2 waiting
2017-10-28T21:15:24.411815000  8 waited
2017-10-28T21:15:24.411839000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.421919000  8 get  Read -0.1
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.421940000  8 OK
2017-10-28T21:15:24.421948000  8 waiting
2017-10-28T21:15:24.431974000  6 waited
2017-10-28T21:15:24.431986000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:24.442064000  6 get  Read  0.3
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:24.442087000  6 OK
2017-10-28T21:15:24.442094000  6 waiting
2017-10-28T21:15:24.521907000  1 waited
2017-10-28T21:15:24.521922000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:24.531998000  1 get  Read  0.2
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:24.532018000  1 OK
2017-10-28T21:15:24.532026000  1 waiting
2017-10-28T21:15:24.532108000  2 waited
2017-10-28T21:15:24.532119000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:24.542201000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:24.542224000  2 OK
2017-10-28T21:15:24.542232000  2 waiting
2017-10-28T21:15:24.622024000  8 waited
2017-10-28T21:15:24.622040000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.632119000  8 get  Read  0.2
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.632139000  8 OK
2017-10-28T21:15:24.632147000  8 waiting
2017-10-28T21:15:24.832096000  1 waited
2017-10-28T21:15:24.832133000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:24.842170000  6 waited
2017-10-28T21:15:24.842188000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:24.842214000  1 get  Read -0.1
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:24.842235000  1 OK
2017-10-28T21:15:24.842243000  1 waiting
2017-10-28T21:15:24.852266000  6 get  Read  0.0
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:24.852287000  6 OK
2017-10-28T21:15:24.852295000  6 waiting
2017-10-28T21:15:24.932222000  8 waited
2017-10-28T21:15:24.932238000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.942304000  8 get  Read  0.5
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:24.942309000  2 waited
2017-10-28T21:15:24.942346000  8 OK
2017-10-28T21:15:24.942357000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:24.942367000  8 waiting
2017-10-28T21:15:24.952453000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:24.952480000  2 OK
2017-10-28T21:15:24.952488000  2 waiting
2017-10-28T21:15:25.052369000  6 waited
2017-10-28T21:15:25.052384000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:25.062461000  6 get  Read  0.4
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:25.062481000  6 OK
2017-10-28T21:15:25.062489000  6 waiting
2017-10-28T21:15:25.162556000  6 waited
2017-10-28T21:15:25.162575000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:25.172668000  6 get  Read -0.1
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:25.172689000  6 OK
2017-10-28T21:15:25.172697000  6 waiting
2017-10-28T21:15:25.242313000  1 waited
2017-10-28T21:15:25.242329000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:25.252407000  1 get  Read  0.0
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:25.252428000  1 OK
2017-10-28T21:15:25.252436000  1 waiting
2017-10-28T21:15:25.342454000  8 waited
2017-10-28T21:15:25.342491000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:25.352573000  8 get  Read  0.4
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:25.352594000  8 OK
2017-10-28T21:15:25.352602000  8 waiting
2017-10-28T21:15:25.452564000  2 waited
2017-10-28T21:15:25.452584000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:25.452672000  8 waited
2017-10-28T21:15:25.452686000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:25.462663000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:25.462683000  2 OK
2017-10-28T21:15:25.462691000  2 waiting
2017-10-28T21:15:25.462762000  8 get  Read  0.2
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:25.462781000  8 OK
2017-10-28T21:15:25.462789000  8 waiting
2017-10-28T21:15:25.572774000  6 waited
2017-10-28T21:15:25.572789000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:25.582868000  6 get  Read  0.1
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:25.582889000  6 OK
2017-10-28T21:15:25.582897000  6 waiting
2017-10-28T21:15:25.662860000  8 waited
2017-10-28T21:15:25.662894000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:25.672970000  8 get  Read  0.5
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:25.672993000  8 OK
2017-10-28T21:15:25.673001000  8 waiting
2017-10-28T21:15:25.752510000  1 waited
2017-10-28T21:15:25.752531000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:25.762609000  1 get  Read  0.3
Read_Write get queueing tasks(1)_0000000000E63F10
Another reader tasks(1)_0000000000E63F10
2017-10-28T21:15:25.762630000  1 OK
2017-10-28T21:15:25.762638000  1 waiting
2017-10-28T21:15:25.862708000  1 waited
2017-10-28T21:15:25.862720000  1 release
Reader releases tasks(1)_0000000000E63F10
2017-10-28T21:15:25.862732000  1 terminate
2017-10-28T21:15:25.862767000  2 waited
2017-10-28T21:15:25.862783000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:25.872861000  2 get  Read  0.2
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:25.872882000  2 OK
2017-10-28T21:15:25.872890000  2 waiting
2017-10-28T21:15:26.073070000  8 waited
2017-10-28T21:15:26.073087000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:26.082972000  6 waited
2017-10-28T21:15:26.082988000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:26.083163000  8 get  Read  0.2
Read_Write get queueing tasks(8)_0000000000E7C4A0
Another reader tasks(8)_0000000000E7C4A0
2017-10-28T21:15:26.083181000  8 OK
2017-10-28T21:15:26.083189000  8 waiting
2017-10-28T21:15:26.093071000  6 get  Read  0.3
Read_Write get queueing tasks(6)_0000000000E75880
Another reader tasks(6)_0000000000E75880
2017-10-28T21:15:26.093095000  6 OK
2017-10-28T21:15:26.093103000  6 waiting
2017-10-28T21:15:26.172971000  2 waited
2017-10-28T21:15:26.172987000  2 release
Reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:26.183059000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:26.183080000  2 OK
2017-10-28T21:15:26.183106000  2 waiting
2017-10-28T21:15:26.383260000  8 waited
2017-10-28T21:15:26.383286000  8 release
Reader releases tasks(8)_0000000000E7C4A0
2017-10-28T21:15:26.383301000  8 terminate
2017-10-28T21:15:26.393182000  6 waited
2017-10-28T21:15:26.393198000  6 release
Reader releases tasks(6)_0000000000E75880
2017-10-28T21:15:26.393212000  6 terminate
2017-10-28T21:15:26.483178000  2 waited
2017-10-28T21:15:26.483208000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:26.493292000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:26.493316000  2 OK
2017-10-28T21:15:26.493325000  2 waiting
2017-10-28T21:15:26.993401000  2 waited
2017-10-28T21:15:26.993437000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:27.003520000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:27.003542000  2 OK
2017-10-28T21:15:27.003550000  2 waiting
2017-10-28T21:15:27.203619000  2 waited
2017-10-28T21:15:27.203647000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:27.213722000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:27.213746000  2 OK
2017-10-28T21:15:27.213754000  2 waiting
2017-10-28T21:15:27.513830000  2 waited
2017-10-28T21:15:27.513855000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:27.523934000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:27.523956000  2 OK
2017-10-28T21:15:27.523964000  2 waiting
2017-10-28T21:15:27.624041000  2 waited
2017-10-28T21:15:27.624061000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:27.634138000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:27.634166000  2 OK
2017-10-28T21:15:27.634175000  2 waiting
2017-10-28T21:15:28.034250000  2 waited
2017-10-28T21:15:28.034286000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:28.044367000  2 get  Read  0.2
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:28.044390000  2 OK
2017-10-28T21:15:28.044398000  2 waiting
2017-10-28T21:15:28.144463000  2 waited
2017-10-28T21:15:28.144477000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:28.154554000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:28.154574000  2 OK
2017-10-28T21:15:28.154582000  2 waiting
2017-10-28T21:15:28.554654000  2 waited
2017-10-28T21:15:28.554694000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:28.564788000  2 get  Read  0.2
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:28.564809000  2 OK
2017-10-28T21:15:28.564817000  2 waiting
2017-10-28T21:15:28.964892000  2 waited
2017-10-28T21:15:28.964930000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:28.975011000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:28.975033000  2 OK
2017-10-28T21:15:28.975041000  2 waiting
2017-10-28T21:15:29.375116000  2 waited
2017-10-28T21:15:29.375152000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:29.385233000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:29.385256000  2 OK
2017-10-28T21:15:29.385264000  2 waiting
2017-10-28T21:15:29.585340000  2 waited
2017-10-28T21:15:29.585369000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:29.595450000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:29.595472000  2 OK
2017-10-28T21:15:29.595499000  2 waiting
2017-10-28T21:15:29.995580000  2 waited
2017-10-28T21:15:29.995616000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:30.005699000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:30.005720000  2 OK
2017-10-28T21:15:30.005728000  2 waiting
2017-10-28T21:15:30.405807000  2 waited
2017-10-28T21:15:30.405841000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:30.415924000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:30.415949000  2 OK
2017-10-28T21:15:30.415957000  2 waiting
2017-10-28T21:15:30.916029000  2 waited
2017-10-28T21:15:30.916066000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:30.926148000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:30.926170000  2 OK
2017-10-28T21:15:30.926178000  2 waiting
2017-10-28T21:15:31.026251000  2 waited
2017-10-28T21:15:31.026271000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:31.036349000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:31.036370000  2 OK
2017-10-28T21:15:31.036378000  2 waiting
2017-10-28T21:15:31.436457000  2 waited
2017-10-28T21:15:31.436496000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:31.446579000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:31.446603000  2 OK
2017-10-28T21:15:31.446611000  2 waiting
2017-10-28T21:15:31.746681000  2 waited
2017-10-28T21:15:31.746717000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:31.756798000  2 get  Read  0.5
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:31.756820000  2 OK
2017-10-28T21:15:31.756828000  2 waiting
2017-10-28T21:15:32.056900000  2 waited
2017-10-28T21:15:32.056916000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:32.066994000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:32.067014000  2 OK
2017-10-28T21:15:32.067022000  2 waiting
2017-10-28T21:15:32.167094000  2 waited
2017-10-28T21:15:32.167110000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:32.177187000  2 get Write  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Writer has got lock tasks(2)_0000000000E68040
2017-10-28T21:15:32.177207000  2 OK
2017-10-28T21:15:32.177214000  2 waiting
2017-10-28T21:15:32.477286000  2 waited
2017-10-28T21:15:32.477325000  2 release
Writer releases tasks(2)_0000000000E68040
2017-10-28T21:15:32.487402000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:32.487424000  2 OK
2017-10-28T21:15:32.487432000  2 waiting
2017-10-28T21:15:32.687509000  2 waited
2017-10-28T21:15:32.687547000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:32.697628000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:32.697651000  2 OK
2017-10-28T21:15:32.697659000  2 waiting
2017-10-28T21:15:32.897731000  2 waited
2017-10-28T21:15:32.897745000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:32.907822000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:32.907842000  2 OK
2017-10-28T21:15:32.907850000  2 waiting
2017-10-28T21:15:33.307919000  2 waited
2017-10-28T21:15:33.307952000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:33.318032000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:33.318071000  2 OK
2017-10-28T21:15:33.318080000  2 waiting
2017-10-28T21:15:33.718160000  2 waited
2017-10-28T21:15:33.718215000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:33.728307000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:33.728329000  2 OK
2017-10-28T21:15:33.728337000  2 waiting
2017-10-28T21:15:34.228412000  2 waited
2017-10-28T21:15:34.228445000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:34.238526000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:34.238548000  2 OK
2017-10-28T21:15:34.238556000  2 waiting
2017-10-28T21:15:34.538629000  2 waited
2017-10-28T21:15:34.538647000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:34.548728000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:34.548752000  2 OK
2017-10-28T21:15:34.548761000  2 waiting
2017-10-28T21:15:34.948840000  2 waited
2017-10-28T21:15:34.948878000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:34.958963000  2 get Write  0.2
Read_Write get queueing tasks(2)_0000000000E68040
Writer has got lock tasks(2)_0000000000E68040
2017-10-28T21:15:34.958987000  2 OK
2017-10-28T21:15:34.958995000  2 waiting
2017-10-28T21:15:35.259070000  2 waited
2017-10-28T21:15:35.259088000  2 release
Writer releases tasks(2)_0000000000E68040
2017-10-28T21:15:35.269165000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:35.269186000  2 OK
2017-10-28T21:15:35.269194000  2 waiting
2017-10-28T21:15:35.569274000  2 waited
2017-10-28T21:15:35.569311000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:35.579396000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:35.579420000  2 OK
2017-10-28T21:15:35.579428000  2 waiting
2017-10-28T21:15:35.879506000  2 waited
2017-10-28T21:15:35.879541000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:35.889623000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:35.889644000  2 OK
2017-10-28T21:15:35.889652000  2 waiting
2017-10-28T21:15:36.189721000  2 waited
2017-10-28T21:15:36.189744000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:36.199823000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:36.199844000  2 OK
2017-10-28T21:15:36.199852000  2 waiting
2017-10-28T21:15:36.599930000  2 waited
2017-10-28T21:15:36.599964000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:36.610050000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:36.610076000  2 OK
2017-10-28T21:15:36.610084000  2 waiting
2017-10-28T21:15:37.010162000  2 waited
2017-10-28T21:15:37.010200000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:37.020282000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:37.020305000  2 OK
2017-10-28T21:15:37.020313000  2 waiting
2017-10-28T21:15:37.420390000  2 waited
2017-10-28T21:15:37.420417000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:37.430498000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:37.430519000  2 OK
2017-10-28T21:15:37.430527000  2 waiting
2017-10-28T21:15:37.730596000  2 waited
2017-10-28T21:15:37.730633000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:37.740713000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:37.740754000  2 OK
2017-10-28T21:15:37.740762000  2 waiting
2017-10-28T21:15:38.140840000  2 waited
2017-10-28T21:15:38.140862000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:38.150942000  2 get  Read  0.5
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:38.150963000  2 OK
2017-10-28T21:15:38.150972000  2 waiting
2017-10-28T21:15:38.551046000  2 waited
2017-10-28T21:15:38.551084000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:38.561169000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:38.561193000  2 OK
2017-10-28T21:15:38.561201000  2 waiting
2017-10-28T21:15:38.761271000  2 waited
2017-10-28T21:15:38.761315000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:38.771407000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:38.771429000  2 OK
2017-10-28T21:15:38.771437000  2 waiting
2017-10-28T21:15:39.171511000  2 waited
2017-10-28T21:15:39.171539000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:39.181620000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:39.181645000  2 OK
2017-10-28T21:15:39.181653000  2 waiting
2017-10-28T21:15:39.381735000  2 waited
2017-10-28T21:15:39.381777000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:39.391859000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:39.391881000  2 OK
2017-10-28T21:15:39.391889000  2 waiting
2017-10-28T21:15:39.691968000  2 waited
2017-10-28T21:15:39.692008000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:39.702089000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:39.702111000  2 OK
2017-10-28T21:15:39.702119000  2 waiting
2017-10-28T21:15:40.002188000  2 waited
2017-10-28T21:15:40.002214000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:40.012293000  2 get Write  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Writer has got lock tasks(2)_0000000000E68040
2017-10-28T21:15:40.012314000  2 OK
2017-10-28T21:15:40.012322000  2 waiting
2017-10-28T21:15:40.412390000  2 waited
2017-10-28T21:15:40.412415000  2 release
Writer releases tasks(2)_0000000000E68040
2017-10-28T21:15:40.422496000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:40.422517000  2 OK
2017-10-28T21:15:40.422525000  2 waiting
2017-10-28T21:15:40.822601000  2 waited
2017-10-28T21:15:40.822637000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:40.832719000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:40.832741000  2 OK
2017-10-28T21:15:40.832749000  2 waiting
2017-10-28T21:15:41.132824000  2 waited
2017-10-28T21:15:41.132845000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:41.142924000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:41.142945000  2 OK
2017-10-28T21:15:41.142953000  2 waiting
2017-10-28T21:15:41.443034000  2 waited
2017-10-28T21:15:41.443077000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:41.453160000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:41.453184000  2 OK
2017-10-28T21:15:41.453192000  2 waiting
2017-10-28T21:15:41.753267000  2 waited
2017-10-28T21:15:41.753306000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:41.763387000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:41.763426000  2 OK
2017-10-28T21:15:41.763434000  2 waiting
2017-10-28T21:15:41.863510000  2 waited
2017-10-28T21:15:41.863525000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:41.873605000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:41.873629000  2 OK
2017-10-28T21:15:41.873637000  2 waiting
2017-10-28T21:15:42.273708000  2 waited
2017-10-28T21:15:42.273741000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:42.283819000  2 get  Read  0.3
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:42.283844000  2 OK
2017-10-28T21:15:42.283853000  2 waiting
2017-10-28T21:15:42.583929000  2 waited
2017-10-28T21:15:42.583954000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:42.594034000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:42.594056000  2 OK
2017-10-28T21:15:42.594065000  2 waiting
2017-10-28T21:15:42.794142000  2 waited
2017-10-28T21:15:42.794182000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:42.804264000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:42.804287000  2 OK
2017-10-28T21:15:42.804296000  2 waiting
2017-10-28T21:15:43.104374000  2 waited
2017-10-28T21:15:43.104400000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:43.114481000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:43.114504000  2 OK
2017-10-28T21:15:43.114513000  2 waiting
2017-10-28T21:15:43.314585000  2 waited
2017-10-28T21:15:43.314605000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:43.324684000  2 get  Read  0.0
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:43.324707000  2 OK
2017-10-28T21:15:43.324715000  2 waiting
2017-10-28T21:15:43.724984000  2 waited
2017-10-28T21:15:43.725023000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:43.735103000  2 get  Read -0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:43.735134000  2 OK
2017-10-28T21:15:43.735143000  2 waiting
2017-10-28T21:15:44.035217000  2 waited
2017-10-28T21:15:44.035255000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:44.045346000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:44.045369000  2 OK
2017-10-28T21:15:44.045377000  2 waiting
2017-10-28T21:15:44.245450000  2 waited
2017-10-28T21:15:44.245471000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:44.255551000  2 get  Read  0.5
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:44.255574000  2 OK
2017-10-28T21:15:44.255582000  2 waiting
2017-10-28T21:15:44.355662000  2 waited
2017-10-28T21:15:44.355703000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:44.365786000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:44.365812000  2 OK
2017-10-28T21:15:44.365821000  2 waiting
2017-10-28T21:15:44.565899000  2 waited
2017-10-28T21:15:44.565930000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:44.576016000  2 get  Read  0.1
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:44.576041000  2 OK
2017-10-28T21:15:44.576050000  2 waiting
2017-10-28T21:15:44.876120000  2 waited
2017-10-28T21:15:44.876158000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:44.886240000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:44.886281000  2 OK
2017-10-28T21:15:44.886290000  2 waiting
2017-10-28T21:15:45.186362000  2 waited
2017-10-28T21:15:45.186384000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:45.196462000  2 get  Read  0.4
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:45.196483000  2 OK
2017-10-28T21:15:45.196492000  2 waiting
2017-10-28T21:15:45.296562000  2 waited
2017-10-28T21:15:45.296585000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:45.306664000  2 get  Read  0.5
Read_Write get queueing tasks(2)_0000000000E68040
Another reader tasks(2)_0000000000E68040
2017-10-28T21:15:45.306685000  2 OK
2017-10-28T21:15:45.306693000  2 waiting
2017-10-28T21:15:45.706766000  2 waited
2017-10-28T21:15:45.706804000  2 release
Last reader releases tasks(2)_0000000000E68040
2017-10-28T21:15:45.706821000  2 terminate
2017-10-28T21:15:50.729534000 Main Deadlock detected, aborting
2017-10-28T21:15:50.729586000 Main Done

Task 7 did not terminate.
Last report of it was "21:15:21.149875000  7 get  Read  0.2"
At this time, 1 has got the lock for read, 3 is requesting it for write and
the other tasks are queueing for read or write (7 is queueing for read).
When 1 releases the lock: 017-10-28T21:15:21.349976000  1 release
the log of swapping shows that task 4, requesting for write, triggers the
swapping: Start swapping tasks(4)_0000000000E6EC60
At that time, all the queueing tasks are logged as being swapped except 7,
and task 7 seems to be blocked somewhere and is never activated.

Can you reproduce it? On Windows?
Is the bug in the test program, or in the mutex implementation, in Linux, or in Gnat?

Thanks

^ permalink raw reply	[relevance 4%]

* Re: Community Input for the Maintenance and Revision of the Ada Programming Language
  @ 2017-10-03  6:36  5%           ` G.B.
  0 siblings, 0 replies; 200+ results
From: G.B. @ 2017-10-03  6:36 UTC (permalink / raw)


On 03.10.17 05:30, reinert wrote:
> I noticed that my compiler did not like for example:
> 
>    t1 : time := clock + 10.0;
>    t2 : time := t1 + 20.0;
>    t3 : time range t1 + 10.0 .. t2 + 30.0;
> 
> 
> No room for syntactic sugar here? :-)

For a start, the compiler has no idea what "20.0" should
mean with regard to Time.

Sweets are available from the time unit sellers:
 From Ada.Calendar, you'll get ranges of Year_Number or
Day_Duration or ....
These will all be the result of calling functions that
take Time values and help the programmer to state his
idea of "20.0".
A chapter in Barnes's book shows how to add sugar.

There is more in the Ada.Real_Time store.


^ permalink raw reply	[relevance 5%]

* Re: Community Input for the Maintenance and Revision of the Ada Programming Language
  2017-10-02 10:06  6% ` reinert
@ 2017-10-02 14:56  0%   ` Dennis Lee Bieber
    1 sibling, 0 replies; 200+ results
From: Dennis Lee Bieber @ 2017-10-02 14:56 UTC (permalink / raw)



ONE: Your question has nothing to do with "Community Input ... Revision
..." You really should have started a new topic rather than making your
question a reply to an existing thread.

TWO: It would have helped if you provided a description of what you
expected vs what you got from the program -- instead making one recreate
your program to test (UGH -- GPS 2017 looks ugly compared to what I've used
for the last decade or so).

On Mon, 2 Oct 2017 03:06:43 -0700 (PDT), reinert <reinkor@gmail.com>
declaimed the following:

>Not a big issue, but why does not this function:
>
>    if t1 < Clock and Clock < t2 then ...
>
>Should it?
>

	That snippet seems to work fine.

>Example code below for testing.
>
>reinert
>
>with Text_IO;
>use  Text_IO;
>with Ada.Calendar;
>use Ada.Calendar;
>procedure test1i is
> t1,t2 : time;
>begin
> t1 := Clock + 10.0;
> t2 := Clock + 20.0;
>
>-- bla bla..
>
>--  if t1 < Clock and Clock < t2 then -- this function
>    if Clock in t1 .. t2 then         -- this dows *not* function

	Well -- GNAT 2017 reports "scalar type required for range", which seems
rather self-explanatory... t1, t2, and by association, the value returned
from Clock, are not "scalar" values.

	"Time" type is defined as "private" in the standard, so could be made
up of anything internally. The comparison operator "<" (and others) are
defined in the calendar package, so are available for use in the first form
of the "if" statement.

-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

^ permalink raw reply	[relevance 0%]

* Re: Community Input for the Maintenance and Revision of the Ada Programming Language
  @ 2017-10-02 10:06  6% ` reinert
  2017-10-02 14:56  0%   ` Dennis Lee Bieber
    0 siblings, 2 replies; 200+ results
From: reinert @ 2017-10-02 10:06 UTC (permalink / raw)


Not a big issue, but why does not this function:

    if t1 < Clock and Clock < t2 then ...

Should it?

Example code below for testing.

reinert

with Text_IO;
use  Text_IO;
with Ada.Calendar;
use Ada.Calendar;
procedure test1i is
 t1,t2 : time;
begin
 t1 := Clock + 10.0;
 t2 := Clock + 20.0;

-- bla bla..

--  if t1 < Clock and Clock < t2 then -- this function
    if Clock in t1 .. t2 then         -- this dows *not* function
       Put_Line(" Here A ");
    end if;
end test1i;


^ permalink raw reply	[relevance 6%]

* Re: NTP
  @ 2017-09-18  8:21  7%     ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2017-09-18  8:21 UTC (permalink / raw)


On 18/09/2017 09:54, Tarjei Jensen wrote:
> I'd just like to point out to the unwary that the time you get is GMT or UTC.

You mean that Ada.Calendar.Formatting.Time_Of with Time_Zone = 0 returns 
GMT and not UTC? And specifically that

    Ada.Calendar.Time_Of (...) /=
    Ada.Calendar.Formatting.Time_Of (..., Time_Zone => UTC_Time_Offset)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 7%]

* Re: NTP
  @ 2017-09-16  9:29  7% ` Dmitry A. Kazakov
    0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2017-09-16  9:29 UTC (permalink / raw)


On 2017-09-16 08:40, Anatoly Chernyshev wrote:

> Is there a way to get time via the Network Time Protocol in Ada? It
> doesn't look like AWS has it (or I've missed something).
> 
> Currently I'm getting around spawning the Cygwin "nc" command, but it hurts my feelings.

Do you mean send a single UDP request to an NTP server and convert the 
response to Ada time?

You can try this:
----------------------------------------------------------------------
with Ada.Text_IO;              use Ada.Text_IO;
with Ada.Calendar;             use Ada.Calendar;
with Ada.Calendar.Formatting;  use Ada.Calendar.Formatting;
with Ada.Exceptions;           use Ada.Exceptions;
with Ada.Streams;              use Ada.Streams;
with GNAT.Sockets;             use GNAT.Sockets;
with Interfaces;               use Interfaces;

procedure Test is

    function Get_NTP_Time
             (  Server  : String;
                Timeout : Timeval_Duration := 10.0
             )  return Time is
       NTP_Packet_Size : constant := 48;
          -- RFC 5905: Official NTP era begins at 1 Jan 1900. We cannot
          -- have it in Ada.Calendar.Time, so taking a later time. Note
          -- Time_Zone = 0 in order to have it UTC
       Era : constant Time := Time_Of (1999, 12, 31, Time_Zone => 0);
          -- RFC 5905: seconds since 1 Jan 1900 to 31 Dec 1999
       Era_Offset : constant := 3_155_587_200;

       Socket   : Socket_Type;
       Address  : Sock_Addr_Type;
       Seconds  : Unsigned_32;
       Fraction : Unsigned_32;
       Last     : Stream_Element_Offset;
       Data     : Stream_Element_Array (1..NTP_Packet_Size) :=
                     (  1  => 2#1110_0011#, -- LI, Version, Mode
                        2  => 0,            -- Stratum, or type of clock
                        3  => 0,            -- Polling Interval
                        4  => 16#EC#,       -- Peer Clock Precision
                        13 => 49,
                        14 => 16#4E#,
                        15 => 49,
                        16 => 52,
                        others => 0
                     );
    begin
       Address.Addr := Addresses (Get_Host_By_Name (Server), 1);
       Address.Port := 123; -- NTP port
       Create_Socket (Socket, Family_Inet, Socket_Datagram);
       Set_Socket_Option
       (  Socket,
          Socket_Level,
          (Receive_Timeout, Timeout)
       );
       Send_Socket (Socket, Data, Last, Address);
       Receive_Socket (Socket, Data, Last, Address);
       if Last /= Data'Last then
          Raise_Exception (Data_Error'Identity, "Mangled response");
       end if;
       Seconds := (  Unsigned_32 (Data (41)) * 2**24
                  +  Unsigned_32 (Data (42)) * 2**16
                  +  Unsigned_32 (Data (43)) * 2**8
                  +  Unsigned_32 (Data (44))
                  -  Era_OFfset
                  );
       Fraction := (  Unsigned_32 (Data (45)) * 2**24
                   +  Unsigned_32 (Data (46)) * 2**16
                   +  Unsigned_32 (Data (47)) * 2**8
                   +  Unsigned_32 (Data (48))
                   );
       return (  Era
              +  Duration (Seconds)
         --     +  Duration (Long_Float (Fraction) / 2.0**32)
              );
    end Get_NTP_Time;

    Stamp : Time;
begin
    Stamp := Get_NTP_Time ("time.nist.gov");
    Put_Line ("NTP time " & Image (Stamp));
exception
    when Error : others =>
       Put_Line ("Error: " & Exception_Information (Error));
end Test;
-------------------------------------------------------------------

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 7%]

* Ok to assume type Duration is for more than one day?
@ 2017-01-22 11:37  6% reinkor
  0 siblings, 0 replies; 200+ results
From: reinkor @ 2017-01-22 11:37 UTC (permalink / raw)


As I understand from my textbook, type Duration is guaranteed to cover the range -86_400 .. 86_400 (number of seconds for one day). Does this mean that I take a considerable risk if I assume "Duration" can represent more than one day?

The following program:

----------------------------------------------------------------
with Ada.Numerics.Generic_Elementary_Functions,Text_IO;
use Text_IO;
with Ada.Calendar; use Ada.Calendar;

procedure d1 is

   package Flt_Io is new Text_IO.Float_Io   (Float);
   package Int_Io is new Text_IO.Integer_Io (Integer);
   package E_F is new Ada.Numerics.Generic_Elementary_Functions (Float);
   use E_F,Flt_Io,Int_Io;

   d : Duration := Duration(3600*24*10);

begin

   Put(" Duration'Last : ");
   Put(Float(Duration'Last)/(3600.0*24.0*365.0),20,1,0);

end d1;
--------------------------------------------------------------

gives (gnat/debian and also Raspberry Pi (Raspbian)):

Duration'Last :                  292.5

(i.e. many years....).

reinert

^ permalink raw reply	[relevance 6%]

* Re: zLibAda vs ZipAda (which should I use, if any)?
  @ 2016-08-27 19:15  4%                           ` gautier_niouzes
  0 siblings, 0 replies; 200+ results
From: gautier_niouzes @ 2016-08-27 19:15 UTC (permalink / raw)


Le samedi 27 août 2016 18:31:30 UTC+2, Aurele a écrit :
> Hi Gautier, I think your GID packages will provide the services I need. Very well done by the way.  
> 
> Maybe you can save me some time and guide me on its use for my needs.  I've inserted some code below that show how I'll load the images from the zip file using Zip-Ada, I arrange the data (not shown), and then I need to call GID procedure to load as Handle.
> 
> Any comments or ideas? 
> 
> declare
> 
>   package ASU renames Ada.Strings.Unbounded;
> 
>   type Entry_ID is new Integer range -1..Integer'Last;
> 
>   type iEntry is record
>     Texture_ID : ZipFile.Entry_ID;
>     FullName   : Ada.Strings.Unbounded.Unbounded_String;
>     Directory  : Ada.Strings.Unbounded.Unbounded_String;
>     EntryName  : Ada.Strings.Unbounded.Unbounded_String;
>     Extension  : Ada.Strings.Unbounded.Unbounded_String;
>   end record;
>   type iEntryEntry_Ptr is access all ZipFile.iEntry;
> 
>   subtype iEntry_Array_Size is Entry_ID;
> 
>   type iEntry_Array is array ( iEntry_Array_Size range <> ) of aliased ZipFile.iEntry;
>   type iEntry_Array_Ptr is access all ZipFile.iEntry_Array;
> 
>   type Information is record
>     File_Location   : Ada.Strings.Unbounded.Unbounded_String;
>     File_Name       : Ada.Strings.Unbounded.Unbounded_String;
>     Total_Entries   : Natural;
>     Texture_Entries : Natural;
>     Data_Ptr        : ZipFile.iEntry_Array_Ptr;
>   end record;
>   type Information_Ptr is access all ZipFile.Information;
> 
>   Zip_File_Name         : constant String := "Textures.zip";
>   Zip_File_Entries      : iEntry_Array_Size;
> 
>   lpTexture_Array       : aliased iEntry_Array_Ptr;
>   lpTexture_Info        : aliased Information_Ptr
> 
>   Local_Index           : Entry_ID;
> 
>   ZipFileInfo           : Zip.Zip_Info;
>   FileType              : UnZip.Streams.Zipped_File_Type;
> 
> -----------------------------------------------------------------
> begin
> 
>   Zip.Load( ZipFileInfo, Zip_File_Name );
> 
>   Zip_File_Entries := iEntry_Array_Size( Zip.Entries( ZipFileInfo ) );
> 
>   lpTexture_Array  := new ZipFile.iEntry_Array( 1..Zip_File_Entries );
>   lpTexture_Info   := new ZipFile.Information;
> 
>   -- Scan procedure not shown here but is straight forward...
>   Scan( ZipFileInfo, FileName, Info_Ptr ); -- FILL INFO_PTR
> 
>   -- Simple test....  try to retrieve an image at index = 10
> 
>   Local_Index := 10; -- TEST: image at index = 10
> 
>   UnZip.Streams.Open
>     ( File         => FileType,
>       Archive_Info => ZipFileInfo,
>       Name  => ASU.To_String( Info_Ptr.Data_Ptr( Local_Index ).FullName ) 
>      );
> 
>   -- ???????????????????????????????????????????????????????
>   -- LoadImage is below, no idea yet what has to be done
> 
>   LoadImage( FileNeme => Info_Ptr.Data_Ptr( Local_Index ).EntryName,
>              FileExt  => Info_Ptr.Data_Ptr( Local_Index ).Extension,
>              FullName => Ada.Streams.Stream_IO.Stream_Access( UnZip.Streams.Stream( FileType ) ) );
> 
>   UnZip.Streams.Close( FileType );
> 
> end;
> 
> 
> -----------------------------------------------------------------
> - TBD: Call "GID" procedure to load image (DIB or BMP (bitmap))
> 
> type Hande is access all System.Address;  
> hBitmap : Hande := NULL;
> 
> procedure LoadImage ( FileName : Ada.Strings.Unbounded.Unbounded_String;
>                       FileExt  : Ada.Strings.Unbounded.Unbounded_String;
>                       FullName : Ada.Strings.Unbounded.Unbounded_String ) is
> begin
>                    -- --------------------------
>   hBitmap := ?;    -- Call GID directly here ??? Steps ????
>                    -----------------------------
> end LoadImage;
> 
> -----------------------------------------------------------------
> 
> Cheers and thanks
> Aurele

I'm just copy-pasting useful things from the To_BMP example, which will be ok for a Windows bitmap. I skip the image rotation stuff to simplify...

  type Byte_Array is array(Integer range <>) of Unsigned_8;
  type p_Byte_Array is access Byte_Array;
  procedure Dispose is new Ada.Unchecked_Deallocation(Byte_Array, p_Byte_Array);

  img_buf: p_Byte_Array:= null;

  procedure Load_raw_image(
    image : in out GID.Image_descriptor;
    buffer: in out p_Byte_Array
  )
  is
    subtype Primary_color_range is Unsigned_8;
    subtype U16 is Unsigned_16;
    image_width: constant Positive:= GID.Pixel_width(image);
    image_height: constant Positive:= GID.Pixel_height(image);
    padded_line_size_x: constant Positive:=
      4 * Integer(Float'Ceiling(Float(image_width) * 3.0 / 4.0));
    padded_line_size_y: constant Positive:=
      4 * Integer(Float'Ceiling(Float(image_height) * 3.0 / 4.0));
    -- (in bytes)
    idx: Integer;
    --
    procedure Set_X_Y (x, y: Natural) is
    pragma Inline(Set_X_Y);
    begin
      idx:= 3 * x + padded_line_size_x * y;
    end Set_X_Y;
    --
    procedure Put_Pixel_without_bkg (
      red, green, blue : Primary_color_range;
      alpha            : Primary_color_range
    )
    is
    pragma Inline(Put_Pixel_without_bkg);
    pragma Warnings(off, alpha); -- alpha is just ignored
    begin
      buffer(idx..idx+2):= (blue, green, red);
      -- GID requires us to look to next pixel for next time:
      idx:= idx + 3;
    end Put_Pixel_without_bkg;
    --
    procedure BMP24_Load_without_bkg is
      new GID.Load_image_contents(
        Primary_color_range,
        Set_X_Y,
        Put_Pixel_without_bkg,
        Feedback,
        GID.fast
      );
    next_frame: Ada.Calendar.Day_Duration;
  begin
    Dispose(buffer);
    buffer:= new Byte_Array(0..padded_line_size_x * GID.Pixel_height(image) - 1);
    BMP24_Load_without_bkg(image, next_frame);
  end Load_raw_image;

...
    i: GID.Image_descriptor;
  begin
    GID.Load_image_header(i, Your_nice_stream_Access.all, True);
    Load_raw_image(i, img_buf);
  end;

Now you surely know better how to let the image buffer (img_buf) meet the hBitmap handle (some Windows-ish bureaucracy ;-) )
_________________________ 
Gautier's Ada programming 
http://gautiersblog.blogspot.com/search/label/Ada 
NB: follow the above link for a valid e-mail address 

^ permalink raw reply	[relevance 4%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-19 15:30  6%       ` Stephen Leake
@ 2016-08-19 17:43  4%         ` G.B.
  0 siblings, 0 replies; 200+ results
From: G.B. @ 2016-08-19 17:43 UTC (permalink / raw)


On 19.08.16 17:30, Stephen Leake wrote:
> On Thursday, August 18, 2016 at 1:13:40 PM UTC-5, Stephen Leake wrote:
>> On Thursday, August 18, 2016 at 12:45:11 PM UTC-5, Stephen Leake wrote:
>>> On Thursday, August 18, 2016 at 6:19:45 AM UTC-5, G.B. wrote:
>>>> On 17.08.16 23:05, Stephen Leake wrote:
>>>>> One solution would be to replace the "DATETIME" field type in the .sql file with "TEXT", always pass strings for times, and rely on lexicographic sorting for time comparison. But that seems extreme.
>>>>
>>>> It seems advisable to use SQLite's Date And Time Functions
>>>> when using SQLite for SQL. Thus,
>>>>
>>>>     " ... WHERE Modified >= datetime(?) ... "
>>>>
>>>
>>> Yes, that works.
>>
>> I take it back; it fixed most of the problems in the full program, but not all.
>>
>> So I'm switching to CHAR[19] for date/time fields.
>
> Which _also_ did not fix the problem. Which makes sense, given that SQL apparently uses TEXT for DATETIME.
>
> So I wrote code to substitute the time string for the ?, and pass a single string to SQLite3 with no bound parameters; that fixed the problem.
>
> There is apparently a problem with bound string parameters and >= in queries. Bound parameters with = INTEGER or LIKE %STRING work (so far, anyway).

TTBOMK, DATETIME, as opposed to TIMESTAMP, is not really present
in standard SQL (1999). DATE and TIME are. However, DATETIME and its
variations are offered by many DBMS products. There are hints at
varying ranges, though. Also, literals of DATETIME may differ.
Found these, for example, for two rather popular ones:

from: 1753-01-01 00:00:00.000	to: 31.12.9999 23:59:59.997
from: 1000-01-01 00:00:00	to: 9999-12-31 23:59:59

And for some version of Oracle, the docs say:
   "Dates between January 1, 4712 B.C. and December 31, 9999 A.D.,
    and times in hours, minutes and seconds."
DATE literals will depend on NLS settings.

For TIMESTAMP and TIME, timezones may enter the picture, as in
TIMESTAMP [WITH TIME ZONE]. Handling zones may depend on the DBMS
or even on SQL session settings, and is therefore not easy to
predict from just looking at SQL queries.

So, if portability or QoI are an issue, Randy Brukardt's suggestion
to use standard Ada conversions, to and from text, looks simple and
safe to me.

In the past, I had successfully used a combination of
DATE and TIME fields, not needing the fractions of TIMESTAMP.
The programs would be using UTC when storing points in time.
This worked reasonably well, since it didn't need complicated
comparisons of points in time. (In fact, when some results need
grouping by day, the split was a logical advantage.)


^ permalink raw reply	[relevance 4%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 18:13  6%     ` Stephen Leake
@ 2016-08-19 15:30  6%       ` Stephen Leake
  2016-08-19 17:43  4%         ` G.B.
  0 siblings, 1 reply; 200+ results
From: Stephen Leake @ 2016-08-19 15:30 UTC (permalink / raw)


On Thursday, August 18, 2016 at 1:13:40 PM UTC-5, Stephen Leake wrote:
> On Thursday, August 18, 2016 at 12:45:11 PM UTC-5, Stephen Leake wrote:
> > On Thursday, August 18, 2016 at 6:19:45 AM UTC-5, G.B. wrote:
> > > On 17.08.16 23:05, Stephen Leake wrote:
> > > > One solution would be to replace the "DATETIME" field type in the .sql file with "TEXT", always pass strings for times, and rely on lexicographic sorting for time comparison. But that seems extreme.
> > > 
> > > It seems advisable to use SQLite's Date And Time Functions
> > > when using SQLite for SQL. Thus,
> > > 
> > >     " ... WHERE Modified >= datetime(?) ... "
> > > 
> > 
> > Yes, that works. 
> 
> I take it back; it fixed most of the problems in the full program, but not all.
> 
> So I'm switching to CHAR[19] for date/time fields.

Which _also_ did not fix the problem. Which makes sense, given that SQL apparently uses TEXT for DATETIME.

So I wrote code to substitute the time string for the ?, and pass a single string to SQLite3 with no bound parameters; that fixed the problem.

There is apparently a problem with bound string parameters and >= in queries. Bound parameters with = INTEGER or LIKE %STRING work (so far, anyway).

-- Stephe


^ permalink raw reply	[relevance 6%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 19:48  6%       ` Dmitry A. Kazakov
  2016-08-18 20:50  5%         ` Jeffrey R. Carter
@ 2016-08-18 22:05 10%         ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Randy Brukardt @ 2016-08-18 22:05 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:np53eg$1o71$1@gioia.aioe.org...
...
> When storing timestamps into SQLite3 it is better to use TEXT and some 
> custom time/string conversion that would guarantee proper ordering and 
> precision.

For many purposes, the ISO-standard format used by Ada.Calendar.Formatting 
is sufficient; the package includes conversions both ways. The ISO format 
has a fixed size (so it works well with Ada strings), and it is formatted 
such that normal string comparisons give an appropriate ordering.

The only reasons to use a custom format would be if one needed to use a 
shorter format for some reason, or if one needs more precision than 1/100 
seconds. Otherwise, sticking with the standard format allows using 
language-defined routines available on all Ada 2005 and later compilers 
(*much* less chance of making a conversion mistake).

                             Randy.


^ permalink raw reply	[relevance 10%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 19:48  6%       ` Dmitry A. Kazakov
@ 2016-08-18 20:50  5%         ` Jeffrey R. Carter
  2016-08-18 22:05 10%         ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Jeffrey R. Carter @ 2016-08-18 20:50 UTC (permalink / raw)


On 08/18/2016 12:48 PM, Dmitry A. Kazakov wrote:
> 
> No, SQLite3 uses NUMERIC which is INTEGER or REAL at SQLite's choice when the
> conversion is reversible. Otherwise it is up to 15 decimal points of precision
> which is not enough for 64-bit time stamps.

The on-line SQLite documentation (https://www.sqlite.org/datatype3.html) says of
NUMERIC (section 3), "If the lossless conversion of TEXT to INTEGER or REAL is
not possible then the value is stored using the TEXT storage class." So storage
as TEXT is a possibility. The discussion of date and time fields (2.2) says,
"SQLite does not have a storage class set aside for storing dates and/or times.
Instead, the built-in Date And Time Functions of SQLite are capable of storing
dates and times as TEXT, REAL, or INTEGER values:" and goes on to discuss
strings in ISO8601 format stored as TEXT, Julian days as REAL, and Unix times as
INTEGER.

-- 
Jeff Carter
"Why don't you bore a hole in yourself and let the sap run out?"
Horse Feathers
49


^ permalink raw reply	[relevance 5%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 18:28 12%     ` Jeffrey R. Carter
@ 2016-08-18 19:48  6%       ` Dmitry A. Kazakov
  2016-08-18 20:50  5%         ` Jeffrey R. Carter
  2016-08-18 22:05 10%         ` Randy Brukardt
  0 siblings, 2 replies; 200+ results
From: Dmitry A. Kazakov @ 2016-08-18 19:48 UTC (permalink / raw)


On 2016-08-18 20:28, Jeffrey R. Carter wrote:

> I would guess that, since you used strings to insert the datetime values, SQLite
> is using TEXT representation for them.

No, SQLite3 uses NUMERIC which is INTEGER or REAL at SQLite's choice 
when the conversion is reversible. Otherwise it is up to 15 decimal 
points of precision which is not enough for 64-bit time stamps.

When storing timestamps into SQLite3 it is better to use TEXT and some 
custom time/string conversion that would guarantee proper ordering and 
precision.

> Also that "+" applied to an
> Ada.Calendar.Time is producing a non-string result (numeric?) and SQLite has
> problems dealing with the combination. Or something.

That depends on how GNATCOLL treats bound parameters. I am not familiar 
with it.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 6%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 17:45  5%   ` Stephen Leake
  2016-08-18 18:13  6%     ` Stephen Leake
@ 2016-08-18 18:28 12%     ` Jeffrey R. Carter
  2016-08-18 19:48  6%       ` Dmitry A. Kazakov
  1 sibling, 1 reply; 200+ results
From: Jeffrey R. Carter @ 2016-08-18 18:28 UTC (permalink / raw)


On 08/18/2016 10:45 AM, Stephen Leake wrote:
> 
> Yes, that works. Although I'm not clear why; 
> https://www.sqlite.org/lang_datefunc.html defines that function to return a string, and the examples are about output formatting. Apparently it has a different meaning when processing bound parameters.

I know nothing about SQLite or how GNATColl accesses it, but ...

Clearly, the query produced using a bare '?' and "+" applied to an
Ada.Calendar.Time is different from the query produced using a bare '?' and "+"
applied to a string [with contents in the correct format]. The query produced
using "datetime(?)" and "+" applied to an Ada.Calendar.Time is equivalent to the
query produced using a bare '?' and "+" applied to a string. Presumably, the
result of "+" applied to an Ada.Calendar.Time is different from "+" applied to a
string, but passing the former to datetime corrects it.

I would guess that, since you used strings to insert the datetime values, SQLite
is using TEXT representation for them. Also that "+" applied to an
Ada.Calendar.Time is producing a non-string result (numeric?) and SQLite has
problems dealing with the combination. Or something.

Personally, I'd want to compare the results of the two "+" calls (which might
require some cheating). I'd also want to see the resulting SQL statements from
substituting them for the '?'. One could then feed those SQL statements directly
into SQLite to see if the problem is in GNATColl or SQLite.

-- 
Jeff Carter
"Why don't you bore a hole in yourself and let the sap run out?"
Horse Feathers
49

^ permalink raw reply	[relevance 12%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 17:45  5%   ` Stephen Leake
@ 2016-08-18 18:13  6%     ` Stephen Leake
  2016-08-19 15:30  6%       ` Stephen Leake
  2016-08-18 18:28 12%     ` Jeffrey R. Carter
  1 sibling, 1 reply; 200+ results
From: Stephen Leake @ 2016-08-18 18:13 UTC (permalink / raw)


On Thursday, August 18, 2016 at 12:45:11 PM UTC-5, Stephen Leake wrote:
> On Thursday, August 18, 2016 at 6:19:45 AM UTC-5, G.B. wrote:
> > On 17.08.16 23:05, Stephen Leake wrote:
> > > One solution would be to replace the "DATETIME" field type in the .sql file with "TEXT", always pass strings for times, and rely on lexicographic sorting for time comparison. But that seems extreme.
> > 
> > It seems advisable to use SQLite's Date And Time Functions
> > when using SQLite for SQL. Thus,
> > 
> >     " ... WHERE Modified >= datetime(?) ... "
> > 
> 
> Yes, that works. 

I take it back; it fixed most of the problems in the full program, but not all.

So I'm switching to CHAR[19] for date/time fields.

-- Stephe


^ permalink raw reply	[relevance 6%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-18 11:19  5% ` G.B.
@ 2016-08-18 17:45  5%   ` Stephen Leake
  2016-08-18 18:13  6%     ` Stephen Leake
  2016-08-18 18:28 12%     ` Jeffrey R. Carter
  0 siblings, 2 replies; 200+ results
From: Stephen Leake @ 2016-08-18 17:45 UTC (permalink / raw)


On Thursday, August 18, 2016 at 6:19:45 AM UTC-5, G.B. wrote:
> On 17.08.16 23:05, Stephen Leake wrote:
> > One solution would be to replace the "DATETIME" field type in the .sql file with "TEXT", always pass strings for times, and rely on lexicographic sorting for time comparison. But that seems extreme.
> 
> It seems advisable to use SQLite's Date And Time Functions
> when using SQLite for SQL. Thus,
> 
>     " ... WHERE Modified >= datetime(?) ... "
> 

Yes, that works. Although I'm not clear why; 
https://www.sqlite.org/lang_datefunc.html defines that function to return a string, and the examples are about output formatting. Apparently it has a different meaning when processing bound parameters.

> Testing SQL scripts using standard SQL syntax and several
> SQL DBMSs has proven to be useful in detecting caveats.
> SQLite's .dump command seems pretty good at producing
> standard SQL syntax. 

That gives:

INSERT INTO "Title" VALUES(2,'2000-01-02 00:00:00','Foundation');

no "datetime" function call.

But we are talking about bound parameters, which could easily be different.

I need to remember SQL is not Ada; it can silently do the wrong thing any time it wants :(.

-- Stephe

^ permalink raw reply	[relevance 5%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-17 21:05 10% GNATCOLL SQLite3 vs Ada.Calendar.Time Stephen Leake
  2016-08-18  8:09  6% ` Dmitry A. Kazakov
@ 2016-08-18 11:19  5% ` G.B.
  2016-08-18 17:45  5%   ` Stephen Leake
  1 sibling, 1 reply; 200+ results
From: G.B. @ 2016-08-18 11:19 UTC (permalink / raw)


On 17.08.16 23:05, Stephen Leake wrote:
> One solution would be to replace the "DATETIME" field type in the .sql file with "TEXT", always pass strings for times, and rely on lexicographic sorting for time comparison. But that seems extreme.

It seems advisable to use SQLite's Date And Time Functions
when using SQLite for SQL. Thus,

    " ... WHERE Modified >= datetime(?) ... "

With Ubuntu's standard GNAT, this change results in:

find modified time (1 day before created):
[SQL.SELECT] SELECT ID, Modified, Title FROM Title WHERE Modified >= 
datetime(?) ORDER BY ID, 1999-12-31 23:00:00
1, 2000-01-02 00:00:00, 2001
2, 2000-01-02 00:00:00, Foundation
3, 2000-01-02 00:00:00, Foundations Edge
4, 2000-01-02 00:00:00, Foundation and Earth
5, 2000-01-02 00:00:00, Foundation and Empire

Also, I think that +"some string" has only recently been added
as an overloaded "+" in GNATCOLL.SQL.Exec, in case it's resolved
to be from there and portability to older installation matters.

Testing SQL scripts using standard SQL syntax and several
SQL DBMSs has proven to be useful in detecting caveats.
SQLite's .dump command seems pretty good at producing
standard SQL syntax. (I have had cases where using double
quotes for VARCHAR literals had made the DBMS take "foo"
for column FOO, and that's formally correct.)


^ permalink raw reply	[relevance 5%]

* Re: GNATCOLL SQLite3 vs Ada.Calendar.Time
  2016-08-17 21:05 10% GNATCOLL SQLite3 vs Ada.Calendar.Time Stephen Leake
@ 2016-08-18  8:09  6% ` Dmitry A. Kazakov
  2016-08-18 11:19  5% ` G.B.
  1 sibling, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2016-08-18  8:09 UTC (permalink / raw)


On 17/08/2016 23:05, Stephen Leake wrote:
> One solution would be to replace the "DATETIME" field type in the
> .sql  file with "TEXT", always pass strings for times, and rely on
> lexicographic sorting for time comparison. But that seems extreme.

AFAIK SQLite3 does not have date/time types. DATETIME is NUMERIC 
according to:

https://www.sqlite.org/datatype3.html

> Any ideas what's going on here?

I would say, never rely on built-in DB types conversions.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 6%]

* GNATCOLL SQLite3 vs Ada.Calendar.Time
@ 2016-08-17 21:05 10% Stephen Leake
  2016-08-18  8:09  6% ` Dmitry A. Kazakov
  2016-08-18 11:19  5% ` G.B.
  0 siblings, 2 replies; 200+ results
From: Stephen Leake @ 2016-08-17 21:05 UTC (permalink / raw)


I've run into some very odd behavior using GNATCOLL to interface to an SQLite3 database, and querying on a DATETIME field. Here's a very simple program that shows the problem:

-- create_db.sql
-- Create a table, fill it with some test data
-- SQLite3 syntax

CREATE TABLE Title
(ID       INTEGER PRIMARY KEY,
 Modified DATETIME,
 Title    TEXT);

INSERT INTO Title (Modified, Title) VALUES ("2000-01-02 00:00:00", "2001"); 
INSERT INTO Title (Modified, Title) VALUES ("2000-01-02 00:00:00", "Foundation");
INSERT INTO Title (Modified, Title) VALUES ("2000-01-02 00:00:00", "Foundations Edge");
INSERT INTO Title (Modified, Title) VALUES ("2000-01-02 00:00:00", "Foundation and Earth");
INSERT INTO Title (Modified, Title) VALUES ("2000-01-02 00:00:00", "Foundation and Empire");

-- end of file


-- debug_db_times.adb
--  Abstract :
--
--  demonstrate a bug in GNATCOLL/sql related to time field handling

pragma License (GPL);

with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar;
with GNATCOLL.SQL.Exec; use GNATCOLL.SQL.Exec;
with GNATCOLL.SQL.Sqlite;
with GNATCOLL.Traces;
procedure Debug_DB_Times
is
   DB     : Database_Connection := Build_Connection (GNATCOLL.SQL.Sqlite.Setup ("debug_db_times.db"));
   Cursor : Forward_Cursor;

   Before_Created : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (1999, 1, 1);
   Jan_1_2000 : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (2000, 1, 1);

   procedure Put_Current
   is begin
      for I  in Field_Index'(0) .. 2 loop
         Put (Cursor.Value (I));
         if I /= 2 then
            Put (", ");
         end if;
      end loop;
      New_Line;
   end Put_Current;
begin
   GNATCOLL.Traces.Parse_Config_File
     (Filename         => "debug_db_times.trace",
      Force_Activation => False);

   Put_Line ("find all:");
   Fetch (Cursor, DB, "SELECT ID, Modified, Title FROM Title ORDER BY ID");
   loop
      exit when not Cursor.Has_Row;
      Put_Current;
      Cursor.Next;
   end loop;

   Put_Line ("find modified time (long before created):");
   Fetch (Cursor, DB, "SELECT ID, Modified, Title FROM Title WHERE Modified >= ? ORDER BY ID", (1 => +Before_Created));
   loop
      exit when not Cursor.Has_Row;
      Put_Current;
      Cursor.Next;
   end loop;

   Put_Line ("find modified time (1 day before created):");
   Fetch (Cursor, DB, "SELECT ID, Modified, Title FROM Title WHERE Modified >= ? ORDER BY ID", (1 => +Jan_1_2000));
   loop
      exit when not Cursor.Has_Row;
      Put_Current;
      Cursor.Next;
   end loop;

   Put_Line ("find modified string:");
   Fetch (Cursor, DB, "SELECT ID, Modified, Title FROM Title WHERE Modified >= ? ORDER BY ID",
          (1 => +"2000-01-01 00:00:00"));
   loop
      exit when not Cursor.Has_Row;
      Put_Current;
      Cursor.Next;
   end loop;
end Debug_DB_Times;
-- end of file

-- debug_db_times.trace
SQL=TRUE
SQL.SELECT=TRUE
-- end of file

Running on Windows 8.1 with GNAT GPL 2016:

sqlite3 -echo -init create_db.sql debug_db_times.db ".quit"
gprbuild -p -P debug_db_times.gpr debug_db_times.adb
./debug_db_times.exe
find all:
[SQL] Connecting to sqlite database debug_db_times.db ()
[SQL] PRAGMA foreign_keys=ON 
[SQL.SELECT] SELECT ID, Modified, Title FROM Title ORDER BY ID 
1, 2000-01-02 00:00:00, 2001
2, 2000-01-02 00:00:00, Foundation
3, 2000-01-02 00:00:00, Foundations Edge
4, 2000-01-02 00:00:00, Foundation and Earth
5, 2000-01-02 00:00:00, Foundation and Empire
find modified time (long before created):
[SQL.SELECT] SELECT ID, Modified, Title FROM Title WHERE Modified >= ? ORDER BY ID, 1999-01-01 06:00:00 
1, 2000-01-02 00:00:00, 2001
find modified time (1 day before created):
[SQL.SELECT] SELECT ID, Modified, Title FROM Title WHERE Modified >= ? ORDER BY ID, 2000-01-01 06:00:00 
1, 2000-01-02 00:00:00, 2001
find modified string:
[SQL.SELECT] SELECT ID, Modified, Title FROM Title WHERE Modified >= ? ORDER BY ID, 2000-01-01 00:00:00 
1, 2000-01-02 00:00:00, 2001
2, 2000-01-02 00:00:00, Foundation
3, 2000-01-02 00:00:00, Foundations Edge
4, 2000-01-02 00:00:00, Foundation and Earth
5, 2000-01-02 00:00:00, Foundation and Empire


When I pass an Ada.Calendar.Time as a parameter, I only get one record back. When I pass a string as a parameter, I get all the records back.

Note that Ada.Calendar.Time messes with time zones in an undocumented way (I happen to be in GMT+6); that's not a problem, since I figured out how to deal with it in my full program.

In my full program, I have similar but different behavior, and always passing a string doesn't fix it.

One solution would be to replace the "DATETIME" field type in the .sql file with "TEXT", always pass strings for times, and rely on lexicographic sorting for time comparison. But that seems extreme.

Any ideas what's going on here?


^ permalink raw reply	[relevance 10%]

* Re: ANN: Introducing AdaBase - Thick database bindings for Ada
  @ 2016-05-16 20:06  5%       ` Randy Brukardt
  0 siblings, 0 replies; 200+ results
From: Randy Brukardt @ 2016-05-16 20:06 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2034 bytes --]


<gautier_niouzes@hotmail.com> wrote in message 
news:f1c76310-e74f-4734-9961-5743e877b5e2@googlegroups.com...
>Le samedi 14 mai 2016 01:37:02 UTC+2, Randy Brukardt a écrit :

>> Impossible, I fear. I tried that with Claw, but even having a several 
>> year
>> head start didn't prevent someone from making their own incompatible
>> version.
>
>And in retrospect, it was a good thing: since around 2000, GWindows [1] is
>the only Ada thick binding for Windows maintained, developed, and usable
>for real applications (just tested the 3rd one, JEWL [2]; builds and runs 
>fine,
>but very limited beyond demos or toy projects).

Not remotely true (except the point about JEWL - but it was always intended 
to be easy rather than powerful).

(1) Plenty of real-world projects use/used Claw - I haven't asked for 
permission to talk about customers projects, but we've used it for the 
Trash-Finder UI, for the Claw Builder itself (a *very* tough task for an 
interface library), and a variety of internal tools.
(2) Claw was actively developed for many years after 2000, and still is 
actively maintained now. (Not doing much development because of lack of 
demand.)
(3) The above of course is a self-fufilling prophecy; once the split 
happened, the community had to make a choice and the effect was to duplicate 
all of the effort spent on Claw. The same effort could have been spent on 
enhancing Claw and more good stuff would have been available.

At least Claw was not a total waste of time: (1) it toughened up the OOP and 
finalization support in Ada compilers, so GWindows and the like were even 
possible. (When we started with Claw, most of our code didn't work on early 
Ada 95 compilers for one reason or another.) (2) Claw.Directories turned 
into Ada.Directories, and Claw.Time turned into Ada.Calendar.Arithmetic and 
Ada.Calendar.Formatting - so those things are now available to all Ada 
programmers. Too bad that I could never get Ada.Sockets (after Claw.Sockets) 
off the ground.

                           Randy.



^ permalink raw reply	[relevance 5%]

* Re: Roundtrip latency problem using Gnoga, on Linux, when testing at localhost address
  @ 2016-03-31 17:44  4%         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2016-03-31 17:44 UTC (permalink / raw)


On 2016-03-31 19:02, Olivier Henley wrote:
> On Thursday, March 31, 2016 at 3:39:10 AM UTC-4, Dmitry A. Kazakov wrote:
>
>> Still it could be indication of a problem or a bug. Usual suspects are:
>>
>> 1. The measurement procedure.
>>
>> 1.1. Artifacts of process switching.
>> 1.2. Wrong clock used. System clocks may be very coarse. In many OSes
>> they are driven by the timer interrupts or from an inferior clock
>> source. Real-time clock at the processor's or the front bus' tact must
>> be used in round-trip measurements.
>
> Debian 8 x64 using Adacore GNAT 2015 and within Ada.Real_Time

AFAIK GNAT's Ada.Real_Time and Ada.Calendar use the same time source and 
it must be TSC under Linux.

To test clock quality call Clock twice and compare the results. Good 
clock must have different reading each time you call it.

>> 2. HTTP. It is a very poor protocol. Much depends on the
>> connection/session settings. E.g. if a new session is created for each
>> measurement it is to expect a quite poor performance. Creating and
>> connecting sockets is expensive.
>
> I am using Gnoga and expect everything to go through Websocket and
> not  HTTP (handshake done). I don't suspect my using of the framework, nor
> the framework, to create new connections every time I communicate with a
> particular client.

WebSocket uses a HTTP session. You first establish a HTTP session and 
then switch to WebSocket. An awful idea, but everything related to HTTP 
is awful.

>> 3. Socket settings
>>
>> 3.1. TCP_NO_DELAY and sending packets in full is essential to short
>> latencies. The frame coalescing algorithm timeout depends on the system
>> settings. Usually it is close to 100ms. Which means that you could have
>> sporadic latency spikes depending on the state of the TCP buffer when
>> the traffic is low.
>
> I need to investigate this one.

Yes. This is the major source of latencies. TCP/IP is optimized for 
throughout, not for short latencies.

>> 4. OS, TCP stack system settings
>>
>> 4.1. Poor Ethernet controller, especially bad are integrated ones. The
>> worst are ones connected over USB/COM. Many boards have ones sitting on
>> top of an UART.
>
> ping 127.0.0.1 gives me like 0.02 ms. So to have a ~80ms
> discrepancy,
> I would not suspect my hardware.

OK, loop-back is not related to Ethernet.

>> Then, it could be a software bug. The Simple Components server gets a
>> notification when there is free space in the output buffer, ready to
>> send more data out. When the traffic is low, the output buffer is never
>> full and this means that, in effect, the buffer-ready signal is always
>> set. Thus dealing with the socket output becomes in effect busy waiting.
>> That in turn leads 100% load of the CPU's core running the server. In
>> order to prevent that the server stops waiting for the buffer-ready
>> signal when there was nothing to send. When a new portion of output data
>> appears the socket waiting is resumed. There is a certain timeout to
>> look after the socket regardless. If there is a bug somewhere that
>> prevents the resuming, it may expose itself as sporadically increased
>> latencies during sending data out. The latency must then be close to the
>> timeout value. [This is similar to the effect of TCP_NO_DELAY not set]
>
> Good. In a sense it reassures me because I am effectively sending
> almost nothing, couple of bytes, every half seconds. I should stress
> test and see if it stays the same or even maybe reduce latency.

I would start with TCP_NO_DELAY. Ask David if Gnoga supports it. Note 
that it must be set on both sides if the communication is 
bi-directional. I don't know if it were possible on the client's script 
side.

> Ok but would it hold if I tell you that using Firefox I get around 120ms instead?

That looks consistent with TCP_NO_DELAY being not set.

> What is my best plan to investigate further? Profiling my exec,
> analysing network traffic etc?

In Wireshark (on LAN) you can see the structure of frames. When 
TCP_NO_DELAY is active packets are small because the TCP stack bypasses 
coalescing and sends data as soon as possible regardless the frame size. 
TCP_NO_DELAY is a dangerous thing that leads to flooding the LAN.

If TCP_NO_DELAY does not help and there is a suspicion that there could 
be something wrong with the server and/or client, I would suggest to 
write a small echo server and client program to test QoS of the server 
and the client separately.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 4%]

* Re: Operating System differences and Ada OS independent programming
  2016-03-24  3:36  4%             ` Shark8
@ 2016-03-24  7:58  0%               ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2016-03-24  7:58 UTC (permalink / raw)


On 2016-03-24 04:36, Shark8 wrote:
> On Wednesday, March 23, 2016 at 2:39:08 AM UTC-6, Dmitry A. Kazakov wrote:
>>
>> Ada's abstraction should reflect the most generic file system properties:
>>
>> - Acyclic directed graph of names built from Unicode code points;
>
> No, these should be a private type which is 0..Unsigned_32/64 and
> has  the name as a property whose value is a unicode string. There should be
> a "translate" function which takes a Unicode string and translates it
> into the filesystem-actual's encoding. -- an identical yet distinct type
> should exist for directories.

Ada does not have Unicode strings. The point is that graph nodes 
(filenames) are logically chains of code points.

>> - Multiple roots (AKA devices);
>
> No, absolutely not.

Why? Only one OS (Unix) has single root, which does not work anyway in 
presence of networking, virtual, portable file systems. In its GUI, e.g. 
GNOME Linux dropped single root concept.

>> - Current directory path generator;
>
> Pretty much unneeded if there's a directory-type:
> Type FS_Rider is
>    Current : Directory_Type;
>    -- Other state information.
> end record;

You need functions returning standard paths. E.g. (imaginary operations)

    Get_Current_Directory / "My_Folder" / "Hello_World" + "ads"

instead of

    "./My_Folder/Hello_World.ads"

>> - Extension / MIME types;
>
> Why?

Files have extensions, don't they?

>> - Version / change / release number;
>
> Definitely.
>
>> - Time stamps (modification, creation etc).
>
> Which should be Ada.Calendar.Time.

Yes, but you need operations putting them into the path.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 0%]

* Re: Operating System differences and Ada OS independent programming
  @ 2016-03-24  3:36  4%             ` Shark8
  2016-03-24  7:58  0%               ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Shark8 @ 2016-03-24  3:36 UTC (permalink / raw)


On Wednesday, March 23, 2016 at 2:39:08 AM UTC-6, Dmitry A. Kazakov wrote:
> 
> Ada's abstraction should reflect the most generic file system properties:
> 
> - Acyclic directed graph of names built from Unicode code points;

No, these should be a private type which is 0..Unsigned_32/64 and has the name as a property whose value is a unicode string. There should be a "translate" function which takes a Unicode string and translates it into the filesystem-actual's encoding. -- an identical yet distinct type should exist for directories.

> - Multiple roots (AKA devices);

No, absolutely not.
These should NOT be part of the filesystem; instead there should be a Physical_Drive type and a Virtual_Drive type, where the former denotes a physical drive, and the virtual denotes either a single partition of a physical_drive or multiple physical drives. (VMS has the capibility to view multiple HDs as a single logical drive.)

UNIX caused all sorts of trouble with their misguided "everything's a file" stupidity.

> - Absolute vs. relative path distinction;

Yes.

> - Current directory path generator;

Pretty much unneeded if there's a directory-type:
Type FS_Rider is
  Current : Directory_Type;
  -- Other state information.
end record;

> - Generators for special directory paths (home, my downloads, my 
> documents etc);

These could be a simple map (key -> directory_type), populated as needed by the particular OS/FS.

> - Extension / MIME types;

Why?

> - Version / change / release number;

Definitely.

> - Time stamps (modification, creation etc).

Which should be Ada.Calendar.Time.


^ permalink raw reply	[relevance 4%]

* Re: Abortable Timed Action
  2016-01-09  8:45  8%             ` Simon Wright
  2016-01-09  9:10  0%               ` Dmitry A. Kazakov
@ 2016-01-09 15:59  0%               ` T.G.
  1 sibling, 0 replies; 200+ results
From: T.G. @ 2016-01-09 15:59 UTC (permalink / raw)


On 2016-01-09, Simon Wright <simon@pushface.org> wrote:
> The common solution is something like

> ...
>         delay until Next;
>         Next := Next + Interval;  -- *not* Ada.Calendar.Clock + Interval

Yes, using Next is much better than my :

          delay until (Start + (Interval * Counter));
          Counter := Counter + 1;

--- news://freenews.netfront.net/ - complaints: news@netfront.net ---


^ permalink raw reply	[relevance 0%]

* Re: Abortable Timed Action
  2016-01-09  8:45  8%             ` Simon Wright
@ 2016-01-09  9:10  0%               ` Dmitry A. Kazakov
  2016-01-09 15:59  0%               ` T.G.
  1 sibling, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2016-01-09  9:10 UTC (permalink / raw)


On 2016-01-09 09:45, Simon Wright wrote:
> "T.G." <anon@anon.org> writes:
>
>> delay until is an interesting idea. I'm assuming that time drift would
>> be an issue in periodic actions that repeat at a certain interval, but
>> in that case delay until could also have issues if it loses some
>> accuracy on each iteration.

Yes, if the period is not a multiple of the clock and system timer 
interrupt source. Though there is no way to eliminate this type of 
jitter, so why worry?

The resolution of Time (not accuracy) can be a problem, e.g. in the 
suggested schema below, which will accumulate error. The error can be 
compensated by computing Next as

    Count := Count + 1;
    Next :=
       Start + Duration (Long_Float (Count) * Long_Float (Interval));

Though, it is difficult to imagine a scenario where that would be really 
needed.

> The common solution is something like
>
>     with Ada.Calendar;
>     with Ada.Text_IO; use Ada.Text_IO;
>     procedure Delay_Until is
>        task T is
>           entry Exec_After (T : Duration);
>        end T;
>        task body T is
>           Start : Ada.Calendar.Time;
>           Next : Ada.Calendar.Time;
>           Interval : Duration;
>           use type Ada.Calendar.Time;
>        begin
>           accept Exec_After (T : Duration) do
>              Start := Ada.Calendar.Clock;
>              Next := Start + T;
>              Interval := T;
>           end Exec_After;
>           loop
>              delay until Next;
>              Next := Next + Interval;  -- *not* Ada.Calendar.Clock + Interval

An missing ticks detection and compensation:

    if Next < Clock then
       Next := Clock;
       Put_Line ("Ticks missed!");
    end if;


-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 0%]

* Re: Abortable Timed Action
  2016-01-08 20:24  7%           ` T.G.
@ 2016-01-09  8:45  8%             ` Simon Wright
  2016-01-09  9:10  0%               ` Dmitry A. Kazakov
  2016-01-09 15:59  0%               ` T.G.
  0 siblings, 2 replies; 200+ results
From: Simon Wright @ 2016-01-09  8:45 UTC (permalink / raw)


"T.G." <anon@anon.org> writes:

> The reason why I had an explicit Finish instead of using terminate was
> that I was thinking of creating the timer dynamically and then freeing
> it with Ada.Unchecked_Deallocation. So I wanted to Finish the task
> before freeing it. I'm not sure if calling Free on an access actually
> terminates the task Normally.

GNAT certainly used to have issues in this area. Indeed, you could abort
the task and then deallocate it, and end with a memory leak (the task
control block wasn't actually freed); the cure was to wait until
'Terminated.

I believe that this is no longer a problem.

> delay until is an interesting idea. I'm assuming that time drift would
> be an issue in periodic actions that repeat at a certain interval, but
> in that case delay until could also have issues if it loses some
> accuracy on each iteration.

The common solution is something like

   with Ada.Calendar;
   with Ada.Text_IO; use Ada.Text_IO;
   procedure Delay_Until is
      task T is
         entry Exec_After (T : Duration);
      end T;
      task body T is
         Start : Ada.Calendar.Time;
         Next : Ada.Calendar.Time;
         Interval : Duration;
         use type Ada.Calendar.Time;
      begin
         accept Exec_After (T : Duration) do
            Start := Ada.Calendar.Clock;
            Next := Start + T;
            Interval := T;
         end Exec_After;
         loop
            delay until Next;
            Next := Next + Interval;  -- *not* Ada.Calendar.Clock + Interval
            Put_Line (Duration'Image (Ada.Calendar.Clock - Start));
         end loop;
      end T;
   begin
      T.Exec_After (0.5);
   end Delay_Until;

^ permalink raw reply	[relevance 8%]

* Re: Abortable Timed Action
  2016-01-06 21:14  7%         ` Anh Vo
@ 2016-01-08 20:24  7%           ` T.G.
  2016-01-09  8:45  8%             ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: T.G. @ 2016-01-08 20:24 UTC (permalink / raw)


On 2016-01-06, Anh Vo <anhvofrcaus@gmail.com> wrote:
> After looking at your original post again, I believe your code
> should work after replacing delay statement by delay until
> statement. The delay until statement does not have time drifting
> issue. In addition, then Entry Finish can be replaced by the
> terminate alternative. The modified version is shown below.

>             select 
>                accept Cancel; 
>             or 
>                delay until (Ada.Calendar.Clock + Timeout); 
>                Put_Line ("Do Something"); 
>             end select; 

The reason why I had an explicit Finish instead of using terminate was
that I was thinking of creating the timer dynamically and then freeing
it with Ada.Unchecked_Deallocation. So I wanted to Finish the task
before freeing it. I'm not sure if calling Free on an access actually
terminates the task Normally.

delay until is an interesting idea. I'm assuming that time drift would
be an issue in periodic actions that repeat at a certain interval, but
in that case delay until could also have issues if it loses some
accuracy on each iteration. For example, modifying the code to run
periodically, with:

      Start_Time : Ada.Calendar.Time;
   begin
      ...
	    accept Exec_After (T : Duration) do
   	       Start_Time := Ada.Calendar.Clock;
	       Timeout    := T;
	    end Exec_After; 
	    Inner : loop
	       select 
		  accept Cancel; 
		  exit Inner;
	       or 
		  delay until (Ada.Calendar.Clock + Timeout); 
		  Put_Line (Duration'Image (Ada.Calendar.Clock - Start_Time));
	       end select; 
	    end loop Inner;

it will drift, however, we can still use delay until but with a
counter, for example:

   task body Timed_Action_Task is 
      Timeout        : Duration;
      Start_Time     : Ada.Calendar.Time;
      Counter        : Positive := 1;
   begin 
      loop 
	 select 
	    accept Exec_After (T : Duration) do 
	       Start_Time := Ada.Calendar.Clock;
	       Timeout    := T;
	       Counter    := 1;
	    end Exec_After; 
	    Inner : loop
	       select 
		  exit Inner;
		  accept Cancel; 
	       or 
		  delay until (Start_Time + (Timeout * Counter));
		  Counter := Counter + 1;
		  Put_Line (Duration'Image (Ada.Calendar.Clock - Start_Time));
	       end select; 
	    end loop Inner;
	 or 
	    terminate;
	 end select; 
      end loop; 
   end Timed_Action_Task;

This avoids the drift from the previous example.

In my actual code, I used Ada.Real_Time.Timing_Events. It ended up
being somewhat complicated, but only because I wanted to pass both
Action and User_Data to the Timer and make a more flexible/reusable
timer. Now after testing the code above, I think I want to recheck my
code for a possible time drift with periodic timed events.


--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

^ permalink raw reply	[relevance 7%]

* Re: Abortable Timed Action
  @ 2016-01-06 21:14  7%         ` Anh Vo
  2016-01-08 20:24  7%           ` T.G.
  0 siblings, 1 reply; 200+ results
From: Anh Vo @ 2016-01-06 21:14 UTC (permalink / raw)


On Thursday, December 31, 2015 at 10:09:30 AM UTC-8, T.G. wrote:
> On 2015-12-31, Anh Vo <anhvofrcaus@gmail.com> wrote:
> > I think accuracy more important than better/simpler way. There is a
> > drifting issue in your codes in term of time since delay statement
> > is involved. In addition, timer has no problem of this kind. If you
> > decide to use timer, take look at
> > http://www.adacore.com/adaanswers/gems/ada-gem-15/. Let me know if
> > have any question.
> >
> > Anh Vo
> 
> Very nice example. I didn't know about Ada.Real_Time.Timing_Events,
> I'll probably go with that. Thanks for the pointer.

After looking at your original post again, I believe your code should work after replacing delay statement by delay until statement. The delay until statement does not have time drifting issue. In addition, then Entry Finish can be replaced by the terminate alternative. The modified version is shown below.

   with Ada.Calendar; use type Ada.Calendar.Time;
   with Ada.Text_Io;  use Ada.Text_Io;
   -- ...

   -- ...
   task type Timed_Action_Task is 
     entry Exec_After (T : Duration); 
     entry Cancel; 
   end Timed_Action_Task; 

   task body Timed_Action_Task is 
      Timeout : Duration; 
   begin 
      loop 
         select 
            accept Exec_After (T : Duration) do 
               Timeout := T; 
            end Exec_After; 
            select 
               accept Cancel; 
            or 
               delay until (Ada.Calendar.Clock + Timeout); 
               Put_Line ("Do Something"); 
            end select; 
         or 
            terminate;
         end select; 
      end loop; 
   end Timed_Action_Task;

^ permalink raw reply	[relevance 7%]

* Re: Two approaches of iterators for the key-value pairs
  @ 2015-11-29 16:17  6%         ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2015-11-29 16:17 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> Brad Moore <bmoore.ada@gmail.com> writes:
>
>> My sense is that if you dont need a container as part of the
>> abstraction, then perhaps it's better to just provide an Iterator
>> type. All the existing containers already were containers, so for
>> those it made sense to make them Iterable containers.  Ada.Directories
>> and Ada.Environment_Variables do not currently have Containers
>> associated with them, so perhaps an argument can be made that they
>> should be Iterators, rather than concoct a Container type so that
>> Iterable container syntax can be used.
>
> I don't see it as concocting a Container type; it's an Iterable
> type. Containers happen to be Iterable.
>
> It's unfortunate (but understandable!) that 4.1.6 and 5.5.1, .2 use
> container-related language.

I think there's a lot to be said for consistency. If users see that they
can iterate over directories, won't they be surprised and disappointed
to find that they have to use the clumsier 'in' form?

The implementer might be happier with a Container-ish object to support
the 'of' form, but surely the users won't care? It's all a black mystery
to them anyway (and quite right, too).

I had fun with my Date_Iteration example to support the 'of' form
without an extra type; the extras needed are the aspects on Date_Set and
the function Element.

   type Date_Set is new Iterator_Interfaces.Forward_Iterator with private
   with
     Constant_Indexing => Element,
     Default_Iterator => Iterate,
     Iterator_Element => Ada.Calendar.Time;

   function Element (Set : Date_Set; C : Cursor) return Ada.Calendar.Time;

(Date_Set is acceptable to GNAT but not to emacs ada-mode, which gets
thoroughly confused)

I must say I got quite confused about what the second parameter of
Element should be until I read ARM5.5.2(13).


^ permalink raw reply	[relevance 6%]

* Re: A few questions
  @ 2015-11-12 20:19  4%               ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2015-11-12 20:19 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> <briot.emmanuel@gmail.com> wrote in message 
> news:aa0cf839-651e-494d-a826-c2ce31a7afd3@googlegroups.com...
>>> The "of" form is for iterating over an array or a container whose
>>> type has the Default_Iterator aspect (which gives the iterator to
>>> use).
>>
>> The main drawback, though, is that you then get a Cursor, not an
>> Element, so you still need to call the functions Element or Reference
>> to get to the actual element. This is slightly less convenient
>> (syntax-wise).
>
> Sure, but not in a case like the OP's, where the "cursor" is the
> actual data and there is no element. In that case, "of" is just
> overkill.

There's one problem for Times; how to determine when to end the loop if
the cursor is the actual data?

I ended up with

   type Cursor (Valid : Boolean := True) is record
      case Valid is
         when True =>
            Date : Ada.Calendar.Time;
         when False =>
            null;
      end case;
   end record;

where both First and Next set Valid to False if the iteration has ended.

I spent a lot too much time without giving Valid a default value; there
is an assignment, but it's hidden inside the generated code, so at the
end of the loop the discriminant changes ...

I think this may be related to the way that F552A00_Prime_Numbers
doesn't support an upper bound of 2; the loop terminates when Is_Prime
returns false, and of course 2 + 1 = 3 which .. Is_Prime.


^ permalink raw reply	[relevance 4%]

* Re: A few questions
  2015-11-03  6:33  0%     ` Randy Brukardt
@ 2015-11-03  8:26  0%       ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2015-11-03  8:26 UTC (permalink / raw)


"Randy Brukardt" <randy@rrsoftware.com> writes:

> "Simon Wright" <simon@pushface.org> wrote in message 

>>   function Constant_Reference
>>     (Container : aliased Date_Container;
>>      Position  : Cursor) return Constant_Reference_Type;
>>
>> returning
>>
>>   type Constant_Reference_Type
>>      (Element : not null access constant Ada.Calendar.Time) is private
>>   with
>>      Implicit_Dereference => Element;

> If you *only* need constants, the Constant_Indexing function can be a
> normal function (no implicit dereference required). In that case, the
> implementation will do the memory management. Note the difference in
> wording between 4.1.6(2/3) and 4.1.6(3/3) (there is no requirement on
> the return type for Constant_Indexing).

Worked a treat!

> OTOH, I think GNAT got that wrong somehow when I constructed an ACATS
> test to try that (don't recall the details). So it may not work in
> your copy of GNAT, most likely it will in a future version.

No problem (for the constant case) with GCC 5.1.0 or GNAT GPL 2015.

^ permalink raw reply	[relevance 0%]

* Re: A few questions
  2015-11-02 18:48  7%   ` Simon Wright
@ 2015-11-03  6:33  0%     ` Randy Brukardt
  2015-11-03  8:26  0%       ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: Randy Brukardt @ 2015-11-03  6:33 UTC (permalink / raw)


"Simon Wright" <simon@pushface.org> wrote in message 
news:ly1tc8me4w.fsf@pushface.org...
> Simon Wright <simon@pushface.org> writes:
>
>> I'd have liked to support
>>
>>    for D in Period loop
>
> Oops, I meant "for D of Period", i.e.
>
>   for D : Ada.Calendar.Time of Period loop
>      ...
>
> but you'd need
>
>   function Constant_Reference
>     (Container : aliased Date_Container;
>      Position  : Cursor) return Constant_Reference_Type;
>
> returning
>
>   type Constant_Reference_Type
>      (Element : not null access constant Ada.Calendar.Time) is private
>   with
>      Implicit_Dereference => Element;
>
> which is clearly meant for actual containers and here would require - I
> think - allocating an Ada.Calendar.Time, and of course freeing it
> eventually.
>
> Shame, it makes it tricky to support lazy evaluation. But perhaps we
> shouldn't want to ...

If you *only* need constants, the Constant_Indexing function can be a normal 
function (no implicit dereference required). In that case, the 
implementation will do the memory management. Note the difference in wording 
between 4.1.6(2/3) and 4.1.6(3/3) (there is no requirement on the return 
type for Constant_Indexing).

OTOH, I think GNAT got that wrong somehow when I constructed an ACATS test 
to try that (don't recall the details). So it may not work in your copy of 
GNAT, most likely it will in a future version.

                                       Randy.




^ permalink raw reply	[relevance 0%]

* Re: A few questions
  2015-11-01  0:25  6% ` Jeffrey R. Carter
  2015-11-01 13:30  0%   ` Laurent
@ 2015-11-03  6:25  6%   ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Randy Brukardt @ 2015-11-03  6:25 UTC (permalink / raw)


"Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:n13m1a$p3c$1@dont-email.me...
> On 10/31/2015 01:29 PM, Laurent wrote:
>>
>> I need a range of Dates.
>>
>> So is there an existing package which generates a range of Dates from .. 
>> to
>> ?
>>
>> PS: need this range of dates because the log files I want to read and 
>> extract
>> informations from are all named like this: vba-yyyymmdd.log where 
>> obviously
>> yyyymmdd is the date. The program generates a new file every date an 
>> stores
>> the communication it treated in it.
>>
>> I want to read this files and extract the messages which passed. Is more 
>> an
>> exercise than actually a need to do it.
>
> I'm not aware of any such pkg. On the other hand, I'm not sure you need 
> it. Do
> you really need to store all the dates in the range? You could process the 
> file
> for date D, then the file for date D + 1, ..., until you have processed 
> all the
> desired files.
>
> Conceptually the idea of an operation
>
> function "+" (Left : in Dates.Object; Right : in Integer) return 
> Dates.Object;
>
> makes sense; without knowing the details of the implementation of 
> Dates.Object I
> have no idea how easy it would be. For Ada.Calendar.Time, one would simply 
> add
> Right * Ada.Calendar.Day_Duration'Last.

Or easier still, just use Ada.Calendar.Arithmetic, which has operations for 
adding numbers of days to a Ada.Calendar.Time (added in Ada 2005). (This is 
hard to do in Ada 95 if you need to add more than one day at a time.)

                                         Randy.


^ permalink raw reply	[relevance 6%]

* Re: A few questions
  2015-11-02 17:45  8% ` Simon Wright
@ 2015-11-02 18:48  7%   ` Simon Wright
  2015-11-03  6:33  0%     ` Randy Brukardt
    1 sibling, 1 reply; 200+ results
From: Simon Wright @ 2015-11-02 18:48 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> I'd have liked to support
>
>    for D in Period loop

Oops, I meant "for D of Period", i.e.

   for D : Ada.Calendar.Time of Period loop
      ...

but you'd need

   function Constant_Reference
     (Container : aliased Date_Container;
      Position  : Cursor) return Constant_Reference_Type;

returning

   type Constant_Reference_Type
      (Element : not null access constant Ada.Calendar.Time) is private
   with
      Implicit_Dereference => Element;

which is clearly meant for actual containers and here would require - I
think - allocating an Ada.Calendar.Time, and of course freeing it
eventually.

Shame, it makes it tricky to support lazy evaluation. But perhaps we
shouldn't want to ...

^ permalink raw reply	[relevance 7%]

* Re: A few questions
  2015-10-31 20:29  6% A few questions Laurent
  2015-10-31 20:49  5% ` Dmitry A. Kazakov
  2015-11-01  0:25  6% ` Jeffrey R. Carter
@ 2015-11-02 17:45  8% ` Simon Wright
  2015-11-02 18:48  7%   ` Simon Wright
    2 siblings, 2 replies; 200+ results
From: Simon Wright @ 2015-11-02 17:45 UTC (permalink / raw)


Laurent <lutgenl@icloud.com> writes:

> Hi
>
> I need a range of Dates.

I wrote the attached, using generalized iteration, which bears a strong
resemblance to the standard container iteration (the names bear too
strong a resemblance! but this way you can see the commonality).

I'd have liked to support

   for D in Period loop
      ...

but "array type required in indexed component" (which I think means that
Date_Container needs the Constant_Indexing aspect?).

Running this test just now,

   with Date_Iteration;
   with Ada.Calendar.Formatting;
   with Ada.Text_IO; use Ada.Text_IO;
   procedure Date_Iteration_Test is
      use type Ada.Calendar.Time;
      Period : Date_Iteration.Date_Container;
      Day : constant Duration := 86_400.0;
   begin
      Period.Initialize (Start_Time => Ada.Calendar.Clock,
                         End_Time   => Ada.Calendar.Clock + Day * 10,
                         Interval   => Day / 2);
      for C in Period.Iterate loop
         Put_Line (Ada.Calendar.Formatting.Image (Date_Iteration.Element (C)));
      end loop;
   end Date_Iteration_Test;

I got

   $ ./date_iteration_test
   2015-11-02 17:35:03
   2015-11-03 05:35:03
   2015-11-03 17:35:03
   2015-11-04 05:35:03
   2015-11-04 17:35:03
   2015-11-05 05:35:03
   2015-11-05 17:35:03
   2015-11-06 05:35:03
   2015-11-06 17:35:03
   2015-11-07 05:35:03
   2015-11-07 17:35:03
   2015-11-08 05:35:03
   2015-11-08 17:35:03
   2015-11-09 05:35:03
   2015-11-09 17:35:03
   2015-11-10 05:35:03
   2015-11-10 17:35:03
   2015-11-11 05:35:03
   2015-11-11 17:35:03
   2015-11-12 05:35:03
   2015-11-12 17:35:03

========================================================================
with Ada.Calendar;
with Ada.Iterator_Interfaces;
package Date_Iteration is
   type Date_Container is tagged private
   with
     Default_Iterator => Iterate,
     Iterator_Element => Ada.Calendar.Time;
   procedure Initialize (D          : out Date_Container;
                         Start_Time :     Ada.Calendar.Time;
                         End_Time   :     Ada.Calendar.Time;
                         Interval   :     Duration := 86_400.0);

   type Cursor is private;
   No_Element : constant Cursor;

   function First (Container : Date_Container) return Cursor;
   function Next (Position : Cursor) return Cursor;
   function Element (Position : Cursor) return Ada.Calendar.Time;

   function Has_Element (C : Cursor) return Boolean;
   package Iterator_Interfaces
     is new Ada.Iterator_Interfaces (Cursor, Has_Element);
   function Iterate (Container : Date_Container)
                    return Iterator_Interfaces.Forward_Iterator'Class;
private
   type Date_Container is tagged record
      Start_Time : Ada.Calendar.Time;
      End_Time   : Ada.Calendar.Time;
      Interval   : Duration;
   end record;
   type Date_Container_Access is access all Date_Container;
   for Date_Container_Access'Storage_Size use 0;

   type Cursor is record
      Container : Date_Container_Access;
      Index     : Ada.Calendar.Time;
   end record;
   No_Element : constant Cursor
     := (Container => null, Index => Ada.Calendar.Clock);

   type Iterator is new Iterator_Interfaces.Forward_Iterator
      with record
         Container : Date_Container_Access;
      end record;
   overriding
   function First (Object : Iterator) return Cursor;
   overriding
   function Next (Object : Iterator; Position : Cursor) return Cursor;
end Date_Iteration;

package body Date_Iteration is
   procedure Initialize (D          : out Date_Container;
                         Start_Time :     Ada.Calendar.Time;
                         End_Time   :     Ada.Calendar.Time;
                         Interval   :     Duration := 86_400.0) is
   begin
      D := (Start_Time => Start_Time,
            End_Time   => End_Time,
            Interval   => Interval);
   end;

   function First (Container : Date_Container) return Cursor is
   begin
      return C : Cursor do
         C.Container := Container'Unrestricted_Access;
         C.Index := Container.Start_Time;
      end return;
   end First;

   function Next (Position : Cursor) return Cursor is
      use type Ada.Calendar.Time;
   begin
      if Position.Container = null then
         return No_Element;
      end if;
      return C : Cursor do
         C.Container := Position.Container;
         C.Index := Position.Index + Position.Container.Interval;
      end return;
   end Next;

   function Element (Position : Cursor) return Ada.Calendar.Time is
     (Position.Index);

   function Has_Element (C : Cursor) return Boolean is
      use type Ada.Calendar.Time;
   begin
      return C.Index <= C.Container.End_Time;
   end Has_Element;

   function Iterate (Container : Date_Container)
                    return Iterator_Interfaces.Forward_Iterator'Class is
   begin
      return It : Iterator do
         It.Container := Container'Unrestricted_Access;
      end return;
   end Iterate;

   function First (Object : Iterator) return Cursor is
   begin
      return Object.Container.First;
   end First;

   function Next (Object : Iterator; Position : Cursor) return Cursor is
   begin
      if Position.Container = null then
         return No_Element;
      end if;
      if Position.Container /= Object.Container then
         raise Program_Error with "container/cursor mismatch";
      end if;
      return Next (Position);
   end Next;
end Date_Iteration;

^ permalink raw reply	[relevance 8%]

* Re: A few questions
  2015-11-01  0:25  6% ` Jeffrey R. Carter
@ 2015-11-01 13:30  0%   ` Laurent
  2015-11-03  6:25  6%   ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Laurent @ 2015-11-01 13:30 UTC (permalink / raw)


On Sunday, 1 November 2015 01:25:22 UTC+1, Jeffrey R. Carter  wrote:

> I'm not aware of any such pkg. On the other hand, I'm not sure you need it. Do
> you really need to store all the dates in the range? You could process the file
> for date D, then the file for date D + 1, ..., until you have processed all the
> desired files.

I don't think that I need to store them. It would allow me to use a simple loop later on and hide the ugly things somewhere else.

> Conceptually the idea of an operation
> 
> function "+" (Left : in Dates.Object; Right : in Integer) return Dates.Object;
> 
> makes sense; without knowing the details of the implementation of Dates.Object I
> have no idea how easy it would be. For Ada.Calendar.Time, one would simply add
> Right * Ada.Calendar.Day_Duration'Last.

Sounds like a good idea. 

I am actually reinventing the wheel because most of the functionality already is in the Calendar package. I tried to understand how this package works but there are few intermediate steps which I don't get. IE: Time_Rep? And there are others. They are probably required for managing one special problem which happens once a century.

At least I will perhaps learn why the package has been designed like this.

Thanks



^ permalink raw reply	[relevance 0%]

* Re: A few questions
  2015-10-31 20:49  5% ` Dmitry A. Kazakov
@ 2015-11-01 13:16  0%   ` Laurent
  0 siblings, 0 replies; 200+ results
From: Laurent @ 2015-11-01 13:16 UTC (permalink / raw)


On Saturday, 31 October 2015 21:49:24 UTC+1, Dmitry A. Kazakov  wrote:

> > subtype Period is range Begin_Date .. End_Date;
> 
> 1. How is this subtype would be different from Date? 
> 
Perhaps in some declarative language where lists are an fundamental part of the language itself the compiler could be smart enough to make Period a list and fill it with dates from..to? Yeah I know mind-reading compiler and World of Fantasycraft :)

> 2. Date is not a numeric type to have ranges

Agreed

> 3. Date cannot be a numeric type because arithmetic operations would not
> make sense: D1 + D2 is what?

Nonsense :)

> > I naively thought that it could be so easy.
> 
> Yes, because it is wrong.

What? Being naive or thinking that it could/should be easy? :)
 
> > I have found in Ada.Calendar a: function "-" (L,R:Time) return Duration
> 
> Similarly D1 - D2 is a Duration, not a date. Likewise you can add duration
> to a date, but not a date to date.
> 
> > Is it possible to make a casting to convert my Date type in (Ada.Calendar) Time type:
> > 
> > Today : Ada.Calendar.Time:= Time(Date); -- or something like that.
> 
> No problem. You would have an equivalent of Year, Month, Day functions
> defined for Date. Then you would call Time_Of. That is.

I actually mentioned the "-" only because it would spare me from having to roll my own to figure out how many days are between D1 and D2. 

But I think that it is probably not necessary at all.

> > So is there an existing package which generates a range of Dates from .. to?
> 
> No, but you could have an abstract iterator for dates in Ada 2012.
> 
> > PS: need this range of dates because the log files I want to read and
> > extract informations from are all named like this: vba-yyyymmdd.log where
> > obviously yyyymmdd is the date. The program generates a new file every
> > date an stores the communication it treated in it.
> 
> See Ada.Calendar.Formatting.Image.

I think getting the names done is the easiest part.

When first took a look at the log files I thought that it would be difficult to extract the informations I am looking for. But no getting some continuous dates from .. to is the real PITA.

Otherwise it would be boring.

Thanks

^ permalink raw reply	[relevance 0%]

* Re: A few questions
  2015-10-31 20:29  6% A few questions Laurent
  2015-10-31 20:49  5% ` Dmitry A. Kazakov
@ 2015-11-01  0:25  6% ` Jeffrey R. Carter
  2015-11-01 13:30  0%   ` Laurent
  2015-11-03  6:25  6%   ` Randy Brukardt
  2015-11-02 17:45  8% ` Simon Wright
  2 siblings, 2 replies; 200+ results
From: Jeffrey R. Carter @ 2015-11-01  0:25 UTC (permalink / raw)


On 10/31/2015 01:29 PM, Laurent wrote:
> 
> I need a range of Dates.
> 
> So is there an existing package which generates a range of Dates from .. to
> ?
> 
> PS: need this range of dates because the log files I want to read and extract
> informations from are all named like this: vba-yyyymmdd.log where obviously
> yyyymmdd is the date. The program generates a new file every date an stores
> the communication it treated in it.
> 
> I want to read this files and extract the messages which passed. Is more an
> exercise than actually a need to do it.

I'm not aware of any such pkg. On the other hand, I'm not sure you need it. Do
you really need to store all the dates in the range? You could process the file
for date D, then the file for date D + 1, ..., until you have processed all the
desired files.

Conceptually the idea of an operation

function "+" (Left : in Dates.Object; Right : in Integer) return Dates.Object;

makes sense; without knowing the details of the implementation of Dates.Object I
have no idea how easy it would be. For Ada.Calendar.Time, one would simply add
Right * Ada.Calendar.Day_Duration'Last.

-- 
Jeff Carter
"Monsieur Arthur King, who has the brain of a duck, you know."
Monty Python & the Holy Grail
09


^ permalink raw reply	[relevance 6%]

* Re: A few questions
  2015-10-31 20:29  6% A few questions Laurent
@ 2015-10-31 20:49  5% ` Dmitry A. Kazakov
  2015-11-01 13:16  0%   ` Laurent
  2015-11-01  0:25  6% ` Jeffrey R. Carter
  2015-11-02 17:45  8% ` Simon Wright
  2 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2015-10-31 20:49 UTC (permalink / raw)


On Sat, 31 Oct 2015 13:29:51 -0700 (PDT), Laurent wrote:

> I need a range of Dates.
>
> So I tried this:
> 
> Begin_Date: Dates.Object; 
> End_Date: Dates.Object;
> -- Dates is a package from an earlier example in my Ada95 book. It is based on Ada.Calendars. I prefer to use
> -- Dates because I actually need only the date, I don't care/ need the hour. I also find the name "Time" for 
> -- something like "2015/10/31 21:00:00" confusing but that's just my opinion.
> 
> That doesn't work unfortunately and the compiler is right to complain:
> 
> subtype Period is range Begin_Date .. End_Date;

1. How is this subtype would be different from Date? 

2. Date is not a numeric type to have ranges

3. Date cannot be a numeric type because arithmetic operations would not
make sense: D1 + D2 is what?

> I naively thought that it could be so easy.

Yes, because it is wrong.

> I have found in Ada.Calendar a: function "-" (L,R:Time) return Duration

Similarly D1 - D2 is a Duration, not a date. Likewise you can add duration
to a date, but not a date to date.

> Is it possible to make a casting to convert my Date type in (Ada.Calendar) Time type:
> 
> Today : Ada.Calendar.Time:= Time(Date); -- or something like that.

No problem. You would have an equivalent of Year, Month, Day functions
defined for Date. Then you would call Time_Of. That is.

> So is there an existing package which generates a range of Dates from .. to?

No, but you could have an abstract iterator for dates in Ada 2012.

> PS: need this range of dates because the log files I want to read and
> extract informations from are all named like this: vba-yyyymmdd.log where
> obviously yyyymmdd is the date. The program generates a new file every
> date an stores the communication it treated in it.

See Ada.Calendar.Formatting.Image.
 
-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

^ permalink raw reply	[relevance 5%]

* A few questions
@ 2015-10-31 20:29  6% Laurent
  2015-10-31 20:49  5% ` Dmitry A. Kazakov
                   ` (2 more replies)
  0 siblings, 3 replies; 200+ results
From: Laurent @ 2015-10-31 20:29 UTC (permalink / raw)


Hi

I need a range of Dates.

So I tried this:

Begin_Date: Dates.Object; 
End_Date: Dates.Object;
-- Dates is a package from an earlier example in my Ada95 book. It is based on Ada.Calendars. I prefer to use
-- Dates because I actually need only the date, I don't care/ need the hour. I also find the name "Time" for 
-- something like "2015/10/31 21:00:00" confusing but that's just my opinion.

That doesn't work unfortunately and the compiler is right to complain:

subtype Period is range Begin_Date .. End_Date;

I naively thought that it could be so easy.

I could solve this problem with a few loops and filling an array or a list with the generated dates but the loop thing will be probably very ugly/complicated. 

For the array I also have to know how many dates I actually have between Begin_Date and End_Date. I have tried to 

I have found in Ada.Calendar a: function "-" (L,R:Time) return Duration

Is it possible to make a casting to convert my Date type in (Ada.Calendar) Time type:

Today : Ada.Calendar.Time:= Time(Date); -- or something like that.

I could of course use the Getters from Dates and then construct a new Time. More of curiosity than an actual problem.

Well of course I could simply use Ada.Calendar.

So is there an existing package which generates a range of Dates from .. to ?
Feels like cheating but causes less frustration. 

 Thanks

Laurent

PS: need this range of dates because the log files I want to read and extract informations from are all named like this: vba-yyyymmdd.log where obviously yyyymmdd is the date. The program generates a new file every date an stores the communication it treated in it.

I want to read this files and extract the messages which passed. Is more an exercise than actually a need to do it.

^ permalink raw reply	[relevance 6%]

* Re: Understanding the dependency to a-calend.adb introduced by gnatcoll-xref.adb in gnatcoll-xref.ali
  2015-08-25  6:44  7% Understanding the dependency to a-calend.adb introduced by gnatcoll-xref.adb in gnatcoll-xref.ali David SAUVAGE
@ 2015-08-25  7:34  0% ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2015-08-25  7:34 UTC (permalink / raw)


David SAUVAGE <david.sauvage@adalabs.com> writes:

> This is a GNAT specific topic, we are trying to understand why a
> dependency to Ada.Calendar implementation is introduced by the
> GNATColl.Xref unit in the gnatcoll-xref.ali [2] Ada Library
> Information [1] file
>
> I would suppose this could be needed in the case of
> generic-related-uses, but as that does not seem to be the case here, I
> would expect only a dependency to a-calend.ads

There are a whole lot of pragma Inline's in Ada.Calendar'spec (in the
private part).

https://gcc.gnu.org/onlinedocs/gnat_ugn/Inlining-of-Subprograms.html

^ permalink raw reply	[relevance 0%]

* Understanding the dependency to a-calend.adb introduced by gnatcoll-xref.adb in gnatcoll-xref.ali
@ 2015-08-25  6:44  7% David SAUVAGE
  2015-08-25  7:34  0% ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: David SAUVAGE @ 2015-08-25  6:44 UTC (permalink / raw)


Hi.all,

This is a GNAT specific topic, we are trying to understand why a dependency to Ada.Calendar implementation is introduced by the GNATColl.Xref unit in the gnatcoll-xref.ali [2] Ada Library Information [1] file

I would suppose this could be needed in the case of generic-related-uses, but as that does not seem to be the case here, I would expect only a dependency to a-calend.ads 

Any feedbacks are most welcome,

Cheers

[1] ALI specifications
http://docs.adacore.com/gnat_ugn-docs/html/gnat_ugn/gnat_ugn/the_gnat_compilation_model.html#the-ada-library-information-files
http://www.seas.gwu.edu/~adagroup/gnat-docs/gnat-3.13p-docs/gnat_ug.html#SEC21
https://www2.adacore.com/gap-static/GNAT_Book/html/frontend/lib-writ__adb.htm


[2] GNAT GPL 2014 version
W ada.calendar%s    a-calend.adb        a-calend.ali
D a-calend.ads		20140406181358 d86d6c8c ada.calendar%s
D a-calend.adb		20140406181357 a0075950 ada.calendar%b

^ permalink raw reply	[relevance 7%]

* Re: Design of cross referring types/classes and proper usage of containers
  2015-08-03 16:08  5% Design of cross referring types/classes and proper usage of containers Serge Robyns
  2015-08-03 16:14  0% ` Serge Robyns
@ 2015-08-03 16:22  0% ` Dmitry A. Kazakov
  1 sibling, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2015-08-03 16:22 UTC (permalink / raw)


On Mon, 3 Aug 2015 09:08:15 -0700 (PDT), Serge Robyns wrote:

> I've a design issue with regards to what is the best if not ideal approach
> in building types or classes that refer to each other and could be
> aggregates.
> 
> Lets use an example  I've the following entity:
> 
>    type T_Client is tagged record  -- will be mapped a table
>       Id         : Integer := 0;
>       First_Name : T_Client_Name := T_Client_Name (P_Empty_String);
>       Last_Name  : T_Client_Name := T_Client_Name (P_Empty_String);
>    end record;
> 
> This is to keep track of client info.
> 
> I've the following other entity amongst others.
> 
>    type T_Subscription is tagged record  -- will be mapped to a table
>       Name    : T_Subscriptiont_Name := No_Subscription_Name;
>       Product : T_Product_Name := No_Product_Name;
>       Client  : T_Client := No_Client;   -- Could also be of the same type T_Client.Id, used in different approach.
>       Date    : Ada.Calendar.Time := GNAT.Calendar.No_Time;
>    end record;
> 
> And I've other entities as well that do have similar relationships.

When aggregation does not work, which is the case when relationships are
complex, you keep them outside. You create maps

   Client to [not null access] Subscription
   Subscription to [not null access] Client

etc. And search the maps if you have one and need another. For the map you
can use hash or binary searched container.

Note that aggregation is fragile. If you have a suspicion that
relationships may go chaotic, don't aggregate.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[relevance 0%]

* Re: Design of cross referring types/classes and proper usage of containers
  2015-08-03 16:08  5% Design of cross referring types/classes and proper usage of containers Serge Robyns
@ 2015-08-03 16:14  0% ` Serge Robyns
  2015-08-03 16:22  0% ` Dmitry A. Kazakov
  1 sibling, 0 replies; 200+ results
From: Serge Robyns @ 2015-08-03 16:14 UTC (permalink / raw)


On Monday, 3 August 2015 18:08:17 UTC+2, Serge Robyns  wrote:
> I've a design issue with regards to what is the best if not ideal approach in building types or classes that refer to each other and could be aggregates.
> 
> Lets use an example  I've the following entity:
> 
>    type T_Client is tagged record  -- will be mapped a table
>       Id         : Integer := 0;
>       First_Name : T_Client_Name := T_Client_Name (P_Empty_String);
>       Last_Name  : T_Client_Name := T_Client_Name (P_Empty_String);
>    end record;
> 
> This is to keep track of client info.
> 
> I've the following other entity amongst others.
> 
>    type T_Subscription is tagged record  -- will be mapped to a table
>       Name    : T_Subscriptiont_Name := No_Subscription_Name;
>       Product : T_Product_Name := No_Product_Name;
>       Client  : T_Client := No_Client;   -- Could also be of the same type T_Client.Id, used in different approach.
>       Date    : Ada.Calendar.Time := GNAT.Calendar.No_Time;
>    end record;
> 
> And I've other entities as well that do have similar relationships.
> 
> The application is keeping parts of the (static) data in memory but eventually all the data will be retrieved and stored into a database.  I'm planning to use a design pattern (bridge or others) to implemnent this step.
> 
> However, I'm wondering what would be the best Ada approach to have these objects interacting, i.e, referring to each other.  Currently I'm using the db approach, which means I use keys to search in various independant containers.
> 
> But why not for example, Client that could have an Ada container of T_Subscriptions.  This container could be either the object itself or a reference (access) or why not a Cursor to another Container containing all subscriptions.  The same applies for the client in the subscription.
> 
> And I've a few other of such entities/cases.
> 
> I'm all ears to the audience experience in this matter.
> 
> Regards,
> Serge

And I forgot to mention, I'm trying to avoid access as much as possible, where it makes sense.  In my C-days, I would have independant containers and use references/pointers.


^ permalink raw reply	[relevance 0%]

* Design of cross referring types/classes and proper usage of containers
@ 2015-08-03 16:08  5% Serge Robyns
  2015-08-03 16:14  0% ` Serge Robyns
  2015-08-03 16:22  0% ` Dmitry A. Kazakov
  0 siblings, 2 replies; 200+ results
From: Serge Robyns @ 2015-08-03 16:08 UTC (permalink / raw)


I've a design issue with regards to what is the best if not ideal approach in building types or classes that refer to each other and could be aggregates.

Lets use an example  I've the following entity:

   type T_Client is tagged record  -- will be mapped a table
      Id         : Integer := 0;
      First_Name : T_Client_Name := T_Client_Name (P_Empty_String);
      Last_Name  : T_Client_Name := T_Client_Name (P_Empty_String);
   end record;

This is to keep track of client info.

I've the following other entity amongst others.

   type T_Subscription is tagged record  -- will be mapped to a table
      Name    : T_Subscriptiont_Name := No_Subscription_Name;
      Product : T_Product_Name := No_Product_Name;
      Client  : T_Client := No_Client;   -- Could also be of the same type T_Client.Id, used in different approach.
      Date    : Ada.Calendar.Time := GNAT.Calendar.No_Time;
   end record;

And I've other entities as well that do have similar relationships.

The application is keeping parts of the (static) data in memory but eventually all the data will be retrieved and stored into a database.  I'm planning to use a design pattern (bridge or others) to implemnent this step.

However, I'm wondering what would be the best Ada approach to have these objects interacting, i.e, referring to each other.  Currently I'm using the db approach, which means I use keys to search in various independant containers.

But why not for example, Client that could have an Ada container of T_Subscriptions.  This container could be either the object itself or a reference (access) or why not a Cursor to another Container containing all subscriptions.  The same applies for the client in the subscription.

And I've a few other of such entities/cases.

I'm all ears to the audience experience in this matter.

Regards,
Serge

^ permalink raw reply	[relevance 5%]

* Re: Running a preprocessor from GPS?
  @ 2015-08-01 20:30  6%                                           ` Georg Bauhaus
  0 siblings, 0 replies; 200+ results
From: Georg Bauhaus @ 2015-08-01 20:30 UTC (permalink / raw)


On 01.08.15 20:15, Paul Rubin wrote:
> "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org> writes:
>> The pkg is a very important concept in Ada, and your insistence that there has
>> to be a Get_Instance function shows that you don't fully understand it yet.
>> Until you do, you won't really understand Ada.
>
> Is there a good place to read about this?  I had the impression that
> package initialization runs unconditionally.  EGarrulo was asking how to
> get it to run only in response to a runtime request that might never
> happen.


I'm sneaking this in here. A generic instance has context, sometimes
non-static context, on which it depends:

with Ada.Text_IO;
with Ada.Calendar;  use Ada.Calendar;

procedure Late is
    
    Start : Time;
    
    generic
       Now : Time;
    package Again is
       --  tells the time
    end Again;
    
    package body Again is
    begin
       Ada.Text_IO.Put_Line (Duration'Image (Now - Start));
    end Again;
    
begin
    Start := Clock;
    loop
       delay 1.0;
       declare
          package Tick is new Again (Now => Clock);
       begin
          null;
       end;
    end loop;
end Late;



^ permalink raw reply	[relevance 6%]

* Re: Time_Zone-aware Day_of_Week ?
  2015-07-13 16:45  7% ` Jeffrey R. Carter
@ 2015-07-16 17:07  0%   ` brbarkstrom
  0 siblings, 0 replies; 200+ results
From: brbarkstrom @ 2015-07-16 17:07 UTC (permalink / raw)


On Monday, July 13, 2015 at 12:45:48 PM UTC-4, Jeffrey R. Carter wrote:
> On 07/13/2015 06:26 AM, Natasha Kerensikova wrote:
> > 
> > Moreover, the description in the ARM of the function is quite terse:
> > "Returns the day of the week for Time. This is based on the Year, Month,
> > and Day values of Time."
> 
> Presumably the Year, Month, and Day returned by Ada.Calendar.Split.
> 
> > However, all of Year, Month and Day functions do have the Time_Zone
> > argument that Day_of_Week lacks. So which time offset is Day_of_Week
> > supposed to use?
> 
> I'd guess the time offset given by Ada.Calendar.Time_Zones.UTC_Time_Offset.
> 
> PragmARC.Date_Handler.Day_Of_Week gives you the day of week of any Year, Month,
> and Day CE you care to give it, even for values of Year outside
> Ada.Calendar.Year_Number. It can also give you the day of week for any
> Ada.Calendar.Time, using the Year, Month, and Day returned by Ada.Calendar.Split.
> 
> The PragmAda Reusable Components are at
> 
> https://pragmada.x10hosting.com/pragmarc.htm
> 
> -- 
> Jeff Carter
> "He that hath no beard is less than a man."
> Much Ado About Nothing
> 132

Depending on the precision you need, it might be worth thinking about
the difference between Civil Time (which uses Year, Month, Day, Hour,
Minute, and Second) and International Atomic Time (TAI - due to French
Standards).  TAI tracks seconds and is directly related to
GPS Time and one or two other variants.  The standard reference for
these different time systems is Seidelmann, P. K., 2006: Explanatory
Supplement to the Astronomical Almanac, University Science Books, 
Sausalito, CA.  If you need to calculate time differences frequently
and want to avoid the unpleasantries of having to deal with errors 
associated with time zone inputs (or lack thereof), TAI is probably
preferable.  This may be important for Fourier analysis of time series,
where the incomensurability of Civil Time can introduces errors into the
frequency spectrum derived from the data.  One satellite mission had to
expend a great deal of effort to find that the lack of a common time basis
caused some serious errors in their measurements of the Earth's reflection.

Bruce B.

^ permalink raw reply	[relevance 0%]

* Re: Time_Zone-aware Day_of_Week ?
  2015-07-13 13:26  6% Time_Zone-aware Day_of_Week ? Natasha Kerensikova
@ 2015-07-13 16:45  7% ` Jeffrey R. Carter
  2015-07-16 17:07  0%   ` brbarkstrom
  0 siblings, 1 reply; 200+ results
From: Jeffrey R. Carter @ 2015-07-13 16:45 UTC (permalink / raw)


On 07/13/2015 06:26 AM, Natasha Kerensikova wrote:
> 
> Moreover, the description in the ARM of the function is quite terse:
> "Returns the day of the week for Time. This is based on the Year, Month,
> and Day values of Time."

Presumably the Year, Month, and Day returned by Ada.Calendar.Split.

> However, all of Year, Month and Day functions do have the Time_Zone
> argument that Day_of_Week lacks. So which time offset is Day_of_Week
> supposed to use?

I'd guess the time offset given by Ada.Calendar.Time_Zones.UTC_Time_Offset.

PragmARC.Date_Handler.Day_Of_Week gives you the day of week of any Year, Month,
and Day CE you care to give it, even for values of Year outside
Ada.Calendar.Year_Number. It can also give you the day of week for any
Ada.Calendar.Time, using the Year, Month, and Day returned by Ada.Calendar.Split.

The PragmAda Reusable Components are at

https://pragmada.x10hosting.com/pragmarc.htm

-- 
Jeff Carter
"He that hath no beard is less than a man."
Much Ado About Nothing
132

^ permalink raw reply	[relevance 7%]

* Time_Zone-aware Day_of_Week ?
@ 2015-07-13 13:26  6% Natasha Kerensikova
  2015-07-13 16:45  7% ` Jeffrey R. Carter
  0 siblings, 1 reply; 200+ results
From: Natasha Kerensikova @ 2015-07-13 13:26 UTC (permalink / raw)


Hello,

I was implementing some human time formatting with the help of Ada 2005
standard package Ada.Calendar.Formatting, and realized I have an issue
with the function Day_of_Week with regards to time zone.

Everything else in Ada.Calendar.Formatting seems to support some
user-defined time offset, but not Day_of_Week. Is there a particular
reason for that?

Moreover, the description in the ARM of the function is quite terse:
"Returns the day of the week for Time. This is based on the Year, Month,
and Day values of Time."

However, all of Year, Month and Day functions do have the Time_Zone
argument that Day_of_Week lacks. So which time offset is Day_of_Week
supposed to use?

Prying into GNAT's implementation, it seems to use standard system
timezone, but can it be deduced from the ARM?

Is there a workaround to still get a Day_of_Week result that is
consistent with a user-given time offset?

I'm currently leaning towards using Ada.Calendar.Arithmetic.Difference
with a reference date, at midnight in the request time zone, but that
feels a bit inelegant. Is there a better way of doing it?


Thanks for your help,
Natasha


^ permalink raw reply	[relevance 6%]

* Re: What do you think about this?
  @ 2015-06-23 19:51  4%             ` Laurent
  0 siblings, 0 replies; 200+ results
From: Laurent @ 2015-06-23 19:51 UTC (permalink / raw)


On Tuesday, 23 June 2015 16:21:17 UTC+2, Stephen Leake  wrote:
> I did not download and compile it, but I did browse around it a bit.

That's why I like git.

> The code looks clean and well-organized,

Ok that is already a good thing to hear.

>What is the whole thing supposed to do?

It is supposed to generate something like this:

mtrsl|pi12345678910|p2164|pp907088|p5907088|si|s040330|ssPLAIES|s5PLAIES|ci501502240387|c040330|ctAERO|ta|rtAST-N264|rr10335191|t12|o1esccol|ra|a1tem|a3<=4|a4S|ra|a1am|a34|a4S|ra|a1amc|a34|a4S|ra|a1tzp|a3<=4|a4S|ra|a1rox|a34|a4S|ra|a1tax|a3<=1|a4S|ra|a1taz|a3<=1|a4S|ra|a1fep|a3<=1|a4S|ra|a1etp|a3<=0,5|a4S|ra|a1mem|a3<=0,25|a4S|ra|a1an|a3<=2|a4S|ra|a1gm|a3<=1|a4S|ra|a1cip|a3<=0,25|a4S|ra|a1lev|a3<=0,12|a4S|ra|a1tgc|a3<=0,5|a4S|ra|a1fos|a3<=16|a4S|ra|a1ftn|a3<=16|a4S|ra|a1sxt|a3<=20|a4S|zz|

And then write it in a text file. 

The hospital I work for has acquired a new software for epidemical surveillance. I work in the lab in the microbiology department and I have been asked to verify the transmission of the results from the analyzer to the software used by the nurses/docters. 

I have 3 possibilities to do that:

1) launch tests but that takes 24hrs and I have no influence on the result
2) use existing tests and rename them. Which means I have to tinker around with results of actual patients. Is bad because of the iso certification which requires everything to be traceable. No influence on the result
3) write a program which generates textfiles with random results which I can copy into the transfer folder on the analyzer. 

> What is a "antibiogramme"?

The analyzer is testing the susceptibility of a bacteria against a number of antibiotics. The whole result is called an antibiogramme. 

The CMI (MIC in english) is the "minimum inhibitory concentration" that is the lowest concentration of the antibiotic required to kill 99.9% of the bacteria. 

There are breakpoints for every antibiotic which define if it is S = sensible, I = intermediate (could work) or R = resistant. That is called the susceptibility.

> What is a "dossier"?

medical file in this case. I am used to the french names of the whole stuff so I used them everywhere.

>but it lacks comments

Yup something I have to improve. In this case the program is only used by me and quite probable only once. As well as a todo list so that I remember where I left in the case I don't work on a project for longer time.

> There are cases where a function returns a V_String but could return a
> plain String; in general, unless the result _must_ be a V_String for
> some reason, it is better to return a String; then the caller can just
> use it without conversion, or declare a local variable to hold it.

I have quite often problems with different string types and their behavior. So I followed  Bruce B's
recommendation (some earlier post: "Annoying behavior") to make a package:

with Ada.Strings.Bounded;
with Ada.Strings.Fixed;

package Common_Defs_BCI is

   V_String_Length  : constant :=  64;

   package V_String is new
     Ada.Strings.Bounded.Generic_Bounded_Length (V_String_Length);

   function "+" (Right : V_String.Bounded_String) return String
                 renames
     V_String.To_String;

   function "+" (Right : String) return V_String.Bounded_String
   is (V_String.To_Bounded_String (Right));

   function Trim (Right : String) return V_String.Bounded_String is
     (V_String.To_Bounded_String (Ada.Strings.Fixed.Trim (Right, Ada.Strings.Both)));

end Common_Defs_BCI;

So no more confusion with different string types. 

>... it is better to return a String; then the caller can just use it without conversion, or declare a >local variable to hold it.

Well without the "+" conversion function I would agree because the To_Bound... thing is annoying.
For the last part I don't understand what you mean. In the main file I have the function Make_File_Name where File_Name is local variable. If it is of type String or the custom V_String, where is the difference? Ok I have to convert it later in procedure Generate. Requires an additional "+". I find it is a quite good tradeoff for the flexibility it offers me. 

If you have an example where you think that it is not recommended I'd like to see. I have of course no idea how expensive that is in terms of computation power.

   function Make_File_Name (How_Many : in Positive) return V_String.Bounded_String is

      File_Name : V_String.Bounded_String;

      Right_Now : Ada.Calendar.Time := Ada.Calendar.Clock;...

   begin
     ...
      File_Name := +("VITEK2-BCI_" &...;
      return File_Name;
   end Make_File_Name;

 procedure Generate (How_Many : in Positive) is

      File : Ada.Text_IO.File_Type;
   begin -- Generate
      for Counter in 1 .. How_Many loop

         declare
--  removed the declaration of the different objects
         begin -- declare
            Ada.Text_IO.Create (File => File,
                                Mode => Ada.Text_IO.Out_File,
                                Name => +Make_File_Name (Counter)); <---

            BCI_Messages.IO.To_BCI (Item => Test_Message, File => File);
            Ada.Text_IO.Close (File);
         end; -- declare
      end loop;
   end Generate;

For the CMI I would have preferred to use enumerations but that doesn't seem to be possible:

CMI_Type is ("<=1","0,004","3"); or CMI_Type is ("1","2","3"); 

but that works CMI_Type is ('1','2','3'); ?

For the SIR I have used an enumeration at the beginning but I had some problems getting the result written to the text file. So the V_String solved most of the problems.

I have to wait for the person which takes care of the informatics in the lab before I inject the text files into the analyzer. Would be stupid to blow up the online connections with an ill formatted result and no one there to restore them.

Thanks Stephen for your time and comments.

Laurent


^ permalink raw reply	[relevance 4%]

* Re: Is there an easier way for this?
  2015-06-21 19:25  7% ` Jeffrey R. Carter
@ 2015-06-21 19:42  0%   ` Laurent
    1 sibling, 0 replies; 200+ results
From: Laurent @ 2015-06-21 19:42 UTC (permalink / raw)


On Sunday, 21 June 2015 21:25:39 UTC+2, Jeffrey R. Carter  wrote:
> You could do
> 
> Year    : Ada.Calendar.Year_Number;
> Month   : Ada.Calendar.Month_Number;
> Day     : Ada.Calendar.Day_Number;
> Hour    : PragmARC.Date_Handler.Hour_Number;
> Minute  : PragmARC.Date_Handler.Minute_Number;
> Seconds : PragmARC.Date_Handler.Minute_Duration;
> 
> PragmARC.Date_Handler.Split (Year    => Year,
>                              Month   => Month,
>                              Day     => Day,
>                              Hour    => Hour,
>                              Minute  => Minute,
>                              Seconds => Seconds);
> 
> "VITEK2-BCI_" &
> PragmARC.Date_Handler.Year_Image_Short (Year) &
> PragmARC.Date_Handler.Month_Image_Numeric (Month) &
> PragmARC.Date_Handler.Day_Image (Day) &
> '_' &
> PragmARC.Date_Handler.Hour_Image_24 (Hour) &
> PragmARC.Date_Handler.Minute_Image (Minute) &
> PragmARC.Date_Handler.Seconds_Image (Seconds) &
> '_' &
> PragmARC.Images.Image (How_Many) &
> ".txt";

Thanks that would be a reason to finally take a look at this package.


^ permalink raw reply	[relevance 0%]

* Re: Is there an easier way for this?
  2015-06-21 19:15  6% ` Niklas Holsti
@ 2015-06-21 19:41  0%   ` Laurent
  0 siblings, 0 replies; 200+ results
From: Laurent @ 2015-06-21 19:41 UTC (permalink / raw)


On Sunday, 21 June 2015 21:15:30 UTC+2, Niklas Holsti  wrote:

> Have you looked at Ada.Calendar.Formatting?
> 
> http://www.ada-auth.org/standards/12rm/html/RM-9-6-1.html#I4152
> 
> There is an Image function there which shows an Ada.Calendar.Time as 
> yyyy-mm-dd hh:mm:ss; you could construct your file name by taking 
> suitable substrings.

Yes I have seen this one but I don't know why I didn't follow it further. Tunnel vision I suppose.

Thanks

^ permalink raw reply	[relevance 0%]

* Re: Is there an easier way for this?
  2015-06-21 18:38  7% Is there an easier way for this? Laurent
  2015-06-21 19:15  6% ` Niklas Holsti
@ 2015-06-21 19:25  7% ` Jeffrey R. Carter
  2015-06-21 19:42  0%   ` Laurent
    1 sibling, 2 replies; 200+ results
From: Jeffrey R. Carter @ 2015-06-21 19:25 UTC (permalink / raw)


On 06/21/2015 11:38 AM, Laurent wrote:
> 
> I need a function which generates some specific file names:
> 
> VITEK2-BCI_yymmdd_hhmmss_x.txt
> 
> where yymmdd is the current date, hhmmss the current time and x the number of txt files. No idea if x 
> actually important.

You could do

Year    : Ada.Calendar.Year_Number;
Month   : Ada.Calendar.Month_Number;
Day     : Ada.Calendar.Day_Number;
Hour    : PragmARC.Date_Handler.Hour_Number;
Minute  : PragmARC.Date_Handler.Minute_Number;
Seconds : PragmARC.Date_Handler.Minute_Duration;

PragmARC.Date_Handler.Split (Year    => Year,
                             Month   => Month,
                             Day     => Day,
                             Hour    => Hour,
                             Minute  => Minute,
                             Seconds => Seconds);

"VITEK2-BCI_" &
PragmARC.Date_Handler.Year_Image_Short (Year) &
PragmARC.Date_Handler.Month_Image_Numeric (Month) &
PragmARC.Date_Handler.Day_Image (Day) &
'_' &
PragmARC.Date_Handler.Hour_Image_24 (Hour) &
PragmARC.Date_Handler.Minute_Image (Minute) &
PragmARC.Date_Handler.Seconds_Image (Seconds) &
'_' &
PragmARC.Images.Image (How_Many) &
".txt";

The PragmAda Reusable Components are at

https://pragmada.x10hosting.com/pragmarc.htm

-- 
Jeff Carter
"Brave Sir Robin ran away."
Monty Python and the Holy Grail
59


^ permalink raw reply	[relevance 7%]

* Re: Is there an easier way for this?
  2015-06-21 18:38  7% Is there an easier way for this? Laurent
@ 2015-06-21 19:15  6% ` Niklas Holsti
  2015-06-21 19:41  0%   ` Laurent
  2015-06-21 19:25  7% ` Jeffrey R. Carter
  1 sibling, 1 reply; 200+ results
From: Niklas Holsti @ 2015-06-21 19:15 UTC (permalink / raw)


On 15-06-21 21:38 , Laurent wrote:
> Hi
>
> I need a function which generates some specific file names:
>
> VITEK2-BCI_yymmdd_hhmmss_x.txt
>
> where yymmdd is the current date, hhmmss the current time and x the number of txt files. No idea if x
> actually important.
>
> I have tinkered this together but I find it quite horrible. Is there a more elegant way to do it?
>
>     function Make_File_Name (How_Many : in Positive) return V_String.Bounded_String is
>
>        use V_String;
>
>        File_Name : V_String.Bounded_String:= (+"VITEK2-BCI_");
>        Temp      : V_String.Bounded_String;
>
>        Right_Now : Ada.Calendar.Time := Ada.Calendar.Clock;
>        Y         : Positive := Ada.Calendar.Year (Right_Now) rem 100;
>        M         : Positive := Ada.Calendar.Month (Right_Now);
>        D         : Positive := Ada.Calendar.Day (Right_Now);

(rest of code snipped)

Have you looked at Ada.Calendar.Formatting?

http://www.ada-auth.org/standards/12rm/html/RM-9-6-1.html#I4152

There is an Image function there which shows an Ada.Calendar.Time as 
yyyy-mm-dd hh:mm:ss; you could construct your file name by taking 
suitable substrings.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .

^ permalink raw reply	[relevance 6%]

* Is there an easier way for this?
@ 2015-06-21 18:38  7% Laurent
  2015-06-21 19:15  6% ` Niklas Holsti
  2015-06-21 19:25  7% ` Jeffrey R. Carter
  0 siblings, 2 replies; 200+ results
From: Laurent @ 2015-06-21 18:38 UTC (permalink / raw)


Hi

I need a function which generates some specific file names:

VITEK2-BCI_yymmdd_hhmmss_x.txt

where yymmdd is the current date, hhmmss the current time and x the number of txt files. No idea if x 
actually important.

I have tinkered this together but I find it quite horrible. Is there a more elegant way to do it?

   function Make_File_Name (How_Many : in Positive) return V_String.Bounded_String is
      
      use V_String;
      
      File_Name : V_String.Bounded_String:= (+"VITEK2-BCI_");
      Temp      : V_String.Bounded_String;
      
      Right_Now : Ada.Calendar.Time := Ada.Calendar.Clock;
      Y         : Positive := Ada.Calendar.Year (Right_Now) rem 100;
      M         : Positive := Ada.Calendar.Month (Right_Now);
      D         : Positive := Ada.Calendar.Day (Right_Now);
      
      Secs_Past_Midnight : Natural;
      Mins_Past_Midnight : Natural;
      Secs          : Natural;
      Mins          : Natural;                                    
      Hrs           : Natural;

   begin
      
      Secs_Past_Midnight := Natural (Ada.Calendar.Seconds (Right_Now));
      Mins_Past_Midnight := Secs_Past_Midnight / 60;
      Secs          := Secs_Past_Midnight rem 60;
      Mins          := Mins_Past_Midnight rem 60;
      Hrs           := Mins_Past_Midnight / 60;
      
      if Y < 10 then
         Temp := (+"0" & Trim(Y'Img));
         File_Name := File_Name & Temp;
      else
         Temp := Trim (Y'Img);
         File_Name := File_Name & Temp;
      end if;
      
      if M < 10 then
         Temp := (+"0" & Trim(M'Img));
         File_Name := File_Name & Temp;
      else
         Temp := Trim (M'Img);
         File_Name := File_Name & Temp;
      end if;
      
      if D < 10 then
         Temp := (+"0" & Trim(D'Img));
         File_Name := File_Name & Temp;
      else
         Temp := Trim (D'Img);
         File_Name := File_Name & Temp;
      end if;
      
      File_Name := File_Name & "_";
      
            if Hrs < 10 then
         Temp := (+"0" & Trim(Hrs'Img));
         File_Name := File_Name & Temp;
      else
         Temp := Trim (Hrs'Img);
         File_Name := File_Name & Temp;
      end if;
      
      if Mins < 10 then
         Temp := (+"0" & Trim(Mins'Img));
         File_Name := File_Name & Temp;
      else
         Temp := Trim (Mins'Img);
         File_Name := File_Name & Temp;
      end if;
      
      if Secs < 10 then
         Temp := (+"0" & Trim(Secs'Img));
         File_Name := File_Name & Temp;
      else
         Temp := Trim (Secs'Img);
         File_Name := File_Name & Temp;
      end if;
     
      File_Name := File_Name & "_";
      File_Name := File_Name & Trim (How_Many'Img) & ".txt";      
      
      return File_Name;
      
   end Make_File_Name;

Thanks

Laurent


^ permalink raw reply	[relevance 7%]

* Re: I've not seen this error before
  2015-04-01 13:08  0% ` Simon Wright
@ 2015-04-01 13:18  5%   ` tonyg
  0 siblings, 0 replies; 200+ results
From: tonyg @ 2015-04-01 13:18 UTC (permalink / raw)


I don't have any controlled types. I've never worked out how to use them :)

The only possibility I think is Ada.Calendar.Time which I think is a private type but not a controlled type.

Device_Class_Type is an enumerated type with three values.

This all seemed to happen when I started storing records in files.So I've now got a task which loads the file at the start then looks at a queue then sticks those changes back in the file.

^ permalink raw reply	[relevance 5%]

* Re: I've not seen this error before
  2015-04-01  8:42  4% I've not seen this error before tonyg
@ 2015-04-01 13:08  0% ` Simon Wright
  2015-04-01 13:18  5%   ` tonyg
  0 siblings, 1 reply; 200+ results
From: Simon Wright @ 2015-04-01 13:08 UTC (permalink / raw)


tonyg <tonythegair@gmail.com> writes:

> 2015-04-01 09:19:32.10 : Exception name: PROGRAM_ERROR
> Message: adjust/finalize raised PROGRAM_ERROR: device_type_pkg.ads:115 finalize/adjust raised exception
>
> the code is an ada specification
>
>  type Device_Details_Type is record
>       Device_Id : Device_Index_Type;
>       The_Device : Device_Class_Type;
>       Room_Id : Room_Id_Type;
>       The_Id : Domoticz_ID_Type;
>       Battery_Level : Battery_Level_Type;
>       Signal_Level : Signal_Level_Type;
>       Name : SU.Unbounded_String;
>       Last_Update : AC.Time;
>       Used : boolean ;
>       Successful_Initialisation : boolean := false;
>       Temperature : Temp_Xten_Type;
>       Protected_Device : boolean; 
>    end record;

>    procedure Set_Device (Device : in Device_Details_Type) is
>         
>       begin

>             Device_Array(Device.Device_Id) :=Device;   -- LINE 694 where the error is reported

> The array that is being written to is a fixed array. There is a value
> of Ada.Calendar.Time in the record but I cannot see why this would
> cause the problem

To get that exception you're going to have a controlled type somewhere,
very likely one of yours, and very likely to be found at
device_type_pkg.ads:115 (I'm guessing, some ancestor in the
Device_Class_Type tree? do you have some reason for naming this type
instead of just using Device'Class or (ugh) Device_Type'Class?).

At line 694 you are overwriting whatever was at
Device_Array(Device.Device_Id); full explanation of what this involves
starting at ARM 7.6(17).

Any unhandled exception raised in Initialize (?), Adjust (?) or Finalize
is going to be converted to PE. See ARM 7.6.1(14) ff.

You could always use the debugger and break on exceptions (e.g "catch
exception program_error").

^ permalink raw reply	[relevance 0%]

* I've not seen this error before
@ 2015-04-01  8:42  4% tonyg
  2015-04-01 13:08  0% ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: tonyg @ 2015-04-01  8:42 UTC (permalink / raw)



2015-04-01 09:19:32.10 : Exception name: PROGRAM_ERROR
Message: adjust/finalize raised PROGRAM_ERROR: device_type_pkg.ads:115 finalize/adjust raised exception

the code is an ada specification

 type Device_Details_Type is record
      Device_Id : Device_Index_Type;
      The_Device : Device_Class_Type;
      Room_Id : Room_Id_Type;
      The_Id : Domoticz_ID_Type;
      Battery_Level : Battery_Level_Type;
      Signal_Level : Signal_Level_Type;
      Name : SU.Unbounded_String;
      Last_Update : AC.Time;
      Used : boolean ;
      Successful_Initialisation : boolean := false;
      Temperature : Temp_Xten_Type;
      Protected_Device : boolean; 
   end record;

The stack trace passed through addr2line (etc) is different

/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:694 (discriminator 3)
/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:689
/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:342
/home/tony/Dropbox/source/common/schedules_rooms_devices_indexes_pkg.adb:356 (discriminator 2)
/home/tony/Dropbox/source/common/data_feed_update_pkg.adb:73 (discriminator 2)
/home/tony/Dropbox/source/common/data_feed_update_pkg.adb:48
/home/tony/Dropbox/source/common/data_feed_update_pkg.adb:41
/home/tony/Dropbox/source/common/decision_maker_pkg.adb:29 (discriminator 2)
s-tassta.adb:?

which is this and is a procedural call inside a protected object

   procedure Set_Device (Device : in Device_Details_Type) is
        
      begin
         if Initialised then
            gnoga.log("Device id " & Device.Device_Id'img);
            Device_Array(Device.Device_Id) :=Device;   -- LINE 694 where the error is reported
            if Device.Device_Id > 0 then
               Device_File_Storage.Save_Record (File_Item => Device,
                                               To => Device.Device_Id);
            else
               Gnoga.log ("Zero Device Id Device Record  NOT SAVED TO DISK");
            end if;

         else
            Gnoga.Log("Devices not loaded from disk");
         end if;

        
      exception
         when E : others => Gnoga.log (Ada.Exceptions.Exception_Information (E));

      end Set_Device;


The array that is being written to is a fixed array. There is a value of Ada.Calendar.Time in the record but I cannot see why this would cause the problem

^ permalink raw reply	[relevance 4%]

* Did I find mamory leak in Generic Image Decoder (GID) ?
@ 2015-02-02  5:50  5% reinkor
  0 siblings, 0 replies; 200+ results
From: reinkor @ 2015-02-02  5:50 UTC (permalink / raw)


Dear All,

I tried out GID (Generic Image Decoder) from

http://sourceforge.net/projects/gen-img-dec/

The point was to read jpeg-images from my Ada program
"wrapped" in a function:

  function  read_jpg(cfile_jpg : String) return image1.imgc_t;

The source code is below. However, this function seems to eat memory
during (say 200) repeated calls to it (large images, 2000x1800 pixels each).

I did something very very stupid ?

reinert

----------------------------------------------------------------------

Here is the actual code:

with Ada.Streams.Stream_IO;
use Ada.Streams.Stream_IO;

with Ada.Characters.Latin_1;

with Interfaces.C;
with Interfaces.C.Strings;

with system;
with Ada.Unchecked_Conversion;
with Interfaces;

with GID;
with Ada.Calendar;
with Ada.Characters.Handling;           use Ada.Characters.Handling;
with Ada.Text_IO;                       use Ada.Text_IO;
with Ada.Unchecked_Deallocation;

with Text_IO; use Text_IO;




package body file_handling3 is

  package Int_Io is new Text_IO.Integer_Io (Integer);
  use Int_Io;

  use Interfaces;

  type Byte_Array is array(Integer range <>) of Unsigned_8;
  type p_Byte_Array is access Byte_Array;
  procedure Dispose is new Ada.Unchecked_Deallocation(Byte_Array, p_Byte_Array);


  img_buf: p_Byte_Array := null;

  procedure Free_buf is new Ada.Unchecked_Deallocation(Object => Byte_Array, Name => p_Byte_Array);

  procedure Load_raw_image(
    image : in out GID.Image_descriptor;
    buffer: in out p_Byte_Array;
    next_frame: out Ada.Calendar.Day_Duration
  )
  is
    subtype Primary_color_range is Unsigned_8;
    image_width : constant Positive:= GID.Pixel_Width(image);
    image_height: constant Positive:= GID.Pixel_height(image);
    idx: Natural;
    --
    procedure Set_X_Y (x, y: Natural) is
    begin
      idx:= 3 * (x + image_width * (image_height - 1 - y));
    end Set_X_Y;
    --
    procedure Put_Pixel (
      red, green, blue : Primary_color_range;
      alpha            : Primary_color_range
    )
    is
    pragma Warnings(off, alpha); -- alpha is just ignored
    begin
      buffer(idx..idx+2):= (red, green, blue);
      idx:= idx + 3;
      -- ^ GID requires us to look to next pixel on the right for next time.
    end Put_Pixel;

    stars: Natural:= 0;
    procedure Feedback(percents: Natural) is
      so_far: constant Natural:= percents / 5;
    begin
      for i in stars+1..so_far loop
        Put( Standard_Error, '*');
      end loop;
      stars:= so_far;
    end Feedback;

    procedure Load_image is
      new GID.Load_image_contents(
        Primary_color_range, Set_X_Y,
        Put_Pixel, Feedback, GID.fast
      );

  begin
    Dispose(buffer);
    buffer:= new Byte_Array(0..3 * image_width * image_height - 1);
    Load_image(image, next_frame);
  end Load_raw_image;



 function read_jpg(cfile_jpg : String) return image1.imgc_t is
    f: Ada.Streams.Stream_IO.File_Type;
    i: GID.Image_descriptor;
    name : String := cfile_jpg;
    up_name: constant String:= To_Upper(name);
    next_frame, current_frame: Ada.Calendar.Day_Duration:= 0.0;
    isx,isy : Integer;
 begin

    Open(f, In_File, name);
    GID.Load_image_header(
      i,
      Stream(f).all,
      try_tga =>
        name'Length >= 4 and then
        up_name(up_name'Last-3..up_name'Last) = ".TGA"
    );
    Load_raw_image(i, img_buf, next_frame);
    Close(f);
    isx := GID.Pixel_Width(i);
    isy := GID.Pixel_Height(i);
    New_line;
    Put(" isx,isy: ");Put(Integer'Image(isx));Put(Integer'Image(isy));
    New_line;

    declare
      img1 : image1.imgc_t(1..isx,1..isy) := (others => (others => image1.Black));
      Index : Positive;
    begin
      Index := img_buf'First;
      for j in img1'Range (2) loop
          for i in img1'Range (1) loop
              img1(i,isy - j + 1).red   := image1.Short_I(img_buf (Index + 0));
              img1(i,isy - j + 1).green := image1.Short_I(img_buf (Index + 1));
              img1(i,isy - j + 1).blue  := image1.Short_I(img_buf (Index + 2));
              Index := Index + 3;
          end loop;
      end loop;
      Free_buf(img_buf);

      return img1;
    end;
 end read_jpg;

end file_handling3;

^ permalink raw reply	[relevance 5%]

* Re: Generics crash course
  @ 2015-01-16  5:14  3% ` Jeffrey Carter
  0 siblings, 0 replies; 200+ results
From: Jeffrey Carter @ 2015-01-16  5:14 UTC (permalink / raw)


On 01/15/2015 08:44 PM, John Smith wrote:
> 
> What I don't understand is from lines 12 to 21.  How does this work exactly?
> I mean, does this somehow "connect" the overloaded < operator to the Search
> procedure?

You can think of a generic as a kind of template for producing actual packages
and subprograms (the example here has a generic procedure). Lines 12-21 are the
"generic formal part" that specifies the "generic formal parameters". These tell
the user what needs to be provided to use the generic. The rest of the generic
is written in terms of these parameters. The instantiation (line 73) creates an
actual procedure (in this case) from the generic that acts upon the actual
parameters in the instantiation in place of the formal parameters.

This is not a great example, since the generic is just a complication in
implementing a binary search of an array of Float indexed by Positive. A better
example might have shown searching multiple arrays of different element types,
indexed by different index types.

As an example, Search could be instantiated for

type Person is record
   ID   : Positive;
   Name : Ada.Strings.Unbounded.Unbounded_String;
   DOB  : Ada.Calendar.Time;
end record;

function "<" (Left : in Person; Right : in Person) return Boolean is
begin -- "<"
   return Left.ID < Right.ID;
end "<";

subtype PLI is Long_Integer range 1 .. Long_Integer'Last;

type Person_List is array (PLI range <>) of Person;

procedure Find is new Search
(Element_Type => Person, Index_Type => PLI, Array_Type => Person_List);

and used to find people by ID.

> Also, on line 53, if this code is ever reached, then this means that the
> entire application will stop executing, yes?  The procedure won't just return
> to the caller.

No. Line 53 is an exit statement. A plain exit statement like this
unconditionally exits the innermost enclosing loop statement. An "exit" with a
loop name can exit any enclosing loop, not just the innermost. An "exit" with a
"when" part is a conditional "exit" and only exits when its condition is true.

exit [loop-name] [when condition];

I would recommend you learn more about basic Ada (such as loop and exit
statements) before attacking more advanced topics such as generics.

-- 
Jeff Carter
"Mr. President, we must not allow a mine-shaft gap!"
Dr. Strangelove
33


^ permalink raw reply	[relevance 3%]

* Re: confusion about message passing between the tasks
  @ 2014-10-25 23:26  6%       ` compguy45
  0 siblings, 0 replies; 200+ results
From: compguy45 @ 2014-10-25 23:26 UTC (permalink / raw)


 Can anyone tell me why i am getting zero printed to the screen even though i am passing 5?


 2 use Ada.Text_IO, Ada.Integer_Text_IO;
  3 
  4 with Ada.Calendar; use Ada.Calendar;
  5 
  6 procedure strib1 is
  7 
  8 task type Counter_Task is
  9    entry Get (Value : out Integer);
 10 end Counter_Task;
 11 
 12 
 13 p: Counter_Task;
 14 i : Integer;
 15      
 16      
 17      
 18 task body Counter_Task is
 19         V : Integer := 0;
 20     begin
 21         loop
 22             select
 23                 accept Get (Value : out Integer) do
 24                     put("Value of parametar passed in is ");put(Value); 
                        --Why am i getting zero printed???
 25                     Value := V;
 26                     V     := V + 1;
 27                 end Get;
 28             or  
 29                 terminate;
 30             end select;
 31         end loop;
 32     end Counter_Task;
 33 
 34 begin
 35   i := 5;
 36   p.Get(i); 
 37 




^ permalink raw reply	[relevance 6%]

* Gnat Pro Cross compiling
@ 2014-10-16 12:55  5% Nahro Nadir
  0 siblings, 0 replies; 200+ results
From: Nahro Nadir @ 2014-10-16 12:55 UTC (permalink / raw)


I am trying to use gnat pro as a cross compiler which use arm-eabi toolchain, but it cannot recognize any Ada packages!!

Here is compilation result:


        5:6 "ada.calendar" is not a predefined library unit
        2:6 "ada.direct_io" is not a predefined library unit
        8:6 "ada.float_text_io" is not a predefined library unit
        7:6 "ada.integer_text_io" is not a predefined library unit
        10:6 "ada.numerics" is not a predefined library unit
        2:6 "ada.text_io" is not a predefined library unit
        2:6 "bmp (spec)" depends on "ada.direct_io (spec)"
        2:6 "bmp (spec)" depends on "ada.text_io (spec)"
        3:6 "serial_net (spec)" depends on "gnat.sockets (spec)"
        2:6 "stream (body)" depends on "bmp (spec)"
        3:6 "stream (body)" depends on "serial_net (spec)"
        3:6 file "g-socket.ads" not found



^ permalink raw reply	[relevance 5%]

* Re: Deleting or editing usenet posts - does it work? fast?
  @ 2014-10-16 10:01  5%       ` J-P. Rosen
  0 siblings, 0 replies; 200+ results
From: J-P. Rosen @ 2014-10-16 10:01 UTC (permalink / raw)


Le 16/10/2014 11:20, Phil a écrit :
> On Wed, 15 Oct 2014 10:29:00 -0400, Peter Chapin wrote:
> 
>> P.S. I hope I'm not making a fool of myself here... this message can't
>> be canceled and will end up in Google's archives until the end of time.
>> :)
> 
> When exactly is the end of time?
> 
According to Ada.Calendar, it's (31, 12 2399).

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr


^ permalink raw reply	[relevance 5%]

* Re: STM32F4 Discovery, communication and libraries
  2014-09-01 20:15  6%                           ` Niklas Holsti
@ 2014-09-01 21:11  5%                             ` Jeffrey Carter
  0 siblings, 0 replies; 200+ results
From: Jeffrey Carter @ 2014-09-01 21:11 UTC (permalink / raw)


On 09/01/2014 01:15 PM, Niklas Holsti wrote:
> 
> I agree, you don't need Ada.Calendar if you have a calendar-capable RTC
> and do not need to do date/time calculations such as finding the
> calendar date of "now + 100_000 seconds".

No, but he'll need something like Ada.Calendar to let him read the H/W RTC, plus
whatever other operations he'll need to do with it (such as sync it to GPS time).

-- 
Jeff Carter
"People called Romanes, they go the house?"
Monty Python's Life of Brian
79


^ permalink raw reply	[relevance 5%]

* Re: STM32F4 Discovery, communication and libraries
  2014-08-30 22:00  5%                         ` Roy Emmerich
@ 2014-09-01 20:15  6%                           ` Niklas Holsti
  2014-09-01 21:11  5%                             ` Jeffrey Carter
  0 siblings, 1 reply; 200+ results
From: Niklas Holsti @ 2014-09-01 20:15 UTC (permalink / raw)


On 14-08-31 01:00 , Roy Emmerich wrote:
> On Friday, 29 August 2014 21:41:18 UTC+2, Niklas Holsti  wrote:
>> On 14-08-29 19:47 , Roy Emmerich wrote:
  ...
>>> This device will effectively aggregate the data from all of these
>>> devices into one, unified format and send control signals to the
>>> generator/inverters.
>> 
>> What is the highest control frequency, or shortest deadline or
>> response time, required of the SW?
> 
> Okay, some new terminology for me here. For this particular
> application the response time doesn't have to be very fast (a few
> seconds). 

Then you can probably ignore all interrupt-handling and just poll for
I/O completion -- if that is much simpler to do.

> ... As this kind of control is
> a lot more dynamic, a much faster response time would be required (20
> ms thumb suck value, considering one 50 Hz period is 20 ms long).

That might or might not require interrupt-handling -- depends on your
overall design.

>>> ... making it important for it to be a low power device (e.g.
>>> much less than say a beaglebone black embedded Linux board), able
>>> to run on a battery for at least 3 days, preferably much more
>> 
>> You may have to modify the Board Support Package and/or the kernel
>> to let the processor sleep between clock interrupts. I don't know
>> if the AdaCore ARM BSP has that ability off-the-shelf.
> 
> Is there an AdaCore ARM BSP yet? I thought this is what Mike Silva
> was referring to when he said:
> 
> "I know that AdaCore is working on comms libraries for the ARM Cortex
> M parts, but I don't know anything about the projected
> availability."
> 
> assuming this would include stuff such as I2C, SPI, UART, etc. which
> is normally also part of the BSP?

In my experience (space domain), the BSP (at least when it comes from a
compiler vendor) usually includes only the functions needed to make the
compiler's run-time system work. For Ada/Ravenscar, this means mainly
that task switching and protected objects work as expected (including
POs used as interrupt handlers) and that some timer or clock HW is
configured to drive Ada.Real_Time and the "delay until" statements. I/O
drivers are not (in my domain) typically included in the BSP -- well,
perhaps the BSP contains a simple serial-port driver to make some
emasculated form of Ada.Text_IO work. I/O drivers typically come separately.

For ground-based embedded systems, I have seen that some compiler or
chip vendors package I/O drivers with their BSPs. Perhaps Mike Silva is
talking about some AdaCore activity in that direction.

> Speaking of which...in order to feel like I'm making progress and Ada
> is going to work for me, I really need to get connecting to my
> peripherals. The only way I can see it happening within the next week
> is to call the STM C drivers supplied with their BSP. Does this make
> sense?

Very much so, at least if the C drivers are designed as a passive
library which does not rely on any specific kernel.

>>> It must keep accurate time (syncing once a day via GPS)

Must the SW actions be accurately synchronized with GPS -- for example,
sample something exactly at the GPS pulse-per-second pulse -- or is it
enough that the SW can accurately label each action/sample with the GPS
time when the sample was taken?

>>> and
>>> (periodically/in emergency) make the data available remotely
>>> (via GPRS).
>> 
>> Time in a Ravenscar system is provided by the predefined package 
>> Ada.Real_Time. It is good for relative timing in seconds and ticks,
>> but does not provide calendar date and time. Probably you will have
>> to write your own Calendar-like package which is synchronised with
>> GPS. Not a very big job.
> 
> Maybe not if you know what you're doing ;)
> 
> This is where it gets a bit vague for me. The STM32F4 has an on-board
> RTC with full calendar functionality.

Nice.

> My thinking is at start up and
> then once a day to enter a "clock_sync" state, fire up the GPS
> receiver, somehow sync the processor's RTC and then continue with
> normal operation.

By "processor's RTC", you mean the one with full calendar functionality?
Sounds like a good plan, if that RTC device allows such synchronisation.

I would not try to sync or adjust whatever HW is driving Ada.Real_Time,
but would let that run in its own time. If necessary, I would adjust the
period of the cyclic tasks to keep them in phase with the GPS and/or the
RTC. That is, if a 1 Hz task finds that it is falling behind -- doing
fewer cycles than there are GPS/RTC 1-second ticks -- it would do a few
"delay untils" with a smaller period than 1 s until it has caught up.

> If I need the absolute date/time I can just get it
> from the RTC, so I don't know why I would want to use the
> Ada.Calendar functionality in the first place. Could you shed some
> light on this?

I agree, you don't need Ada.Calendar if you have a calendar-capable RTC
and do not need to do date/time calculations such as finding the
calendar date of "now + 100_000 seconds".

From what I understand of your application, I think you should be fine
with Ada.Real_Time and the RTC.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .


^ permalink raw reply	[relevance 6%]

* Re: STM32F4 Discovery, communication and libraries
  @ 2014-08-30 22:00  5%                         ` Roy Emmerich
  2014-09-01 20:15  6%                           ` Niklas Holsti
  0 siblings, 1 reply; 200+ results
From: Roy Emmerich @ 2014-08-30 22:00 UTC (permalink / raw)


On Friday, 29 August 2014 21:41:18 UTC+2, Niklas Holsti  wrote:
> On 14-08-29 19:47 , Roy Emmerich wrote:
> > My requirements for dynamic behaviour don't extend so far as to be
> > plug and play ready. What I do want, being a modular hardware
> > platform, is to define, in a configuration file, which hardware
> > modules are plugged into which socket. At start up the supervisor
> > will read this file and instantiate the relevant software modules.
> 
> So the Ada program contains SW modules that can handle all known and
> possible hardware modules, but the SW modules are all "data/table
> driven" in the sense that the supervisor can tell each SW module where
> (in which socket, &c) its HW, if any, can be found?

Yes.

> As far as I can see, the only problem that the Ravenscar profile can
> cause for that design is the restriction No_Dynamic_Attachment, which
> means that the connection between an interrupt source and its handler
> must be established at elaboration time, by pragmas or aspects, and not
> dynamically using a call of Ada.Interrupts.Attach_Handler.
> 
> In principle, the configuration file could be read at elaboration time,
> and could provide the interrupt numbers to be used in the pragma/aspect
> Attach_Handler. However, doing lots of computation at elaboration time
> can make it tricky for the compiler to find a feasible elaboration order
> (especially if the program has tasks).
> 
> The other solution is to attach handlers to all interrupt sources
> statically, but to decide in each handler, at run time, based on the
> configuration data, which SW module is to handle the interrupt, and to
> call the suitable operation from that SW module. A kind of indirection step.

Okay. I think I got that.

> > This device will effectively aggregate the
> > data from all of these devices into one, unified format and send
> > control signals to the generator/inverters.
> 
> What is the highest control frequency, or shortest deadline or response
> time, required of the SW?

Okay, some new terminology for me here. For this particular application the response time doesn't have to be very fast (a few seconds). It will be monitoring battery state of charge and active power and turning the generator on or off. I do foresee the need to do reactive power control in larger off-grid systems. For this the phase shift between voltage and current is normally measured by a CE/UL certified power analyser (legal/safety issues) and transmitted, once again, via MODBUS RTU, to my device. As this kind of control is a lot more dynamic, a much faster response time would be required (20 ms thumb suck value, considering one 50 Hz period is 20 ms long). Sorry that it is still so vague. A bit of guidance wouldn't go amiss :)

> > ... making it
> > important for it to be a low power device (e.g. much less than say a
> > beaglebone black embedded Linux board), able to run on a battery for
> > at least 3 days, preferably much more
> 
> You may have to modify the Board Support Package and/or the kernel to
> let the processor sleep between clock interrupts. I don't know if the
> AdaCore ARM BSP has that ability off-the-shelf.

Is there an AdaCore ARM BSP yet? I thought this is what Mike Silva was referring to when he said:

"I know that AdaCore is working on comms libraries for the ARM Cortex M parts, but I don't know anything about the projected availability."

assuming this would include stuff such as I2C, SPI, UART, etc. which is normally also part of the BSP?

Speaking of which...in order to feel like I'm making progress and Ada is going to work for me, I really need to get connecting to my peripherals. The only way I can see it happening within the next week is to call the STM C drivers supplied with their BSP. Does this make sense?

> > It must keep accurate time (syncing once a day via GPS)
> > and (periodically/in emergency) make the data available remotely (via
> > GPRS).
> 
> Time in a Ravenscar system is provided by the predefined package
> Ada.Real_Time. It is good for relative timing in seconds and ticks, but
> does not provide calendar date and time. Probably you will have to write
> your own Calendar-like package which is synchronised with GPS. Not a
> very big job.

Maybe not if you know what you're doing ;)

This is where it gets a bit vague for me. The STM32F4 has an on-board RTC with full calendar functionality. My thinking is at start up and then once a day to enter a "clock_sync" state, fire up the GPS receiver, somehow sync the processor's RTC and then continue with normal operation. If I need the absolute date/time I can just get it from the RTC, so I don't know why I would want to use the Ada.Calendar functionality in the first place. Could you shed some light on this?


^ permalink raw reply	[relevance 5%]

* Re: STM32F4 Discovery, communication and libraries
  @ 2014-08-29 16:52  4%                   ` Niklas Holsti
  0 siblings, 0 replies; 200+ results
From: Niklas Holsti @ 2014-08-29 16:52 UTC (permalink / raw)


On 14-08-29 16:06 , Dennis Lee Bieber wrote:
> On Thu, 28 Aug 2014 13:34:58 -0700 (PDT),
> embeddedrelatedmike@scriptoriumdesigns.com declaimed the following:
> 
>> On Thursday, August 28, 2014 1:09:05 PM UTC-7, Dmitry A. Kazakov wrote:
>>> Not really. OS is more than tasking, it is also a queueing mechanism, which
>>> allows waiting for I/O completion in one task without blocking all other
>>> tasks.
>>> ......
>>> You could not implement an equivalent of I/O queueing under the Ravenscar 
>>> constraints.
>>
>> Are you saying that a full Ada implementation on bare metal could
>> not implement an equivalent of I/O queueing?
>>
>> Or are you saying that Ravenscar tasking on bare metal could not implement
>> such queueing?
> 
> 	Have you looked at the list of restrictions that profile requires?
> 
> 	Max_Task_Entries = 0 (which goes along with)
> 	No_Select_Statements
> 
> 	Max_Protected_Entries = 1 (effectively no queuing up for access to
> protected objects by multiple tasks)
> 	Simple_Barriers (plain T/F Boolean variable controlling entries)
> 
> 	No_Relative_Delays (no "delay n" only "delay until m")
> 
> 	Oh, and No_Abort_Statements (and a number of other restrictions)

All Ravenscar restrictions are on the _tasking_ system, with the
exception of No_Implicit_Heap_Allocation and forbidding the use of
Ada.Calendar (but _explicit_ heap allocation remains possible).

The rest of Ada remains in its full form.

However, some Ravenscar run-time systems _also_ have other restrictions,
for example limitations on the use of unconstrained array types in
expressions.

> 	It works if the entire system including the "user application" level is
> built "as one".

That same restriction holds for all standard Ada programs (with the
possible exception of distributed programs -- I have no experience
there). At bind time, all the compilation modules forming the program
are identified and included in the program, and no other modules/code
can be added later, unless the program dynamically links to plug-in
libraries, which is not standard Ada.

> It is NOT a very dynamic arrangement wherein you may plug
> in a new sensor and have it magically install itself to some list of
> sensors to be reported.

It is certainly possible to write a Ravenscar program in which adding a
new sensor can be done by adding a single line, "with My_New_Sensor", to
the main subprogram. At elaboration time, My_New_Sensor can install its
tasks and protected objects in the application's data structures. No
problem.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .

^ permalink raw reply	[relevance 4%]

* Re: Leap second support and ARM 9.6.1p89/2
  @ 2014-08-07  8:59  6%     ` Markus Schöpflin
  0 siblings, 0 replies; 200+ results
From: Markus Schöpflin @ 2014-08-07  8:59 UTC (permalink / raw)


Am 07.08.2014 09:35, schrieb Natasha Kerensikova:

> Ok, so would I. So I guess the next step is checking who is the
> implementer, i.e. whether's it's AdaCore's problem or FSF's.
>
> Would someone here with a working installation of GNAT GPL 2014 be kind
> enough to test the function in the OP, and tell me whether it's
> affected?

Can't say about GNAT GPL 2014, but I tested it with GNAT Pro 7.1.2 and a 
pre-release version of 7.3.0.

 > gnatmake -gnata -gnat05 -f test.adb
gcc -c -gnata -gnat05 test.adb
gnatbind -x test.ali
gnatlink test.ali
gnatlink: warning: executable name "test" may conflict with shell command
 > ./test

raised SYSTEM.ASSERTIONS.ASSERT_FAILURE : test.adb:50

 > sed -n '50p' test.adb
          pragma ASSERT (LEAP_SECOND);

HTH, Markus

PS: Next time, please make sure that you post a full example which compiles, 
binds, and links correctly. Your code not only needs a main procedure, it also 
needs to with & use ADA.CALENDAR.FORMATTING instead of ADA.CALENDAR.TIME.

^ permalink raw reply	[relevance 6%]

* Leap second support and ARM 9.6.1p89/2
@ 2014-08-05 19:47  5% Natasha Kerensikova
    0 siblings, 1 reply; 200+ results
From: Natasha Kerensikova @ 2014-08-05 19:47 UTC (permalink / raw)


Hello,

I've recently came across ARM 9.6.1p89/2 and tried the following
function to detect leap second at runtime:

   function Leap_Second_Support return Boolean is
      use Ada.Calendar;
      use Ada.Calendar.Time;

      Date : Time;
   begin
      begin
         Date := Time_Of
           (Year => 1990,
            Month => 12,
            Day => 31,
            Hour => 23,
            Minute => 59,
            Second => 59,
            Sub_Second => 0.5,
            Leap_Second => True,
            Time_Zone => 0);
      exception
         when Time_Error =>
            return False;
      end;

      declare
         Year : Year_Number;
         Month : Month_Number;
         Day : Day_Number;
         Hour : Hour_Number;
         Minute : Minute_Number;
         Second : Second_Number;
         Sub_Second : Second_Duration;
         Leap_Second : Boolean;
      begin
         Split
           (Date,
            Year, Month, Day,
            Hour, Minute, Second, Sub_Second,
            Leap_Second, 0);

         pragma Assert (Year = 1990);
         pragma Assert (Month = 12);
         pragma Assert (Day = 31);
         pragma Assert (Hour = 23);
         pragma Assert (Minute = 59);
         pragma Assert (Second = 59);
         pragma Assert (Leap_Second);
      end;

      return True;
   end Leap_Second_Support;

I was quite surprised to find that on my platforms (FSF GNAT 4.9.0 on
FreeBSD and FSF GNAT 4.8.3 on Fedora), the assertion testing Leap_Second
is raised, which means that Leap_Second is ignored instead of raising an
exception.

I realize that 9.6.1p89/2 is under "Implementation Advice", so I guess
that ignoring Leap_Second is allowed by the standard, right?
Should I still report it as a bug somewhere?

Can I just replace "pragma Assert (Leap_Second)" with "return False;" or
is it even more subtle? I don't see anything about the semantics for
systems without support for leap seconds, does it means it's undefined
behavior?


Thanks for your insights,
Natasha


^ permalink raw reply	[relevance 5%]

* Re: why the pascal family of languages (Pascal, Ada, Modula-2,2,Oberon,
  @ 2014-07-22 21:46  4%             ` Randy Brukardt
  0 siblings, 0 replies; 200+ results
From: Randy Brukardt @ 2014-07-22 21:46 UTC (permalink / raw)


"Dan'l Miller" <optikos@verizon.net> wrote in message 
news:5d9cd056-b36b-4448-be8d-a8bafbaa6d81@googlegroups.com...
>On Monday, July 21, 2014 7:01:20 PM UTC-5, Randy Brukardt wrote:
>> "Dan'l Miller" wrote in message:
>> > There actually does exist a GUI library written entirely in Ada for 
>> > Ada:
>> > Gnavi.
>>
>> You misspelled "Claw". ;-) GNavi exists mainly because the authors didn't
>> like our design for Claw. Which has been a long-standing problem with 
>> Ada --
>> too many choices never quite finished, rather than one library that most
>> people use and extend.
>
>Randy, you make it sound as though Gnavi is a fork of Claw or some other
>direct derivative work, by making the reference to misspelling (a rose by 
>any
>other name is just a sweet).

It's derivative in that it took the ideas that we had pioneered in Claw and 
reimplemented them. I didn't mean to imply that any of the actual code was 
used. Being first, we had the fun of debugging compilers (early Ada 95 
compilers were not up to the task when we started, particularly with 
finalization), and to a lesser extent, figuring out what doesn't work.

> Perhaps some of the developers of Gnavi were
>first Claw users, but it seems they simply designed a competitor rather 
>than a
>derivative work.
>
>
>  Or was now-EULA-licensed Claw open source at one point in the past?

The introductory version is open source now, and has been for a long time. 
That's not as obvious as it should be, mainly because I couldn't find the 
appropriate wording to put into the packaging. I planned to do that in the 
next release that's never happened.

The plan always was to open source the libraries (but not the tools). We 
didn't do it right away because it wasn't clear whether we had the right 
model, and we didn't want a lot of dependence on mistakes until we had more 
evidence (that is, programs using it) one way or another. (There also were 
the requirements of our ATIP/P contract, which needed be cleared before 
giving away anything.) Problems with early compilers pushed that back a 
number of years which effectively wrecked the plan. I had originally hoped 
to have what amounted to a standard Ada library for Windows, such that 
people could simply assume it is there and do cool stuff on top of it. That 
of course never happened in any sense.

At least a few parts of Claw ended up in the Ada standard: Ada.Directories 
and the various children of Ada.Calendar existed in some form in Claw 
(because these rather basic capabilities were missing from Ada 95), and the 
Claw versions formed the basis for the packages in the Standard (especially 
for Ada.Directories, which started as a copy of Claw.Directories with 
appropriate substitutions ["Claw" -> "Ada", etc.]).

                                     Randy.



^ permalink raw reply	[relevance 4%]

* Re: Asynchronous Transfer of Control
  2014-04-10 10:41  6% Asynchronous Transfer of Control AdaMagica
@ 2014-04-10 15:15  0% ` Adam Beneschan
  0 siblings, 0 replies; 200+ results
From: Adam Beneschan @ 2014-04-10 15:15 UTC (permalink / raw)


On Thursday, April 10, 2014 3:41:15 AM UTC-7, AdaMagica wrote:
> This piece of code is very similar to RM 9.7.4(10-13).
> 
> It seems that GNT GPL 2013 on Windows does ot work correctly.
> 
> with Ada.Text_IO;
> use  Ada.Text_IO;
> with Ada.Calendar;
> use  Ada.Calendar;
> 
> procedure Run_It is
> 
>   Line: String (1 .. 10);
>   Last: Natural;
>   Now : constant Time := Clock;
> begin
>   select
>     delay 10.0;
>     Put_Line ("aborted   " & Integer'Image (last) & Duration'Image (Clock - Now));
>   then abort
>     Put (" > ");
>     Get_Line (Line, Last); 
>     Put_Line ("terminated" & Integer'Image (last) & Duration'Image (Clock - Now));
>   end select;
> end Run_It;
> 
> This is the result if I only press <return> after the delay has expired:
> 
> C:\...\Ada-Kode\run_it
> 
> terminated 0 26.688941821
> aborted    0 26.689382659
> 
> [2014-04-10 12:24:42] process terminated successfully (elapsed time: 26.92s)
> 
> I.e. the abortable_part is not aborted.
> 
> Am I missing something? Or is this expected behaviour on Windows?

The RM says that when the abortable_part is aborted, it doesn't actually have to stop executing until the next abort completion point.  The abort completion points are defined in 9.8(16-19).  The abortable_part *could* be terminated at other points (as long as they're not inside abort-deferred operations, see 9.8(6-11)), but it's up to the implementation.

I/O operations like Get_Line aren't abort completion points.  It seems reasonable that an implementation *should* provide for an I/O operation to be aborted if it could be forced to wait (e.g. input from the console, waiting for a socket connect, etc.).  But the RM doesn't require it.
  
Based on that, I think the examples in 9.7.4(10-13) are flawed.  While those kinds of examples may be the intended use of the asynchronous_select, they don't necessarily work, and the RM should probably make it clear that the effect is implementation-dependent.  In particular, the comment in the first example, "-- This will be abandoned upon terminal interrupt", appears to be making an assertion that is not necessarily true.  I'm planning on sending something to Ada-Comment about this.  (Don't know why I didn't notice this before.)  In the second example, we don't know whether Horribly_Complicated_Recursive_Function contains any abort completion points or not.  If it's a mathematical calculation, chances are that it doesn't; however, adding "delay 0.0;" statements at key places in the calculation would add abort compeltion points, and hopefully this statement would be implemented in a way so that it isn't a severe drag on efficiency.  (There's also Ada.Dispatching.Yield, which the RM says is a "task dispatching point", but it's not clear to me whether all task dispatching points are also abort completion points--seems like they should be, but I'd have to check the RM further.)

My understanding is that Windows makes it more difficult than, say, Unix/Linux to forcibly interrupt a thread, without that thread's cooperation.  That is, if I recall correctly, the thread to be interrupted has to use different versions of I/O API calls, and/or special API routines, that enable the operation to be interrupted.  I think that system designers have come to believe that allowing threads to be interrupted at any arbitrary point causes problems.  As I mentioned above, it may be a reasonable expectation that a keyboard input subprogram should allow for thread interruption, but others may have different opinions; anyway, it's not a requirement and GNAT apparently doesn't do it.

                                -- Adam 



^ permalink raw reply	[relevance 0%]

* Asynchronous Transfer of Control
@ 2014-04-10 10:41  6% AdaMagica
  2014-04-10 15:15  0% ` Adam Beneschan
  0 siblings, 1 reply; 200+ results
From: AdaMagica @ 2014-04-10 10:41 UTC (permalink / raw)


This piece of code is very similar to RM 9.7.4(10-13).
It seems that GNT GPL 2013 on Windows does ot work correctly.

with Ada.Text_IO;
use  Ada.Text_IO;
with Ada.Calendar;
use  Ada.Calendar;

procedure Run_It is

  Line: String (1 .. 10);
  Last: Natural;
  Now : constant Time := Clock;

begin

  select
    delay 10.0;
    Put_Line ("aborted   " & Integer'Image (last) & Duration'Image (Clock - Now));
  then abort
    Put (" > ");
    Get_Line (Line, Last);
    Put_Line ("terminated" & Integer'Image (last) & Duration'Image (Clock - Now));
  end select;

end Run_It;

This is the result if I only press <return> after the delay has expired:
C:\...\Ada-Kode\run_it
 > 
terminated 0 26.688941821
aborted    0 26.689382659
[2014-04-10 12:24:42] process terminated successfully (elapsed time: 26.92s)

I.e. the abortable_part is not aborted.

Am I missing something? Or is this expected behaviour on Windows?


^ permalink raw reply	[relevance 6%]

* Re: gnatmake error I don't understand
  2014-04-04  0:35  5% gnatmake error I don't understand agent
@ 2014-04-04  4:14  0% ` Per Sandberg
  0 siblings, 0 replies; 200+ results
From: Per Sandberg @ 2014-04-04  4:14 UTC (permalink / raw)


On Thu, 03 Apr 2014 20:35:18 -0400
agent@drrob1.com wrote:
The attribute "Main" is a file-name so it shall be:
   for main use ("habits.adb");
and not:
   for main use ("Habits");
/Per



> I typed the following code from a recent issue of Linux Format
> 
> texthabits.ads
> with Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO;
> use  Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO;
> 
> -- REVISION HISTORY
> -- ================
> -- 31 Mar 14 -- Extracted from LinuxFormat LXF 181 coding article
> 
> Package texthabits is
> 
> PROCEDURE CreateOrOpen (File: in out File_Type; Name: in String; Form:
> in String := "");
> 
> Procedure OpenOrCreateDataFile(File : in out File_Type; Name : in
> String);
> 
> Procedure ReadAndDisplayDatafile(File : in out File_Type; Name :
> String);
> 
> Procedure Habits ;
> 
> END texthabits;
> 
> -----------------------------------------------------------------------------------------
> texthabits.adb
> with Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO, Ada.Calendar,
> Ada.Directories;
> use  Ada.Text_IO, Ada.Strings.Unbounded,
> Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO, Ada.Calendar,
> Ada.Directories;
> 
> -- REVISION HISTORY
> -- ================
> -- 31 Mar 14 -- Extracted from LinuxFormat LXF 181 coding article
> 
> 
> Package body texthabits is
>   habit : Unbounded_String;
>   filehandle : File_Type;
>   HabitFileName : String(1..13);
>   ctr : Natural := 1;
> 
> PROCEDURE CreateOrOpen (File: in out File_Type; Name: in String; Form:
> in String := "") is
> BEGIN
>   Open(File, Append_File, Name, Form);
> EXCEPTION
>   WHEN Ada.Text_IO.Name_Error =>
>     Create(File, Out_File, Name, Form);  -- If must create file, then
> append_file does not make sense, even if desired.
> END CreateOrOpen;
> 
> Procedure OpenOrCreateDataFile(File : in out File_Type; Name : in
> String) is
> Begin
>   Open(File, Append_File, Name);
> Exception
>   when Ada.Text_IO.Name_Error => Create(File => File, Mode =>
> Append_File, Name => Name);
> End OpenOrCreateDataFile;
> 
> Procedure ReadAndDisplayDatafile(File : in out File_Type; Name :
> String) is
>   buffer : String(1..100);
>   length : Natural;
> Begin
>   IF EXISTS(Name) THEN
>     Open(File => File, Mode => In_File, Name => Name);
>     While not End_Of_File(File => File) loop
>       Get_Line(File => File, item => buffer, last => Length);
>       Put_Line(buffer(1..length));
>     end loop;
>     Close(File);
>   END IF; -- if exists 
> End ReadAndDisplayDatafile;
> 
> 
> Procedure Habits is
> Begin
>   HabitFileName  :=  "habitfile.txt";
>   ReadAndDisplayDatafile(filehandle, HabitFileName);  -- for input. Do
> nothing if file does not exist.
>   OpenOrCreateDataFile(filehandle, HabitFileName);    -- for output
>   LOOP
>     Put(" Enter a new habit, quit or exit: ");
>     habit  :=  Get_Line;
>     exit when (CAP(To_STRING(Head(Habit,4))) = "QUIT") OR
> (CAP(to_string(Head(Habit,4))) = "EXIT") ;
>     Put_Line(filehandle,Habit);
>     ctr := ctr + 1;
>   END LOOP;
>   Close(filehandle);
>   Put(" You entered and saved ");
>   Put(ctr,3);
>   Put_Line(" new habits.");
> End Habits;
> 
> END texthabits;
> ---------------------------------------------------------------------------------
> texthabits.gpr
> project texthabits is
>   for Source_Files use ("texthabits.adb", "texthabits.ads",
> "tokenizea.ads", "tokenizea.adb");
>   for Source_Dirs use (".", "./**");
>   for Main use ("Habits");                                            
> 
>   package Builder is
>     for Default_Switches ("Ada")
>         use ("-g");
>   end Builder;
> 
>   package Compiler is
>     for Default_Switches ("Ada")
>        use ("-fstack-check",
>             "-gnatVa",
>             "-g",
>             "-gnato",
>             "-gnatf",
>             "-gnatwu",
>             "-gnat2012");
>   end Compiler;
>    
> end texthabits;
> 
> ------------------------------------------------------------------------------
> Ubuntu 12.04  amd64 version
> 
> gnatmake -Ptexthabits
> 
> gnatmake: "Habits" is not a source of project texthabits.
> 
> I don't understand the error or what to do about it.
> 
> Thanks,
> Rob Solomon
> 


^ permalink raw reply	[relevance 0%]

* gnatmake error I don't understand
@ 2014-04-04  0:35  5% agent
  2014-04-04  4:14  0% ` Per Sandberg
  0 siblings, 1 reply; 200+ results
From: agent @ 2014-04-04  0:35 UTC (permalink / raw)


I typed the following code from a recent issue of Linux Format

texthabits.ads
with Ada.Text_IO, Ada.Strings.Unbounded,
Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO;
use  Ada.Text_IO, Ada.Strings.Unbounded,
Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO;

-- REVISION HISTORY
-- ================
-- 31 Mar 14 -- Extracted from LinuxFormat LXF 181 coding article

Package texthabits is

PROCEDURE CreateOrOpen (File: in out File_Type; Name: in String; Form:
in String := "");

Procedure OpenOrCreateDataFile(File : in out File_Type; Name : in
String);

Procedure ReadAndDisplayDatafile(File : in out File_Type; Name :
String);

Procedure Habits ;

END texthabits;

-----------------------------------------------------------------------------------------
texthabits.adb
with Ada.Text_IO, Ada.Strings.Unbounded,
Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO, Ada.Calendar,
Ada.Directories;
use  Ada.Text_IO, Ada.Strings.Unbounded,
Ada.Strings.Unbounded.Text_IO, Ada.Integer_Text_IO, Ada.Calendar,
Ada.Directories;

-- REVISION HISTORY
-- ================
-- 31 Mar 14 -- Extracted from LinuxFormat LXF 181 coding article


Package body texthabits is
  habit : Unbounded_String;
  filehandle : File_Type;
  HabitFileName : String(1..13);
  ctr : Natural := 1;

PROCEDURE CreateOrOpen (File: in out File_Type; Name: in String; Form:
in String := "") is
BEGIN
  Open(File, Append_File, Name, Form);
EXCEPTION
  WHEN Ada.Text_IO.Name_Error =>
    Create(File, Out_File, Name, Form);  -- If must create file, then
append_file does not make sense, even if desired.
END CreateOrOpen;

Procedure OpenOrCreateDataFile(File : in out File_Type; Name : in
String) is
Begin
  Open(File, Append_File, Name);
Exception
  when Ada.Text_IO.Name_Error => Create(File => File, Mode =>
Append_File, Name => Name);
End OpenOrCreateDataFile;

Procedure ReadAndDisplayDatafile(File : in out File_Type; Name :
String) is
  buffer : String(1..100);
  length : Natural;
Begin
  IF EXISTS(Name) THEN
    Open(File => File, Mode => In_File, Name => Name);
    While not End_Of_File(File => File) loop
      Get_Line(File => File, item => buffer, last => Length);
      Put_Line(buffer(1..length));
    end loop;
    Close(File);
  END IF; -- if exists 
End ReadAndDisplayDatafile;


Procedure Habits is
Begin
  HabitFileName  :=  "habitfile.txt";
  ReadAndDisplayDatafile(filehandle, HabitFileName);  -- for input. Do
nothing if file does not exist.
  OpenOrCreateDataFile(filehandle, HabitFileName);    -- for output
  LOOP
    Put(" Enter a new habit, quit or exit: ");
    habit  :=  Get_Line;
    exit when (CAP(To_STRING(Head(Habit,4))) = "QUIT") OR
(CAP(to_string(Head(Habit,4))) = "EXIT") ;
    Put_Line(filehandle,Habit);
    ctr := ctr + 1;
  END LOOP;
  Close(filehandle);
  Put(" You entered and saved ");
  Put(ctr,3);
  Put_Line(" new habits.");
End Habits;

END texthabits;
---------------------------------------------------------------------------------
texthabits.gpr
project texthabits is
  for Source_Files use ("texthabits.adb", "texthabits.ads",
"tokenizea.ads", "tokenizea.adb");
  for Source_Dirs use (".", "./**");
  for Main use ("Habits");                                            

  package Builder is
    for Default_Switches ("Ada")
        use ("-g");
  end Builder;

  package Compiler is
    for Default_Switches ("Ada")
       use ("-fstack-check",
            "-gnatVa",
            "-g",
            "-gnato",
            "-gnatf",
            "-gnatwu",
            "-gnat2012");
  end Compiler;
   
end texthabits;

------------------------------------------------------------------------------
Ubuntu 12.04  amd64 version

gnatmake -Ptexthabits

gnatmake: "Habits" is not a source of project texthabits.

I don't understand the error or what to do about it.

Thanks,
Rob Solomon



^ permalink raw reply	[relevance 5%]

* Ann: Excel Writer v.12
@ 2014-03-30  8:50  5% gautier_niouzes
  0 siblings, 0 replies; 200+ results
From: gautier_niouzes @ 2014-03-30  8:50 UTC (permalink / raw)


Hello! 

There is a new release of Excel Writer. 

What's new: 
* added Ada.Calendar.Time Put/Write and date built-in formats
* added background colours
* added wrap_text format option

Excel Writer (Excel_Out) is a free, standalone, portable, open source package for producing Excel spreadsheets with basic formattings and page layout. It can be used in an "Ada.Text_IO" fashion, with Put, Put_Line and New_Line.

URL: http://excel-writer.sf.net 

Enjoy!
_________________________ 
Gautier's Ada programming 
http://sf.net/users/gdemont

^ permalink raw reply	[relevance 5%]

* Re: need help learning Ada for a modula-2 programmer
  2014-01-30  4:29  0%   ` Nasser M. Abbasi
@ 2014-01-30 16:28  0%     ` Pascal Obry
  0 siblings, 0 replies; 200+ results
From: Pascal Obry @ 2014-01-30 16:28 UTC (permalink / raw)


Le mercredi 29 janvier 2014 à 22:29 -0600, Nasser M. Abbasi a écrit : 
> On 1/29/2014 10:58 AM, Dirk Heinrichs wrote:
> > agent@drrob1.com wrote:
> >
> >> with Ada.Calendar; use Ada.Calendar;
> >> Package timliba is
> >>
> >> --  REVISION HISTORY
> >> --  ----------------
> >> --   6 Oct 13 -- Converted to gm2.  And changed its name.
> >> --  19 Jan 14 -- Converted to Ada.
> >>
> >
> > You've already received some valuable on-topic replies, so here's an off-
> > topic (but hopefully as valuable) one ;)
> >
> > You should avoid putting the revision history _into_ your files. It's the
> > job of your version control system to handle this. Putting it into the file
> > increases the probability of getting merge conflicts.
> >
> 
> Wrong advice.

Hard to understand why a commonly used and spread usage in all big open
source projects could be wrong!!!

A revision history means just nothing in a source file as what is
important is the *set of* sources (or repository state) for a given bug
fix or feature.

And why should a developer have to duplicate information about what has
been done when it is recorded into the VCS?

My 2 cents!

-- 
  Pascal Obry /  Magny Les Hameaux (78)

  The best way to travel is by means of imagination

  http://v2p.fr.eu.org
  http://www.obry.net

  gpg --keyserver keys.gnupg.net --recv-key F949BD3B




^ permalink raw reply	[relevance 0%]

* Re: need help learning Ada for a modula-2 programmer
  2014-01-29 16:58  0% ` Dirk Heinrichs
  2014-01-29 20:43  0%   ` Randy Brukardt
@ 2014-01-30  4:29  0%   ` Nasser M. Abbasi
  2014-01-30 16:28  0%     ` Pascal Obry
  1 sibling, 1 reply; 200+ results
From: Nasser M. Abbasi @ 2014-01-30  4:29 UTC (permalink / raw)


On 1/29/2014 10:58 AM, Dirk Heinrichs wrote:
> agent@drrob1.com wrote:
>
>> with Ada.Calendar; use Ada.Calendar;
>> Package timliba is
>>
>> --  REVISION HISTORY
>> --  ----------------
>> --   6 Oct 13 -- Converted to gm2.  And changed its name.
>> --  19 Jan 14 -- Converted to Ada.
>>
>
> You've already received some valuable on-topic replies, so here's an off-
> topic (but hopefully as valuable) one ;)
>
> You should avoid putting the revision history _into_ your files. It's the
> job of your version control system to handle this. Putting it into the file
> increases the probability of getting merge conflicts.
>

Wrong advice.

Revision history belongs to the source code itself. If you remove it
and put it in some separate container such as a database, then you
are stuck to having that database along side for ever, and it means
no one can see the revisions made to the source code, unless they
access and install some additional software and files.

--Nasser




^ permalink raw reply	[relevance 0%]

* Re: need help learning Ada for a modula-2 programmer
  2014-01-29 16:58  0% ` Dirk Heinrichs
@ 2014-01-29 20:43  0%   ` Randy Brukardt
  2014-01-30  4:29  0%   ` Nasser M. Abbasi
  1 sibling, 0 replies; 200+ results
From: Randy Brukardt @ 2014-01-29 20:43 UTC (permalink / raw)


"Dirk Heinrichs" <dirk.heinrichs@altum.de> wrote in message 
news:lcbc0j$cci$1@online.de...
> agent@drrob1.com wrote:
>
>> with Ada.Calendar; use Ada.Calendar;
>> Package timliba is
>>
>> --  REVISION HISTORY
>> --  ----------------
>> --   6 Oct 13 -- Converted to gm2.  And changed its name.
>> --  19 Jan 14 -- Converted to Ada.
>>
>
> You've already received some valuable on-topic replies, so here's an off-
> topic (but hopefully as valuable) one ;)
>
> You should avoid putting the revision history _into_ your files. It's the
> job of your version control system to handle this. Putting it into the 
> file
> increases the probability of getting merge conflicts.

I strongly disagree with this advice. The time to write revision history 
entries is when you are either about to write the code or just finished 
doing so (and more rarely, in the middle). That's when all of the important 
issues are fresh in your mind. It's definitely not at check-in time, which 
occurs after all testing is completed. For the Janus/Ada compiler, that 
means after running the entire ACATS and in-house test suites (twice, in 
Ada2007 mode and Ada95 mode). That's at a minumum 4 hours later - by which 
time you're likely to have forgotten half of the information that ought to 
be in the change log. It's also important to have it in the file if the 
source is likely to be separated from the version control at some point --  
which is almost envitable in today's world (for instance, when the version 
control in use is changed).

The point about merges is correct, except that it really isn't a problem 
with a manual merge (what's one more difference out of dozens?). Assuming 
you have a proper tool for doing those (a multi-window editor with a good 
window-comparison tool), there is no problem. I'd agree that an automated 
merge might have problems, but for me, the idea that an automated merge is 
of any value is laughable. For an automated merge to have any value, it has 
to know all of the contents of the two new files and the contents of 
whatever file they originated from. But that latter item is unknowable in 
general - even the programmers don't know it accurately. One might imagine 
that very strict rules about version control use would help; but I've never 
been on a programming team that didn't break whatever rules were in place 
from time-to-time. And some people (like my co-founder) were completely 
incapable of following any rules whatsoever, no matter how easy and 
unobstrusive they might be.

IMHO, if your depending on merges, especially automated merges, to keep your 
version control consistent, you're already in trouble. You're probably 
losing a percentage of your team's work every day.

                                                 Randy.




^ permalink raw reply	[relevance 0%]

* Re: need help learning Ada for a modula-2 programmer
  2014-01-28  1:06  5% need help learning Ada for a modula-2 programmer agent
@ 2014-01-29 16:58  0% ` Dirk Heinrichs
  2014-01-29 20:43  0%   ` Randy Brukardt
  2014-01-30  4:29  0%   ` Nasser M. Abbasi
  0 siblings, 2 replies; 200+ results
From: Dirk Heinrichs @ 2014-01-29 16:58 UTC (permalink / raw)


agent@drrob1.com wrote:

> with Ada.Calendar; use Ada.Calendar;
> Package timliba is
> 
> --  REVISION HISTORY
> --  ----------------
> --   6 Oct 13 -- Converted to gm2.  And changed its name.
> --  19 Jan 14 -- Converted to Ada.
> 

You've already received some valuable on-topic replies, so here's an off-
topic (but hopefully as valuable) one ;)

You should avoid putting the revision history _into_ your files. It's the 
job of your version control system to handle this. Putting it into the file 
increases the probability of getting merge conflicts.

Bye...

	Dirk
-- 
Dirk Heinrichs <dirk.heinrichs@altum.de>
Tel: +49 (0)2471 209385 | Mobil: +49 (0)176 34473913
GPG Public Key C2E467BB | Jabber: dirk.heinrichs@altum.de

^ permalink raw reply	[relevance 0%]

* need help learning Ada for a modula-2 programmer
@ 2014-01-28  1:06  5% agent
  2014-01-29 16:58  0% ` Dirk Heinrichs
  0 siblings, 1 reply; 200+ results
From: agent @ 2014-01-28  1:06 UTC (permalink / raw)


The following code does not compile.  I don't understand why.

The string processing fails to compile, saying "prefix of image must
be a type"

and 

"move is undefined"

I don't yet understand string processing with Ada

--rob

with Ada.Calendar; use Ada.Calendar;
Package timliba is

--  REVISION HISTORY
--  ----------------
--   6 Oct 13 -- Converted to gm2.  And changed its name.
--  19 Jan 14 -- Converted to Ada.

  SubType String10Type is String(1..10);
  TYPE DAYNAMESType is ARRAY (1..7) OF String10Type;
  TYPE MONTHNAMESType is ARRAY (1..12) OF String10Type;
  Type DateTimeType is RECORD
    SystemTime: Time;
    month,day,year,hours,minutes,seconds : Natural;
    ElapsedSec : Duration;
  END Record;

  DateTime: DateTimeType;

  DAYNAMES : Constant DayNamesType  := ("Sunday    ","Monday
","Tuesday   ","Wednesday ", "Thursday  ","Friday    ","Saturday  ");
  MONTHNAMES : Constant MonthNamesType := ("January   ","February
","March     ","April     ","May       ",
      "June      ","July      ","August    ","September ","October
","November  ","December  ");

PROCEDURE TIME2MDY(M,D,Y : Out Natural);
-- System Time To Month, Day, and Year Conversion.

Procedure GetDateTime(DateTime: Out DateTimeType);
-- DateTimeType is my record time type containing everything.

Function JULIAN(M,D,Y : Natural) return Natural;

PROCEDURE GREGORIAN(Juldate : Natural; M,D,Y : OUT Natural);

END timliba;



-- with environa; use environa;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Characters; use Ada.Characters;
with Ada.Characters.Conversions;  use Ada.Characters.Conversions;
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Calendar; use Ada.Calendar;

Package body timliba is

--  REVISION HISTORY
--  ----------------
--  14 Apr 92 -- Created JULIAN and GREGORIAN procs, which are
accurate beyond 3/1/2100.
--  25 Jul 93 -- Changed GREG2JUL and JUL2GREG limits to those imposed
by the
--                algorithm, ie, only years <2100 are now allowed.
--  25 Jul 94 -- Changed limits of allowed years to 1700 from 1900.
--  10 Nov 02 -- Converted to SBM2 Win v4.
--  17 May 03 -- First Win32 version.
--  26 May 03 -- Adjusted algorithm for Julian fcn so year has a
pivot.
--   6 Oct 13 -- Converted to gm2.
--  19 Jan 14 -- Converted to Ada.

  SubType String255 is String(1..255);
  K,IDX,PTR,c,RETCOD                           : Natural;
  CH                                           : CHARacter;
  FLAG,FLAG2,FLAG3,FLAG4,FLAG5,EOFFLG          : BOOLEAN;
--  PROMPT,NAMDFT,TYPDFT,INFNAM,OUTFNAM,
--  TMPBUF,NUMBUF,DRVPATH,INBUF,TOKEN            : BUFTYP;
--  TKNSTATE                                     : FSATYP;
  I,J                                          : INTEGER;

  TYPE ADIPMType is ARRAY (0..11) OF INTEGER;

--  This is a typed constant that represents the difference btwn the
last day
--  of the previous month and 30, assuming each month was 30 days
long.
--  The variable name is an acronym of Accumulated Days In Previous
Months.

  ADIPM : CONSTant ADIPMType :=  (0,1,-1,0,0,1,1,2,3,3,4,4);
  FUDGEFACTOR : CONSTant LONG_FLOAT := 5.0;
-- These are declared in the spec file
--  Type DateTimeType is RECORD
--    SystemTime: Time;
--    month,day,year,hours,minutes,seconds : Natural;
--    ElapsedSec : Duration;
--  END Record;


PROCEDURE TIME2MDY(M,D,Y : Out Natural) is
-- *********************************** TIME2MDY
*************************
-- System Time To Month, Day, and Year Conversion.

  Systime : Time;

BEGIN
  Systime := Clock;
  M := Month(Systime);
  D := Day(Systime);
  Y := Year(Systime);
END TIME2MDY;

Procedure GetDateTime(DateTime : Out DateTimeType) is
   CardSec : Natural;

BEGIN
  DateTime.SystemTime := Clock;

Split(DateTime.SystemTime,DateTime.year,DateTime.month,DateTime.day,DateTime.ElapsedSec);
  CardSec := Natural(DateTime.ElapsedSec+0.5);
  DateTime.hours := CardSec / 3600;
  CardSec := CardSec - DateTime.hours * 3600;
  DateTime.minutes := CardSec / 60;
  DateTime.seconds := CardSec MOD 60;
END GetDateTime;


PROCEDURE MDY2STR(M,D,Y : Natural; MDYSTR : Out String255) is
-- ***************************** MDY2STR
*********************************
-- Month Day Year Cardinals To String.

  DateSepChar : constant character :=  '/';
  MSTR,DSTR,YSTR : String(1..2);
  IntermedStr    : String(1..10);
  m0,d0,y0       : Natural;

BEGIN
  m0 := M;
  d0 := D;
  y0 := Y;
  IntermedStr := m0'Image & DateSepChar & d0'Image & DateSepChar &
y0'Image;
--  DSTR := D'Image;
--  YSTR := Y'Image;
--  MDYSTR := To255(IntermedStr);
    Move(IntermedStr,MDYstr);
END MDY2STR;



Function JULIAN(M,D,Y : Natural) return Natural is

  M0,D0,Y0   : Natural;
  Juldate    : Natural;

BEGIN
  IF Y < 30 THEN
    Y0 := Y + 2000 - 1;
  ELSIF Y < 100 THEN
    Y0 := Y + 1900 - 1;
  ELSE
    Y0 := Y - 1;
  END IF;
  IF (M < 1) OR (M > 12) OR (D < 1) OR (D > 31) OR (Y < 1700) OR (Y >
2500) THEN
-- Month, Day or Year is out of range
    Juldate := 0;
    RETURN(Juldate);
  END IF;

  M0 := M - 1;

  Juldate :=  Y0 * 365     -- Number of days in previous normal years
            + Y0 / 4   -- Number of possible leap days
            - Y0 / 100 -- Subtract all century years
            + Y0 / 400 -- Add back the true leap century years
            + ADIPM(M0) + M0 * 30 + D;

  IF ((( Y MOD 4 = 0) AND ( Y MOD 100 /= 0)) OR ( Y MOD 400 = 0)) AND
--   123            3     3               32    2              21
                                                                 (M >
2) THEN
    Juldate := Juldate + 1;
  END IF;
  RETURN Juldate;
END JULIAN;

PROCEDURE GREGORIAN(Juldate : Natural; M,D,Y : OUT Natural) is

  Y0,M0,D0,L,JD : Natural;

BEGIN
  Y0 := Juldate / 365;
  M0 := 1;
  D0 := 1;

  WHILE JULIAN(M0,D0,Y0) > Juldate LOOP Y0 := Y0 - 1; END Loop;

  M0 := 12;
  WHILE JULIAN(M0,D0,Y0) > Juldate Loop M0 := M0 - 1; END Loop;

  WHILE JULIAN(M0,D0,Y0) < Juldate Loop D0 := D0 + 1; END Loop;

  M := M0;
  D := D0;
  Y := Y0;
END GREGORIAN;

END timliba;


^ permalink raw reply	[relevance 5%]

* Re: Renaming vs assignment to constant
  2013-12-06 16:47  0% ` adambeneschan
  2013-12-06 18:06  0%   ` Eryndlia Mavourneen
@ 2013-12-07  0:47  0%   ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Randy Brukardt @ 2013-12-07  0:47 UTC (permalink / raw)


<adambeneschan@gmail.com> wrote in message 
news:c95e7c9c-6c3b-472b-ac5e-d70538bfc41a@googlegroups.com...
On Friday, December 6, 2013 7:14:51 AM UTC-8, Simon Wright wrote:
>> A poster on Stack Overflow wrote
>>
>>    Now : Time renames Clock;
>>
>> (using Ada.Calendar) which made me blink until I realised that it is the
>> equivalent of
>>
>>    Now : constant Time := Clock;
>>
>> GNAT generates the same code for these two forms. Is there a difference?
>>
>> Which form is preferred?
>
>I prefer the second form, mostly because in the first one, Time does not 
>"rename" anything the
>same way that a variable that renames another variable, or a function that 
>renames another
>function, does.  (Technically, I think Time renames an anonymous object 
>created by the compiler
>to hold the function result, although it seems like incorrect English to 
>talk about "renaming"
>something that didn't have a name in the first place.)

Be glad that we didn't introduce named anonymous access types. :-) [We 
seriously considered that, to allow named types with dynamic accessibility 
and the special anonymous access-to-subprogram rules, but decided it was 
just too weird.]

>However, there *might* be a difference between the two forms if the type 
>involved is (1) a task type
>or a type that contains a task as a subcomponent, (2) a controlled type or 
>a type that contains one,
>(3) something with a coextension.  I'm really not sure whether there's a 
>difference in any of these
>cases, and #2 may be a case where some of the differences are or were 
>dependent on the
>implementation (because of build-in-place semantics).  I'd have to do some 
>research to figure
>out if there are any differences.  Maybe Randy already knows the answer. 
>Also, there may be
>differences related to accessibility levels.  In this simple case that 
>doesn't involve any of those
>features, I don't think there's a semantic difference.

Any differences in (1) and (2) would be because there is a difference in 
accessibility levels. I think there is such a difference, but you're not 
going to talk me into a trip into the Heart-of-Darkness (3.10.2) to figure 
it out!

In general, the difference between:

   R : <something> renames <name>;

and

  C : constant <something> := <name>;

is that the former is essentially by reference (and any constraints on 
<something> are ignored, a terrible Ada 83 decision made mainly because they 
didn't want to introduce a complex concept like static matching -- which of 
course the Ada 95 team decided had to be introduced, so there are no 
language complexity savings and a lot of confusion over the meaning) and the 
latter is essentially by-copy (a copy of <name> is made).

For the function call case, the thing being renamed is an anonymous return 
object, so the difference isn't really noticable, especially with the 
various permissions and requirements to eliminate those objects.

                             Randy.




^ permalink raw reply	[relevance 0%]

* Re: Renaming vs assignment to constant
  2013-12-06 15:14  5% Renaming vs assignment to constant Simon Wright
                   ` (2 preceding siblings ...)
  2013-12-06 18:35  0% ` G.B.
@ 2013-12-06 21:59  0% ` Shark8
  3 siblings, 0 replies; 200+ results
From: Shark8 @ 2013-12-06 21:59 UTC (permalink / raw)


On Friday, December 6, 2013 8:14:51 AM UTC-7, Simon Wright wrote:
> A poster on Stack Overflow wrote
> 
>    Now : Time renames Clock;

That was me! :)


> (using Ada.Calendar) which made me blink until I realised that it is the
> equivalent of
> 
>    Now : constant Time := Clock;

Yep, it is. I probably used it because I had recently run into a C# problem where renaming a variable [and typecast] would have been *VERY* useful.

'Renames' doesn't get enough love; its been neglected over the past [few] standard revisions. -- After using some of the Ada1012 features it'd be kinda nice to put pre/post conditions on a callback independent of those of the actual subprogram referenced; perhaps:

type callback_type is not null access procedure;
Procedure Some_Procedure;
--...
 callback : callback_type renames procedure'access
               with pre => [...], post => [...];

Generics are another feature that seems to have been neglected (for 2005 and 2012), even though they're really pretty good in Ada they could be better still... perhaps a bit of polishing such as allowing Instantiation.Input_variable on formal parameter Input_Variable (conceptually IN would map to constant, IN OUT to a variable, and OUT should likely be handled as an out parameter in a subprogram): this would allow for clients of an instantiation to depend on it w/o having to be generics themselves.

> GNAT generates the same code for these two forms. Is there a difference?
> Which form is preferred?

I think the big difference happens when the result has subcomponents:
    ch   : constant Character:= 'X';             -- Character X.
    temp : String  renames Character'Image(ch);  -- Its image: 'X'.
    ch2  : Character renames temp(2);            -- The unquoted character.

^ permalink raw reply	[relevance 0%]

* Re: Renaming vs assignment to constant
  2013-12-06 15:14  5% Renaming vs assignment to constant Simon Wright
  2013-12-06 16:09  0% ` Jeffrey Carter
  2013-12-06 16:47  0% ` adambeneschan
@ 2013-12-06 18:35  0% ` G.B.
  2013-12-06 21:59  0% ` Shark8
  3 siblings, 0 replies; 200+ results
From: G.B. @ 2013-12-06 18:35 UTC (permalink / raw)


On 06.12.13 16:14, Simon Wright wrote:
> A poster on Stack Overflow wrote
>
>     Now : Time renames Clock;
>
> (using Ada.Calendar) which made me blink until I realised that it is the
> equivalent of
>
>     Now : constant Time := Clock;
>
> GNAT generates the same code for these two forms. Is there a difference?
> Which form is preferred?


Generated code is (or was) more efficient for arrays because the array
object renamed isn't (or wasn't) copied into the constant.

FTR, with limited types returned by reference (Ada 95),
a difference between renaming and a constant declaration is
that the former is possible.

       type Id is range 1 .. 3;
       type LT is limited private;

       function Choose (Choice : Id) return LT;


       X : LT renames Choose (2);

       Some_Op (Choose (1));


Today, returning an *existing* limited object requires the
use of a pointer, IINM.

^ permalink raw reply	[relevance 0%]

* Re: Renaming vs assignment to constant
  2013-12-06 16:47  0% ` adambeneschan
@ 2013-12-06 18:06  0%   ` Eryndlia Mavourneen
  2013-12-07  0:47  0%   ` Randy Brukardt
  1 sibling, 0 replies; 200+ results
From: Eryndlia Mavourneen @ 2013-12-06 18:06 UTC (permalink / raw)


On Friday, December 6, 2013 10:47:03 AM UTC-6, adambe...@gmail.com wrote:
> On Friday, December 6, 2013 7:14:51 AM UTC-8, Simon Wright wrote:
> > A poster on Stack Overflow wrote
> > 
> >    Now : Time renames Clock;
> > 
> > (using Ada.Calendar) which made me blink until I realised that it is the
> > equivalent of
> > 
> >    Now : constant Time := Clock;
> > 
> > GNAT generates the same code for these two forms. Is there a difference?
> > 
> > Which form is preferred?
> 
> I prefer the second form, mostly because in the first one, Time does not "rename" anything the same way that a variable that renames another variable, or a function that renames another function, does.  (Technically, I think Time renames an anonymous object created by the compiler to hold the function result, although it seems like incorrect English to talk about "renaming" something that didn't have a name in the first place.)
> 
> However, there *might* be a difference between the two forms if the type involved is (1) a task type or a type that contains a task as a subcomponent, (2) a controlled type or a type that contains one, (3) something with a coextension.  I'm really not sure whether there's a difference in any of these cases, and #2 may be a case where some of the differences are or were dependent on the implementation (because of build-in-place semantics).  I'd have to do some research to figure out if there are any differences.  Maybe Randy already knows the answer.  Also, there may be differences related to accessibility levels.  In this simple case that doesn't involve any of those features, I don't think there's a semantic difference.
> 
>                               -- Adam

I believe "rename" is just that -- creating another name for an entity.  There may be a difference in scope of the new name (possibly more limited), but it seems that there should not be any other differences.  Kind of like a sophisticated version of #define that is syntax- and semantic-smart.

-- Eryndlia Mavourneen (KK1T)

^ permalink raw reply	[relevance 0%]

* Re: Renaming vs assignment to constant
  2013-12-06 15:14  5% Renaming vs assignment to constant Simon Wright
  2013-12-06 16:09  0% ` Jeffrey Carter
@ 2013-12-06 16:47  0% ` adambeneschan
  2013-12-06 18:06  0%   ` Eryndlia Mavourneen
  2013-12-07  0:47  0%   ` Randy Brukardt
  2013-12-06 18:35  0% ` G.B.
  2013-12-06 21:59  0% ` Shark8
  3 siblings, 2 replies; 200+ results
From: adambeneschan @ 2013-12-06 16:47 UTC (permalink / raw)


On Friday, December 6, 2013 7:14:51 AM UTC-8, Simon Wright wrote:
> A poster on Stack Overflow wrote
> 
>    Now : Time renames Clock;
> 
> (using Ada.Calendar) which made me blink until I realised that it is the
> equivalent of
> 
>    Now : constant Time := Clock;
> 
> GNAT generates the same code for these two forms. Is there a difference?
> 
> Which form is preferred?

I prefer the second form, mostly because in the first one, Time does not "rename" anything the same way that a variable that renames another variable, or a function that renames another function, does.  (Technically, I think Time renames an anonymous object created by the compiler to hold the function result, although it seems like incorrect English to talk about "renaming" something that didn't have a name in the first place.)

However, there *might* be a difference between the two forms if the type involved is (1) a task type or a type that contains a task as a subcomponent, (2) a controlled type or a type that contains one, (3) something with a coextension.  I'm really not sure whether there's a difference in any of these cases, and #2 may be a case where some of the differences are or were dependent on the implementation (because of build-in-place semantics).  I'd have to do some research to figure out if there are any differences.  Maybe Randy already knows the answer.  Also, there may be differences related to accessibility levels.  In this simple case that doesn't involve any of those features, I don't think there's a semantic difference.

                              -- Adam

^ permalink raw reply	[relevance 0%]

* Re: Renaming vs assignment to constant
  2013-12-06 15:14  5% Renaming vs assignment to constant Simon Wright
@ 2013-12-06 16:09  0% ` Jeffrey Carter
  2013-12-06 16:47  0% ` adambeneschan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 200+ results
From: Jeffrey Carter @ 2013-12-06 16:09 UTC (permalink / raw)


On 12/06/2013 08:14 AM, Simon Wright wrote:
> A poster on Stack Overflow wrote
>
>     Now : Time renames Clock;
>
> (using Ada.Calendar) which made me blink until I realised that it is the
> equivalent of
>
>     Now : constant Time := Clock;
>
> GNAT generates the same code for these two forms. Is there a difference?
> Which form is preferred?

Some people are under the impression that a renaming is more "efficient". I 
prefer that things that are constant be explicitly declared as such.

-- 
Jeff Carter
"I was in love with a beautiful blonde once, dear.
She drove me to drink. That's the one thing I'm
indebted to her for."
Never Give a Sucker an Even Break
109

^ permalink raw reply	[relevance 0%]

* Renaming vs assignment to constant
@ 2013-12-06 15:14  5% Simon Wright
  2013-12-06 16:09  0% ` Jeffrey Carter
                   ` (3 more replies)
  0 siblings, 4 replies; 200+ results
From: Simon Wright @ 2013-12-06 15:14 UTC (permalink / raw)


A poster on Stack Overflow wrote

   Now : Time renames Clock;

(using Ada.Calendar) which made me blink until I realised that it is the
equivalent of

   Now : constant Time := Clock;

GNAT generates the same code for these two forms. Is there a difference?
Which form is preferred?

^ permalink raw reply	[relevance 5%]

* Re: GNAT not generating any code for sub‑program: known bug?
  @ 2013-04-28  7:14  4%   ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2013-04-28  7:14 UTC (permalink / raw)


"Yannick Duchêne (Hibou57)" <yannick_duchene@yahoo.fr> writes:

> Here is:
> http://www.les-ziboux.rasama.org/download/2013-04-28-cla-gnat-bug.zip

The code is

   function Syscall
     (Number  : Positive;
      Handle  : Natural;
      Address : System.Address;
      Size    : Natural)
      return Integer
   is
      Result : Integer;
   begin
      System.Machine_Code.Asm
        (Template => "int $0x80",
         Outputs => Integer'Asm_Output ("=a", Result),
         Inputs =>
           (Positive'Asm_Input       ("a", Number),
            Natural'Asm_Input        ("b", Handle),
            System.Address'Asm_Input ("c", Address),
            Natural'Asm_Input        ("d", Size)),
         Volatile => False);
      return Result;
   end;

and I think that the problem is that Template actually has to use the
inputs and outputs! So, while optimising, the compiler says

   "int $0x80" doesn't use any of the inputs, so I can ignore them
   "int $0x80" doesn't write to any of the outputs, so I can ignore them
   Result isn't changed, so it's undefined
   Therefore I don't need to do anything.

The assembler generated by GNAT GPL 2012 is different but equally
ineffective:

.globl _library__write
_library__write:
LFB3:
        pushq   %rbp
LCFI0:
        movq    %rsp, %rbp
LCFI1:
        leave
LCFI2:
        ret
LFE3:

I think that you have to write the template to show how the parameters
are set up and returned. Here's one I wrote earlier:

   with Ada.Unchecked_Conversion;
   with System.Machine_Code;

   separate (BC.Support.High_Resolution_Time)
   function Clock return Time is

      type Half is (Low, High);
      type Low_High is array (Half) of Interfaces.Unsigned_32;

      Lower, Upper : Interfaces.Unsigned_32;

      function To_Time is new Ada.Unchecked_Conversion (Low_High, Time);

   begin

      System.Machine_Code.Asm
        ("rdtsc" & ASCII.LF & ASCII.HT &
           "movl %%eax, %0"& ASCII.LF & ASCII.HT &
           "movl %%edx, %1",
         Outputs => (Interfaces.Unsigned_32'Asm_Output ("=g", Lower),
                     Interfaces.Unsigned_32'Asm_Output ("=g", Upper)),
         Clobber => "eax, edx",
         Volatile => True);

      return To_Time ((Low => Lower, High => Upper));

   end Clock;

By the way, this doesn't actually work as intended on kit such as the
Macbook Pro (more than one core? advanced power management?), presumably
because the core's clock is slowed down or stopped. Fortunately,
Ada.Calendar.Clock's resolution is 1 microsecond, good enough for most
purposes.



^ permalink raw reply	[relevance 4%]

* Re: A thicker binding for Lapack
  @ 2012-12-29 19:59  5%     ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2012-12-29 19:59 UTC (permalink / raw)


jpwoodruff@gmail.com writes:

> Conclusion:   transpose appears necessary.

For info, the compiler (well, GNAT) will automatically transpose when
doing assignment between arrays with different conventions. And it's
quicker (not by very much at -O2, though).

with Ada.Calendar; use Ada.Calendar;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Float_Random;
with Interfaces.Fortran;
with System.Generic_Array_Operations;
procedure Sauvage_Timing is

   package BLAS is

      --  Copied from old GNAT Interfaces.Fortran.BLAS.

      --  Vector types

      type Real_Vector is array (Integer range <>)
        of Interfaces.Fortran.Real;

      type Complex_Vector is array (Integer range <>)
        of Interfaces.Fortran.Complex;

      type Double_Precision_Vector is array (Integer range <>)
        of Interfaces.Fortran.Double_Precision;

      type Double_Complex_Vector is array (Integer range <>)
        of Interfaces.Fortran.Double_Complex;

      --  Matrix types

      type Real_Matrix is array (Integer range <>, Integer range <>)
        of Interfaces.Fortran.Real;

      type Double_Precision_Matrix
         is array (Integer range <>, Integer range <>)
        of Interfaces.Fortran.Double_Precision;

      type Complex_Matrix is array (Integer range <>, Integer range <>)
        of Interfaces.Fortran.Complex;

      type Double_Complex_Matrix is array (Integer range <>, Integer range <>)
        of Interfaces.Fortran.Double_Complex;

   end BLAS;

   procedure Transpose
   is new System.Generic_Array_Operations.Transpose
     (Scalar => Interfaces.Fortran.Double_Precision'Base,
      Matrix => BLAS.Double_Precision_Matrix);

   type Double_Precision_Matrix is array (Integer range <>, Integer range <>)
     of Interfaces.Fortran.Double_Precision;
   pragma Convention (Fortran, Double_Precision_Matrix);

   A, B : BLAS.Double_Precision_Matrix (1 .. 100, 1 .. 100);
   C : Double_Precision_Matrix (1 .. 100, 1 .. 100);
   pragma Volatile (B);
   pragma Volatile (C);

   Gen : Ada.Numerics.Float_Random.Generator;

   Start, Finish : Time;

   use type Interfaces.Fortran.Double_Precision;

begin

   Ada.Numerics.Float_Random.Reset (Gen);

   for J in A'Range (1) loop
      for K in A'Range (2) loop
         A (J, K) :=
           Interfaces.Fortran.Double_Precision (J * K)
           * Interfaces.Fortran.Double_Precision
           (Ada.Numerics.Float_Random.Random (Gen));
      end loop;
   end loop;

   Start := Clock;
   for J in 1 .. 100 loop
      Transpose (A, B);
   end loop;
   Finish := Clock;
   Put_Line ("Transpose took " & Duration'Image (Finish - Start));

   Start := Clock;
   for J in 1 .. 100 loop
      C := Double_Precision_Matrix (A);
   end loop;
   Finish := Clock;
   Put_Line ("Assignment took" & Duration'Image (Finish - Start));

   declare
      Same : Boolean := True;
   begin
      for J in 1 .. 100 loop
         for K in 1 .. 100 loop
            if B (J, K) /= C (K, J) then
               Same := False;
            end if;
         end loop;
      end loop;
      Put_Line ("B = ~C: " & Same'Img);
   end;

end Sauvage_Timing;



^ permalink raw reply	[relevance 5%]

* Re: Tasking troubles, unexpected termination.
  2012-10-31  2:59  6%       ` Shark8
@ 2012-11-02 16:02  0%         ` Anh Vo
  0 siblings, 0 replies; 200+ results
From: Anh Vo @ 2012-11-02 16:02 UTC (permalink / raw)


On Tuesday, October 30, 2012 7:59:33 PM UTC-7, Shark8 wrote:
> The following edit gives expected behavior: -------------------------------------------------------------- For Index in 1..10 loop declare Use Ada.Calendar; Function Alert Return Ada.Calendar.Time is ( Now + Duration(1.5*Index) ); -- Removed Item declaration in favor of building in-place. begin K.Add( Event => New Notification'( Message => + ("DD"&Positive'Image(Index)), -- Expire at Now and 3*Index seconds. Expiry => New Time'( Alert ) ) ); end; end loop; -------------------------------------------------------------- Though this raises the question of why the other behavior is executed with: Item : Notification:= Notification'( Message => + ("DD"&Positive'Image(Index)), -- Expire at Now and 3*Index seconds. Expiry => New Time'( Alert ) ); [...] K.Add( Event => New Notification'(Item) );

I do not have a good feeling to see these forms do not behave the same way. Thus, I made an initial investigation to see why. I am certain that it has to do with the way Expiry stored in the vector or how this value is extracted during iteration. I will investigate deeper when time permits.




^ permalink raw reply	[relevance 0%]

* Re: Child packages named Ada illegal?
  @ 2012-10-31 17:02  8% ` Shark8
  0 siblings, 0 replies; 200+ results
From: Shark8 @ 2012-10-31 17:02 UTC (permalink / raw)


It's probably an issue of visibility. Consider:

with Ada.Calendar.Time;
Procedure Test is
    package Ada is
    end Ada;
    
    Now : Constant Ada.Calendar.Time:= Ada.Calendar.Clock;
Begin
  null;
End Test;

In this case the Now declaration is prevented from being valid because the type, Time, resides in the package Calendar which is a child of Ada... but Ada at that point refers to Test.Ada which has no Calendar child package.

That te following compiles indicates Ada is not reserved:
Procedure Test is
    Now : Constant Ada.Calendar.Time:= Ada.Calendar.Clock;
Begin
    declare
	package Ada is
	end Ada;
	
    begin
	null;
    end;
End Test;



^ permalink raw reply	[relevance 8%]

* Re: Tasking troubles, unexpected termination.
  2012-10-31  2:17  6%     ` Shark8
@ 2012-10-31  2:59  6%       ` Shark8
  2012-11-02 16:02  0%         ` Anh Vo
  0 siblings, 1 reply; 200+ results
From: Shark8 @ 2012-10-31  2:59 UTC (permalink / raw)


The following edit gives expected behavior:
--------------------------------------------------------------
    For Index in 1..10 loop
	declare
	    Use Ada.Calendar;
	    Function Alert Return Ada.Calendar.Time is
		( Now + Duration(1.5*Index) );
            -- Removed Item declaration in favor of building in-place.
	begin
	    K.Add( Event => New Notification'(
			 Message => + ("DD"&Positive'Image(Index)),
			 -- Expire at Now and 3*Index seconds.
			 Expiry  => New Time'( Alert )
			)
	  );
	end;
    end loop;
--------------------------------------------------------------
Though this raises the question of why the other behavior is executed with:
	    Item  : Notification:=
	      Notification'(
			 Message => + ("DD"&Positive'Image(Index)),
			 -- Expire at Now and 3*Index seconds.
			 Expiry  => New Time'( Alert )
			);
            [...]
	    K.Add( Event => New Notification'(Item) );



^ permalink raw reply	[relevance 6%]

* Re: Tasking troubles, unexpected termination.
  @ 2012-10-31  2:17  6%     ` Shark8
  2012-10-31  2:59  6%       ` Shark8
  0 siblings, 1 reply; 200+ results
From: Shark8 @ 2012-10-31  2:17 UTC (permalink / raw)


Here's the updated code:

---- Scheduling.adb ------------------------------------------
with
Ada.Text_IO,
Ada.Calendar,
Ada.Containers.Indefinite_Vectors,
Ada.Task_Termination,
Ada.Task_Identification,
Task_Debugging;

Procedure Scheduling is

    -- Introduce shorthand so convert Strings to access strings.
    Function "+" (Item : String) Return Not Null Access String is
      ( New String'(Item) );
    
    -- Forward declare the Notification type; indicate it has discriminants.
    Type Notification(<>);
    
    -- Declare Handle for Notifications.
    Type Notification_Handle is Not Null Access Notification;
    
    Type Notification(	Message	: Not Null Access String;
			Expiry	: Not Null Access Ada.Calendar.Time
		     ) is null record;
    
    -- Declare the Timing-task.
    Task Type Timing ( Resolution : Not Null Access Duration ) is
	Entry Add( Event : Notification_Handle );
    end Timing;

    
    -- Implementation for the timing-task.
    Task body Timing is

	-- Package for showing Duration.
	Package Decimal_Display is new Ada.Text_IO.Fixed_IO( Duration );
	
	-- Internal package, defining Vectors holding notification handles.
	Package Notification_Vector is New Ada.Containers.Indefinite_Vectors
	  ( Index_Type => Positive, Element_Type => Notification_Handle );
	Use Notification_Vector;
	
	-- Handle expired messages.
	Procedure Handle_Expiration( List : in out Vector ) is
	    Use Ada.Calendar, Ada.Text_IO;
	    Length : Positive:= Positive(List.Length);
	    Now    : Time:= Clock;

	    -- We flag everything to be deleted, as tampering with the cursor is
	    -- not good.
	    Type Deletion_Flags is Array(1..Length) of Boolean;
	    Deletion_Marks : Deletion_Flags:= (Others => False);
	    
	    
	    procedure Execute(Position : Cursor) is
		Item	: Constant Notification_Handle:= Element(position);
		Index	: Constant Positive:= Positive( To_Index(position) );
	    begin
		Deletion_Marks(Index):= Now >= Item.Expiry.All;
		--
		Ada.Text_IO.Put( ASCII.HT & "Exipration: " );
		Decimal_Display.Put( Item.Expiry.All - Now, Fore => 2, Aft => 3 );
		Ada.Text_IO.New_Line;
	    end Execute;

	begin
	    -- Iterate through the vector's elements; old-style iterator.
	    List.Reverse_Iterate( Process => Execute'Access );

	    -- Delete flagged elements; iteration bckwards to preserve indicies.
	    For Index in reverse Deletion_Marks'Range loop
		if Deletion_Marks(Index) then
		    
		    Put_Line( "Message: " & List(Index).Message.All);
		    List.Delete( Index );
		end if;
	    end loop;
	    
	    -- Render a report on the new length, if it was altered.
	    declare
		Post_op_length : Natural:= Natural(List.Length);
	    begin
		if Length /= post_op_length then
		    Put_Line( "Deleted items; New Length:" &  post_op_length'Img);
		end if;
	    end;
	end Handle_Expiration;

	-- Declare a Vector to hold all the nofifications.
	Notification_List : Vector:= Empty_Vector;
	
	Use Ada.Task_Termination, Task_Debugging, Ada.Containers, Ada.Calendar;
	
	-- Mark the start-time.
	Start : Time:= Clock;
	
--	Function Elapsed Return String is
--	  ( Duration'Image(Clock - Start)(1..7) );
	Function Elapsed Return Duration is
	  ( Clock - Start );

    begin
	-- Set our debugging-handler for this task.
	Ada.Task_Termination.Set_Specific_Handler(
		T       => Ada.Task_Identification.Current_Task,
		Handler => Debug.Termination'Access );

	-- When there are no items in our internal vector, then we need can only
	-- accept Add or terminate the task.
	-- When we add an item, then we can either add another item or when the
	-- time expires iterate the vector and handling Notifications as needed.
	loop
	    select 
		accept Add( Event : Notification_Handle ) do
		    Notification_List.Append( Event );
		end add;
		while not Notification_List.Is_Empty loop
		    Ada.Text_IO.Put( "Elapsed:" );
		    Decimal_Display.Put( Elapsed, Fore => 2, Aft => 3 );
		    Ada.Text_IO.New_Line;
		    Handle_Expiration( List => Notification_List );
		    select
			accept Add( Event : Notification_Handle ) do
			    Notification_List.Append( Event );
			    Ada.Text_IO.Put_Line( "New Length: " & Notification_List.Length'Img );
			    Ada.Text_IO.Put( ASCII.HT & "Exipration: " );
			    Decimal_Display.Put( Event.Expiry.All - Clock, Fore => 2, Aft => 3 );
			    Ada.Text_IO.New_Line;
			end add;
		    or
			delay Timing.Resolution.All;
		    end select;
		end loop;
		Ada.Text_IO.Put_Line( "EMPTY." );
	    or
		terminate;
	    end select;
	end loop;
    end Timing;
    
    
      
    K : Timing( Resolution => New Duration'(2.0) ); -- 2 second resolution.
    Now : Ada.Calendar.Time:= Ada.Calendar.Clock;
begin
    For Index in 1..10 loop
	declare
	    Use Ada.Calendar;
	    Item : Notification(
			 Message => + ("DD"&Positive'Image(Index)),
			 -- Expire at Now and 3*Index seconds.
			 Expiry  => New Time'( Now + Duration(Index) )
			);
	begin
	    K.Add( Event => New Notification'(Item) );
	end;
    end loop;
    
    -- Add an element in the past... it should immediately be operated on.
    K.Add( Event => New Notification'(
	Message => + ("Last."),
	Expiry  => New Ada.Calendar.Time'( Now )
	)
    );

end Scheduling;

---- Task_Debugging.ads ----------------------------------------------
-- The following are not strictly nessacary, but used in this example for 
-- debugging purposes.
With
System.Address_To_Access_Conversions,
Ada.Unchecked_Conversion,
Ada.Exceptions.Traceback,
Ada.Task_Identification,
Ada.Task_Termination;

Package Task_Debugging is
    Pragma Elaborate_Body;
    
    Protected Type Debugging is
	-- Termination debugging function.
	procedure Termination(
				 Cause : Ada.Task_Termination.Cause_Of_Termination;
				 T     : Ada.Task_Identification.Task_Id;
				 X     : Ada.Exceptions.Exception_Occurrence);

    End Debugging;
    
    -- Debug, an instance of our debugging object.
    Debug : Debugging;
    
End Task_Debugging;

---- Task_Debugging.adb ----------------------------------------------
With Ada.Text_IO;

Package Body Task_Debugging is

    Protected body Debugging is
	-- Termination debugging function.
	procedure Termination(
		       Cause : Ada.Task_Termination.Cause_Of_Termination;
		       T     : Ada.Task_Identification.Task_Id;
		       X     : Ada.Exceptions.Exception_Occurrence) is
	    Use Ada.Text_IO, Ada.Task_Termination, Ada.Exceptions;
	begin
	    Put_Line("Termination: "& Cause'Img);
	    case Cause is
	    When Normal | Abnormal => Null;
	    When Unhandled_Exception =>
		Put_Line( Exception_Name(X)&": "&Exception_Message(X) );
	    end case;
	end Termination;	
    end Debugging;

End Task_Debugging;
---------------------------------------------------------------------------

I've fixed the original problems (first the "tampering", and second a constraint_error) but there's still something strange going on. The discriminants for notifications seem to be being ignored (or rather the latest one being used).

Here's the output:
C:\Programming\Projects\Scheduler>scheduling.exe
Elapsed: 0.000
        Exipration:  0.984
New Length:  2
        Exipration:  1.983
Elapsed: 0.002
        Exipration:  1.982
        Exipration:  1.982
New Length:  3
        Exipration:  2.981
Elapsed: 0.004
        Exipration:  2.980
        Exipration:  2.980
        Exipration:  2.980
[...]
Message: Last.
Deleted items; New Length: 10
Elapsed: 2.047
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
        Exipration:  7.938
Elapsed: 4.051
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
        Exipration:  5.933
Elapsed: 6.061
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
        Exipration:  3.923
Elapsed: 8.086
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
        Exipration:  1.898
Elapsed:10.106
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
        Exipration: -0.122
Message: DD 10
Message: DD 9
Message: DD 8
Message: DD 7
Message: DD 6
Message: DD 5
Message: DD 4
Message: DD 3
Message: DD 2
Message: DD 1
Deleted items; New Length: 0
EMPTY.
Termination: NORMAL

As you can see, instead of each element being different they're all tagged as having the same expiration.



^ permalink raw reply	[relevance 6%]

* Tasking troubles, unexpected termination.
@ 2012-10-30 22:03  6% Shark8
    0 siblings, 1 reply; 200+ results
From: Shark8 @ 2012-10-30 22:03 UTC (permalink / raw)


with
Ada.Text_IO,
Ada.Calendar,
Ada.Containers.Indefinite_Vectors;

Procedure Scheduling is

    -- Introduce shorthand so convert Strings to access strings.
    Function "+" (Item : String) Return Not Null Access String is
      ( New String'(Item) );
    
    -- Forward declare the Notification type; indicate it has discriminants.
    Type Notification(<>);
    
    -- Declare Handle for Notifications.
    Type Notification_Handle is Not Null Access Notification;
    
    Type Notification(	Message	: Not Null Access String;
			Expiry	: Not Null Access Ada.Calendar.Time
		     ) is null record;
    
    -- Declare the Timing-task.
    Task Type Timing ( Resolution : Not Null Access Duration ) is
	Entry Add( Event : Notification_Handle );
    end Timing;


    -- Implementation for the timing-task.
    Task body Timing is
	-- Internal package, defining Vectors holding notification handles.
	Package Notification_Vector is New Ada.Containers.Indefinite_Vectors
	  ( Index_Type => Positive, Element_Type => Notification_Handle );
	Use Notification_Vector;
	
	-- Declare a Vector to hold all the notifications.
	Notification_List : Vector:= Empty_Vector;
	
	Procedure Handle_Expiration is
	    Use Ada.Calendar, Ada.Text_IO;
	    Length : Positive:= Positive(Notification_List.Length);
	    Now    : Time:= Clock;
	begin
	    -- Iterate through the vector's elements; reversed so that deletion
	    -- does not intefere with the iteration.
	    for Index in reverse 1..Length loop
		declare
		    Item : Notification_Handle Renames Notification_List(Index);
		begin
		    -- If it's reached the expiry, then we display the message
		    -- and remove the item.
		    if Now > Item.Expiry.All then
			Put_Line( "Message: " & Item.Message.All);
			Notification_List.Delete(Index);
		    end if;
		end;
	    end loop;
	    
	    declare
		Post_op_length : Positive:= Positive(Notification_List.Length);
	    begin
		if Length /= post_op_length then
		    Put_Line( "Deleted items; New Length:" &  post_op_length'Img);
		end if;
	    end;
	end Handle_Expiration;

	Use Ada.Containers;
    begin
	-- When there are no items in our internal vector, then we need can only
	-- accept Add or terminate the task.
	-- When we add an item, then we can either add another item or when the
	-- time expires iterate the vector and handling Notifications as needed.
	loop
	    select 
		accept Add( Event : Notification_Handle ) do
		    Notification_List.Append( Event );
		end add;
		while not Notification_List.Is_Empty loop
		    Handle_Expiration;
		    select
			accept Add( Event : Notification_Handle ) do
			    Notification_List.Append( Event );
			    Ada.Text_IO.Put_Line( "New Length: " & Notification_List.Length'Img );
			end add;
		    or
			delay Timing.Resolution.All;
		    end select;
		end loop;
		Ada.Text_IO.Put_Line( "EMPTY. Length: " & Notification_List.Length'Img );
	    or
		terminate;
	    end select;
	end loop;
    end Timing;
    
    
    K : Timing( Resolution => New Duration'(2.0) );
    
begin
    For Index in 1..10 loop
	declare
	    Use Ada.Calendar;
	    Expire : Time:= Clock + (Index*2.0); -- Now and 2*Index seconds.
	    Item : Notification(
			 Message => + ("DD"&Positive'Image(Index)),
			 Expiry  => New Time'( Expire )
			);
	begin
	    K.Add( Event => New Notification'(Item) );
	end;
    end loop;
end Scheduling;

----------------------------------

Output:
C:\Programming\Projects\Scheduler>scheduling.exe
New Length:  2
New Length:  3
New Length:  4
New Length:  5
New Length:  6
New Length:  7
New Length:  8
New Length:  9
New Length:  10
Message: DD 10


As you can see there's something happening to force termination -- there should at the least be an new-length message -- this leads me to believe [or, more accurately, guess] that there's some exception happening in the task which is blowing everything up.

Is that the case?
Also, if there is some tasking-exceptions interaction, how do I force them to display [and/or handle them] instead of falling off a cliff?



^ permalink raw reply	[relevance 6%]

* Re: Ganssle plugs Ada
  @ 2012-09-14 21:29  4% ` Shark8
  0 siblings, 0 replies; 200+ results
From: Shark8 @ 2012-09-14 21:29 UTC (permalink / raw)


Thanks for sharing that; it was a pretty good read.

I found some of the objections in the comments to be rather amusing; in particular this list [comments added]:

>1. Software that was not designed or specified right so that software implemented according to spec would not function correctly in the real world.

-- Granted; that's the problem with having an incorrect model. No language can help there.

> 2. Algorithmic errors. Poorly implemented algorithms. A sort that doesn't, for example.

-- No language can keep you from logic errors like ">" instead of ">=" -- Ada does help in this regard as much as it is able to by not cluttering the "operator namespaces" with similar symbols; this touches two of Ada's design goals: Readability & Maintainability.

> 3. Oversights of the metres vs feet variety, or poor calibration/filtering etc resulting in incorrect calculations.

-- Ada addresses this in as far as possible by disallowing different [numeric] types from freely interacting.

> 4. Timing/locking issues.

-- Ada spent lots of effort dealing with this; there's the Ada.Calendar package, the Duration type, and protected objects/methods which can severely cut down on race-conditions.

> 5. Incorrect hardware handling. For example using edge triggered instead of level triggered interrupts resulting in peripherals going to sleep and product failure.

-- I've not done a lot of low-level work... but I'm under the impression that Ada's interrupt handlers work perfectly fine.

> 6. Buffer overflows, poor pointer handling and the like.
>
> Ada can only address (6).

-- Nope, Ada addressed at least 2/3rds of that list.

> Valgrind etc can help to find (6) too when these turn up in C.

-- Ah, yes, 'help'.



^ permalink raw reply	[relevance 4%]

* Re: how to tell gnatmake to send executables to a different directory when compiling multi source?
  @ 2012-07-30 10:31  3%                       ` Vasiliy Molostov
  2012-07-30 11:05  0%                         ` Ludovic Brenta
  0 siblings, 1 reply; 200+ results
From: Vasiliy Molostov @ 2012-07-30 10:31 UTC (permalink / raw)


Ludovic Brenta <ludovic@ludovic-brenta.org> писал(а) в своём письме Mon,  
30 Jul 2012 10:40:28 +0400:

> No, even in C an object file corresponds to not one but *several* input
> files: one or possibly several *.c and many *.h files.  Make was
> invented to compensate for the deficiencies of C, which does not track
> dependencies, and Make does a bad job of that, even in simple projects.

As we can see from predefined make rules

%.o: %.c

which means that C input source file has a direct correspondence to a  
resulting object file, and which is not applicable to gnat ada sources at  
all. Make is a general tool supporting that strict input-output pairing  
correspondence approach.

As for dependencies of C code and header files (*.h) they are come from  
gcc autogenerated dependencies, lately included into makefile as a part.  
And indeed it is a helper, since a hand intervention is still might be  
required to express an author wish.

The way it works is similar to all C stuff, someone has even named it as  
dancing with a blade. Is it danger? Perhaps. Is it devil?

>> But why the "recursive" is devil? Usual project contains many files
>> that needs to be built, not only source code, but data, man pages and
>> docs,  configurations, all these are separate and usually built via
>> recursive  makefiles.
>
> Just because many lemmings are wrong doesn't make them right.  Read the
> paper; it explains very well how recursive makefiles defeat dependency
> management completely.  This is the cause for the biggest and most
> insidious problems.

I have read them in a count that is inappropriate for the moment, many  
papers expressing novice opinion about danger of any thing, similar to  
warnings about smoking and fugu fish eating. None of them are good,  
because make (fish, smoke) still exist and widely used and happily  
consumed. And used mush more widely than Ada or Java.

If someone fills that people in danger with that tool, please be so kind  
to correct existing or to write a better tool, which is the right way, but  
as for me I am sick and tired from advices about devil things (like  
ada.calendar.time), those came from personal desire, and produce only  
warring about a need (a requirement!) of restrictive use, without  
constructive movement forward.

>> Why to name a good time-proven tool as devil? I see no reason, only
>> tendentious and imperatively expressed opinion.
>
> Make and especially recursive make have been time-proven to be fragile,
> unmaintainable, error-prone and inefficient.

Do you plan to rewrite all these old good debian packages?

> It is possible and recommended to
> use make the same way, i.e. by means of include Makefiles instead of
> recursive.

You can suppose here that make can include not complete makefiles but  
dependency info collected by a separate tool.

> This is a valid point.  The problem is that Make doesn't know about
> dependencies between Ada units like gnatmake does; therefore Make
> violates the Ada Reference manual.  In short, when compiling Ada you
> *must* use gnatmake or its equivalent for another compiler than GNAT.
> And yo *must* use whatever configuration file is appropriate for
> gnatmake.

*must* should better sounds with *can*, since this approach relates to  
GNAT only. And as a consequence the GNAT compilation model approach can  
not turn makefile into a devil thing. This is the same as personal haircut  
can not turn outer world into an ambiguous state.

> Ada has none of these deficiencies.
>
>> For Ada with gnat these are not appropriate enough of course, but it
>> is not due to recursively calling make, or autotools by itself. They
>> are just other tools for doing another things, and nothing
>> else. Regarding autotools and ada, take a look at AWS source - I dont
>> know why but you still need to 'configure' it. Would you like to know
>> why?
>
> I know why.  The configure in AWS is not constructed with autoconf, it
> is written by hand and is minimalistic.  The things that need
> configuring are: whether or not to support SSL or GNU TLS,
> etc. i.e. which libraries other than AWS are present on the system and
> should be used.  And AWS does not use automake either.

So here we can see when "none of these deficiencies" becomes a need to  
establish environment capabilities in "tls/ssl and etc" dependencies. So  
the correct answer here is that GNAT Ada has some deficiencies but in  
general they are different from C approach.

And no devil, indeed.
-- 
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/



^ permalink raw reply	[relevance 3%]

* Re: how to tell gnatmake to send executables to a different directory when compiling multi source?
  2012-07-30 10:31  3%                       ` Vasiliy Molostov
@ 2012-07-30 11:05  0%                         ` Ludovic Brenta
  0 siblings, 0 replies; 200+ results
From: Ludovic Brenta @ 2012-07-30 11:05 UTC (permalink / raw)


Vasiliy Molostov wrote on comp.lang.ada:
> Ludovic Brenta <ludovic@ludovic-brenta.org> писал(а) в своём письме Mon,  
> As we can see from predefined make rules
> 
> %.o: %.c
> 
> which means that C input source file has a direct correspondence to a  
> resulting object file, and which is not applicable to gnat ada sources at  
> all. Make is a general tool supporting that strict input-output pairing  
> correspondence approach.
> 
> As for dependencies of C code and header files (*.h) they are come from  
> gcc autogenerated dependencies, lately included into makefile as a part.

Don't you see how wrong this approach is?
- The Makefile must call gcc -M to generate the dependencies and store
  them in a file
- The Makefile *cannot* include the generated dependency file while it
  runs
- therefore you must run make twice: (1) to generate the dependency info
  and (2) to build using the dependency info.

Add to that that Make dependencies do not take compiler flags into account
(gnatmake does) and are therefore incomplete.  For example:

all: foo
foo: a.o b.o
        gcc -o $@ $<

is not good enough, even when supplemented by generated source
dependencies. Why? Because when CFLAGS contains -O3 or some explicit
option, cross-unit inlining comes into the picture, so a.o does not depend
on "just" b.o, it depends on a b.o compiled with the *same compiler
options*.  Make simply does not capture this dependency information.

> The way it works is similar to all C stuff, someone has even named
> it as dancing with a blade. Is it danger? Perhaps. Is it devil?

Yes.

> If someone fills that people in danger with that tool, please be so kind  
> to correct existing or to write a better tool, which is the right way, but  

Correcting make is impossible without breaking compatibility with existing
makefiles.  Therefore the only option is to replace make completely.
gnatmake and gprbuild exist for this very purpose; so do all of the make
alternatives mentioned elsewhere in this thread.

> as for me I am sick and tired from advices about devil things (like  
> ada.calendar.time), those came from personal desire, and produce only  
> warring about a need (a requirement!) of restrictive use, without  
> constructive movement forward.

The constructive movement forward is: use *existing* better tools.
If you still *must* use make, do that non-recursively.

> Do you plan to rewrite all these old good debian packages?

No. I have *already* written all my Debian packages non-recursively
and I routinely bypass upstream's fragile recursive makefiles with
one non-recursive, simple makefile and one GNAT project file.  And
I usually specify .SUFFIXES in most of my Makefiles because the
predefined rules just get in the way.

BTW, many "old good Debian packages" are actually old and bad; this
is being revealed by the growing number of build failures triggered
by parallelism.  To the point where many "old good Debian packages",
rather than fixing or rewriting their recursive makefiles completely,
disable parallel builds altogether.

>> dependencies between Ada units like gnatmake does; therefore Make
>> violates the Ada Reference manual.  In short, when compiling Ada you
>> *must* use gnatmake or its equivalent for another compiler than GNAT.
>> And yo *must* use whatever configuration file is appropriate for
>> gnatmake.
> 
> *must* should better sounds with *can*, since this approach relates to  
> GNAT only.  And as a consequence the GNAT compilation model approach can

No.  This approach exists with all Ada compilers and with several other
languages that mandate the precise tracking of dependencies between
compilation units like OCaml and, to a lesser extent, Java.
  
> not turn makefile into a devil thing. This is the same as personal haircut  
> can not turn outer world into an ambiguous state.

No.  While a personal haircut creates no danger, recursive makefiles do
create danger.

> So here we can see when "none of these deficiencies" becomes a need to  
> establish environment capabilities in "tls/ssl and etc" dependencies. So  
> the correct answer here is that GNAT Ada has some deficiencies but in  
> general they are different from C approach.

No. The reason for the existence of "configure" in AWS is because the
external, optional dependencies are not written in Ada.  In the Debian
package for AWS, I bypass configure and upstream's makefile completely.
Instead I use one non-recursive Makefile and one GNAT project file, as
usual.  This is fast and reliable.  And I don't need to call configure
because Debian allows me to control which external libraries must be
present before building AWS.

-- 
Ludovic Brenta.



^ permalink raw reply	[relevance 0%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-23 22:07 11% ` Adam Beneschan
       [not found]       ` <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com>
  2012-07-24  7:24  6%   ` erlo.haugen
@ 2012-07-24  7:37  6%   ` erlo.haugen
  2 siblings, 0 replies; 200+ results
From: erlo.haugen @ 2012-07-24  7:37 UTC (permalink / raw)


> My gut feeling is that if NTP gives you a time in the range 1-1-1900 to 12-31-1900, something is pretty wrong because computers didn&#39;t exist during that time period.  So I&#39;m not really sure what the issue is.  I think you need to be more specific about what you&#39;re trying to do.  What kind of value is your program using for an &quot;NTP time&quot;--is it an integer, and if so, what does it represent (seconds since 1-1-1900, nanoseconds since 1-1-1900, or what)?  Are you trying to see if an NTP time is less than or greater than a value of Ada.Calendar.Time, or compute the difference in seconds (or something else) between an NTP time value and an Ada.Calendar.Time value, or what?  
> 
>                         -- Adam
I want to compare two timestamps, a Unix timestamp and an NTP timestamp. Both are seconds since their respective epoch.

Erlo



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 20:33 10%     ` Simon Wright
@ 2012-07-25 10:14 13%       ` Simon Wright
  2012-07-25 13:16  6%         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Simon Wright @ 2012-07-25 10:14 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> Of course, if you are worried about leap seconds, you are in for a
> world of pain either way.

But since the time received via NTP is UTC *now* and
Ada.Calendar.Time_Zones.UTC_Time_Offset allows you to convert
Ada.Calendar.Clock times to UTC *now*, I think you should ignore all
posts about political time vs GMT vs UTC.

Unless you are really concerned about time intervals of years.



^ permalink raw reply	[relevance 13%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  7:11 11%     ` Dmitry A. Kazakov
@ 2012-07-24  7:50  6%       ` erlo.haugen
  2012-07-24  8:14 10%         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: erlo.haugen @ 2012-07-24  7:50 UTC (permalink / raw)


Den tirsdag den 24. juli 2012 09.11.57 UTC+2 skrev Dmitry A. Kazakov:
> On Tue, 24 Jul 2012 00:37:13 -0400, Dennis Lee Bieber wrote:
> 
> &gt; On Mon, 23 Jul 2012 15:07:48 -0700 (PDT), Adam Beneschan
> &gt; &lt;adam@irvine.com&gt; declaimed the following in comp.lang.ada:
> &gt; 
> &gt; My gut feeling is that if NTP gives you a time in the range 1-1-1900 to
> &gt; 12-31-1900, something is pretty wrong because computers didn&#39;t exist
> &gt; during that time period.  So I&#39;m not really sure what the issue is.  I
> &gt; think you need 
> &gt; 
> &gt; 	Nonetheless, it appears that a 128bit value of all 0s represents the
> &gt; epoch for Network Time Protocol...
> 
> Is NTP political time? If not, it does not make much sense to convert it
> Ada.Calendar.Time anyway. Ada.Real_Time.Time looks more appropriate.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Enlighten me please, what is meant by 'political time'?

Erlo



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 18:28 11%       ` Dmitry A. Kazakov
  2012-07-24 19:07 11%         ` Adam Beneschan
@ 2012-07-24 19:43  9%         ` Vasiliy Molostov
  2012-07-24 20:29  6%           ` Dmitry A. Kazakov
  1 sibling, 1 reply; 200+ results
From: Vasiliy Molostov @ 2012-07-24 19:43 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> писал(а) в своём письме Tue,  
24 Jul 2012 22:28:27 +0400:

> Furthermore, operations like UTC_Time_Offset, Time_Of, Split for some
> distant time in the past, e.g. 1901 are most likely wrong, because  
> OS/Ada's
> RTL cannot keep track of all political changes of all time zones in order
> to be able to evaluate the number of seconds from present time to 1901 in
> the time zone. It is *not* the number of years multiplied by the year's
> duration. (IANA Time Zone Database or alike is required for that)
>
> Calculating future times is absolutely impossible because that depends on
> future decisions of the corresponding governmental bodies having the
> authority over the time zone, from daylight saving time to changing the
> whole zone.

I took a look at  
http://www.ada-auth.org/cgi-bin/cvsweb.cgi/ai05s/ai05-0119-1.txt

And I can say that there is a mis .... "misviewving" of the Time, UTC time  
and Zoned Time (political)

While typical application takes time from some sort of monotonic time  
source (e.g. clock), which is supposed to be one and authoritative for  
such application, it is in the same moment this application also deals  
with time representation, and a "political" time (zoned) is one of such  
representations.

Probably and personally, I don't prefer to convert between representations  
and catch one or two hour diffs, instead I prefer to do calculations  
better done with monotonic time, and then convert result to the required  
representation.

Converting from some representation into authoritative monotonic time is  
"mission impossibe", since important data may be lost, because this  
important data belongs entirely to the representation, and can not be  
expressed in monotonic authoritative source.

Things like "ada.calendar is a fake" are just based on "speculative  
cone-moving" between "time real value" and "time representation".

>
> This is why it is better not to touch Ada.Calendar.Time.
>
> Ada.Real_Time, Duration, Time_Span, some numeric type would be much  
> better
> candidates.
>


-- 
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/



^ permalink raw reply	[relevance 9%]

* Ada.Calendar and NTP (and Unix Epoch)
@ 2012-07-23 21:42 14% erlo
  2012-07-23 22:07 11% ` Adam Beneschan
                   ` (2 more replies)
  0 siblings, 3 replies; 200+ results
From: erlo @ 2012-07-23 21:42 UTC (permalink / raw)


The following code raises an ADA.CALENDAR.TIME_ERROR exception:

with Calendar;
with Calendar.Conversions;
with Calendar.Arithmetic;
with Calendar.Formatting;
with Text_IO;
with Ada.Exceptions;

use Calendar;
use Text_IO;


procedure Main is
    AdaTid : Time;
begin
    AdaTid := Conversions.To_Ada_Time(tm_year  => 00,
                                      tm_mon   => 00,
                                      tm_day   => 01,
                                      tm_hour  => 0,
                                      tm_min   => 0,
                                      tm_sec   => 0,
                                      tm_isdst => 0); -- raises exception


    put_line(Formatting.Image(Date                  => AdaTid,
                              Include_Time_Fraction => False,
                              Time_Zone             => 0));

end Main;

This is because Ada.Calendar starts at 1-1-1901. But NTP starts at 
1-1-1900, so how can I work my way around this issue? I need to compare 
NTP time with Unix Epoch based time.

Erlo



^ permalink raw reply	[relevance 14%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-23 21:42 14% Ada.Calendar and NTP (and Unix Epoch) erlo
@ 2012-07-23 22:07 11% ` Adam Beneschan
       [not found]       ` <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com>
                     ` (2 more replies)
  2012-07-24 11:34  6% ` Simon Wright
  2012-07-25  2:23  6% ` sla29970
  2 siblings, 3 replies; 200+ results
From: Adam Beneschan @ 2012-07-23 22:07 UTC (permalink / raw)


On Monday, July 23, 2012 2:42:32 PM UTC-7, erlo wrote:
> The following code raises an ADA.CALENDAR.TIME_ERROR exception:
> 
> with Calendar;
> with Calendar.Conversions;
> with Calendar.Arithmetic;
> with Calendar.Formatting;
> with Text_IO;
> with Ada.Exceptions;
> 
> use Calendar;
> use Text_IO;
> 
> 
> procedure Main is
>     AdaTid : Time;
> begin
>     AdaTid := Conversions.To_Ada_Time(tm_year  => 00,
>                                       tm_mon   => 00,
>                                       tm_day   => 01,
>                                       tm_hour  => 0,
>                                       tm_min   => 0,
>                                       tm_sec   => 0,
>                                       tm_isdst => 0); -- raises exception
> 
> 
>     put_line(Formatting.Image(Date                  => AdaTid,
>                               Include_Time_Fraction => False,
>                               Time_Zone             => 0));
> 
> end Main;
> 
> This is because Ada.Calendar starts at 1-1-1901. But NTP starts at 
> 1-1-1900, so how can I work my way around this issue?

My gut feeling is that if NTP gives you a time in the range 1-1-1900 to 12-31-1900, something is pretty wrong because computers didn't exist during that time period.  So I'm not really sure what the issue is.  I think you need to be more specific about what you're trying to do.  What kind of value is your program using for an "NTP time"--is it an integer, and if so, what does it represent (seconds since 1-1-1900, nanoseconds since 1-1-1900, or what)?  Are you trying to see if an NTP time is less than or greater than a value of Ada.Calendar.Time, or compute the difference in seconds (or something else) between an NTP time value and an Ada.Calendar.Time value, or what?  

                        -- Adam



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 20:29  6%           ` Dmitry A. Kazakov
@ 2012-07-24 21:22  5%             ` Vasiliy Molostov
  2012-07-25  6:32  6%               ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Vasiliy Molostov @ 2012-07-24 21:22 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> писал(а) в своём письме Wed,  
25 Jul 2012 00:29:00 +0400:

> On Tue, 24 Jul 2012 23:43:49 +0400, Vasiliy Molostov wrote:
>
>> Probably and personally, I don't prefer to convert between  
>> representations
>> and catch one or two hour diffs, instead I prefer to do calculations
>> better done with monotonic time, and then convert result to the required
>> representation.
>
> This is the only right way to do it.
>
>> Converting from some representation into authoritative monotonic time is
>> "mission impossibe", since important data may be lost, because this
>> important data belongs entirely to the representation, and can not be
>> expressed in monotonic authoritative source.
>
> Possible, but under two conditions:
>
> 1. the corresponding time sources are synchronized;

If you can synchronize representations, you are a god of time  
representations. Be aware of Mars orbiter time representation and its  
political times.
Also take into account that a matter of some incorrectly raised question  
may issue very ample answers, involving presidential elections also.

In a nut shell, a transformational function for converting *time  
representation* should take into account those parameters, that you have  
not in your (or your opponent) application, so you can tell only relative  
*time representation*, relative to your environment, in which your app (or  
your opponent) running. It is very funny to see people converting these  
relative things on the fly (without parametrized transformation, unlinked  
to the common and absolute source), and concluding that they don't match  
something speculatively implied, indeed. Even if these are syncronized.

>
> 2. the representation is sane (anything but political time).
>

It is sane by legislative rules that are out of Ada standard control, you  
know. It is very obvious question, and I see this as an intentional  
mistake.

-- 
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/



^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  7:24  6%   ` erlo.haugen
  2012-07-24 16:26 11%     ` Adam Beneschan
@ 2012-07-24 20:33 10%     ` Simon Wright
  2012-07-25 10:14 13%       ` Simon Wright
  1 sibling, 1 reply; 200+ results
From: Simon Wright @ 2012-07-24 20:33 UTC (permalink / raw)


erlo.haugen@gmail.com writes:

>> My gut feeling is that if NTP gives you a time in the range 1-1-1900
>> to 12-31-1900, something is pretty wrong because computers
>> didn't exist during that time period.  So I'm not really
>> sure what the issue is.  I think you need to be more specific about
>> what you're trying to do.  What kind of value is your program
>> using for an "NTP time"--is it an integer, and if so, what
>> does it represent (seconds since 1-1-1900, nanoseconds since
>> 1-1-1900, or what)?  Are you trying to see if an NTP time is less
>> than or greater than a value of Ada.Calendar.Time, or compute the
>> difference in seconds (or something else) between an NTP time value
>> and an Ada.Calendar.Time value, or what?
>> 
>>                         -- Adam
> NTP epoch 1 started 1-1-1900 0:00, just like the Unix epoch started
> 1-1-1970 0:00. So when I get a time from an NTP-server, I get seconds
> from the start of the NTP epoch.

Yes; but if you regard the 64-bit value as a *signed* value then the
current NTP value is about -24 years. The next NTP epoch is in 2036,
which is easily representable in Ada.Calendar.Time. So, *add* -24 to
2036 and, presto, 2012! In UTC.

Of course, if you are worried about leap seconds, you are in for a world
of pain either way.

From Wikipedia[1],

   NTP delivers UTC time. UTC is subject to scheduled leap seconds to
   synchronize the timescale to the rotation of the earth. When a leap
   second is added, NTP is suspended for 1 second. Because NTP has no
   mechanism for remembering the history of leap seconds, leap seconds
   cause the entire NTP timescale to shift by 1 second.

[1] http://en.wikipedia.org/wiki/Network_Time_Protocol#Leap_seconds



^ permalink raw reply	[relevance 10%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 12:27 11%               ` erlo.haugen
@ 2012-07-24 13:02 11%                 ` Dmitry A. Kazakov
  2012-07-24 14:10  6%                   ` erlo
  2012-07-24 16:37  6%                 ` Adam Beneschan
  1 sibling, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24 13:02 UTC (permalink / raw)


On Tue, 24 Jul 2012 05:27:30 -0700 (PDT), erlo.haugen@gmail.com wrote:

>> Where is a problem then?
>> 
>>    E1 + T1 vs. E2 + T2
>> 
>> &lt;=&gt;
>> 
>>    T1 vs. (E2 - E1) + T2
>> 
>> Where E2 - E1 is the time offset between the epochs.
> 
> That's true, the issue here is that I was fooled by Ada.Calendar.Conversion spec

Is it a standard Ada package?

> into thinking that I can use To_Ada_Time to convert the NTP epoch base
> (1-1-1900 0:00) to a variable of type Time.

Take some other base, e.g. 01.01.2010 00:00 [UTC, GMT, CET ...], if you
have an NTP reading of it. E.g. if NTP uses some astronomical year or other
method to calculate difference between two times.

You should not use Ada.Calendar without knowing exactly what time it
represents on the given machine.

>> This presumes that they represent *same* time though maybe using different
>> epochs. You might need to read the UNIX and NTP documentation to learn what
>> exactly times they do represent. That would give you E2 - E1. To put it
>> simple: same time = synchronized clocks.
> 
> This is the exact case.

Which I doubt, but anyway.
 
-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 19:25  6%         ` Simon Wright
@ 2012-07-24 22:07  6%           ` Georg Bauhaus
  0 siblings, 0 replies; 200+ results
From: Georg Bauhaus @ 2012-07-24 22:07 UTC (permalink / raw)


On 24.07.12 21:25, Simon Wright wrote:
> Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:
>
>> In the end, the world frame operators will succeed in convincing
>> computer users that they always need to ask the operator do anything
>> with their computers. It is very well possible to adjust CSS settings
>> to personal preferences using what is called a user style sheet.
>
> I couldn't see a way to do this with Safari. I followed the recipe I
> found on the Web for Firefox: no effect.

The following four lines in a user style sheet would be radical.
Tested with Safari (after restart):

* {
      background-color: white ! important;
      color: black ! important;
}




^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 19:43  9%         ` Vasiliy Molostov
@ 2012-07-24 20:29  6%           ` Dmitry A. Kazakov
  2012-07-24 21:22  5%             ` Vasiliy Molostov
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24 20:29 UTC (permalink / raw)


On Tue, 24 Jul 2012 23:43:49 +0400, Vasiliy Molostov wrote:

> Probably and personally, I don't prefer to convert between representations  
> and catch one or two hour diffs, instead I prefer to do calculations  
> better done with monotonic time, and then convert result to the required  
> representation.

This is the only right way to do it.
 
> Converting from some representation into authoritative monotonic time is  
> "mission impossibe", since important data may be lost, because this  
> important data belongs entirely to the representation, and can not be  
> expressed in monotonic authoritative source.

Possible, but under two conditions:

1. the corresponding time sources are synchronized;

2. the representation is sane (anything but political time).

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 19:07 11%         ` Adam Beneschan
@ 2012-07-24 20:17 10%           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24 20:17 UTC (permalink / raw)


On Tue, 24 Jul 2012 12:07:52 -0700 (PDT), Adam Beneschan wrote:

> On Tuesday, July 24, 2012 11:28:27 AM UTC-7, Dmitry A. Kazakov wrote:
>> On Tue, 24 Jul 2012 09:26:46 -0700 (PDT), Adam Beneschan wrote:
>> 
>> &gt; Now, use Ada.Calendar.Time_Of to create a Time T_Base representing 1/1/1901. 
>> &gt; Or, better, if the NTP time is always UTC, then you should probably use
>> &gt; Ada.Calendar.Formatting.Time_Of to create a time that represents midnight
>> &gt; of 1/1/1901 in UTC time; I think you do this by passing Time_Zone =&gt;
>> &gt; Ada.Calendar.Time_Zones.UTC_Time_Offset.  (Somebody please correct me if
>> &gt; I&#39;m supposed to negate the value.)
>> 
>> There is no simple way of converting Ada.Calendar.Time to UTC. At least
>> there was none in Ada 2005. I think Randy Brukardt wanted to fix that, or
>> sort of.
> 
> The problem here, I think, is that the concept of "converting
> Ada.Calendar.Time to UTC" is a broad, general one, and probably somewhat
> vague.  I'm not trying to explain how to work with UTC time in general;
> I'm trying to solve a specific problem.
> 
> The specific problem (as I understood it) was this:  You have an integer
> value that represents a specific *point* *in* *time* T1 by specifying the
> number of seconds that have elapsed since midnight on New Years Day in
> Greenwich.

T1 [GMT]

> You have another value that was returned by Ada.Calendar.Clock at some
> other point in time T2.

T2 [nobody knows what]

>  My contention is that you can create an Ada.Calendar.Time value to
> represent T1 by using Ada.Calendar.Formatting.Time_Of with a suitable
> Time_Offset,

The problem is the Time_Offset, where do you get it? You need
GMT_Time_Offset, which firstly is not defined, and secondly if it were
there, it would be no more constant than the UTC_Time_Offset is.

Once you get T1 and T2 to the same time basis of more or less monotonic
time, e.g. GMT, UTC, whatever, but *not* a political time, there will be no
further problems.

> Furthermore, I don't see how Ada.Real_Time is a solution; that package's
> purpose is, I think, to provide a better way to measure time *intervals*
> with a higher resolution, but it doesn't do all that well with absolute
> time (the RM says that Real_Time is considered relative to an undefined
> "epoch" that could be the last system boot time).  So I don't see how it
> could be involved in a solution to this particular problem.

Ada.Real_Time.Time is not a full solution. It only provides sane time
arithmetic, e.g. "+", "-". A numeric type could do this as well.

Ada.Calendar.Time cannot give even that little. You could not define
arithmetical operations on it in any reasonable way. This is of course
because of time skews, which make some values non-existent and some values
repeating. I presume that any Ada implementation of it is broken in this or
other way, which is irrelevant here, because there is no way to have
arithmetic on something that is not additive anyway. I posted a couple
examples for CET on the topic to Ada Comments some time ago.

So the rule is: do not do any computations with Ada.Calendar.Time. Ada RM
simply does not define the outcome.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 10%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  7:24  6%   ` erlo.haugen
@ 2012-07-24 16:26 11%     ` Adam Beneschan
  2012-07-24 18:28 11%       ` Dmitry A. Kazakov
  2012-07-24 20:33 10%     ` Simon Wright
  1 sibling, 1 reply; 200+ results
From: Adam Beneschan @ 2012-07-24 16:26 UTC (permalink / raw)


On Tuesday, July 24, 2012 12:24:17 AM UTC-7, erlo....@gmail.com wrote:

> NTP epoch 1 started 1-1-1900 0:00, just like the Unix epoch started 1-1-1970
> 0:00. So when I get a time from an NTP-server, I get seconds from the start of 
> the NTP epoch.

All right, then.  First of all, I don't know what Ada.Calendar.Conversions is.  It's not defined by the language, but rather by one particular implementor.  IMHO you should prefer to use the language-defined packages if at all feasible.  It will be more portable, plus a lot of work goes into making sure things in the Standard have precise definitions.  

If you have an integer value N representing the number of seconds since 1/1/1900, I think you want to convert this to an Ada.Calendar.Time that represents the same point in time, so that you can then compare it easily to another value of Ada.Calendar.Time.  If Ada had a Time that represented 1/1/1900, you could just take that Time and add N seconds to it.  But, as you found out, it didn't, so the first step is to convert N to a value N2 representing the number of seconds since 1/1/1901.  You can do this by setting N2 := N - constant (you'd better be able to figure out what the constant is!).  As I implied before, if N2 is negative then some very weird stuff is going on, so don't worry about that possibility.

Now, use Ada.Calendar.Time_Of to create a Time T_Base representing 1/1/1901. 
Or, better, if the NTP time is always UTC, then you should probably use Ada.Calendar.Formatting.Time_Of to create a time that represents midnight of 1/1/1901 in UTC time; I think you do this by passing Time_Zone => Ada.Calendar.Time_Zones.UTC_Time_Offset.  (Somebody please correct me if I'm supposed to negate the value.)

Now, you *may* be able to create a Time T representing your NTP time just by setting

   T := T_Base + Duration(N2);

This will work on some implementations.  On other implementations, though, Duration isn't guaranteed to have a range that covers 112 years or more (the language only requires that it covers one day).  You can get around this by breaking N2 into "days" and "seconds":

   N2_Days := N2 / 86_400;
   N2_Seconds := N2 mod 86_400;
   T := T_Base + Day_Count (N2_Days) + Duration (N2_Seconds);

The Day_Count type is defined in Ada.Calendar.Arithmetic.

Now T will be a Time value that represents the point in time that occurred N seconds after midnight on 1/1/1900 (UTC), and you can compare this to any other Time value.

                          -- Adam



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 16:59  6%       ` Georg Bauhaus
@ 2012-07-24 19:25  6%         ` Simon Wright
  2012-07-24 22:07  6%           ` Georg Bauhaus
  0 siblings, 1 reply; 200+ results
From: Simon Wright @ 2012-07-24 19:25 UTC (permalink / raw)


Georg Bauhaus <rm.dash-bauhaus@futureapps.de> writes:

> In the end, the world frame operators will succeed in convincing
> computer users that they always need to ask the operator do anything
> with their computers. It is very well possible to adjust CSS settings
> to personal preferences using what is called a user style sheet.

I couldn't see a way to do this with Safari. I followed the recipe I
found on the Web for Firefox: no effect.

On Chrome I found Stylish which does the trick; I had to include both
.parity0 and .parity1 settings to eliminate all trace.

However, I will now disable it, since I quite like the effect complained
of!



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 11:59  6%   ` Nasser M. Abbasi
@ 2012-07-24 15:08  6%     ` Simon Wright
  2012-07-24 16:59  6%       ` Georg Bauhaus
  2012-07-24 19:17  6%     ` John B. Matthews
  1 sibling, 1 reply; 200+ results
From: Simon Wright @ 2012-07-24 15:08 UTC (permalink / raw)


"Nasser M. Abbasi" <nma@12000.org> writes:

> On 7/24/2012 6:34 AM, Simon Wright wrote:
>> erlo <erlo@none> writes:
>>
>
>>
>> [1]
>> http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.ads
>> http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.adb
>>
>
> hi Simon,
>
>
> just a side note. If you have control of the HTML formating itself, or
> know who does, then the above pages are really hard on the eyes to
> look at due to the background of the HTML page.
>
> It has those annoying white and gray stripes. This makes it hard to
> read text as it leaves double images after effect in the eyes
> afterwords.
>
> May be just basic white background will be better.

Sorry to hear that. They look quite attractive to me!

They are from a standard Mercurial stylesheet, which says (inter alia)

   .parity0 { background-color: #f0f0f0; }
   .parity1 { background-color: white; }

and we'd have to change the first line to

   .parity0 { background-color: white; }

(or maybe a less deep grey).
(or even a pale green, for those of us who remember lineprinters!)

But I don't know how to do that, especially on Sourceforge (they haven't
been receptive to similar style suggestions in the past).




^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 13:02 11%                 ` Dmitry A. Kazakov
@ 2012-07-24 14:10  6%                   ` erlo
  0 siblings, 0 replies; 200+ results
From: erlo @ 2012-07-24 14:10 UTC (permalink / raw)


On 07/24/2012 03:02 PM, Dmitry A. Kazakov wrote:
>
> Is it a standard Ada package?
I guess it's a gnat-specific package - I can't find it in the RM.
>
>> into thinking that I can use To_Ada_Time to convert the NTP epoch base
>> (1-1-1900 0:00) to a variable of type Time.
>
> Take some other base, e.g. 01.01.2010 00:00 [UTC, GMT, CET ...], if you
> have an NTP reading of it. E.g. if NTP uses some astronomical year or other
> method to calculate difference between two times.
>
I will try this approach.
> You should not use Ada.Calendar without knowing exactly what time it
> represents on the given machine.
>
>>> This presumes that they represent *same* time though maybe using different
>>> epochs. You might need to read the UNIX and NTP documentation to learn what
>>> exactly times they do represent. That would give you E2 - E1. To put it
>>> simple: same time = synchronized clocks.
>>
>> This is the exact case.
>
> Which I doubt, but anyway.
>
>
--
Regards
Erlo



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar Question
  2012-07-20 18:51 13%     ` Simon Wright
@ 2012-07-23 13:23 11%       ` awdorrin
  0 siblings, 0 replies; 200+ results
From: awdorrin @ 2012-07-23 13:23 UTC (permalink / raw)


On Friday, July 20, 2012 2:51:23 PM UTC-4, Simon Wright wrote:
> 
> It depends what you mean by &#39;epoch&#39;. If it&#39;s 1 Jan 1970 (as for Unix),
> then you should be aware that at the change to Ada 05 GNAT changed
> representations so that 1 Jan 1970 is no longer stored as 0.

Since I'm interfacing to C routines, I do mean 1-Jan-1970.

I do like your suggestion, it is much cleaner and I don't need to include either the Interfaces.C or Ada.Calendar.Conversions packages.

Thanks!



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar Question
  2012-07-20 17:59 11% ` Adam Beneschan
@ 2012-07-20 18:24 13%   ` awdorrin
  2012-07-20 18:51 13%     ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: awdorrin @ 2012-07-20 18:24 UTC (permalink / raw)


I finally realized that these nested packages are tagged private. Now it makes sense.

It looks like the 'easiest' way for me to get from the stored 'seconds' and 'nanoseconds' is to do the following:

procedure Example( sec : in Integer; nSec : in Integer) is

  T : Ada.Calendar.Time;

begin

  T := Ada.Calendar.Conversions.To_Ada_Time(0) -- to get epoch
    + Ada.Calendar.Conversions.To_Duration( long(sec), long(nSec));

  Put_Line( Ada.Calendar.Formatting.Image(
    Date => T, Include_Time_Fraction => True, 
    Time_Zone => Ada.Calendar.Time_Zones.UTC_Time_Offset(T) );

end Example;

The 'To_Duration' is a bit annoying, requiring withing the 'Interfaces.C' package for the 'long' type, but it does work fine.



^ permalink raw reply	[relevance 13%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-23 22:07 11% ` Adam Beneschan
       [not found]       ` <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com>
@ 2012-07-24  7:24  6%   ` erlo.haugen
  2012-07-24 16:26 11%     ` Adam Beneschan
  2012-07-24 20:33 10%     ` Simon Wright
  2012-07-24  7:37  6%   ` erlo.haugen
  2 siblings, 2 replies; 200+ results
From: erlo.haugen @ 2012-07-24  7:24 UTC (permalink / raw)



> My gut feeling is that if NTP gives you a time in the range 1-1-1900 to 12-31-1900, something is pretty wrong because computers didn&#39;t exist during that time period.  So I&#39;m not really sure what the issue is.  I think you need to be more specific about what you&#39;re trying to do.  What kind of value is your program using for an &quot;NTP time&quot;--is it an integer, and if so, what does it represent (seconds since 1-1-1900, nanoseconds since 1-1-1900, or what)?  Are you trying to see if an NTP time is less than or greater than a value of Ada.Calendar.Time, or compute the difference in seconds (or something else) between an NTP time value and an Ada.Calendar.Time value, or what?  
> 
>                         -- Adam
NTP epoch 1 started 1-1-1900 0:00, just like the Unix epoch started 1-1-1970 0:00. So when I get a time from an NTP-server, I get seconds from the start of the NTP epoch.

Erlo




^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-23 21:42 14% Ada.Calendar and NTP (and Unix Epoch) erlo
  2012-07-23 22:07 11% ` Adam Beneschan
@ 2012-07-24 11:34  6% ` Simon Wright
  2012-07-24 11:59  6%   ` Nasser M. Abbasi
  2012-07-25  2:23  6% ` sla29970
  2 siblings, 1 reply; 200+ results
From: Simon Wright @ 2012-07-24 11:34 UTC (permalink / raw)


erlo <erlo@none> writes:

> This is because Ada.Calendar starts at 1-1-1901. But NTP starts at
> 1-1-1900, so how can I work my way around this issue? I need to
> compare NTP time with Unix Epoch based time.

I did it by (effectively) working backward from the next NTP epoch (I
treated NTP time as signed, so that the current NTP time is a negative
number), which according to the code I have here[1] is
2036-02-07:06:28:16 (this should fit with Unix time, but I just used
Ada).

[1]
http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.ads
http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.adb



^ permalink raw reply	[relevance 6%]

* Ada.Calendar Question
@ 2012-07-20 17:18 13% awdorrin
  2012-07-20 17:59 11% ` Adam Beneschan
  0 siblings, 1 reply; 200+ results
From: awdorrin @ 2012-07-20 17:18 UTC (permalink / raw)


I have been looking at the Ada.Calendar and Ada.Real_Time packages, trying to update some old Ada code, which interfaces to C.

How do I access the 'Conversion_Operations' package defined within Ada.Calendar?

I have been trying to make use of:
 Conversion_Operations.To_Ada_Time( Unix_Time : Long-Integer );
 Conversion_Operations.To_Struct_Timespec()
and
 Conversion_Operations.To_Duration()

I have seen the C specific versions in Ada.Calendar.Conversion, but those all use the Interfaces.C package types.








^ permalink raw reply	[relevance 13%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 16:26 11%     ` Adam Beneschan
@ 2012-07-24 18:28 11%       ` Dmitry A. Kazakov
  2012-07-24 19:07 11%         ` Adam Beneschan
  2012-07-24 19:43  9%         ` Vasiliy Molostov
  0 siblings, 2 replies; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24 18:28 UTC (permalink / raw)


On Tue, 24 Jul 2012 09:26:46 -0700 (PDT), Adam Beneschan wrote:

> Now, use Ada.Calendar.Time_Of to create a Time T_Base representing 1/1/1901. 
> Or, better, if the NTP time is always UTC, then you should probably use
> Ada.Calendar.Formatting.Time_Of to create a time that represents midnight
> of 1/1/1901 in UTC time; I think you do this by passing Time_Zone =>
> Ada.Calendar.Time_Zones.UTC_Time_Offset.  (Somebody please correct me if
> I'm supposed to negate the value.)

There is no simple way of converting Ada.Calendar.Time to UTC. At least
there was none in Ada 2005. I think Randy Brukardt wanted to fix that, or
sort of.

The problem is that UTC_Time_Offset has time argument. It is not constant.
UTC_Time_Offset jumps forth and back together with the political time.

Furthermore, operations like UTC_Time_Offset, Time_Of, Split for some
distant time in the past, e.g. 1901 are most likely wrong, because OS/Ada's
RTL cannot keep track of all political changes of all time zones in order
to be able to evaluate the number of seconds from present time to 1901 in
the time zone. It is *not* the number of years multiplied by the year's
duration. (IANA Time Zone Database or alike is required for that)

Calculating future times is absolutely impossible because that depends on
future decisions of the corresponding governmental bodies having the
authority over the time zone, from daylight saving time to changing the
whole zone.

This is why it is better not to touch Ada.Calendar.Time.

Ada.Real_Time, Duration, Time_Span, some numeric type would be much better
candidates.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  8:34  6%           ` erlo.haugen
@ 2012-07-24  9:13  5%             ` Dmitry A. Kazakov
  2012-07-24 12:27 11%               ` erlo.haugen
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24  9:13 UTC (permalink / raw)


On Tue, 24 Jul 2012 01:34:03 -0700 (PDT), erlo.haugen@gmail.com wrote:

>> Political time is one regulated by politicians, localized, daylight saving
>> etc. Political time is unusable for the purpose of time stamping and clock
>> synchronization, but of course indispensable for the UI.
>> 
>> Ada.Calendar implicitly represents such a time. NTP, I only guess, because
>> we are using other mechanisms of time distribution and synchronization, is
>> not a political time. Is it UTC?
>> 
>> Which is why I second to Adam asking what are going to achieve.
> 
> I see. NTP is just the number of seconds

Any time is just a number of seconds added to some epoch...

> The purpose of this exercise is to compare two timestamps, one base on
> Unix epoch and one based on NTP epoch.

Where is a problem then?

   E1 + T1 vs. E2 + T2

<=>

   T1 vs. (E2 - E1) + T2

Where E2 - E1 is the time offset between the epochs.

This presumes that they represent *same* time though maybe using different
epochs. You might need to read the UNIX and NTP documentation to learn what
exactly times they do represent. That would give you E2 - E1. To put it
simple: same time = synchronized clocks.

Note that if any of two times is political, E2 - E1 does not exist as it
becomes a function of time. This where all starts really complicated and is
the reason why one should never ever mess up with the political time for
the purpose of time stamping. And this is just a relatively simple case
when clocks are synchronized but one of them is periodically skewed.

When clocks are not synchronized, time stamps are fundamentally
incomparable without the history of synchronization, which, well, means
that they were rather synchronized. (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  8:14 10%         ` Dmitry A. Kazakov
@ 2012-07-24  8:34  6%           ` erlo.haugen
  2012-07-24  9:13  5%             ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: erlo.haugen @ 2012-07-24  8:34 UTC (permalink / raw)
  Cc: mailbox


> Political time is one regulated by politicians, localized, daylight saving
> etc. Political time is unusable for the purpose of time stamping and clock
> synchronization, but of course indispensable for the UI.
> 
> Ada.Calendar implicitly represents such a time. NTP, I only guess, because
> we are using other mechanisms of time distribution and synchronization, is
> not a political time. Is it UTC?
> 
> Which is why I second to Adam asking what are going to achieve.
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

I see. NTP is just the number of seconds (and fractions thereof) from 1-1-1900 0:00, adjusted with leap seconds - so it is not adjusted for timezones, daylight saving. It is not UTC, as UTC does not take leap seconds in account.

The purpose of this exercise is to compare two timestamps, one base on Unix epoch and one based on NTP epoch.

Regards
Erlo



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  7:50  6%       ` erlo.haugen
@ 2012-07-24  8:14 10%         ` Dmitry A. Kazakov
  2012-07-24  8:34  6%           ` erlo.haugen
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24  8:14 UTC (permalink / raw)


On Tue, 24 Jul 2012 00:50:15 -0700 (PDT), erlo.haugen@gmail.com wrote:

> Den tirsdag den 24. juli 2012 09.11.57 UTC+2 skrev Dmitry A. Kazakov:
>> On Tue, 24 Jul 2012 00:37:13 -0400, Dennis Lee Bieber wrote:
>> 
>> &gt; On Mon, 23 Jul 2012 15:07:48 -0700 (PDT), Adam Beneschan
>> &gt; &lt;adam@irvine.com&gt; declaimed the following in comp.lang.ada:
>> &gt; 
>> &gt; My gut feeling is that if NTP gives you a time in the range 1-1-1900 to
>> &gt; 12-31-1900, something is pretty wrong because computers didn&#39;t exist
>> &gt; during that time period.  So I&#39;m not really sure what the issue is.  I
>> &gt; think you need 
>> &gt; 
>> &gt; 	Nonetheless, it appears that a 128bit value of all 0s represents the
>> &gt; epoch for Network Time Protocol...
>> 
>> Is NTP political time? If not, it does not make much sense to convert it
>> Ada.Calendar.Time anyway. Ada.Real_Time.Time looks more appropriate.
> 
> Enlighten me please, what is meant by 'political time'?

Political time is one regulated by politicians, localized, daylight saving
etc. Political time is unusable for the purpose of time stamping and clock
synchronization, but of course indispensable for the UI.

Ada.Calendar implicitly represents such a time. NTP, I only guess, because
we are using other mechanisms of time distribution and synchronization, is
not a political time. Is it UTC?

Which is why I second to Adam asking what are going to achieve.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 10%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
       [not found]       ` <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com>
@ 2012-07-24  7:11 11%     ` Dmitry A. Kazakov
  2012-07-24  7:50  6%       ` erlo.haugen
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-24  7:11 UTC (permalink / raw)


On Tue, 24 Jul 2012 00:37:13 -0400, Dennis Lee Bieber wrote:

> On Mon, 23 Jul 2012 15:07:48 -0700 (PDT), Adam Beneschan
> <adam@irvine.com> declaimed the following in comp.lang.ada:
> 
> My gut feeling is that if NTP gives you a time in the range 1-1-1900 to
> 12-31-1900, something is pretty wrong because computers didn't exist
> during that time period.  So I'm not really sure what the issue is.  I
> think you need 
> 
> 	Nonetheless, it appears that a 128bit value of all 0s represents the
> epoch for Network Time Protocol...

Is NTP political time? If not, it does not make much sense to convert it
Ada.Calendar.Time anyway. Ada.Real_Time.Time looks more appropriate.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar Question
  2012-07-20 17:18 13% Ada.Calendar Question awdorrin
@ 2012-07-20 17:59 11% ` Adam Beneschan
  2012-07-20 18:24 13%   ` awdorrin
  0 siblings, 1 reply; 200+ results
From: Adam Beneschan @ 2012-07-20 17:59 UTC (permalink / raw)


On Friday, July 20, 2012 10:18:22 AM UTC-7, awdorrin wrote:
> I have been looking at the Ada.Calendar and Ada.Real_Time packages, trying to update some old Ada code, which interfaces to C.
> 
> How do I access the 'Conversion_Operations' package defined within
> Ada.Calendar?

This is defined in the *private* part of one implementor's implementation of Ada.Calendar.  They could easily change the semantics of those routines in a future release.  So attempting to access them seems like a very bad idea.

                          -- Adam



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 11:59  6%   ` Nasser M. Abbasi
  2012-07-24 15:08  6%     ` Simon Wright
@ 2012-07-24 19:17  6%     ` John B. Matthews
  1 sibling, 0 replies; 200+ results
From: John B. Matthews @ 2012-07-24 19:17 UTC (permalink / raw)


In article <jum2mm$4vi$1@speranza.aioe.org>,
 "Nasser M. Abbasi" <nma@12000.org> wrote:

> May be just basic white background will be better.

Choosing the _raw_ link may be an alternative:

<http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/raw-file/a6f
d7b0dfeba/SNTP.impl/sntp_support.ads>

<http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/raw-file/a6f
d7b0dfeba/SNTP.impl/sntp_support.adb>

-- 
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24  9:13  5%             ` Dmitry A. Kazakov
@ 2012-07-24 12:27 11%               ` erlo.haugen
  2012-07-24 13:02 11%                 ` Dmitry A. Kazakov
  2012-07-24 16:37  6%                 ` Adam Beneschan
  0 siblings, 2 replies; 200+ results
From: erlo.haugen @ 2012-07-24 12:27 UTC (permalink / raw)
  Cc: mailbox


> Where is a problem then?
> 
>    E1 + T1 vs. E2 + T2
> 
> &lt;=&gt;
> 
>    T1 vs. (E2 - E1) + T2
> 
> Where E2 - E1 is the time offset between the epochs.

That's true, the issue here is that I was fooled by Ada.Calendar.Conversion spec
into thinking that I can use To_Ada_Time to convert the NTP epoch base (1-1-1900 0:00) to a variable of type Time. This would make it easy to calculate
the offset between the two epochs:
epoch_diff := To_Ada_Time(70, 0, 1, 0, 0 ,0 0) - To_Ada_Time(00, 0, 1, 0, 0 ,0 0)

Snip from Ada.Calendar.Conversion spec:

  function To_Ada_Time
     (tm_year  : Interfaces.C.int;
      tm_mon   : Interfaces.C.int;
      tm_day   : Interfaces.C.int;
      tm_hour  : Interfaces.C.int;
      tm_min   : Interfaces.C.int;
      tm_sec   : Interfaces.C.int;
      tm_isdst : Interfaces.C.int) return Time;
   --  Convert a time value expressed in Unix-like fields of struct tm into
   --  a Time value relative to the Ada Epoch. The ranges of the formals are
   --  as follows:

   --     tm_year   --  years since 1900 *this one fooled me*
   --     tm_mon    --  months since January [0 .. 11]

I had the idea that zero would be a legal value for tm_year...

> 
> This presumes that they represent *same* time though maybe using different
> epochs. You might need to read the UNIX and NTP documentation to learn what
> exactly times they do represent. That would give you E2 - E1. To put it
> simple: same time = synchronized clocks.
> 

This is the exact case.

> Note that if any of two times is political, E2 - E1 does not exist as it
> becomes a function of time. This where all starts really complicated and is
> the reason why one should never ever mess up with the political time for
> the purpose of time stamping. And this is just a relatively simple case
> when clocks are synchronized but one of them is periodically skewed.
> 
> When clocks are not synchronized, time stamps are fundamentally
> incomparable without the history of synchronization, which, well, means
> that they were rather synchronized. (:-))
> 
> -- 
> Regards,
> Dmitry A. Kazakov
> http://www.dmitry-kazakov.de

Erlo



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  8:30  6%                       ` Dmitry A. Kazakov
@ 2012-07-25  8:45  6%                         ` Vasiliy Molostov
  2012-07-25  9:30  6%                           ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Vasiliy Molostov @ 2012-07-25  8:45 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> писал(а) в своём письме Wed,  
25 Jul 2012 12:30:21 +0400:
>>> There is certainly no such thing as "time value." What is the point?
>>
>> It is the source of time representation.
>
> The representation is determined by the clock. So?

representation is determined by who screwing clock, man. the question I  
suppose is not ada specific.



-- 
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/

^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  7:04  5%                 ` Vasiliy Molostov
@ 2012-07-25  7:33  6%                   ` Dmitry A. Kazakov
  2012-07-25  8:05  6%                     ` Vasiliy Molostov
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-25  7:33 UTC (permalink / raw)


On Wed, 25 Jul 2012 11:04:05 +0400, Vasiliy Molostov wrote:

> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> яПНяПНяПНяПНяПН(яПН) яПН яПНяПНяПНяПНяПН яПНяПНяПНяПНяПНяПН Wed,  
> 25 Jul 2012 10:32:05 +0400:
> 
>>> If you can synchronize representations, you are a god of time
>>> representations.
>>
>> Synchronization does not necessarily means that you control the clocks.
> 
> Do you see the terminology diff: "time represented"  and "time valued"?
> Why you insist on false obvious mistake you follow due to this difference?

There is certainly no such thing as "time value." What is the point?
 
> As for ai05-0119-1, do you understand that calculating linear algebra
> equation with n variables can give you a complex number in the answer?

No, it does not, provided you meant real coefficients. A solution of such a
set of linear equations is real when exists. When does not exist. It also
does not in the field of complex numbers.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  7:33  6%                   ` Dmitry A. Kazakov
@ 2012-07-25  8:05  6%                     ` Vasiliy Molostov
  2012-07-25  8:30  6%                       ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Vasiliy Molostov @ 2012-07-25  8:05 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> писал(а) в своём письме Wed,  
25 Jul 2012 11:33:17 +0400:

> On Wed, 25 Jul 2012 11:04:05 +0400, Vasiliy Molostov wrote:
>
>> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> писал(а) в своём письме  
>> Wed,
>> 25 Jul 2012 10:32:05 +0400:
>>
>>>> If you can synchronize representations, you are a god of time
>>>> representations.
>>>
>>> Synchronization does not necessarily means that you control the clocks.
>>
>> Do you see the terminology diff: "time represented"  and "time valued"?
>> Why you insist on false obvious mistake you follow due to this  
>> difference?
>
> There is certainly no such thing as "time value." What is the point?

It is the source of time representation.

>> As for ai05-0119-1, do you understand that calculating linear algebra
>> equation with n variables can give you a complex number in the answer?
>
> No, it does not, provided you meant real coefficients. A solution of  
> such a
> set of linear equations is real when exists. When does not exist. It also
> does not in the field of complex numbers.

I meant complex, that giving simple arithmetic calculus you have got  
complex answer. I can only guess, that this came from speculative imply of  
some variables that are not reflected in the expression.


>


-- 
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  6:32  6%               ` Dmitry A. Kazakov
@ 2012-07-25  7:04  5%                 ` Vasiliy Molostov
  2012-07-25  7:33  6%                   ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Vasiliy Molostov @ 2012-07-25  7:04 UTC (permalink / raw)


Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> писал(а) в своём письме Wed,  
25 Jul 2012 10:32:05 +0400:

>>
>> If you can synchronize representations, you are a god of time
>> representations.
>
> Synchronization does not necessarily means that you control the clocks.

Do you see the terminology diff: "time represented"  and "time valued"?
Why you insist on false obvious mistake you follow due to this difference?

As for ai05-0119-1, do you understand that calculating linear algebra
equation with n variables can give you a complex number in the answer?

> However it is true that the effect of clock synchronization is by
> definition local. In particular it implies that more distant time stamps
> are less sense any conversion would make. In short, some real-time clock
> readings can be converted if synchronized. Anything else is most likely
> garbage.

wow.
rook gambits are tied (С).

btw, the effect of clock syncronization is at least country wide. Airbus  
rulez! :)

-- 
Написано в почтовом клиенте браузера Opera: http://www.opera.com/mail/



^ permalink raw reply	[relevance 5%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 15:08  6%     ` Simon Wright
@ 2012-07-24 16:59  6%       ` Georg Bauhaus
  2012-07-24 19:25  6%         ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: Georg Bauhaus @ 2012-07-24 16:59 UTC (permalink / raw)


On 24.07.12 17:08, Simon Wright wrote:
> "Nasser M. Abbasi" <nma@12000.org> writes:
> 
>> On 7/24/2012 6:34 AM, Simon Wright wrote:
>>> erlo <erlo@none> writes:
>>>
>>
>>>
>>> [1]
>>> http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.ads
>>> http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.adb
>>>
>>
>> hi Simon,
>>
>>
>> just a side note. If you have control of the HTML formating itself, or
>> know who does, then the above pages are really hard on the eyes to
>> look at due to the background of the HTML page.

> 
> They are from a standard Mercurial stylesheet, which says (inter alia)
> 
>    .parity0 { background-color: #f0f0f0; }
>    .parity1 { background-color: white; }
> 
> and we'd have to change the first line to
> 
>    .parity0 { background-color: white; }
> 
> (or maybe a less deep grey).
> (or even a pale green, for those of us who remember lineprinters!)
> 
> But I don't know how to do that, especially on Sourceforge (they haven't
> been receptive to similar style suggestions in the past).

In the end, the world frame operators will succeed in convincing
computer users that they always need to ask the operator do
anything with their computers. It is very well possible to adjust
CSS settings to personal preferences using what is called
a user style sheet.

It's your personal computer. Yours. Sapere aude!




^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 21:22  5%             ` Vasiliy Molostov
@ 2012-07-25  6:32  6%               ` Dmitry A. Kazakov
  2012-07-25  7:04  5%                 ` Vasiliy Molostov
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-25  6:32 UTC (permalink / raw)


On Wed, 25 Jul 2012 01:22:55 +0400, Vasiliy Molostov wrote:

> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> яПНяПНяПНяПНяПН(яПН) яПН яПНяПНяПНяПНяПН яПНяПНяПНяПНяПНяПН Wed,  
> 25 Jul 2012 00:29:00 +0400:
> 
>> On Tue, 24 Jul 2012 23:43:49 +0400, Vasiliy Molostov wrote:
>>
>>> Converting from some representation into authoritative monotonic time is
>>> "mission impossibe", since important data may be lost, because this
>>> important data belongs entirely to the representation, and can not be
>>> expressed in monotonic authoritative source.
>>
>> Possible, but under two conditions:
>>
>> 1. the corresponding time sources are synchronized;
> 
> If you can synchronize representations, you are a god of time  
> representations.

Synchronization does not necessarily means that you control the clocks. 

However it is true that the effect of clock synchronization is by
definition local. In particular it implies that more distant time stamps
are less sense any conversion would make. In short, some real-time clock
readings can be converted if synchronized. Anything else is most likely
garbage.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar Question
  2012-07-20 18:24 13%   ` awdorrin
@ 2012-07-20 18:51 13%     ` Simon Wright
  2012-07-23 13:23 11%       ` awdorrin
  0 siblings, 1 reply; 200+ results
From: Simon Wright @ 2012-07-20 18:51 UTC (permalink / raw)


awdorrin <awdorrin@gmail.com> writes:

> procedure Example( sec : in Integer; nSec : in Integer) is
>
>   T : Ada.Calendar.Time;
>
> begin
>
>   T := Ada.Calendar.Conversions.To_Ada_Time(0) -- to get epoch
>     + Ada.Calendar.Conversions.To_Duration( long(sec), long(nSec));

It depends what you mean by 'epoch'. If it's 1 Jan 1970 (as for Unix),
then you should be aware that at the change to Ada 05 GNAT changed
representations so that 1 Jan 1970 is no longer stored as 0.

      use type Ada.Calendar.Time;
   begin
      T := Ada.Calendar.Time_Of (Year => 1970, Month => 1, Day => 1)
             + Duration (sec) + Duration (nSec) / 1.0e9;



^ permalink raw reply	[relevance 13%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  2:23  6% ` sla29970
@ 2012-07-25  6:40  6%   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2012-07-25  6:40 UTC (permalink / raw)


On Tue, 24 Jul 2012 19:23:52 -0700 (PDT), sla29970@gmail.com wrote:

> On Monday, July 23, 2012 2:42:32 PM UTC-7, erlo wrote:
>> This is because Ada.Calendar starts at 1-1-1901. But NTP starts at 
>> 1-1-1900, so how can I work my way around this issue? I need to compare 
>> NTP time with Unix Epoch based time.
> 
> What time scale is being used?  Is that time scale counting mean solar
> seconds or atomic seconds?  Of course UTC and atomic time did not exist at
> those epochs, but unless the situation defines the time scale a problem
> exists even if the year in question is 1972.  See
> http://www.ucolick.org/~sla/leapsecs/epochtime.html

A great link. Thanks!

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada  "library only" compiler ?
  @ 2012-07-21 16:47  2%     ` Niklas Holsti
  0 siblings, 0 replies; 200+ results
From: Niklas Holsti @ 2012-07-21 16:47 UTC (permalink / raw)


On 12-07-21 02:30 , Patrick wrote:
> Hi Niklas
>
> ...
>
> So just to clarify, I am not advocating an Ada interpreter, it's just
> that Lua's developers are quite resistant to implementing more then
> the tiniest set of standard libraries. Lua and all the standard
> libraries are less then 18K lines of code and they are determined to
> keep it that way. Lua programmers are supposed to rely on C.

Lua is explicitely meant to be an "extension language", to make some 
application "scriptable". The heavy application functions are meant to 
be implemented in C (or whatever the host application language is), with 
calls from and to Lua code to add flexibility.

I don't think that C libraries can be used easily to extend "Lua the 
language" with more language features.

Ada is not meant to be an extension language, but to be a full language 
in which one can implement entire applications.

So I don't quite understand why you are using Lua as a comparison. 
Perhaps we can approach this in another way, by asking you why you would 
prefer to use Ada rather than Lua? Which features of Ada are absent from 
Lua, or are better than the corresponding features in Lua? We can then 
discuss if and how these features could be implemented in the same way 
that Lua is currently implemented.

> Ada is huge

That is debatable. But even if you consider "Ada the language" to be 
huge, this just means that an Ada compiler has a lot to do, so the 
compilers are "huge" and hard to write. This is in harmony with the 
goals of the Ada language: to allow lots of compile-time checking. The 
generated code is not necessarily huge.

> and I am not proposing some sort of limit like this but I
> do think that a strategic retreat might be in order, at least for
> some of us and Lua is an example of this. There are not really that
> many libraries and bindings relative to C. If someone had a small Ada
> compiler that they knew had to be supplemented with C that might
> offer a little more clarity of purpose and perhaps leaning on C for
> library support is the better way to go for some people and a toolset
> tailor made for this might be good. Again I don't mean to bash Ada, I
> do like it a lot.

Which parts of "Ada the language" would you omit and replace by "library 
support"?

Historically, some Ada developers avoided the tasking features and 
instead used some non-Ada real-time kernel. Instead of creating 
tasks/threads with the Ada "task" keyword, they would call a kernel 
function to create the thread at run-time, providing some ordinary Ada 
subprogram as the "main function" of the thread. This can be seen as an 
example of replacing Ada language features with libraries (and, I regret 
to say, this practice still goes on in some places).

It is not so clear what other language features could profitably be 
replaced in this way. At the moment, only the fixed-point types come to 
my mind. An Ada program could avoid the Ada fixed-point types and 
instead call some fixed-point library, much like some Ada programs now 
use libraries for unbounded numbers ("bignums"). It seems to me that 
removing fixed-point types from Ada would simplify the compilers -- but 
probably not by much.

> So for instance it looks like Ada has a library to retrieve command
> line arguments.

Yes, Ada.Command_Line, a standard predefined package.

> However it looks to be just thin wrapper over ARGV and ARGC.

The services of Ada.Command_Line are similar to ARGV/ARGC, yes. This was 
a natural minimum level to provide. However, Ada.Command_Line can be 
implemented on systems that have a different method to access 
command-line parameters.

> If someone wanted to use something a little higher up like
> getopts, they could rework ARGV/ARGC out this part of their C
> boilerplate code.

An Ada program can certainly use the getopt() library function, although 
it may have to provide a C "main" function to do so (and how that is 
done depends on the Ada compiler).

> At the moment the Ada binding is there whether or
> not you use it.

So? The package Ada.Command_Line is unlikely to be linked into your Ada 
program if you don't use it explicitly. And the mere existence of this 
package is a trivial burden on the compiler. And I would bet that the 
code in this package is of trivial size.

> I am assuming there will be many more examples of
> this.

Examples of what, exactly?

If you look at the rest of the Ada predefined standard library packages, 
they either provide substantial functionality that is not standard in C 
(e.g. Ada.Calendar, Ada.Strings.Unbounded, Ada.Containers.*), or they 
are simple wrappers (e.g. Ada.Characters.Handling) for C or POSIX 
functions. The former can mostly be implemented in Ada itself, in a 
portable way; the latter can be implemented by calling system functions 
or libraries, in C or other languages. So I don't believe that the 
library packages are a significant obstacle to making Ada available on 
more devices, in particular since one can just say "sorry, my compiler 
does not (yet) support package X".

> However also as an example of my ignorance, I tried this to see if I
> could generate ASM from gnat: gnatmake -S first_procedure.adb
>
> It calls GCC right away: gcc -c -S first_procedure.adb gnatmake:
> "first_procedure.ali" WARNING: ALI or object file not found after
> compile gnatmake: "first_procedure.adb" compilation erro

GCC does not mean "GNU C Compiler", it means "GNU Compiler Collection" 
or "GNU Compiler Caller". The "gcc" program is a driver that parses the 
arguments and then calls the real compiler programs according to the 
chosen or deduced source language. The program "gnat1" is the real GNAT 
Ada compiler and gcc will call it eventually. (The program "cc1" is the 
real GNU C compiler.)

> It looks like GNAT does not generate it's own ASM but relies on GCC
> for this, so the idea of reworking GNAT into an Ada to ASM converter
> is certainly false, they must interact with an internal
> representation.

Your understanding of how GNAT and GCC work is a bit confused.

The principle is that the GNU compilers are separated into a "front end" 
part, distinct for each language, and a "back end" part that is distinct 
for each target processor. The front end for language X translates the X 
source code into the GCC internal representation; the back end for 
processor P translates the internal representation into 
assembly-language source code for P. The assembler for P then translates 
the assembly-language source code into binary machine code for P.

The Ada-specific part of GNAT is in the front end, which (as I 
understand it) is the "gnat1" program. But perhaps I should not say 
more, since I really don't know the details.

 > So at best it would be an Ada to GCC IR converter and
 > then other then a simpler to understand compiler, i guess the
 > proposal really doesn't offer much.

The core of GNAT is already an Ada-to-GCC-IR converter.

But the main point is that much of what an Ada compiler does, and most 
of what is due to the "hugeness" of Ada, does not depend on the target 
processor. When an Ada compiler sees "I+J", where I and J are some 
integer variables, it does not immediately decide to use a specific ADD 
instruction from the target processor's instruction set. Instead, after 
many checks on the legality of the expression, and after deciding which 
function called "+" is meant, the expression "I+J" is translated into 
the compiler's intermediate language and passed to the back end, which 
chooses the instructions. It may well be that the instructions chosen to 
compute I+J are quite different when the expression is used in a 
statement like K:=I+J, and when it is used in an expression like 
K:=Some_Array(I+J).

To conclude, if the goal is to make Ada available on some device D that 
is supported by the GCC back-end, then:
- most of the Ada-specific work is already done in GNAT, and
- most of the D-specific work is already done in GCC.

What is left to do is to take care of the details (where the devil is, 
of course), and implement the run-time support for Ada on device D. As 
can be seen from the AVR-Ada example, the compiler can be useful even 
with rudimentary run-time support.

If performance is not important, an alternative is to choose some 
virtual machine V, add support for that virtual machine to the GCC 
back-end, and port GNAT into an Ada-to-V compiler. The run-time system 
could then be written once, for V, and the V simulator could probably be 
written in a fairly portable way, to run on several devices with small 
adaptations. This was the JGNAT route (GNAT ported to compile Ada into 
byte code for the Java Virtual Machine). I'm not sure if JGNAT is still 
with us; it seems it had few users.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .





^ permalink raw reply	[relevance 2%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 11:34  6% ` Simon Wright
@ 2012-07-24 11:59  6%   ` Nasser M. Abbasi
  2012-07-24 15:08  6%     ` Simon Wright
  2012-07-24 19:17  6%     ` John B. Matthews
  0 siblings, 2 replies; 200+ results
From: Nasser M. Abbasi @ 2012-07-24 11:59 UTC (permalink / raw)


On 7/24/2012 6:34 AM, Simon Wright wrote:
> erlo <erlo@none> writes:
>

>
> [1]
> http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.ads
> http://coldframe.hg.sourceforge.net/hgweb/coldframe/adasntp/file/a6fd7b0dfeba/SNTP.impl/sntp_support.adb
>

hi Simon,


just a side note. If you have control of the HTML formating itself, or know
who does, then the above pages are really hard on the eyes to look at due to
the background of the HTML page.

It has those annoying white and gray stripes. This makes it hard
to read text as it leaves double images after effect in the eyes afterwords.

May be just basic white background will be better.

--Nasser





^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-23 21:42 14% Ada.Calendar and NTP (and Unix Epoch) erlo
  2012-07-23 22:07 11% ` Adam Beneschan
  2012-07-24 11:34  6% ` Simon Wright
@ 2012-07-25  2:23  6% ` sla29970
  2012-07-25  6:40  6%   ` Dmitry A. Kazakov
  2 siblings, 1 reply; 200+ results
From: sla29970 @ 2012-07-25  2:23 UTC (permalink / raw)


On Monday, July 23, 2012 2:42:32 PM UTC-7, erlo wrote:
> This is because Ada.Calendar starts at 1-1-1901. But NTP starts at 
> 1-1-1900, so how can I work my way around this issue? I need to compare 
> NTP time with Unix Epoch based time.

What time scale is being used?  Is that time scale counting mean solar seconds or atomic seconds?  Of course UTC and atomic time did not exist at those epochs, but unless the situation defines the time scale a problem exists even if the year in question is 1972.  See
http://www.ucolick.org/~sla/leapsecs/epochtime.html



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25 10:14 13%       ` Simon Wright
@ 2012-07-25 13:16  6%         ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2012-07-25 13:16 UTC (permalink / raw)


On Wed, 25 Jul 2012 11:14:44 +0100, Simon Wright wrote:

> Unless you are really concerned about time intervals of years.

Of weeks you should say. The last leap second happened June 30 this year.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  8:45  6%                         ` Vasiliy Molostov
@ 2012-07-25  9:30  6%                           ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2012-07-25  9:30 UTC (permalink / raw)


On Wed, 25 Jul 2012 12:45:16 +0400, Vasiliy Molostov wrote:

> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> яПНяПНяПНяПНяПН(яПН) яПН яПНяПНяПНяПНяПН яПНяПНяПНяПНяПНяПН Wed,  
> 25 Jul 2012 12:30:21 +0400:
>>>> There is certainly no such thing as "time value." What is the point?
>>>
>>> It is the source of time representation.
>>
>> The representation is determined by the clock. So?
> 
> representation is determined by who screwing clock, man.

Irrelevant. If anybody does something with the clock that is how the clock
works.

> the question I suppose is not ada specific.

That depends on the question.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-25  8:05  6%                     ` Vasiliy Molostov
@ 2012-07-25  8:30  6%                       ` Dmitry A. Kazakov
  2012-07-25  8:45  6%                         ` Vasiliy Molostov
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-07-25  8:30 UTC (permalink / raw)


On Wed, 25 Jul 2012 12:05:51 +0400, Vasiliy Molostov wrote:

> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> яПНяПНяПНяПНяПН(яПН) яПН яПНяПНяПНяПНяПН яПНяПНяПНяПНяПНяПН Wed,  
> 25 Jul 2012 11:33:17 +0400:
> 
>> On Wed, 25 Jul 2012 11:04:05 +0400, Vasiliy Molostov wrote:
>>
>>> Dmitry A. Kazakov <mailbox@dmitry-kazakov.de> яПНяПНяПНяПНяПН(яПН) яПН яПНяПНяПНяПНяПН яПНяПНяПНяПНяПНяПН  
>>> Wed,
>>> 25 Jul 2012 10:32:05 +0400:
>>>
>>>>> If you can synchronize representations, you are a god of time
>>>>> representations.
>>>>
>>>> Synchronization does not necessarily means that you control the clocks.
>>>
>>> Do you see the terminology diff: "time represented"  and "time valued"?
>>> Why you insist on false obvious mistake you follow due to this  
>>> difference?
>>
>> There is certainly no such thing as "time value." What is the point?
> 
> It is the source of time representation.

The representation is determined by the clock. So?

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 6%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 18:28 11%       ` Dmitry A. Kazakov
@ 2012-07-24 19:07 11%         ` Adam Beneschan
  2012-07-24 20:17 10%           ` Dmitry A. Kazakov
  2012-07-24 19:43  9%         ` Vasiliy Molostov
  1 sibling, 1 reply; 200+ results
From: Adam Beneschan @ 2012-07-24 19:07 UTC (permalink / raw)


On Tuesday, July 24, 2012 11:28:27 AM UTC-7, Dmitry A. Kazakov wrote:
> On Tue, 24 Jul 2012 09:26:46 -0700 (PDT), Adam Beneschan wrote:
> 
> &gt; Now, use Ada.Calendar.Time_Of to create a Time T_Base representing 1/1/1901. 
> &gt; Or, better, if the NTP time is always UTC, then you should probably use
> &gt; Ada.Calendar.Formatting.Time_Of to create a time that represents midnight
> &gt; of 1/1/1901 in UTC time; I think you do this by passing Time_Zone =&gt;
> &gt; Ada.Calendar.Time_Zones.UTC_Time_Offset.  (Somebody please correct me if
> &gt; I&#39;m supposed to negate the value.)
> 
> There is no simple way of converting Ada.Calendar.Time to UTC. At least
> there was none in Ada 2005. I think Randy Brukardt wanted to fix that, or
> sort of.

The problem here, I think, is that the concept of "converting Ada.Calendar.Time to UTC" is a broad, general one, and probably somewhat vague.  I'm not trying to explain how to work with UTC time in general; I'm trying to solve a specific problem.

The specific problem (as I understood it) was this:  You have an integer value that represents a specific *point* *in* *time* T1 by specifying the number of seconds that have elapsed since midnight on New Years Day in Greenwich.  You have another value that was returned by Ada.Calendar.Clock at some other point in time T2.  My contention is that you can create an Ada.Calendar.Time value to represent T1 by using Ada.Calendar.Formatting.Time_Of with a suitable Time_Offset, and using the "+" functions defined in Ada.Calendar and Ada.Calendar.Formatting, that produces an Ada.Calendar.Time value representing T1 that can correctly be compared with T2 (and subtracted to produce a Duration).

Do you believe my contention is incorrect?  If so, please demonstrate.

It's true, as you say, that UTC_Time_Offset's result isn't constant, and changes when the time zone goes in and out of Daylight Savings Time.  The point is, I was trying to use it in a way that would cancel out the effect of that, producing a result in which the "offsets" factored into the two Ada.Calendar.Time values being compared are the same, which means that you can compare or subtract them correctly, regardless of whether the offsets would be different if you ran the program six months from now.  I may have done it wrong, but I don't believe it is impossible.  If it is, please show why.

There are certainly a lot of things that are difficult to get right with Ada.Calendar for some of the reasons you state.  I don't think any of those are relevant to solving *this* particular problem.  Furthermore, I don't see how Ada.Real_Time is a solution; that package's purpose is, I think, to provide a better way to measure time *intervals* with a higher resolution, but it doesn't do all that well with absolute time (the RM says that Real_Time is considered relative to an undefined "epoch" that could be the last system boot time).  So I don't see how it could be involved in a solution to this particular problem.

                            -- Adam



^ permalink raw reply	[relevance 11%]

* Re: Ada.Calendar and NTP (and Unix Epoch)
  2012-07-24 12:27 11%               ` erlo.haugen
  2012-07-24 13:02 11%                 ` Dmitry A. Kazakov
@ 2012-07-24 16:37  6%                 ` Adam Beneschan
  1 sibling, 0 replies; 200+ results
From: Adam Beneschan @ 2012-07-24 16:37 UTC (permalink / raw)


On Tuesday, July 24, 2012 5:27:30 AM UTC-7, erlo....@gmail.com wrote:
> > Where is a problem then?
> > 
> >    E1 + T1 vs. E2 + T2
> > 
> > <=>
> > 
> >    T1 vs. (E2 - E1) + T2
> > 
> > Where E2 - E1 is the time offset between the epochs.
> 
> That's true, the issue here is that I was fooled by Ada.Calendar.Conversion spec
> into thinking that I can use To_Ada_Time to convert the NTP epoch base (1-1-1900 0:00) to a variable of type Time. This would make it easy to calculate
> the offset between the two epochs:
> epoch_diff := To_Ada_Time(70, 0, 1, 0, 0 ,0 0) - To_Ada_Time(00, 0, 1, 0, 0 ,0 0)

If all you're trying to do is figure out the number of seconds between 1/1/1970 and 1/1/1900 by using an Ada Time type, you can do this easily by figuring out the number of seconds between 1/1/1970 and 1/1/1901, and adding a constant.

                           -- Adam



^ permalink raw reply	[relevance 6%]

* Re: Practicalities of Ada for app development
  @ 2012-06-12 11:44  4%                   ` Dmitry A. Kazakov
  0 siblings, 0 replies; 200+ results
From: Dmitry A. Kazakov @ 2012-06-12 11:44 UTC (permalink / raw)


On Tue, 12 Jun 2012 11:48:43 +0200, Georg Bauhaus wrote:

> On 12.06.12 09:55, Dmitry A. Kazakov wrote:
>> On Mon, 11 Jun 2012 22:50:33 +0200, Georg Bauhaus wrote:
>>
>>> Reason: numeric literals typically mean a number of some "arithmetic"
>>> type.
>>
>> No, a numeric literal means what it tells "a number."
> 
> "A number" tells little to an average reader of a program
> seeing just that number.

Sorry for the reader, but numeric literal is just that: a number.

>>>     Some_Time_Object :=  45 * Seconds;
> 
>> Technically Barnes is not quite right.
> 
> Oh, I believe he is right and makes sure this is understood:
> 
> "the expression uses the rule that a fixed[!] point value
> can be multiplied by an integer giving a result of the same fixed
> point type". (�18.3, p.465)
>
> Using whole quantities of Seconds, Minutes, and so on will give
> us aggregates and formulas that do not invite confusion by
> stipulating that the fraction can be anything but 0.

It is very difficult if possible to create dimensioned fixed-point system
due to problems of handling accuracy. Note that the point of using fixed
point is to keep results exact.

>> 2. You cannot multiply time, you do durations (time intervals);
> 
> Like in "two times"? "Time after Time"? "Many times"?

The thing represented by Ada.Calendar.Time or Ada.Real_Time.Time has no
dimension. You can multiply durations by themselves and by other
dimensioned values and scalars. Times can be subtracted. Duration can be
added to time.
 
>> 3. "s" or "second" is the proper name of the unit.
> 
> "Seconds" is the plural of a "second" (one unit of time).

http://physics.nist.gov/cuu/Units/units.html
 
> "s" is asking for trouble, since "s" may well name a parameter
> or variable, like when copied from a formula (s = v * t, say).
> 
> By comparison, is "m" the name of Meter or of Minute?

"m" is meter. Minute is not a SI unit. Yes, there are many conflicting
names when irregular or units outside SI are involved.

As for conflicts with names of variables, that is not a problem in Ada.

>> in a properly typed languages you need no special
>> forms of literals. I guess that U+n stems from C-ish nL, nU etc.
> 
> Uhm, no! U+number is official U-nicode notation. (Also in ISO 10646.)

Yes, but C is where the ears are growing from.

If you want to follow the notation, you should to do it exactly, i.e.
U+0C20, without dashes around the number. If you don't, then use the most
appropriate way from the implementation language perspective. The middle
way would bring nothing but confusion.

>> You can overload numeric literals in almost any context in Ada.
> 
> Overloading literals is the questionable part. It is what got me
> started. No inference, please! Even when compilers can decide
> whether or not there is that single assignable type!
> 
> What I consider silly is to insist that readers infer
> the proper meaning of a sequence of digits when we can
> do better.

Sorry, but the program as a whole is not what it means. You have to
interpret the program in order to understand its semantics. A good language
design is to support trivial inference and require complex things explicit. 

Type annotation of operands of an expression *is* trivial, or else the
program is poorly designed.

>> The proper way to do this is:
>>
>>     UTF8_Pi : constant String := Image (16#0C30#);
> 
> How is that different from
> 
>        UTF8_Pi : constant String := U+16#0C30;

Compare:

   Image (16#0C30#) * 3

and

   U+16#0C30# * 3

Anyway, if U+n notation support seem the only problem with Ada UTF-8, I
gather that the issue is closed. (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 4%]

* Re: package Ada.Tags
  2012-06-07 20:36  7% package Ada.Tags RasikaSrinivasan
@ 2012-06-07 21:49  0% ` Adam Beneschan
  0 siblings, 0 replies; 200+ results
From: Adam Beneschan @ 2012-06-07 21:49 UTC (permalink / raw)


On Thursday, June 7, 2012 1:36:32 PM UTC-7, RasikaSr...@gmail.com wrote:
> Friends
> 
> I have two types declared as follows:
> 
> with Ada.Calendar ;
> 
> package events is
>     type events_record_type is abstract tagged 
>       record
>          time : ada.Calendar.time ;
>       end record ;
>    procedure show(event : events_record_type) ;
>    
>    type basal_delivery_event_type is new events_record_Type with
>       record
>          amount : float ;
>       end record ;
>    overriding
>    procedure show( event : basal_delivery_event_type ) ;
>    
>    type bolus_delivery_event_type is new events_record_Type with
>       record
>          amount : float ;
>       end record ;
>    overriding
>    procedure show( event : bolus_delivery_event_type ) ;
>    
>    type SMBG_event_type is new events_record_type with
>       record
>          amount : short_integer ;
>       end record ;
>    overriding
>    procedure show( event : SMBG_event_type ) ;
>    
> end events ;
> 
> The following implementation in the body:
> 
> 
> 
>    procedure show (event : events_record_type) is
>       use GNAT.Calendar.Time_IO;  
>    begin      
>       put( ada.Tags.Expanded_Name( event'tag ) );      
>       put( gnat.Calendar.time_io.Image( event.time , gnat.Calendar.Time_IO.ISO_Date & " %T")) ;      
>    end show;
> 
> gives me a compilation error:
> 
> "tag" attribute can only be applied to objects of class - wide type.
> 
> In the above, isnt event an object meeting this criterion?

No.  Ada makes a distinction between specific types and class-wide types.  If a parameter is declared using a specific type, only objects of that type can be passed to it.  (This is different from what happens in, say, Java.)  What's happening here is that when you declare your derived types, the compiler inherits "show" from them, and declares a new version of "show" with a new specific type as a parameter--either basal_delivery_event_type, bolus_delivery_event_type, or SMBG_event_type.  If you don't override them, the code for the new routines will be the same as the code for the original routine, but using the new specific type.  When you dispatch, the program will call whichever routine has that specific type as a parameter.  But the type is still a specific type.  (Note: Although I'm describing this as if a new copy of the "show" routine is being created, the code should still be in your program only once.)

This is different from a routine with a class-wide parameter:

   procedure classwide_show (events : events_record_type'class);

Now, you can call this routine with any of your derived types as a parameter.  But this time, there's only one copy of the routine, not multiple copies as above.  Now, the routine can use events'tag to get information about the actual type of the object.  

But you can't do this in your example, because the show routine uses a specific type as a parameter.  However, you can get around it like this:

  put( ada.Tags.Expanded_Name( events_record_type'class(event)'tag ) );

In other words, tell the compiler to treat event as though it were a class-wide type, and it will be happy.

One other thing: You've declared overriding routines for show, but you didn't provide the bodies.  If you it to do the exact same thing as the "show" you declared for events_record_type, then don't override it--just let the program use the inherited copy.  If you want to have a body that performs the original "show" and does some other functions, then override it and have the body call this:

   events_record_type(event).show;  --or
   show (events_record_type (event));

That tells the compiler to treat event as though it had type events_record_type, and then it will pick the version of "show" that has an events_record_type parameter, i.e. the original one.  The 'Tag will still be the tag of whatever type you want, because 'Tag tells you what type the object really is, not what type you're telling the compiler to pretend it is.  

Hope this helps.  The paradigm in Ada is different from C++ or Java, so I think it takes some getting used to if you're coming from one of those languages.  But it's pretty simple to grasp once you get used to it.

                           -- Adam





^ permalink raw reply	[relevance 0%]

* package Ada.Tags
@ 2012-06-07 20:36  7% RasikaSrinivasan
  2012-06-07 21:49  0% ` Adam Beneschan
  0 siblings, 1 reply; 200+ results
From: RasikaSrinivasan @ 2012-06-07 20:36 UTC (permalink / raw)


Friends

I have two types declared as follows:

with Ada.Calendar ;

package events is
    type events_record_type is abstract tagged 
      record
         time : ada.Calendar.time ;
      end record ;
   procedure show(event : events_record_type) ;
   
   type basal_delivery_event_type is new events_record_Type with
      record
         amount : float ;
      end record ;
   overriding
   procedure show( event : basal_delivery_event_type ) ;
   
   type bolus_delivery_event_type is new events_record_Type with
      record
         amount : float ;
      end record ;
   overriding
   procedure show( event : bolus_delivery_event_type ) ;
   
   type SMBG_event_type is new events_record_type with
      record
         amount : short_integer ;
      end record ;
   overriding
   procedure show( event : SMBG_event_type ) ;
   
end events ;

The following implementation in the body:



   procedure show (event : events_record_type) is
      use GNAT.Calendar.Time_IO;  
   begin      
      put( ada.Tags.Expanded_Name( event'tag ) );      
      put( gnat.Calendar.time_io.Image( event.time , gnat.Calendar.Time_IO.ISO_Date & " %T")) ;      
   end show;

gives me a compilation error:

"tag" attribute can only be applied to objects of class - wide type.

In the above, isnt event an object meeting this criterion?

clearly i am missing something. The question is I want to find out the equivalent of RTTI from C++. ie Which one if the derived types is it.

clues appreciated. srini



^ permalink raw reply	[relevance 7%]

* Re: Ada and linux real time
  @ 2012-03-17 15:50  7%                   ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2012-03-17 15:50 UTC (permalink / raw)


Simon Wright <simon@pushface.org> writes:

> I was under the impression that the PREEMPT RT kernel "just" made the
> standard primitives more predictable & hence suitable for RT.
>
> I found http://pengutronix.de/software/linux-rt/debian_en.html and was
> going to have a go, but it looks as though they only support sid and I
> don't plan to update just yet!

There seems to be some real-time-ness in the standard Debian squeeze
kernel (2.6.32???).

This is a demo program - I made the delay 12 ms in case the OS tick was
10 ms; it isn't.

with Ada.Calendar;
with Ada.Text_Io; use Ada.Text_Io;
with Ada.Integer_Text_Io; use Ada.Integer_Text_Io;

procedure Check_Real_Time is
   --  Accumulates a histogram of the actual time taken by a notional
   --  12-ms delay. The bucket size is 0.01 ms.
   --
   --  Only prints out the non-zero buckets.
   subtype Bucket_Index is Natural range 0 .. 40000;
   Buckets : array (Bucket_Index) of Natural := (others => 0);
   use type Ada.Calendar.Time;
   Next : Ada.Calendar.Time;
begin
   Next := Ada.Calendar.Clock;
   for J in 1 .. 1000 loop
      declare
	 Start : constant Ada.Calendar.Time := Ada.Calendar.Clock;
	 Actual_Interval : Natural;  -- in hundredth-milliseconds
      begin
	 Next := Next + 0.012;
	 delay until Next;
	 Actual_Interval := Natural ((Ada.Calendar.Clock - Start) * 100_000.0);
	 if Actual_Interval > Buckets'Last then
	    Buckets (Buckets'Last) := Buckets (Buckets'Last) + 1;
	 else
	    Buckets (Actual_Interval) := Buckets (Actual_Interval) + 1;
	 end if;
      end;
   end loop;
   for J in Buckets'Range loop
      if Buckets (J) > 0 then
	 Put (J, Width => 5);
	 Put (Buckets (J), Width => 5);
	 New_Line;
      end if;
   end loop;
end Check_Real_Time;

Running the program wthout any special treatment:

   root@flambard:/home/simon# ./check_real_time 
    1120    1
    1136    1
    1163    1
    1165    1
    1176    1
    1189    1
    1191    2
    1197    1
    1198   32
    1199   36
    1200  852
    1201   24
    1202   36
    1203    1
    1204    1
    1208    1
    1209    1
    1210    1
    1211    1
    1225    1
    1235    1
    1238    1
    1264    1
    1280    1

Running the program at elevated but non-real-time priority:

   root@flambard:/home/simon# nice -1 ./check_real_time 
    1098    1
    1099    1
    1125    1
    1136    1
    1148    1
    1153    1
    1165    1
    1182    1
    1183    1
    1184    1
    1186    1
    1191    1
    1193    1
    1195    2
    1197    3
    1198   37
    1199   18
    1200  860
    1201   14
    1202   34
    1203    1
    1204    1
    1205    2
    1208    1
    1209    2
    1215    1
    1217    2
    1218    1
    1231    1
    1236    1
    1247    1
    1253    1
    1263    1
    1272    1
    1275    1
    1302    1

Running the program with elevated real-time priority:

   root@flambard:/home/simon# chrt 1 ./check_real_time 
    1194    1
    1195    1
    1198   37
    1199   26
    1200  872
    1201   22
    1202   35
    1203    4
    1206    1
    1208    1

Not perfect, but much better! (by the way, there was no other
user-generated load).



^ permalink raw reply	[relevance 7%]

* Re: Any leap year issues caused by Ada yesterday?
  2012-03-06 19:18  4%                         ` Dmitry A. Kazakov
@ 2012-03-06 20:22  7%                           ` Simon Wright
  0 siblings, 0 replies; 200+ results
From: Simon Wright @ 2012-03-06 20:22 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Tue, 06 Mar 2012 17:59:04 +0000, Simon Wright wrote:
>
>> 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).
>
> You could improve that a bit by putting Ada.Calendar.Clock into a loop.
> When it returns a different value, you exit the loop and take that value
> for the time base.

Ada.Calendar.Clock was basically the POSIX gettimeofday() (?) from
VxWorks; which was (epoch + ticks/clockrate). So it was updated at clock
interrupt.

> If the quartz is same you need not to synchronize it anymore. Since the
> multiplier is known you simply add the RTC minus its value at the base
> multiplied by the factor and converted to Duration (or Time_Span) to the
> base and use that instead of the original Ada's Clock.

Didn't want to mess with the RTS use of Ada.Calendar.Time for delays. No
point in using Ada.Real_Time.Time because (then) it was the same as
Ada.Calendar.Time. So we had AC.Time (for internal use only),
<Project>.Calendar.Time for both internal & external use (but not, of
course, for delays).

> Did you check the kernel settings? It has a variable that sets the time
> source to the RTC. This might work on your PPC's BSP. The effect is that
> the system clock is changed each time when queried rather than upon timer
> interrupts.

Don't remember that one.



^ permalink raw reply	[relevance 7%]

* Re: Any leap year issues caused by Ada yesterday?
  2012-03-06 17:59  4%                       ` Simon Wright
@ 2012-03-06 19:18  4%                         ` Dmitry A. Kazakov
  2012-03-06 20:22  7%                           ` Simon Wright
  0 siblings, 1 reply; 200+ results
From: Dmitry A. Kazakov @ 2012-03-06 19:18 UTC (permalink / raw)


On Tue, 06 Mar 2012 17:59:04 +0000, Simon Wright wrote:

> 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).

You could improve that a bit by putting Ada.Calendar.Clock into a loop.
When it returns a different value, you exit the loop and take that value
for the time base.

If the quartz is same you need not to synchronize it anymore. Since the
multiplier is known you simply add the RTC minus its value at the base
multiplied by the factor and converted to Duration (or Time_Span) to the
base and use that instead of the original Ada's Clock.

Did you check the kernel settings? It has a variable that sets the time
source to the RTC. This might work on your PPC's BSP. The effect is that
the system clock is changed each time when queried rather than upon timer
interrupts.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[relevance 4%]

* Re: Any leap year issues caused by Ada yesterday?
  @ 2012-03-06 17:59  4%                       ` Simon Wright
  2012-03-06 19:18  4%                         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 200+ results
From: Simon Wright @ 2012-03-06 17:59 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Tue, 06 Mar 2012 16:46:35 +0000, Simon Wright wrote:
>
>> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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).



^ permalink raw reply	[relevance 4%]

Results 1-200 of ~900   | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2012-03-01 13:06     Any leap year issues caused by Ada yesterday? Georg Bauhaus
2012-03-05 11:07     ` tonyg
2012-03-05 15:59       ` Shark8
2012-03-05 18:03         ` Dmitry A. Kazakov
2012-03-05 18:30           ` Simon Wright
2012-03-05 20:17             ` Dmitry A. Kazakov
2012-03-05 20:56               ` Simon Wright
2012-03-06  8:47                 ` Dmitry A. Kazakov
2012-03-06  9:20                   ` Simon Wright
2012-03-06 10:07                     ` Dmitry A. Kazakov
2012-03-06 16:46                       ` Simon Wright
2012-03-06 17:37                         ` Dmitry A. Kazakov
2012-03-06 17:59  4%                       ` Simon Wright
2012-03-06 19:18  4%                         ` Dmitry A. Kazakov
2012-03-06 20:22  7%                           ` Simon Wright
2012-03-06 21:19     Ada and linux real time slos
2012-03-07  8:23     ` Dmitry A. Kazakov
2012-03-07 12:10       ` slos
2012-03-07 14:18         ` Dmitry A. Kazakov
2012-03-08  2:38           ` Eilie
2012-03-08 12:04             ` Simon Clubley
2012-03-08 21:45               ` slos
2012-03-15  2:35                 ` BrianG
2012-03-16 20:36                   ` slos
2012-03-17 12:34                     ` Simon Wright
2012-03-17 15:50  7%                   ` Simon Wright
2012-06-07 20:36  7% package Ada.Tags RasikaSrinivasan
2012-06-07 21:49  0% ` Adam Beneschan
2012-06-10 19:33     Practicalities of Ada for app development Dmitry A. Kazakov
2012-06-10 21:36     ` Nomen Nescio
2012-06-11  8:22       ` Dmitry A. Kazakov
2012-06-11 14:27         ` Georg Bauhaus
2012-06-11 14:43           ` Dmitry A. Kazakov
2012-06-11 17:14             ` Georg Bauhaus
2012-06-11 18:38               ` Dmitry A. Kazakov
2012-06-11 20:50                 ` Georg Bauhaus
2012-06-12  7:55                   ` Dmitry A. Kazakov
2012-06-12  9:48                     ` Georg Bauhaus
2012-06-12 11:44  4%                   ` Dmitry A. Kazakov
2012-07-20 17:18 13% Ada.Calendar Question awdorrin
2012-07-20 17:59 11% ` Adam Beneschan
2012-07-20 18:24 13%   ` awdorrin
2012-07-20 18:51 13%     ` Simon Wright
2012-07-23 13:23 11%       ` awdorrin
2012-07-20 20:05     Ada "library only" compiler ? Patrick
2012-07-20 21:11     ` Niklas Holsti
2012-07-20 23:30       ` Patrick
2012-07-21 16:47  2%     ` Niklas Holsti
2012-07-23 21:42 14% Ada.Calendar and NTP (and Unix Epoch) erlo
2012-07-23 22:07 11% ` Adam Beneschan
     [not found]       ` <5s8s08lv6dj1i4tkb99roq9roifsgr44vd@invalid.netcom.com>
2012-07-24  7:11 11%     ` Dmitry A. Kazakov
2012-07-24  7:50  6%       ` erlo.haugen
2012-07-24  8:14 10%         ` Dmitry A. Kazakov
2012-07-24  8:34  6%           ` erlo.haugen
2012-07-24  9:13  5%             ` Dmitry A. Kazakov
2012-07-24 12:27 11%               ` erlo.haugen
2012-07-24 13:02 11%                 ` Dmitry A. Kazakov
2012-07-24 14:10  6%                   ` erlo
2012-07-24 16:37  6%                 ` Adam Beneschan
2012-07-24  7:24  6%   ` erlo.haugen
2012-07-24 16:26 11%     ` Adam Beneschan
2012-07-24 18:28 11%       ` Dmitry A. Kazakov
2012-07-24 19:07 11%         ` Adam Beneschan
2012-07-24 20:17 10%           ` Dmitry A. Kazakov
2012-07-24 19:43  9%         ` Vasiliy Molostov
2012-07-24 20:29  6%           ` Dmitry A. Kazakov
2012-07-24 21:22  5%             ` Vasiliy Molostov
2012-07-25  6:32  6%               ` Dmitry A. Kazakov
2012-07-25  7:04  5%                 ` Vasiliy Molostov
2012-07-25  7:33  6%                   ` Dmitry A. Kazakov
2012-07-25  8:05  6%                     ` Vasiliy Molostov
2012-07-25  8:30  6%                       ` Dmitry A. Kazakov
2012-07-25  8:45  6%                         ` Vasiliy Molostov
2012-07-25  9:30  6%                           ` Dmitry A. Kazakov
2012-07-24 20:33 10%     ` Simon Wright
2012-07-25 10:14 13%       ` Simon Wright
2012-07-25 13:16  6%         ` Dmitry A. Kazakov
2012-07-24  7:37  6%   ` erlo.haugen
2012-07-24 11:34  6% ` Simon Wright
2012-07-24 11:59  6%   ` Nasser M. Abbasi
2012-07-24 15:08  6%     ` Simon Wright
2012-07-24 16:59  6%       ` Georg Bauhaus
2012-07-24 19:25  6%         ` Simon Wright
2012-07-24 22:07  6%           ` Georg Bauhaus
2012-07-24 19:17  6%     ` John B. Matthews
2012-07-25  2:23  6% ` sla29970
2012-07-25  6:40  6%   ` Dmitry A. Kazakov
2012-07-29  9:31     how to tell gnatmake to send executables to a different directory when compiling multi source? Nasser M. Abbasi
2012-07-29 10:00     ` Dmitry A. Kazakov
2012-07-29 11:35       ` Nasser M. Abbasi
2012-07-29 12:29         ` Patrick
2012-07-29 13:02           ` Nasser M. Abbasi
2012-07-29 13:49             ` Ludovic Brenta
2012-07-29 14:09               ` Nasser M. Abbasi
2012-07-29 15:35                 ` Ludovic Brenta
2012-07-29 17:35                   ` Vasiliy Molostov
2012-07-29 19:46                     ` Robert A Duff
2012-07-30  0:20                       ` Vasiliy Molostov
2012-07-30  6:40                         ` Ludovic Brenta
2012-07-30 10:31  3%                       ` Vasiliy Molostov
2012-07-30 11:05  0%                         ` Ludovic Brenta
2012-09-14 14:36     Ganssle plugs Ada mjsilva
2012-09-14 21:29  4% ` Shark8
2012-10-30 22:03  6% Tasking troubles, unexpected termination Shark8
2012-10-30 23:01     ` Adam Beneschan
2012-10-31  1:05       ` Anh Vo
2012-10-31  2:17  6%     ` Shark8
2012-10-31  2:59  6%       ` Shark8
2012-11-02 16:02  0%         ` Anh Vo
2012-10-31 16:47     Child packages named Ada illegal? Marius Amado-Alves
2012-10-31 17:02  8% ` Shark8
2012-12-27 18:48     A thicker binding for Lapack jpwoodruff
2012-12-27 19:18     ` Shark8
2012-12-29 18:36       ` jpwoodruff
2012-12-29 19:59  5%     ` Simon Wright
2013-04-27 21:08     GNAT not generating any code for sub‑program: known bug? Yannick Duchêne (Hibou57)
2013-04-27 22:22     ` Yannick Duchêne (Hibou57)
2013-04-28  7:14  4%   ` Simon Wright
2013-12-06 15:14  5% Renaming vs assignment to constant Simon Wright
2013-12-06 16:09  0% ` Jeffrey Carter
2013-12-06 16:47  0% ` adambeneschan
2013-12-06 18:06  0%   ` Eryndlia Mavourneen
2013-12-07  0:47  0%   ` Randy Brukardt
2013-12-06 18:35  0% ` G.B.
2013-12-06 21:59  0% ` Shark8
2014-01-28  1:06  5% need help learning Ada for a modula-2 programmer agent
2014-01-29 16:58  0% ` Dirk Heinrichs
2014-01-29 20:43  0%   ` Randy Brukardt
2014-01-30  4:29  0%   ` Nasser M. Abbasi
2014-01-30 16:28  0%     ` Pascal Obry
2014-03-30  8:50  5% Ann: Excel Writer v.12 gautier_niouzes
2014-04-04  0:35  5% gnatmake error I don't understand agent
2014-04-04  4:14  0% ` Per Sandberg
2014-04-10 10:41  6% Asynchronous Transfer of Control AdaMagica
2014-04-10 15:15  0% ` Adam Beneschan
2014-07-16 12:25     why the pascal family of languages (Pascal, Ada, Modula-2,2,Oberon, Delphi, Algol,...) failed compared to the C family? Nasser M. Abbasi
2014-07-16 17:40     ` john
2014-07-16 19:52       ` Jeffrey Carter
2014-07-17  5:29         ` why the pascal family of languages (Pascal, Ada, Modula-2,2,Oberon, anon
2014-07-17 12:24           ` why the pascal family of languages (Pascal, Ada, Modula-2, 2, Oberon, Dan'l Miller
2014-07-22  0:01             ` Randy Brukardt
2014-07-22 14:41               ` why the pascal family of languages (Pascal, Ada, Modula-2,2,Oberon, Dan'l Miller
2014-07-22 21:46  4%             ` Randy Brukardt
2014-08-05 19:47  5% Leap second support and ARM 9.6.1p89/2 Natasha Kerensikova
2014-08-07  4:57     ` Randy Brukardt
2014-08-07  7:35       ` Natasha Kerensikova
2014-08-07  8:59  6%     ` Markus Schöpflin
2014-08-26 22:38     STM32F4 Discovery, communication and libraries roy.emmerich
2014-08-27 13:08     ` Dennis Lee Bieber
2014-08-27 16:03       ` Roy Emmerich
2014-08-28  1:48         ` Dennis Lee Bieber
2014-08-28 10:12           ` Roy Emmerich
2014-08-28 13:00             ` Dmitry A. Kazakov
2014-08-28 16:28               ` Mike Silva
2014-08-28 20:09                 ` Dmitry A. Kazakov
2014-08-28 20:34                   ` embeddedrelatedmike
2014-08-29 13:06                     ` Dennis Lee Bieber
2014-08-29 16:52  4%                   ` Niklas Holsti
2014-08-28 21:17                   ` Niklas Holsti
2014-08-29  7:41                     ` Dmitry A. Kazakov
2014-08-29 16:31                       ` Niklas Holsti
2014-08-29 16:47                         ` Roy Emmerich
2014-08-29 19:41                           ` Niklas Holsti
2014-08-30 22:00  5%                         ` Roy Emmerich
2014-09-01 20:15  6%                           ` Niklas Holsti
2014-09-01 21:11  5%                             ` Jeffrey Carter
2014-10-14 16:02     Deleting or editing usenet posts - does it work? fast? Phil
2014-10-14 19:47     ` Simon Clubley
2014-10-15 14:29       ` Peter Chapin
2014-10-16  9:20         ` Phil
2014-10-16 10:01  5%       ` J-P. Rosen
2014-10-16 12:55  5% Gnat Pro Cross compiling Nahro Nadir
2014-10-24 16:44     confusion about message passing between the tasks compguy45
2014-10-25 17:25     ` Dennis Lee Bieber
2014-10-25 17:54       ` Jeffrey Carter
2014-10-25 22:23         ` Robert A Duff
2014-10-25 23:26  6%       ` compguy45
2015-01-16  3:44     Generics crash course John Smith
2015-01-16  5:14  3% ` Jeffrey Carter
2015-02-02  5:50  5% Did I find mamory leak in Generic Image Decoder (GID) ? reinkor
2015-04-01  8:42  4% I've not seen this error before tonyg
2015-04-01 13:08  0% ` Simon Wright
2015-04-01 13:18  5%   ` tonyg
2015-06-21 18:38  7% Is there an easier way for this? Laurent
2015-06-21 19:15  6% ` Niklas Holsti
2015-06-21 19:41  0%   ` Laurent
2015-06-21 19:25  7% ` Jeffrey R. Carter
2015-06-21 19:42  0%   ` Laurent
2015-06-22 16:41       ` Laurent
2015-06-22 16:47         ` Jeffrey R. Carter
2015-06-22 17:18           ` Laurent
2015-06-22 18:04             ` What do you think about this? Laurent
2015-06-23 14:21               ` Stephen Leake
2015-06-23 19:51  4%             ` Laurent
2015-07-13 13:26  6% Time_Zone-aware Day_of_Week ? Natasha Kerensikova
2015-07-13 16:45  7% ` Jeffrey R. Carter
2015-07-16 17:07  0%   ` brbarkstrom
2015-07-27 14:28     Running a preprocessor from GPS? EGarrulo
2015-07-29 22:32     ` EGarrulo
2015-07-29 23:51       ` Jeffrey R. Carter
2015-07-30  0:10         ` EGarrulo
2015-07-30  6:01           ` Niklas Holsti
2015-07-30  7:33             ` Björn Lundin
2015-07-30  8:03               ` EGarrulo
2015-07-30  8:08                 ` Jacob Sparre Andersen
2015-07-30  8:37                   ` EGarrulo
2015-07-30 19:29                     ` Jeffrey R. Carter
2015-07-30 20:53                       ` EGarrulo
2015-07-31 11:26                         ` Brian Drummond
2015-07-31 17:54                           ` Jeffrey R. Carter
2015-07-31 18:20                             ` EGarrulo
2015-08-01  7:20                               ` Simon Wright
2015-08-01  8:06                                 ` EGarrulo
2015-08-01  8:33                                   ` Simon Wright
2015-08-01 10:47                                     ` EGarrulo
2015-08-01 11:44                                       ` Niklas Holsti
2015-08-01 12:19                                         ` EGarrulo
2015-08-01 17:49                                           ` Jeffrey R. Carter
2015-08-01 18:15                                             ` Paul Rubin
2015-08-01 20:30  6%                                           ` Georg Bauhaus
2015-08-03 16:08  5% Design of cross referring types/classes and proper usage of containers Serge Robyns
2015-08-03 16:14  0% ` Serge Robyns
2015-08-03 16:22  0% ` Dmitry A. Kazakov
2015-08-25  6:44  7% Understanding the dependency to a-calend.adb introduced by gnatcoll-xref.adb in gnatcoll-xref.ali David SAUVAGE
2015-08-25  7:34  0% ` Simon Wright
2015-10-31 20:29  6% A few questions Laurent
2015-10-31 20:49  5% ` Dmitry A. Kazakov
2015-11-01 13:16  0%   ` Laurent
2015-11-01  0:25  6% ` Jeffrey R. Carter
2015-11-01 13:30  0%   ` Laurent
2015-11-03  6:25  6%   ` Randy Brukardt
2015-11-02 17:45  8% ` Simon Wright
2015-11-02 18:48  7%   ` Simon Wright
2015-11-03  6:33  0%     ` Randy Brukardt
2015-11-03  8:26  0%       ` Simon Wright
2015-11-03  6:40       ` Randy Brukardt
2015-11-03  8:34         ` Simon Wright
2015-11-04 16:19           ` Simon Wright
2015-11-05  1:20             ` Randy Brukardt
2015-11-05  8:34               ` briot.emmanuel
2015-11-12 18:28                 ` Randy Brukardt
2015-11-12 20:19  4%               ` Simon Wright
2015-11-27 15:25     Two approaches of iterators for the key-value pairs ytomino
2015-11-27 17:43     ` Brad Moore
2015-11-27 19:38       ` ytomino
2015-11-27 23:11         ` Brad Moore
2015-11-28  8:58           ` Simon Wright
2015-11-29 16:17  6%         ` Simon Wright
2015-12-31  4:15     Abortable Timed Action T.G.
2015-12-31  6:40     ` Anh Vo
2015-12-31  7:32       ` T.G.
2015-12-31 16:21         ` Anh Vo
2015-12-31 18:09           ` T.G.
2016-01-06 21:14  7%         ` Anh Vo
2016-01-08 20:24  7%           ` T.G.
2016-01-09  8:45  8%             ` Simon Wright
2016-01-09  9:10  0%               ` Dmitry A. Kazakov
2016-01-09 15:59  0%               ` T.G.
2016-03-21 13:18     Operating System differences and Ada OS independent programming ldries46
2016-03-21 17:24     ` Dennis Lee Bieber
2016-03-21 22:04       ` Randy Brukardt
2016-03-22  8:43         ` Dmitry A. Kazakov
2016-03-22 11:15           ` G.B.
2016-03-23  8:13             ` gautier_niouzes
2016-03-23  8:38               ` Dmitry A. Kazakov
2016-03-24  3:36  4%             ` Shark8
2016-03-24  7:58  0%               ` Dmitry A. Kazakov
2016-03-30 15:35     Roundtrip latency problem using Gnoga, on Linux, when testing at localhost address Olivier Henley
2016-03-31  4:47     ` rieachus
2016-03-31  5:23       ` Jeffrey R. Carter
2016-03-31  7:38         ` Dmitry A. Kazakov
2016-03-31 17:02           ` Olivier Henley
2016-03-31 17:44  4%         ` Dmitry A. Kazakov
2016-05-13 20:37     ANN: Introducing AdaBase - Thick database bindings for Ada jrmarino
2016-05-13 21:44     ` Per Sandberg
2016-05-13 23:37       ` Randy Brukardt
2016-05-14  6:59         ` gautier_niouzes
2016-05-16 20:06  5%       ` Randy Brukardt
2016-08-17 21:05 10% GNATCOLL SQLite3 vs Ada.Calendar.Time Stephen Leake
2016-08-18  8:09  6% ` Dmitry A. Kazakov
2016-08-18 11:19  5% ` G.B.
2016-08-18 17:45  5%   ` Stephen Leake
2016-08-18 18:13  6%     ` Stephen Leake
2016-08-19 15:30  6%       ` Stephen Leake
2016-08-19 17:43  4%         ` G.B.
2016-08-18 18:28 12%     ` Jeffrey R. Carter
2016-08-18 19:48  6%       ` Dmitry A. Kazakov
2016-08-18 20:50  5%         ` Jeffrey R. Carter
2016-08-18 22:05 10%         ` Randy Brukardt
2016-08-25 20:17     zLibAda vs ZipAda (which should I use, if any)? Aurele
2016-08-25 23:07     ` Aurele
2016-08-25 23:43       ` gautier_niouzes
2016-08-25 23:55         ` Aurele
2016-08-26  0:18           ` gautier_niouzes
2016-08-26  1:44             ` Aurele
2016-08-26 12:36               ` gautier_niouzes
2016-08-26 14:23                 ` Aurele
2016-08-26 15:16                   ` gautier_niouzes
2016-08-26 16:05                     ` Aurele
2016-08-26 23:04                       ` Aurele
2016-08-27  5:30                         ` gautier_niouzes
2016-08-27 11:52                           ` Aurele
2016-08-27 16:31                             ` Aurele
2016-08-27 19:15  4%                           ` gautier_niouzes
2017-01-22 11:37  6% Ok to assume type Duration is for more than one day? reinkor
2017-08-03  5:45     Community Input for the Maintenance and Revision of the Ada Programming Language Randy Brukardt
2017-10-02 10:06  6% ` reinert
2017-10-02 14:56  0%   ` Dennis Lee Bieber
2017-10-02 15:02       ` G.B.
2017-10-02 16:23         ` reinert
2017-10-02 19:14           ` Jeffrey R. Carter
2017-10-03  3:30             ` reinert
2017-10-03  6:36  5%           ` G.B.
2017-09-16  6:40     NTP Anatoly Chernyshev
2017-09-16  9:29  7% ` NTP Dmitry A. Kazakov
2017-09-18  7:54       ` NTP Tarjei Jensen
2017-09-18  8:21  7%     ` NTP Dmitry A. Kazakov
2017-10-28 20:02  4% Read-write mutex sometimes fails on deadlock pascal.malaise
2017-11-19  2:19     When to use Bounded_String? Victor Porton
2017-11-23 10:04     ` briot.emmanuel
2017-12-28 11:46       ` Vincent DIEMUNSCH
2017-12-28 12:00         ` Dmitry A. Kazakov
2017-12-28 12:29           ` Mehdi Saada
2017-12-29  0:42  4%         ` Randy Brukardt
2018-02-17 12:55  4% GNAT can't vectorize Real_Matrix multiplication from Ada.Numerics.Real_Arrays. What a surprise! Bojan Bozovic
2018-02-17 15:17  0% ` Bojan Bozovic
2018-02-17 15:49  0%   ` Bojan Bozovic
2018-02-18  1:51  5% ` Bojan Bozovic
2018-07-17  1:20  6% How to run a GNAT program without starting a terminal session Jerry
2018-07-17 12:46  0% ` Björn Lundin
2018-07-17 21:07  0%   ` Jerry
2018-07-17 21:12         ` Shark8
2018-07-17 21:56           ` Jerry
2018-07-18  1:33  7%         ` Shark8
2018-07-17 18:21  0% ` Shark8
2018-07-19  2:57  0% ` Jerry
2018-07-19  7:20  0%   ` Björn Lundin
2018-07-19 11:30  0%     ` Jerry
2018-08-04  0:20     Ann: Ada-Win32 bindings alby.gamper
2018-08-04  7:10  4% ` Dmitry A. Kazakov
2018-08-04  9:58  0%   ` alby.gamper
2018-09-21 10:29     Watchdog-Timer Assignment Alex
2018-09-22  3:29  6% ` Shark8
2018-09-22 11:56  0%   ` Alex
2018-10-04 21:38     A little trouble with very large arrays Shark8
2018-10-05  6:20     ` Niklas Holsti
2018-10-05 16:47       ` Shark8
2018-10-05 17:39         ` Niklas Holsti
2018-10-05 19:49  5%       ` Shark8
2018-10-05 20:31  0%         ` Dmitry A. Kazakov
2018-11-19 22:56  6% GNAT Modification_Time limitation Lionel Draghi
2018-11-20  1:33  0% ` Keith Thompson
2018-11-20 23:32  7%   ` Randy Brukardt
2018-11-20  8:08  0% ` briot.emmanuel
2019-04-30  0:58  7% Q: Calendar and time zones b.mcguinness747
2019-07-23 21:15  4% ANN: dcf-ada 2.0.0 -- A library for document container files, a Zip-based archive format onox
2020-03-02 18:49 12% Ada.Calendar.Formatting.Image (or Time_Of) changing the time Marius Amado-Alves
2020-03-02 23:08  6% ` Randy Brukardt
2020-03-03 12:59  6%   ` Marius Amado-Alves
2020-03-03 14:25  9%     ` Dmitry A. Kazakov
2020-03-03 14:53 12% ` Simon Wright
2020-03-03 17:40  6%   ` Simon Wright
2020-03-03 23:49  5%   ` Randy Brukardt
2020-03-04 15:19  6%     ` Simon Wright
2020-03-04 22:33  6%     ` Optikos
2020-03-05 16:11  5%       ` Optikos
2020-03-05 23:29  5%       ` Randy Brukardt
2020-03-06 14:42  3%         ` Optikos
2020-03-07  0:19  5%           ` Randy Brukardt
2020-03-07  1:18  6%             ` Optikos
2020-10-24  7:38  5% Ann: HAC v.0.076 gautier...@hotmail.com
2021-07-17  7:56     Problem with emacs ada-mode-7.1.4 Paul Onions
2021-07-17 21:18     ` Simon Wright
2021-07-18  8:43       ` Paul Onions
2021-07-18  9:00         ` Dmitry A. Kazakov
2021-07-18  9:26  4%       ` Paul Onions
2021-09-05  6:56     Trivial question: how to avoid confusing sec, min, hour and day in a program? reinert
2021-09-05  7:27     ` Dmitry A. Kazakov
2021-10-24  6:52       ` reinert
2021-10-24 10:48  4%     ` Simon Wright
2023-02-28 21:10     Build order with gprbuild Gautier write-only address
2023-02-28 22:07     ` Dmitry A. Kazakov
2023-03-01 20:08  4%   ` Gautier write-only address
2023-04-19 17:36     Ada interface to Excel file AdaMagica
2023-04-20 19:08  4% ` Gautier write-only address
2023-08-18  7:18     Parameterised 'Image Attributes Rod Kay
2023-08-18  8:25     ` Luke A. Guest
2023-08-19  9:14       ` J-P. Rosen
2023-08-19 15:27  3%     ` Jeffrey R.Carter
2023-08-20  7:53  0%       ` G.B.
     [not found]     <262bea8c-57ff-480e-b5aa-da94f0436e98n@googlegroups.com>
2023-10-16 18:35     ` Windows file timestamp converted to local time Matt Borchers
2023-10-16 18:49  5%   ` Niklas Holsti
2023-10-17  2:39  0%     ` Randy Brukardt
2023-10-17 14:13  0%     ` Matt Borchers
2023-10-17 16:28  6%       ` Niklas Holsti
2023-10-17 16:35  0%         ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox