Beispiel #1
0
void declarations (SymTableNodePtr routineIdPtr, bool allowFunctions) {

	if (curToken == TKN_CONST) {
		getToken();
		constDefinitions();
	}

	if (curToken == TKN_TYPE) {
		getToken();
		typeDefinitions();
	}

	if (curToken == TKN_VAR) {
		getToken();
		varDeclarations(routineIdPtr);
	}

	//---------------------------------------------------
	// Loop to process all of the function definitions...
	if (allowFunctions)
		while ((curToken == TKN_FUNCTION) || (curToken == TKN_ORDER) || (curToken == TKN_STATE)){
			routine();

			//---------------------
			// Error synchronize...
			synchronize(followRoutineList, declarationStartList, statementStartList);
			if (curToken == TKN_SEMICOLON)
				getToken();
			else if (tokenIn(declarationStartList) || tokenIn(statementStartList))
				syntaxError(ABL_ERR_SYNTAX_MISSING_SEMICOLON);
		}
	else if ((curToken == TKN_FUNCTION) || (curToken == TKN_ORDER) || (curToken == TKN_STATE))
		syntaxError(ABL_ERR_SYNTAX_NO_FUNCTION_NESTING);
}
Beispiel #2
0
void
hc_action_execute(hc_action_t *action)
{
    action_exit_code_t exit_code;
    action_routine_t routine;

    routine = hc_action_get_action_routine(action->type);
    if (!routine) {
        cm_trace(CM_TRACE_LEVEL_ERROR,
                 "The action routine for type [%d] has not been found",
                 action->type);
        action->status = ACTION_STATUS_FAILED;
        return;
    }

    exit_code = routine(action->params);
    switch (exit_code) {
    case ACTION_EXIT_FAILED:
        action->status = ACTION_STATUS_FAILED;
        break;

    case ACTION_EXIT_SUCCEEDED:
        action->status = ACTION_STATUS_EXECUTED;
        break;

    case ACTION_EXIT_WAITING:
        action->status = ACTION_STATUS_WAITING;
        break;
    }
}
Beispiel #3
0
static int 
__pthread_once_stub(void *id, void (*routine)(void))
{
    void **tmp;
    unsigned int i;

    /* look for the id */
    for (i = 0; i < __pthread_once_last_key; i++)
	if (__pthread_once_keys[i] == id) 
	    return 0;
    /* allocate more room if needed */
    if ((__pthread_once_last_key % PTHREAD_ONCE_KEYS_CHUNK) == 0) {
	tmp = realloc(__pthread_once_keys,
	      (__pthread_once_last_key 
	       + PTHREAD_ONCE_KEYS_CHUNK)*sizeof(void *));
	if (tmp == NULL)
	    return ENOMEM;
	for (i = 0; i < PTHREAD_ONCE_KEYS_CHUNK; i++)
	    tmp[__pthread_once_last_key + i] = NULL;
	__pthread_once_keys = tmp;
    }
    /* call the routine */
    routine();
    /* Mark it */
    __pthread_once_keys[__pthread_once_last_key++] = id;
    return 0;
}
int
main (void)
{
  list_init();
  routine();
  before_exit();
  return 0;
}
Beispiel #5
0
PUBLIC int
ROMlib_lockunlockrange (int fd, uint32 begin, uint32 count, lockunlock_t op)
{
  int retval;
  BOOL WINAPI (*routine) (HANDLE, DWORD, DWORD, DWORD, DWORD);

  warning_trace_info ("fd = %d, begin = %d, count = %d, op = %d",
		      fd, begin, count, op);
  switch (op)
    {
    case lock:
      routine = LockFile;
      break;
    case unlock:
      routine = UnlockFile;
      break;
    default:
      warning_unexpected ("op = %d", op);
      routine = 0;
      break;
    }
    
  if (!routine)
    retval = paramErr;
  else
    {
      BOOL success;
      HANDLE h;

      h = (HANDLE) _get_osfhandle (fd);
      success = routine (h, begin, 0, count, 0);
      if (success)
	retval = noErr;
      else
	{
	  DWORD err;

	  err = GetLastError ();
	  switch (err)
	    {
	    case ERROR_LOCK_VIOLATION:
	      retval = fLckdErr;
	      break;
	    case ERROR_NOT_LOCKED:
	      retval = afpRangeNotLocked;
	      break;
	    case ERROR_LOCK_FAILED:
	      retval = afpRangeOverlap;
	      break;
	    default:
	      warning_unexpected ("err = %ld, h = %p", err, h);
	      retval = noErr;
	      break;
	    }
	}
    }
  return retval;
}
Beispiel #6
0
// For non-VPI compliant applications that cannot find vlog_startup_routines symbol
void vlog_startup_routines_bootstrap(void) {
    void (*routine)(void);
    int i;
    routine = vlog_startup_routines[0];
    for (i = 0, routine = vlog_startup_routines[i];
         routine;
         routine = vlog_startup_routines[++i]) {
        routine();
    }
}
Beispiel #7
0
static void * pthread_tad_start(struct tad_start * tad_start)
{
	void * (*routine)() = tad_start->routine;
	void * arg = tad_start->arg;

	pthread_mutex_lock(&tad_start->tad->mutex);
	pthread_cleanup_push(pthread_tad_done, tad_start->tad);
	pthread_mutex_unlock(&tad_start->tad->mutex);
	free(tad_start);
	return(routine(arg));
}
Beispiel #8
0
static void * pthread_tad_start(void * tad_start_arg)
{
	pthread_tad_t * tad = tad_start_arg;
	void * (*routine)() = tad->routine;
	void * arg = tad->arg;

	tad->count_current++;
	pthread_cleanup_push(pthread_tad_done, tad);
	pthread_mutex_unlock(&tad->mutex);
	return(routine(arg));
}
Beispiel #9
0
static void *routine(void *_){
	struct start_arg *starg = (struct start_arg*)_;
	void *arg = starg->arg;
	void*(*routine)(void*) = starg->routine;
	kn_mutex_lock(starg->mtx);
	if(!starg->running){
		starg->running = 1;
		kn_condition_signal(starg->cond);
	}
	kn_mutex_unlock(starg->mtx);
	return routine(arg);
}
static void IRAM_ATTR timer_isr(void *p)
{
    espos_test_isr_routine routine = (espos_test_isr_routine) p;

    espos_isr_enter();

    TIMERG0.int_clr_timers.t0 = 1;

    routine();

    espos_isr_exit();
}
Beispiel #11
0
int main(int argc, char *argv[])
{
	//Cargamos librería sockets
	SocketTools::CargarLibreria();
	//Recibimos los argumentos de consola que nos indican qué dirección y puerto escuchar y a qué dirección y puerto mandar
	std::string direccion = argv[1];
	int conexiones = atoi(argv[2]);
	
	routine(direccion,conexiones);

	//Liberamos la librería
	SocketTools::DescargarLibreria();
}
Beispiel #12
0
static void yarn_launcher ( yarn_launch_data* ld )
{
	TTDGET();
	yarn* active_yarn = ld->active_yarn;
	void (*routine)(void*) = ld->routine;
	void* udata = ld->udata;
	// basically a bootstrap routine for each yarn which runs the routine then cleans up
	yfree(ld);
	routine(udata);
	DEBUG("yarn %p completed, yarn_context_set\n", active_yarn);
	TTD.runtime = UNSCHEDULE;
	PTABLE(active_yarn->pid) = 0;
	yarn_context_set(&(TTD.sched_context));
}
Beispiel #13
0
/* Execute task cleanup routines. */
static void
mm_task_cleanup(struct mm_task *task)
{
	ENTER();

	while (task->cleanup != NULL) {
		void (*routine)(uintptr_t) = task->cleanup->routine;
		uintptr_t routine_arg = task->cleanup->routine_arg;
		task->cleanup = task->cleanup->next;
		routine(routine_arg);
	}

	LEAVE();
}
Beispiel #14
0
static void*
start_routine(void *_)
{
	struct start_arg *starg = (struct start_arg*)_;
	void *arg = starg->arg;
	void*(*routine)(void*) = starg->routine;
	mutex_lock(starg->mtx);
	if(!starg->running){
		starg->running = 1;
		mutex_unlock(starg->mtx);
		condition_signal(starg->cond);
	}
	void *ret = routine(arg);
	clear_thdmailbox();
	return ret;
}
Beispiel #15
0
Datei: Err.c Projekt: theory/lucy
Err*
Err_trap(Err_Attempt_t routine, void *context) {
    jmp_buf  env;
    jmp_buf *prev_env = current_env;
    current_env = &env;

    if (!setjmp(env)) {
        routine(context);
    }

    current_env = prev_env;

    Err *error = thrown_error;
    thrown_error = NULL;
    return error;
}
Beispiel #16
0
static ThreadPoolTask* sumbit(void* (*routine)(void*), void* param, int toFront) {

    if (threadPool == NULL) {
        routine(param);
        return NULL;
    }
    
    ThreadPoolQueue* queue = &(threadPool->queue);
    
    semaphoreWait(&(queue->mutex));

    if (threadPool->terminated) {
        semaphorePost(&(queue->mutex));
        return NULL;
    }
    
    if (queue->current == (queue->last + 1) % queue->maxLength) {
        queue->full = 1;
        semaphorePost(&(queue->mutex));
        semaphoreWait(&(queue->wait));
        semaphoreWait(&(queue->mutex));
    }

    if (threadPool->terminated) {
        semaphorePost(&(queue->mutex));
        return NULL;
    }
    
    ThreadPoolTask* task = (ThreadPoolTask*) malloc(sizeof(ThreadPoolTask));
    task->routine = routine;
    task->param = param;
    semaphoreCreate(&(task->wait), 0);
    
    if (toFront) {
        queue->current = (queue->current - 1 + queue->maxLength) % queue->maxLength;
        queue->data[queue->current] = task;
    } else {
        queue->data[queue->last] = task;
        queue->last = (queue->last + 1) % queue->maxLength;
    }
    
    semaphorePost(&(queue->mutex));  
    
    semaphorePost(&(queue->submit));  
    
    return task;
}
Beispiel #17
0
void ServletManager::execute(unsigned servlet_id, unsigned seq, unsigned size, Peer *peer) noexcept {
    if (servlet_id == GX_KEEPALIVE_SERVLET) {
        if (seq || size) {
            peer->close();
            return;
        }
        return;
    }

    auto it = _map.find(servlet_id);
    if (it == _map.end()) {
        log_debug("servlet 0x%x not registered.", servlet_id);
        peer->close();
        return;
    }

    ServletBase *servlet = it->second;

    Coroutine *co;
    bool use_co = servlet->use_coroutine();
    if (use_co) {
        co = Coroutine::spawn(routine, peer);
    }
    else {
        co = Coroutine::self();
    }

    if (!co) {
        log_debug("no coroutine available.");
        peer->input().read(nullptr, size);
        return;
    }

    co->context()->_servlet = servlet;
    co->context()->_seq = seq;
    co->context()->_size = size;

    if (use_co) {
        co->resume();
    }
    else {
        routine(peer);
    }
}
Beispiel #18
0
void UC_posix_class::uc_pthread_cleanup_pop (int execute){
	UC_thread_class *thread = qt_parent_rtos->get_current_cpu()->m_current_task->m_current_thread;

	void (*routine)(void*) = thread->m_lifo_cancel_func.top();
	void *arg = thread->m_lifo_cancel_args.top();
	thread->m_lifo_cancel_func.pop();
	thread->m_lifo_cancel_args.pop();

	if (routine == NULL) {
		return;
	}

	if (arg == NULL) {
		return;
	}

	if (execute != 0) {
		routine(arg);
	}
}
Beispiel #19
0
static long OpenServer( LONG (*routine)(), char *name,
                 LONG *handle, LONG attr, LONG privs )
{
   LONG volumeNumber, pathBase, pathCount, entryNumber;
   BYTE pathString[128];
   BYTE fileName[256];
   void *Entry;

   fileName[1] = '\0';
   fileName[0] = AppendStr( (char *)fileName + 1, name );

   if (ConvertPathString(0, 0, fileName, &volumeNumber,
         &pathBase, pathString, &pathCount) != 0)
      /* The path is invalid */
      return (-1);

   /* Attempt to open the command file */
   return( routine(0, 1, volumeNumber, pathBase, pathString, pathCount, 0,
         attr, privs, PrimaryDataStream, handle, &entryNumber,
         &Entry ) );
}
main()
{ void (*routine)();
routine=&shellcode;
printf("size of shellcode: %dbytes\n",sizeof(shellcode));
routine();
}
Beispiel #21
0
int npp_integer(NPP *npp, const glp_iocp *parm)
{     /* process MIP prior to applying branch-and-bound method */
      NPPROW *row, *prev_row;
      NPPCOL *col;
      NPPAIJ *aij;
      int count, ret;
      xassert(npp->sol == GLP_MIP);
      xassert(parm == parm);
      /*==============================================================*/
      /* perform basic MIP processing */
      ret = npp_process_prob(npp, 1);
      if (ret != 0) goto done;
      /*==============================================================*/
      /* binarize problem, if required */
      if (parm->binarize)
         npp_binarize_prob(npp);
      /*==============================================================*/
      /* identify hidden packing inequalities */
      count = 0;
      /* new rows will be added to the end of the row list, so we go
         from the end to beginning of the row list */
      for (row = npp->r_tail; row != NULL; row = prev_row)
      {  prev_row = row->prev;
         /* skip free row */
         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX) continue;
         /* skip equality constraint */
         if (row->lb == row->ub) continue;
         /* skip row having less than two variables */
         if (row->ptr == NULL || row->ptr->r_next == NULL) continue;
         /* skip row having non-binary variables */
         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
         {  col = aij->col;
            if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
               break;
         }
         if (aij != NULL) continue;
         count += npp_hidden_packing(npp, row);
      }
      if (count > 0)
         xprintf("%d hidden packing inequaliti(es) were detected\n",
            count);
      /*==============================================================*/
      /* identify hidden covering inequalities */
      count = 0;
      /* new rows will be added to the end of the row list, so we go
         from the end to beginning of the row list */
      for (row = npp->r_tail; row != NULL; row = prev_row)
      {  prev_row = row->prev;
         /* skip free row */
         if (row->lb == -DBL_MAX && row->ub == +DBL_MAX) continue;
         /* skip equality constraint */
         if (row->lb == row->ub) continue;
         /* skip row having less than three variables */
         if (row->ptr == NULL || row->ptr->r_next == NULL ||
             row->ptr->r_next->r_next == NULL) continue;
         /* skip row having non-binary variables */
         for (aij = row->ptr; aij != NULL; aij = aij->r_next)
         {  col = aij->col;
            if (!(col->is_int && col->lb == 0.0 && col->ub == 1.0))
               break;
         }
         if (aij != NULL) continue;
         count += npp_hidden_covering(npp, row);
      }
      if (count > 0)
         xprintf("%d hidden covering inequaliti(es) were detected\n",
            count);
      /*==============================================================*/
      /* reduce inequality constraint coefficients */
      count = 0;
      /* new rows will be added to the end of the row list, so we go
         from the end to beginning of the row list */
      for (row = npp->r_tail; row != NULL; row = prev_row)
      {  prev_row = row->prev;
         /* skip equality constraint */
         if (row->lb == row->ub) continue;
         count += npp_reduce_ineq_coef(npp, row);
      }
      if (count > 0)
         xprintf("%d constraint coefficient(s) were reduced\n", count);
      /*==============================================================*/
#ifdef GLP_DEBUG
      routine(npp);
#endif
      /*==============================================================*/
      /* all seems ok */
      ret = 0;
done: return ret;
}
Beispiel #22
0
static int
httpd_main(UDM_AGENT *Agent, int ctl_sock,
           int (*routine)(int sock, UDM_AGENT *A))
{
  fd_set mask;
  int verb= UDM_LOG_ERROR;
  int res= UDM_OK;

  FD_ZERO(&mask);
  FD_SET(ctl_sock,&mask);

  for (; ;)
  {
    
    int sel;
    struct timeval tval;
    fd_set msk;
    
    tval.tv_sec= 300;
    tval.tv_usec= 0;
    msk= mask;
    sel= select(16,&msk,0,0,&tval);

    if(have_sigpipe)
    {
      UdmLog(Agent, verb, "SIGPIPE arrived. Broken pipe!");
      have_sigpipe = 0;
      res= UDM_ERROR;
      break;
    }
    
    if (have_sigint)
    {
      UdmLog(Agent, verb, "SIGINT arrived.");
      have_sigterm = 0;
      res= UDM_ERROR;
      break;
    }

    if(sel == 0)
      continue;
    
    if(sel==-1)
    {
      switch(errno)
      {
        case EINTR:  /* Child */
          break;
        default:
          UdmLog(Agent,verb,"FIXME select error %d %s",errno,strerror(errno));
      }
      continue;
    }
    
    if(FD_ISSET(ctl_sock,&msk))
    {
      int  ns;
      struct sockaddr_in client_addr;
      socklen_t  addrlen=sizeof(client_addr);
      char  addr[128]= "";
      
      /*
      int   method;
      UDM_MATCH  *M;
      UDM_MATCH_PART  P[10];
      */
      
      if ((ns= accept(ctl_sock, (struct sockaddr *) &client_addr, &addrlen)) == -1)
      {
        UdmLog(Agent,verb,"accept() error %d %s",errno,strerror(errno));
        UdmEnvFree(Agent->Conf);
        UdmAgentFree(Agent);
        exit(1);
      }
      UdmLog(Agent,verb,"Connect %s", inet_ntoa(client_addr.sin_addr));
      udm_snprintf(addr,sizeof(addr)-1,"%s",inet_ntoa(client_addr.sin_addr));
      
      /*
      M=UdmMatchListFind(&Agent->Conf->Filters,addr,10,P);
      method=M?UdmMethod(M->arg):UDM_METHOD_GET;
      UdmLog(Agent,verb,"%s %s %s%s",M?M->arg:"",addr,M?M->pattern:"",M?"":"Allow by default");
      
      if(method==UDM_METHOD_DISALLOW)
      {
        UdmLog(Agent,verb,"Reject client");
        close(ns);
        continue;
      }
      */
      
      if (0)
      {
        pid_t fres;
        if(!(fres= fork()))
        {
          alarm(300); /* 5 min. - maximum time of child execution */
          closesocket(ctl_sock);
          routine(ns, Agent);
          closesocket(ns);
          exit(0);
        }
        else
        {
          close(ns);
          if(fres > 0)
          {
            /* Do nothing */
          }
          else
          {
            UdmLog(Agent,verb,"fork error %d",fres);
          }
        }
      }
      else
      {
        routine(ns, Agent);
        closesocket(ns);
      }
      
    }
  }
  return res;
}
Beispiel #23
0
void Task::PostEventAsync(const PEvent &event, PThreadPool tp)
{
  PEventHandleRoutine routine(new EventHandleRoutine(m_eh, event));
  tp->PostRunnable(routine);
}
Beispiel #24
0
		void execute()
		{
			if (routine != nullptr)
				routine(arg);
		}