libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / m2 / mc-boot / GMemUtils.cc
blob1d9feed27d60532c14ff592b7415c58d05dad577
1 /* do not edit automatically generated by mc from MemUtils. */
2 /* MemUtils.mod provides some basic memory utilities.
4 Copyright (C) 2001-2024 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
7 This file is part of GNU Modula-2.
9 GNU Modula-2 is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3, or (at your option)
12 any later version.
14 GNU Modula-2 is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 General Public License for more details.
19 Under Section 7 of GPL version 3, you are granted additional
20 permissions described in the GCC Runtime Library Exception, version
21 3.1, as published by the Free Software Foundation.
23 You should have received a copy of the GNU General Public License and
24 a copy of the GCC Runtime Library Exception along with this program;
25 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
26 <http://www.gnu.org/licenses/>. */
28 #include "config.h"
29 #include "system.h"
30 #include <stdbool.h>
31 # if !defined (PROC_D)
32 # define PROC_D
33 typedef void (*PROC_t) (void);
34 typedef struct { PROC_t proc; } PROC;
35 # endif
37 #define _MemUtils_C
39 #include "GMemUtils.h"
40 # include "GSYSTEM.h"
44 MemCopy - copys a region of memory to the required destination.
47 extern "C" void MemUtils_MemCopy (void * from, unsigned int length, void * to);
50 MemZero - sets a region of memory: a..a+length to zero.
53 extern "C" void MemUtils_MemZero (void * a, unsigned int length);
57 MemCopy - copys a region of memory to the required destination.
60 extern "C" void MemUtils_MemCopy (void * from, unsigned int length, void * to)
62 typedef unsigned int *MemCopy__T1;
64 typedef unsigned char *MemCopy__T2;
66 MemCopy__T1 pwb;
67 MemCopy__T1 pwa;
68 MemCopy__T2 pbb;
69 MemCopy__T2 pba;
71 while (length >= sizeof (unsigned int ))
73 pwa = static_cast<MemCopy__T1> (from);
74 pwb = static_cast<MemCopy__T1> (to);
75 (*pwb) = (*pwa);
76 from = reinterpret_cast<void *> (reinterpret_cast<char *> (from)+sizeof (unsigned int ));
77 to = reinterpret_cast<void *> (reinterpret_cast<char *> (to)+sizeof (unsigned int ));
78 length -= sizeof (unsigned int );
80 while (length > 0)
82 pba = static_cast<MemCopy__T2> (from);
83 pbb = static_cast<MemCopy__T2> (to);
84 (*pbb) = (*pba);
85 from = reinterpret_cast<void *> (reinterpret_cast<char *> (from)+sizeof (unsigned char ));
86 to = reinterpret_cast<void *> (reinterpret_cast<char *> (to)+sizeof (unsigned char ));
87 length -= sizeof (unsigned char );
93 MemZero - sets a region of memory: a..a+length to zero.
96 extern "C" void MemUtils_MemZero (void * a, unsigned int length)
98 typedef unsigned int *MemZero__T3;
100 typedef unsigned char *MemZero__T4;
102 MemZero__T3 pwa;
103 MemZero__T4 pba;
105 pwa = static_cast<MemZero__T3> (a);
106 while (length >= sizeof (unsigned int ))
108 (*pwa) = (unsigned int ) (0);
109 pwa += sizeof (unsigned int );
110 length -= sizeof (unsigned int );
112 pba = static_cast<MemZero__T4> ((void *) (pwa));
113 while (length >= sizeof (unsigned char ))
115 (*pba) = (unsigned char ) (0);
116 pba += sizeof (unsigned char );
117 length -= sizeof (unsigned char );
121 extern "C" void _M2_MemUtils_init (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])
125 extern "C" void _M2_MemUtils_fini (__attribute__((unused)) int argc, __attribute__((unused)) char *argv[], __attribute__((unused)) char *envp[])