1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-25 23:10:47 -08:00
emacs/mps/test/function/26.c
Gareth Rees fd3136bb30 Fix mmqa function test cases so that they run on windows. in detail:
1. On w3i6mv, int and long are 32 bits, so these types can't be used to hold a size_t or an mps_word_t. See 26.c, 38.c, 47.c, 66.c, 123.c, 136.c, 164.c, 165.c, 200.c, 203.c, 204.c, 205.c, 206.c, 207.c, 215.c, 223.c.
2. The Windows command line doesn't cope with parentheses. See 170.c.
3. The natural platform alignment is 16 bytes on w3i6mv, so allocations into pools using the default alignment need to be rounded up. See 21.c, 22.c, 203.c, 204.c, 205.c.
4. Microsoft Visual C/C++ is fussy about signed/unsigned comparison. See 226.c.
5. windows.h defines a SIZE macro so you can't use it as a parameter. See 232.c.

Copied from Perforce
 Change: 191569
 ServerID: perforce.ravenbrook.com
2016-04-22 15:44:58 +01:00

63 lines
1.1 KiB
C

/*
TEST_HEADER
id = $Id$
summary = try to allocate as large an object as will succeed
language = c
link = testlib.o
OUTPUT_SPEC
maxsize > 100000000
END_HEADER
*/
#include "testlib.h"
#include "mpscmv.h"
mps_arena_t arena;
mps_pool_t pool;
mps_addr_t q;
static mps_res_t trysize(size_t try) {
mps_res_t res;
die(mps_pool_create(&pool, arena, mps_class_mv(),
(size_t)(1024*32), (size_t)(1024*16), (size_t)(1024*256)),
"pool_create");
comment("Trying %x", try);
res = mps_alloc(&q, pool, try);
mps_pool_destroy(pool);
comment("%s", err_text(res));
return res;
}
static void test(void) {
size_t inf, sup, try;
die(mps_arena_create(&arena, mps_arena_class_vm(), mmqaArenaSIZE), "create");
inf = 0;
sup = 1024*1024*1000; /* i.e. 1 gigabyte */
while (sup-inf > 1) {
try = inf + (sup-inf)/2;
if (trysize(try) == MPS_RES_OK) {
inf = try;
} else {
sup = try;
}
}
for (try = inf-4; try < inf+4; try++)
(void) trysize(try);
report("maxsize", "%lu", (unsigned long) inf);
}
int main(void) {
easy_tramp(test);
pass();
return 0;
}