/alps/pcitool

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/pcitool

« back to all changes in this revision

Viewing changes to tools.c

  • Committer: Suren A. Chilingaryan
  • Date: 2011-02-13 02:07:11 UTC
  • Revision ID: csa@dside.dyndns.org-20110213020711-y9bjh3n4ke6p4t4n
Initial import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <string.h>
 
3
#include <unistd.h>
 
4
#include <stdint.h>
 
5
 
 
6
void *memcpy8(void * dst, void const * src, size_t len) {
 
7
    int i;
 
8
    for (i = 0; i < len; i++) ((char*)dst)[i] = ((char*)src)[i];
 
9
    return dst;
 
10
}
 
11
 
 
12
 
 
13
void *memcpy32(void * dst, void const * src, size_t len) {
 
14
    uint32_t * plDst = (uint32_t *) dst;
 
15
    uint32_t const * plSrc = (uint32_t const *) src;
 
16
 
 
17
    while (len >= 4) {
 
18
        *plDst++ = *plSrc++;
 
19
        len -= 4;
 
20
    }
 
21
 
 
22
    char * pcDst = (char *) plDst;
 
23
    char const * pcSrc = (char const *) plSrc;
 
24
 
 
25
    while (len--) {
 
26
        *pcDst++ = *pcSrc++;
 
27
    }
 
28
 
 
29
    return (dst);
 
30
 
31
 
 
32
 
 
33
int get_page_mask() {
 
34
    int pagesize,pagemask,temp;
 
35
 
 
36
    pagesize = getpagesize();
 
37
 
 
38
    for( pagemask=0, temp = pagesize; temp != 1; ) {
 
39
        temp = (temp >> 1);
 
40
        pagemask = (pagemask << 1)+1;
 
41
    }
 
42
    return pagemask;
 
43
}