check_unaligned_ram_access.cmake 592 B

1234567891011121314151617181920212223242526272829
  1. # find if the unaligned RAM access is possible on the build system
  2. include ( CheckCXXSourceRuns )
  3. CHECK_CXX_SOURCE_RUNS ( "
  4. #include <stdlib.h>
  5. #include <string.h>
  6. int main()
  7. {
  8. int ichars[8];
  9. char * sBuf = (char*)ichars;
  10. for ( int i=0; i<8*sizeof(int); i++ )
  11. sBuf[i] = i;
  12. // check for crashes (SPARC)
  13. volatile int iRes = 0;
  14. for ( int i=0; i<(int)sizeof(int); ++i )
  15. {
  16. int * pPtr = (int*)( sBuf+i );
  17. iRes += *pPtr;
  18. }
  19. // check for correct values (ARM)
  20. iRes = *(int*)( sBuf+1 );
  21. if (!( iRes==0x01020304 || iRes==0x04030201 ))
  22. return 1;
  23. // all seems ok
  24. return 0;
  25. }
  26. " UNALIGNED_RAM_ACCESS )