예제 #1
0
/*** do cyclic coordinate descent optimization for fixed lambda1
 * repeat coordinate descent algorithm until solution is converged ***/
bool
cdescent_do_update_one_cycle (cdescent *cd)
{
	int					ccd_iter = 0;
	bool				converged = false;

	update_one_cycle	update_func;

	update_func = (cd->rule == CDESCENT_SELECTION_RULE_STOCHASTIC) ?
			cdescent_do_update_once_cycle_stochastic : cdescent_do_update_once_cycle_cyclic;


	if (!cd) error_and_exit ("cdescent_do_cyclic_update", "cdescent *cd is empty.", __FILE__, __LINE__);

	while (!converged) {

		converged = update_func (cd);

		if (++ccd_iter >= cd->maxiter) {
			printf_warning ("cdescent_do_cyclic_update", "reaching max number of iterations.", __FILE__, __LINE__);
			break;
		}

	}
	cd->total_iter += ccd_iter;
	return converged;
}
예제 #2
0
파일: emu.cpp 프로젝트: nealey/vera
//----------------------------------------------------------------------
bool create_func_frame(func_t *pfn)	// create frame of newly created function
{
  bool std_vars_func = true;

  if ( pfn != NULL )
  {
    if ( pfn->frame == BADNODE )
    {
      ea_t ea = pfn->startEA;
      int regsize = 0;

      while (ea < pfn->endEA) // check for register pushs
      {
        decode_insn(ea);
        ea += cmd.size;		// считаем кол-во push
        if ( (cmd.itype == OAK_Dsp_push) && (cmd.Op1.type == o_reg) )
            regsize++;
        else
            break;
      }


      ea = pfn->startEA;
      int16 localsize = 0;
      while (ea < pfn->endEA) // check for frame creation
      {
        decode_insn(ea);
        ea += cmd.size;	// Попытка определить команду типа	ADDV	#,SP
        if ( (cmd.itype == OAK_Dsp_addv) && (cmd.Op1.type == o_imm) && (cmd.Op2.type == o_reg) && (cmd.Op2.reg == SP) )
        {
          localsize = (uint16)cmd.Op1.value;
          break;
        }

        // Если встретили команду mov #, rb  --> не надо создавать фрейм такой ф-ции, и объявлять локальные переменные
        if ( (cmd.itype == OAK_Dsp_mov) && (cmd.Op1.type == o_imm) && (cmd.Op2.type == o_reg) && (cmd.Op2.reg == RB) )
        {
          std_vars_func = false;
          break;
        }

      }

      if (std_vars_func)
      {
         pfn->flags |= FUNC_FRAME;
         update_func(pfn);
      }   

      add_frame(pfn, -localsize, (ushort)regsize, 0);

    }
  }
  return 0;
}
예제 #3
0
파일: tm_work_object.c 프로젝트: AR-H/geany
gboolean tm_work_object_update(TMWorkObject *work_object, gboolean force
  , gboolean recurse, gboolean update_parent)
{
	if ((NULL != work_object) && (work_object->type > 0) &&
		  (work_object->type < s_work_object_subclasses->len) &&
		  (s_work_object_subclasses->pdata[work_object->type] != NULL))
	{
		TMUpdateFunc update_func =
		  ((TMWorkObjectClass *)s_work_object_subclasses->pdata[work_object->type])->update_func;
		if (NULL != update_func)
			return update_func(work_object, force, recurse, update_parent);
	}
	return FALSE;
}
예제 #4
0
파일: protocols.c 프로젝트: GNOME/gftp
static void
_cleanup_get_all_subdirs (gftp_transfer * transfer, char *oldfromdir,
                          char *oldtodir,
                          void (*update_func) (gftp_transfer * transfer))
{
  if (update_func != NULL)
    {
      transfer->numfiles = transfer->numdirs = -1;
      update_func (transfer);
    }

  if (oldfromdir != NULL)
    g_free (oldfromdir);

  if (oldtodir != NULL)
    g_free (oldtodir);
}
예제 #5
0
//----------------------------------------------------------------------
static void setup_far_func(func_t *pfn)
{
  if ( (pfn->flags & FUNC_FAR) == 0 )
  {
    ea_t ea1 = pfn->startEA;
    ea_t ea2 = pfn->endEA;
    while ( ea1 < ea2 )
    {
      if ( isCode(get_flags_novalue(ea1)) )
      {
        decode_insn(ea1);
        if ( is_far_ending() )
        {
          pfn->flags |= FUNC_FAR;
          update_func(pfn);
          break;
        }
      }
      ea1 = next_head(ea1, ea2);
    }
  }
}
예제 #6
0
void EIF::receive_spike() {
   update_func();
}
예제 #7
0
void QuadIF::receive_spike() {
   update_func();
}
예제 #8
0
void StochLIF::receive_spike() {
   update_func();
}
예제 #9
0
static TEE_Result tee_buffer_update(
		TEE_OperationHandle op,
		TEE_Result(*update_func)(unsigned long state, const void *src,
				size_t slen, void *dst, uint64_t *dlen),
		const void *src_data, size_t src_len,
		void *dest_data, uint64_t *dest_len)
{
	TEE_Result res;
	const uint8_t *src = src_data;
	size_t slen = src_len;
	uint8_t *dst = dest_data;
	size_t dlen = *dest_len;
	size_t acc_dlen = 0;
	uint64_t tmp_dlen;
	size_t l;
	size_t buffer_size;
	size_t buffer_left;

	if (op->buffer_two_blocks) {
		buffer_size = op->block_size * 2;
		buffer_left = 1;
	} else {
		buffer_size = op->block_size;
		buffer_left = 0;
	}

	if (op->buffer_offs > 0) {
		/* Fill up complete block */
		if (op->buffer_offs < op->block_size)
			l = MIN(slen, op->block_size - op->buffer_offs);
		else
			l = MIN(slen, buffer_size - op->buffer_offs);
		memcpy(op->buffer + op->buffer_offs, src, l);
		op->buffer_offs += l;
		src += l;
		slen -= l;
		if ((op->buffer_offs % op->block_size) != 0)
			goto out;	/* Nothing left to do */
	}

	/* If we can feed from buffer */
	if ((op->buffer_offs > 0) &&
	    ((op->buffer_offs + slen) >= (buffer_size + buffer_left))) {
		l = ROUNDUP(op->buffer_offs + slen - buffer_size,
				op->block_size);
		l = MIN(op->buffer_offs, l);
		tmp_dlen = dlen;
		res = update_func(op->state, op->buffer, l, dst, &tmp_dlen);
		if (res != TEE_SUCCESS)
			TEE_Panic(res);
		dst += tmp_dlen;
		dlen -= tmp_dlen;
		acc_dlen += tmp_dlen;
		op->buffer_offs -= l;
		if (op->buffer_offs > 0) {
			/*
			 * Slen is small enough to be contained in rest buffer.
			 */
			memcpy(op->buffer, op->buffer + l, buffer_size - l);
			memcpy(op->buffer + op->buffer_offs, src, slen);
			op->buffer_offs += slen;
			goto out;	/* Nothing left to do */
		}
	}

	if (slen >= (buffer_size + buffer_left)) {
		/* Buffer is empty, feed as much as possible from src */
		l = ROUNDUP(slen - buffer_size + 1, op->block_size);

		tmp_dlen = dlen;
		res = update_func(op->state, src, l, dst, &tmp_dlen);
		if (res != TEE_SUCCESS)
			TEE_Panic(res);
		src += l;
		slen -= l;
		dst += tmp_dlen;
		dlen -= tmp_dlen;
		acc_dlen += tmp_dlen;
	}

	/* Slen is small enough to be contained in buffer. */
	memcpy(op->buffer + op->buffer_offs, src, slen);
	op->buffer_offs += slen;

out:
	*dest_len = acc_dlen;
	return TEE_SUCCESS;
}
예제 #10
0
//----------------------------------------------------------------------
int idaapi emu(void)
{
  uint32 Feature = cmd.get_canon_feature();
  int flag1 = is_forced_operand(cmd.ea, 0);
  int flag2 = is_forced_operand(cmd.ea, 1);
  int flag3 = is_forced_operand(cmd.ea, 2);

  flow = ((Feature & CF_STOP) == 0);

  if ( Feature & CF_USE1 ) process_operand(cmd.Op1, flag1, 1);
  if ( Feature & CF_USE2 ) process_operand(cmd.Op2, flag2, 1);
  if ( Feature & CF_USE3 ) process_operand(cmd.Op3, flag3, 1);

  if ( Feature & CF_CHG1 ) process_operand(cmd.Op1, flag1, 0);
  if ( Feature & CF_CHG2 ) process_operand(cmd.Op2, flag2, 0);
  if ( Feature & CF_CHG3 ) process_operand(cmd.Op3, flag3, 0);

//
//      Determine if the next instruction should be executed
//
  if ( segtype(cmd.ea) == SEG_XTRN )
     flow = false;

//
// Handle loads to segment registers
//
  sel_t v = BADSEL;
  switch ( cmd.itype )
  {
    case H8500_andc:
      if ( cmd.Op1.value == 0 )
        v = 0;
      goto SPLIT;
    case H8500_orc:
      if ( cmd.Op1.value == 0xFF )
        v = 0xFF;
      goto SPLIT;
    case H8500_ldc:
      if ( cmd.Op1.type == o_imm )
        v = cmd.Op1.value;
    case H8500_xorc:
SPLIT:
      if ( cmd.Op2.reg >= BR && cmd.Op2.reg <= TP )
        split_srarea(cmd.ea+cmd.size, cmd.Op2.reg, v, SR_auto);
      break;
  }

  if ( (Feature & CF_CALL) != 0 )
  {
    ea_t callee = find_callee();
    if ( !handle_function_call(callee) )
      flow = false;
  }

//
//      Handle SP modifications
//
  if ( may_trace_sp() )
  {
    func_t *pfn = get_func(cmd.ea);
    if ( pfn != NULL )
    {
      if ( (pfn->flags & FUNC_USERFAR) == 0
        && (pfn->flags & FUNC_FAR) == 0
        && is_far_ending() )
      {
        pfn->flags |= FUNC_FAR;
        update_func(pfn);
        reanalyze_callers(pfn->startEA, 0);
      }
      if ( !flow )
        recalc_spd(cmd.ea);     // recalculate SP register for the next insn
      else
        trace_sp();
    }
  }

  if ( flow )
    ua_add_cref(0, cmd.ea+cmd.size, fl_F);

  return 1;
}
예제 #11
0
void WINAPI WinMainCRTStartup()
#endif
{
    PIXELFORMATDESCRIPTOR pfd;
    pfd.cColorBits = pfd.cDepthBits = 32;
    pfd.dwFlags    = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;

#ifdef NDEBUG
    DEVMODE deviceMode;
    deviceMode.dmSize = sizeof(deviceMode);
    deviceMode.dmPelsWidth = WIDTH;
    deviceMode.dmPelsHeight = HEIGHT;
    deviceMode.dmBitsPerPel = 32;
    deviceMode.dmFields = DM_BITSPERPEL | DM_PELSWIDTH | DM_PELSHEIGHT;
    
    ChangeDisplaySettings(&deviceMode, CDS_FULLSCREEN);
#endif
    
#ifdef NDEBUG
    HDC hDC = GetDC( CreateWindow("edit", 0, WS_POPUP|WS_VISIBLE|WS_MAXIMIZE, 0, 0, 0, 0, 0, 0, 0, 0) );
#else
    HDC hDC = GetDC( CreateWindow("edit", 0, WS_POPUP|WS_VISIBLE, 0, 0, 800, 600, 0, 0, 0, 0) );
#endif
    SetPixelFormat( hDC, ChoosePixelFormat ( hDC, &pfd) , &pfd );
    wglMakeCurrent( hDC, wglCreateContext(hDC) );
    
    ShowCursor(FALSE);
    glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
    SwapBuffers(hDC);
    
    // Init
    InitGL();
    glowInitTextures();
    InitDome( g_dome_panels, g_dome_verlets, 1, 0 );
    InitMirrors();
    
#ifndef NO_SOUND
    initAndStartSound();
#endif
    
    // Run
    DWORD start = GetTickCount();
    int run_time = 0;
    int cur_seq = 0;
    do
    {
        // Get frames to advance
        DWORD cur = GetTickCount();
        DWORD diff = cur - start;
        if ( diff > 10000 )
        {
            start = cur;
            continue;
        }
        
        int frames = diff / MS_PER_FRAME;
        if ( frames <= 0 )
            continue;
        
        int ms = frames * MS_PER_FRAME;
        run_time += ms;
        start += ms;
        
        // Advance the sequnce
        //int runtime_sec = run_time >> 10; // roughly /1000
        int runtime_sec = run_time >> 9;
        if ( runtime_sec > g_seq_times[ cur_seq ] )
            ++cur_seq;
        SeqFunc update_func = g_seq_funcs[ cur_seq ];
        if ( update_func == 0 )
            break;
        
        // Advance
        beginBaseTextureRender();
        while ( frames-- > 0 )
        {
            // Init the OpenGL
            glShadeModel( GL_SMOOTH );
            
            glEnable( GL_NORMALIZE );
            
            glEnable( GL_LIGHTING );
            glEnable( GL_LIGHT0 );
            glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
            
            glEnable( GL_COLOR_MATERIAL );
            //glColorMaterial( GL_FRONT_AND_BACK, GL_DIFFUSE );
            
            glEnable( GL_DEPTH_TEST );
            glDisable( GL_CULL_FACE );
            
            glEnable( GL_BLEND );
            glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
            //glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
            
            glLineWidth( 7 );
            
            glClear( GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT );
            
            // Update & render
            update_func();
        }
        endBaseTextureRender();
        beginGlow();
        glowRender();
        endGlow();
        
        // Swap it
        SwapBuffers( hDC );
#ifndef NO_SOUND
        //updateSound();
#endif
        Sleep(1);
    } while ( !GetAsyncKeyState(VK_ESCAPE) );
    
#ifdef NDEBUG
    ChangeDisplaySettings( NULL, 0 );
#endif
    ExitProcess( 0 );

#ifdef _DEBUG
    return 0;
#endif
}
예제 #12
0
파일: flare.cpp 프로젝트: MarkOates/beary2d
bool FlareManager::Flare::update()
{
	lifespan -= 0.01; // figure this out
	if (update_func) update_func(this);
	return !(lifespan < 0);
}
예제 #13
0
static int search_dir(char *abs_dir_name,
    void (*update_func)(char *filename, char *dirname),
    struct z_story_list *story_list, bool recursive, struct babel_info *babel)
{
  z_dir *current_dir;
  struct z_dir_ent z_dir_entry;
  char *dirname = NULL;
  int dirname_size = 0;
  int len;
  char *cwd = fsi->get_cwd();

  TRACE_LOG("Trying to readdir \"%s\".\n", abs_dir_name);

  if ((fsi->ch_dir(abs_dir_name)) == -1)
  {
    return -1;
  }

  if ((current_dir = fsi->open_dir(".")) == NULL)
  {
    printf("\"%s\":\n", abs_dir_name);
    perror("could not opendir");
    return -1;
  }

  if ( (show_progress == true) && (update_func != NULL) )
    update_func(NULL, abs_dir_name);

  while (fsi->read_dir(&z_dir_entry, current_dir) == 0)
  {
    if (
        (strcmp(z_dir_entry.d_name, ".") == 0)
        ||
        (strcmp(z_dir_entry.d_name, "..") == 0)
       )
      continue;

    len = strlen(abs_dir_name) + strlen(z_dir_entry.d_name) + 2;
    if (len > dirname_size)
    {
      dirname = (char*)fizmo_realloc(dirname, len);
      dirname_size = len;
    }

    strcpy(dirname, abs_dir_name);
    if (dirname[strlen(dirname) - 1] != '/')
      strcat(dirname, "/");
    strcat(dirname, z_dir_entry.d_name);

    if (fsi->is_filename_directory(z_dir_entry.d_name) == true)
    {
      if (recursive == true)
        search_dir(dirname, update_func, story_list, true, babel);
    }
    else
    {
      if ( (show_progress == true) && (update_func != NULL) )
        update_func(z_dir_entry.d_name, NULL);
      detect_and_add_z_file(dirname, NULL, babel, story_list);
      }
  }

  if (dirname != NULL)
    free(dirname);

  fsi->close_dir(current_dir);

  fsi->ch_dir(cwd);
  free(cwd);

  return 0;
}
예제 #14
0
파일: protocols.c 프로젝트: GNOME/gftp
int
gftp_get_all_subdirs (gftp_transfer * transfer,
                      void (*update_func) (gftp_transfer * transfer))
{
  GList * templist, * lastlist;
  char *oldfromdir, *oldtodir;
  GHashTable * device_hash;
  gftp_file * curfle;
  off_t linksize;
  mode_t st_mode;
  int ret;

  g_return_val_if_fail (transfer != NULL, GFTP_EFATAL);
  g_return_val_if_fail (transfer->fromreq != NULL, GFTP_EFATAL);
  g_return_val_if_fail (transfer->files != NULL, GFTP_EFATAL);

  if (transfer->files == NULL)
    return (0);

  ret = 0;
  lastlist = _setup_current_directory_transfer (transfer, &ret);
  if (lastlist == NULL)
    return (ret);

  oldfromdir = oldtodir = NULL;
  device_hash = g_hash_table_new (uint_hash_function, uint_hash_compare);

  for (templist = transfer->files; templist != NULL; templist = templist->next)
    {
      curfle = templist->data;

      if (_lookup_curfle_in_device_hash (transfer->fromreq, curfle,
                                         device_hash))
        continue;

      if (S_ISLNK (curfle->st_mode) && !S_ISDIR (curfle->st_mode))
        {
          st_mode = 0;
          linksize = 0;
          ret = gftp_stat_filename (transfer->fromreq, curfle->file, &st_mode,
                                    &linksize);
          if (ret == GFTP_EFATAL)
            {
              _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir,
                                        update_func);
              return (ret);
            }
          else if (ret == 0)
            {
              if (S_ISDIR (st_mode))
                curfle->st_mode = st_mode;
              else
                curfle->size = linksize;
            }
        }

      if (!S_ISDIR (curfle->st_mode))
        {
          transfer->numfiles++;
          continue;
        }

      /* Got a directory... */
      transfer->numdirs++;

      if (oldfromdir == NULL)
        oldfromdir = g_strdup (transfer->fromreq->directory);

      ret = gftp_set_directory (transfer->fromreq, curfle->file);
      if (ret < 0)
        {
          _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir,
                                    update_func);
          _free_device_hash (device_hash);
          return (ret);
        }

      if (transfer->toreq != NULL)
        {
          if (oldtodir == NULL)
            oldtodir = g_strdup (transfer->toreq->directory);

          if (curfle->exists_other_side)
            {
              ret = gftp_set_directory (transfer->toreq, curfle->destfile);
              if (ret == GFTP_EFATAL)
                {
                  _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir,
                                            update_func);
                  _free_device_hash (device_hash);
                  return (ret);
                }
            }
          else
            {
              if (transfer->toreq->directory != NULL)
                g_free (transfer->toreq->directory);

              transfer->toreq->directory = g_strdup (curfle->destfile);
            }
        } 

      ret = 0;
      lastlist->next = gftp_get_dir_listing (transfer,
                                             curfle->exists_other_side, &ret);
      if (ret < 0)
        {
          _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir,
                                    update_func);
          _free_device_hash (device_hash);
          return (ret);
        }

      if (lastlist->next != NULL)
        {
          lastlist->next->prev = lastlist;
          for (; lastlist->next != NULL; lastlist = lastlist->next);
        }

      if (update_func != NULL)
        update_func (transfer);
    }

  _free_device_hash (device_hash);

  if (oldfromdir != NULL)
    {
      ret = gftp_set_directory (transfer->fromreq, oldfromdir);
      if (ret == GFTP_EFATAL)
        {
          _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir,
                                    update_func);
          return (ret);
        }
    }

  if (oldtodir != NULL)
    {
      ret = gftp_set_directory (transfer->toreq, oldtodir);
      if (ret == GFTP_EFATAL)
        {
          _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir,
                                    update_func);
          return (ret);
        }
    }

  _cleanup_get_all_subdirs (transfer, oldfromdir, oldtodir, update_func);

  return (0);
}
예제 #15
0
void HH::receive_spike() {
   update_func();
}
예제 #16
0
void Node::receive_spike() {
   update_func();
}
예제 #17
0
static TEE_Result tee_buffer_update(
		TEE_OperationHandle op,
		TEE_Result(*update_func) (uint32_t state, const void *src,
					  size_t slen, void *dst, size_t *dlen),
		const void *src_data, size_t src_len,
		void *dest_data, size_t *dest_len)
{
	TEE_Result res;
	const uint8_t *src = src_data;
	size_t slen = src_len;
	uint8_t *dst = dest_data;
	size_t dlen = *dest_len;
	size_t acc_dlen = 0;
	size_t tmp_dlen;
	size_t l;
	size_t buffer_size;

	if (op->buffer_two_blocks)
		buffer_size = op->block_size * 2;
	else
		buffer_size = op->block_size;

	if (op->buffer_offs > 0) {
		/* Fill up complete block */
		if (op->buffer_offs < op->block_size)
			l = MIN(slen, op->block_size - op->buffer_offs);
		else
			l = MIN(slen, buffer_size - op->buffer_offs);
		memcpy(op->buffer + op->buffer_offs, src, l);
		op->buffer_offs += l;
		src += l;
		slen -= l;
		if ((op->buffer_offs % op->block_size) != 0)
			goto out;	/* Nothing left to do */
	}

	/* If we can feed from buffer */
	if (op->buffer_offs > 0 && (op->buffer_offs + slen) > buffer_size) {
		l = ROUNDUP(op->buffer_offs + slen - buffer_size,
				op->block_size);
		l = MIN(op->buffer_offs, l);
		tmp_dlen = dlen;
		res = update_func(op->state, op->buffer, l, dst, &tmp_dlen);
		if (res != TEE_SUCCESS)
			TEE_Panic(res);
		dst += tmp_dlen;
		dlen -= tmp_dlen;
		acc_dlen += tmp_dlen;
		op->buffer_offs -= l;
		if (op->buffer_offs > 0) {
			/*
			 * Slen is small enough to be contained in rest buffer.
			 */
			memcpy(op->buffer, op->buffer + l, buffer_size - l);
			memcpy(op->buffer + op->buffer_offs, src, slen);
			op->buffer_offs += slen;
			goto out;	/* Nothing left to do */
		}
	}

	if (slen > buffer_size) {
		/* Buffer is empty, feed as much as possible from src */
		if (TEE_ALIGNMENT_IS_OK(src, uint32_t)) {
			l = ROUNDUP(slen - buffer_size + 1, op->block_size);

			tmp_dlen = dlen;
			res = update_func(op->state, src, l, dst, &tmp_dlen);
			if (res != TEE_SUCCESS)
				TEE_Panic(res);
			src += l;
			slen -= l;
			dst += tmp_dlen;
			dlen -= tmp_dlen;
			acc_dlen += tmp_dlen;
		} else {
			/*
			 * Supplied data isn't well aligned, we're forced to
			 * feed through the buffer.
			 */
			while (slen >= op->block_size) {
				memcpy(op->buffer, src, op->block_size);

				tmp_dlen = dlen;
				res =
				    update_func(op->state, op->buffer,
						op->block_size, dst, &tmp_dlen);
				if (res != TEE_SUCCESS)
					TEE_Panic(res);
				src += op->block_size;
				slen -= op->block_size;
				dst += tmp_dlen;
				dlen -= tmp_dlen;
				acc_dlen += tmp_dlen;
			}
		}
	}

	/* Slen is small enough to be contained in buffer. */
	memcpy(op->buffer + op->buffer_offs, src, slen);
	op->buffer_offs += slen;

out:
	*dest_len = acc_dlen;
	return TEE_SUCCESS;
}