mercurial/pure/osutil.py
branchstable
changeset 27971 f7d0c28d34b3
parent 27704 051b0dcec98b
child 29600 7a157639b8f2
equal deleted inserted replaced
27970:3d23700cf4a9 27971:f7d0c28d34b3
   102             ('cmsg_type', ctypes.c_int),
   102             ('cmsg_type', ctypes.c_int),
   103             ('cmsg_data', ctypes.c_ubyte * 0),
   103             ('cmsg_data', ctypes.c_ubyte * 0),
   104         ]
   104         ]
   105 
   105 
   106     _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
   106     _libc = ctypes.CDLL(ctypes.util.find_library('c'), use_errno=True)
   107     _recvmsg = _libc.recvmsg
   107     _recvmsg = getattr(_libc, 'recvmsg', None)
   108     _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long)
   108     if _recvmsg:
   109     _recvmsg.argtypes = (ctypes.c_int, ctypes.POINTER(_msghdr), ctypes.c_int)
   109         _recvmsg.restype = getattr(ctypes, 'c_ssize_t', ctypes.c_long)
       
   110         _recvmsg.argtypes = (ctypes.c_int, ctypes.POINTER(_msghdr),
       
   111                              ctypes.c_int)
       
   112     else:
       
   113         # recvmsg isn't always provided by libc; such systems are unsupported
       
   114         def _recvmsg(sockfd, msg, flags):
       
   115             raise NotImplementedError('unsupported platform')
   110 
   116 
   111     def _CMSG_FIRSTHDR(msgh):
   117     def _CMSG_FIRSTHDR(msgh):
   112         if msgh.msg_controllen < ctypes.sizeof(_cmsghdr):
   118         if msgh.msg_controllen < ctypes.sizeof(_cmsghdr):
   113             return
   119             return
   114         cmsgptr = ctypes.cast(msgh.msg_control, ctypes.POINTER(_cmsghdr))
   120         cmsgptr = ctypes.cast(msgh.msg_control, ctypes.POINTER(_cmsghdr))