コード例 #1
0
void
nsColumnSetFrame::DrainOverflowColumns()
{
  // First grab the prev-in-flows overflows and reparent them to this
  // frame.
  nsColumnSetFrame* prev = static_cast<nsColumnSetFrame*>(GetPrevInFlow());
  if (prev) {
    nsAutoPtr<nsFrameList> overflows(prev->StealOverflowFrames());
    if (overflows) {
      nsContainerFrame::ReparentFrameViewList(PresContext(), *overflows,
                                              prev, this);

      mFrames.InsertFrames(this, nsnull, *overflows);
    }
  }
  
  // Now pull back our own overflows and append them to our children.
  // We don't need to reparent them since we're already their parent.
  nsAutoPtr<nsFrameList> overflows(StealOverflowFrames());
  if (overflows) {
    // We're already the parent for these frames, so no need to set
    // their parent again.
    mFrames.AppendFrames(nsnull, *overflows);
  }
}
コード例 #2
0
ファイル: tpow.c プロジェクト: mmanley/Antares
int
main (void)
{
    mp_prec_t p;

    MPFR_TEST_USE_RANDS ();
    tests_start_mpfr ();

    special ();
    particular_cases ();
    check_pow_ui ();
    check_pow_si ();
    check_special_pow_si ();
    pow_si_long_min ();
    for (p = 2; p < 100; p++)
        check_inexact (p);
    underflows ();
    overflows ();
    x_near_one ();

    test_generic (2, 100, 100);
    test_generic_ui (2, 100, 100);
    test_generic_si (2, 100, 100);

    data_check ("data/pow275", mpfr_pow275, "mpfr_pow275");

    tests_end_mpfr ();
    return 0;
}
コード例 #3
0
float findwater(int i,int j,int x)            //根据上面溢出来的水量计算
{
	float tmp = 0;
	if(j == (i*(i-1)/2+1))
	{
		tmp = overflows(i-1,j-i+1,x)/2;
	}
	else if(j == (i*(i-1)/2+i))
	{
		tmp = overflows(i-1,j-i,x)/2;
	}
	else
	{
		tmp = overflows(i-1,j-i,x)/2 + overflows(i-1,j-i+1,x)/2;
	}
	return (tmp > j)?j:tmp;
}
コード例 #4
0
float overflows(int i,int j,int x)             //求溢出的水量
{
	float tmp = 0;
	if(j == 1)
		return (x >= 1 )?(float)(x-1):0;
	if(j == (i*(i-1)/2+1))
	{
		tmp = overflows(i-1,j-i+1,x)/2;
	}
	else if(j == (i*(i-1)/2+i))
	{
		tmp = overflows(i-1,j-i,x)/2;
	}
	else
	{
		tmp = overflows(i-1,j-i,x)/2 + overflows(i-1,j-i+1,x)/2;
	}
	return (tmp > j)?(tmp-j):0;
}
コード例 #5
0
ファイル: ttee.c プロジェクト: krokodilerian/ttee
void *rcv_thread(void *ptr) {
	char buff[BUFSZ];
	struct wrdata *dat = (struct wrdata *) ptr;
	int buffdat = 0;

	int j;
	int p1, p2;

	int overflow;
	struct timeval tv;

	fd_set reads;
	long flags;	

	flags = fcntl( dat->fd, F_GETFL, 0 );
	fcntl( dat->fd, F_SETFL, flags | O_NONBLOCK );

	dat->cbuf = calloc( 1, BUFFER );

	while (42) {

		tv.tv_sec = 1;
		tv.tv_usec = 0;

		FD_ZERO( &reads );
		FD_SET( dat->fd, &reads );

		// we check nothing. There are no error conditions that we care about.
		select( dat->fd + 1, &reads, NULL, NULL, &tv );

		if ( (buffdat = read ( dat->fd, buff, BUFSZ ) ) <=0 ) {
			if ( (buffdat == -1) && (errno = EAGAIN))
				continue;
			__sync_fetch_and_add(&dat->eof, 1);
			ERR("EOF\n");
			pthread_exit(NULL);
		}

		while (43) {
			overflow = 0;
			pthread_mutex_lock(&dat->wrlock);

			if (dat->processed==0) break;
			// the current buffer is full, switch to a new one
			// or the timeout passed
			for (j=0; (j<dat->numfiles) && (!overflow) ; j++) 
				overflow |= overflows (RP,  buffdat, WP[j]);

			if (!overflow) 
				break;

			pthread_mutex_unlock( &dat->wrlock );
			ERR("Ring buffer overflow, sleeping - RP %d WP %d WPid %d ofw %d\n", RP, WP[j], j, overflow);
			sleep_10ms();
		}

		if (RP + buffdat <= BUFFER) {
			// easy case
			memcpy ( &(dat->cbuf[RP]), buff, buffdat ); 
		} else {
			/* not-so-easy-case
			   split the bufer in two, and copy them separately
			*/
			p1 = BUFFER - RP;
			p2 = buffdat - p1;

			memcpy ( &(dat->cbuf[RP]), buff, p1 ); 
			memcpy ( &(dat->cbuf[0]), &buff[p1], p2 ); 

		}

		RP += buffdat;
		RP %= BUFFER;
		DBG ("RP moved to %d\n", RP);

		pthread_mutex_unlock( &dat->wrlock );
		dat->processed += buffdat;
	}
	return NULL;
}