unpack.h 1.5 KB

12345678910111213141516171819202122232425262728
  1. #ifndef __NVIF_UNPACK_H__
  2. #define __NVIF_UNPACK_H__
  3. #define nvif_unvers(r,d,s,m) ({ \
  4. void **_data = (d); __u32 *_size = (s); int _ret = (r); \
  5. if (_ret == -ENOSYS && *_size == sizeof(m)) { \
  6. *_data = NULL; \
  7. *_size = _ret = 0; \
  8. } \
  9. _ret; \
  10. })
  11. #define nvif_unpack(r,d,s,m,vl,vh,x) ({ \
  12. void **_data = (d); __u32 *_size = (s); \
  13. int _ret = (r), _vl = (vl), _vh = (vh); \
  14. if (_ret == -ENOSYS && *_size >= sizeof(m) && \
  15. (m).version >= _vl && (m).version <= _vh) { \
  16. *_data = (__u8 *)*_data + sizeof(m); \
  17. *_size = *_size - sizeof(m); \
  18. if (_ret = 0, !(x)) { \
  19. _ret = *_size ? -E2BIG : 0; \
  20. *_data = NULL; \
  21. *_size = 0; \
  22. } \
  23. } \
  24. _ret; \
  25. })
  26. #endif