MagickCore 6.9.11-60
Convert, Edit, Or Compose Bitmap Images
memory-private.h
Go to the documentation of this file.
1/*
2 Copyright 1999-2021 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. You may
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 MagickCore private memory methods.
17*/
18#ifndef MAGICKCORE_MEMORY_PRIVATE_H
19#define MAGICKCORE_MEMORY_PRIVATE_H
20
22#include <stdint.h>
23
24#if defined(__cplusplus) || defined(c_plusplus)
25extern "C" {
26#endif
27
28#if defined(__powerpc__)
29# define CACHE_LINE_SIZE (16 * MAGICKCORE_SIZEOF_VOID_P)
30#else
31# define CACHE_LINE_SIZE (8 * MAGICKCORE_SIZEOF_VOID_P)
32#endif
33
34#define CACHE_ALIGNED(n) MAGICKCORE_ALIGN_UP(n,CACHE_LINE_SIZE)
35
36#if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 6))
37#if !defined(__ICC)
38#define MagickAssumeAligned(address) \
39 __builtin_assume_aligned((address),CACHE_LINE_SIZE)
40#else
41#define MagickAssumeAligned(address) (address)
42#endif
43#else
44#define MagickAssumeAligned(address) (address)
45#endif
46
47static inline MagickBooleanType HeapOverflowCheckAdd(const size_t size,
48 const size_t increment)
49{
50 if (size > (SIZE_MAX-increment))
51 {
52 errno=ENOMEM;
53 return(MagickTrue);
54 }
55 return(MagickFalse);
56}
57
58extern MagickPrivate void
62
63#if defined(__cplusplus) || defined(c_plusplus)
64}
65#endif
66
67#endif
size_t MagickSizeType
Definition: magick-type.h:140
MagickBooleanType
Definition: magick-type.h:203
@ MagickFalse
Definition: magick-type.h:204
@ MagickTrue
Definition: magick-type.h:205
MagickPrivate void ResetVirtualAnonymousMemory(void)
static MagickBooleanType HeapOverflowCheckAdd(const size_t size, const size_t increment)
Definition: memory-private.h:47
MagickPrivate void SetMaxMemoryRequest(const MagickSizeType)
Definition: memory.c:1581
MagickPrivate void ResetMaxMemoryRequest(void)
#define MagickPrivate
Definition: method-attribute.h:81