コード例 #1
0
 std::vector<std::string> to_internal(const std::vector<T>& s)
 {
     std::vector<std::string> result;
     for (unsigned i = 0; i < s.size(); ++i)
         result.push_back(to_internal(s[i]));            
     return result;
 }
コード例 #2
0
 basic_command_line_parser<charT>::
 basic_command_line_parser(int argc, charT* argv[])
 : detail::cmdline(
     // Explicit template arguments are required by gcc 3.3.1 
     // (at least mingw version), and do no harm on other compilers.
     to_internal(detail::make_vector<charT, charT**>(argv+1, argv+argc+!argc)))
 {}
コード例 #3
0
ファイル: pthread_setschedparam.c プロジェクト: jiezh/h5vcc
int
pthread_setschedparam (pthread_t thread, int policy,
		       const struct sched_param *param)
{
  int result;

  /* Validate the thread id. */
  result = pthread_kill (thread, 0);
  if (0 != result)
    {
      return result;
    }

  /* Validate the scheduling policy. */
  if (policy < SCHED_MIN || policy > SCHED_MAX)
    {
      return EINVAL;
    }

  /* Ensure the policy is SCHED_OTHER. */
  if (policy != SCHED_OTHER)
    {
      return ENOTSUP;
    }

  return (ptw32_setthreadpriority (
      to_internal(thread), policy, param->sched_priority));
}
コード例 #4
0
ファイル: Box.hpp プロジェクト: kozo2/ecell4
inline Box::length_type
distance(Box const& obj, typename Box::position_type const& pos)
{
    typedef Box::length_type length_type;
    boost::array<length_type, 3> x_y_z(to_internal(obj, pos));
    boost::array<length_type, 3> dx_dy_dz(subtract(abs(x_y_z), obj.half_extent()));

    if (dx_dy_dz[0] > 0)
    {
        if (dx_dy_dz[1] > 0)
        {
            if (dx_dy_dz[2] > 0)
            {
                // Far away from box.
                return length(dx_dy_dz);
            }
            else
            {
                return length(array_slice<0, 2>(dx_dy_dz));
            }
        }
        else
        {
            if (dx_dy_dz[2] > 0)
            {
                return std::sqrt(gsl_pow_2(dx_dy_dz[0]) + gsl_pow_2(dx_dy_dz[2]));
            }
            else
            {
                return dx_dy_dz[0];
            }
        }
    }
    else
    {
        if (dx_dy_dz[1] > 0)
        {
            if (dx_dy_dz[2] > 0)
            {
                return length(array_slice<1, 3>(dx_dy_dz));
            }
            else
            {
                return dx_dy_dz[1];
            }
        }
        else
        {
            if (dx_dy_dz[2] > 0)
            {
                return dx_dy_dz[2];
            }
            else
            {
                // Inside box.
                return std::max(std::max(dx_dy_dz[0], dx_dy_dz[1]), dx_dy_dz[2]);
            }
        }
    }
}
コード例 #5
0
	Self & operator<<(Symbol symbol) {
		InternalSymbol internal_symbol = to_internal(symbol);
		if (location[internal_symbol] == nullptr) {
			new_symbol(internal_symbol);
		}
		increse_weight(location[internal_symbol]);
		return *this;
	}
コード例 #6
0
ファイル: winmain.cpp プロジェクト: xhy20070406/PDAL
 BOOST_PROGRAM_OPTIONS_DECL std::vector<std::wstring>
 split_winmain(const std::wstring& cmdline)
 {
     std::vector<std::wstring> result;
     std::vector<std::string> aux = split_winmain(to_internal(cmdline));
     for (unsigned i = 0, e = aux.size(); i < e; ++i)
         result.push_back(from_utf8(aux[i]));
     return result;        
 }
コード例 #7
0
ファイル: Plane.hpp プロジェクト: YetAnotherTomek/egfrd
inline std::pair<typename Plane<T_>::position_type,
                 typename Plane<T_>::length_type>
projected_point(Plane<T_> const& obj, typename Plane<T_>::position_type const& pos)
{
    boost::array<typename Plane<T_>::length_type, 3> x_y_z(to_internal(obj, pos));
    return std::make_pair(
        add(add(obj.position(), multiply(obj.unit_x(), x_y_z[0])),
            multiply(obj.unit_y(), x_y_z[1])),
        x_y_z[2]);
}
コード例 #8
0
ファイル: config_file.hpp プロジェクト: AndresGalaviz/NAO
 bool
 basic_config_file_iterator<charT>::getline(std::string& s)
 {
     std::basic_string<charT> in;
     if (std::getline(*is, in)) {
         s = to_internal(in);
         return true;
     } else {
         return false;
     }
 }
コード例 #9
0
ファイル: Cylinder.hpp プロジェクト: YetAnotherTomek/egfrd
inline std::pair<typename Cylinder<T_>::position_type,
                 typename Cylinder<T_>::length_type>
projected_point(Cylinder<T_> const& obj,
                typename Cylinder<T_>::position_type const& pos)
{
    typedef typename Cylinder<T_>::length_type length_type;

    // The projection lies on the z-axis.
    std::pair<length_type, length_type> r_z(to_internal(obj, pos));
    return std::make_pair(
        add(obj.position(), multiply(obj.unit_z(), r_z.second)),
        r_z.first);
}
コード例 #10
0
ファイル: pthread_getattr_np.c プロジェクト: jiezh/h5vcc
// Get a pthread_attr_t containing attributes of the given pthread_t.
int pthread_getattr_np(pthread_t tid, pthread_attr_t* attr) {
  ptw32_thread_t* thread_ptr;
  if (ptw32_is_attr(attr) != 0) {
    return EINVAL;
  }

  thread_ptr = (ptw32_thread_t*)to_internal(tid).p;
  (*attr)->stacksize = thread_ptr->stackSize;
  (*attr)->stackaddr = thread_ptr->stackAddr;
  (*attr)->detachstate = thread_ptr->detachState;
  (*attr)->param.sched_priority = thread_ptr->sched_priority;
  return 0;
}
コード例 #11
0
ファイル: rmon_tools.c プロジェクト: LydiaBrothers/cctools
void rmDsummary_print(FILE *output, struct rmDsummary *so) {
	struct rmsummary *s = rmsummary_create(-1);

	s->command    = xxstrdup(so->command);

	if(so->category)
	{
		s->category   = xxstrdup(so->category);
	}
	else if(so->command)
	{
		s->category   = xxstrdup(so->command);
	}
	else
	{
		s->category   = xxstrdup(DEFAULT_CATEGORY);
		s->command    = xxstrdup(DEFAULT_CATEGORY);
	}

	if(so->task_id) {
		s->task_id = xxstrdup(so->task_id);
	}

	s->start     = so->start;
	s->end       = so->end;
	s->wall_time = so->wall_time;

	to_internal(so, s, start,     "us");
	to_internal(so, s, end,       "us");
	to_internal(so, s, wall_time, "s");
	to_internal(so, s, cpu_time,  "s");

	to_internal(so, s, cores,                   "cores");
	to_internal(so, s, total_processes,         "procs");
	to_internal(so, s, max_concurrent_processes,"procs");

	to_internal(so, s, memory,         "MB");
	to_internal(so, s, virtual_memory, "MB");
	to_internal(so, s, swap_memory,    "MB");

	to_internal(so, s, bytes_read,    "MB");
	to_internal(so, s, bytes_written, "MB");

	to_internal(so, s, bytes_received, "MB");
	to_internal(so, s, bytes_sent,     "MB");
	to_internal(so, s, bandwidth,      "Mbps");

	to_internal(so, s, total_files, "files");
	to_internal(so, s, disk, "MB");

	rmsummary_print(output, s, /* pprint */ 1, /* extra fields */ 0);
	rmsummary_delete(s);

	return;
}
コード例 #12
0
 basic_command_line_parser<charT>::
 basic_command_line_parser(const std::vector<
                           std::basic_string<charT> >& args)
    : detail::cmdline(to_internal(args))
 {}
コード例 #13
0
ファイル: w32_CancelableWait.c プロジェクト: jiezh/h5vcc
static INLINE int
ptw32_cancelable_wait (HANDLE waitHandle, DWORD timeout)
     /*
      * -------------------------------------------------------------------
      * This provides an extra hook into the pthread_cancel
      * mechanism that will allow you to wait on a Windows handle and make it a
      * cancellation point. This function blocks until the given WIN32 handle is
      * signaled or pthread_cancel has been called. It is implemented using
      * WaitForMultipleObjects on 'waitHandle' and a manually reset WIN32
      * event used to implement pthread_cancel.
      * 
      * Given this hook it would be possible to implement more of the cancellation
      * points.
      * -------------------------------------------------------------------
      */
{
  int result;
  pthread_t self;
  ptw32_thread_t * sp;
  HANDLE handles[2];
  DWORD nHandles = 1;
  DWORD status;

  handles[0] = waitHandle;

  self = pthread_self();
  sp = (ptw32_thread_t *) to_internal(self).p;

  if (sp != NULL)
    {
      /*
       * Get cancelEvent handle
       */
      if (sp->cancelState == PTHREAD_CANCEL_ENABLE)
	{

	  if ((handles[1] = sp->cancelEvent) != NULL)
	    {
	      nHandles++;
	    }
	}
    }
  else
    {
      handles[1] = NULL;
    }

  status = WaitForMultipleObjects (nHandles, handles, PTW32_FALSE, timeout);

  switch (status - WAIT_OBJECT_0)
    {
    case 0:
      /*
       * Got the handle.
       * In the event that both handles are signalled, the smallest index
       * value (us) is returned. As it has been arranged, this ensures that
       * we don't drop a signal that we should act on (i.e. semaphore,
       * mutex, or condition variable etc).
       */
      result = 0;
      break;

    case 1:
      /*
       * Got cancel request.
       * In the event that both handles are signaled, the cancel will
       * be ignored (see case 0 comment).
       */
      ResetEvent (handles[1]);

      if (sp != NULL)
	{
          ptw32_mcs_local_node_t stateLock;
	  /*
	   * Should handle POSIX and implicit POSIX threads..
	   * Make sure we haven't been async-canceled in the meantime.
	   */
	  ptw32_mcs_lock_acquire (&sp->stateLock, &stateLock);
	  if (sp->state < PThreadStateCanceling)
	    {
	      sp->state = PThreadStateCanceling;
	      sp->cancelState = PTHREAD_CANCEL_DISABLE;
	      ptw32_mcs_lock_release (&stateLock);
	      ptw32_throw (PTW32_EPS_CANCEL);

	      /* Never reached */
	    }
	  ptw32_mcs_lock_release (&stateLock);
	}

      /* Should never get to here. */
      result = EINVAL;
      break;

    default:
      if (status == WAIT_TIMEOUT)
	{
	  result = ETIMEDOUT;
	}
      else
	{
	  result = EINVAL;
	}
      break;
    }

  return (result);

}				/* CancelableWait */
コード例 #14
0
ファイル: parsers.hpp プロジェクト: DCMF/Dawn-of-Civilization
 basic_command_line_parser<charT>::
 basic_command_line_parser(const std::vector<
                           std::basic_string<charT> >& args)
 : common_command_line_parser(to_internal(args))
 {}
コード例 #15
0
	Cursor operator[](Symbol symbol) const {
		return (*this)[to_internal(symbol)];
	}
コード例 #16
0
ファイル: pthread_getunique_np.c プロジェクト: jiezh/h5vcc
unsigned __int64
pthread_getunique_np (pthread_t thread)
{
  return ((ptw32_thread_t*)to_internal(thread).p)->seqNumber;
}