comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pushface.org>
Subject: Compiler doesn't respect 'Size for atomic object
Date: Wed, 20 Dec 2017 12:35:51 +0000
Date: 2017-12-20T12:35:51+00:00	[thread overview]
Message-ID: <lyy3lxfufs.fsf@pushface.org> (raw)

The code below is an abstract of one for a Cortex-M processor; it
generates an external interrupt, useful for testing.

All released GNAT compilers I have access to and which accept the syntax
(GPL 2015+, FSF GCC 5+) produce the result that the hardware needs and
that I intended, i.e. 16#1#.

GCC 8, which is still under development, produces 16#FFFFFF01#, i.e. has
only written the least significant byte.

I'm pretty sure this is an error, rather than an unhelpful
interpretation: can anyone confirm one way or the other, before I raise
a bug, please?

========================================================================
with Ada.Text_IO;
with Interfaces;

procedure Full_Word is

   Register : Interfaces.Unsigned_32;

   type Interrupt_ID is range 0 .. 44;

   procedure Trigger_Interrupt (IRQ : Interrupt_ID) is
      --  The Software Trigger Interrupt Register.
      NVIC_STIR : Interrupt_ID
      with
        Import,
        Atomic,
        Size    => 32,
        Address => Register'Address;

   begin
      NVIC_STIR := IRQ;                   -- h/w requires 32-bit write
   end Trigger_Interrupt;

   package Unsigned_32_IO
     is new Ada.Text_IO.Modular_IO (Interfaces.Unsigned_32);

begin
   Register := 16#ffff_ffff#;
   Trigger_Interrupt (1);
   Unsigned_32_IO.Put (Register, Base => 16);
   Ada.Text_IO.New_Line;
end Full_Word;


             reply	other threads:[~2017-12-20 12:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20 12:35 Simon Wright [this message]
2017-12-20 19:23 ` Compiler doesn't respect 'Size for atomic object Simon Clubley
2017-12-20 20:19   ` Simon Wright
2017-12-20 20:45     ` Simon Clubley
2017-12-21  7:10       ` Randy Brukardt
2017-12-21 14:08         ` Simon Wright
2017-12-20 21:20     ` Simon Wright
2017-12-21  5:55       ` Robert Eachus
2017-12-21 14:02         ` Simon Wright
2017-12-21 22:02         ` Simon Wright
2017-12-22  4:51           ` Robert Eachus
2017-12-22 10:21             ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox