https://gcc.gnu.org/g:dde7adea08d7738ca822e2badb683354bf95815b
commit r17-5033-gdde7adea08d7738ca822e2badb683354bf95815b Author: Gaius Mulley <[email protected]> Date: Fri Oct 9 18:18:37 2026 +0100 PR modula2/127794: New LongStorage module to allow large dynamic memory alloc This patch provides two new PIM style modules LongStorage and LongSysStorage. These allow the programmer to allocate/deallocate more than 4GB memory (MAX(CARDINAL) in one library call. M2Diagnostic has additional long cardinal procedures which track the overall application memory used. gcc/m2/ChangeLog: PR modula2/127794 * gm2-libs/M2Diagnostic.def (MemIncrLong): New procedure. (MemDecrLong): Ditto. (MemSetLong): Ditto. (TotalHeapIncrLong): Ditto. (TotalHeapDecrLong): Ditto. * gm2-libs/M2Diagnostic.mod (MemIncrLong): New procedure. (MemDecrLong): Ditto. (MemSetLong): Ditto. (TotalHeapIncrLong): Ditto. (TotalHeapDecrLong): Ditto. (MemIncr): Reimplement. (MemDecr): Ditto. (MemSet): Ditto. (TotalHeapIncr): Ditto. (TotalHeapDecr): Ditto. * gm2-libs/LongStorage.def: New file. * gm2-libs/LongStorage.mod: New file. * gm2-libs/LongSysStorage.def: New file. * gm2-libs/LongSysStorage.mod: New file. libgm2/ChangeLog: PR modula2/127794 * libm2pim/Makefile.am (M2DEFS): Add LongStorage.def and LongSysStorage.def. (M2MODS): Add LongStorage.mod and LongSysStorage.mod. * libm2pim/Makefile.in: Regenerate. gcc/testsuite/ChangeLog: PR modula2/127794 * gm2.dg/pim/pass/largestore.mod: New test. * gm2.dg/pim/pass/largestore2.mod: New test. Signed-off-by: Gaius Mulley <[email protected]> Diff: --- gcc/m2/gm2-libs/LongStorage.def | 78 +++++++++++ gcc/m2/gm2-libs/LongStorage.mod | 57 ++++++++ gcc/m2/gm2-libs/LongSysStorage.def | 87 ++++++++++++ gcc/m2/gm2-libs/LongSysStorage.mod | 195 ++++++++++++++++++++++++++ gcc/m2/gm2-libs/M2Diagnostic.def | 38 +++++ gcc/m2/gm2-libs/M2Diagnostic.mod | 73 ++++++++-- gcc/testsuite/gm2.dg/pim/pass/largestore.mod | 30 ++++ gcc/testsuite/gm2.dg/pim/pass/largestore2.mod | 34 +++++ libgm2/libm2pim/Makefile.am | 2 + libgm2/libm2pim/Makefile.in | 9 +- 10 files changed, 590 insertions(+), 13 deletions(-) diff --git a/gcc/m2/gm2-libs/LongStorage.def b/gcc/m2/gm2-libs/LongStorage.def new file mode 100644 index 000000000000..fb76e1a84a5b --- /dev/null +++ b/gcc/m2/gm2-libs/LongStorage.def @@ -0,0 +1,78 @@ +(* LongStorage.def provides access to large dynamic memory hunks. + +Copyright (C) 2026 Free Software Foundation, Inc. +Contributed by Gaius Mulley <[email protected]>. + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. *) + +DEFINITION MODULE LongStorage ; + +(* + Title : LongStorage + Author : Gaius Mulley + System : GNU Modula-2 + Date : Fri Oct 9 12:40:43 2026 + Revision : $Version$ + Description: provides allocation and deallocation procedures + to manipulate dynamic memory sizes up to + MAX(LONGCARD). +*) + +FROM SYSTEM IMPORT ADDRESS ; +EXPORT QUALIFIED ALLOCATE, DEALLOCATE, REALLOCATE, Available ; + + +(* + ALLOCATE - attempt to allocate memory from the heap. + NIL is returned in, a, if ALLOCATE fails. +*) + +PROCEDURE ALLOCATE (VAR a: ADDRESS ; Size: LONGCARD) ; + + +(* + DEALLOCATE - return, Size, bytes to the heap. + The variable, a, is set to NIL. +*) + +PROCEDURE DEALLOCATE (VAR a: ADDRESS ; Size: LONGCARD) ; + + +(* + REALLOCATE - attempts to reallocate storage. The address, + a, should either be NIL in which case ALLOCATE + is called, or alternatively it should have already + been initialized by ALLOCATE. The allocated storage + is resized accordingly. +*) + +PROCEDURE REALLOCATE (VAR a: ADDRESS; Size: LONGCARD) ; + + +(* + Available - returns TRUE if Size bytes can be allocated. +*) + +PROCEDURE Available (Size: LONGCARD) : BOOLEAN ; + + +END LongStorage. diff --git a/gcc/m2/gm2-libs/LongStorage.mod b/gcc/m2/gm2-libs/LongStorage.mod new file mode 100644 index 000000000000..944fc43221c4 --- /dev/null +++ b/gcc/m2/gm2-libs/LongStorage.mod @@ -0,0 +1,57 @@ +(* LongStorage.mod provides access to large dynamic memory hunks. + +Copyright (C) 2026 Free Software Foundation, Inc. +Contributed by Gaius Mulley <[email protected]>. + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. *) + +IMPLEMENTATION MODULE LongStorage ; + + +IMPORT LongSysStorage ; + + +PROCEDURE ALLOCATE (VAR a: ADDRESS ; Size: LONGCARD) ; +BEGIN + LongSysStorage.ALLOCATE (a, Size) +END ALLOCATE ; + + +PROCEDURE DEALLOCATE (VAR a: ADDRESS; Size: LONGCARD); +BEGIN + LongSysStorage.DEALLOCATE (a, Size) +END DEALLOCATE ; + + +PROCEDURE REALLOCATE (VAR a: ADDRESS; Size: LONGCARD); +BEGIN + LongSysStorage.REALLOCATE (a, Size) +END REALLOCATE ; + + +PROCEDURE Available (Size: LONGCARD) : BOOLEAN; +BEGIN + RETURN LongSysStorage.Available (Size) +END Available ; + + +END LongStorage. diff --git a/gcc/m2/gm2-libs/LongSysStorage.def b/gcc/m2/gm2-libs/LongSysStorage.def new file mode 100644 index 000000000000..acf5aacf7e93 --- /dev/null +++ b/gcc/m2/gm2-libs/LongSysStorage.def @@ -0,0 +1,87 @@ +(* LongSysStorage.def provides dynamic allocation for the system components. + +Copyright (C) 2026 Free Software Foundation, Inc. +Contributed by Gaius Mulley <[email protected]>. + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. *) + +DEFINITION MODULE LongSysStorage ; + +(* Provides dynamic allocation for the system components. + This allows the application to use the traditional Storage module + which can be handled differently. + ALLOCATE and DEALLOCATE will call M2Diagnostic to adjust the + global tracking of the application heap. *) + +FROM SYSTEM IMPORT ADDRESS ; + + +(* + ALLOCATE - attempt to allocate memory from the heap. + NIL is returned in, a, if ALLOCATE fails. +*) + +PROCEDURE ALLOCATE (VAR a: ADDRESS ; size: LONGCARD) ; + + +(* + DEALLOCATE - return, size, bytes to the heap. + The variable, a, is set to NIL. +*) + +PROCEDURE DEALLOCATE (VAR a: ADDRESS ; size: LONGCARD) ; + + +(* + REALLOCATE - attempts to reallocate storage. The address, + a, should either be NIL in which case ALLOCATE + is called, or alternatively it should have already + been initialized by ALLOCATE. The allocated storage + is resized accordingly. + Note that this procedure does not adjust the + M2Diagnostic.TotalHeap it is expected that the caller + must track the reallocation differences and call + M2Diagnostic.TotalHeapIncr or M2Diagnostic.TotalHeapDecr + as appropriate. +*) + +PROCEDURE REALLOCATE (VAR a: ADDRESS; size: LONGCARD) ; + + +(* + Available - returns TRUE if, size, bytes can be allocated. +*) + +PROCEDURE Available (size: LONGCARD) : BOOLEAN; + + +(* + Init - initializes the heap. + This does nothing on a GNU/Linux system. + But it remains here since it might be used in an + embedded system. +*) + +PROCEDURE Init ; + + +END LongSysStorage. diff --git a/gcc/m2/gm2-libs/LongSysStorage.mod b/gcc/m2/gm2-libs/LongSysStorage.mod new file mode 100644 index 000000000000..77f735d2aa8d --- /dev/null +++ b/gcc/m2/gm2-libs/LongSysStorage.mod @@ -0,0 +1,195 @@ +(* LongSysStorage.mod provides dynamic allocation for the system components. + +Copyright (C) 2026 Free Software Foundation, Inc. +Contributed by Gaius Mulley <[email protected]>. + +This file is part of GNU Modula-2. + +GNU Modula-2 is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3, or (at your option) +any later version. + +GNU Modula-2 is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +Under Section 7 of GPL version 3, you are granted additional +permissions described in the GCC Runtime Library Exception, version +3.1, as published by the Free Software Foundation. + +You should have received a copy of the GNU General Public License and +a copy of the GCC Runtime Library Exception along with this program; +see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +<http://www.gnu.org/licenses/>. *) + +IMPLEMENTATION MODULE LongSysStorage ; + +FROM libc IMPORT malloc, free, realloc, memset, getenv, printf ; +FROM Debug IMPORT Halt ; +FROM SYSTEM IMPORT ADR ; + +IMPORT M2Diagnostic ; + + +CONST + enableDeallocation = TRUE ; + enableZero = TRUE ; + enableTrace = FALSE ; + +VAR + callno: CARDINAL ; + zero, + trace : BOOLEAN ; + + +PROCEDURE ALLOCATE (VAR a: ADDRESS ; size: LONGCARD) ; +BEGIN + a := malloc (size) ; + IF a = NIL + THEN + Halt ('out of memory error', + __FILE__, __FUNCTION__, __LINE__) + END ; + IF enableTrace AND trace + THEN + printf ("<DEBUG-CALL> %d LongSysStorage.ALLOCATE (0x%x, %ld bytes)\n", callno, a, size) ; + printf ("<MEM-ALLOC> %ld %ld\n", a, size); + INC (callno) + END ; + M2Diagnostic.TotalHeapIncrLong (size) +END ALLOCATE ; + + +PROCEDURE DEALLOCATE (VAR a: ADDRESS; size: LONGCARD); +BEGIN + IF enableTrace AND trace + THEN + printf ("<DEBUG-CALL> %d LongSysStorage.DEALLOCATE (0x%x, %ld bytes)\n", callno, a, size) ; + INC (callno) + END ; + IF enableZero AND zero + THEN + IF enableTrace AND trace + THEN + printf (" memset (0x%x, 0, %ld bytes)\n", a, size) + END ; + IF memset (a, 0, size) # a + THEN + Halt ('memset should have returned the first parameter', + __FILE__, __FUNCTION__, __LINE__) + END + END ; + IF enableDeallocation + THEN + IF enableTrace AND trace + THEN + printf (" free (0x%x) %ld bytes\n", a, size) ; + printf ("<MEM-FREE> %ld %d\n", a, size); + END ; + free (a) + END ; + M2Diagnostic.TotalHeapDecrLong (size) ; + a := NIL +END DEALLOCATE ; + + +(* + REALLOCATE - attempts to reallocate storage. The address, + a, should either be NIL in which case ALLOCATE + is called, or alternatively it should have already + been initialized by ALLOCATE. The allocated storage + is resized accordingly. + Note that this procedure does not adjust the + M2Diagnostic.TotalHeap it is expected that the caller + must track the reallocation differences and call + M2Diagnostic.TotalHeapIncr or M2Diagnostic.TotalHeapDecr + as appropriate. +*) + +PROCEDURE REALLOCATE (VAR a: ADDRESS; size: LONGCARD) ; +BEGIN + IF a = NIL + THEN + ALLOCATE (a, size) + ELSE + IF enableTrace AND trace + THEN + printf ("<DEBUG-CALL> %d LongSysStorage.REALLOCATE (0x%x, %ld bytes)\n", + callno, a, size) ; + INC (callno) + END ; + IF enableTrace AND trace + THEN + printf (" realloc (0x%x, %ld bytes) -> ", a, size) ; + printf ("<MEM-FREE> %ld %ld\n", a, size) + END ; + a := realloc (a, size) ; + IF a = NIL + THEN + Halt ('out of memory error', + __FILE__, __FUNCTION__, __LINE__) + END ; + IF enableTrace AND trace + THEN + printf ("<MEM-ALLOC> %ld %d\n", a, size) ; + printf (" 0x%x %ld bytes\n", a, size) + END + END +END REALLOCATE ; + + +PROCEDURE Available (size: LONGCARD) : BOOLEAN; +VAR + a: ADDRESS ; +BEGIN + IF enableTrace AND trace + THEN + printf ("<DEBUG-CALL> %d LongSysStorage.Available (%ld bytes)\n", + callno, size) ; + INC (callno) + END ; + a := malloc (size) ; + IF a = NIL + THEN + IF enableTrace AND trace + THEN + printf (" no\n") + END ; + RETURN FALSE + ELSE + IF enableTrace AND trace + THEN + printf (" yes\n") + END ; + free (a) ; + RETURN TRUE + END +END Available ; + + +(* + Init - initializes the heap. This does nothing on a GNU/Linux system. + But it remains here since it might be used in an embedded system. +*) + +PROCEDURE Init ; +END Init ; + + +BEGIN + callno := 0 ; + IF enableTrace + THEN + trace := getenv (ADR ("M2DEBUG_SYSSTORAGE_trace")) # NIL + ELSE + trace := FALSE + END ; + IF enableZero + THEN + zero := getenv (ADR ("M2DEBUG_SYSSTORAGE_zero")) # NIL + ELSE + zero := FALSE + END +END LongSysStorage. diff --git a/gcc/m2/gm2-libs/M2Diagnostic.def b/gcc/m2/gm2-libs/M2Diagnostic.def index e9b06e17b3f7..5951525a1827 100644 --- a/gcc/m2/gm2-libs/M2Diagnostic.def +++ b/gcc/m2/gm2-libs/M2Diagnostic.def @@ -90,6 +90,14 @@ PROCEDURE InitMemDiagnostic (name, format: ARRAY OF CHAR) : Diagnostic ; PROCEDURE MemIncr (MemDiag: Diagnostic; paramno: CARDINAL; incr: CARDINAL) ; +(* + MemIncrLong - allow the appropriate parameter to be incremented by a LONGCARD + data type. +*) + +PROCEDURE MemIncrLong (MemDiag: Diagnostic; paramno: CARDINAL; incr: LONGCARD) ; + + (* MemDecr - allow the appropriate parameter to be decremented. All parameters are initially set to zero and are stored @@ -99,6 +107,14 @@ PROCEDURE MemIncr (MemDiag: Diagnostic; paramno: CARDINAL; incr: CARDINAL) ; PROCEDURE MemDecr (MemDiag: Diagnostic; paramno: CARDINAL; decr: CARDINAL) ; +(* + MemDecrLong - allow the appropriate parameter to be decremented using a + LONGCARD data type. +*) + +PROCEDURE MemDecrLong (MemDiag: Diagnostic; paramno: CARDINAL; decr: LONGCARD) ; + + (* MemSet - allow the appropriate parameter to be set to value. All parameters are initially set to zero. @@ -107,6 +123,14 @@ PROCEDURE MemDecr (MemDiag: Diagnostic; paramno: CARDINAL; decr: CARDINAL) ; PROCEDURE MemSet (MemDiag: Diagnostic; paramno: CARDINAL; value: CARDINAL) ; +(* + MemSetLong - allow the appropriate parameter to be set to value. + All parameters are initially set to zero. +*) + +PROCEDURE MemSetLong (MemDiag: Diagnostic; paramno: CARDINAL; value: LONGCARD) ; + + (* TotalHeapIncr - increments the total heap used. *) @@ -114,6 +138,13 @@ PROCEDURE MemSet (MemDiag: Diagnostic; paramno: CARDINAL; value: CARDINAL) ; PROCEDURE TotalHeapIncr (incr: CARDINAL) ; +(* + TotalHeapIncrLong - increments the total heap used. +*) + +PROCEDURE TotalHeapIncrLong (incr: LONGCARD) ; + + (* TotalHeapDecr - decrements the total heap used. *) @@ -121,6 +152,13 @@ PROCEDURE TotalHeapIncr (incr: CARDINAL) ; PROCEDURE TotalHeapDecr (incr: CARDINAL) ; +(* + TotalHeapDecrLong - decrements the total heap used. +*) + +PROCEDURE TotalHeapDecrLong (incr: LONGCARD) ; + + (* SetEnable - set the enable flag in Diag to value. *) diff --git a/gcc/m2/gm2-libs/M2Diagnostic.mod b/gcc/m2/gm2-libs/M2Diagnostic.mod index d460da6eb300..d03af8158b8e 100644 --- a/gcc/m2/gm2-libs/M2Diagnostic.mod +++ b/gcc/m2/gm2-libs/M2Diagnostic.mod @@ -326,19 +326,30 @@ END CheckParam ; *) PROCEDURE MemIncr (MemDiag: Diagnostic; paramno: CARDINAL; incr: CARDINAL) ; +BEGIN + MemIncrLong (MemDiag, paramno, VAL (LONGCARD, incr)) +END MemIncr ; + + +(* + MemIncrLong - allow the appropriate parameter to be incremented by a LONGCARD + data type. +*) + +PROCEDURE MemIncrLong (MemDiag: Diagnostic; paramno: CARDINAL; incr: LONGCARD) ; BEGIN IF EnableDiagnostics AND (MemDiag # NIL) THEN CheckParam (paramno) ; CASE MemDiag^.type OF - memdiag: INC (MemDiag^.mdiag.param[paramno], VAL (LONGCARD, incr)) + memdiag: INC (MemDiag^.mdiag.param[paramno], incr) ELSE HALT END END -END MemIncr ; +END MemIncrLong ; (* @@ -348,19 +359,30 @@ END MemIncr ; *) PROCEDURE MemDecr (MemDiag: Diagnostic; paramno: CARDINAL; decr: CARDINAL) ; +BEGIN + MemDecrLong (MemDiag, paramno, VAL (LONGCARD, decr)) +END MemDecr ; + + +(* + MemDecrLong - allow the appropriate parameter to be decremented using a + LONGCARD data type. +*) + +PROCEDURE MemDecrLong (MemDiag: Diagnostic; paramno: CARDINAL; decr: LONGCARD) ; BEGIN IF EnableDiagnostics AND (MemDiag # NIL) THEN CheckParam (paramno) ; CASE MemDiag^.type OF - memdiag: DEC (MemDiag^.mdiag.param[paramno], VAL (LONGCARD, decr)) + memdiag: DEC (MemDiag^.mdiag.param[paramno], decr) ELSE HALT END END -END MemDecr ; +END MemDecrLong ; (* @@ -369,19 +391,30 @@ END MemDecr ; *) PROCEDURE MemSet (MemDiag: Diagnostic; paramno: CARDINAL; value: CARDINAL) ; +BEGIN + MemSetLong (MemDiag, paramno, VAL (LONGCARD, value)) +END MemSet ; + + +(* + MemSetLong - allow the appropriate parameter to be set to value. + All parameters are initially set to zero. +*) + +PROCEDURE MemSetLong (MemDiag: Diagnostic; paramno: CARDINAL; value: LONGCARD) ; BEGIN IF EnableDiagnostics AND (MemDiag # NIL) THEN CheckParam (paramno) ; CASE MemDiag^.type OF - memdiag: MemDiag^.mdiag.param[paramno] := VAL (LONGCARD, value) + memdiag: MemDiag^.mdiag.param[paramno] := value ELSE HALT END END -END MemSet ; +END MemSetLong ; (* @@ -389,12 +422,22 @@ END MemSet ; *) PROCEDURE TotalHeapIncr (incr: CARDINAL) ; +BEGIN + TotalHeapIncrLong (VAL (LONGCARD, incr)) +END TotalHeapIncr ; + + +(* + TotalHeapIncrLong - increments the total heap used. +*) + +PROCEDURE TotalHeapIncrLong (incr: LONGCARD) ; BEGIN IF EnableDiagnostics THEN - TotalHeap := TotalHeap + VAL (LONGCARD, incr) + TotalHeap := TotalHeap + incr END -END TotalHeapIncr ; +END TotalHeapIncrLong ; (* @@ -402,12 +445,22 @@ END TotalHeapIncr ; *) PROCEDURE TotalHeapDecr (incr: CARDINAL) ; +BEGIN + TotalHeapDecrLong (VAL (LONGCARD, incr)) +END TotalHeapDecr ; + + +(* + TotalHeapDecrLong - decrements the total heap used. +*) + +PROCEDURE TotalHeapDecrLong (incr: LONGCARD) ; BEGIN IF EnableDiagnostics THEN - TotalHeap := TotalHeap - VAL (LONGCARD, incr) + TotalHeap := TotalHeap - incr END -END TotalHeapDecr ; +END TotalHeapDecrLong ; (* diff --git a/gcc/testsuite/gm2.dg/pim/pass/largestore.mod b/gcc/testsuite/gm2.dg/pim/pass/largestore.mod new file mode 100644 index 000000000000..eb10c1acb61c --- /dev/null +++ b/gcc/testsuite/gm2.dg/pim/pass/largestore.mod @@ -0,0 +1,30 @@ +(* Test for > 4GB ALLOCATE. *) +(* { dg-do compile { target *-*-* } } *) + +MODULE largestore ; + +FROM LongStorage IMPORT ALLOCATE, DEALLOCATE, Available ; +FROM libc IMPORT printf, exit ; +FROM SYSTEM IMPORT ADDRESS ; + +CONST + GB = 1024 * 1024 * 1024 ; + Amount = 5 * GB ; + +VAR + start: ADDRESS ; +BEGIN + IF Available (Amount) + THEN + printf ("%ld GB available\n", Amount DIV GB) ; + ALLOCATE (start, Amount) ; + IF start = NIL + THEN + printf (" .. but not allocated to this process\n") ; + exit (1) + END ; + DEALLOCATE (start, Amount) + ELSE + printf ("%ld GB unavailable\n", Amount DIV GB) + END +END largestore. diff --git a/gcc/testsuite/gm2.dg/pim/pass/largestore2.mod b/gcc/testsuite/gm2.dg/pim/pass/largestore2.mod new file mode 100644 index 000000000000..671983338889 --- /dev/null +++ b/gcc/testsuite/gm2.dg/pim/pass/largestore2.mod @@ -0,0 +1,34 @@ +(* Test for NEW/DISPOSE with LongStorage. *) +(* { dg-do compile { target *-*-* } } *) + +MODULE largestore2 ; + +FROM LongStorage IMPORT ALLOCATE, DEALLOCATE, Available ; +FROM libc IMPORT printf, exit ; +FROM SYSTEM IMPORT ADDRESS, BYTE ; + +CONST + G = 1024 * 1024 * 1024 ; + Amount = G ; + +TYPE + Content = ARRAY [0..Amount] OF BYTE ; + Buf = POINTER TO Content ; + +VAR + ptr: Buf ; +BEGIN + IF Available (SIZE (Content)) + THEN + printf ("2 GB available\n") ; + NEW (ptr) ; + IF ptr = NIL + THEN + printf (" .. but not allocated to this process\n") ; + exit (1) + END ; + DISPOSE (ptr) + ELSE + printf ("2 GB unavailable\n") + END +END largestore2. diff --git a/libgm2/libm2pim/Makefile.am b/libgm2/libm2pim/Makefile.am index 2f92672558f3..b71197fbaa66 100644 --- a/libgm2/libm2pim/Makefile.am +++ b/libgm2/libm2pim/Makefile.am @@ -112,6 +112,7 @@ M2MODS = ASCII.mod \ TimeString.mod Environment.mod \ FpuIO.mod Debug.mod \ SysStorage.mod Storage.mod \ + LongSysStorage.mod LongStorage.mod \ StdIO.mod SEnvironment.mod \ DynamicStrings.mod SFIO.mod \ SArgs.mod SCmdArgs.mod \ @@ -147,6 +148,7 @@ M2DEFS = Args.def ASCII.def \ IO.def ldtoa.def \ LegacyReal.def libc.def \ libm.def LMathLib0.def \ + LongSysStorage.def LongStorage.def \ M2Dependent.def \ M2Diagnostic.def \ M2EXCEPTION.def \ diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in index 04e60277e71f..48a08eafb1cd 100644 --- a/libgm2/libm2pim/Makefile.in +++ b/libgm2/libm2pim/Makefile.in @@ -165,9 +165,10 @@ LTLIBRARIES = $(toolexeclib_LTLIBRARIES) @BUILD_PIMLIB_TRUE@ Break.lo CmdArgs.lo Scan.lo StrCase.lo \ @BUILD_PIMLIB_TRUE@ FIO.lo StrIO.lo StrLib.lo TimeString.lo \ @BUILD_PIMLIB_TRUE@ Environment.lo FpuIO.lo Debug.lo \ -@BUILD_PIMLIB_TRUE@ SysStorage.lo Storage.lo StdIO.lo \ -@BUILD_PIMLIB_TRUE@ SEnvironment.lo DynamicStrings.lo SFIO.lo \ -@BUILD_PIMLIB_TRUE@ SArgs.lo SCmdArgs.lo PushBackInput.lo \ +@BUILD_PIMLIB_TRUE@ SysStorage.lo Storage.lo LongSysStorage.lo \ +@BUILD_PIMLIB_TRUE@ LongStorage.lo StdIO.lo SEnvironment.lo \ +@BUILD_PIMLIB_TRUE@ DynamicStrings.lo SFIO.lo SArgs.lo \ +@BUILD_PIMLIB_TRUE@ SCmdArgs.lo PushBackInput.lo \ @BUILD_PIMLIB_TRUE@ StringConvert.lo FormatStrings.lo \ @BUILD_PIMLIB_TRUE@ Builtins.lo MathLib0.lo M2EXCEPTION.lo \ @BUILD_PIMLIB_TRUE@ RTExceptions.lo SMathLib0.lo RTint.lo \ @@ -499,6 +500,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_PIMLIB_TRUE@ TimeString.mod Environment.mod \ @BUILD_PIMLIB_TRUE@ FpuIO.mod Debug.mod \ @BUILD_PIMLIB_TRUE@ SysStorage.mod Storage.mod \ +@BUILD_PIMLIB_TRUE@ LongSysStorage.mod LongStorage.mod \ @BUILD_PIMLIB_TRUE@ StdIO.mod SEnvironment.mod \ @BUILD_PIMLIB_TRUE@ DynamicStrings.mod SFIO.mod \ @BUILD_PIMLIB_TRUE@ SArgs.mod SCmdArgs.mod \ @@ -534,6 +536,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) @BUILD_PIMLIB_TRUE@ IO.def ldtoa.def \ @BUILD_PIMLIB_TRUE@ LegacyReal.def libc.def \ @BUILD_PIMLIB_TRUE@ libm.def LMathLib0.def \ +@BUILD_PIMLIB_TRUE@ LongSysStorage.def LongStorage.def \ @BUILD_PIMLIB_TRUE@ M2Dependent.def \ @BUILD_PIMLIB_TRUE@ M2Diagnostic.def \ @BUILD_PIMLIB_TRUE@ M2EXCEPTION.def \
