Example #1
0
 int minDistance(string word1, string word2) {
     vector<vector<int>> DP(word1.size()+1, vector<int> (word2.size()+1, 0));
     for(int i = 1; i<=word1.size(); i++) {
         DP[i][0] = i;
     }
     for(int j = 1; j <= word2.size(); j++) {
         DP[0][j] = j;
     }
     for(int i = 1; i<=word1.size(); i++) {
         for(int j=1; j<=word2.size(); j++) {
             if(word1[i-1] == word2[j-1]) {
                 DP[i][j] = DP[i-1][j-1];
             }
             else {
                 DP[i][j] = min(min(DP[i-1][j] + 1, DP[i][j-1] + 1), DP[i-1][j-1] + 1);
             }
         }
     }
     return DP[word1.size()][word2.size()];
 }
Example #2
0
/* returns 0 on success */
static inline int
__addip(struct ip_set *set, 
	ip_set_ip_t ip, unsigned char *ethernet, ip_set_ip_t *hash_ip)
{
	struct ip_set_macipmap *map =
	    (struct ip_set_macipmap *) set->data;
	struct ip_set_macip *table =
	    (struct ip_set_macip *) map->members;

	if (ip < map->first_ip || ip > map->last_ip)
		return -ERANGE;
	if (test_and_set_bit(IPSET_MACIP_ISSET, 
			     &table[ip - map->first_ip].flags))
		return -EEXIST;

	*hash_ip = ip;
	DP("%u.%u.%u.%u, %u.%u.%u.%u", HIPQUAD(ip), HIPQUAD(*hash_ip));
	memcpy(&table[ip - map->first_ip].ethernet, ethernet, ETH_ALEN);
	return 0;
}
Example #3
0
static int setpool(
	struct sock *sk,
	int optval,
	void *user,
	unsigned int len
) {
	struct ip_pool_request req;

	DP("ip_pool:setpool: optval=%d, user=%p, len=%d\n", optval, user, len);
	if (!capable(CAP_NET_ADMIN))
		return -EPERM;
	if (optval != SO_IP_POOL)
		return -EBADF;
	if (len != sizeof(req))
		return -EINVAL;
	if (copy_from_user(&req, user, sizeof(req)) != 0)
		return -EFAULT;
	printk("obsolete op - upgrade your ippool(8) utility.\n");
	return -EINVAL;
}
void CSVPHostMountCB::FileOpenL(const TDesC& aName,TUint aMode,TFileOpen anOpen,CFileCB* aFile)
	{
	DP(_L("** (SVPHOSTMNT) CSVPHostMountCB::FileOpenL(%S)"), &aName);
	CSVPHostFileCB& file=(*((CSVPHostFileCB*)aFile));

	TBuf<KMaxPath> name;
	TUint driveNumber = Drive().DriveNumber();
	CanonicalizePathname(aName, driveNumber, name);
	TSVPHostFsFileOpenInfo info(driveNumber, name,aMode,anOpen);
	TInt err = SVP_HOST_FS_DEVICE().FileOpen(info);

	User::LeaveIfError(err);

	file.SetHandle(info.iHandle);
	file.SetSize(info.iSize);
	file.SetAtt(info.iAtt&KEntryAttMaskSupported);
	TTime tempTime=file.Modified();
	fileTimeToTime(info.iModified, tempTime, info.iTimeType);
	file.SetModified(tempTime);
	}
Example #5
0
wyToast* wyToast::make(const char* text, float duration) {
	// create texture of default toast background
	wyTexture2D* bgTex = wyTexture2D::makeRawPNG((const char*)_toast_bg_png, sizeof(_toast_bg_png) - 2);
	wyNinePatchSprite* bg = wyNinePatchSprite::make(bgTex, wyr(DP(24), DP(24), 1, 1));

	// create label as content
	wyLabel* label = wyLabel::make(text, SP(12), BOLD);
	label->setLineWidth(wyDevice::winWidth * 4 / 5);

	// create toast and set default margin
	wyToast* t = WYNEW wyToast(bg, label, duration);
	t->setMargin(DP(15), DP(20), DP(20), DP(15));
	t->m_useDefaultBg = true;
	return (wyToast*)t->autoRelease();
}
Example #6
0
static uchar i2c_select_device (uchar dev_addr, uchar read, int ten_bit)
{
	unsigned int status, data, bits = 7;
	int count = 0;

	DP (puts ("i2c_select_device\n"));

	/* Output slave address */

	if (ten_bit) {
		bits = 10;
	}

	data = (dev_addr << 1);
	/* set the read bit */
	data |= read;
	GT_REG_WRITE (I2C_DATA, data);
	/* assert the address */
	RESET_REG_BITS (I2C_CONTROL, BIT3);

	udelay (I2C_DELAY);

	GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);
	count = 0;
	while (((status & 0xff) != 0x40) && ((status & 0xff) != 0x18)) {
		udelay (I2C_DELAY);
		if (count > 20) {
			GT_REG_WRITE (I2C_CONTROL, (0x1 << 4));	/*stop */
			return (status);
		}
		GT_REG_READ (I2C_STATUS_BAUDE_RATE, &status);
		count++;
	}

	if (bits == 10) {
		printf ("10 bit I2C addressing not yet implemented\n");
		return (0xff);
	}

	return (0);
}
Example #7
0
/*         anything but zero is failure */
uchar
i2c_write (uchar dev_addr, unsigned int offset, int alen, uchar * data,
	   int len)
{
	uchar status = 0;
	unsigned int i2cFreq = CONFIG_SYS_I2C_SPEED;

	DP (puts ("i2c_write\n"));

	i2c_init (i2cFreq, 0);	/* set the i2c frequency */

	status = i2c_start ();	/* send a start bit */

	if (status) {
#ifdef DEBUG_I2C
		printf ("Transaction start failed: 0x%02x\n", status);
#endif
		return status;
	}

	status = i2c_set_dev_offset (dev_addr, offset, 0, alen);	/* send the slave address + offset */
	if (status) {
#ifdef DEBUG_I2C
		printf ("Failed to set slave address & offset: 0x%02x\n",
			status);
#endif
		return status;
	}


	status = i2c_write_byte (data, len);	/* write the data */
	if (status) {
#ifdef DEBUG_I2C
		printf ("Data not written: 0x%02x\n", status);
#endif
		return status;
	}
	/* issue a stop bit */
	i2c_stop ();
	return 0;
}
Example #8
0
static inline __u32
hash_id_cidr(struct ip_set_nethash *map,
	     ip_set_ip_t ip,
	     unsigned char cidr,
	     ip_set_ip_t *hash_ip)
{
	__u32 id;
	u_int16_t i;
	ip_set_ip_t *elem;

	*hash_ip = pack(ip, cidr);
	
	for (i = 0; i < map->probes; i++) {
		id = jhash_ip(map, i, *hash_ip) % map->hashsize;
	   	DP("hash key: %u", id);
		elem = HARRAY_ELEM(map->members, ip_set_ip_t *, id);
	   	if (*elem == *hash_ip)
			return id;
	}
	return UINT_MAX;
}
Example #9
0
/* Add, del, test parser */
static ip_set_ip_t
adt_parser(unsigned cmd, const char *optarg, void *data)
{
	struct ip_set_req_macipmap *mydata =
	    (struct ip_set_req_macipmap *) data;
	char *saved = ipset_strdup(optarg);
	char *ptr, *tmp = saved;

	DP("macipmap: %p %p", optarg, data);

	ptr = strsep(&tmp, ":%");
	parse_ip(ptr, &mydata->ip);

	if (tmp)
		parse_mac(tmp, mydata->ethernet);
	else
		memset(mydata->ethernet, 0, ETH_ALEN);	

	free(saved);
	return 1;	
}
Example #10
0
int run_com_general(const char *buffer) {

	int scan_count;

	scan_count = sscanf(buffer, PROC_STRING, PROC_SCANF_LIST);

	if( scan_count != LIST_LEN) {
		printk("eth proc bad format %x != %x\n", scan_count, LIST_LEN );
		return 1;
	}

#ifndef INCLUDE_MULTI_QUEUE
	printk("\n Be carefull eth is compiled without MULTI Q!! \n");
#endif	
	switch(command){
		case COM_SRQ:
			DP(" Port %x: Got SRQ command Q %x and packet type is %x <bpdu/arp/tcp/udp> \n",port,q,packett);
			run_com_srq();
			break;
		case COM_SQ:
			DP(" Port %x: Got SQ command Q %x direction %x <Rx/Tx> mac %2x:%2x:%2x:%2x:%2x:%2x\n",port, q, direct,
				mac[0],  mac[1],  mac[2],  mac[3],  mac[4],  mac[5]);
			run_com_sq();
			break;

#ifdef INCLUDE_MULTI_QUEUE
		case COM_SRP:
			DP(" Port %x: Got SRP command Q %x policy %x <Fixed/WRR> \n",port,q,policy); 
			run_com_srp();
			break;
		case COM_SRQW:
			DP(" Port %x: Got SQRW command Q %x weight %x \n",port,q,weight);
			run_com_srqw();
			break;
		case COM_STP:
			DP("STP cmd - Unsupported: Port %x Q %x policy %x <WRR/FIXED> weight %x\n",port,q,policy,weight); 
			break;
#endif /* INCLUDE_MULTI_QUEUE */

		case COM_STS:
			DP("  Port %x: Got STS command status %x\n",port,status);
			run_com_statis();
			break;
		default:
			printk("eth proc unknown command.\n");
	}
  	return 0;
}
 int minCut(string s) {
     int slen = s.length ();
     if (slen < 2)  return 0;
     dp.resize (slen);
     for (int i=0;i<slen;i++)    dp[i].resize (0);
     
     for (int i=0;i<slen;i++){
         int low = i, high = i+1;
         while (low>=0 && high<slen && s[low]==s[high]){
             dp[high].push_back (low); low--, high++;
         }
         dp[i].push_back (i);
         low = i-1, high = i + 1;
         while (low>=0 && high<slen && s[low]==s[high])
             dp[high].push_back (low),low--, high++;
     }
     f.resize (slen+1);
     fill_n (f.begin(), slen+1, -1);
     f[0] = 0;
     return DP(slen) - 1;
 }
Example #12
0
void knh_HashMap__k(Ctx *ctx, knh_Hash_t *o, OutputStream *w, String *m)
{
	size_t pos = 0, c = 0;
	size_t max = (KNH_HASH_TABLESIZE / o->hashop->size) * DP(o)->tables_size;
	knh_putc(ctx, w, '{');
	while(pos < max) {
		knh_hashentry_t *e = knh_hashentry_at((knh_Hash_t*)o, pos);
		if(e != NULL) {
			if(c > 0) {
				knh_write_delim(ctx,w);
			}
			knh_format(ctx, w, METHODN__k, e->key, KNH_NULL);
			knh_putc(ctx, w, ':');
			knh_putc(ctx, w, ' ');
			knh_format(ctx, w, METHODN__k, e->value, KNH_NULL);
			c++;
		}
		pos++;
	}
	knh_putc(ctx, w, '}');
}
Example #13
0
/*         anything other than zero is failure, no device */
int i2c_probe (uchar chip)
{

	/* We are just looking for an <ACK> back. */
	/* To see if the device/chip is there */

#ifdef DEBUG_I2C
	unsigned int i2c_status;
#endif
	uchar status = 0;
	unsigned int i2cFreq = CONFIG_SYS_I2C_SPEED;

	DP (puts ("i2c_probe\n"));

	i2c_init (i2cFreq, 0);	/* set the i2c frequency */

	status = i2c_start ();	/* send a start bit */

	if (status) {
#ifdef DEBUG_I2C
		printf ("Transaction start failed: 0x%02x\n", status);
#endif
		return (int) status;
	}

	status = i2c_set_dev_offset (chip, 0, 0, 0);	/* send the slave address + no offset */
	if (status) {
#ifdef DEBUG_I2C
		printf ("Failed to set slave address: 0x%02x\n", status);
#endif
		return (int) status;
	}
#ifdef DEBUG_I2C
	GT_REG_READ (I2C_STATUS_BAUDE_RATE, &i2c_status);
	printf ("address %#x returned %#x\n", chip, i2c_status);
#endif
	/* issue a stop bit */
	i2c_stop ();
	return 0;		/* successful completion */
}
Example #14
0
// Create a new HTML file with a given filename and title
// The heading, if not given, will be the same as the title
void
html_head(FILE *of, const string fname, const string title, const char *heading)
{
    swill_title(title.c_str());
    if (DP())
        cerr << "Write to " << fname << endl;
    fprintf(of,
            "<!doctype html public \"-//IETF//DTD HTML//EN\">\n"
            "<html>\n"
            "<head>\n"
            "<meta name=\"GENERATOR\" content=\"CScout %s - %s\">\n",
            Version::get_revision().c_str(),
            Version::get_date().c_str());
    fputs(
        "<meta http-equiv=\"Content-Style-Type\" content=\"text/css\">"
        "<style type=\"text/css\" >"
        "<!--\n", of);

    ifstream in;
    string css_fname;
    if (cscout_input_file("style.css", in, css_fname)) {
        int val;
        while ((val = in.get()) != EOF)
            putc(val, of);
    } else
        fputs(
#include "css.c"
            , of);
    fputs(
        "-->"
        "</style>"
        "</head>", of);
    fprintf(of,
            "<title>%s</title>\n"
            "</head>\n"
            "<body>\n"
            "<h1>%s</h1>\n",
            title.c_str(),
            heading ? heading : title.c_str());
}
Example #15
0
int i2c_write(uchar chip, uint addr, int alen, uchar *buffer, int len)
{
	MV_TWSI_SLAVE twsiSlave;
	DP(puts("i2c_write\n"));

	twsiSlave.slaveAddr.type = ADDR7_BIT;
	twsiSlave.slaveAddr.address = chip;
	if(alen != 0){
		twsiSlave.validOffset = MV_TRUE;
		twsiSlave.offset = addr;
		if(alen == 2)
		{
			twsiSlave.moreThen256 = MV_TRUE;
		}
		else
		{
			twsiSlave.moreThen256 = MV_FALSE;
		}
	}
	i2c_init(CONFIG_SYS_I2C_SPEED,0); /* set the i2c frequency */
	return mvTwsiWrite (i2c_current_bus, &twsiSlave, buffer, len);
}
Example #16
0
static
knh_dbcur_t *knh_dbquery__sqlite3(Ctx *ctx, knh_db_t *hdr, knh_bytes_t sql, ResultSet *rs)
{
	if(rs == NULL) {
		int r = sqlite3_exec((sqlite3*)hdr, (const char*)sql.buf, NULL, NULL, NULL);
		if(r != SQLITE_OK) {
			knh_sqlite3_perror(ctx, (sqlite3*)hdr, r);
		}
		return NULL;
	}
	else {
		sqlite3_stmt *stmt = NULL;
		sqlite3_prepare((sqlite3*)hdr, (char*)sql.buf, sql.len, &stmt, NULL);
//	if (r != SQLITE_OK) {
//		sqlite3_finalize(stmt);
//		DBG2_P("msg='%s', sqlite3_errmsg((sqlite3)hdr));
//		return NULL;
//	}
//		r = sqlite3_reset(stmt);
//	if(r != SQLITE_OK) {
//		sqlite3_finalize(stmt);
//		return NULL;
//	}
		size_t column_size = (size_t)sqlite3_column_count(stmt);
		//DBG2_P("column_size=%d", column_size);
		knh_ResultSet_initColumn(ctx, rs, column_size);
		if(column_size > 0) {
			size_t i;
			for(i = 0; i < DP(rs)->column_size; i++) {
				char *n = (char*)sqlite3_column_name(stmt, i);
				//DBG2_P("(%d) name = '%s'", i, n);
				if(n != NULL) {
					knh_ResultSet_setName(ctx, rs, i, new_String(ctx, B(n), NULL));
				}
			}
		}
		return (knh_dbcur_t*)stmt;
	}
}
Example #17
0
static knh_String_t *Gamma_vperror(CTX ctx, int pe, const char *fmt, va_list ap)
{
	knh_String_t *msg = TS_EMPTY;
	int isPRINT = (pe <= KC_DWARN) ? 1 : 0;
	if(pe != KC_DEBUG && (CTX_isInteractive(ctx) || knh_isCompileOnly(ctx))) {
		isPRINT = 1;
	}
	if(Gamma_isQuiet(ctx->gma) || ctx->gma->uline == 0) {
		isPRINT = 0;
	}
	//DBG_P("/*isPRINT=%d*/ uline=%d", isPRINT, ctx->gma->uline);
	if(isPRINT == 1) {
		knh_cwb_t cwbbuf, *cwb = knh_cwb_open(ctx, &cwbbuf);
		knh_write_uline(ctx, cwb->w, ctx->gma->uline);
		knh_write_ascii(ctx, cwb->w, KC__(pe));
		knh_vprintf(ctx, cwb->w, fmt, ap);
		msg = knh_cwb_newString(ctx, cwb);
		knh_Array_add(ctx, DP(ctx->gma)->errmsgs, msg);
		fprintf(stderr, "%s - %s%s\n", TERM_BNOTE(ctx, pe), S_tochar(msg), TERM_ENOTE(ctx, pe));
	}
	return msg;
}
Example #18
0
int bnx2x_vfpf_release(struct bnx2x *bp)
{
	struct vfpf_release_tlv *req = &bp->vf2pf_mbox->req.release;
	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
	u32 rc = 0, vf_id;

	/* clear mailbox and prep first tlv */
	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_RELEASE, sizeof(*req));

	if (bnx2x_get_vf_id(bp, &vf_id))
		return -EAGAIN;

	req->vf_id = vf_id;

	/* add list termination tlv */
	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
		      sizeof(struct channel_list_end_tlv));

	/* output tlvs list */
	bnx2x_dp_tlv_list(bp, req);

	/* send release request */
	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);

	if (rc)
		/* PF timeout */
		return rc;
	if (resp->hdr.status == PFVF_STATUS_SUCCESS) {
		/* PF released us */
		DP(BNX2X_MSG_SP, "vf released\n");
	} else {
		/* PF reports error */
		BNX2X_ERR("PF failed our release request - are we out of sync? response status: %d\n",
			  resp->hdr.status);
		return -EAGAIN;
	}

	return 0;
}
Example #19
0
    /**
     * @param A: an integer array.
     * @param k: a positive integer (k <= length(A))
     * @param target: a integer
     * @return an integer
     */
    int kSum2(vector<int> A, int k, int target) {
      int n = A.size();

      // DP[i][j][t] means the total number of combinations that j numbers out of first A[0~i-1] sum up to t
      vector<vector<vector<int> > > DP(n+1, vector<vector<int> >(k+1, vector<int>(target+1, 0)));
      for (int i = 0; i <= A.size(); i++) {
        DP[i][0][0] = 1;
      }

      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= min(k,i); j++) {
          for (int t = 1; t < A[i-1]; t++) {
            DP[i][j][t] = DP[i-1][j][t];
          }
          for (int t = A[i-1]; t <= target; t++) {
            DP[i][j][t] = DP[i-1][j][t] + DP[i-1][j-1][t-A[i-1]];
          }
        }
      }

      return DP[n][k][target];
    }
STDMETHODIMP CGfxFB::Open(DWORD dwWidth, DWORD dwHeight, DWORD dwBuffers, 
		const DWORD *pdwFourCC, IMcPreInit* pPrepareData, RECT* pDst)		
{
	POINT pt;

	if(dwWidth==0 || dwHeight==0)
		return E_FAIL;


	m_dwWidth = dwWidth;
	m_dwHeight = dwHeight;
	if(pdwFourCC)
		m_pdwFourCCList = pdwFourCC;
	else
		m_pdwFourCCList = const_dwFourCC;
	DP("[GFXFB]Open w:%d h:%d \n",m_dwWidth, m_dwHeight);
	pt.x = m_rectDst.left;
	pt.y = m_rectDst.top;
	m_bScnClip = TRUE;

	return CreateSurfaces(dwBuffers);
}
Example #21
0
File: stmt.c Project: matsuu/konoha
void knh_Stmt__s(Ctx *ctx, Stmt *o, OutputStream *w, String *m)
{
    knh_intptr_t i;
    knh_putc(ctx, w, '(');
    if(SP(o)->stt != STT_OP && SP(o)->stt != STT_NEW && SP(o)->stt != STT_CALL ) {
        knh_write_char(ctx, w, knh_stmt_tochar(SP(o)->stt));
        if(DP(o)->size > 0) {
            knh_putc(ctx, w, ' ');
        }
    }
    for(i = 0; i < DP(o)->size; i++) {
        if(i > 0) knh_putc(ctx, w, ' ');
        if(IS_Token(DP(o)->terms[i])) {
            knh_Token__s(ctx, DP(o)->tokens[i], w, m);
        } else {
            KNH_ASSERT(IS_Stmt(DP(o)->terms[i]));
            knh_Stmt__s(ctx, DP(o)->stmts[i], w, m);
            if(IS_NOTNULL(DP(DP(o)->stmts[i])->next)) {
                knh_write_dots(ctx, w);
            }
        }
    }
    knh_putc(ctx, w, ')');
}
Example #22
0
/* Tell PF about SB addresses */
int bnx2x_vfpf_init(struct bnx2x *bp)
{
	struct vfpf_init_tlv *req = &bp->vf2pf_mbox->req.init;
	struct pfvf_general_resp_tlv *resp = &bp->vf2pf_mbox->resp.general_resp;
	int rc, i;

	/* clear mailbox and prep first tlv */
	bnx2x_vfpf_prep(bp, &req->first_tlv, CHANNEL_TLV_INIT, sizeof(*req));

	/* status blocks */
	for_each_eth_queue(bp, i)
		req->sb_addr[i] = (dma_addr_t)bnx2x_fp(bp, i,
						       status_blk_mapping);

	/* statistics - requests only supports single queue for now */
	req->stats_addr = bp->fw_stats_data_mapping +
			  offsetof(struct bnx2x_fw_stats_data, queue_stats);

	/* add list termination tlv */
	bnx2x_add_tlv(bp, req, req->first_tlv.tl.length, CHANNEL_TLV_LIST_END,
		      sizeof(struct channel_list_end_tlv));

	/* output tlvs list */
	bnx2x_dp_tlv_list(bp, req);

	rc = bnx2x_send_msg2pf(bp, &resp->hdr.status, bp->vf2pf_mbox_mapping);
	if (rc)
		return rc;

	if (resp->hdr.status != PFVF_STATUS_SUCCESS) {
		BNX2X_ERR("INIT VF failed: %d. Breaking...\n",
			  resp->hdr.status);
		return -EAGAIN;
	}

	DP(BNX2X_MSG_SP, "INIT VF Succeeded\n");
	return 0;
}
    int numDecodings(string s) {
     if(s.empty())return 0;
     if(s.size()==1 && s[0]=='0') return 0;
     vector<int>DP(s.size()+1,1);
     for(int i=2; i<=s.size();i++){
         int cur = s[i-1] - '0';
         int pre = s[i-2] - '0';
         if((pre==0 && i==2) || (cur==0 && (pre>2 || pre==0)))
            return 0;

         if( (pre==2 && cur<=6 && cur>0) || (pre==1 && cur<=9 && cur>0) )  {
             if(i<s.size() && s[i]=='0'){
                 DP[i] = DP[i-1];
             }else
                DP[i] = DP[i-1] + DP[i-2];
         }
        else{
            DP[i] = DP[i-1];
        }
     }

    return DP[s.size()];
    }
Example #24
0
int run_com_general(const char *buffer) {

	int scan_count;

	scan_count = sscanf(buffer, PROC_STRING, PROC_SCANF_LIST);

	if( scan_count != LIST_LEN) {
		printk("eth proc bad format %x != %x\n", scan_count, LIST_LEN );
		return 1;
	}

	switch(command){
		case COM_SRQ:
			DP(" Port %x: Got SRQ command Q %x and packet type is %x <bpdu/arp/tcp/udp> \n",port,q,packet);
			run_com_srq();
			break;
		case COM_SQ:
			DP(" Port %x: Got SQ command Q %x mac %2x:%2x:%2x:%2x:%2x:%2x\n",port, q,
				mac[0],  mac[1],  mac[2],  mac[3],  mac[4],  mac[5]);
			run_com_sq();
			break;

#if (MV_ETH_RX_Q_NUM > 1)
		case COM_SRP:
			DP(" Port %x: Got SRP command Q %x policy %x <Fixed/WRR> \n",port,q,policy);
            printk("Not supported\n");
			break;
		case COM_SRQW:
			DP(" Port %x: Got SQRW command Q %x weight %x \n",port,q,weight);
			printk("Not supported\n");
			break;
		case COM_STP:
			DP("STP cmd - Unsupported: Port %x Q %x policy %x <WRR/FIXED> weight %x\n",port,q,policy,weight);
			break;
#endif /* MV_ETH_RX_Q_NUM > 1 */

		case COM_STS:
			DP("  Port %x: Got STS command status %x\n",port,status);
			run_com_stats();
			break;
		default:
			printk("eth proc unknown command.\n");
	}
	return 0;
}
Example #25
0
/*******************************************************************************
	概要	:	アプリケーション・メモリ構造情報クラスの初期化
	説明	:
	Include	:	AMSI.h
	引数	:	const AppliHeader& CR_AplHead	アプリケーション情報
	戻り値	:	void
*******************************************************************************/
void	AMSI::Init( const AppliHeader& CR_AplHead )
{
	//スタックサイズ修正
	if( CR_AplHead.u4_StackSize < STACK_MIN_SIZE )
		Mui_StackSize = STACK_MIN_SIZE;
	else if( CR_AplHead.u4_StackSize > STACK_MAX_SIZE )
		Mui_StackSize = STACK_MAX_SIZE;
	else
		Mui_StackSize = CR_AplHead.u4_StackSize;
	Mui_StackSize = INT_CEIL_BIN( Mui_StackSize, 0xfff );

	//ヒープサイズ修正
	if( CR_AplHead.u4_HeapSize < HEAP_MIN_SIZE )
		Mui_HeapSize = STACK_MIN_SIZE;
	else if( CR_AplHead.u4_HeapSize > HEAP_MAX_SIZE )
		Mui_HeapSize = STACK_MAX_SIZE;
	else
		Mui_HeapSize = CR_AplHead.u4_HeapSize;
	Mui_HeapSize = INT_CEIL_BIN( Mui_HeapSize, 0xfff );

	Mui_BodySize = INT_CEIL_BIN( CR_AplHead.u4_AppliSize - sizeof (AppliHeader), 0xfff );
	DP( "Mui_BodySize:%#x", Mui_BodySize );
}
Example #26
0
METHOD knh__System_setMethodCompilationListener(Ctx *ctx, knh_sfp_t *sfp)
{
	String *key;
	if(IS_NULL(sfp[2].s)) {
		key = T__("MethodC");
	}
	else {
		knh_cwb_t cwbbuf, *cwb = knh_cwb_openinit(ctx, &cwbbuf, STEXT("MethodC"));
		knh_bytes_t anno = knh_String_tobytes(sfp[2].s);
		if(anno.buf[0] != '@') {
			knh_cwb_putc(ctx, cwb, '@');
		}
		knh_cwb_write(ctx, cwb, anno);
		key = knh_cwb_newString(ctx, cwb);
	}
	KNH_LOCK(ctx, LOCK_SYSTBL, NULL);
	{
		DictMap *dm = DP(ctx->sys)->listenerDictMap;
		knh_DictMap_set(ctx, dm, key, sfp[1].o);
	}
	KNH_UNLOCK(ctx, LOCK_SYSTBL, NULL);
	KNH_RETURN_void(ctx, sfp);
}
void knh_throw(Ctx *ctx, knh_sfp_t *sfp, long start)
{
	if(IS_Exception(ctx->e)) {
		knh_sfp_t *sp = (sfp == NULL) ? ctx->esp : sfp + start;
		while(ctx->stack <= sp) {
			DBG_P("[%d] cid=%s ivalue=%lld", (sp - ctx->stack), CLASS__(knh_Object_cid(sp[0].o)), sp[0].ivalue);
			if(sp[0].callmtd != NULL && isCalledMethod(ctx, sp)) {
				sp = knh_Exception_addStackTrace(ctx, ctx->e, sp+1);
			}
			if(IS_ExceptionHandler(sp[0].hdr) && DP(sp[0].hdr)->return_address != NULL) {
				knh_ExceptionHandler_longjmp(ctx, sp[0].hdr);
				goto L_NOCATCH;
			}
			sp--;
		}
		L_NOCATCH:;
		{
			knh_Method_t *mtdf = knh_getSystemFormatter(ctx, CLASS_Exception, MN__dump);
			knh_write_Object(ctx, KNH_STDERR, sfp, &mtdf, UPCAST(ctx->e));
		}
		knh_exit(ctx, 0);
	}
}
Example #28
0
const string
Token::get_refactored_name() const
{
	if (parts.begin() == parts.end())
		return val;
	string result;
	for (dequeTpart::const_iterator i = parts.begin(); i != parts.end(); i++) {
		Eclass *ec = i->get_tokid().check_ec();
		if (ec == NULL)
			return val;
		IdProp::const_iterator idi;
		idi = Identifier::ids.find(ec);
		if (idi == Identifier::ids.end())
			return val;
		if (idi->second.get_replaced())
			result += idi->second.get_newid();
		else
			result += idi->second.get_id();
	}
	if (DP())
		cout << "refactored name for " << val << " is " << result << endl;
	return result;
}
Example #29
0
/* Final check; exit if not ok. */
static void
create_final(void *data, unsigned int flags)
{
	struct ip_set_req_macipmap_create *mydata =
	    (struct ip_set_req_macipmap_create *) data;

	if (flags == 0)
		exit_error(PARAMETER_PROBLEM,
			   "Need to specify --from and --to, or --network\n");

	if (flags & OPT_CREATE_NETWORK) {
		/* --network */
		if ((flags & OPT_CREATE_FROM) || (flags & OPT_CREATE_TO))
			exit_error(PARAMETER_PROBLEM,
				   "Can't specify --from or --to with --network\n");
	} else {
		/* --from --to */
		if ((flags & OPT_CREATE_FROM) == 0
		    || (flags & OPT_CREATE_TO) == 0)
			exit_error(PARAMETER_PROBLEM,
				   "Need to specify both --from and --to\n");
	}


	DP("from : %x to: %x  diff: %d  match unset: %d", mydata->from,
	   mydata->to, mydata->to - mydata->from,
	   flags & OPT_CREATE_MATCHUNSET);

	if (mydata->from > mydata->to)
		exit_error(PARAMETER_PROBLEM,
			   "From can't be lower than to.\n");

	if (mydata->to - mydata->from > MAX_RANGE)
		exit_error(PARAMETER_PROBLEM,
			   "Range too large. Max is %d IPs in range\n",
			   MAX_RANGE+1);
}
Example #30
0
/*
 * Thread start routine that repeatedly locks a mutex and
 * increments a counter.
 */
PRIVATE void *counter_thread()
{
    S32 status;
    U32 spin;

    /*
     * Until end_time, increment the counter each
     * second. Instead of just incrementing the counter, it
     * sleeps for another second with the mutex locked, to give
     * monitor_thread a reasonable chance of running.
     */
    while (time(NULL) < end_time)
    {
        status = pthread_mutex_lock (&mutex);
        if (status != 0)
        {
            err_abort (status, "Lock mutex");
        }

        for (spin = 0; spin < SPIN; spin++)
        {
            counter++;
        }

        status = pthread_mutex_unlock (&mutex);
        if (status != 0)
        {
            err_abort (status, "Unlock mutex");
        }

        sleep (1);
    }

    DP("Counter is %d\n", counter);

    return NULL;
}