示例#1
0
文件: cont.c 项目: 3runo5ouza/rhodes
static VALUE
fiber_init(VALUE fibval, VALUE proc)
{
    rb_fiber_t *fib = fiber_t_alloc(fibval);
    rb_context_t *cont = &fib->cont;
    rb_thread_t *th = &cont->saved_thread;

    fiber_link_join(fib);

    /* initialize cont */
    cont->vm_stack = 0;

    th->stack = 0;
    th->stack_size = FIBER_VM_STACK_SIZE;
    th->stack = ALLOC_N(VALUE, th->stack_size);

    th->cfp = (void *)(th->stack + th->stack_size);
    th->cfp--;
    th->cfp->pc = 0;
    th->cfp->sp = th->stack + 1;
    th->cfp->bp = 0;
    th->cfp->lfp = th->stack;
    *th->cfp->lfp = 0;
    th->cfp->dfp = th->stack;
    th->cfp->self = Qnil;
    th->cfp->flag = 0;
    th->cfp->iseq = 0;
    th->cfp->proc = 0;
    th->cfp->block_iseq = 0;
    th->tag = 0;
    th->local_storage = st_init_numtable();

    th->first_proc = proc;

    MEMCPY(&cont->jmpbuf, &th->root_jmpbuf, rb_jmpbuf_t, 1);

    return fibval;
}
示例#2
0
RETVAL GSimSocket::bindSocket()
{
   S16                  ret = ROK;
   struct sockaddr_in   addr;
   struct sockaddr_in6  addr6;

   if (IP_ADDR_TYPE_V4 == m_ep.ipAddr.ipAddrType)
   {
      addr.sin_addr.s_addr = htonl(m_ep.ipAddr.u.ipv4Addr.addr);
      addr.sin_family = AF_INET;
      addr.sin_port = htons(m_ep.port);
      MEMSET(addr.sin_zero, '\0', sizeof(addr.sin_zero));
   }
   else
   {
      MEMCPY(addr6.sin6_addr.s6_addr, m_ep.ipAddr.u.ipv6Addr.addr,
            m_ep.ipAddr.u.ipv6Addr.len);
      addr6.sin6_family = AF_INET6;
      addr6.sin6_port = htons(m_ep.port);
   }

   if (IP_ADDR_TYPE_V4 == m_ep.ipAddr.ipAddrType)
   {
      ret = bind(m_fd, (struct sockaddr *)&addr, sizeof(addr));
   }
   else
   {
      ret = bind(m_fd, (struct sockaddr *)&addr6, sizeof(addr6));
   }

   if (ret < 0)
   {
      LOG_FATAL("Socket Binding Failed, [%s]", strerror(errno));
      return ERR_SYS_SOCKET_BIND;
   }

   return ROK;
}
/**
 * Initialize virtual machine state prior to executing vertex program.
 */
static void
init_machine(GLcontext *ctx, struct gl_program_machine *machine)
{
   /* Input registers get initialized from the current vertex attribs */
   MEMCPY(machine->VertAttribs, ctx->Current.Attrib,
          MAX_VERTEX_PROGRAM_ATTRIBS * 4 * sizeof(GLfloat));

   if (ctx->VertexProgram._Current->IsNVProgram) {
      GLuint i;
      /* Output/result regs are initialized to [0,0,0,1] */
      for (i = 0; i < MAX_NV_VERTEX_PROGRAM_OUTPUTS; i++) {
         ASSIGN_4V(machine->Outputs[i], 0.0F, 0.0F, 0.0F, 1.0F);
      }
      /* Temp regs are initialized to [0,0,0,0] */
      for (i = 0; i < MAX_NV_VERTEX_PROGRAM_TEMPS; i++) {
         ASSIGN_4V(machine->Temporaries[i], 0.0F, 0.0F, 0.0F, 0.0F);
      }
      for (i = 0; i < MAX_VERTEX_PROGRAM_ADDRESS_REGS; i++) {
         ASSIGN_4V(machine->AddressReg[i], 0, 0, 0, 0);
      }
   }

   machine->NumDeriv = 0;

   /* init condition codes */
   machine->CondCodes[0] = COND_EQ;
   machine->CondCodes[1] = COND_EQ;
   machine->CondCodes[2] = COND_EQ;
   machine->CondCodes[3] = COND_EQ;

   /* init call stack */
   machine->StackDepth = 0;

   machine->FetchTexelLod = vp_fetch_texel;
   machine->FetchTexelDeriv = NULL; /* not used by vertex programs */

   machine->Samplers = ctx->VertexProgram._Current->Base.SamplerUnits;
}
示例#4
0
int
meta_load_sysindex(char *sysindex)
{
	int	fd;
	char	tab_meta_dir[TABLE_NAME_MAX_LEN];
	int	status;
	int	rtn_stat;


	rtn_stat= TRUE;
	
	
	MEMSET(tab_meta_dir, 256);
	MEMCPY(tab_meta_dir, MT_META_INDEX, STRLEN(MT_META_INDEX));
	str1_to_str2(tab_meta_dir, '/', "sysindex");

	OPEN(fd, tab_meta_dir, (O_RDONLY));

	if (fd < 0)
	{
		return FALSE;
	}

	status = READ(fd, sysindex, sizeof(META_SYSINDEX));

	Assert(status == sizeof(META_SYSINDEX));

	if (status != sizeof(META_SYSINDEX))
	{
		traceprint("Save sysindex hit error!\n");
		rtn_stat = FALSE;
		
	}

	CLOSE(fd);

	return rtn_stat;
}
示例#5
0
IpAddr convIpStrToIpAddr(const S8* pIp, U32 len)
{
   LOG_ENTERFN();

   IpAddr ipAddr;
   S8     ip[GSIM_SIZE_32] = {'\0'};
   MEMCPY(ip, pIp, len);

   ipAddr.ipAddrType = IP_ADDR_TYPE_INV;
   if (STRFIND(ip, ":") != NULL)
   {
      RETVAL ret = inet_pton(AF_INET6, ip, (VOID *)(ipAddr.u.ipv6Addr.addr));
      if (0 == ret)
      {
         LOG_FATAL("Invalid IPv6 Address");
      }
      else
      {
         ipAddr.u.ipv6Addr.len = STRLEN(ip);
         ipAddr.ipAddrType = IP_ADDR_TYPE_V6;
      }
   }
   else
   {
      RETVAL ret = inet_pton(AF_INET, ip, (VOID *)&(ipAddr.u.ipv4Addr.addr));
      if (0 == ret)
      {
         LOG_FATAL("Invalid IPv4 Address");
      }
      else
      {
         ipAddr.u.ipv4Addr.addr = ntohl(ipAddr.u.ipv4Addr.addr);
         ipAddr.ipAddrType = IP_ADDR_TYPE_V4;
      }
   }

   LOG_EXITFN(ipAddr);
}
示例#6
0
int OmegaUdpCreate(char *HostDnsName, int UdpPort)
{
	struct hostent *host; 
	struct sockaddr_in sa; 
	char IpAddr[20];
	
	if ((host = (struct hostent *)S_GETHOSTBYNAME(HostDnsName)) == NULL) //根据域名获取相应的IP信息, host将包含@remote_host对应的IP信息 
	{ 
		//libc_printf("----S_GETHOSTBYNAME Host name %s error! ----\r\n",HostDnsName);
	  return -1; 
	} 
	MEMCPY(&sa.sin_addr, host->h_addr, host->h_length);
	MEMSET(IpAddr,0,20);
	STRCPY(IpAddr,inet_ntoa(sa.sin_addr));
	//libc_printf("--Found omega,RAW  address:%s\n",inet_ntoa(sa.sin_addr)); 
	//libc_printf("--Found omega,IpAddr  address:%s\n",IpAddr);
	sock = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP);
	memset(&servaddr,0,sizeof(servaddr));
	servaddr.sin_family=AF_INET;
	servaddr.sin_addr.s_addr=inet_addr(IpAddr);
	servaddr.sin_port = htons(UdpPort);
	return sock;
}
示例#7
0
/* Clones ServerCredentials instances.

   Gives ServerCredentials a consistent implementation of Ruby's object copy/dup
   protocol. */
static VALUE grpc_rb_server_credentials_init_copy(VALUE copy, VALUE orig) {
  grpc_rb_server_credentials *orig_ch = NULL;
  grpc_rb_server_credentials *copy_ch = NULL;

  if (copy == orig) {
    return copy;
  }

  /* Raise an error if orig is not a server_credentials object or a subclass. */
  if (TYPE(orig) != T_DATA ||
      RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_server_credentials_free) {
    rb_raise(rb_eTypeError, "not a %s",
             rb_obj_classname(rb_cServerCredentials));
  }

  Data_Get_Struct(orig, grpc_rb_server_credentials, orig_ch);
  Data_Get_Struct(copy, grpc_rb_server_credentials, copy_ch);

  /* use ruby's MEMCPY to make a byte-for-byte copy of the server_credentials
     wrapper object. */
  MEMCPY(copy_ch, orig_ch, grpc_rb_server_credentials, 1);
  return copy;
}
示例#8
0
int tls_cmd_set_default_socket_params(
        struct tls_cmd_socket_t *params, u8 update_flash)
{
    struct tls_socket_cfg  *skt_cfg = &socket_cfg;
	struct tls_param_socket param_socket_cfg;
    if(tls_param_get_updp_mode()==0)
    {
	    skt_cfg->proto = params->proto;
	    skt_cfg->client = params->client;
	    skt_cfg->port = params->port;
	   	skt_cfg->host_len = params->host_len;  
	    MEMCPY(skt_cfg->ip_addr, params->ip_addr, 4);
		strcpy((char *)skt_cfg->host, params->host_name);
	    skt_cfg->timeout = params->timeout;
    }
    param_socket_cfg.client_or_server = params->client ? 0 : 1;
    param_socket_cfg.protocol = params->proto;
    param_socket_cfg.port_num = params->port;
   	strcpy((char *)param_socket_cfg.host, params->host_name);
    tls_param_set(TLS_PARAM_ID_DEFSOCKET, (void *)&param_socket_cfg,
            (bool)update_flash);
    return 0;
}
void AnsiString::operator=(const AnsiString& S) {
    size_t len;

    if (Data)
        Data[0] = 0;
    _LENGTH = 0;

    char *other_data = S.c_str();
    len = S._LENGTH;
    if (len) {
        _LENGTH = len;
        if (len + 1 >= _DATA_SIZE) {
            /*if (Data)
             *  delete[] Data;*/
            free(Data);
            _DATA_SIZE = ((len + 1) / BLOCK_SIZE) * BLOCK_SIZE + BLOCK_SIZE;
            //Data=new char[_DATA_SIZE];
            Data = (char *)malloc(_DATA_SIZE);
        }
        MEMCPY(Data, other_data, len + 1);
        //Data[len]=0;
    }
}
示例#10
0
/* Clones Channel instances.

   Gives Channel a consistent implementation of Ruby's object copy/dup
   protocol. */
static VALUE grpc_rb_channel_init_copy(VALUE copy, VALUE orig) {
  grpc_rb_channel *orig_ch = NULL;
  grpc_rb_channel *copy_ch = NULL;

  if (copy == orig) {
    return copy;
  }

  /* Raise an error if orig is not a channel object or a subclass. */
  if (TYPE(orig) != T_DATA ||
      RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_channel_free) {
    rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_rb_cChannel));
    return Qnil;
  }

  TypedData_Get_Struct(orig, grpc_rb_channel, &grpc_channel_data_type, orig_ch);
  TypedData_Get_Struct(copy, grpc_rb_channel, &grpc_channel_data_type, copy_ch);

  /* use ruby's MEMCPY to make a byte-for-byte copy of the channel wrapper
   * object. */
  MEMCPY(copy_ch, orig_ch, grpc_rb_channel, 1);
  return copy;
}
示例#11
0
sp_error
sp_playlist_add_tracks(sp_playlist *playlist, sp_track *const *tracks, int num_tracks, int position, sp_session *session)
{
  int size = sp_playlist_num_tracks(playlist);
  int new_size = size + num_tracks;
  int i, j, k;
  sp_playlist_track_t *new_tracks = NULL;

  if (position < 0 || position > size)
  {
    return SP_ERROR_INVALID_INDATA;
  }

  new_tracks = ALLOC_N(sp_playlist_track_t, new_size);

  for (i = 0, j = 0, k = 0; i < new_size; ++i)
  {
    if (i >= position && j < num_tracks)
    {
      new_tracks[i].track = tracks[j++];
      new_tracks[i].create_time = (int) time(NULL); // let’s hope before year 2038 we fix this :)
      new_tracks[i].creator = sp_session_user(session);
      new_tracks[i].message = NULL;
      new_tracks[i].seen = true;
    }
    else
    {
      MEMCPY(&new_tracks[i], &playlist->tracks[k++], sp_playlist_track_t);
    }
  }

  free(playlist->tracks);
  playlist->tracks = new_tracks;
  playlist->num_tracks = new_size;

  return SP_ERROR_OK;
}
示例#12
0
int update_player_states(play_para_t *para, int force)
{
    callback_t *cb = &para->update_state;
    update_state_fun_t fn;
    para->state.last_sta = para->state.status;
    para->state.status = get_player_state(para);

    if (check_time_interrupt(&cb->callback_old_time, cb->update_interval) || force) {
        player_info_t state;
        MEMCPY(&state, &para->state, sizeof(state));
        //if(force == 1)
        log_print("**[update_state]pid:%d status=%s(tttlast:%s) err=0x%x curtime=%d (ms:%d) fulltime=%d lsttime=%d\n",
                  para->player_id,
                  player_status2str(state.status),
                  player_status2str(state.last_sta),
                  (-state.error_no),
                  state.current_time,
                  state.current_ms,
                  state.full_time,
                  state.last_time);		
        log_print("**[update_state]abuflevel=%.08f vbublevel=%.08f abufrp=%x vbufrp=%x read_end=%d\n",
                  state.audio_bufferlevel,
                  state.video_bufferlevel,
                  para->abuffer.buffer_rp,
                  para->vbuffer.buffer_rp,
                  para->playctrl_info.read_end_flag);
        fn = cb->update_statue_callback;

        if (fn) {
            fn(para->player_id, &state);
        }
        send_event(para, PLAYER_EVENTS_PLAYER_INFO, &state, 0);
        para->state.error_no = 0;
        player_hwbuflevel_update(para);
    }
	return 0;
}
示例#13
0
/**
 * RTP send packets
 */
static void
rtp_send_packets( int sock, struct sockaddr_in* to)
{
  struct rtp_hdr* rtphdr;
  u8_t*           rtp_payload;
  int             rtp_payload_size;
  size_t          rtp_data_index;

  /* prepare RTP packet */
  rtphdr = (struct rtp_hdr*)rtp_send_packet;
  rtphdr->version     = RTP_VERSION;
  rtphdr->payloadtype = 0;
  rtphdr->ssrc        = PP_HTONL(RTP_SSRC);
  rtphdr->timestamp   = lwip_htonl(lwip_ntohl(rtphdr->timestamp) + RTP_TIMESTAMP_INCREMENT);

  /* send RTP stream packets */
  rtp_data_index = 0;
  do {
    rtp_payload      = rtp_send_packet+sizeof(struct rtp_hdr);
    rtp_payload_size = LWIP_MIN(RTP_PAYLOAD_SIZE, (sizeof(rtp_data) - rtp_data_index));

    MEMCPY(rtp_payload, rtp_data + rtp_data_index, rtp_payload_size);

    /* set MARKER bit in RTP header on the last packet of an image */
    rtphdr->payloadtype = RTP_PAYLOADTYPE | (((rtp_data_index + rtp_payload_size)
      >= sizeof(rtp_data)) ? RTP_MARKER_MASK : 0);

    /* send RTP stream packet */
    if (sendto(sock, rtp_send_packet, sizeof(struct rtp_hdr) + rtp_payload_size,
        0, (struct sockaddr *)to, sizeof(struct sockaddr)) >= 0) {
      rtphdr->seqNum  = lwip_htons(lwip_ntohs(rtphdr->seqNum) + 1);
      rtp_data_index += rtp_payload_size;
    } else {
      LWIP_DEBUGF(RTP_DEBUG, ("rtp_sender: not sendto==%i\n", errno));
    }
  }while (rtp_data_index < sizeof(rtp_data));
}
示例#14
0
void
of_wire_buffer_replace_data(of_wire_buffer_t *wbuf,
                            int offset,
                            int old_len,
                            uint8_t *data,
                            int new_len)
{
    int bytes;
    uint8_t *src_ptr, *dst_ptr;
    int cur_bytes;

    ASSERT(wbuf != NULL);

    cur_bytes = wbuf->current_bytes;

    /* Doesn't make sense; mismatch in current buffer info */
    ASSERT(old_len + offset <= wbuf->current_bytes);

    if (old_len < new_len) {
        of_wire_buffer_grow(wbuf, offset + new_len);
    } else {
        wbuf->current_bytes += (new_len - old_len); // may decrease size
    }

    if ((old_len + offset < cur_bytes) && (old_len != new_len)) {
        /* Need to move back of buffer */
        src_ptr = &wbuf->buf[offset + old_len];
        dst_ptr = &wbuf->buf[offset + new_len];
        bytes = cur_bytes - (offset + old_len);
        MEMMOVE(dst_ptr, src_ptr, bytes);
    }

    dst_ptr = &wbuf->buf[offset];
    MEMCPY(dst_ptr, data, new_len);

    ASSERT(wbuf->current_bytes == cur_bytes + (new_len - old_len));
}
示例#15
0
static snmp_err_t 
system_set_value(const struct snmp_scalar_array_node_def *node, u16_t len, void *value)
{
  u8_t*  var_wr = NULL;
  u16_t* var_wr_len;

  switch (node->oid) {
  case 4: /* sysContact */
    var_wr     = syscontact_wr;
    var_wr_len = syscontact_wr_len;
    break;
  case 5: /* sysName */
    var_wr     = sysname_wr;
    var_wr_len = sysname_wr_len;
    break;
  case 6: /* sysLocation */
    var_wr     = syslocation_wr;
    var_wr_len = syslocation_wr_len;
    break;
  default:
    LWIP_DEBUGF(SNMP_MIB_DEBUG,("system_set_value(): unknown id: %"S32_F"\n", node->oid));
    return SNMP_ERR_GENERROR;
  }

  /* no need to check size of target buffer, this was already done in set_test method */
  LWIP_ASSERT("", var_wr != NULL);
  MEMCPY(var_wr, value, len);
  
  if (var_wr_len == NULL) {
    /* add terminating 0 */
    var_wr[len] = 0;
  } else {
    *var_wr_len = len;
  }

  return SNMP_ERR_NOERROR;
}
示例#16
0
static void ChallengeResponse(const u_char *challenge,
		  const u_char PasswordHash[MD4_SIGNATURE_SIZE],
		  u_char response[24]) {
    u_char    ZPasswordHash[21];
    lwip_des_context des;
    u_char des_key[8];

    BZERO(ZPasswordHash, sizeof(ZPasswordHash));
    MEMCPY(ZPasswordHash, PasswordHash, MD4_SIGNATURE_SIZE);

#if 0
    dbglog("ChallengeResponse - ZPasswordHash %.*B",
	   sizeof(ZPasswordHash), ZPasswordHash);
#endif

    pppcrypt_56_to_64_bit_key(ZPasswordHash + 0, des_key);
    lwip_des_init(&des);
    lwip_des_setkey_enc(&des, des_key);
    lwip_des_crypt_ecb(&des, challenge, response +0);
    lwip_des_free(&des);

    pppcrypt_56_to_64_bit_key(ZPasswordHash + 7, des_key);
    lwip_des_init(&des);
    lwip_des_setkey_enc(&des, des_key);
    lwip_des_crypt_ecb(&des, challenge, response +8);
    lwip_des_free(&des);

    pppcrypt_56_to_64_bit_key(ZPasswordHash + 14, des_key);
    lwip_des_init(&des);
    lwip_des_setkey_enc(&des, des_key);
    lwip_des_crypt_ecb(&des, challenge, response +16);
    lwip_des_free(&des);

#if 0
    dbglog("ChallengeResponse - response %.24B", response);
#endif
}
示例#17
0
int tls_cmd_create_ibss_net( void )
{
	u8 ret=0;
#if TLS_CONFIG_IBSS
	struct tls_ibss_info_t* ibssinfo;
	struct tls_ibssip_info_t* ipinfo;
	struct tls_cmd_ssid_t ssid;
	struct tls_cmd_ip_params_t ip_addr;
	u8 channel_en;

	ibssinfo = tls_mem_alloc(sizeof(struct tls_softap_info_t));
	if(ibssinfo == NULL)
		return CMD_ERR_MEM;
	ipinfo = tls_mem_alloc(sizeof(struct tls_ip_info_t));
	if(ipinfo == NULL){
		tls_mem_free(ibssinfo);
		return CMD_ERR_MEM;
	}
		
	tls_cmd_get_ssid(&ssid);
	MEMCPY(ibssinfo->ssid, ssid.ssid, ssid.ssid_len);
	ibssinfo->ssid[ssid.ssid_len] = '\0';
	
	tls_cmd_get_encrypt( &ibssinfo->encrypt);
	
	tls_cmd_get_channel( &ibssinfo->channel, &channel_en);

	tls_cmd_get_key((struct tls_cmd_key_t *)(&ibssinfo->keyinfo));

	tls_cmd_get_ip_info(&ip_addr);

	/*ip配置信息:ip地址,掩码,dns名称*/
	MEMCPY(ipinfo->ip, ip_addr.ip_addr, 4);
	MEMCPY(ipinfo->netmask, ip_addr.netmask, 4);
	MEMCPY(ipinfo->gateway, ip_addr.gateway, 4);
	MEMCPY(ipinfo->dns1, ip_addr.dns, 4);
	MEMCPY(ipinfo->dns2, ip_addr.dns, 4);

	ret = tls_wifi_ibss_create(ibssinfo, ipinfo);
	tls_mem_free(ibssinfo);
	tls_mem_free(ipinfo);
#endif	
	return ret;	
}
示例#18
0
/* Clones Server instances.

   Gives Server a consistent implementation of Ruby's object copy/dup
   protocol. */
static VALUE grpc_rb_server_init_copy(VALUE copy, VALUE orig) {
    grpc_rb_server *orig_srv = NULL;
    grpc_rb_server *copy_srv = NULL;

    if (copy == orig) {
        return copy;
    }

    /* Raise an error if orig is not a server object or a subclass. */
    if (TYPE(orig) != T_DATA ||
            RDATA(orig)->dfree != (RUBY_DATA_FUNC)grpc_rb_server_free) {
        rb_raise(rb_eTypeError, "not a %s", rb_obj_classname(grpc_rb_cServer));
    }

    TypedData_Get_Struct(orig, grpc_rb_server, &grpc_rb_server_data_type,
                         orig_srv);
    TypedData_Get_Struct(copy, grpc_rb_server, &grpc_rb_server_data_type,
                         copy_srv);

    /* use ruby's MEMCPY to make a byte-for-byte copy of the server wrapper
       object. */
    MEMCPY(copy_srv, orig_srv, grpc_rb_server, 1);
    return copy;
}
示例#19
0
/* ----------------- Lstrcat ------------------ */
void __CDECL
Lstrcat( const PLstr to, const PLstr from )
{
	size_t	l;
	if (LLEN(*from)==0) return;

	if (LLEN(*to)==0) {
		Lstrcpy( to, from );
		return;
	}

	L2STR(to);
	L2STR(from);

	l = LLEN(*to)+LLEN(*from);
	if (LMAXLEN(*to) < l)
#ifdef JCC
		Lfx(to, MAX(l,LMAXLEN(*to) + CAT_INC));
#else
		Lfx(to, l);
#endif
	MEMCPY( LSTR(*to) + LLEN(*to), LSTR(*from), LLEN(*from) );
	LLEN(*to) = l;
} /* Lstrcat */
示例#20
0
void config_upge_feature(struct upge_feature_config *pupge_feature_config)
{
    if(NULL == pupge_feature_config)
    {
        ASSERT(0);
    }
	else
		MEMCPY(&g_upge_feature_config, pupge_feature_config, sizeof(struct upge_feature_config));

    bk_buff = g_upge_feature_config.bk_buff;

    g_upge_feature_config.enable_fast_erom_upgrade = TRUE;
//    g_upge_feature_config.InitBlockList = InitBlockList_fast;
//    g_upge_feature_config.FreeBlockList = FreeBlockList_fast;
//    g_upge_feature_config.FreeSlavelist = FreeSlavelist_fast;
//    g_upge_feature_config.Index2Id = Index2Id_fast;
//    g_upge_feature_config.ClearUpgFlag = ClearUpgFlag_fast;
//    g_upge_feature_config.SetUpgFlag = SetUpgFlag_fast;
//    g_upge_feature_config.p2p_delay = NULL;
//    
//    g_upge_feature_config.sys_upgrade = sys_upgrade_fast;
//    g_upge_feature_config.SetUpgradeMode = SetUpgradeMode_fast;
    
}
示例#21
0
文件: pan.c 项目: Janesak1977/ali3602
/*
 * 	Name		:   pan_get_key()
 *	Description	:   Get a input code
 *	Parameter	:	struct pan_device *dev		: Device get code from
 *					UINT32 timeout				: Timeout mode
 *	Return		:	UINT32 						: Return code
 *
 */
struct pan_key * pan_get_key(struct pan_device *dev, UINT32 timeout)
{
	while (1)
	{
	    if (pan_rx_buff_head != pan_rx_buff_tail)
		{
			break;
		}
		if (timeout != OSAL_WAIT_FOREVER_TIME)
		{
			if (timeout-- == 0)
			{
				return NULL;
			}
		}
		osal_task_sleep(1);
	}

	MEMCPY(&panel_key, pan_rx_buff[pan_rx_buff_tail], sizeof(struct pan_key));
	pan_rx_buff_tail++;
    pan_rx_buff_tail %= PAN_RX_BUFF_SIZE;

	return &panel_key;
}
void AnsiString::operator=(char *value) {
    size_t len;

    if (Data)
        Data[0] = 0;
    _LENGTH = 0;
    if (value) {
        len     = strlen(value);
        _LENGTH = len;
        if (len) {
            if (len + 1 >= _DATA_SIZE) {
                /*if (Data)
                    delete[] Data;*/
                _DATA_SIZE = ((len + 1) / BLOCK_SIZE) * BLOCK_SIZE + BLOCK_SIZE;
                //Data=new char[_DATA_SIZE];
                Data = (char *)realloc(Data, _DATA_SIZE);
            }
            // varianta 2:
            MEMCPY(Data, value, len + 1);// copiez si terminatorul
            // varianta 1:
            // strcpy(Data,value);
        }
    }
}
示例#23
0
UINT8 gyca_addmail_one_to_ram(T_CAMailInfo *data)
{
	UINT8 i;
	UINT8 ret = 0xff;
	if(!MEMCMP(&premail, data, sizeof(T_CAMailInfo)))
		return 1;
	
	gyca_mutex_lock();
	ret = gyca_getmail_num_from_ram();
	if(GYCA_EMAIL_MAX_CNT == ret)
	{
		gyca_mutex_unlock();
		return 2;
	}
	i = ret ;
	//gyca_mutex_lock();
	flashbuf[i].flg = 1;
	flashbuf[i].status = 1;
	MEMCPY(&flashbuf[i].info, data, sizeof(T_CAMailInfo));
	gyca_write_enable_time = osal_get_tick();
	gyca_write_enable = TRUE;
	gyca_mutex_unlock();
	return 0;
}
示例#24
0
文件: ecmain.c 项目: TitaniumBoy/lin
acpi_status
ec_terminate(void)
{
	acpi_status             status = AE_OK;
	BM_DEVICE_ID		criteria;
	BM_DRIVER		driver;

	FUNCTION_TRACE("ec_terminate");

	MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
	MEMSET(&driver, 0, sizeof(BM_DRIVER));

	/*
	 * Unregister driver for AC Adapter devices.
	 */
	MEMCPY(criteria.hid, EC_HID_EC, sizeof(EC_HID_EC));

	driver.notify = &ec_notify;
	driver.request = &ec_request;

	status = bm_unregister_driver(&criteria, &driver);

	return_ACPI_STATUS(status);
}
示例#25
0
acpi_status
ac_initialize (void)
{
    acpi_status		status = AE_OK;
    BM_DEVICE_ID		criteria;
    BM_DRIVER		driver;

    FUNCTION_TRACE("ac_initialize");

    MEMSET(&criteria, 0, sizeof(BM_DEVICE_ID));
    MEMSET(&driver, 0, sizeof(BM_DRIVER));

    driver.notify = &ac_notify;
    driver.request = &ac_request;

    /*
     * Register driver for AC Adapter devices.
     */
    MEMCPY(criteria.hid, AC_HID_AC_ADAPTER, sizeof(AC_HID_AC_ADAPTER));

    status = bm_register_driver(&criteria, &driver);

    return_ACPI_STATUS(status);
}
/* --------------------------------------------------------------------------*/
int player_get_media_info(int pid, media_info_t *minfo)
{
    play_para_t *player_para;
    player_status sta;

    player_para = player_open_pid_data(pid);
    if (player_para == NULL) {
        return PLAYER_NOT_VALID_PID;    /*this data is 0 for default!*/
    }

    sta = get_player_state(player_para);
    if (sta >= PLAYER_ERROR && sta <= PLAYER_EXIT) {
        player_close_pid_data(pid);
        return PLAYER_INVALID_CMD;
    }

    MEMSET(minfo, 0, sizeof(media_info_t));
    MEMCPY(minfo, &player_para->media_info, sizeof(media_info_t));

    log_print("[player_get_media_info]video_num=%d vidx=%d\n", minfo->stream_info.total_video_num, minfo->stream_info.cur_video_index);
    player_close_pid_data(pid);

    return PLAYER_SUCCESS;
}
示例#27
0
文件: cont.c 项目: genki/ruby
static VALUE
fiber_new(VALUE klass, VALUE proc)
{
    rb_context_t *cont = fiber_alloc(klass);
    VALUE contval = cont->self;
    rb_thread_t *th = &cont->saved_thread;

    /* initialize */
    cont->vm_stack = 0;

    th->stack = 0;
    th->stack_size = FIBER_VM_STACK_SIZE;
    th->stack = ALLOC_N(VALUE, th->stack_size);

    th->cfp = (void *)(th->stack + th->stack_size);
    th->cfp--;
    th->cfp->pc = 0;
    th->cfp->sp = th->stack + 1;
    th->cfp->bp = 0;
    th->cfp->lfp = th->stack;
    *th->cfp->lfp = 0;
    th->cfp->dfp = th->stack;
    th->cfp->self = Qnil;
    th->cfp->flag = 0;
    th->cfp->iseq = 0;
    th->cfp->proc = 0;
    th->cfp->block_iseq = 0;
    th->tag = 0;
    th->local_storage = st_init_numtable();

    th->first_proc = proc;

    MEMCPY(&cont->jmpbuf, &th->root_jmpbuf, rb_jmpbuf_t, 1);

    return contval;
}
示例#28
0
/**
 * Generic atomic list append operation
 * @param list The list to which an item is being appended
 * @param item THe item to append to the list
 *
 * The contents of the item are copied to the end of the list.
 * Currently assumes the list is at the end of its parent.
 */
int
of_list_append(of_object_t *list, of_object_t *item)
{
    int new_len;

    new_len = list->length + item->length;

    if (!of_object_can_grow(list, new_len)) {
        return OF_ERROR_RESOURCE;
    }

    of_wire_buffer_grow(list->wbuf,
                        OF_OBJECT_ABSOLUTE_OFFSET(list, new_len));

    MEMCPY(OF_OBJECT_BUFFER_INDEX(list, list->length),
           OF_OBJECT_BUFFER_INDEX(item, 0), item->length);

    /* Update the list's length */
    of_object_parent_length_update(list, item->length);

    OF_LENGTH_CHECK_ASSERT(list);

    return OF_ERROR_NONE;
}
示例#29
0
/*
 * Perform a 4x4 matrix multiplication  (product = a x b).
 * Input:  a, b - matrices to multiply
 * Output:  product - product of a and b
 */
static void matmul( GLdouble *product, const GLdouble *a, const GLdouble *b )
{
   /* This matmul was contributed by Thomas Malik */
   GLdouble temp[16];
   GLint i;

#define A(row,col)  a[(col<<2)+row]
#define B(row,col)  b[(col<<2)+row]
#define T(row,col)  temp[(col<<2)+row]

   /* i-te Zeile */
   for (i = 0; i < 4; i++)
     {
	T(i, 0) = A(i, 0) * B(0, 0) + A(i, 1) * B(1, 0) + A(i, 2) * B(2, 0) + A(i, 3) * B(3, 0);
	T(i, 1) = A(i, 0) * B(0, 1) + A(i, 1) * B(1, 1) + A(i, 2) * B(2, 1) + A(i, 3) * B(3, 1);
	T(i, 2) = A(i, 0) * B(0, 2) + A(i, 1) * B(1, 2) + A(i, 2) * B(2, 2) + A(i, 3) * B(3, 2);
	T(i, 3) = A(i, 0) * B(0, 3) + A(i, 1) * B(1, 3) + A(i, 2) * B(2, 3) + A(i, 3) * B(3, 3);
     }

#undef A
#undef B
#undef T
   MEMCPY( product, temp, 16*sizeof(GLdouble) );
}
示例#30
0
文件: guess.c 项目: wanabe/guess4r
static VALUE guess4r_f__guess_open(int argc, VALUE *argv) {
  VALUE *args, opt, f, str, enc;
  int i;

  args = ALLOCA_N(VALUE, argc + 1);
  args[0] = argv[0];
  if (TYPE(argv[argc - 1]) != T_HASH) {
    args[1] = args[argc++] = rb_hash_new();
  } else {
    args[1] = argv[argc - 1];
  }

  rb_hash_aset(args[1], ID2SYM(rb_intern("encoding")), rb_const_get(rb_cEncoding, rb_intern("ASCII_8BIT")));
  rb_funcall(args[1], rb_intern("delete"), 1, ID2SYM(rb_intern("external_encoding")));
  rb_funcall(args[1], rb_intern("delete"), 1, ID2SYM(rb_intern("internal_encoding")));
  f = rb_funcall2(rb_mKernel, rb_intern("open"), 2, args);
  str = rb_funcall(f, rb_intern("read"), 0);
  enc = guess4r_str__guess_encoding(str);
  rb_funcall(f, rb_intern("close"), 0);
  rb_hash_aset(args[1], ID2SYM(rb_intern("encoding")), enc);

  MEMCPY(args, argv, VALUE, argc - 1);
  return rb_funcall_passing_block(rb_mKernel, rb_intern("open"), argc, args);
}