diff options
author | Ralf Corsepius <ralf.corsepius@rtems.org> | 2009-10-22 05:07:25 +0000 |
---|---|---|
committer | Ralf Corsepius <ralf.corsepius@rtems.org> | 2009-10-22 05:07:25 +0000 |
commit | 2334ea19ae85cab636b0ae035661e49526cac145 (patch) | |
tree | de765afa88bc73f7c36d625a79b09cf6dcc85c4a | |
parent | Add cast to uint32_t to allow 16bit shift on 16bit-int targets. (diff) | |
download | rtems-2334ea19ae85cab636b0ae035661e49526cac145.tar.bz2 |
Add HAVE_CONFIG_H guard.
Include <limits.h>. Shift pid_t's by (sizeof(pid_t)*CHAR_BIT)>>1
instead of hard-coded 16 to permit building on non 16bit-int
targets.
-rw-r--r-- | cpukit/libmisc/uuid/gen_uuid.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cpukit/libmisc/uuid/gen_uuid.c b/cpukit/libmisc/uuid/gen_uuid.c index b0219059ec..1d0aac7ec6 100644 --- a/cpukit/libmisc/uuid/gen_uuid.c +++ b/cpukit/libmisc/uuid/gen_uuid.c @@ -32,7 +32,9 @@ * %End-Header% */ +#if HAVE_CONFIG_H #include "config.h" +#endif /* * Force inclusion of SVID stuff since we need it if we're compiling in @@ -46,6 +48,7 @@ #define UUID MYUUID #endif #include <stdio.h> +#include <limits.h> /* for CHAR_BIT */ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -153,7 +156,7 @@ static int get_random_fd(void) fcntl(fd, F_SETFD, i | FD_CLOEXEC); } #endif - srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); + srand((getpid() << ((sizeof(pid_t)*CHAR_BIT)>>1)) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); #ifdef DO_JRAND_MIX jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF); jrand_seed[1] = getppid() ^ (tv.tv_usec & 0xFFFF); |