Implement malloc_vsnprintf().

Implement malloc_vsnprintf() (a subset of vsnprintf(3)) as well as
several other printing functions based on it, so that formatted printing
can be relied upon without concern for inducing a dependency on floating
point runtime support.  Replace malloc_write() calls with
malloc_*printf() where doing so simplifies the code.

Add name mangling for library-private symbols in the data and BSS
sections.  Adjust CONF_HANDLE_*() macros in malloc_conf_init() to expose
all opt_* variable use to cpp so that proper mangling occurs.
This commit is contained in:
Jason Evans
2012-03-06 14:57:45 -08:00
parent 4507f34628
commit d81e4bdd5c
17 changed files with 958 additions and 570 deletions

View File

@@ -77,14 +77,14 @@ main(void)
r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
fprintf(stderr,
"Expected error for nallocm(&nsz, %zu, 0x%x)\n",
"Expected error for nallocm(&nsz, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
rsz = 0;
r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
fprintf(stderr,
"Expected error for allocm(&p, %zu, 0x%x)\n",
"Expected error for allocm(&p, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
if (nsz != rsz)
@@ -105,7 +105,7 @@ main(void)
r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
fprintf(stderr,
"Expected error for allocm(&p, %zu, 0x%x)\n",
"Expected error for allocm(&p, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
@@ -119,14 +119,14 @@ main(void)
r = nallocm(&nsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
fprintf(stderr,
"Expected error for nallocm(&nsz, %zu, 0x%x)\n",
"Expected error for nallocm(&nsz, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
rsz = 0;
r = allocm(&p, &rsz, sz, ALLOCM_ALIGN(alignment));
if (r == ALLOCM_SUCCESS) {
fprintf(stderr,
"Expected error for allocm(&p, %zu, 0x%x)\n",
"Expected error for allocm(&p, %zu, %#x)\n",
sz, ALLOCM_ALIGN(alignment));
}
if (nsz != rsz)
@@ -150,7 +150,7 @@ main(void)
if (r != ALLOCM_SUCCESS) {
fprintf(stderr,
"nallocm() error for size %zu"
" (0x%zx): %d\n",
" (%#zx): %d\n",
sz, sz, r);
exit(1);
}
@@ -160,7 +160,7 @@ main(void)
if (r != ALLOCM_SUCCESS) {
fprintf(stderr,
"allocm() error for size %zu"
" (0x%zx): %d\n",
" (%#zx): %d\n",
sz, sz, r);
exit(1);
}

View File

@@ -100,7 +100,7 @@ main(void)
alignment, size);
if (err) {
fprintf(stderr,
"Error for size %zu (0x%zx): %s\n",
"Error for size %zu (%#zx): %s\n",
size, size, strerror(err));
exit(1);
}