]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/gm2/isolib/run/pass/testmem.mod
Merge modula-2 front end onto gcc.
[thirdparty/gcc.git] / gcc / testsuite / gm2 / isolib / run / pass / testmem.mod
1 (* Copyright (C) 2011 Free Software Foundation, Inc. *)
2 (* This file is part of GNU Modula-2.
3
4 GNU Modula-2 is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 3, or (at your option) any later
7 version.
8
9 GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13
14 You should have received a copy of the GNU General Public License along
15 with gm2; see the file COPYING. If not, write to the Free Software
16 Foundation, 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA. *)
18
19 MODULE testmem ;
20
21 FROM MemStream IMPORT OpenRead, OpenWrite, Close ;
22 FROM ChanConsts IMPORT FlagSet, OpenResults, raw, write, read ;
23 FROM IOChan IMPORT ChanId ;
24 FROM SYSTEM IMPORT ADDRESS ;
25 FROM libc IMPORT printf ;
26
27 IMPORT RawIO ;
28
29 CONST
30 Amount = 1000 ;
31
32 VAR
33 fd : ChanId ;
34 res : OpenResults ;
35 start : ADDRESS ;
36 length: CARDINAL ;
37 used : CARDINAL ;
38 i,
39 value : CARDINAL ;
40 BEGIN
41 OpenWrite (fd, raw+write, res, start, length, used, FALSE) ;
42 IF res=opened
43 THEN
44 FOR i := 1 TO Amount DO
45 RawIO.Write (fd, i)
46 END ;
47 Close(fd) ;
48 printf ("buffer at %p has length 0x%x bytes and 0x%x are used\n",
49 start, length, used);
50 IF used#SIZE(CARDINAL)*Amount
51 THEN
52 HALT
53 END ;
54 OpenRead (fd, raw+read, res, start, length, TRUE) ;
55 FOR i := 1 TO Amount DO
56 RawIO.Read (fd, value) ;
57 IF i#value
58 THEN
59 HALT
60 END
61 END ;
62 printf ("read the contents of the complete buffer successfully");
63 ELSE
64 HALT
65 END
66 END testmem.