diff options
author | Eric Wong <e@80x24.org> | 2022-11-15 19:33:36 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2022-11-16 09:25:10 +0000 |
commit | f9f30aad253c6a5d44830a25d82b275a696da3e5 (patch) | |
tree | e326b8aeb5bccae5aeeca5912d47a1c62217643a | |
parent | ad099a42014469ed4369613f9f179f433e6b61b2 (diff) | |
download | mwrap-f9f30aad253c6a5d44830a25d82b275a696da3e5.tar.gz |
These aliases aren't necessary for modern glibc, at least, but they also don't hurt. This quiets an old warning about cfree.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Mwrap.xs | 4 | ||||
-rw-r--r-- | t/mwrap.t | 31 |
3 files changed, 35 insertions, 1 deletions
@@ -9,3 +9,4 @@ /blib /pm_to_blib /config.mak +/_Inline @@ -542,8 +542,10 @@ int posix_memalign(void **p, size_t alignment, size_t size) return internal_memalign(p, alignment, size, RETURN_ADDRESS(0)); } +/* these aliases aren't needed for glibc, not sure about other libcs... */ void *aligned_alloc(size_t, size_t) __attribute__((alias("memalign"))); -void cfree(void *) __attribute__((alias("free"))); +void cfree(void *) __attribute__((__nothrow__)) + __attribute__((__leaf__)) __attribute__((alias("free"))); void *valloc(size_t size) { @@ -141,6 +141,37 @@ diag slurp($out); is(Devel::Mwrap::quiet(1), 0, 'was not quiet, before'); is(Devel::Mwrap::quiet(0), 1, 'was quiet, before'); +SKIP: { + eval { require Inline::C } or skip 'Inline::C not available', 1; + $ENV{TEST_ALIASES} or skip 'TEST_ALIASES unset', 1; + my $c_src = <<'EOM'; +#include <stdlib.h> +void cfree(void *); /* lold glibc version */ +int test_aliases() +{ + size_t i; + void *p; + for (i = 0; i < 100; i++) { + if (i % 3 == 0) + p = aligned_alloc(64, i); + else + p = malloc(i); + if (i % 2 == 0) + cfree(p); + else + free(p); + } + return 3; +} +EOM + eval <<'EOM'; +use Inline C => $c_src, BUILD_NOISY => 1 +EOM + BAIL_OUT "cannot build $@" if $@; + is(test_aliases(), 3, + 'aligned_alloc + cfree function ran w/o crashing'); +}; + done_testing(); sub slurp { |