diff options
author | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2011-12-30 10:45:13 +0000 |
---|---|---|
committer | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2011-12-30 10:45:13 +0000 |
commit | aa7b5a64b7c920b133666189450c815165b3c6d6 (patch) | |
tree | efce5c8f88d301313973112e0d27be2d88df7c72 /mcon/U/d_bcopy.U | |
parent | 4af44e12b2d1094c62854478815ece518ce3b300 (diff) |
Complexify code testing for bcopy() to avoid gcc optimizing it away.
git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@110 2592e710-e01b-42a5-8df0-11608a6cc53d
Diffstat (limited to 'mcon/U/d_bcopy.U')
-rw-r--r-- | mcon/U/d_bcopy.U | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/mcon/U/d_bcopy.U b/mcon/U/d_bcopy.U index 2daad18..60b8bea 100644 --- a/mcon/U/d_bcopy.U +++ b/mcon/U/d_bcopy.U @@ -39,13 +39,27 @@ ?M:. ?LINT:set d_bcopy : see if bcopy exists +?X: Test is over-complex to avoid gcc optimizing bcopy() away. $cat >try.c <<EOC #include <strings.h> +static void +init_data(char *a, unsigned len) +{ + unsigned i; + for (i = 0; i < len; i++) + a[i] = i * 2 + 1; +} +static void +recopy_data(char *src, char *dst, unsigned len) +{ + bcopy(&src[3], &dst[0], len - 3); +} int main(void) { - static int src, dst; - bcopy(&src, &dst, sizeof(dst)); - return 0; + static char src[20], dst[20]; + init_data(src, sizeof src); + recopy_data(src, dst, sizeof src); + return dst[0] + dst[1]; } EOC cyn=bcopy |