summaryrefslogtreecommitdiff
path: root/test/testrmm.c
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2004-07-07 17:01:13 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2004-07-07 17:01:13 +0000
commit72cdb463c5588a89b2766174e18ec6d2e3d18dfb (patch)
tree185d28f3586e860798f56d90dae083f750650003 /test/testrmm.c
parentdd11748d12b5455f1dd698039b22a64bcba01dc7 (diff)
downloadlibapr-util-72cdb463c5588a89b2766174e18ec6d2e3d18dfb.tar.gz
* misc/apr_rmm.c: Ensure allocated blocks use default address
alignment by using aligned structure sizes throughout. * test/testrmm.c (test_rmm): Check for address alignment. PR: 29873 git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@59090 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/testrmm.c')
-rw-r--r--test/testrmm.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/testrmm.c b/test/testrmm.c
index c4dc989f..8203be16 100644
--- a/test/testrmm.c
+++ b/test/testrmm.c
@@ -51,7 +51,7 @@ static apr_status_t test_rmm(apr_pool_t *parpool)
}
/* We're going to want 10 blocks of data from our target rmm. */
- size = SHARED_SIZE + apr_rmm_overhead_get(FRAG_COUNT);
+ size = SHARED_SIZE + apr_rmm_overhead_get(FRAG_COUNT + 1);
printf("Creating anonymous shared memory (%"
APR_SIZE_T_FMT " bytes).....", size);
rv = apr_shm_create(&shm, size, NULL, pool);
@@ -87,6 +87,24 @@ static apr_status_t test_rmm(apr_pool_t *parpool)
else {
return APR_EGENERAL;
}
+
+ printf("Checking each fragment for address alignment.....");
+ for (i = 0; i < FRAG_COUNT; i++) {
+ char *c = apr_rmm_addr_get(rmm, off[i]);
+ apr_size_t sc = (apr_size_t)c;
+
+ if (off[i] == 0) {
+ printf("allocation failed for offset %d\n", i);
+ return APR_ENOMEM;
+ }
+
+ if (sc & 7) {
+ printf("Bad alignment for fragment %d; %p not %p!\n",
+ i, c, (void *)APR_ALIGN_DEFAULT((apr_size_t)c));
+ return APR_EGENERAL;
+ }
+ }
+ fprintf(stdout, "OK\n");
printf("Setting each fragment to a unique value..........");
for (i = 0; i < FRAG_COUNT; i++) {