NEURON
memory.cpp
Go to the documentation of this file.
1 #ifdef HAVE_CONFIG_H
2 #include <../../nrnconf.h>
3 #endif
4 /*
5  * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University
6  * Copyright (c) 1991 Silicon Graphics, Inc.
7  *
8  * Permission to use, copy, modify, distribute, and sell this software and
9  * its documentation for any purpose is hereby granted without fee, provided
10  * that (i) the above copyright notices and this permission notice appear in
11  * all copies of the software and related documentation, and (ii) the names of
12  * Stanford and Silicon Graphics may not be used in any advertising or
13  * publicity relating to the software without the specific, prior written
14  * permission of Stanford and Silicon Graphics.
15  *
16  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
18  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR
21  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
22  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
24  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25  * OF THIS SOFTWARE.
26  */
27 
28 #include <OS/memory.h>
29 #if defined(WIN32) || MAC
30 #define STDC_HEADERS 1
31 #else
32 #include <unistd.h>
33 #endif
34 #include <string.h>
35 
36 void Memory::copy(const void* from, void* to, unsigned int nbytes) {
37 #if MAC
38  BlockMove(from, to, nbytes);
39 #elif defined(STDC_HEADERS) // ANSI C memmove and memset:
40  memmove(to, from, size_t(nbytes));
41 #elif defined(HAVE_BCOPY)
42  bcopy(from, to, nbytes);
43 #else
44 #error "Neither bcopy nor mmove is defined."
45 #endif
46 }
47 
48 int Memory::compare(const void* b1, const void* b2, unsigned int nbytes) {
49  return memcmp(b1, b2, nbytes) != 0;
50 }
51 
52 void Memory::zero(void* b, unsigned int nbytes) {
53  memset(b, 0, size_t(nbytes));
54 }
static int compare(const void *, const void *, unsigned int nbytes)
Definition: memory.cpp:48
static void zero(void *, unsigned int nbytes)
Definition: memory.cpp:52
static void copy(const void *from, void *to, unsigned int nbytes)
Definition: memory.cpp:36