Example #1
0
void vmSetLed(VmThread* thread)
{
    if(getChar(thread->fp + 4) == 0)
        SYNC(&led, turnOn, 0);
    else
        SYNC(&led, turnOff, 0);
    thread->sp = thread->fp + 5;
}
Example #2
0
    //
    // CmdHandler
    //
    void CmdHandler(U32 pathCrc)
    {
      switch (pathCrc)
      {
        case 0x43382C8E: // "sys.game.runcode"
        {
          const char *s;
          if (Console::ArgCount() == 2 && Console::GetArgString(1, s))
          {
            Set(s);
          }
          else
          {
            CON_ERR((Console::ARGS))
          }
          break;
        }

        case 0xBB563A77: // "sys.game.migrate.start"
          SYNC("Migration commencing")

          IFace::Activate("|Game::Resync");
          migration = MIGRATING;
          LOG_DIAG(("Switching to MIGRATING"))
          break;

        case 0x7CE02766: // "sys.game.migrate.resync"
          if (migration == MIGRATING)
          {
            migration = RESYNC;
            LOG_DIAG(("Switching to RESYNC"))
            MultiPlayer::SetReady();
          }
          break;

        case 0x7D690127: // "sys.game.migrate.end"
        {
          SYNC("Migration completed")

          // Change runcode to the sim
          IControl *ctrl = IFace::FindByName("|Game::Resync");
          if (ctrl)
          {
            IFace::SendNotify(ctrl, NULL, 0x334DAB78); // "ResyncComplete"
            IFace::Deactivate(ctrl);
          }
          MultiPlayer::ClearReady();
          migration = NORMAL;
          LOG_DIAG(("Switching to NORMAL"))
          break;
        }

        default:
          break;
      }
    }
Example #3
0
static void blink(Blinker *self, int flag)
{
	if(self->period > 0) {
		if(flag) {
			SYNC(self->lcd, segmentOn, self->segment);
		} else {
			SYNC(self->lcd, segmentOff, self->segment);
		}
		AFTER(MSEC(self->period), self, blink, !flag);
		// BEFORE(MSEC(self->period), self, blink, nothing);
	}
}
Example #4
0
TASK_3(BDD, union_par, BDD*, arr, int, first, int, last)
{
    if (first == last) return arr[first];

    BDD left, right;

    int mid = (first+last)/2;
    // check: last == first + 1
    if (first == mid) { // we have 2
        return CALL(sylvan_ite, arr[first], sylvan_true, arr[last], 0); // or
    }

    if (mid+1 == last) { // we have 3
        left = sylvan_ref(CALL(sylvan_ite, arr[first], sylvan_true, arr[mid], 0)); // or
        BDD result = CALL(sylvan_ite, left, sylvan_true, arr[last], 0);
        sylvan_deref(left);
        return result;
    }

    SPAWN(union_par, arr, first, mid);
    right = sylvan_ref(CALL(union_par, arr, mid+1, last));
    left = sylvan_ref(SYNC(union_par));
    BDD result = CALL(sylvan_ite, left, sylvan_true, right, 0);
    sylvan_deref(left);
    sylvan_deref(right);
    return result;
}
Example #5
0
/*
 * A \in M(m, n)
 * B \in M(n, p)
 * C \in M(m, p)
 */
VOID_TASK_8(rec_matmul, REAL*, A, REAL*, B, REAL*, C, int, m, int, n, int, p, int, ld, int, add)
{
    if ((m + n + p) <= 64) {
        int i, j, k;
        /* base case */
        if (add) {
            for (i = 0; i < m; i++)
                for (k = 0; k < p; k++) {
                    REAL c = 0.0;
                    for (j = 0; j < n; j++)
                        c += A[i * ld + j] * B[j * ld + k];
                    C[i * ld + k] += c;
                }
        } else {
            for (i = 0; i < m; i++)
                for (k = 0; k < p; k++) {
                    REAL c = 0.0;
                    for (j = 0; j < n; j++)
                        c += A[i * ld + j] * B[j * ld + k];
                    C[i * ld + k] = c;
                }
        }
    } else if (m >= n && n >= p) {
        int m1 = m >> 1;
        SPAWN(rec_matmul, A, B, C, m1, n, p, ld, add);
        CALL(rec_matmul, A + m1 * ld, B, C + m1 * ld, m - m1, n, p, ld, add);
        SYNC(rec_matmul);
    } else if (n >= m && n >= p) {
Example #6
0
    void Console::start_threads(STATE) {
      SYNC(state);

      // Don't start threads if we couldn't open communication channels.
      if(request_fd_ < 0 || response_fd_ < 0) return;

      if(!request_vm_) {
        request_vm_ = state->shared().new_vm();
        request_vm_->metrics()->init(metrics::eConsoleMetrics);
        request_exit_ = false;
        request_.set(Thread::create(state, request_vm_, G(thread),
                     console_request_trampoline, true));
      }

      if(!response_vm_) {
        response_vm_ = state->shared().new_vm();
        response_vm_->metrics()->init(metrics::eConsoleMetrics);
        response_exit_ = false;
        response_.set(Thread::create(state, response_vm_, G(thread),
                     console_response_trampoline, true));
      }

      if(request_vm_ && response_vm_) {
        run(state);
      }
    }
Example #7
0
    void Console::stop_threads(STATE) {
      SYNC(state);

      if(request_vm_) {
        wakeup();

        void* return_value;
        pthread_t os = request_vm_->os_thread();
        pthread_join(os, &return_value);

        request_vm_ = NULL;
      }

      if(response_vm_) {
        response_exit_ = true;
        atomic::memory_barrier();

        response_cond_.signal();

        void* return_value;
        pthread_t os = response_vm_->os_thread();
        pthread_join(os, &return_value);

        response_vm_ = NULL;
      }
    }
Example #8
0
// ====================
//  PUBLIC SLOTS:
// ====================
void IrcUser::setUser(const QString &user)
{
    if (!user.isEmpty() && _user != user) {
        _user = user;
        SYNC(ARG(user));
    }
}
static void
prepare_files(int nfiles)
{
	int i, j;
	char fname[1024];

	for (i = 0; i < nfiles; i++)
	{
		int fd;

		sprintf(fname, "%d", i);

		if ((fd = open(fname, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)) == -1)
		{
			printf("open failed");
			exit(7);
		}

		rewrite_file(fd);

		/* fdatasync is default on linux */
		if (SYNC(fd) != 0)
		{
			printf("sync failed");
			exit(8);
		}

		if (close(fd) != 0)
		{
			printf("close failed");
			exit(9);
		}
	}
}
void BufferViewConfig::setAllowedBufferTypes(int bufferTypes) {
  if(_allowedBufferTypes == bufferTypes)
    return;

  _allowedBufferTypes = bufferTypes;
  SYNC(ARG(bufferTypes))
  emit configChanged();
}
void BufferViewConfig::setSortAlphabetically(bool sortAlphabetically) {
  if(_sortAlphabetically == sortAlphabetically)
    return;

  _sortAlphabetically = sortAlphabetically;
  SYNC(ARG(sortAlphabetically))
  emit configChanged();
}
void BufferViewConfig::setAddNewBuffersAutomatically(bool addNewBuffersAutomatically) {
  if(_addNewBuffersAutomatically == addNewBuffersAutomatically)
    return;

  _addNewBuffersAutomatically = addNewBuffersAutomatically;
  SYNC(ARG(addNewBuffersAutomatically))
  emit configChanged();
}
Example #13
0
void Transfer::setAddress(const QHostAddress &address)
{
    if (_address != address) {
        _address = address;
        SYNC(ARG(address));
        emit addressChanged(address);
    }
}
void BufferViewConfig::setBufferViewName(const QString &bufferViewName) {
  if(_bufferViewName == bufferViewName)
    return;

  _bufferViewName = bufferViewName;
  SYNC(ARG(bufferViewName))
  emit bufferViewNameSet(bufferViewName);
}
Example #15
0
  void SignalHandler::start_thread(STATE) {
    SYNC(state);
    if(self_) return;
    self_ = state->shared().new_vm();
    thread_.set(Thread::create(state, self_, G(thread), signal_handler_tramp, false, true));
    run(state);

  }
Example #16
0
void Transfer::setFileName(const QString &fileName)
{
    if (_fileName != fileName) {
        _fileName = fileName;
        SYNC(ARG(fileName));
        emit fileNameChanged(fileName);
    }
}
Example #17
0
void Transfer::setState(Transfer::State state)
{
    if (_state != state) {
        _state = state;
        SYNC(ARG(state));
        emit stateChanged(state);
    }
}
Example #18
0
void Transfer::setStatus(Transfer::Status status)
{
    if (_status != status) {
        _status = status;
        SYNC(ARG(status));
        emit statusChanged(status);
    }
}
Example #19
0
void Transfer::setNick(const QString &nick)
{
    if (_nick != nick) {
        _nick = nick;
        SYNC(ARG(nick));
        emit nickChanged(nick);
    }
}
Example #20
0
void Transfer::setFileSize(quint64 fileSize)
{
    if (_fileSize != fileSize) {
        _fileSize = fileSize;
        SYNC(ARG(fileSize));
        emit fileSizeChanged(fileSize);
    }
}
void BufferViewConfig::setMinimumActivity(int activity) {
  if(_minimumActivity == activity)
    return;

  _minimumActivity = activity;
  SYNC(ARG(activity))
  emit configChanged();
}
void BufferViewConfig::setHideInactiveBuffers(bool hideInactiveBuffers) {
  if(_hideInactiveBuffers == hideInactiveBuffers)
    return;

  _hideInactiveBuffers = hideInactiveBuffers;
  SYNC(ARG(hideInactiveBuffers))
  emit configChanged();
}
Example #23
0
void Transfer::setPort(quint16 port)
{
    if (_port != port) {
        _port = port;
        SYNC(ARG(port));
        emit portChanged(port);
    }
}
Example #24
0
void Transfer::setDirection(Transfer::Direction direction)
{
    if (_direction != direction) {
        _direction = direction;
        SYNC(ARG(direction));
        emit directionChanged(direction);
    }
}
Example #25
0
  void SharedState::clear_critical(STATE) {
    SYNC(state);

    if(ruby_critical_set_ && pthread_equal(ruby_critical_thread_, pthread_self())) {
      ruby_critical_set_ = false;
      ruby_critical_lock_.unlock();
    }
  }
void repeat(HELP* self, int incordec){
	PULSEGEN* pulse;
	
	if(self->gui->pulseUsed == 0){
		pulse = self->gui->pulse1;
	}else{
		pulse = self->gui->pulse2;
	}
	if(self->firstpress){
		self->firstpress = 0;
		AFTER(MSEC(1000), self, repeat, 0);	
	}
	if((((PINB >> 6) & 1) == 0 && incordec == 0)){		//Up
		SYNC(pulse, pulseInc, 0); 
		SYNC(self->gui, update, 0);
		AFTER(MSEC(400), self, repeat, 0);
	}else if (((PINB >> 7) == 0) && incordec == 1){		//Down
void BufferViewConfig::setNetworkId(const NetworkId &networkId) {
  if(_networkId == networkId)
    return;

  _networkId = networkId;
  SYNC(ARG(networkId))
  emit networkIdSet(networkId);
  emit configChanged();
}
Example #28
0
  QueryAgent* SharedState::start_agent(STATE) {
    SYNC(state);

    if(!agent_) {
      agent_ = new QueryAgent(state);
    }

    return agent_;
  }
Example #29
0
void NetworkConfig::setAutoWhoInterval(int interval)
{
    if (_autoWhoInterval == interval)
        return;

    _autoWhoInterval = interval;
    SYNC(ARG(interval))
    emit autoWhoIntervalSet(interval);
}
Example #30
0
 void FinalizerHandler::start_thread(STATE) {
   SYNC(state);
   if(self_) return;
   utilities::thread::Mutex::LockGuard lg(worker_lock_);
   self_ = state->shared().new_vm();
   exit_ = false;
   thread_.set(Thread::create(state, self_, G(thread), finalizer_handler_tramp, false, true));
   run(state);
 }