예제 #1
0
/*
 * Handle a gru_mesq failure. Some of these failures are software recoverable
 * or retryable.
 */
static int send_message_failure(void *cb, struct gru_message_queue_desc *mqd,
				void *mesg, int lines)
{
	int substatus, ret = 0;

	substatus = gru_get_cb_message_queue_substatus(cb);
	switch (substatus) {
	case CBSS_NO_ERROR:
		STAT(mesq_send_unexpected_error);
		ret = MQE_UNEXPECTED_CB_ERR;
		break;
	case CBSS_LB_OVERFLOWED:
		STAT(mesq_send_lb_overflow);
		ret = MQE_CONGESTION;
		break;
	case CBSS_QLIMIT_REACHED:
		STAT(mesq_send_qlimit_reached);
		ret = send_message_queue_full(cb, mqd, mesg, lines);
		break;
	case CBSS_AMO_NACKED:
		STAT(mesq_send_amo_nacked);
		ret = MQE_CONGESTION;
		break;
	case CBSS_PUT_NACKED:
		STAT(mesq_send_put_nacked);
		ret = send_message_put_nacked(cb, mqd, mesg, lines);
		break;
	case CBSS_PAGE_OVERFLOW:
		STAT(mesq_page_overflow);
		/* fallthru */
	default:
		BUG();
	}
	return ret;
}
예제 #2
0
static inline int NCR5380_pwrite(struct Scsi_Host *instance, unsigned char *addr,
              int len)
{
  int iobase = instance->io_port;
printk("writing %p len %d\n",addr, len);
  if(!len) return -1;

  while(1)
  {
    int status;
    while(((status = STAT(iobase)) & 0x100)==0);
  }
}
예제 #3
0
/*
 * Lock & load the kernel context for the specified blade.
 */
static struct gru_blade_state *gru_lock_kernel_context(int blade_id)
{
	struct gru_blade_state *bs;

	STAT(lock_kernel_context);
	bs = gru_base[blade_id];

	down_read(&bs->bs_kgts_sema);
	if (!bs->bs_kgts || !bs->bs_kgts->ts_gru)
		gru_load_kernel_context(bs, blade_id);
	return bs;

}
예제 #4
0
BOOL drive_file_query_information(DRIVE_FILE* file, UINT32 FsInformationClass, wStream* output)
{
	struct STAT st;

	if (STAT(file->fullpath, &st) != 0)
	{
		Stream_Write_UINT32(output, 0); /* Length */
		return FALSE;
	}

	switch (FsInformationClass)
	{
		case FileBasicInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232094.aspx */
			Stream_Write_UINT32(output, 36); /* Length */
			Stream_EnsureRemainingCapacity(output, 36);
			Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
			Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */
			Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */
			Stream_Write_UINT64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */
			Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			/* Reserved(4), MUST NOT be added! */
			break;

		case FileStandardInformation:
			/*  http://msdn.microsoft.com/en-us/library/cc232088.aspx */
			Stream_Write_UINT32(output, 22); /* Length */
			Stream_EnsureRemainingCapacity(output, 22);
			Stream_Write_UINT64(output, st.st_size); /* AllocationSize */
			Stream_Write_UINT64(output, st.st_size); /* EndOfFile */
			Stream_Write_UINT32(output, st.st_nlink); /* NumberOfLinks */
			Stream_Write_UINT8(output, file->delete_pending ? 1 : 0); /* DeletePending */
			Stream_Write_UINT8(output, file->is_dir ? 1 : 0); /* Directory */
			/* Reserved(2), MUST NOT be added! */
			break;

		case FileAttributeTagInformation:
			/* http://msdn.microsoft.com/en-us/library/cc232093.aspx */
			Stream_Write_UINT32(output, 8); /* Length */
			Stream_EnsureRemainingCapacity(output, 8);
			Stream_Write_UINT32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
			Stream_Write_UINT32(output, 0); /* ReparseTag */
			break;

		default:
			Stream_Write_UINT32(output, 0); /* Length */
			DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass);
			return FALSE;
	}
	return TRUE;
}
예제 #5
0
파일: disk_file.c 프로젝트: kingiol/FreeRDP
boolean disk_file_query_information(DISK_FILE* file, uint32 FsInformationClass, STREAM* output)
{
    struct STAT st;

    if (STAT(file->fullpath, &st) != 0)
    {
        stream_write_uint32(output, 0); /* Length */
        return false;
    }
    switch (FsInformationClass)
    {
    case FileBasicInformation:
        /* http://msdn.microsoft.com/en-us/library/cc232094.aspx */
        stream_write_uint32(output, 36); /* Length */
        stream_check_size(output, 36);
        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* CreationTime */
        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_atime)); /* LastAccessTime */
        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_mtime)); /* LastWriteTime */
        stream_write_uint64(output, FILE_TIME_SYSTEM_TO_RDP(st.st_ctime)); /* ChangeTime */
        stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
        /* Reserved(4), MUST NOT be added! */
        break;

    case FileStandardInformation:
        /*  http://msdn.microsoft.com/en-us/library/cc232088.aspx */
        stream_write_uint32(output, 22); /* Length */
        stream_check_size(output, 22);
        stream_write_uint64(output, st.st_size); /* AllocationSize */
        stream_write_uint64(output, st.st_size); /* EndOfFile */
        stream_write_uint32(output, st.st_nlink); /* NumberOfLinks */
        stream_write_uint8(output, file->delete_pending ? 1 : 0); /* DeletePending */
        stream_write_uint8(output, file->is_dir ? 1 : 0); /* Directory */
        /* Reserved(2), MUST NOT be added! */
        break;

    case FileAttributeTagInformation:
        /* http://msdn.microsoft.com/en-us/library/cc232093.aspx */
        stream_write_uint32(output, 8); /* Length */
        stream_check_size(output, 8);
        stream_write_uint32(output, FILE_ATTR_SYSTEM_TO_RDP(file, st)); /* FileAttributes */
        stream_write_uint32(output, 0); /* ReparseTag */
        break;

    default:
        stream_write_uint32(output, 0); /* Length */
        DEBUG_WARN("invalid FsInformationClass %d", FsInformationClass);
        return false;
    }
    return true;
}
예제 #6
0
/*
 * Our WinPcap send function.
 * Not sure if partial writes are possible with NPF. Retry if rc != length.
 */
int pkt_send (const void *tx, int length)
{
  const ADAPTER *adapter;
  PACKET pkt;
  int    tx_cnt, rc = 0;

  ASSERT_PKT_INF (0);

  adapter = (const ADAPTER*) _pkt_inf->adapter;

  PROFILE_START ("pkt_send");

  for (tx_cnt = 1 + pkt_txretries; tx_cnt > 0; tx_cnt--)
  {
    pkt.Buffer = (void*) tx;
    pkt.Length = length;
    if (PacketSendPacket (adapter, &pkt, TRUE))
    {
      rc = length;
      break;
    }
    STAT (macstats.num_tx_retry++);
  }

  if (rc == length)
  {
    num_tx_pkt++;
    num_tx_bytes += length;
  }
  else
  {
    num_tx_errors++;  /* local copy */
    STAT (macstats.num_tx_err++);
  }
  PROFILE_STOP();
  return (rc);
}
예제 #7
0
/*
 * Send a message to a message queue
 * 	mqd	message queue descriptor
 * 	mesg	message. ust be vaddr within a GSEG
 * 	bytes	message size (<= 2 CL)
 */
int gru_send_message_gpa(struct gru_message_queue_desc *mqd, void *mesg,
				unsigned int bytes)
{
	struct message_header *mhdr;
	void *cb;
	void *dsr;
	int istatus, clines, ret;

	STAT(mesq_send);
	BUG_ON(bytes < sizeof(int) || bytes > 2 * GRU_CACHE_LINE_BYTES);

	clines = DIV_ROUND_UP(bytes, GRU_CACHE_LINE_BYTES);
	if (gru_get_cpu_resources(bytes, &cb, &dsr))
		return MQE_BUG_NO_RESOURCES;
	memcpy(dsr, mesg, bytes);
	mhdr = dsr;
	mhdr->present = MQS_FULL;
	mhdr->lines = clines;
	if (clines == 2) {
		mhdr->present2 = get_present2(mhdr);
		restore_present2(mhdr, MQS_FULL);
	}

	do {
		ret = MQE_OK;
		gru_mesq(cb, mqd->mq_gpa, gru_get_tri(mhdr), clines, IMA);
		istatus = gru_wait(cb);
		if (istatus != CBS_IDLE)
			ret = send_message_failure(cb, mqd, dsr, clines);
	} while (ret == MQIE_AGAIN);
	gru_free_cpu_resources(cb, dsr);

	if (ret)
		STAT(mesq_send_failed);
	return ret;
}
예제 #8
0
uint64_t ffsb_get_filesize(char *name)
{
#ifndef HAVE_STAT64
 #define STAT(a, b) do { stat((a), (b)); } while (0)
	struct stat filestat;
#else
 #define STAT(a, b) do { stat64((a), (b)); } while (0)
	struct stat64 filestat;
#endif


	STAT(name, &filestat);
	return (uint64_t)filestat.st_size;
#undef STAT
}
예제 #9
0
STAT Setup::getHighestAbility(std::vector<STAT> stats) {
	unsigned int max_value = 0;
	for (unsigned int i = 0; i < NUM_STAT; i++) {
		for (unsigned int j = 0; j < stats.size(); j++) {
			if (stats[j] == STAT(i)) max_value = std::max(max_value, this->getMax(stats[j]));
		}
	}
	if (max_value == getMax(STR)) return STR;
	else if (max_value == getMax(STA)) return STA;
	else if (max_value == getMax(AGI)) return AGI;
	else if (max_value == getMax(SEN)) return SEN;
	else if (max_value == getMax(INT)) return INT;
	else if (max_value == getMax(PSY)) return PSY;
	else return NUM_STAT;
}
예제 #10
0
/*
 * Copy a block of data using the GRU resources
 */
int gru_copy_gpa(unsigned long dest_gpa, unsigned long src_gpa,
				unsigned int bytes)
{
	void *cb;
	void *dsr;
	int ret;

	STAT(copy_gpa);
	if (gru_get_cpu_resources(GRU_NUM_KERNEL_DSR_BYTES, &cb, &dsr))
		return MQE_BUG_NO_RESOURCES;
	gru_bcopy(cb, src_gpa, dest_gpa, gru_get_tri(dsr),
		  XTYPE_B, bytes, GRU_NUM_KERNEL_DSR_CL, IMA);
	ret = gru_wait(cb);
	gru_free_cpu_resources(cb, dsr);
	return ret;
}
예제 #11
0
FskErr KplFileGetFileInfo(const char *fullPath, KplFileInfo *itemInfo) {
	int err;
	STATTYPE statbuf;

	err = sCheckFullPath(fullPath, kKplPathIsAny);
	if (err) return err;

	err = STAT(fullPath, &statbuf);
	if (err == -1) return errnoToFskErr(errno);

	GetFileInfoFromStat(&statbuf, itemInfo);

	itemInfo->flags = 0;

	return kFskErrNone;
}
예제 #12
0
파일: gcd.c 프로젝트: SRI-CSL/libpoly
void coefficient_lcm(const lp_polynomial_context_t* ctx, coefficient_t* lcm, const coefficient_t* C1, const coefficient_t* C2) {
  TRACE("coefficient", "coefficient_lcm()\n");
  STAT(coefficient, lcm) ++;

  if (trace_is_enabled("coefficient")) {
    tracef("C1 = "); coefficient_print(ctx, C1, trace_out); tracef("\n");
    tracef("C2 = "); coefficient_print(ctx, C2, trace_out); tracef("\n");
  }

  assert(ctx->K == lp_Z);

  if (C1->type == COEFFICIENT_NUMERIC && C2->type == COEFFICIENT_NUMERIC) {
    // Integer LCM
    if (lcm->type == COEFFICIENT_POLYNOMIAL) {
      coefficient_destruct(lcm);
      coefficient_construct(ctx, lcm);
    }
    integer_lcm_Z(&lcm->value.num, &C1->value.num, &C2->value.num);
  } else {
    // LCM(C1, C2) = C1*C2/GCD(C1, C2)
    coefficient_t gcd;
    coefficient_construct(ctx, &gcd);
    coefficient_gcd(ctx, &gcd, C1, C2);
    if (coefficient_is_one(ctx, &gcd)) {
      coefficient_mul(ctx, lcm, C1, C2);
    } else {
      if (coefficient_cmp_type(ctx, C1, C2) <= 0) {
        coefficient_div(ctx, lcm, C1, &gcd);
        coefficient_mul(ctx, lcm, lcm, C2);
      } else {
        coefficient_div(ctx, lcm, C2, &gcd);
        coefficient_mul(ctx, lcm, lcm, C1);
      }
    }
    if (coefficient_lc_sgn(ctx, lcm) < 0) {
      coefficient_neg(ctx, lcm, lcm);
    }
    coefficient_destruct(&gcd);
  }

  if (trace_is_enabled("coefficient")) {
    tracef("coefficient_lcm() => "); coefficient_print(ctx, lcm, trace_out); tracef("\n");
  }

  assert(coefficient_is_normalized(ctx, lcm));
}
예제 #13
0
static void openloghost (void)
{
  struct servent *sp;
  struct hostent *hp;

  if (logSock)
  {
    sock_close (logSock);
    logSock = NULL;
  }

  sp = getservbyname ("syslog", "udp");
  if (sp)
     syslog_port = htons (sp->s_port);

  logHost = _inet_addr (syslog_hostName);
  if (!logHost)
  {
    hp = gethostbyname (syslog_hostName);
    if (!hp)
    {
      fprintf (stderr, "syslog: Unknown host `%s'\n", syslog_hostName);
      return;
    }
    logHost = ntohl (*(DWORD*)hp->h_addr);
  }

  if (!logSock)
  {
    logSock = malloc (sizeof(udp_Socket));
    if (!logSock)
    {
      perror ("syslog");
      return;
    }
  }

  if (!udp_open ((udp_Socket*)logSock, 0, logHost, syslog_port, NULL))
  {
    errno = errno_s = EHOSTUNREACH;  /* "No route to host" (ARP failed) */
    STAT (ipstats.ips_noroute++);
    perror ("syslog");
    sock_close (logSock);
    logSock = NULL;
  }
}
예제 #14
0
파일: l9x.c 프로젝트: EtchedPixels/L9X
static uint8_t getb(uint8_t *p)
{
	uint16_t addr = (uint16_t)p;
	uint8_t ah = addr >> 8;
	uint8_t c;

	if (ah == last_ah) {
		STAT(fast);
		return last_base[addr&0xff];
	}

	/* Find the right buffer */
	c = page_find(ah);
	last_ah = ah;
	last_base = page_cache[c];
	return last_base[addr & 0xff];
}
예제 #15
0
// <mStat>       ->      empty | <stat>  <mStat>
APTNode* MSTAT(void)
{
	if ((strcmp(currentTok.sym, "SCANFtk") == 0) || (strcmp(currentTok.sym, "PRINTFtk") == 0) ||
		(strcmp(currentTok.sym, "IFtk") == 0) || (strcmp(currentTok.sym, "LOOPtk") == 0) ||
		(strcmp(currentTok.sym, "BEGINtk") == 0) || (strcmp(currentTok.sym, "IDtk") == 0))
	{
		//printf("MSTAT node with sym = %s and text = %s \n", currentTok.sym, currentTok.selection);
		APTNode* parentMstatNode = createNonIdAPTNode("<MSTAT>");
		APTNode* statNode = STAT();
		APTNode* childMstatNode = MSTAT();

		addChildNode(parentMstatNode, statNode);
		addChildNode(parentMstatNode, childMstatNode);

		return parentMstatNode;
	} else return NULL;
}
예제 #16
0
/*
 * Load a DW from a global GPA. The GPA can be a memory or MMR address.
 */
int gru_read_gpa(unsigned long *value, unsigned long gpa)
{
	void *cb;
	void *dsr;
	int ret, iaa;

	STAT(read_gpa);
	if (gru_get_cpu_resources(GRU_NUM_KERNEL_DSR_BYTES, &cb, &dsr))
		return MQE_BUG_NO_RESOURCES;
	iaa = gpa >> 62;
	gru_vload_phys(cb, gpa, gru_get_tri(dsr), iaa, IMA);
	ret = gru_wait(cb);
	if (ret == CBS_IDLE)
		*value = *(unsigned long *)dsr;
	gru_free_cpu_resources(cb, dsr);
	return ret;
}
예제 #17
0
파일: filetutils.cpp 프로젝트: proton/ireon
char * ChangeToDir (const char *Dirname)
{
    STRUCT_STAT st;

    if (STAT(Dirname, &st))
    {
        // doen't exist; must create it
        MKDIR (Dirname);
    }
    if (S_ISDIR(st.st_mode) == 0) 
    {
        // it's not a dir, must create a dir
        MKDIR (Dirname);
    }
    char *oldDirname = GetCurrDir ();
    CHDIR(Dirname);
    return oldDirname;
}
예제 #18
0
void FAsyncIOSystemBase::InternalRead( IFileHandle* FileHandle, int64 Offset, int64 Size, void* Dest )
{
	DECLARE_SCOPE_CYCLE_COUNTER(TEXT("FAsyncIOSystemBase::InternalRead"), STAT_AsyncIOSystemBase_InternalRead, STATGROUP_AsyncIO_Verbose);

	FScopeLock ScopeLock( ExclusiveReadCriticalSection );

	STAT(double ReadTime = 0);
	{	
		SCOPE_SECONDS_COUNTER(ReadTime);
		PlatformReadDoNotCallDirectly( FileHandle, Offset, Size, Dest );
	}	
	INC_FLOAT_STAT_BY(STAT_AsyncIO_PlatformReadTime,(float)ReadTime);

	// The platform might actually read more than Size due to aligning and internal min read sizes
	// though we only really care about throttling requested bandwidth as it's not very accurate
	// to begin with.
	STAT(ConstrainBandwidth(Size, ReadTime));
}
예제 #19
0
void
tcp_fasttimo(void)
{
	register struct socket *so;
	register struct tcpcb *tp;

	DEBUG_CALL("tcp_fasttimo");

	so = tcb.so_next;
	if (so)
	for (; so != &tcb; so = so->so_next)
		if ((tp = (struct tcpcb *)so->so_tcpcb) &&
		    (tp->t_flags & TF_DELACK)) {
			tp->t_flags &= ~TF_DELACK;
			tp->t_flags |= TF_ACKNOW;
			STAT(tcpstat.tcps_delack++);
			(void) tcp_output(tp);
		}
}
예제 #20
0
파일: bench_stat.c 프로젝트: HKingz/iLOG3
int bench_stat( long count )
{
    long		l ;
    struct STAT	st ;

    int		nret ;

    for( l = 0 ; l < count ; l++ )
    {
        nret = STAT( PATHFILENAME , & st ) ;
        if( nret )
        {
            printf( "stat failed[%d] , errno[%d]\n" , nret , errno );
            return -1;
        }
    }

    return 0;
}
예제 #21
0
/**
 * Start a directory scanner thread.
 *
 * @param filename name of the directory to scan
 * @param disable_extractor GNUNET_YES to not to run libextractor on files (only build a tree)
 * @param ex if not NULL, must be a list of extra plugins for extractor
 * @param cb the callback to call when there are scanning progress messages
 * @param cb_cls closure for 'cb'
 * @return directory scanner object to be used for controlling the scanner
 */
struct GNUNET_FS_DirScanner *
GNUNET_FS_directory_scan_start (const char *filename,
				int disable_extractor, const char *ex,
				GNUNET_FS_DirScannerProgressCallback cb, 
				void *cb_cls)
{
  struct stat sbuf;
  char *filename_expanded;
  struct GNUNET_FS_DirScanner *ds;

  if (0 != STAT (filename, &sbuf))
    return NULL;
  filename_expanded = GNUNET_STRINGS_filename_expand (filename);
  if (NULL == filename_expanded)
    return NULL;
  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
	      "Starting to scan directory `%s'\n",
	      filename_expanded);
  ds = GNUNET_malloc (sizeof (struct GNUNET_FS_DirScanner));
  ds->progress_callback = cb;
  ds->progress_callback_cls = cb_cls;
  ds->filename_expanded = filename_expanded;
  if (disable_extractor)  
    ds->ex_arg = GNUNET_strdup ("-");
  else 
    ds->ex_arg = (NULL != ex) ? GNUNET_strdup (ex) : NULL;
  ds->args[0] = "gnunet-helper-fs-publish";
  ds->args[1] = ds->filename_expanded;
  ds->args[2] = ds->ex_arg;
  ds->args[3] = NULL;
  ds->helper = GNUNET_HELPER_start (GNUNET_NO,
				    "gnunet-helper-fs-publish",
				    ds->args,
				    &process_helper_msgs,
				    &helper_died_cb, ds);
  if (NULL == ds->helper)
    {
    GNUNET_free (filename_expanded);
    GNUNET_free (ds);
    return NULL;
  }
  return ds;
}
예제 #22
0
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
              int len)
{
  int iobase = instance->io_port;
  int iobase2= instance->io_port + 0x100;
  unsigned char *start = addr;
  int s;
printk("reading %p len %d\n",addr, len);
  outb(inb(iobase + 128), iobase + 135);
  while(len > 0)
  {
    int status,b,i, timeout;
    timeout = 0x07FFFFFF;
    while(((status = STAT(iobase)) & 0x100)==0)
    {
      timeout--;
      if(status & 0x200 || !timeout)
      {
        printk("status = %p\n",status);
        outb(0, iobase + 135);
        return 1;
      }
    }
    if(len >= 128)
    {
      for(i=0; i<64; i++)
      {
        b = inw(iobase + 136);
        *addr++ = b;
        *addr++ = b>>8;
      }
      len -= 128;
    }
    else
    {
      b = inw(iobase + 136);
      *addr ++ = b;
      len -= 1;
      if(len)
        *addr ++ = b>>8;
      len -= 1;
    }
  }
void COptionsStats::OnRemoveAll() 
{
	if(MessageBox(theApp.m_Language.GetString("Remove_All", "This will remove all Copy Entries!\n\nContinue?"), _T("Warning"), MB_YESNO) == IDYES)
	{
		if( DeleteAllIDs() )
		{
			m_eSavedCopies.Empty();
			m_eSavedCopyData.Empty();

			struct _stat buf;
			int nResult;
			nResult = STAT(GetDBName(), &buf);
			if(nResult == 0)
				m_eDatabaseSize.Format(_T("%d KB"), (buf.st_size/1024));

			UpdateData(FALSE);
		}
	}
}
예제 #24
0
/*
 * Reload the blade's kernel context into a GRU chiplet. Called holding
 * the bs_kgts_sema for READ. Will steal user contexts if necessary.
 */
static void gru_load_kernel_context(struct gru_blade_state *bs, int blade_id)
{
	struct gru_state *gru;
	struct gru_thread_state *kgts;
	void *vaddr;
	int ctxnum, ncpus;

	up_read(&bs->bs_kgts_sema);
	down_write(&bs->bs_kgts_sema);

	if (!bs->bs_kgts) {
		do {
			bs->bs_kgts = gru_alloc_gts(NULL, 0, 0, 0, 0, 0);
			if (!IS_ERR(bs->bs_kgts))
				break;
			msleep(1);
		} while (true);
		bs->bs_kgts->ts_user_blade_id = blade_id;
	}
	kgts = bs->bs_kgts;

	if (!kgts->ts_gru) {
		STAT(load_kernel_context);
		ncpus = uv_blade_nr_possible_cpus(blade_id);
		kgts->ts_cbr_au_count = GRU_CB_COUNT_TO_AU(
			GRU_NUM_KERNEL_CBR * ncpus + bs->bs_async_cbrs);
		kgts->ts_dsr_au_count = GRU_DS_BYTES_TO_AU(
			GRU_NUM_KERNEL_DSR_BYTES * ncpus +
				bs->bs_async_dsr_bytes);
		while (!gru_assign_gru_context(kgts)) {
			msleep(1);
			gru_steal_context(kgts);
		}
		gru_load_context(kgts);
		gru = bs->bs_kgts->ts_gru;
		vaddr = gru->gs_gru_base_vaddr;
		ctxnum = kgts->ts_ctxnum;
		bs->kernel_cb = get_gseg_base_address_cb(vaddr, ctxnum, 0);
		bs->kernel_dsr = get_gseg_base_address_ds(vaddr, ctxnum, 0);
	}
	downgrade_write(&bs->bs_kgts_sema);
}
예제 #25
0
	/**
	 * Minimal initialization constructor.
	 * @param InOwner - The UTextureCube which this FTextureCubeResource represents.
	 */
	FTextureCubeResource(UTextureCube* InOwner)
	:	Owner(InOwner)
	,	TextureSize(0)
	{
		//Initialize the MipData array
		for ( int32 FaceIndex=0;FaceIndex<6; FaceIndex++)
		{
			for( int32 MipIndex=0; MipIndex<ARRAY_COUNT(MipData[FaceIndex]); MipIndex++ )
			{
				MipData[FaceIndex][MipIndex] = NULL;
			}
		}

		check(Owner->GetNumMips() > 0);

		TIndirectArray<FTexture2DMipMap>& Mips = InOwner->PlatformData->Mips;
		for( int32 MipIndex=0; MipIndex<Mips.Num(); MipIndex++ )
		{
			FTexture2DMipMap& Mip = Mips[MipIndex];
			if( Mip.BulkData.GetBulkDataSize() <= 0 )
			{
				UE_LOG(LogTexture, Error, TEXT("Corrupt texture [%s]! Missing bulk data for MipIndex=%d"),*InOwner->GetFullName(),MipIndex );
			}
			else			
			{
				TextureSize += Mip.BulkData.GetBulkDataSize();
				uint32 MipSize = Mip.BulkData.GetBulkDataSize() / 6;

				uint8* In = (uint8*)Mip.BulkData.Lock(LOCK_READ_ONLY);

				for(uint32 Face = 0; Face < 6; ++Face)
				{
					MipData[Face][MipIndex] = FMemory::Malloc(MipSize);
					FMemory::Memcpy(MipData[Face][MipIndex], In + MipSize * Face, MipSize);
				}

				Mip.BulkData.Unlock();
			}
		}
		STAT( LODGroupStatName = TextureGroupStatFNames[InOwner->LODGroup] );
	}
예제 #26
0
/*
 * Handle SOCK_DGRAM connection. Always blocking in _arp_resolve()
 */
static int udp_connect (Socket *socket)
{
#if defined(USE_IPV6)
  if (socket->so_family == AF_INET6)
  {
    const struct sockaddr_in6 *la = (const struct sockaddr_in6*) socket->local_addr;
    const struct sockaddr_in6 *ra = (const struct sockaddr_in6*) socket->remote_addr;

    if (!_UDP6_open (socket, &ra->sin6_addr, la->sin6_port, ra->sin6_port))
    {
      SOCK_DEBUGF ((", no route (udp6)"));
      SOCK_ERRNO (EHOSTUNREACH);
      STAT (ip6stats.ip6s_noroute++);
      return (-1);
    }
  }
  else
#endif
  if (!_UDP_open (socket,
                  socket->remote_addr->sin_addr,
                  socket->local_addr->sin_port,
                  socket->remote_addr->sin_port))
  {
    /* errno already set in udp_open() */
    SOCK_DEBUGF ((", %s", socket->udp_sock->err_msg));
    return (-1);
  }

  if ((socket->so_state & SS_PRIV) && socket->bcast_pool)
  {
    /* undo what udp_open() did above.
     * !!Fix me: clears recv data.
     */
    sock_recv_init ((sock_type*)socket->udp_sock,
                    socket->bcast_pool, socket->pool_size);
  }

  socket->so_state &= ~SS_UNCONNECTED;
  socket->so_state |=  SS_ISCONNECTED;
  return (0);
}
예제 #27
0
static struct gru_blade_state *gru_lock_kernel_context(int blade_id)
{
	struct gru_blade_state *bs;
	int bid;

	STAT(lock_kernel_context);
again:
	bid = blade_id < 0 ? uv_numa_blade_id() : blade_id;
	bs = gru_base[bid];

	/*                                                                     */
	down_read(&bs->bs_kgts_sema);
	if (blade_id < 0 && bid != uv_numa_blade_id()) {
		up_read(&bs->bs_kgts_sema);
		goto again;
	}
	if (!bs->bs_kgts || !bs->bs_kgts->ts_gru)
		gru_load_kernel_context(bs, bid);
	return bs;

}
예제 #28
0
/*
 * Lock & load the kernel context for the specified blade.
 */
static struct gru_blade_state *gru_lock_kernel_context(int blade_id)
{
	struct gru_blade_state *bs;
	int bid;

	STAT(lock_kernel_context);
again:
	bid = blade_id < 0 ? uv_numa_blade_id() : blade_id;
	bs = gru_base[bid];

	/* Handle the case where migration occurred while waiting for the sema */
	down_read(&bs->bs_kgts_sema);
	if (blade_id < 0 && bid != uv_numa_blade_id()) {
		up_read(&bs->bs_kgts_sema);
		goto again;
	}
	if (!bs->bs_kgts || !bs->bs_kgts->ts_gru)
		gru_load_kernel_context(bs, bid);
	return bs;

}
예제 #29
0
QString QDir::currentDirPath()
{
    QString result;

    STATBUF st;
    if ( STAT( ".", &st ) == 0 ) {
	char currentName[PATH_MAX];
	if ( GETCWD( currentName, PATH_MAX ) != 0 )
	    result = QFile::decodeName(currentName);
#if defined(DEBUG)
	if ( result.isNull() )
	    qWarning( "QDir::currentDirPath: getcwd() failed" );
#endif
    } else {
#if defined(DEBUG)
	qWarning( "QDir::currentDirPath: stat(\".\") failed" );
#endif
    }
    slashify( result );
    return result;
}
예제 #30
0
static inline int NCR5380_pread(struct Scsi_Host *instance, unsigned char *addr,
              int len)
{
  int iobase = instance->io_port;
printk("reading %p len %d\n", addr, len);
  while(len > 0)
  {
    int status, timeout;
    unsigned long b;
    
    timeout = 0x01FFFFFF;
    
    while(((status = STAT(iobase)) & 0x100)==0)
    {
      timeout--;
      if(status & 0x200 || !timeout)
      {
        printk("status = %08X\n",status);
        return 1;
      }
    }
    if(len >= 128)
    {
      inswb(iobase + 136, addr, 128);
      addr += 128;
      len -= 128;
    }
    else
    {
      b = (unsigned long) inw(iobase + 136);
      *addr ++ = b;
      len -= 1;
      if(len)
        *addr ++ = b>>8;
      len -= 1;
    }
  }
  return 0;
}