MagickCore 7.0.10
memory-private.h
Go to the documentation of this file.
1/*
2 Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization
3 dedicated to making software imaging solutions freely available.
4
5 You may not use this file except in compliance with the License.
6 obtain a copy of the License at
7
8 https://imagemagick.org/script/license.php
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15
16 The Wizard's Toolkit private memory methods.
17*/
18#ifndef _WIZARDSTOOLKIT_MEMORY_PRIVATE_H
19#define _WIZARDSTOOLKIT_MEMORY_PRIVATE_H
20
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24#if defined(__powerpc__)
25# define CACHE_LINE_SIZE 128
26#else
27# define CACHE_LINE_SIZE 64
28#endif
29
30#define CacheAlign(size) ((size) < CACHE_LINE_SIZE ? CACHE_LINE_SIZE : (size))
31
32#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6))
33#if !defined(__ICC)
34#define WizardAssumeAligned(address) \
35 __builtin_assume_aligned((address),CACHE_LINE_SIZE)
36#else
37#define WizardAssumeAligned(address) (address)
38#endif
39#else
40#define WizardAssumeAligned(address) (address)
41#endif
42
43static inline size_t OverAllocateMemory(const size_t length)
44{
45 size_t
46 extent;
47
48 /*
49 Over allocate memory, typically used when concatentating strings.
50 */
51 extent=length;
52 if (extent < 131072)
53 for (extent=256; extent < length; extent*=2);
54 return(extent);
55}
56
57#if defined(__cplusplus) || defined(c_plusplus)
58}
59#endif
60
61#endif
static size_t OverAllocateMemory(const size_t length)