diff options
author | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-02-13 03:07:11 +0100 |
---|---|---|
committer | Suren A. Chilingaryan <csa@dside.dyndns.org> | 2011-02-13 03:07:11 +0100 |
commit | b72e8567723c30f0e5a83675743e9380c48e5d55 (patch) | |
tree | f0dc052508543771fca08c358836507770864249 /tools.c | |
download | pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.tar.gz pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.tar.bz2 pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.tar.xz pcitool-b72e8567723c30f0e5a83675743e9380c48e5d55.zip |
Initial import
Diffstat (limited to 'tools.c')
-rw-r--r-- | tools.c | 43 |
1 files changed, 43 insertions, 0 deletions
@@ -0,0 +1,43 @@ +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <stdint.h> + +void *memcpy8(void * dst, void const * src, size_t len) { + int i; + for (i = 0; i < len; i++) ((char*)dst)[i] = ((char*)src)[i]; + return dst; +} + + +void *memcpy32(void * dst, void const * src, size_t len) { + uint32_t * plDst = (uint32_t *) dst; + uint32_t const * plSrc = (uint32_t const *) src; + + while (len >= 4) { + *plDst++ = *plSrc++; + len -= 4; + } + + char * pcDst = (char *) plDst; + char const * pcSrc = (char const *) plSrc; + + while (len--) { + *pcDst++ = *pcSrc++; + } + + return (dst); +} + + +int get_page_mask() { + int pagesize,pagemask,temp; + + pagesize = getpagesize(); + + for( pagemask=0, temp = pagesize; temp != 1; ) { + temp = (temp >> 1); + pagemask = (pagemask << 1)+1; + } + return pagemask; +} |