27#if defined(__GNUC__) && __GNUC__ >= 7
28#pragma GCC diagnostic ignored "-Walloc-size-larger-than=9223372036854775807"
44 if ((alignment & (alignment - 1)) == 0)
45 ok(
mem !=
NULL,
"_aligned_malloc(%d, %d) failed\n",
size, alignment);
47 ok(
mem ==
NULL,
"_aligned_malloc(%d, %d) should have failed\n",
size, alignment);
52 "_aligned_malloc(%d, %d) not aligned: %p\n",
size, alignment,
mem);
56 saved = *(
void **)((
DWORD_PTR)((
char *)
mem -
sizeof(
void *)) & ~(
sizeof(
void *) - 1));
57 trace(
"_aligned_malloc(%3d, %3d) returns %p, saved = %p\n",
size, alignment,
mem, saved );
71 if ((alignment & (alignment - 1)) == 0)
77 ok(
mem ==
NULL,
"_aligned_offset_malloc(%d, %d, %d) should have failed\n",
size, alignment,
offset);
82 "_aligned_offset_malloc(%d, %d, %d) not aligned: %p\n",
size, alignment,
offset,
mem);
86 saved = *(
void **)((
DWORD_PTR)((
char *)
mem -
sizeof(
void *)) & ~(
sizeof(
void *) - 1));
87 trace(
"_aligned_offset_malloc(%3d, %3d, %3d) returns %p, saved = %p\n",
98 void *
mem, *mem1, *mem2;
102 if ((alignment & (alignment - 1)) == 0)
103 ok(
mem !=
NULL,
"_aligned_malloc(%d, %d) failed\n", size1, alignment);
105 ok(
mem ==
NULL,
"_aligned_malloc(%d, %d) should have failed\n", size1, alignment);
113 for (
i = 0;
i < size1;
i++)
114 ((
char *)
mem)[
i] =
i + 1;
119 "_aligned_malloc(%d, %d) not aligned: %p\n", size1, alignment,
mem);
123 saved = *(
void **)((
DWORD_PTR)((
char *)
mem -
sizeof(
void *)) & ~(
sizeof(
void *) - 1));
124 trace(
"_aligned_malloc(%3d, %3d) returns %p, saved = %p\n", size1, alignment,
mem, saved);
129 ok(mem2 !=
NULL,
"_aligned_realloc(%p, %d, %d) failed\n",
mem, size2, alignment);
133 ok(((
DWORD_PTR)mem2 & (alignment ? alignment - 1 : 0)) == 0,
134 "_aligned_realloc(%p, %d, %d) not aligned: %p\n",
mem, size2, alignment, mem2);
138 saved = *(
void **)((
DWORD_PTR)((
char *)mem2 -
sizeof(
void *)) & ~(
sizeof(
void *) - 1));
139 trace(
"_aligned_realloc(%p, %3d, %3d) returns %p, saved = %p\n",
140 mem, size2, alignment, mem2, saved);
144 ok(
memcmp(mem2, mem1,
min(size1, size2))==0,
"_aligned_realloc(%p, %d, %d) has different data\n",
mem, size2, alignment);
148 for (
i = 0;
i <
min(size1, size2);
i++)
150 if (((
char *)mem2)[
i] != ((
char *)mem1)[
i])
151 trace(
"%d: %02x != %02x\n",
i, ((
char *)mem2)[
i] & 0xff, ((
char *)mem1)[
i] & 0xff);
155 p_aligned_free(mem2);
168 unsigned int alignment,
unsigned int offset)
170 void *
mem, *mem1, *mem2;
174 if ((alignment & (alignment - 1)) == 0)
175 ok(
mem !=
NULL,
"_aligned_offset_malloc(%d, %d, %d) failed\n", size1, alignment,
offset);
177 ok(
mem ==
NULL,
"_aligned_offset_malloc(%d, %d, %d) should have failed\n", size1, alignment,
offset);
185 for (
i = 0;
i < size1;
i++)
186 ((
char *)
mem)[
i] =
i + 1;
191 "_aligned_offset_malloc(%d, %d, %d) not aligned: %p\n", size1, alignment,
offset,
mem);
195 saved = *(
void **)((
DWORD_PTR)((
char *)
mem -
sizeof(
void *)) & ~(
sizeof(
void *) - 1));
196 trace(
"_aligned_offset_malloc(%3d, %3d, %3d) returns %p, saved = %p\n",
202 ok(mem2 !=
NULL,
"_aligned_offset_realloc(%p, %d, %d, %d) failed\n",
mem, size2, alignment,
offset);
207 "_aligned_offset_realloc(%p, %d, %d, %d) not aligned: %p\n",
mem, size2, alignment,
offset, mem2);
211 saved = *(
void **)((
DWORD_PTR)((
char *)mem2 -
sizeof(
void *)) & ~(
sizeof(
void *) - 1));
212 trace(
"_aligned_offset_realloc(%p, %3d, %3d, %3d) returns %p, saved = %p\n",
213 mem, size2, alignment,
offset, mem2, saved);
217 ok(
memcmp(mem2, mem1,
min(size1, size2))==0,
"_aligned_offset_realloc(%p, %d, %d, %d) has different data\n",
mem, size2, alignment,
offset);
221 for (
i = 0;
i <
min(size1, size2);
i++)
223 if (((
char *)mem2)[
i] != ((
char *)mem1)[
i])
224 trace(
"%d: %02x != %02x\n",
i, ((
char *)mem2)[
i] & 0xff, ((
char *)mem1)[
i] & 0xff);
228 p_aligned_free(mem2);
230 ok(
errno ==
EINVAL,
"_aligned_offset_realloc(%p, %d, %d, %d) errno: %d != %d\n",
mem, size2, alignment,
offset,
errno,
EINVAL);
255 skip(
"aligned memory tests skipped\n");
427 if(
sizeof(
void*) == 8) {
438 ok(threshold == 16,
"threshold = %d\n", threshold);
442 ok(threshold == 16,
"threshold = %d\n", threshold);
446 ok(threshold == 1008,
"threshold = %d\n", threshold);
460 ok(threshold == 0,
"threshold = %d\n", threshold);
468 void *(
__cdecl *p_calloc)(
size_t,
size_t);
473 ptr = p_calloc(1, 0);
477 ptr = p_calloc(0, 0);
481 ptr = p_calloc(0, 1);
486 ptr = p_calloc(~(
size_t)0 / 2, ~(
size_t)0 / 2);
497 ok(
mem !=
NULL,
"memory not allocated for size 0\n");
501 ok(
mem !=
NULL,
"memory not allocated\n");
504 ok(
mem !=
NULL,
"memory not reallocated\n");
510 ok(
mem !=
NULL,
"memory not (re)allocated for size 0\n");
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define GetProcAddress(x, y)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_CRTIMP int __cdecl _set_sbh_threshold(_In_ size_t _NewValue)
_Check_return_ _CRTIMP size_t __cdecl _get_sbh_threshold(void)
#define memcpy(s1, s2, n)
static void test_aligned_malloc(unsigned int size, unsigned int alignment)
static void test_aligned_offset_realloc(unsigned int size1, unsigned int size2, unsigned int alignment, unsigned int offset)
static void *__cdecl * p_aligned_offset_realloc(void *, size_t, size_t, size_t)
static void test_calloc(void)
static void *__cdecl * p_aligned_offset_malloc(size_t, size_t, size_t)
static void *__cdecl * p_aligned_realloc(void *, size_t, size_t)
static void test_aligned_realloc(unsigned int size1, unsigned int size2, unsigned int alignment)
static void test_aligned(void)
static void *__cdecl * p_aligned_malloc(size_t, size_t)
static void test_sbheap(void)
static void test_aligned_offset_malloc(unsigned int size, unsigned int alignment, unsigned int offset)
unsigned __int3264 UINT_PTR