Example #1
0
void moveships(void)
{
   register int n,i,p;
   int target;

   target = goodbogey(0);
   if (target != 0)
      for (n=0; amtable[n] < MAXSHIPS; n++)
         if (amtable[n] != player)
            shiplist[amtable[n]].course = intercept(amtable[n], target -1);
   target = goodbogey(JAPANESE);
   if (target != 0)
      for (n=0; japtable[n] < MAXSHIPS; n++)
         if (japtable[n] != player)
            shiplist[japtable[n]].course = intercept(japtable[n], target -1);
   for (n=0; n < MAXSHIPS; n++) {
      firedflack[n] = 0;
      firedguns[n] = 0;
      if (shiplist[n].torps && shiplist[n].hits && n != player && n != MIDWAY)
         drdc((shiplist[n].course = shiplist[shiplist[n].flagship].course), &shiplist[n].row, &shiplist[n].col);
   }
   if (player != MIDWAY)
      drdc(shiplist[player].course, &shiplist[player].row, &shiplist[player].col);
   if (automatic >= 0)
	   plotships();

   for (n=0; amtable[n] < MAXSHIPS; n++) {
      if (shiplist[amtable[n]].hits && shiplist[amtable[n]].torps) {
         for (i = 0; japtable[i] < MAXSHIPS; i++) {
            if (shiplist[japtable[i]].hits && shiplist[japtable[i]].torps) {
               if (range(shiplist[amtable[n]].row, shiplist[amtable[n]].col, shiplist[japtable[i]].row, shiplist[japtable[i]].col) < 25) {   /* within sight */
                  for (p=japtable[i]; p < MAXSHIPS && shiplist[p].flagship == japtable[i]; p++)
                     if (p != player)
                        fireguns(p, amtable[n]);
                  for (p=amtable[n]; p < MAXSHIPS && shiplist[p].flagship == amtable[n]; p++)
                     if (p != player)
                        fireguns(p, japtable[i]);
                  newbogey(japtable[i]);
                  newbogey(amtable[n]);
               }
            }
         }
      }
   }
   fly(american,0,1);
   fly(japanese,0,0);
   fly(amscouts,1,1);
   fly(japscouts,1,0);
   if (automatic >= 0)
	   plotplanes();
   steer(american,0,1);
   steer(japanese,0,0);
   steer(amscouts,1,1);
   steer(japscouts,1,0);
}
Example #2
0
int main()
{

/*
L3 is 6MB, which can fit INTS_IN_L3 uint32_ts

Declaring an array that is 8 times bigger than L3.

*/

uint32_t *arrMuchBiggerThanL3=NULL;
long long max = (MULT * INTS_IN_L3);
arrMuchBiggerThanL3 = (uint32_t*)malloc((max) * sizeof(uint32_t));

uint32_t readValue, p;
//Step by 64k -- 64k = 2048 ints
uint32_t delta = 8193;
long long i, ntimes, k=0;
int randIdx;
struct timeval start, end;

//Initialize
for(i=0; i<max; i++)
	arrMuchBiggerThanL3[i] = ((++k) % (65535));


printf("\nMemory used: %1f MB", ((double) (max * sizeof(uint32_t)))/(1024.0 * 1024.0));

//Loop through

srand(time(NULL));
gettimeofday(&start, NULL);


for(ntimes=0; ntimes<NTIMES; ntimes++){

	for(i=0; i<max; i+=delta){
		//Access a[max - i], followed by a[i]
		 randIdx = ((unsigned long)rand()) % max;
		intercept();
		readValue = arrMuchBiggerThanL3[randIdx];
		intercept();
	//	p = arrMuchBiggerThanL3[i];
		p = readValue + 10;
		
	}
}

gettimeofday(&end, NULL);

double t2 =  (end.tv_sec + (end.tv_usec/1000000.0)) - (start.tv_sec + (start.tv_usec/1000000.0));
printf("\nTime taken: %lf secs\n", t2);
return 0;

}
Example #3
0
/* Set up all of our intercept functions, if they aren't already */
static int ensure_intercepts(void)
{
  int ok;
  if( !_pthread_create )
    _pthread_create = intercept("pthread_create");
  if( !_pthread_setname_np )
    _pthread_setname_np = intercept("pthread_setname_np");
  if( !_prctl ) _prctl = intercept("prctl");
  if( !_socket ) _socket = intercept("socket");
  /* Make sure everything is intercepted */
  ok = _pthread_create && _pthread_setname_np && _prctl && _socket;
  LOG("Intercepts set up %d", ok);
  return ok ? 0 : -EOPNOTSUPP;
}
Example #4
0
void
rewinddir (DIR *dirp)
{
        intercept ("rewinddir", 1);
        set_errno ();
        return;
}
Example #5
0
void
seekdir (DIR *dirp, off_t offset)
{
        intercept ("seekdir", 2);
        set_errno ();
        return;
}
Example #6
0
char *
realpath (const char *path, char *resolved)
{
        intercept ("realpath", 1);
        set_errno ();
        return NULL;
}
Example #7
0
struct dirent *
readdir64 (DIR *dir)
{
        intercept ("readdir64", 2);
        set_errno ();
        return NULL;
}
Example #8
0
int
close (int fd)
{
        intercept ("close", 2);
        set_errno ();
        return -1;
}
Example #9
0
ssize_t
read (int fd, void *buf, size_t count)
{
        intercept ("read", 2);
        set_errno ();
        return -1;
}
Example #10
0
int
__lxstat64 (int ver, const char *path, struct stat *buf)
{
        intercept ("__lxstat64", 2);
        set_errno ();
        return -1;
}
Example #11
0
int
fcntl (int fd, int cmd, ...)
{
        intercept ("fcntl", 2);
        set_errno ();
        return -1;
}
Example #12
0
int
__fxstat64 (int ver, int fd, struct stat *buf)
{
        intercept ("__fxstat64", 2);
        set_errno ();
        return -1;
}
Example #13
0
int
fstat64 (int fd , struct stat *buf)
{
        intercept ("fstat64", 2);
        set_errno ();
        return -1;
}
Example #14
0
int
stat (const char *path, struct stat *buf)
{
        intercept ("stat", 2);
        set_errno ();
        return -1;
}
Example #15
0
int
closedir (DIR *dh)
{
        intercept ("closedir", 1);
        set_errno ();
        return -1;
}
Example #16
0
int
readdir64_r (DIR *dir, struct dirent *entry, struct dirent **result)
{
        intercept ("readdir64_r", 1);
        set_errno ();
        return -1;
}
Example #17
0
off_t
telldir (DIR *dirp)
{
        intercept ("telldir", 2);
        set_errno ();
        return -1;
}
Example #18
0
int
lstat64 (const char *path, struct stat *buf)
{
        intercept ("lstat64", 2);
        set_errno ();
        return -1;
}
Example #19
0
ssize_t
sendfile64 (int out_fd, int in_fd, off_t *offset, size_t count)
{
        intercept ("sendfile64", 1);
        set_errno ();
        return -1;
}
Example #20
0
int
statvfs64 (const char *path, struct statvfs *buf)
{
        intercept ("statvfs64", 2);
        set_errno ();
        return -1;
}
Example #21
0
int
creat (const char *pathname, mode_t mode)
{
        intercept ("creat", 2);
        set_errno ();
        return -1;
}
Example #22
0
ssize_t
lgetxattr (const char *path, const char *name, void *value, size_t size)
{
        intercept ("lgetxattr", 1);
        set_errno ();
        return -1;
}
Example #23
0
int
open (const char *pathname, int flags, ...)
{
        intercept ("open", 2);
        set_errno ();
        return -1;
}
AudioDataOutputXT::AudioDataOutputXT(AudioDataOutput *output) :
    SinkNodeXT("AudioDataOutput"),
    SourceNodeXT("AudioDataOutput"),
    m_frontend(output),
    m_audioPort(0),
    m_postOutput(0)
{
    m_xine = Backend::xine();

    m_firstVpts = -1;

    // Dummy audio port, until we get the proper one
    xine_audio_port_t *port = xine_open_audio_driver(m_xine, "none", 0);

    // Allocate a new scope plugin
    m_plugin = (scope_plugin_t*)qMalloc(sizeof(scope_plugin_t));

    // It is also a post plugin
    post_plugin_t *post_plugin  = (post_plugin_t*)m_plugin;

    //1 audio input, 0 video inputs
    _x_post_init(post_plugin, 1, 0);

    // Intercept the null audio port (until we get the proper one)
    intercept(port, true);

    /* code is straight from xine_init_post()
       can't use that function as it only dlopens the plugins
       and our plugin is statically linked in */
    post_plugin->running_ticket = (*m_xine).port_ticket;
    post_plugin->xine = m_xine;

    // Store a reference to our own object in the post plugin struct
    m_plugin->audioDataOutput = this;
}
Example #25
0
// calculate intercept point from ship's current position and velocity
Vector3 NounShip::intercept( Noun * pIntercept, float fVelocity )
{
	Vector3 target( pIntercept->worldPosition() );
	if ( fVelocity < 1.0f )
		return target;

	Vector3 velocity( pIntercept->worldVelocity() );
	Vector3 myPosition( worldPosition() );

	// calculate the distance to the target
	float distance = (target - myPosition).magnitude();
	// caluclate the projectile time to the target
	float t = distance / fVelocity;	
	// calculate the intercept point
	Vector3 intercept( target + (velocity * t) );

	// refine the intercept position
	int recurseCount = INTERCEPT_RECURSE_COUNT;
	while( recurseCount > 0 )
	{
		recurseCount--;

		// recalculate the intercept point again
		distance = (intercept - myPosition).magnitude();
		t = distance / fVelocity;
		intercept = target + (velocity * t);
	}

	return intercept;
}
Example #26
0
int
readlink (const char *path, char *buf, size_t bufsize)
{
        intercept ("readlink", 1);
        set_errno ();
        return -1;
}
Example #27
0
int
remove (const char* path)
{
        intercept ("remove", 2);
        set_errno ();
        return -1;
}
Example #28
0
DIR *
opendir (const char *path)
{
        intercept ("opendir", 2);
        set_errno ();
        return NULL;
}
int prolog_call0(CTXTdeclc Cell term)
{
    Psc  psc;
    if (isconstr(term)) {
      int  disp;
      char *addr;
      psc = get_str_psc(term);
      addr = (char *)(clref_val(term));
      for (disp = 1; disp <= (int)get_arity(psc); ++disp) {
	bld_copy(reg+disp, cell((CPtr)(addr)+disp));
      }
    } else if (isstring(term)) {
      int  value;
      Pair sym;
      if (string_val(term) == true_string) return TRUE; /* short-circuit if calling "true" */
      sym = insert(string_val(term),0,(Psc)flags[CURRENT_MODULE],&value);
      psc = pair_psc(sym);
    } else {
      if (isnonvar(term))
	xsb_type_error(CTXTc "callable",term,"call/1",1);
      else xsb_instantiation_error(CTXTc "call/1",1);
      return FALSE;
    }
#ifdef CP_DEBUG
    pscreg = psc;
#endif
    pcreg = get_ep(psc);
    if (asynint_val) intercept(CTXTc psc);
    return TRUE;
}
Example #30
0
int
lchown (const char *path, uid_t owner, gid_t group)
{
        intercept ("lchown", 2);
        set_errno ();
        return -1;
}