main
|
Last change
on this file was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
1.6 KB
|
| Line | |
|---|
| 1 | /* $Id: testMemSizec.c 1142 2006-06-06 10:33:22Z bdauverg $ */
|
|---|
| 2 | #include <stdio.h>
|
|---|
| 3 |
|
|---|
| 4 | void allzero_(int *array) {
|
|---|
| 5 | int *inArray = array ;
|
|---|
| 6 | int i = 0 ;
|
|---|
| 7 | while (i<1000) {
|
|---|
| 8 | *inArray = 0 ;
|
|---|
| 9 | inArray++ ;
|
|---|
| 10 | i++ ;
|
|---|
| 11 | }
|
|---|
| 12 | }
|
|---|
| 13 |
|
|---|
| 14 | void allones_(int *array) {
|
|---|
| 15 | int *inArray = array ;
|
|---|
| 16 | int i = 0 ;
|
|---|
| 17 | while (i<1000) {
|
|---|
| 18 | *inArray = ~0 ;
|
|---|
| 19 | inArray++ ;
|
|---|
| 20 | i++ ;
|
|---|
| 21 | }
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | void all226s_(int *array) {
|
|---|
| 25 | int *inArray = array ;
|
|---|
| 26 | int i = 0 ;
|
|---|
| 27 | while (i<1000) {
|
|---|
| 28 | *inArray = 226 ;
|
|---|
| 29 | inArray++ ;
|
|---|
| 30 | i++ ;
|
|---|
| 31 | }
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | void displaybits_(int *array, int *n) {
|
|---|
| 35 | int *inArray = array ;
|
|---|
| 36 | int i = 0 ;
|
|---|
| 37 | int mask, j, bitone ;
|
|---|
| 38 | printf("\n") ;
|
|---|
| 39 | while (i<*n) {
|
|---|
| 40 | mask = (int)1 ;
|
|---|
| 41 | j = 0 ;
|
|---|
| 42 | while (j<32) {
|
|---|
| 43 | if (!mask) printf("mask is zero !\n") ;
|
|---|
| 44 | bitone = *inArray & mask ;
|
|---|
| 45 | if (bitone)
|
|---|
| 46 | printf("1") ;
|
|---|
| 47 | else
|
|---|
| 48 | printf("0") ;
|
|---|
| 49 | mask = mask<<1 ;
|
|---|
| 50 | j++ ;
|
|---|
| 51 | }
|
|---|
| 52 | printf("\n") ;
|
|---|
| 53 | if (mask) printf("mask is not zero !\n") ;
|
|---|
| 54 | inArray++ ;
|
|---|
| 55 | i++ ;
|
|---|
| 56 | }
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | int countsetbits_(int *array0, int *array1, int *repeat, int *n) {
|
|---|
| 60 | int nbBytes = -1;
|
|---|
| 61 | int *inArray0 = array0 ;
|
|---|
| 62 | int *inArray1 = array1 ;
|
|---|
| 63 | int i = 0 ;
|
|---|
| 64 | int mask, j, bitone0, bitone1 ;
|
|---|
| 65 | int count = 0 ;
|
|---|
| 66 | while (i<*n && nbBytes==-1) {
|
|---|
| 67 | mask = (int)1 ;
|
|---|
| 68 | j = 0 ;
|
|---|
| 69 | while (j<32 && nbBytes==-1) {
|
|---|
| 70 | bitone0 = *inArray0 & mask ;
|
|---|
| 71 | bitone1 = *inArray1 & mask ;
|
|---|
| 72 | if ((bitone0 && bitone1) || (!bitone0 && !bitone1)) {
|
|---|
| 73 | count++ ;
|
|---|
| 74 | } else {
|
|---|
| 75 | /* printf(" %f bits\n",((float)count)/((float)(*repeat))) ;*/
|
|---|
| 76 | nbBytes = (int)((float)count)/((float)(*repeat*8)) ;
|
|---|
| 77 | }
|
|---|
| 78 | mask = mask<<1 ;
|
|---|
| 79 | j++ ;
|
|---|
| 80 | }
|
|---|
| 81 | inArray0++ ;
|
|---|
| 82 | inArray1++ ;
|
|---|
| 83 | i++ ;
|
|---|
| 84 | }
|
|---|
| 85 | return nbBytes ;
|
|---|
| 86 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.