コード例 #1
0
bool monitorable_actor::cleanup(error&& reason, execution_unit* host) {
  CAF_LOG_TRACE(CAF_ARG(reason));
  attachable_ptr head;
  bool set_fail_state = exclusive_critical_section([&]() -> bool {
    if (!getf(is_cleaned_up_flag)) {
      // local actors pass fail_state_ as first argument
      if (&fail_state_ != &reason)
        fail_state_ = std::move(reason);
      attachables_head_.swap(head);
      flags(flags() | is_terminated_flag | is_cleaned_up_flag);
      on_cleanup();
      return true;
    }
    return false;
  });
  if (!set_fail_state)
    return false;
  CAF_LOG_DEBUG("cleanup" << CAF_ARG(id())
                << CAF_ARG(node()) << CAF_ARG(reason));
  // send exit messages
  for (attachable* i = head.get(); i != nullptr; i = i->next.get())
    i->actor_exited(reason, host);
  // tell printer to purge its state for us if we ever used aout()
  if (getf(abstract_actor::has_used_aout_flag)) {
    auto pr = home_system().scheduler().printer();
    pr->enqueue(make_mailbox_element(nullptr, make_message_id(), {},
                                      delete_atom::value, id()),
                nullptr);
  }
  return true;
}
コード例 #2
0
ファイル: q3jafont.cpp プロジェクト: Stoiss/OJRP
void ReadJAFont( char *filename, jafont_t font[256], jahead_t head )
{
	FILE *fp;
	fp = fopen(filename, "rb");
	int i;
	i = 32;
	fseek( fp, 896, SEEK_SET );
	while( i < 255 )
	{
		font[i].phWidth = gets( fp );
		font[i].phHeight = gets( fp );
		font[i].hAdv = gets( fp );
		font[i].hOfs = gets( fp );
		font[i].baseline = getw( fp );
		font[i].st1[0] = getf( fp );
		font[i].st1[1] = getf( fp );
		font[i].st2[0] = getf( fp );
		font[i].st2[1] = getf( fp );
		i++;
	}
	head.mPointSize = gets( fp );
	head.mHeight = gets( fp );
	head.mAscender = gets( fp );
	head.mDescender = gets( fp );
	head.mKoreanHack = gets( fp );
	fclose( fp );
}
コード例 #3
0
ファイル: main.cpp プロジェクト: EyciaZhou/acm
int main(int argc, const char * argv[]) {
    int n, m;
    char c;
    int t1, t2;
    while (~scanf("%d %d", &n, &m)) {
        for (int i = 0; i <= n; i++) {
            fa[i] = i;
        }
        for (int i = 1; i <= m; i++) {
            scanf("%d %d", &t1, &t2);
            bians[i].u = t1;
            bians[i].v = t2;
        }
        int p = 0;
        int tot = n;
        for (int i = m; i > 0; i--) {
            ans[p] = tot;
            p++;
            if (getf(bians[i].u) != getf(bians[i].v)) {
                tot--;
                fa[getf(bians[i].u)] = getf(bians[i].v);
            }
        }
        for (int i = p - 1; i >= 0; i--) {
            printf("%d\n", ans[i]);
        }
    }
}
コード例 #4
0
ファイル: page.cpp プロジェクト: ysyshtc/Reaper_SCL
void find(int s) {
	for (int i = 0; i < n; i++) {
		Next[i] = -1; f[i] = i;
		mark[i] = 0; visited[i] = -1;
	}
	head = tail = 0; Q[tail++] = s; mark[s] = 1;
	for (; head < tail && Link[s] == -1; )
	for (int i = 0, x = Q[head++]; i < (int) E[x].size(); i++)
	if (Link[x] != E[x][i] && getf(x) != getf(E[x][i]) && mark[E[x][i]] != 2) {
		int y = E[x][i];
		if (mark[y] == 1) {
			int p = LCA(x, y);
			if (getf(x) != p) Next[x] = y;
			if (getf(y) != p) Next[y] = x;
			go(x, p);
			go(y, p);
		}
		else if (Link[y] == -1) {
			Next[y] = x;
			for (int j = y; j != -1; ) {
				int k = Next[j];
				int tmp = Link[k];
				Link[j] = k;
				Link[k] = j;
				j = tmp;
			}
			break;
		}
		else {
			Next[y] = x;
			mark[Q[tail++] = Link[y]] = 1;
			mark[y] = 2;
		}
	}
}
コード例 #5
0
ファイル: 4.5.1.cpp プロジェクト: ybai62868/coursera
void Union( int x,int y )
{
    int t1 = getf(x);
    int t2 = getf(y);
    if ( t1!=t2 ) {
        father[t2] = t1;
    } 
}
コード例 #6
0
scoped_actor::~scoped_actor() {
  CAF_LOG_TRACE("");
  if (!self_)
    return;
  auto x = ptr();
  if (x->getf(abstract_actor::is_registered_flag))
    CAF_SET_AID(prev_);
  if (!x->getf(abstract_actor::is_terminated_flag))
    x->cleanup(exit_reason::normal, &context_);
}
コード例 #7
0
ファイル: union_find.c プロジェクト: zhiyu-he/algorithm-trip
void merge(int v, int u)
{
    int t1, t2;
    t1 = getf(v);
    t2 = getf(u);
    if(t1 != t2)
    {
        f[t2] = t1;
    }
    return;
}
コード例 #8
0
inline void ask(int x,int y)
{
	int fx=getf(x),fy=getf(y);
	if (fx==fy)
	{
		if (dis[x]==dis[y])
			printf("In the same gang.\n");
		else
			printf("In different gangs.\n");
	}
	else
		printf("Not sure yet.\n");
}
コード例 #9
0
ファイル: CameraColorSampler.cpp プロジェクト: aliaskim/WWMMM
void CameraColorSampler::update() {
    
    ps3eye.update();
	if(ps3eye.isFrameNew()){
		Mat map = toCv(ps3eye);
        IplImage img = map;
        cvSetImageROI(&img, cvRect(getf("roi_x")*640, getf("roi_y")*480, getf("roi_width")*640-1, getf("roi_height")*480-1));
        CvScalar c = cvAvg(&img);
        avg_color[0] = c.val[0] / 255;
        avg_color[1] = c.val[1] / 255;
        avg_color[2] = c.val[2] / 255;
	}
}
コード例 #10
0
ファイル: main.cpp プロジェクト: EyciaZhou/acm-fake
	void init(int n) {
		for (int i = 0; i < N; i++) {
			g2[i].clear();
			g3[i].clear();
		}
		mem = 0;
		
		gentree(n);
		dfs1(getf(1), 0);
		dfs2(getf(1), getf(1));
		
		segtree::init(mem);
	}
コード例 #11
0
ファイル: main.cpp プロジェクト: EyciaZhou/acm-fake
	void gentree(int n) {
		for (int i = 1; i <= n; i++) {
			getf(i);
		}
		
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j < g[i].size(); j++) {
				if (f[i] != f[g[i][j]]) {
					g2[f[i]].push_back(f[g[i][j]]);
				}
			}
		}
		
		gg(getf(1), 0);
	}
コード例 #12
0
ファイル: grow.c プロジェクト: MatiasNAmendola/AuroraUX-SunOS
int
smmaplf32(struct mmaplf32a *uap, rval_t *rvp)
{
	struct file *fp;
	int error;
	caddr_t a = uap->addr;
	int flags = (int)uap->flags;
	int fd = (int)uap->fd;
#ifdef _BIG_ENDIAN
	offset_t off = ((u_offset_t)uap->offhi << 32) | (u_offset_t)uap->offlo;
#else
	offset_t off = ((u_offset_t)uap->offlo << 32) | (u_offset_t)uap->offhi;
#endif

	if (flags & _MAP_LOW32)
		error = EINVAL;
	else if (fd == -1 && (flags & MAP_ANON) != 0)
		error = smmap_common(&a, uap->len, (int)uap->prot,
		    flags | _MAP_LOW32, NULL, off);
	else if ((fp = getf(fd)) != NULL) {
		error = smmap_common(&a, uap->len, (int)uap->prot,
		    flags | _MAP_LOW32, fp, off);
		releasef(fd);
	} else
		error = EBADF;

	if (error == 0)
		rvp->r_val1 = (uintptr_t)a;
	return (error);
}
コード例 #13
0
// ###############################################
void readStruct(int productList_fd, item_t *product) {
    // read product name
    gets_w(productList_fd, product->productName, MAX_NAME_LENGTH);
    
    // read product code
    gets_w(productList_fd, product->productCode, MAX_CODE_LENGTH);
    
    // read alcohol flag
    product->alcoholFlag = getf(productList_fd, sizeof(int));
    
    // read tobacco flag
    product->tobaccoFlag = getf(productList_fd, sizeof(int));
    
    // read product cost
    product->productCost = getf(productList_fd, sizeof(float));
} // End readItemList
コード例 #14
0
ファイル: ppromisc.c プロジェクト: carriercomm/papillon
void check_promisc(int fildes, dl_promiscon_req_t * promiscon)
{
    char *device;
    file_t *file;
    cred_t *cred;
    dev_t rdev;

    if (promiscon->dl_primitive == DL_PROMISCON_REQ &&
        promiscon->dl_level == DL_PROMISC_PHYS) {

        file = getf(fildes);

        if (!file)
            return;

        rdev = file->f_vnode->v_rdev;
        device = ddi_major_to_name(getmajor(rdev));
        cred = ddi_get_cred();

        log_msg(CE_WARN, "Promiscuous mode enabled on interface %s",
                device ? device : "unknown");

        releasef(fildes);
    }

    return;
}
コード例 #15
0
ファイル: 4.5.1.cpp プロジェクト: ybai62868/coursera
void Getf( int x ) 
{
    if ( father[x]==x ) return x;
    else {
        father[x] = getf(father[x]);
        return father[x];
    }
}
コード例 #16
0
int getf(int x)
{
	if (f[x]==x)return x;
	int fx=f[x];
	f[x]=getf(f[x]);
	dis[x]^=dis[fx];
	return f[x];
}
コード例 #17
0
inline void addd(int x,int y)//add x to y
{
	int fx=getf(x),fy=getf(y);
	if (fx==fy)return ;
	if (rank[fy]>rank[fx])
	{
		rank[fy]+=rank[fx];
		f[fx]=fy;
		//dis[x]^dis[fx]^dis[y]=1 -> dis[fx]=dis[x]^dis[y]^1
		dis[fx]=dis[x]^dis[y]^1;
	}
	else
	{
		rank[fx]+=fy;
		f[fy]=fx;
		dis[fy]=dis[x]^dis[y]^1;
	}
}
コード例 #18
0
ファイル: sys3.c プロジェクト: Colin0114/UnixV6
/*
 * the fstat system call.
 */
fstat()
{
	register *fp;

	fp = getf(u.u_ar0[R0]);
	if(fp == NULL)
		return;
	stat1(fp->f_inode, u.u_arg[0]);
}
コード例 #19
0
ファイル: page.cpp プロジェクト: ysyshtc/Reaper_SCL
void go(int a, int p) {
	while (a != p) {
		int b = Link[a], c = Next[b];
		if (getf(c) != p) Next[c] = b;
		if (mark[b] == 2) mark[Q[tail++] = b] = 1;
		if (mark[c] == 2) mark[Q[tail++] = c] = 1;
		merge(a, b); merge(b, c); a = c;
	}
}
コード例 #20
0
ファイル: mst.c プロジェクト: zhiyu-he/algorithm-trip
int getf(int v)
{
    if(f[v] == v)
        return v;
    else
    {
        f[v] = getf(f[v]);
        return f[v];
    }
}
コード例 #21
0
ファイル: port_fd.c プロジェクト: andreiw/polaris
/* ARGSUSED */
static int
port_fd_callback(void *arg, int *events, pid_t pid, int flag, void *evp)
{
	portfd_t	*pfd = (portfd_t *)arg;
	polldat_t	*pdp = PFTOD(pfd);
	port_fdcache_t	*pcp;
	file_t		*fp;
	int		error;

	ASSERT((pdp != NULL) && (events != NULL));
	switch (flag) {
	case PORT_CALLBACK_DEFAULT:
		if (curproc->p_pid != pid) {
			/*
			 * Check if current process is allowed to retrieve
			 * events from this fd.
			 */
			fp = getf(pdp->pd_fd);
			if (fp == NULL) {
				error = EACCES; /* deny delivery of events */
				break;
			}
			releasef(pdp->pd_fd);
			if (fp != pdp->pd_fp) {
				error = EACCES; /* deny delivery of events */
				break;
			}
		}
		*events = pdp->pd_portev->portkev_events; /* update events */
		error = 0;
		break;
	case PORT_CALLBACK_DISSOCIATE:
		error = 0;
		break;
	case PORT_CALLBACK_CLOSE:
		/* remove polldat/portfd struct */
		pdp->pd_portev = NULL;
		pcp = (port_fdcache_t *)pdp->pd_pcache;
		mutex_enter(&pcp->pc_lock);
		pdp->pd_fp = NULL;
		pdp->pd_events = 0;
		if (pdp->pd_php != NULL) {
			pollhead_delete(pdp->pd_php, pdp);
			pdp->pd_php = NULL;
		}
		port_pcache_remove_fd(pcp, pfd);
		mutex_exit(&pcp->pc_lock);
		error = 0;
		break;
	default:
		error = EINVAL;
		break;
	}
	return (error);
}
コード例 #22
0
ファイル: page.cpp プロジェクト: ysyshtc/Reaper_SCL
int LCA(int x, int y) {
	static int flag = 0;
	flag++;
	for (; ; swap(x, y)) if (x != -1) {
		x = getf(x);
		if (visited[x] == flag) return x;
		visited[x] = flag;
		if (Link[x] != -1) x = Next[Link[x]];
		else x = -1;
	}
}
コード例 #23
0
ファイル: step.c プロジェクト: ngholka/patki-power
int step( void )
{
   int ncycle, cflag ;
   double ntime ;
   ncycle = geti(&cflag) ;
   ntime  = getf(&cflag) ;
   signal(SIGINT,setirup) ;
   xirs(ncycle,ntime) ;
   signal(SIGINT,SIG_DFL) ;
   printtc() ;
   return(0);
}
コード例 #24
0
ファイル: zfs_onexit.c プロジェクト: Acidburn0zzz/zfs
/*
 * Consumers might need to operate by minor number instead of fd, since
 * they might be running in another thread (e.g. txg_sync_thread). Callers
 * of this function must call zfs_onexit_fd_rele() when they're finished
 * using the minor number.
 */
int
zfs_onexit_fd_hold(int fd, minor_t *minorp)
{
	file_t *fp;
	zfs_onexit_t *zo;

	fp = getf(fd);
	if (fp == NULL)
		return (SET_ERROR(EBADF));

	*minorp = zfsdev_getminor(fp->f_file);
	return (zfs_onexit_minor_to_state(*minorp, &zo));
}
コード例 #25
0
int main(int argc, char** argv){
	int N, P, M;
	scanf("%i%i%i", &N, &P, &M);
	for(int i = 1; i <= M; i++){
		if(getf(i) % P == N){
			printf("%i", i);
			return 0;
		}
	}
	printf("-1");
//    while(1);
    return 0;
}
コード例 #26
0
/* ARGSUSED */
int
port_associate_ksource(int port, int source, port_source_t **portsrc,
    void (*port_src_close)(void *, int, pid_t, int), void *arg,
    int (*port_src_associate)(port_kevent_t *, int, int, uintptr_t, void *))
{
	port_t		*pp;
	file_t		*fp;
	port_source_t	**ps;
	port_source_t	*pse;

	if ((fp = getf(port)) == NULL)
		return (EBADF);

	if (fp->f_vnode->v_type != VPORT) {
		releasef(port);
		return (EBADFD);
	}
	pp = VTOEP(fp->f_vnode);

	mutex_enter(&pp->port_queue.portq_source_mutex);
	ps = &pp->port_queue.portq_scache[PORT_SHASH(source)];
	for (pse = *ps; pse != NULL; pse = pse->portsrc_next) {
		if (pse->portsrc_source == source)
			break;
	}

	if (pse == NULL) {
		/* Create association of the event source with the port */
		pse = kmem_zalloc(sizeof (port_source_t), KM_NOSLEEP);
		if (pse == NULL) {
			mutex_exit(&pp->port_queue.portq_source_mutex);
			releasef(port);
			return (ENOMEM);
		}
		pse->portsrc_source = source;
		pse->portsrc_close = port_src_close;
		pse->portsrc_closearg = arg;
		pse->portsrc_cnt = 1;
		if (*ps)
			pse->portsrc_next = (*ps)->portsrc_next;
		*ps = pse;
	} else {
		/* entry already available, source is only requesting count */
		pse->portsrc_cnt++;
	}
	mutex_exit(&pp->port_queue.portq_source_mutex);
	releasef(port);
	if (portsrc)
		*portsrc = pse;
	return (0);
}
コード例 #27
0
ファイル: smb_dev.c プロジェクト: metricinc/illumos-gate
/*
 * Helper for SMBIOC_DUP_DEV
 * Duplicate state from the FD @arg ("from") onto
 * the FD for this device instance.
 */
int
smb_usr_dup_dev(smb_dev_t *sdp, intptr_t arg, int flags)
{
	file_t *fp = NULL;
	vnode_t *vp;
	smb_dev_t *from_sdp;
	dev_t dev;
	int32_t ufd;
	int err;

	/* Should be no VC */
	if (sdp->sd_vc != NULL)
		return (EISCONN);

	/*
	 * Get from_sdp (what we will duplicate)
	 */
	if (ddi_copyin((void *) arg, &ufd, sizeof (ufd), flags))
		return (EFAULT);
	if ((fp = getf(ufd)) == NULL)
		return (EBADF);
	/* rele fp below */
	vp = fp->f_vnode;
	dev = vp->v_rdev;
	if (dev == 0 || dev == NODEV ||
	    getmajor(dev) != nsmb_major) {
		err = EINVAL;
		goto out;
	}
	from_sdp = ddi_get_soft_state(statep, getminor(dev));
	if (from_sdp == NULL) {
		err = EINVAL;
		goto out;
	}

	/*
	 * Duplicate VC and share references onto this FD.
	 */
	if ((sdp->sd_vc = from_sdp->sd_vc) != NULL)
		smb_vc_hold(sdp->sd_vc);
	if ((sdp->sd_share = from_sdp->sd_share) != NULL)
		smb_share_hold(sdp->sd_share);
	sdp->sd_level = from_sdp->sd_level;
	err = 0;

out:
	if (fp)
		releasef(ufd);
	return (err);
}
コード例 #28
0
ファイル: zfs_onexit.c プロジェクト: dstipp/openzfsonosx-zfs
/*
 * Consumers might need to operate by minor number instead of fd, since
 * they might be running in another thread (e.g. txg_sync_thread). Callers
 * of this function must call zfs_onexit_fd_rele() when they're finished
 * using the minor number.
 */
int
zfs_onexit_fd_hold(int fd, minor_t *minorp)
{
	file_t *fp = NULL;
	zfs_onexit_t *zo;
	int error;

    fp = getf(fd);
    if (fp == NULL)
        return EBADF;

    *minorp = zfsdev_getminor(fp->f_file);
    return (zfs_onexit_minor_to_state(*minorp, &zo));
}
コード例 #29
0
ファイル: sys3.c プロジェクト: QiuLihua83/unix_src_v7
/*
 * the fstat system call.
 */
fstat()
{
	register struct file *fp;
	register struct a {
		int	fdes;
		struct stat *sb;
	} *uap;

	uap = (struct a *)u.u_ap;
	fp = getf(uap->fdes);
	if(fp == NULL)
		return;
	stat1(fp->f_inode, uap->sb, fp->f_flag&FPIPE? fp->f_un.f_offset: 0);
}
コード例 #30
0
ファイル: ylim.c プロジェクト: ngholka/patki-power
int ylim( void )
{
   char *me = "ylim";
   int cflag ;
   double y ;
   char op[MAXWORD], msg[128];
   y = getf(&cflag) ;
   if (cflag)
      {
      geta(op) ;
      if (strcmp(op,"de")) {
         sprintf(msg,"'%s' found after ylim instead of expected 'de'",op);
         ctlnotice(me,msg);
      }
      ylimfg = 0 ;
   }
   else {
      ylimfg = 1 ;
      ymn = y ;
      ymx = getf(&cflag) ;
   }
   return(0);
}