Пример #1
0
void
gread(struct termios *tp, char *s)
{
	const struct cchar *cp;
	char *ep, *p;
	long tmp;

	if ((s = strchr(s, ':')) == NULL)
		gerr(NULL);
	for (++s; s != NULL;) {
		p = strsep(&s, ":\0");
		if (!p || !*p)
			break;
		if (!(ep = strchr(p, '=')))
			gerr(p);
		*ep++ = '\0';
		(void)sscanf(ep, "%lx", &tmp);

#define	CHK(s)	(*p == s[0] && !strcmp(p, s))
		if (CHK("cflag")) {
			tp->c_cflag = tmp;
			continue;
		}
		if (CHK("iflag")) {
			tp->c_iflag = tmp;
			continue;
		}
		if (CHK("ispeed")) {
			(void)sscanf(ep, "%ld", &tmp);
			tp->c_ispeed = tmp;
			continue;
		}
		if (CHK("lflag")) {
			tp->c_lflag = tmp;
			continue;
		}
		if (CHK("oflag")) {
			tp->c_oflag = tmp;
			continue;
		}
		if (CHK("ospeed")) {
			(void)sscanf(ep, "%ld", &tmp);
			tp->c_ospeed = tmp;
			continue;
		}
		for (cp = cchars1; cp->name != NULL; ++cp)
			if (CHK(cp->name)) {
				tp->c_cc[cp->sub] = tmp;
				break;
			}
		if (cp->name == NULL)
			gerr(p);
	}
}
Пример #2
0
/*
	BMessageRunner(BMessenger target, const BMessage *message,
				   bigtime_t interval, int32 count)
	@case 3			target is valid, message is valid, interval == 0, count > 0
	@results		R5: InitCheck() should return B_ERROR.
						GetInfo() should return B_BAD_VALUE.
					OBOS: InitCheck() should return B_OK.
						  GetInfo() should return B_OK.
						  A minimal time interval is used (50000).
 */
void TBMessageRunnerTester::BMessageRunnerA3()
{
	MessageRunnerTestApp app(kTesterSignature);
	MessageRunnerTestLooper *looper = app.TestLooper();
	BMessenger target(looper);
	BMessage message(MSG_RUNNER_MESSAGE);
	bigtime_t interval = 0;
	int32 count = 5;
	BMessageRunner runner(target, &message, interval, count);
#ifdef TEST_R5
	CHK(runner.InitCheck() == B_ERROR);
	check_message_runner_info(runner, B_BAD_VALUE);
#else
	bigtime_t startTime = system_time();
	CHK(runner.InitCheck() == B_OK);
	interval = max(interval, kMinTimeInterval);
	check_message_runner_info(runner, B_OK, interval, count);
	snooze((count + 1) * interval + 10000);
	CHK(looper->CheckMessages(startTime, interval, count));
	CHK(app.CountReplies() == count);
#endif
}
Пример #3
0
utilStatus channelTestFamily_done( channelTestFamily * This ) {
   utilStatus status = UTIL_STATUS_NO_ERROR;
   if( This ) {
      unsigned i;
      if( This->parent2 ) {
         CHK(__FILE__,__LINE__,channelTestPerson_delete( &This->parent2 ))
      }
      for( i = 0; i < This->children.count; ++i ) {
         CHK(__FILE__,__LINE__,channelTestPerson_delete( &This->children.items[i] ))
      }
      CHK(__FILE__,__LINE__,channelList_done((channelList *)&This->children ))
   }
   else {
Пример #4
0
int cli_fault_injection_dev_addr(char *line, int num_of_args)
{
	char fault_num_str[MAX_ARG_SIZE];
	char dev_addr_str[MAX_ARG_SIZE];
	int fault_num;
	int dev_addr;

	/* Get number of fault injection */
	CHK(cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2));

	/* Get device address */
	CHK(cli_get_word(line, dev_addr_str, sizeof(dev_addr_str), 3));

	/* Convert strings to int */
	fault_num = atoi(fault_num_str) - 1;
	dev_addr = (int) strtol(dev_addr_str, (char **) &dev_addr_str, 16);


	CHK(cfg_set_fault_injection_dev_address(fault_num, (unsigned char) dev_addr));

	return 0;
}
Пример #5
0
/*
	void GetAppList(const char *signature, BList *teamIDList) const
	@case 2			teamIDList is not NULL and not empty, signature is not
					NULL, but no app with this signature is running
	@results		Should not modify teamIDList.
*/
void GetAppListTester::GetAppListTestB2()
{
	const char *signature = "application/x-vnd.obos-does-not-exist";
	// create a list with some dummy entries
	BList list;
	list.AddItem((void*)-7);
	list.AddItem((void*)-42);
	// get a list of running applications for reference
	BRoster roster;
	BList list1(list);
	roster.GetAppList(signature, &list1);
	// run some apps
	AppRunner runner1(true);
	AppRunner runner2(true);
	AppRunner runner3(true);
	CHK(runner1.Run("AppRunTestApp1") == B_OK);
	CHK(runner2.Run("AppRunTestApp2") == B_OK);
	CHK(runner3.Run("BMessengerTestApp1") == B_OK);
	BList expectedApps;
	// get a new app list and check it
	BList list2(list);
	roster.GetAppList(signature, &list2);
	check_list(list2, list, list1, expectedApps);
	// quit app 1
	runner1.WaitFor(true);
	BList list3(list);
	roster.GetAppList(signature, &list3);
	check_list(list3, list, list1, expectedApps);
	// quit app 2
	runner2.WaitFor(true);
	BList list4(list);
	roster.GetAppList(signature, &list4);
	check_list(list4, list, list1, expectedApps);
	// quit app 3
	runner3.WaitFor(true);
	BList list5(list);
	roster.GetAppList(signature, &list5);
	check_list(list5, list, list1, expectedApps);
}
Пример #6
0
	inline ConstIterator IteratorForIndex(int32 index) const
	{
		if (index < 0 || index > Count()) {
			CHK(fMyVector.IteratorForIndex(index) == fMyVector.End());
			return End();
		} else {
			MyIterator myIt = fMyVector.IteratorForIndex(index);
			ReferenceIterator it = fReferenceVector.begin();
			for (int32 i = 0; i < index; i++)
				++it;
			return ConstIterator(this, myIt, it);
		}
	}
Пример #7
0
uint TestDir15(void)
{
  tIORes res;
  uint result = 1;
  tReadDirState ReadDirState;
  tFATDirectoryEntry DirEntry;
//  tFATFSStatus FSStatus2;

  FAT_opendir (&stdio_FATFS, &res, "d:\\", &ReadDirState);
  CHK(res == ior_OK);

  FAT_readdir (&stdio_FATFS, &res, &ReadDirState, &DirEntry);
  CHK(res == ior_NO_MORE_FILES);

  FAT_closedir (&stdio_FATFS, &res, &ReadDirState);
  CHK(res == ior_OK);

  result = 0;

lend:
  return result;
}
Пример #8
0
int main(int argc, char **argv)
{
	/* create dummy pixmap to get initialization out of the way */
	c2d_ts_handle curTimestamp;
	PixmapPtr tmp = create_pixmap(64, 64, xRGB);
	CHK(c2dFlush(tmp->id, &curTimestamp));
	CHK(c2dWaitTimestamp(curTimestamp));

/*
[  1340.257] (II) freedreno(0): MSMCheckComposite:590 op:12: 0x2eb268 {20028888, 0} <- 0x2eb3a8 {08018000, 0} ((nil) {00000000, 0})
[  1340.257] (II) freedreno(0): MSMPrepareComposite:694 0x2eb178 {35x8,256} <- 0x2eb2c8 {1024x320,1024} ((nil) {0x0,0})
[  1340.258] (II) freedreno(0): MSMComposite:766 srcX=0 srcY=0  maskX=0 maskY=0 dstX=0  dstY=2  width=7 height=6
 */

	test_composite(C2D_ALPHA_BLEND_ADDITIVE,
			ARGB, 35,   8,
			A8,   1024, 320,
			0,    0,    0,
			0, 0, 0, 0, 0, 2, 7, 6);

	return 0;
}
Пример #9
0
/*
 * Checkup routine
 */
int ctr_drbg_self_test( int verbose )
{
    ctr_drbg_context ctx;
    unsigned char buf[16];

    /*
     * Based on a NIST CTR_DRBG test vector (PR = True)
     */
    if( verbose != 0 )
        polarssl_printf( "  CTR_DRBG (PR = TRUE) : " );

    test_offset = 0;
    CHK( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy,
                                entropy_source_pr, nonce_pers_pr, 16, 32 ) );
    ctr_drbg_set_prediction_resistance( &ctx, CTR_DRBG_PR_ON );
    CHK( ctr_drbg_random( &ctx, buf, CTR_DRBG_BLOCKSIZE ) );
    CHK( ctr_drbg_random( &ctx, buf, CTR_DRBG_BLOCKSIZE ) );
    CHK( memcmp( buf, result_pr, CTR_DRBG_BLOCKSIZE ) );

    if( verbose != 0 )
        polarssl_printf( "passed\n" );

    /*
     * Based on a NIST CTR_DRBG test vector (PR = FALSE)
     */
    if( verbose != 0 )
        polarssl_printf( "  CTR_DRBG (PR = FALSE): " );

    test_offset = 0;
    CHK( ctr_drbg_init_entropy_len( &ctx, ctr_drbg_self_test_entropy,
                            entropy_source_nopr, nonce_pers_nopr, 16, 32 ) );
    CHK( ctr_drbg_random( &ctx, buf, 16 ) );
    CHK( ctr_drbg_reseed( &ctx, NULL, 0 ) );
    CHK( ctr_drbg_random( &ctx, buf, 16 ) );
    CHK( memcmp( buf, result_nopr, 16 ) );

    if( verbose != 0 )
        polarssl_printf( "passed\n" );

    if( verbose != 0 )
            polarssl_printf( "\n" );

    return( 0 );
}
Пример #10
0
/* writting from chunk */
int chunk_write(void *chunk, int fd)
{
    int n = -1;

    if(chunk && fd > 0 && CHK(chunk)->left > 0 && CHK(chunk)->data && CHK(chunk)->end
            && (n = write(fd, CHK(chunk)->end, CHK(chunk)->left)) > 0)
    {
        CHK(chunk)->left -= n;
        CHK(chunk)->end += n;
    }
    return n;
}
Пример #11
0
/*
 * Calculate and set the AFE offset.
 *
 * low:  known-good AFE offset-register value. See note.
 * high: known-good AFE offset-register value. See note. 
 *
 * Note:
 * 'low' and 'high' depend on the scanner model.
 * Choose them so that
 * 1. both produce black pixel samples > 0, and never zero.
 * 2. 'low' produces a a darker black level than 'high',
 * 3. 'low' and 'high' values are as far apart as possible,
 *    for better precision.
 * Example: For CanoScan 4400F, select low = 75, high = 0.
 * Notice that the 'low' register value is not necessarily
 * less than the 'high' register value. It is what comes
 * out of the scanner that counts.
 */
static int calc_afe_blacklevel(struct gl843_device *dev,
			       struct calibration_info *cal,
			       uint8_t low, uint8_t high)
{
	int ret, i;
	struct gl843_image *img;
	struct img_stat lo_stat, hi_stat;

	DBG(DBG_msg, "Calibrating A/D-converter black level.\n");

	CHK_MEM(img = create_image(cal->width, cal->height, PXFMT_RGB16));

	/* Scan with the lamp off to produce black pixels. */
	CHK(set_lamp(dev, LAMP_OFF, 0));

	/* Sample 'low' black level */

	for (i = 0; i < 3; i++) {
		CHK(write_afe_gain(dev, i, 1.0));
		CHK(write_afe(dev, 32 + i, low));  /* Set 'low' black level */
	}
	CHK(scan_img(dev, img, 10000));
	get_image_stats(img, &lo_stat);

	/* Sample 'high' black level */

	for (i = 0; i < 3; i++) {
		CHK(write_afe(dev, 32 + i, high)); /* Set 'high' black level */
	}
	CHK(scan_img(dev, img, 10000));
	get_image_stats(img, &hi_stat);

	/* Use the line equation to find and set the best offset value */

	for (i = 0; i < 3; i++) {
		double m, c; /* y = mx + c */
		int o;	/* offset */
		m = (hi_stat.avg[i] - lo_stat.avg[i]) / (high - low);
		c = lo_stat.avg[i] - m * low;
		o = (int) satf(-c / m + 0.5, 0, 255);
		cal->offset[i] = o;
		CHK(write_afe(dev, 32 + i, o));
		DBG(DBG_info, "AFE %s offset = %d\n", idx_name(i), o);
	}

	ret = 0;
chk_failed:
	free(img);
	return ret;	
chk_mem_failed:
	ret = LIBUSB_ERROR_NO_MEM;
	goto chk_failed;
}
Пример #12
0
int
msearch(char ***argvp, struct info *ip)
{
	struct modes *mp;
	char *name;

	name = **argvp;

	for (mp = cmodes; mp->name; ++mp)
		if (CHK(mp->name)) {
			ip->t.c_cflag &= ~mp->unset;
			ip->t.c_cflag |= mp->set;
			ip->set = 1;
			return (1);
		}
	for (mp = imodes; mp->name; ++mp)
		if (CHK(mp->name)) {
			ip->t.c_iflag &= ~mp->unset;
			ip->t.c_iflag |= mp->set;
			ip->set = 1;
			return (1);
		}
	for (mp = lmodes; mp->name; ++mp)
		if (CHK(mp->name)) {
			ip->t.c_lflag &= ~mp->unset;
			ip->t.c_lflag |= mp->set;
			ip->set = 1;
			return (1);
		}
	for (mp = omodes; mp->name; ++mp)
		if (CHK(mp->name)) {
			ip->t.c_oflag &= ~mp->unset;
			ip->t.c_oflag |= mp->set;
			ip->set = 1;
			return (1);
		}
	return (0);
}
Пример #13
0
int main(int argc, char **argv)
{
	/* create dummy pixmap to get initialization out of the way */
	c2d_ts_handle curTimestamp;
	PixmapPtr tmp = create_pixmap(64, 64, xRGB);
	CHK(c2dFlush(tmp->id, &curTimestamp));
	CHK(c2dWaitTimestamp(curTimestamp));

	test_fill(1920, 1080, xRGB, 0, 0, 1920, 1080);
	test_fill(1920, 1080, xRGB, 717, 395, 718, 685);

	/* test limits of x, y */
	test_fill(1920, 1080, xRGB, 0x100, 0, 0x101, 0);
	test_fill(1920, 1080, xRGB, 0, 0x100, 0, 0x101);

	/* test limits of width, height */
	test_fill(1920, 1080, xRGB, 0, 0, 0x100, 0);
	test_fill(1920, 1080, xRGB, 0, 0, 0, 0x100);

	test_fill(1, 1, xRGB, 0, 0, 1, 1);

	return 0;
}
Пример #14
0
int cli_fault_injection_gen_read_en(char *line, int num_of_args)
{
	char fault_num_str[MAX_ARG_SIZE];
	char en_value_str[MAX_ARG_SIZE];
	int fault_num;
	int en_value;

	/* Get number of fault injection */
	CHK(cli_get_word(line, fault_num_str, sizeof(fault_num_str), 2));

	/* Get enable value */
	CHK(cli_get_word(line, en_value_str, sizeof(en_value_str), 3));

	/* Convert strings to int */
	fault_num = atoi(fault_num_str) - 1;
	en_value = atoi(en_value_str);

	CHK(cfg_set_fault_injection_read_enable(fault_num, en_value));

	return 0;

	return 0;
}
Пример #15
0
uint TestDir13(void)
{
  tIORes res;
  uint result = 1;
//  tFATFSStatus FSStatus1;

  FAT_mkdir (&stdio_FATFS, &res, "d:\\level1", mt_S_IWUSR);
  CHK(res == ior_OK);

  result = 0;

lend:
  return result;
}
Пример #16
0
int cfg_set_fault_injection_dev_address(int index, unsigned char address)
{
	if (!IS_VALID_FAULT_INJECTION_INDEX(index))
		return ERR_INVALID_PARAM;

	if (!IS_VALID_DEV_ADDR(address))
		return ERR_INVALID_PARAM;

	CHK(hw_set_i2c_address(FI_INDEX_TO_I2C_NUMBER(index), address));

	Cfg.i2c_fi[index].dev_address = address;

	return 0;
}
ESR_ReturnCode IntArrayListImport(int* value, IntArrayList** self)
{
  ESR_ReturnCode rc;
  IntArrayListImpl* impl;
  
  if (self == NULL)
    return ESR_INVALID_ARGUMENT;
  CHK(rc, IntArrayListCreate(self));
  impl = (IntArrayListImpl*) self;
  impl->contents = value;
  return ESR_SUCCESS;
CLEANUP:
  return rc;
}
Пример #18
0
// check_list
static
void
check_list(const BList &toCheck, const BList &base, const BList &extendedBase,
		   const BList &expected)
{
	// toCheck and extendedBase must have prefix base
	int32 baseCount = base.CountItems();
	for (int32 i = 0; i < baseCount; i++) {
		CHK(base.ItemAt(i) == toCheck.ItemAt(i));
		CHK(base.ItemAt(i) == extendedBase.ItemAt(i));
	}
	// toCheck must have correct size
	int32 toCheckCount = toCheck.CountItems();
	int32 extendedBaseCount = extendedBase.CountItems();
	int32 expectedCount = expected.CountItems();
	CHK(toCheckCount == extendedBaseCount + expectedCount);
	// toCheck must contain all elements of extendedBase and expected
	// (arbitrary order)
	BList list(extendedBase);
	list.AddList((BList*)&expected);
	CHK(contains_list(toCheck, list));
	CHK(contains_list(list, toCheck));
}
Пример #19
0
ESR_ReturnCode SR_EventLog_TokenSize_t(SR_EventLog* self, const LCHAR* token, size_t value)
{
  SR_EventLogImpl *impl = (SR_EventLogImpl *)self;
  ESR_ReturnCode rc;
  LCHAR alpha[MAX_UINT_DIGITS+1];
  size_t size = MAX_INT_DIGITS+1;

  if (impl->logLevel == 0)
    return ESR_SUCCESS;
  CHK(rc, lultostr(value, alpha, &size, 10));
  return self->token(self, token, alpha);
CLEANUP:
  return rc;
}
Пример #20
0
static void open_socket (int port)
{
	struct sockaddr_in my_addr;
	int sock = socket(AF_INET, SOCK_STREAM, 0);
	CHK(sock);
	my_addr.sin_addr.s_addr = htonl(INADDR_ANY);
	my_addr.sin_port = htons(port);
	my_addr.sin_family = AF_INET;
	int optval = 1;
	CHK(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof optval));

	CHK(bind(sock,(struct sockaddr *)&my_addr,sizeof(struct sockaddr_in)));
	CHK(listen(sock,1));
	sockfd = accept(sock,&bot_addr, &bot_addrlen);
	CHK(sockfd);
	close(sock);
	char msg[MAX_MSG_SIZE] ;
	recv(sockfd,msg,MAX_MSG_SIZE,0);
	int wlen = 4;
	if (strncmp(msg, "NAME", wlen) == 0) {
	  mm_botname(msg + wlen + 1,word_len(msg+wlen+1));	
	}
}
Пример #21
0
	void Remove(const Value &value)
	{
		int32 oldCount = Count();
		for (ReferenceIterator it = fReferenceVector.begin();
			 it != fReferenceVector.end();) {
			if (*it == value)
				it = fReferenceVector.erase(it);
			else
				++it;
		}
		int32 newCount = fReferenceVector.size();
		CHK(fMyVector.Remove(value) == oldCount - newCount);
		Check();
	}
Пример #22
0
/*
	BMessageRunner(BMessenger target, const BMessage *message,
				   bigtime_t interval, int32 count)
	@case 2			target is valid, message is NULL, interval > 0, count > 0
	@results		InitCheck() should return B_BAD_VALUE.
					GetInfo() should return B_BAD_VALUE.
 */
void TBMessageRunnerTester::BMessageRunnerA2()
{
// R5: chrashes when passing a NULL message
#ifndef TEST_R5
	MessageRunnerTestApp app(kTesterSignature);
	MessageRunnerTestLooper *looper = app.TestLooper();
	BMessenger target(looper);
	bigtime_t interval = 100000;
	int32 count = 5;
	BMessageRunner runner(target, NULL, interval, count);
	CHK(runner.InitCheck() == B_BAD_VALUE);
	check_message_runner_info(runner, B_BAD_VALUE);
#endif
}
Пример #23
0
/*
	BMessageRunner(BMessenger target, const BMessage *message,
				   bigtime_t interval, int32 count, BMessenger replyTo)
	@case 6			target is valid, message is valid, interval > 0, count == 0
	@results		InitCheck() should return B_ERROR.
					GetInfo() should return B_BAD_VALUE.
 */
void TBMessageRunnerTester::BMessageRunnerB6()
{
	MessageRunnerTestApp app(kTesterSignature);
	MessageRunnerTestLooper *looper = app.TestLooper();
	BMessenger target(looper);
	BMessage message(MSG_RUNNER_MESSAGE);
	bigtime_t interval = 100000;
	int32 count = 0;
	MessageRunnerTestHandler *handler = app.TestHandler();
	BMessenger replyTo(handler);
	BMessageRunner runner(target, &message, interval, count, replyTo);
	CHK(runner.InitCheck() == B_ERROR);
	check_message_runner_info(runner, B_BAD_VALUE);
}
Пример #24
0
/* writting from chunk with SSL */
int chunk_write_SSL(void *chunk, void *ssl)
{
    int n = -1;
#ifdef HAVE_SSL
    if(chunk && ssl && CHK(chunk)->left > 0 && CHK(chunk)->data && CHK(chunk)->end
            && (n = SSL_write(XSSL(ssl), CHK(chunk)->end, CHK(chunk)->left)) > 0)
    {
        CHK(chunk)->left -= n;
        CHK(chunk)->end += n;
    }
#endif
    return n;
}
Пример #25
0
ErrorCode SoftwareBreakpointManager::add(Address const &address,
                                         Lifetime lifetime, size_t size,
                                         Mode mode) {
  if (size < 2 || size > 4) {
    bool isThumb = false;

    //
    // Unless the address specifies the thumb bit,
    // we look at the current CPSR.
    //
    if (address.value() & 1) {
      isThumb = true;
    } else {
      ds2::Architecture::CPUState state;
      CHK(_process->currentThread()->readCPUState(state));
      isThumb = state.isThumb();
    }

    if (isThumb) {
      //
      // The size for breakpoints is counted in bytes, but for the
      // special case of 3 where it indicates a 2x16bit word, this in
      // order to distinguish the 32bit ARM instructions. This semantic
      // is equivalent to the one used by GDB.
      //
      uint32_t insn;
      CHK(_process->readMemory(address.value() & ~1ULL, &insn, sizeof(insn)));
      auto inst_size = Architecture::ARM::GetThumbInstSize(insn);
      size = inst_size == Architecture::ARM::ThumbInstSize::TwoByteInst ? 2 : 3;
    } else {
      size = 4;
    }
  }

  return super::add(address.value() & ~1ULL, lifetime, size, mode);
}
Пример #26
0
int parse_args(char** cmdline, ATERM *funcname, ATERM *args,int *arg_len) {
  char *str;
  int arg;
  *arg_len = 0;
  CHK((str = strsep(cmdline,"(")) == NULL);
  mk_atom(*funcname,str,strlen(str));

  while (*arg_len < 10 &&
	  (str = strsep(cmdline, ",)")) != NULL) {
    sscanf(str,"%d",&arg);
    *(args+*arg_len) = mk_num((double)arg);
    (*arg_len)++;
  }
  return 0;
}
Пример #27
0
int foo(const char *path)
{
  int fd,err,rank;
  unsigned int sum,value;
  struct stat64 st;

  if (MPI_Comm_rank) { 
    err = MPI_Comm_rank(MPI_COMM_WORLD,&rank);CHK(err); 
  } 
  else rank = -1;
    
  fd = __collfs_open(path,O_RDONLY);
  if (fd < 0) ERR("[%d] open(\"%s\",O_RDONLY) failed",rank,path);
  sum = 0;

  err = __collfs_lseek(fd,0,SEEK_SET); CHK(err);

  long pagesize;
  char* pa;
  pagesize = sysconf(_SC_PAGESIZE);
  pa = __collfs_mmap((void *)0,pagesize,PROT_READ,MAP_PRIVATE,fd,(off_t)0);
  if (pa == MAP_FAILED) ERR("[%d] mmap(%d,pagesize) failed",rank,fd);

  while (__collfs_libc_read(fd,&value,sizeof value) == sizeof value) {
    sum ^= value;
  }

  err = __collfs_munmap(pa,pagesize); CHK(err);

  err = __collfs_close(fd); CHK(err);
  printf("[%d] XOR-sum of \"%s\": %x\n",rank,path,sum);

  err = __collfs_xstat64(_STAT_VER, path, &st);CHK(err);
  printf("[%d] %s (via __collfs_xstat64): inode %ld size %ld\n", rank, path, (long)st.st_ino, (long)st.st_size);
  return 0;
}
Пример #28
0
/*
	BMessageRunner(BMessenger target, const BMessage *message,
				   bigtime_t interval, int32 count, BMessenger replyTo)
	@case 5			target is valid, message is valid,
					interval == LONGLONG_MAX, count > 0
	@results		InitCheck() should return B_OK.
					GetInfo() should return B_OK.
					No message should be delivered.
 */
void TBMessageRunnerTester::BMessageRunnerB5()
{
// R5: doesn't behave very well. In worst case registrar time loop gets
// locked up and system wide message runners don't get messages anymore.
#ifndef TEST_R5
	MessageRunnerTestApp app(kTesterSignature);
	MessageRunnerTestLooper *looper = app.TestLooper();
	BMessenger target(looper);
	BMessage message(MSG_RUNNER_MESSAGE);
	bigtime_t interval = LONGLONG_MAX;
	int32 count = 5;
	MessageRunnerTestHandler *handler = app.TestHandler();
	BMessenger replyTo(handler);
	BMessageRunner runner(target, &message, interval, count, replyTo);
	bigtime_t startTime = system_time();
	CHK(runner.InitCheck() == B_OK);
	interval = max(interval, kMinTimeInterval);
	check_message_runner_info(runner, B_OK, interval, count);
	snooze(10000);
	CHK(looper->CheckMessages(startTime, interval, 0));
	CHK(app.CountReplies() == 0);
	CHK(handler->CountReplies() == 0);
#endif
}
Пример #29
0
int main(void)
{
    int N,w,h,x1,y1,x2,y2,dx1,dx2,step,best,v;
    
    scanf("%d",&N);
    while (N--) {
        scanf("%d %d",&w,&h);
        for(y1=0;y1<h;y1++) {
            scanf("%s",map[y1]);
            
        }
        memset(m,-1,sizeof m);
        m[0][0][0]=map[0][0]=='*';
        for(step=1;step<w+h-1;step++)
            for(x1=0;x1<=step;x1++)
                for(x2=x1;x2<=step;x2++) {
                    y1=step-x1;
                    y2=step-x2;
                    best=-1;
                    if (!CHK(x1,y1) || !CHK(x2,y2)) continue;
                    for(dx1=0;dx1<2;dx1++)
                        for(dx2=0;dx2<2;dx2++)
                            if (CHK(x1-dx1,y1-!dx1) && CHK(x2-dx2,y2-!dx2)) {
                                v=m[step-1][x1-dx1][x2-dx2];
                                if(v==-1)continue;
                                if (v>best) best=v;
                            }
                    v=(map[y1][x1]=='*')+(map[y2][x2]=='*');
                    if (v==2 && x1==x2) v=1;
                    m[step][x1][x2]=best+v;
                }
        
        printf("%d\n",m[w+h-2][w-1][w-1]);
    }
    return 0;
}
Пример #30
0
/* initialize chunk file */
int chunk_file(void *chunk, char *file, off_t offset, off_t len)
{
    if(chunk && file && offset >= 0 && len > 0)
    {
        CHK(chunk)->type = CHUNK_FILE;
        CHK(chunk)->status = CHUNK_STATUS_ON;
        CHK(chunk)->size = CHK(chunk)->left = len;
        CHK(chunk)->offset = offset;
        CHK(chunk)->ndata = 0;
        strcpy(CHK(chunk)->filename, file);
        return 0;
    }
    return -1;
}