From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: Unifont static compiled and stack size... Date: Mon, 14 Aug 2023 12:06:35 +0200 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 14 Aug 2023 10:06:36 -0000 (UTC) Injection-Info: dont-email.me; posting-host="13b96440b5c2aea0289fe3b4104f8eda"; logging-data="2374445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+kUHDb/2FADmo6f10Tlr81EQR+ZLEEEls=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Cancel-Lock: sha1:eULddB0B3wqJkAnq987ogEv6mDo= Content-Language: en-US In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:65521 List-Id: 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