/* do not edit automatically generated by mc from MemUtils. */ /* MemUtils.mod provides some basic memory utilities. Copyright (C) 2001-2023 Free Software Foundation, Inc. Contributed by Gaius Mulley . 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 . */ #include "config.h" #include "system.h" #include # if !defined (PROC_D) # define PROC_D typedef void (*PROC_t) (void); typedef struct { PROC_t proc; } PROC; # endif #define _MemUtils_H #define _MemUtils_C # include "GSYSTEM.h" /* MemCopy - copys a region of memory to the required destination. */ extern "C" void MemUtils_MemCopy (void * from, unsigned int length, void * to); /* MemZero - sets a region of memory: a..a+length to zero. */ extern "C" void MemUtils_MemZero (void * a, unsigned int length); /* MemCopy - copys a region of memory to the required destination. */ extern "C" void MemUtils_MemCopy (void * from, unsigned int length, void * to) { typedef unsigned int *MemCopy__T1; typedef unsigned char *MemCopy__T2; MemCopy__T1 pwb; MemCopy__T1 pwa; MemCopy__T2 pbb; MemCopy__T2 pba; while (length >= sizeof (unsigned int )) { pwa = static_cast (from); pwb = static_cast (to); (*pwb) = (*pwa); from = reinterpret_cast (reinterpret_cast (from)+sizeof (unsigned int )); to = reinterpret_cast (reinterpret_cast (to)+sizeof (unsigned int )); length -= sizeof (unsigned int ); } while (length > 0) { pba = static_cast (from); pbb = static_cast (to); (*pbb) = (*pba); from = reinterpret_cast (reinterpret_cast (from)+sizeof (unsigned char )); to = reinterpret_cast (reinterpret_cast (to)+sizeof (unsigned char )); length -= sizeof (unsigned char ); } } /* MemZero - sets a region of memory: a..a+length to zero. */ extern "C" void MemUtils_MemZero (void * a, unsigned int length) { typedef unsigned int *MemZero__T3; typedef unsigned char *MemZero__T4; MemZero__T3 pwa; MemZero__T4 pba; pwa = static_cast (a); while (length >= sizeof (unsigned int )) { (*pwa) = (unsigned int ) (0); pwa += sizeof (unsigned int ); length -= sizeof (unsigned int ); } pba = static_cast ((void *) (pwa)); while (length >= sizeof (unsigned char )) { (*pba) = (unsigned char ) (0); pba += sizeof (unsigned char ); length -= sizeof (unsigned char ); } } extern "C" void _M2_MemUtils_init (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) { } extern "C" void _M2_MemUtils_fini (__attribute__((unused)) int argc,__attribute__((unused)) char *argv[],__attribute__((unused)) char *envp[]) { }