Beispiel #1
0
int main()
{
     XGpio Gpio;    /* GPIO Device driver instance */

     int Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
     if (Status != XST_SUCCESS) {
          return XST_FAILURE;
     }
     /*Set the direction for the LEDs to output. */
     XGpio_SetDataDirection(&Gpio, LED_CHANNEL, 0x00);
        
     printf("Allocating arrays\n");
     uint32 *A, *B;
     A = (uint32 *)sds_alloc(NUMBYTES);
     B = (uint32 *)sds_alloc(NUMBYTES);
        
     if (A == NULL)      printf("Could not allocate memory A - exiting\n");
     else if (B == NULL) printf("Could not allocate memory B - exiting\n");
     else {
          int i, j;
          int success = 1;
          printf("LEDs match iteration index...\n");
          for (j = 0; j < 64; j++) {
               XGpio_DiscreteWrite(&Gpio, LED_CHANNEL, (unsigned char) j);
               for (i = N-1; i >= 0; i-- ) {
                    A[i] = rand() % N ;
                    B[i] = 0;
               }
               printf("A: ");
               for (i = 0; i < N; i++)
                    printf("%5d", A[i]);
               printf("\n");
                  
               arraycopy(A, B);
                  
               if (compare_uint32_arrays(A, B)) {
                    success = 0;
                    break;
               }
               printf("Iteration %2d matched.  Update LEDs and spin CPU to make change visible.\n",  j);
               for (i=0; i < 50000000; i++);
          }
          printf("Freeing array\n");
          sds_free(A);
          printf("%s\n", success ? "Test passed!" : "Better luck next time...");
     } 

     return 0;
}
Beispiel #2
0
static void lru_cache_pair_free(void *pair) {
	pair_t *p = pair;
	sds_free(p->key);
	zfree(p->value);
	zfree(p);
}