Beispiel #1
0
void loop(void* arg) {
  int (*test)(int, int) = (int (*)(int, int))arg;
  int i, j;
  int res;
  //communicator_t* loc_com = &comm;
  communicator_t* loc_com = &comm_world;
  //if (test == barrier_master || test == barrier_slave ||
  //    test == broadcast_master || test == broadcast_slave) {
  //  loc_com = &comm_world;
  //}
  //communicator_t stack_com;
  //stack_com.barrier_set = loc_com->barrier_set;
  //for(int i = 0; i < loc_com->count; i++) {
  //  stack_com.addr[i] = loc_com->addr[i];
  //}
  //stack_com.count = loc_com->count;
  //stack_com.msg_size = loc_com->msg_size;
  DEBUGGER("Initial test run\n");
  /* Allow routing/cache setup ahead of time */
  test(1,1024);
  DEBUGGER("Initial test run done\n");
  for( i=0; i < num_sizes; i++){
    if (flush & FLUSH_BETWEEN_SIZES)
      {
      inval_dcache();
      inval_mcache();
    }
    for( j=1; j <= repeat_count; j++){
      if (flush & FLUSH_BETWEEN_REPEATS) {
        inval_dcache();
        inval_mcache();
      }
      mp_barrier(loc_com);
      //mp_barrier(&stack_com);
      res = test(iterations, sizes[i]);
      my_two_printf("%u\t%i\n",sizes[i],res);
      mp_barrier(loc_com);
      //mp_barrier(&stack_com);
    }
  }

	inval_dcache();
	inval_mcache();

  if(get_cpuid() != 0){
    int ret = 0;
    corethread_exit(&ret);
  }
  return;

}
Beispiel #2
0
void panic(char *reason)
{
    kprintf("");
    kprintf("PANIC: %s",reason);    
	DEBUGGER();
    asm("hlt");    
}
Beispiel #3
0
TTrackerState::TTrackerState(const TTrackerState&)
	:
	Settings("", ""),
	fShowDisksIcon(NULL),
	fMountVolumesOntoDesktop(NULL),
	fDesktopFilePanelRoot(NULL),
	fMountSharedVolumesOntoDesktop(NULL),
	fEjectWhenUnmounting(NULL),
	fShowFullPathInTitleBar(NULL),
	fSingleWindowBrowse(NULL),
	fShowNavigator(NULL),
	fShowSelectionWhenInactive(NULL),
	fTransparentSelection(NULL),
	fSortFolderNamesFirst(NULL),
	fHideDotFiles(NULL),
	fTypeAheadFiltering(NULL),
	fRecentApplicationsCount(NULL),
	fRecentDocumentsCount(NULL),
	fRecentFoldersCount(NULL),
	fShowVolumeSpaceBar(NULL),
	fUsedSpaceColor(NULL),
	fFreeSpaceColor(NULL),
	fWarningSpaceColor(NULL),
	fDontMoveFilesToTrash(NULL),
	fAskBeforeDeleteFile(NULL),
	fInited(false),
	fSettingsLoaded(false)
{
	// Placeholder copy constructor to prevent others from accidentally using
	// the default copy constructor.  Note, the DEBUGGER call is for the off
	// chance that a TTrackerState method (or friend) tries to make a copy.
	DEBUGGER("Don't make a copy of this!");
}
Beispiel #4
0
void
BeOSCanvas::InitBufferBitmap( void )
{
    bool needToUnlock = false;
    if ( m_canvasView && m_canvasView->Window() )
    {
        if ( !( needToUnlock = m_canvasView->LockLooper() ) )
        {
            DEBUGGER( "Geez, LockLooper failed" );
        }
    }

    if ( m_pBufferBitmap )
    {
        delete m_pBufferBitmap;
    }

    m_pBufferBitmap = new BeOSBitmap(
                        m_oBGRect.Width(),
                        m_oBGRect.Height(),
                        string( "BufferBitmap" ),
                        true // has offscreen BView for text rendering
                        );
    m_pBufferBitmap->BlitRect( m_pBGBitmap, m_oBGRect, m_oBGRect );

    if ( m_canvasView )
    {
        m_canvasView->SetCanvasBitmap( m_pBufferBitmap->GetBBitmap() );
        if ( needToUnlock )
        {
            m_canvasView->UnlockLooper();
        }
    }
}
Beispiel #5
0
void AudioFilterNode::SetParameterValue(
	int32												id,
	bigtime_t										changeTime,
	const void*									value,
	size_t											size) {

	// not running? set parameter now
	if(RunState() != B_STARTED) {
		ASSERT(m_parameterSet);
		m_parameterSet->setValue(
			id,
			changeTime,
			value,
			size);
		return;
	}
	
	// queue a parameter-change event

	if(size > 64) { // +++++ hard-coded limitation in media_timed_event
		DEBUGGER((
			"!!! AudioFilterNode::SetParameterValue(): parameter data too large\n"));
	}
	
	media_timed_event ev(
		changeTime,
		BTimedEventQueue::B_PARAMETER,
		0,
		BTimedEventQueue::B_NO_CLEANUP,
		size,
		id,
		(char*)value, size);
	EventQueue()->AddEvent(ev);	
}
Beispiel #6
0
TTrackerState::TTrackerState(const TTrackerState&)
	:	Settings("", "")
{
	// Placeholder copy constructor to prevent others from accidentally using the
	// default copy constructor.  Note, the DEBUGGER call is for the off chance that
	// a TTrackerState method (or friend) tries to make a copy.
	DEBUGGER("Don't make a copy of this!");
}
Beispiel #7
0
uint64	STCOAtom::getOffsetForChunk(uint32 pChunkID)
{
	// First chunk is first array entry
	if ((pChunkID > 0) && (pChunkID <= theHeader.NoEntries)) {
		return theChunkToOffsetArray[pChunkID - 1]->Offset;
	}
	
	#if DEBUG
	  char msg[100]; sprintf(msg, "Bad Chunk ID %ld / %ld\n", pChunkID, theHeader.NoEntries);
	  DEBUGGER(msg);
	#endif

	TRESPASS();
	return 0LL;
}
Beispiel #8
0
uint64
STCOAtom::GetOffsetForChunk(uint32 pChunkIndex)
{
	// Chunk Indexes start at 1 
	if ((pChunkIndex > 0) && (pChunkIndex <= theHeader.NoEntries)) {
		return theChunkToOffsetArray[pChunkIndex - 1]->Offset;
	}
	
#ifdef DEBUG
	char msg[100]; sprintf(msg, "Bad Chunk ID %ld / %ld\n", pChunkIndex,
		theHeader.NoEntries);
	DEBUGGER(msg);
#endif

	TRESPASS();
	return 0LL;
}
Beispiel #9
0
void Semaphore::Wait()
{
	status_t	err;
#if SEM_DEBUG
	int32		tc;
	get_sem_count( mutex, &tc );
	PRINT(( "Semaphore::Wait:id(%d):count(%d)\n", mutex, tc ));
#endif
	if ( ( err = acquire_sem( mutex ) ) < B_NO_ERROR )
	{
		puts( "Sem::Wait:couldn't acquire sem" );
		DEBUGGER(( "Semaphore::Wait: couldn't acquire sem : %s\n",
					strerror( err ) ));
	}
#if SEM_DEBUG
	get_sem_count( mutex, &tc );
	PRINT(( "Semaphore::Wait:id(%d):count(%d) done\n", mutex, tc ));
#endif
}
Beispiel #10
0
void mp_send_size(mpd_t* mpd_ptr, int bytes) {
	int k = 0;
	while(k < bytes) {
      int chunk = 0;
      if ( bytes-k >= mpd_ptr->buf_size) {
          // If the remaining data is more than the size of the buffer
          chunk = mpd_ptr->buf_size;   
      } else {
          // The remaining data all fits in a buffer
          chunk = bytes-k;
      }
      // Copy the chunk of data to the write buffer
    //  for (int j = 0; j < chunk; ++j) {
    //      *((volatile char _SPM *)m2s.write_buf+j) = send_data[k+j];
    //  }
      // Send the chunk of data
      mp_send(mpd_ptr);
      DEBUGGER("Message sent\n");
      k += chunk;
  	}
}
Beispiel #11
0
NS_IMETHODIMP 
nsDebugImpl::Abort(const char *aFile, PRInt32 aLine)
{
  InitLog();

   PR_LOG(gDebugLog, PR_LOG_ERROR, 
         ("###!!! Abort: at file %s, line %d", aFile, aLine));
   PR_LogFlush();
   fprintf(stderr, "\07 Abort\n");  fflush(stderr);
   fflush(stderr);

#if defined(_WIN32)
#ifdef _M_IX86
  long* __p = (long*) 0x7;
  *__p = 0x7;
#else /* _M_ALPHA */
  PR_Abort();
#endif
#elif defined(XP_MAC)
  ExitToShell();
#elif defined(XP_UNIX)
  PR_Abort();
#elif defined(XP_OS2)
  DebugBreak();
  return NS_OK;
#elif defined(XP_BEOS)
  {
#ifndef DEBUG_cls
	char buf[2000];
	sprintf(buf, "Abort: at file %s, line %d", aFile, aLine);
	DEBUGGER(buf);
#endif
  } 
#endif
  return NS_OK;
}
Beispiel #12
0
void
CMOVAtom::OnProcessMetaData()
{
	BMallocIO *theUncompressedData;
	uint8 *outBuffer;
	CMVDAtom *aCMVDAtom = NULL;
	uint32	compressionID = 0;
	uint64	descBytesLeft;
	uint32	Size;
	
	descBytesLeft = GetAtomSize();
	
	// Check for Compression Type
	while (descBytesLeft > 0) {
		AtomBase *aAtomBase = GetAtom(theStream);
	
		aAtomBase->OnProcessMetaData();

		if (aAtomBase->GetAtomSize() > 0) {
			descBytesLeft = descBytesLeft - aAtomBase->GetAtomSize();
		} else {
			printf("Invalid Atom found when reading Compressed Headers\n");
			descBytesLeft = 0;
		}

		if (dynamic_cast<DCOMAtom *>(aAtomBase)) {
			// DCOM atom
			compressionID = dynamic_cast<DCOMAtom *>(aAtomBase)->GetCompressionID();
			delete aAtomBase;
		} else {
			if (dynamic_cast<CMVDAtom *>(aAtomBase)) {
				// CMVD atom
				aCMVDAtom = dynamic_cast<CMVDAtom *>(aAtomBase);
				descBytesLeft = 0;
			}
		}
	}

	// Decompress data
	if (compressionID == 'zlib') {
		Size = aCMVDAtom->GetUncompressedSize();
		
		outBuffer = (uint8 *)(malloc(Size));
		
		printf("Decompressing %ld bytes to %ld bytes\n",aCMVDAtom->GetBufferSize(),Size);
		int result = uncompress(outBuffer, &Size, aCMVDAtom->GetCompressedData(), aCMVDAtom->GetBufferSize());
		
		if (result != Z_OK) {
			printf("Failed to decompress headers uncompress returned ");
			switch (result) {
				case Z_MEM_ERROR:
					DEBUGGER("Lack of Memory Error\n");
					break;
				case Z_BUF_ERROR:
					DEBUGGER("Lack of Output buffer space Error\n");
					break;
				case Z_DATA_ERROR:
					DEBUGGER("Input Data is corrupt or not a compressed set Error\n");
					break;
			}
		}

		// Copy uncompressed data into BMAllocIO
		theUncompressedData = new BMallocIO();
		theUncompressedData->SetSize(Size);
		theUncompressedData->WriteAt(0L,outBuffer,Size);
		
		free(outBuffer);
		delete aCMVDAtom;
		
		// reset position on BMAllocIO
		theUncompressedData->Seek(SEEK_SET,0L);
		// Assign to Stream
		theUncompressedStream = theUncompressedData;
		
		// All subsequent reads should use theUncompressedStream
	}

}
Beispiel #13
0
void STSDAtom::ReadSoundDescription()
{
	uint64 descBytesLeft;

	SoundDescriptionV1 *aSoundDescriptionV1;
			
	aSoundDescriptionV1 = new SoundDescriptionV1;
	Read(&aSoundDescriptionV1->basefields.Size);
	Read(&aSoundDescriptionV1->basefields.DataFormat);
	Read(aSoundDescriptionV1->basefields.Reserved,6);
	Read(&aSoundDescriptionV1->basefields.DataReference);

	aSoundDescriptionV1->VOLSize = 0;
	aSoundDescriptionV1->theVOL = NULL;

	// Read in Audio Sample Data
	// We place into a V1 description even though it might be a V0 or earlier

	Read(&aSoundDescriptionV1->desc.Version);
	Read(&aSoundDescriptionV1->desc.Revision);
	Read(&aSoundDescriptionV1->desc.Vendor);
	Read(&aSoundDescriptionV1->desc.NoOfChannels);
	Read(&aSoundDescriptionV1->desc.SampleSize);
	Read(&aSoundDescriptionV1->desc.CompressionID);
	Read(&aSoundDescriptionV1->desc.PacketSize);
	Read(&aSoundDescriptionV1->desc.SampleRate);

	if ((aSoundDescriptionV1->desc.Version == 1) && (aSoundDescriptionV1->basefields.DataFormat != AUDIO_IMA4)) {
		Read(&(aSoundDescriptionV1->samplesPerPacket));
		Read(&(aSoundDescriptionV1->bytesPerPacket));
		Read(&(aSoundDescriptionV1->bytesPerFrame));
		Read(&(aSoundDescriptionV1->bytesPerSample));
	
	} else {
		// Calculate?
		if (aSoundDescriptionV1->basefields.DataFormat == AUDIO_IMA4) {
			aSoundDescriptionV1->samplesPerPacket = 64;
			aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * 34;

			aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8;
			aSoundDescriptionV1->bytesPerPacket = 64 * aSoundDescriptionV1->bytesPerFrame;
		} else {
			aSoundDescriptionV1->bytesPerSample = aSoundDescriptionV1->desc.SampleSize / 8;
			aSoundDescriptionV1->bytesPerFrame = aSoundDescriptionV1->desc.NoOfChannels * aSoundDescriptionV1->bytesPerSample;
			aSoundDescriptionV1->bytesPerPacket = aSoundDescriptionV1->desc.PacketSize;
			aSoundDescriptionV1->samplesPerPacket = aSoundDescriptionV1->desc.PacketSize / aSoundDescriptionV1->bytesPerFrame;
		}
	}

	// 0 means we dont have one
	aSoundDescriptionV1->theWaveFormat.format_tag = 0;

	descBytesLeft = getBytesRemaining();

	while (descBytesLeft > 0) {

		// More extended atoms
		AtomBase *aAtomBase = getAtom(theStream);
				
		aAtomBase->OnProcessMetaData();
		printf("%s\n",aAtomBase->getAtomName());

		if (dynamic_cast<WAVEAtom *>(aAtomBase)) {
			// WAVE atom
			aSoundDescriptionV1->theWaveFormat = dynamic_cast<WAVEAtom *>(aAtomBase)->getWaveFormat();
		}

		if (dynamic_cast<ESDSAtom *>(aAtomBase)) {
			// ESDS atom good
			aSoundDescriptionV1->VOLSize = aAtomBase->getDataSize();
			aSoundDescriptionV1->theVOL = (uint8 *)(malloc(aSoundDescriptionV1->VOLSize));
			memcpy(aSoundDescriptionV1->theVOL,dynamic_cast<ESDSAtom *>(aAtomBase)->getVOL(),aSoundDescriptionV1->VOLSize);
		}
		
		if ((aAtomBase->getAtomSize() > 0) && (descBytesLeft >= aAtomBase->getAtomSize())) {
			descBytesLeft = descBytesLeft - aAtomBase->getAtomSize();
		} else {
			DEBUGGER("Invalid Atom found when reading Sound Description\n");
			descBytesLeft = 0;
		}
				
		delete aAtomBase;
	}
			
	theAudioDescArray[0] = aSoundDescriptionV1;

	PRINT(("Size:Format=%ld:%ld %Ld\n",aSoundDescriptionV1->basefields.Size,aSoundDescriptionV1->basefields.DataFormat,descBytesLeft));
}
Beispiel #14
0
// Writes data to the bitmap starting at a specific position and size.
ssize_t
BBitmapStream::WriteAt(off_t pos, const void* data, size_t size)
{
	if (size == 0)
		return B_OK;
	if (!data || pos < 0 || pos > (off_t)fSize)
		return B_BAD_VALUE;

	ssize_t written = 0;
	while (size > 0) {
		size_t toWrite;
		void *dest;
		// We depend on writing the header separately in detecting
		// changes to it
		if (pos < (off_t)sizeof(TranslatorBitmap)) {
			toWrite = sizeof(TranslatorBitmap) - pos;
			dest = (reinterpret_cast<uint8 *> (&fHeader)) + pos;
		} else {
			if (fBitmap == NULL || !fBitmap->IsValid())
				return B_ERROR;

			toWrite = fHeader.dataSize - pos + sizeof(TranslatorBitmap);
			dest = (reinterpret_cast<uint8 *> (fBitmap->Bits())) +
				pos - sizeof(TranslatorBitmap);
		}
		if (toWrite > size)
			toWrite = size;
		if (!toWrite && size)
			// i.e. we've been told to write too much
			return B_BAD_VALUE;

		memcpy(dest, data, toWrite);
		pos += toWrite;
		written += toWrite;
		data = (reinterpret_cast<const uint8 *> (data)) + toWrite;
		size -= toWrite;
		if (pos > (off_t)fSize)
			fSize = pos;
		// If we change the header, the rest needs to be reset
		if (pos == sizeof(TranslatorBitmap)) {
			// Setup both host and Big Endian byte order bitmap headers
			memcpy(fBigEndianHeader, &fHeader, sizeof(TranslatorBitmap));
			if (B_HOST_IS_LENDIAN)
				SwapHeader(fBigEndianHeader, &fHeader);

			if (fBitmap != NULL
				&& (fBitmap->Bounds() != fHeader.bounds
					|| fBitmap->ColorSpace() != fHeader.colors
					|| (uint32)fBitmap->BytesPerRow() != fHeader.rowBytes)) {
				if (!fDetached)
					// if someone detached, we don't delete
					delete fBitmap;
				fBitmap = NULL;
			}
			if (fBitmap == NULL) {
				if (fHeader.bounds.left > 0.0 || fHeader.bounds.top > 0.0)
					DEBUGGER("non-origin bounds!");
				fBitmap = new (std::nothrow )BBitmap(fHeader.bounds,
					fHeader.colors);
				if (fBitmap == NULL)
					return B_ERROR;
				if (!fBitmap->IsValid()) {
					status_t error = fBitmap->InitCheck();
					delete fBitmap;
					fBitmap = NULL;
					return error;
				}
				if ((uint32)fBitmap->BytesPerRow() != fHeader.rowBytes) {
					fprintf(stderr, "BitmapStream %" B_PRId32 " %" B_PRId32 "\n",
						fBitmap->BytesPerRow(), fHeader.rowBytes);
					return B_MISMATCHED_VALUES;
				}
			}
			if (fBitmap != NULL)
				fSize = sizeof(TranslatorBitmap) + fBitmap->BitsLength();
		}
	}
	return written;
}
Beispiel #15
0
NS_IMETHODIMP 
nsDebugImpl::Break(const char *aFile, PRInt32 aLine)
{
#ifndef TEMP_MAC_HACK
  // Write out the assertion message to the debug log
   InitLog();

   PR_LOG(gDebugLog, PR_LOG_ERROR, 
         ("###!!! Break: at file %s, line %d", aFile, aLine));
   PR_LogFlush();

  fprintf(stderr, "Break: at file %s, line %d\n",aFile, aLine);  fflush(stderr);
  fflush(stderr);

#if defined(_WIN32)
#ifdef _M_IX86
   ::DebugBreak();
#endif
#elif defined(XP_UNIX) && !defined(UNIX_CRASH_ON_ASSERT)
    fprintf(stderr, "\07");

    char *assertBehavior = getenv("XPCOM_DEBUG_BREAK");

    if (!assertBehavior) {

      // the default; nothing else to do
      ;

    } else if ( strcmp(assertBehavior, "suspend")== 0 ) {

      // the suspend case is first because we wanna send the signal before 
      // other threads have had a chance to get too far from the state that
      // caused this assertion (in case they happen to have been involved).
      //
      fprintf(stderr, "Suspending process; attach with the debugger.\n");
      kill(0, SIGSTOP);

    } else if ( strcmp(assertBehavior, "warn")==0 ) {
      
      // same as default; nothing else to do (see "suspend" case comment for
      // why this compare isn't done as part of the default case)
      //
      ;

    } 
    else if ( strcmp(assertBehavior,"stack")==0 ) {

      // walk the stack
      //
      nsTraceRefcntImpl::WalkTheStack(stderr);
    } 
    else if ( strcmp(assertBehavior,"abort")==0 ) {

      // same as UNIX_CRASH_ON_ASSERT
      //
      Abort(aFile, aLine);

    } else if ( strcmp(assertBehavior,"trap")==0 ) {

      DebugBreak();

    } else {

      fprintf(stderr, "unrecognized value of XPCOM_DEBUG_BREAK env var!\n");

    }    
    fflush(stderr); // this shouldn't really be necessary, i don't think,
                    // but maybe there's some lame stdio that buffers stderr

#elif defined(XP_BEOS)
  {
#ifdef UNIX_CRASH_ON_ASSERT
	char buf[2000];
	sprintf(buf, "Break: at file %s, line %d", aFile, aLine);
	DEBUGGER(buf);
#endif
  }
#else
  Abort(aFile, aLine);
#endif
#endif // TEMP_MAC_HACK
  return NS_OK;
}