unaligned.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:1k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. #ifndef __I386_UNALIGNED_H
  2. #define __I386_UNALIGNED_H
  3. /*
  4.  * The i386 can do unaligned accesses itself. 
  5.  *
  6.  * The strange macros are there to make sure these can't
  7.  * be misused in a way that makes them not work on other
  8.  * architectures where unaligned accesses aren't as simple.
  9.  */
  10. /**
  11.  * get_unaligned - get value from possibly mis-aligned location
  12.  * @ptr: pointer to value
  13.  *
  14.  * This macro should be used for accessing values larger in size than 
  15.  * single bytes at locations that are expected to be improperly aligned, 
  16.  * e.g. retrieving a u16 value from a location not u16-aligned.
  17.  *
  18.  * Note that unaligned accesses can be very expensive on some architectures.
  19.  */
  20. #define get_unaligned(ptr) (*(ptr))
  21. /**
  22.  * put_unaligned - put value to a possibly mis-aligned location
  23.  * @val: value to place
  24.  * @ptr: pointer to location
  25.  *
  26.  * This macro should be used for placing values larger in size than 
  27.  * single bytes at locations that are expected to be improperly aligned, 
  28.  * e.g. writing a u16 value to a location not u16-aligned.
  29.  *
  30.  * Note that unaligned accesses can be very expensive on some architectures.
  31.  */
  32. #define put_unaligned(val, ptr) ((void)( *(ptr) = (val) ))
  33. #endif