Set the complete tcp flag bitmask
184975
def set_tcp_flags(self, tcp_flags):
        """"""

        if tcp_flags < 0 or tcp_flags > 255:
            raise ValueError("Invalid tcp_flags. Valid: 0-255.")

        prev_size = 0
        if self._json_dict.get('tcp_flags') is not None:
            prev_size = len(str(self._json_dict['tcp_flags'])) + len('tcp_flags') + 3  # str, key, key quotes, colon

        self._json_dict['tcp_flags'] = tcp_flags

        # update size
        new_size = len(str(self._json_dict['tcp_flags'])) + len('tcp_flags') + 3  # str, key, key quotes, colon
        self._size += new_size - prev_size

        if prev_size == 0 and self._has_field:
            # add the comma and space
            self._size += 2
        self._has_field = True
789787
def do_kpl_set_on_mask(self, args):
        
        params = args.split()
        address = None
        group = None
        mask_string = None
        mask = None

        try:
            address = params[0]
            group = int(params[1])
            mask_string = params[2]
            if mask_string[0:2].lower() == '0x':
                mask = binascii.unhexlify(mask_string[2:])
            else:
                mask = int(mask_string)
        except IndexError:
            _LOGGING.error("Address, group and mask are regquired")
            self.do_help('kpl_status')
        except TypeError:
            _LOGGING.error("Group must be an integer")
            self.do_help('kpl_status')

        if address and group and mask:
            self.tools.kpl_set_on_mask(address, group, mask)
435358
def setblocking(fd, blocking):
    """"""
    if not fcntl:
        warnings.warn('setblocking() not supported on Windows')
    flags = fcntl.fcntl(fd, fcntl.F_GETFL)
    if blocking:
        flags |= os.O_NONBLOCK
    else:
        flags &= ~os.O_NONBLOCK
    fcntl.fcntl(fd, fcntl.F_SETFL, flags)
213572
def has_flags(self, *flags):
        

        mask = sum(flags)
        return (self.bits & mask) == mask
1013199
def set(bit)
      quotient = bit >> 3
      remainder = bit & 0x7
      mask = 0x80 >> remainder

      raise "Bit #{bit} out of range of bitfield with length #{length}" if quotient >= @data.length
      @data[quotient] |= mask
    end
675380
def set_opcode(self, opcode):
        
        self.flags &= 0x87FF
        self.flags |= dns.opcode.to_flags(opcode)
1047237
def _split_optional_netmask(address):
    """"""
    addr = str(address).split('/')
    if len(addr) > 2:
        raise AddressValueError("Only one '/' permitted in %r" % address)
    return addr
1317038
def set_tcp_md5sig(s, addr, key):
    
    impls = {
        'FreeBSD': _set_tcp_md5sig_bsd,
        'Linux': _set_tcp_md5sig_linux,
        'NetBSD': _set_tcp_md5sig_bsd,
    }
    system = platform.system()
    try:
        impl = impls[system]
    except KeyError:
        raise NotImplementedError("TCP-MD5 unsupported on this platform")
    impl(s, addr, key)
103676
@Benchmark long setMaskX64(int reps) {
    long count = 64L * reps;
    long bitMask = 0L;
    for (int i = 0; i < count; i++) {
      bitMask |= 1 << (i & 0x3F);
    }
    return bitMask;
  }
1334842
def set_flag(self, value, flag, reset_val=False):
        """"""
        if not self.__dict__[flag]:
            self.__dict__[flag] = matrix(1.0, (len(self.__dict__[value]), 1),
                                         'd')
        for idx, item in enumerate(self.__dict__[value]):
            if item == 0:
                self.__dict__[flag][idx] = 0
                if reset_val:
                    self.__dict__[value][idx] = 1
694365
public function set_xor(Bitmask $Binary)
   {
      if(!($Binary instanceof Bitmask)) return;
      $data = $Binary->get_raw();

      foreach($data as $Pos => $Byte)
         $this->data[$Pos] = @$this->data[$Pos] ^ $Byte;
   }
589001
public function addFlag($flags)
    {
        $this->bitmask = $this->bitmask | $this->getMaskFromFlags($flags);

        return $this;
    }
578459
def buildMask(dqarr, bitvalue):
    
    return bitfield_to_boolean_mask(dqarr, bitvalue, good_mask_value=1,
                                    dtype=np.uint8)
979461
def _patch_tcpserver():
    
    shutdown_request = TCPServer.shutdown_request

    def shutdown_request_patched(*args, **kwargs):
        thread = current_thread()
        shutdown_request(*args, **kwargs)
        if thread in _exc_cache:
            post_mortem_interaction(*_exc_cache.pop(thread))

    TCPServer.shutdown_request = shutdown_request_patched
578358
def set_power_mask(self, sid_mask, state):
    """"""

    packet = bytearray(16)
    packet[0x00] = 0x0d
    packet[0x02] = 0xa5
    packet[0x03] = 0xa5
    packet[0x04] = 0x5a
    packet[0x05] = 0x5a
    packet[0x06] = 0xb2 + ((sid_mask<<1) if state else sid_mask)
    packet[0x07] = 0xc0
    packet[0x08] = 0x02
    packet[0x0a] = 0x03
    packet[0x0d] = sid_mask
    packet[0x0e] = sid_mask if state else 0

    response = self.send_packet(0x6a, packet)

    err = response[0x22] | (response[0x23] << 8)
1220252
def bfx(value, msb, lsb):
    """"""
    mask = bitmask((msb, lsb))
    return (value & mask) >> lsb
247696
def bit_mask(name,flags,type=:uint)
      bit_mask = BitMask.new(flags,type)

      typedef(bit_mask,name)
      return bit_mask
    end