comp.lang.ada
 help / color / mirror / Atom feed
* s-stoele.ads:62:69: error: cannot convert to a pointer type
@ 2016-11-16 18:01 Lucretia
  2016-11-16 19:51 ` Simon Wright
  2016-11-16 19:53 ` Simon Wright
  0 siblings, 2 replies; 5+ messages in thread
From: Lucretia @ 2016-11-16 18:01 UTC (permalink / raw)


Hi,

I've been updating my bare_bones project and I've always wanted to add a simple secondary stack to it, so as a dummy interface I created the following in my RTS:

package System.Secondary_Stack is
   package SSE renames System.Storage_Elements;
   
   type Mark_Id is private;
   
   function SS_Mark return Mark_Id;
   
   procedure SS_Allocate
     (Addr         : System.Address;
      Storage_Size : SSE.Storage_Count);
   
   procedure SS_Release (M : Mark_Id);
private
   type Mark_Id is new SSE.Integer_Address;
   
   SS_Pool : Integer;
   
   SS_Size : constant SSE.Storage_Element with
     import        => True,
     Convention    => Asm,
     External_Name => "sec_stack_size";
end System.Secondary_Stack;

package body System.Secondary_Stack is
   function SS_Mark return Mark_Id is
   begin
      return Mark_Id'First;
   end SS_Mark;
   
   procedure SS_Allocate     
     (Addr         : System.Address;
      Storage_Size : SSE.Storage_Count) is
   begin
      null;
   end SS_Allocate;

   procedure SS_Release (M : Mark_Id) is
   begin
      null;
   end SS_Release;
end System.Secondary_Stack;

But when compiling this:

--  Cut out the use/with clauses
procedure Bare_Bones is
   Line : Screen_Height_Range := Screen_Height_Range'First;

   procedure T is
   begin
      Put ("T called", Screen_Width_Range'First, Line);
   end T;
   
   function Hello return String is
   begin
      return "hello";
   end Hello;
begin
   --     null;
   Clear;

   Put ("Hello, bare bones in Ada",
        Screen_Width_Range'First,
        Line);

   Line := Line + 1;

   if Magic = Magic_Value then
      Put ("Magic numbers match!", Screen_Width_Range'First, Line);
   else
      Put ("Magic numbers don't match!", Screen_Width_Range'First, Line);  --  comment

      raise Program_Error;
   end if;

   Line := Line + 1;

   T;
   
   Line := Line + 1;

   Put (Hello, Screen_Width_Range'First, Line);
end Bare_Bones;

I get the following error:

GNAT 4.9.2
Copyright 1992-2014, Free Software Foundation, Inc.
/home/laguest/src/mine/bare_bones/build/gnat/gen/rts/i586/adainclude/s-stoele.ads: In function 'Bare_Bones.Hello':
/home/laguest/src/mine/bare_bones/build/gnat/gen/rts/i586/adainclude/s-stoele.ads:62:69: error: cannot convert to a pointer type

Compiling: /home/laguest/src/mine/bare_bones/src/bare_bones.adb (source file time stamp: 2016-11-16 17:01:32)
 186 lines: No errors
End of compilation
i586-elf-gnatmake: "/home/laguest/src/mine/bare_bones/src/bare_bones.adb" compilation error
makefile:118: recipe for target '/home/laguest/src/mine/bare_bones/build/gnat/gen/pc/debug/disk/boot/bare_bones-i586.elf' failed
make: *** [/home/laguest/src/mine/bare_bones/build/gnat/gen/pc/debug/disk/boot/bare_bones-i586.elf] Error 4

My expanded source is:


pragma restrictions (no_obsolescent_features);
with vga_console;
use vga_console;
with multiboot;
use multiboot;
use type multiboot.multiboot__magic_values;
with system.system__secondary_stack;

procedure bare_bones is
   M9b : system__secondary_stack__mark_id :=
     $system__secondary_stack__ss_mark;
   procedure bare_bones___finalizer;
   freeze bare_bones___finalizer []

   procedure bare_bones___finalizer is
   begin
      $system__secondary_stack__ss_release (M9b);
      return;
   end bare_bones___finalizer;
begin
   line : vga_console__screen_height_range := 1;

   procedure bare_bones__t is
   begin
      vga_console__put__2 ("T called", 1, line, foreground =>
        vga_console__white, background => vga_console__black);
      return;
   end bare_bones__t;

   function bare_bones__hello return string is
   begin
      return "hello";
   end bare_bones__hello;

   vga_console__clear (background => vga_console__black);
   vga_console__put__2 ("Hello, bare bones in Ada", 1, 1, foreground =>
     vga_console__white, background => vga_console__black);
   line := 2;
   if magic = multiboot__magic_value then
      vga_console__put__2 ("Magic numbers match!", 1, 2, foreground =>
        vga_console__white, background => vga_console__black);
   else
      vga_console__put__2 ("Magic numbers don't match!", 1, 2,
        foreground => vga_console__white, background =>
        vga_console__black);
      [program_error "explicit raise"]
   end if;
   line := 3;
   bare_bones__t;
   R7b : constant integer := line + 1;
   [constraint_error when
     not (R7b in 1 .. 25)
     "range check failed"]
   line := R7b;
   B8b : declare
   begin
      vga_console__put__2 (bare_bones__hello, 1, line, foreground =>
        vga_console__white, background => vga_console__black);
   end B8b;
   return;
at end
   bare_bones___finalizer;
end bare_bones;

I'm lost. Anyone have any idea?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s-stoele.ads:62:69: error: cannot convert to a pointer type
  2016-11-16 18:01 s-stoele.ads:62:69: error: cannot convert to a pointer type Lucretia
@ 2016-11-16 19:51 ` Simon Wright
  2016-11-16 19:59   ` Lucretia
  2016-11-16 19:53 ` Simon Wright
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Wright @ 2016-11-16 19:51 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

>    procedure SS_Allocate
>      (Addr         : System.Address;
>       Storage_Size : SSE.Storage_Count);

Addr should be an out parameter


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s-stoele.ads:62:69: error: cannot convert to a pointer type
  2016-11-16 18:01 s-stoele.ads:62:69: error: cannot convert to a pointer type Lucretia
  2016-11-16 19:51 ` Simon Wright
@ 2016-11-16 19:53 ` Simon Wright
  2016-11-16 20:00   ` Lucretia
  1 sibling, 1 reply; 5+ messages in thread
From: Simon Wright @ 2016-11-16 19:53 UTC (permalink / raw)


Lucretia <laguest9000@googlemail.com> writes:

>    SS_Size : constant SSE.Storage_Element with
>      import        => True,
>      Convention    => Asm,
>      External_Name => "sec_stack_size";

Only 0 .. 255?

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s-stoele.ads:62:69: error: cannot convert to a pointer type
  2016-11-16 19:51 ` Simon Wright
@ 2016-11-16 19:59   ` Lucretia
  0 siblings, 0 replies; 5+ messages in thread
From: Lucretia @ 2016-11-16 19:59 UTC (permalink / raw)


On Wednesday, 16 November 2016 19:51:59 UTC, Simon Wright  wrote:
> Lucretia <me> writes:
> 
> >    procedure SS_Allocate
> >      (Addr         : System.Address;
> >       Storage_Size : SSE.Storage_Count);
> 
> Addr should be an out parameter

Doh! Thanks, missed that one.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: s-stoele.ads:62:69: error: cannot convert to a pointer type
  2016-11-16 19:53 ` Simon Wright
@ 2016-11-16 20:00   ` Lucretia
  0 siblings, 0 replies; 5+ messages in thread
From: Lucretia @ 2016-11-16 20:00 UTC (permalink / raw)


On Wednesday, 16 November 2016 19:53:41 UTC, Simon Wright  wrote:
> Lucretia <me> writes:
> 
> >    SS_Size : constant SSE.Storage_Element with
> >      import        => True,
> >      Convention    => Asm,
> >      External_Name => "sec_stack_size";
> 
> Only 0 .. 255?

It was just a placeholder and meant to be Storage_Count :D I've changed it.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-16 20:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-16 18:01 s-stoele.ads:62:69: error: cannot convert to a pointer type Lucretia
2016-11-16 19:51 ` Simon Wright
2016-11-16 19:59   ` Lucretia
2016-11-16 19:53 ` Simon Wright
2016-11-16 20:00   ` Lucretia

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