comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R.Carter" <spam.jrcarter.not@spam.acm.org.not>
Subject: Re: Unifont static compiled and stack size...
Date: Mon, 14 Aug 2023 12:06:35 +0200	[thread overview]
Message-ID: <ubcubb$28epd$1@dont-email.me> (raw)
In-Reply-To: <f8a1dfeb-5648-4a28-b07b-367c32d8b342n@googlegroups.com>

On 2023-08-13 18:16, Micah Waddoups wrote:
> I tried to compile the Unifont hex file, converted with a script into variable Ada code, but it went on forever, gradually blowing up my memory.  I used an .ads file and aimed for a static build, but I suspect I would have hit the stack size limit for executables if I succeeded

As I understand it, the file in question is for code points 0 .. 16#FFFF#, with 
a maximum of 32 bytes per code point. A straightforward representation of this is

package Unifont is
    type Byte is mod 2 ** 8 with Size => 8;

    type Line is array (1 .. 2) of Byte with Size => 16;

    type Bitmap is array (1 .. 16) of Line with Size => 256;

    function Width_8 (Map : in Bitmap) return Boolean is
       (for all L of Map => L (2) = 0);

    type Code_Point is mod 16#FFFF# + 1;

    type Font_Map is array (Code_Point) of Bitmap with Size => 2 ** 24;

    Font : constant Font_Map := (others => (others => (others => 0) ) );
end Unifont;

Font will occupy 2 MB.

We can test this with

with Ada.Text_IO;
with Unifont;

procedure Unifont_Test is
    -- Empty
begin -- Unifont_Test
    Ada.Text_IO.Put_Line (Item => Unifont.Font (0) (1) (1)'Image);
end Unifont_Test;

and see what happens:

$ gnatmake -m -j0 -gnat12 -gnatan -gnato2 -O2 -fstack-check unifont_test.adb
x86_64-linux-gnu-gcc-12 -c -gnat12 -gnatan -gnato2 -O2 -fstack-check 
unifont_test.adb
x86_64-linux-gnu-gcc-12 -c -gnat12 -gnatan -gnato2 -O2 -fstack-check unifont.ads
x86_64-linux-gnu-gnatbind-12 -x unifont_test.ali
x86_64-linux-gnu-gnatlink-12 unifont_test.ali -O2 -fstack-check
$ ./unifont_test
  0

so this representation seems to be workable. It should be trivial to write a 
program to read the file and produce the real array aggregate for Font.

-- 
Jeff Carter
"I wave my private parts at your aunties."
Monty Python & the Holy Grail
13

  parent reply	other threads:[~2023-08-14 10:06 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-13 16:16 Unifont static compiled and stack size Micah Waddoups
2023-08-13 21:19 ` DrPi
2023-08-14  0:29   ` Micah Waddoups
2023-08-14  8:21     ` Dmitry A. Kazakov
2023-08-14  8:07 ` Niklas Holsti
2023-08-14  8:31   ` Dmitry A. Kazakov
2023-08-14  9:25     ` Kevin Chadwick
2023-08-14  9:30       ` Kevin Chadwick
2023-08-14  9:43         ` Dmitry A. Kazakov
2023-08-14  9:39       ` Dmitry A. Kazakov
2023-08-15  8:40     ` G.B.
2023-08-16  6:17       ` Dmitry A. Kazakov
2023-08-18  3:04         ` Randy Brukardt
2023-08-14 10:06 ` Jeffrey R.Carter [this message]
2023-08-14 15:10   ` Micah Waddoups
2023-08-14 15:59     ` Jeffrey R.Carter
2023-08-14 16:02     ` Dmitry A. Kazakov
2023-08-15  4:48       ` Micah Waddoups
replies disabled

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