unixsockets.inc 705 B

12345678910111213141516171819202122232425262728293031323334
  1. function CMSG_FIRSTHDR(mhdr: Pmsghdr): Pcmsghdr;
  2. begin
  3. if mhdr^.msg_controllen >= SizeOf(cmsghdr) then
  4. Result:=mhdr^.msg_control
  5. else
  6. Result:=nil;
  7. end;
  8. function CMSG_NXTHDR(mhdr: Pmsghdr; cmsg: Pcmsghdr): Pcmsghdr;
  9. begin
  10. Result:=__cmsg_nxthdr(mhdr, cmsg);
  11. end;
  12. function CMSG_ALIGN(len: size_t): size_t;
  13. begin
  14. Result:=(len+SizeOf(size_t)-1) and (not(SizeOf(size_t)-1));
  15. end;
  16. function CMSG_SPACE(len: size_t): size_t;
  17. begin
  18. Result:=CMSG_ALIGN(len)+CMSG_ALIGN(SizeOf(cmsghdr));
  19. end;
  20. function CMSG_LEN(len: size_t): size_t;
  21. begin
  22. Result:=CMSG_ALIGN(SizeOf(cmsghdr))+len;
  23. end;
  24. function CMSG_DATA(cmsg: Pointer): PByte;
  25. begin
  26. Result:=PByte(Cardinal(cmsg) + SizeOf(Pcmsghdr));
  27. end;