[openrtm-commit:02533] r2976 - in trunk/OpenRTM-aist/src/lib/coil/vxworks: . coil
openrtm @ openrtm.org
openrtm @ openrtm.org
2017年 3月 22日 (水) 14:30:54 JST
Author: miyamoto
Date: 2017-03-22 14:30:53 +0900 (Wed, 22 Mar 2017)
New Revision: 2976
Added:
trunk/OpenRTM-aist/src/lib/coil/vxworks/Makefile.am
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Makefile.am
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.cpp
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.h
trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/atomic.h
Log:
[new file] Copied file from posix to vxworks.
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/Makefile.am (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/Makefile.am 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,8 @@
+## -*- Makefile -*-
+##---------------------------------------------------------------------------
+## Makefile.am for coil (Component Object Infrastructure Layer)
+##
+## $Id$
+##---------------------------------------------------------------------------
+
+SUBDIRS = coil
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,25 @@
+// -*- C++ -*-
+/*!
+ * @file MutexPosix.h
+ * @brief RT-Middleware Service interface
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/Condition.h>
+
+namespace coil
+{
+ // no implementaion
+};
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Condition.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,200 @@
+// -*- C++ -*-
+/*!
+ * @file Condition_posix.h
+ * @brief Condition variable for POSIX
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_CONDITION_H
+#define COIL_CONDITION_H
+
+#include <pthread.h>
+#include <algorithm>
+#include <ctime>
+#include <sys/time.h>
+
+namespace coil
+{
+ /*!
+ * @if jp
+ *
+ * @class Condition
+ * @brief Condition テンプレートクラス
+ *
+ * @else
+ *
+ * @class Condition
+ * @brief Condition template class
+ *
+ * @endif
+ */
+ template <class M>
+ class Condition
+ {
+ public:
+
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ Condition(M& mutex)
+ : m_mutex(mutex)
+ {
+ ::pthread_cond_init(&m_cond, 0);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * デストラクタ。
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ ~Condition()
+ {
+ ::pthread_cond_destroy(&m_cond);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief スレッド実行の再開
+ *
+ * 待機しているスレッド実行を再開させる。
+ *
+ * @else
+ *
+ * @brief Resume of the thread practice
+ *
+ * Let the practice of a waiting thread resume.
+ *
+ * @endif
+ */
+ inline void signal()
+ {
+ ::pthread_cond_signal(&m_cond);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 全スレッド実行の再開
+ *
+ * 待機している全てのスレッド実行を再開させる。
+ *
+ * @else
+ *
+ * @brief Resume of all the thread practice
+ *
+ * Let all waiting thread practice resume.
+ *
+ * @endif
+ */
+ inline void broadcast()
+ {
+ ::pthread_cond_broadcast(&m_cond);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief スレッド実行の待機
+ *
+ * 条件変数が送信されるまでスレッドの実行を停止する。
+ *
+ * @return true: 成功, false: 失敗
+ *
+ * @else
+ *
+ * @brief Wait of the thread practice
+ *
+ * Stop the practice of the thread till a condition variable is transmitted.
+ *
+ * @return true: successful, false: failed
+ *
+ * @endif
+ */
+ bool wait()
+ {
+ return 0 == ::pthread_cond_wait(&m_cond, &m_mutex.mutex_);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 設定時間のスレッド実行待機
+ *
+ * 設定された時間、スレッドの実行を停止する。
+ *
+ * @param second 秒単位の時間
+ * @param nano_second ナノ秒単位の時間
+ *
+ * @return true: 成功, false: 失敗
+ *
+ * @else
+ *
+ * @brief Thread practice wait of set time
+ *
+ * In set time, stop the practice of the thread.
+ *
+ * @param second Time of the seconds.
+ * @param nano_second time of the nanoseconds.
+ *
+ * @return true: successful, false: failed
+ *
+ * @endif
+ */
+ bool wait(long second, long nano_second = 0)
+ {
+ struct timeval tv;
+ timespec abstime;
+
+ ::gettimeofday(&tv, NULL);
+ abstime.tv_sec = tv.tv_sec + second;
+ abstime.tv_nsec = tv.tv_usec * 1000 + nano_second;
+ if (abstime.tv_nsec >= 1000000000) {
+ abstime.tv_nsec -= 1000000000;
+ abstime.tv_sec ++;
+ }
+ return 0 == ::pthread_cond_timedwait(&m_cond, &m_mutex.mutex_, &abstime);
+ }
+
+ private:
+ Condition(const M&);
+ Condition& operator=(const M &);
+ pthread_cond_t m_cond;
+ M& m_mutex;
+ };
+};
+#endif // COIL_CONDITION_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,173 @@
+// -*- C++ -*-
+/*!
+ * @file DynamicLib.cpp
+ * @brief DynamicLib class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008 Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/DynamicLib.h>
+
+namespace coil
+{
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ DynamicLib::DynamicLib(int close_handle_on_destruction)
+ : m_closeflag(close_handle_on_destruction)
+ {
+ }
+
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ DynamicLib::DynamicLib(const char* dynlib_name,
+ int open_mode,
+ int close_handle_on_destruction)
+ : m_name(dynlib_name), m_mode(open_mode),
+ m_closeflag(close_handle_on_destruction)
+ {
+ if (open(m_name.c_str(), m_mode, m_closeflag) != 0)
+ {
+ throw std::bad_alloc();
+ }
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ DynamicLib::~DynamicLib()
+ {
+ close();
+ }
+
+ /*!
+ * @if jp
+ * @brief コピーコンストラクタ
+ * @else
+ * @brief Copy Constructor
+ * @endif
+ */
+ DynamicLib::DynamicLib(const DynamicLib& rhs)
+ : m_name(""), m_mode(0), m_closeflag(0), m_handle(0)
+ {
+ if (!rhs.m_name.empty() &&
+ open(rhs.m_name.c_str(), rhs.m_mode, rhs.m_closeflag) == 0)
+ return;
+// throw std::bad_alloc();
+ }
+
+ /*!
+ * @if jp
+ * @brief 代入演算子
+ * @else
+ * @brief Assignment operator
+ * @endif
+ */
+ DynamicLib& DynamicLib::operator=(const DynamicLib& rhs)
+ {
+ DynamicLib tmp(rhs);
+ std::swap(this->m_name, tmp.m_name);
+ std::swap(this->m_mode, tmp.m_mode);
+ std::swap(this->m_closeflag, tmp.m_closeflag);
+ std::swap(this->m_handle, tmp.m_handle);
+ return *this;
+ }
+
+ /*!
+ * @if jp
+ * @brief 動的リンクライブラリのロード
+ * @else
+ * @brief Load of the Dynamic link library
+ * @endif
+ */
+ int DynamicLib::open(const char* dll_name,
+ int open_mode,
+ int close_handle_on_destruction)
+ {
+ void* handle = ::dlopen(dll_name, open_mode);
+ if (handle == NULL)
+ {
+ return -1;
+ }
+ m_handle = handle;
+ m_name = dll_name;
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief 動的リンクライブラリのアンロード
+ * @else
+ * @brief Unload of the Dynamic link library
+ * @endif
+ */
+ int DynamicLib::close(void)
+ {
+ if (m_handle == NULL)
+ return -1;
+ if (m_name.empty())
+ {
+ return -1;
+ }
+ ::dlclose(m_handle);
+ m_handle = NULL;
+ m_name = "";
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief シンボルがロードされたメモリアドレスを返す
+ * @else
+ * @brief Return an address of the memory where a symbol was loaded
+ * @endif
+ */
+ void* DynamicLib::symbol(const char* symbol_name)
+ {
+ if (m_handle == NULL) return NULL;
+ return ::dlsym(m_handle, symbol_name);
+ }
+
+ /*!
+ * @if jp
+ * @brief エラーについての説明メッセージを返す
+ * @else
+ * @brief Return the explanation message about the error
+ * @endif
+ */
+ const char* DynamicLib::error(void) const
+ {
+ return ::dlerror();
+ }
+};
+
+/*!
+ * for unit test.
+ */
+extern "C"
+{
+ int ForExternTest(void) { return coil::DynamicLib::ForExternTest(); }
+}
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/DynamicLib.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,292 @@
+// -*- C++ -*-
+/*!
+ * @file DynamicLib_posix.h
+ * @brief DynamicLib class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008 Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_DYNAMICLIB_H
+#define COIL_DYNAMICLIB_H
+
+#include <dlfcn.h>
+#include <string>
+#include <coil/config_coil.h>
+
+#define COIL_DEFAULT_DYNLIB_MODE RTLD_LAZY
+
+extern "C"
+{
+ int ForExternTest(void);
+}
+
+namespace coil
+{
+ /*!
+ * @if jp
+ *
+ * @class DynamicLib
+ * @brief DynamicLib クラス
+ *
+ * @else
+ *
+ * @class DynamicLib
+ * @brief DynamicLib class
+ *
+ * @endif
+ */
+ class DynamicLib
+ {
+ public:
+
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @param close_handle_on_destruction クローズフラグ
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @param close_handle_on_destruction Close flag.
+ *
+ * @endif
+ */
+ DynamicLib(int close_handle_on_destruction = 1);
+
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @param dynlib_name 動的リンクライブラリ名称
+ * @param open_mode オープンモード
+ * @param close_handle_on_destruction クローズフラグ
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @param dynlib_name Dynamic link library name.
+ * @param open_mode Open mode.
+ * @param close_handle_on_destruction Close flag.
+ *
+ * @endif
+ */
+ DynamicLib(const char* dynlib_name,
+ int open_mode = COIL_DEFAULT_DYNLIB_MODE,
+ int close_handle_on_destruction = 1);
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * デストラクタ。
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~DynamicLib();
+
+ /*!
+ * @if jp
+ *
+ * @brief コピーコンストラクタ
+ *
+ * コピーコンストラクタ。
+ *
+ * @param rhs コピー元動的リンクライブラリオブジェクト
+ *
+ * @else
+ *
+ * @brief Copy Constructor
+ *
+ * Copy Constructor
+ *
+ * @param rhs Dynamic link library object of copy source.
+ *
+ * @endif
+ */
+ DynamicLib(const DynamicLib& rhs);
+
+ /*!
+ * @if jp
+ *
+ * @brief 代入演算子
+ *
+ * 動的リンクライブラリオブジェクトをコピーする。
+ *
+ * @param rhs 代入元動的リンクライブラリオブジェクト
+ *
+ * @return 代入結果
+ *
+ * @else
+ *
+ * @brief Assignment operator
+ *
+ * Copy a Dynamic link library object.
+ *
+ * @param rhs Dynamic link library object of assignment source.
+ *
+ * @return Assignment result.
+ *
+ * @endif
+ */
+ DynamicLib& operator=(const DynamicLib& rhs);
+
+ /*!
+ * @if jp
+ *
+ * @brief 動的リンクライブラリのロード
+ *
+ * 動的リンクライブラリをロードする。
+ *
+ * @param dll_name 動的リンクライブラリ名称
+ * @param open_mode オープンモード
+ * @param close_handle_on_destruction クローズフラグ
+ *
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ *
+ * @brief Load of the Dynamic link library
+ *
+ * Load of the Dynamic link library.
+ *
+ * @param dll_name Dynamic link library name.
+ * @param open_mode Open mode.
+ * @param close_handle_on_destruction Close flag.
+ *
+ * @return 0: successful, -1: failed
+ *
+ * @endif
+ */
+ virtual int open(const char* dll_name,
+ int open_mode = COIL_DEFAULT_DYNLIB_MODE,
+ int close_handle_on_destruction = 1);
+
+ /*!
+ * @if jp
+ *
+ * @brief 動的リンクライブラリのアンロード
+ *
+ * 動的リンクライブラリをアンロードする。
+ *
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ *
+ * @brief Unload of the Dynamic link library
+ *
+ * Unload of the Dynamic link library.
+ *
+ * @return 0: successful, -1: failed
+ *
+ * @endif
+ */
+ virtual int close(void);
+
+ /*!
+ * @if jp
+ *
+ * @brief シンボルがロードされたメモリアドレスを返す
+ *
+ * シンボルがロードされたメモリアドレスを返す。
+ *
+ * @param symbol_name シンボル名称
+ *
+ * @return メモリアドレス(NULL: 失敗)
+ *
+ * @else
+ *
+ * @brief Return an address of the memory where a symbol was loaded
+ *
+ * Return an address of the memory where a symbol was loaded.
+ *
+ * @param symbol_name Symbol name.
+ *
+ * @return Memory address.(NULL: failed)
+ *
+ * @endif
+ */
+ void *symbol (const char* symbol_name);
+
+ /*!
+ * @if jp
+ *
+ * @brief エラーについての説明メッセージを返す
+ *
+ * エラーについての説明メッセージを返す。
+ *
+ * @return エラーメッセージ(NULL: エラーなし)
+ *
+ * @else
+ *
+ * @brief Return the explanation message about the error
+ *
+ * Return the explanation message about the error.
+ *
+ * @return Error message.(NULL: not an error)
+ *
+ * @endif
+ */
+ const char* error(void) const;
+
+ /*!
+ * @if jp
+ *
+ * @brief ユニットテスト
+ *
+ * ユニットテストを行う。
+ *
+ * @return 0xdeadbeef
+ *
+ * @else
+ *
+ * @brief Unit Test
+ *
+ * Unit Test.
+ *
+ * @return 0xdeadbeef
+ *
+ * @endif
+ */
+ static int ForExternTest(void) { return 0xdeadbeef; }
+
+ private:
+ std::string m_name;
+ int m_mode;
+ int m_closeflag;
+ void* m_handle;
+ int m_error;
+ };
+
+};
+
+#endif // DynamicLib_h
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/File.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,194 @@
+// -*- C++ -*-
+/*!
+ * @file File_posix.h
+ * @brief File functions
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_FILE_H
+#define COIL_FILE_H
+
+#include <cstring>
+#include <sys/types.h>
+#include <dirent.h>
+#include <libgen.h>
+
+#include <coil/config_coil.h>
+#include <coil/stringutil.h>
+
+#ifdef __QNX__
+using std::strlen;
+using std::strcpy;
+#endif
+
+namespace coil
+{
+
+ /*!
+ * @if jp
+ *
+ * @brief ファイルパスよりディレクトリ部分を取得する
+ *
+ * ファイルパスよりディレクトリ部分を取得する。
+ *
+ * @param path ファイルパス
+ *
+ * @return ディレクトリ名称
+ *
+ * @else
+ *
+ * @brief Get a directory part than a file pass
+ *
+ * Get a directory part than a file pass.
+ *
+ * @param path File path
+ *
+ * @return Directory name
+ *
+ * @endif
+ */
+ inline std::string dirname(char* path)
+ {
+ char path_name[strlen(path)+1];
+ strcpy(path_name, path);
+ std::string dir_name = ::dirname(path);
+ return dir_name;
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief ファイルパスよりファイル名部分を取得する
+ *
+ * ファイルパスよりファイル名部分を取得する。
+ *
+ * @param path ファイルパス
+ *
+ * @return ファイル名称
+ *
+ * @else
+ *
+ * @brief Get a file name part than a file pass
+ *
+ * Get a directory part than a file pass.
+ *
+ * @param path File path
+ *
+ * @return File name
+ *
+ * @endif
+ */
+ inline std::string basename(const char* path)
+ {
+ char path_name[strlen(path)+1];
+ strcpy(path_name, path);
+ std::string base_name = ::basename(path_name);
+ return base_name;
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief ファイルリストを取得する
+ *
+ * ディレクトリパスの中で指定ファイルにマッチするリストを取得する。
+ *
+ * @param path ディレクトリパス
+ * @param glob_str ファイル名
+ *
+ * @return ファイルリスト
+ *
+ * @else
+ *
+ * @brief Get file list
+ *
+ * Get a list matching a file designated than a directory path.
+ *
+ * @param path Directory path
+ * @param glob_str File name
+ *
+ * @return File list
+ *
+ * @endif
+ */
+ inline coil::vstring filelist(const char* path, const char* glob_str = "")
+ {
+ struct dirent* ent;
+ coil::vstring flist;
+ bool has_glob(false);
+ std::string pattern;
+
+ if (path == 0) { return flist; }
+ if (glob_str[0] != '\0') { has_glob = true; }
+
+ DIR* dir_ptr(::opendir(path));
+ if (dir_ptr == 0) { return flist; }
+
+ while ((ent = ::readdir(dir_ptr)) != 0)
+ {
+ bool match(true);
+ if (has_glob)
+ {
+ const char* globc(glob_str);
+ std::string fname(ent->d_name);
+ for (size_t i(0); i < fname.size() && *globc != '\0'; ++i, ++globc)
+ {
+ if (*globc == '*')
+ {
+ // the last '*' matches every thing
+ if (globc[1] == '\0') { break; }
+ // consecutive * or + are skiped, but fname keeps pointer
+ if (globc[1] == '*' || globc[1] == '+') { --i; continue; }
+
+ // advance pointer and find normal characters
+ ++globc;
+ size_t pos(fname.find(*globc, i));
+ if (pos == std::string::npos) { match = false; break; }
+ // matched, and advance i to pos
+ i = pos;
+ }
+ else if (*globc == '+')
+ {
+ // the last '+' matches last one or more characters
+ if (globc[1] == '\0' && !(i + 1 < fname.size())) { break; }
+ // consecutive * or + are skiped, but fname keeps pointer
+ if (globc[1] == '*' || globc[1] == '+') { --i; continue; }
+
+ // advance pointer and find normal characters
+ ++globc;
+ size_t pos(fname.find(*globc, i + 1));
+ if (pos == std::string::npos) { match = false; break; }
+ // matched, and advance i to pos
+ i = pos;
+ }
+ else
+ {
+ if (fname[i] != *globc) { match = false; }
+ }
+
+ // in the last fname character, if glob is not end,
+ // or *, fname is not matched.
+ if (i + 1 == fname.size() &&
+ globc[1] != '\0' && globc[1] != '*') { match = false; }
+ }
+ }
+ if (match) { flist.push_back(ent->d_name); }
+ }
+ ::closedir(dir_ptr);
+
+ return flist;
+ }
+};
+
+#endif // COIL_FILE_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Makefile.am
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Makefile.am (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Makefile.am 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,93 @@
+## -*- Makefile -*-
+##---------------------------------------------------------------------------
+## Makefile.am for coil (Component Object Infrastructure Layer)
+##
+## $Id$
+##---------------------------------------------------------------------------
+
+AM_CPPFLAGS=-I.. -I$(top_srcdir)/include
+DEFAULT_INCLUDES=
+
+# posix API dependent sources
+COIL_PLATFORM_SRC = \
+ Condition.cpp \
+ DynamicLib.cpp \
+ Mutex.cpp \
+ Process.cpp \
+ Routing.cpp \
+ Signal.cpp \
+ Task.cpp \
+ Time.cpp \
+ UUID.cpp
+
+# posix API dependent headers
+COIL_PLATFORM_H = \
+ atomic.h \
+ File.h \
+ OS.h \
+ $(COIL_PLATFORM_SRC:.cpp=.h)
+
+# coil common source
+COIL_COMMON_SRC = \
+ Allocator.cpp \
+ PeriodicTask.cpp \
+ Properties.cpp \
+ TimeMeasure.cpp \
+ TimeValue.cpp \
+ Timer.cpp \
+ ClockManager.cpp \
+ crc.cpp \
+ stringutil.cpp
+
+# coil common headers
+COIL_COMMON_H = \
+ Allocator.h \
+ Async.h \
+ Factory.h \
+ Guard.h \
+ Listener.h \
+ Logger.h \
+ NonCopyable.h \
+ PeriodicTask.h \
+ PeriodicTaskBase.h \
+ Properties.h \
+ Singleton.h \
+ TimeMeasure.h \
+ TimeValue.h \
+ Timer.h \
+ ClockManager.h \
+ crc.h \
+ stringutil.h
+
+
+# coil all sources and headers
+COIL_SRC = $(COIL_COMMON_SRC) $(COIL_PLATFORM_SRC)
+COIL_H = $(COIL_COMMON_H) $(COIL_PLATFORM_H)
+COIL_ALL = $(COIL_SRC) $(COIL_H)
+
+$(COIL_COMMON_SRC): $(COIL_COMMON_H)
+ cp -p $(top_srcdir)/common/$@ .
+
+$(COIL_COMMON_H):
+ cp -p $(top_srcdir)/common/$@ .
+
+
+coilheaderdir = $(coil_includedir)/coil
+
+coilheader_HEADERS = $(COIL_H) $(top_srcdir)/include/coil/config_coil.h
+
+lib_LTLIBRARIES = libcoil.la
+#noinst_LTLIBRARIES = libcoil.la
+
+libcoil_la_SOURCES = \
+ $(COIL_ALL)
+
+libcoil_la_LDFLAGS = \
+ -no-undefined \
+ -release $(PACKAGE_VERSION)
+
+clean-local:
+ rm -f *~
+ rm -f *.o *.lo *.loT
+ rm -f $(COIL_COMMON_SRC) $(COIL_COMMON_H)
+ chmod 644 *.cpp *.h
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,20 @@
+// -*- C++ -*-
+/*!
+ * @file MutexPosix.h
+ * @brief RT-Middleware Service interface
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/Mutex.h>
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Mutex.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,165 @@
+// -*- C++ -*-
+/*!
+ * @file Mutex_posix.h
+ * @brief coil POSIX mutex class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_MUTEX_H
+#define COIL_MUTEX_H
+
+#include <pthread.h>
+
+namespace coil
+{
+ /*!
+ * @if jp
+ *
+ * @class Mutex
+ * @brief Mutex クラス
+ *
+ * @else
+ *
+ * @class Mutex
+ * @brief Mutex class
+ *
+ * @endif
+ */
+ class Mutex
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @param name オブジェクト名
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @param name Object name
+ *
+ * @endif
+ */
+ Mutex(const char * const name = 0)
+ {
+ ::pthread_mutex_init(&mutex_, 0);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * デストラクタ。
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ ~Mutex()
+ {
+ ::pthread_mutex_destroy(&mutex_);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 排他制御のロック
+ *
+ * 排他制御のロックを行う。
+ *
+ * @else
+ *
+ * @brief Mutual exclusion lock
+ *
+ * Lock the Mutual exclusion.
+ *
+ * @endif
+ */
+ inline void lock()
+ {
+ ::pthread_mutex_lock(&mutex_);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 排他制御のノンブロッキングロック
+ *
+ * 排他制御のロックをノンブロッキングで行う。
+ *
+ * @else
+ *
+ * @brief Mutual exclusion non-blocking lock
+ *
+ * Lock the Mutual exclusion by non-blocking.
+ *
+ * @endif
+ */
+ inline bool trylock()
+ {
+ return ::pthread_mutex_trylock(&mutex_);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 排他制御のロック解除
+ *
+ * 排他制御のロック解除を行う。
+ *
+ * @else
+ *
+ * @brief Mutual exclusion unlock
+ *
+ * Unlock the Mutual exclusion.
+ *
+ * @endif
+ */
+ inline void unlock()
+ {
+ ::pthread_mutex_unlock(&mutex_);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 排他制御オブジェクト
+ *
+ * @else
+ *
+ * @brief Mutual exclusion object
+ *
+ * @endif
+ */
+ pthread_mutex_t mutex_;
+
+ private:
+ Mutex(const Mutex&);
+ Mutex& operator=(const Mutex &);
+ };
+};
+#endif // COIL_MUTEX_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/OS.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,274 @@
+// -*- C++ -*-
+/*!
+ * @file OS_posix.h
+ * @brief OS class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_OS_H
+#define COIL_OS_H
+
+#include <string>
+#include <sys/utsname.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+extern "C"
+{
+ extern char *optarg;
+};
+
+namespace coil
+{
+ /*!
+ * @if jp
+ *
+ * @brief システム情報取得
+ *
+ * システム情報を構造体に設定して返す。
+ *
+ * @param name 構造体名称
+ *
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ *
+ * @brief Get System information
+ *
+ * Return a system information to a structure.
+ *
+ * @param name Name of structure
+ *
+ * @return 0: Successful, -1: failed
+ *
+ * @endif
+ */
+ typedef ::utsname utsname;
+ inline int uname(utsname* name)
+ {
+ return ::uname(name);
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 呼び出し元プロセスのプロセスID取得
+ *
+ * 呼び出し元プロセスのプロセスIDを返す。
+ *
+ * @return プロセスID
+ *
+ * @else
+ *
+ * @brief Get process ID of the caller process
+ *
+ * Return a process ID of the caller process.
+ *
+ * @return Process ID
+ *
+ * @endif
+ */
+ typedef ::pid_t pid_t;
+ inline pid_t getpid()
+ {
+ return ::getpid();
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 呼び出し元プロセスの親プロセスのプロセスID取得
+ *
+ * 呼び出し元プロセスの親プロセスのプロセスIDを返す。
+ *
+ * @return プロセスID
+ *
+ * @else
+ *
+ * @brief Get process ID of the parent process
+ *
+ * Return a process ID of the parent process.
+ *
+ * @return Process ID
+ *
+ * @endif
+ */
+ inline pid_t getppid()
+ {
+ return ::getppid();
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief 環境変数取得
+ *
+ * 環境変数を返す。
+ *
+ * @param name 環境変数名称
+ *
+ * @return 環境変数の値(NULL: 該当なし)
+ *
+ * @else
+ *
+ * @brief Get environment variable
+ *
+ * Return a environment variable.
+ *
+ * @param name Name of environment variable
+ *
+ * @return Value of environment variable(NULL: nonexistent)
+ *
+ * @endif
+ */
+ inline char* getenv(const char *name)
+ {
+ return ::getenv(name);
+ }
+
+
+ /* Global Variables for getopt() */
+
+ /*!
+ * @if jp
+ *
+ * @class GetOpt
+ * @brief GetOpt クラス
+ *
+ * @else
+ *
+ * @class GetOpt
+ * @brief GetOpt class
+ *
+ * @endif
+ */
+ class GetOpt
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @param name オブジェクト名
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @param name Object name
+ *
+ * @endif
+ */
+ GetOpt(int argc, char* const argv[], const char* opt, int flag)
+ : optarg(::optarg), optind(1), opterr(1), optopt(0), m_argc(argc), m_argv(argv), m_opt(opt), m_flag(flag)
+ {
+ ::optind = 1;
+#ifdef __QNX___
+ optind_last = 1;
+#endif
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * デストラクタ。
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ ~GetOpt()
+ {
+ ::optind = 1;
+#ifdef __QNX__
+ optind_last = 1;
+#endif
+ }
+
+ /*!
+ * @if jp
+ *
+ * @brief コマンドライン引数解析
+ *
+ * コマンドライン引数を解析する。
+ *
+ * @return 解析結果
+ *
+ * @else
+ *
+ * @brief Parses the command line arguments
+ *
+ * Parses the command line arguments.
+ *
+ * @return Result of parses.
+ *
+ * @endif
+ */
+ int operator()()
+ {
+ ::opterr = opterr;
+#ifndef __QNX__
+ ::optind = optind;
+#else
+ ::optind = optind_last;
+ ::optarg = 0;
+#endif
+ int result = getopt(m_argc, m_argv, m_opt);
+#ifdef __QNX__
+ if(::optind == optind_last)
+ {
+ ::optind++;
+ result = getopt(m_argc, m_argv, m_opt);
+ optind_last = ::optind;
+ }
+#endif
+ optarg = ::optarg;
+ optind = ::optind;
+ optopt = ::optopt;
+#if __QNX__
+ if(optind_last < m_argc) { ++optind_last; }
+#endif
+ return result;
+ }
+
+ char* optarg; //! オプション引数
+ int optind; //! 処理対象引数
+ int opterr; //! エラー表示 0:抑止、1:表示
+ int optopt; //! オプション文字が足りない時、多い時にセットされる
+#ifdef __QNX__
+ int optind_last;
+#endif
+
+ private:
+ int m_argc;
+ char* const * m_argv;
+ const char* m_opt;
+ int m_flag;
+ };
+
+};
+
+#endif // COIL_OS_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,84 @@
+// -*- C++ -*-
+/*!
+ * @file Process.h
+ * @brief Process handling functions
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2010
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_PROCESS_H
+#define COIL_PROCESS_H
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <coil/stringutil.h>
+
+namespace coil
+{
+
+ /*!
+ * @if jp
+ * @brief プロセスを起動する
+ * @else
+ * @brief Launching a process
+ * @endif
+ */
+ int launch_shell(std::string command)
+ {
+ signal(SIGCHLD, SIG_IGN);
+
+ pid_t pid;
+ if((pid = fork()) < 0 )
+ { // fork failed
+ return -1;
+ }
+
+ if (pid == 0) // I'm child process
+ {
+ // signal(SIGCHLD, SIG_IGN);
+ // signal(SIGALRM, SIG_IGN);
+ // signal(SIGHUP , SIG_IGN);
+ // signal(SIGPIPE, SIG_IGN);
+ // signal(SIGTERM, SIG_IGN);
+ setsid();
+ // close(0);
+ // close(1);
+ // close(2);
+ // open("/dev/null", O_RDWR);
+ // dup2(0, 1);
+ // dup2(0, 2);
+ // umask(0);
+
+ coil::vstring vstr(::coil::split(command, " "));
+ char* const * argv = ::coil::toArgv(vstr);
+
+ execvp(vstr.front().c_str(), argv);
+
+ return -1;
+ }
+ return 0;
+ }
+
+ int daemon(int nochdir, int noclose)
+ {
+ return daemon(nochdir, noclose);
+ }
+
+
+}; // namespace coil
+#endif // COIL_PROCESS_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Process.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,62 @@
+// -*- C++ -*-
+/*!
+ * @file Process.h
+ * @brief Process handling functions
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2010
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_PROCESS_H
+#define COIL_PROCESS_H
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <libgen.h>
+#include <coil/stringutil.h>
+
+namespace coil
+{
+
+ /*!
+ * @if jp
+ * @brief プロセスを起動する
+ *
+ * プロセスを起動する。引数には起動するファイル名を与える。実行ファイ
+ * ルは環境変数 PATH に設定されたコマンドサーチパス内から検索され、見
+ * つかればコマンドが起動される。プロセスの起動が成功すれば 0、失敗す
+ * れば -1 を返す。
+ *
+ * @param command 起動する実行ファイルのフルパス
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ * @brief Launching a process
+ *
+ * This function launches a process. The argument is command file
+ * name be launched. The command will be searched according to the
+ * environment variable PATH of command search path. 0 will be
+ * returned if launching process is successful, and -1 will be
+ * returned if it is failed.
+ *
+ * @param command full path string to a command to be executed.
+ * @return 0: successful, -1: failed
+ *
+ * @endif
+ */
+ int launch_shell(std::string command);
+
+ int daemon(int nochdir, int noclose);
+
+}; // namespace coil
+#endif // COIL_PROCESS_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,172 @@
+// -*- C++ -*-
+/*!
+ * @file Routing.cpp
+ * @brief Network routing information handling functions
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2010
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <stdio.h>
+#include <netdb.h> // gethostbyname
+#include <arpa/inet.h> // inet_ntoa
+#include <netinet/in.h> // sockaddr_in
+#include <sys/wait.h>
+
+#include <coil/Routing.h>
+#include <coil/stringutil.h>
+#include <coil/config_coil.h>
+
+namespace coil
+{
+ /*!
+ * @if jp
+ * @brief 宛先アドレスから利用されるエンドポイントアドレスを得る
+ * @else
+ * @brief Getting network interface name from destination address
+ * @endif
+ */
+ bool dest_to_endpoint(std::string dest_addr, std::string& endpoint)
+ {
+ std::string dest_if;
+ if (!find_dest_ifname(dest_addr, dest_if))
+ {
+ return false;
+ }
+ return ifname_to_ipaddr(dest_if, endpoint);
+ }
+
+ /*!
+ * @if jp
+ * @brief 宛先アドレスから利用されるネットワークインターフェース名を得る
+ * @else
+ * @brief Getting network interface name from destination address
+ * @endif
+ */
+ bool find_dest_ifname(std::string dest_addr, std::string& dest_if)
+ {
+ // This logic should be replaced by direct retrieving using
+ // routing interface like AFROUTE or sysctl.
+ struct ::hostent *hostent;
+ struct ::sockaddr_in addr;
+
+ hostent = gethostbyname(dest_addr.c_str());
+ addr.sin_addr.s_addr = **(unsigned int **)(hostent->h_addr_list);
+ dest_addr = inet_ntoa(addr.sin_addr);
+
+#if defined(COIL_OS_FREEBSD) || defined(COIL_OS_DARWIN) || defined(COIL_OS_CYGWIN) || defined(COIL_OS_QNX)
+ std::string cmd("PATH=/bin:/sbin:/usr/bin:/usr/sbin "
+ "route get ");
+ const char* match_str = "interface";
+ const char* delimiter = ":";
+ size_t ifname_pos(1);
+ cmd += dest_addr;
+ cmd += " 2> /dev/null";
+#endif // COIL_OS_IS_FREEBSD || COIL_OS_DARWIN || COIL_OS_CYGWIN || COIL_OS_QNX
+#if defined(COIL_OS_LINUX)
+ std::string cmd("PATH=/bin:/sbin:/usr/bin:/usr/sbin "
+ "ip route get ");
+ const char* match_str = "dev ";
+ const char* delimiter = " ";
+ size_t ifname_pos(2);
+ cmd += dest_addr;
+ cmd += " 2> /dev/null";
+#endif // COIL_OS_IS_LINUX
+
+ FILE* fp;
+ if ((fp = popen(cmd.c_str(), "r")) == NULL)
+ {
+ return false;
+ }
+
+ do
+ {
+ char str[512];
+ fgets(str, 512, fp);
+ std::string line(str);
+
+ if (std::string::npos == line.find(match_str)) { continue; }
+
+ line.erase(line.end() - 1);
+ coil::vstring vs(coil::split(line, delimiter));
+
+#if defined(COIL_OS_FREEBSD) || defined(COIL_OS_DARWIN) || defined(COIL_OS_CYGWIN) || defined(COIL_OS_QNX)
+ if (vs.size() > ifname_pos)
+ {
+ dest_if = vs[ifname_pos];
+ pclose(fp);
+ wait(NULL);
+ return true;
+ }
+#endif // COIL_OS_FREEBSD || COIL_OS_DARWIN || COIL_OS_CYGWIN || COIL_OS_QNX
+#if defined(COIL_OS_LINUX)
+ for (int i(0); i < vs.size(); ++i)
+ {
+ if (vs[i] == "dev")
+ {
+ dest_if = vs[i + 1];
+ pclose(fp);
+ return true;
+ }
+ }
+#endif // COIL_OS_LINUX
+ } while (!feof(fp));
+ pclose(fp);
+ wait(NULL);
+ return false;
+ }
+
+ /*!
+ * @if jp
+ * @brief ネットワークインターフェース名からIPアドレスを得る
+ * @else
+ * @brief Get IP address from a network interface name
+ * @endif
+ */
+ bool ifname_to_ipaddr(std::string ifname, std::string& ipaddr)
+ {
+ std::string cmd("ifconfig ");
+ cmd += ifname;
+ cmd += " 2> /dev/null";
+
+ FILE* fp;
+ if ((fp = popen(cmd.c_str(), "r")) == NULL)
+ {
+ return false;
+ }
+
+ do
+ {
+ char str[512];
+ fgets(str, 512, fp);
+ std::string line(str);
+
+ if (std::string::npos == line.find("inet ")) { continue; }
+
+ line.erase(line.end() - 1);
+ coil::eraseHeadBlank(line);
+ coil::vstring vs(coil::split(line, " "));
+ if (vs.size() == 6)
+ {
+ ipaddr = vs[1];
+ pclose(fp);
+ wait(NULL);
+ return true;
+ }
+ } while (!feof(fp));
+ pclose(fp);
+ wait(NULL);
+ return false;
+ }
+
+}; // namespace coil
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Routing.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,124 @@
+// -*- C++ -*-
+/*!
+ * @file Routing.h
+ * @brief Network routing information handling functions
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2010
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_ROUTING_H
+#define COIL_ROUTING_H
+
+#include <string>
+
+namespace coil
+{
+ /*!
+ * @if jp
+ * @brief 宛先アドレスから利用されるエンドポイントアドレスを得る
+ *
+ * 宛先アドレスを与えると、その際に利用されるエンドポイントのアドレス
+ * が返される。宛先アドレス dest_addr には、IPアドレスまたはFQDNホス
+ * ト名を与えることができる。宛先アドレスが到
+ * 達可能であり、利用するエンドポイントが得られた場合 true、宛先アド
+ * レスに到達できない場合は false が返される。
+ *
+ * @param dest_addr 宛先アドレスまたはホスト名
+ * @param dest_if 宛先と通信を行う際に使用されるインターフェース名
+ * @return 成功 true, 失敗 false
+ *
+ * @else
+ * @brief Getting network interface name from destination address
+ *
+ * This operation returns IP address of a endpoint to be used to
+ * communicate with the given destination address. IP address and
+ * FQDN hostname are available for the destination address
+ * dest_addr. If a destination address are reachable and an endpoint
+ * IP address is available, this operation returns true, and
+ * otherwise false.
+ *
+ * @param dest_addr a destination address or host name
+ * @param endpoint a IP address of the endpoint to be used to communicate
+ * with the destination address
+ * @return successful: true, failed: false
+ *
+ * @endif
+ */
+ bool dest_to_endpoint(std::string dest_addr, std::string& endpoint);
+
+ /*!
+ * @if jp
+ * @brief 宛先アドレスから利用されるネットワークインターフェース名を得る
+ *
+ * 宛先アドレスを与えると、その際に利用されるネットワークインターフェー
+ * ス名をルーティングテーブルから取得する。宛先アドレス dest_addr に
+ * は、IPアドレスまたはFQDNホスト名を与えることができる。返される
+ * dest_if はネットワークインターフェース名である。宛先アドレスが到達
+ * 可能であり、利用するネットワークインターフェース名が得られた場合
+ * true、宛先アドレスに到達できない場合は false が返される。
+ *
+ * @param dest_addr 宛先アドレスまたはホスト名
+ * @param dest_if 宛先と通信を行う際に使用されるインターフェース名
+ * @return 成功 true, 失敗 false
+ *
+ * @else
+ * @brief Getting network interface name from destination address
+ *
+ * This operation returns network interface name to be used to
+ * communicate with the given destination address. IP address and
+ * FQDN hostname are available for the destination address
+ * dest_addr. Returned dest_if means the network interface name. If
+ * a destination address are reachable and network interface name is
+ * available, this operation returns true, and otherwise false.
+ *
+ * @param dest_addr a destination address or host name
+ * @param dest_if a network interface name to be used to communicate
+ * with the destination address
+ * @return successful: true, failed: false
+ *
+ * @endif
+ */
+ bool find_dest_ifname(std::string dest_addr, std::string& dest_if);
+
+ /*!
+ * @if jp
+ * @brief ネットワークインターフェース名からIPアドレスを得る
+ *
+ * ネットワークインターフェース名を与えると、当該インターフェースに割
+ * り当てられたIPアドレスを返す。IPアドレスが割り当てられていない場合
+ * は、falseが返される。
+ *
+ * @param ifname ネットワークインターフェース名
+ * @param ipaddr ネットワークインターフェースに割り当てられたIPアドレス
+ * @return 成功 true, 失敗 false
+ *
+ * @else
+ * @brief Get IP address from a network interface name
+ *
+ * This operation returns IP address which is assigned with the
+ * given network interface. If IP address could be obtained from the
+ * network interface name, this operation returns true, otherwise
+ * false.
+ *
+ * @param ifname a network interface name
+ * @param ipaddr IP address that is assigned to the network interface
+ * @return successful: true, failed: false
+ *
+ * @endif
+ */
+ bool ifname_to_ipaddr(std::string ifname, std::string& ipaddr);
+
+
+ }; //namespace coil
+#endif // COIL_ROUTING_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,87 @@
+// -*- C++ -*-
+/*!
+ * @file Signal_posix.cpp
+ * @brief SignalAction class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/config_coil.h>
+#include <coil/Signal.h>
+#include <string.h>
+
+#ifdef COIL_OS_FREEBSD
+#define _SIGSET_NWORDS _SIG_WORDS
+#endif
+
+namespace coil
+{
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ SignalAction::SignalAction()
+ : m_handle(0), m_signum(0), m_mask(0), m_flags(0)
+ {
+ }
+
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @param handle シグナルハンドラ
+ * @param signum シグナル番号
+ * @else
+ * @brief Constructor
+ * @param handle Signal handler.
+ * @param signum Signal number.
+ * @endif
+ */
+ SignalAction::SignalAction(SignalHandler handle, int signum)
+ : m_handle(handle), m_signum(signum), m_mask(0), m_flags(0)
+ {
+ struct sigaction action;
+ memset(&action, 0, sizeof(action)); // clear.
+ action.sa_handler = m_handle;
+
+ signal(m_signum, SIG_IGN);
+ if (sigaction(m_signum, &action, 0) < 0)
+ {
+ signal(m_signum, SIG_DFL);
+ m_handle = 0;
+ m_signum = 0;
+ m_mask = 0;
+ m_flags = 0;
+ }
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ SignalAction::~SignalAction()
+ {
+ signal(m_signum, SIG_DFL);
+ m_handle = 0;
+ m_signum = 0;
+ m_mask = 0;
+ m_flags = 0;
+ }
+
+};
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Signal.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,112 @@
+// -*- C++ -*-
+/*!
+ * @file Signal_posix.h
+ * @brief SignalAction class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_SIGNAL_H
+#define COIL_SIGNAL_H
+
+#include <signal.h>
+
+namespace coil
+{
+ typedef void (*SignalHandler)(int);
+
+ /*!
+ * @if jp
+ *
+ * @class SignalAction
+ * @brief SignalAction クラス
+ *
+ * @else
+ *
+ * @class SignalAction
+ * @brief SignalAction class
+ *
+ * @endif
+ */
+ class SignalAction
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ SignalAction();
+
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ。
+ *
+ * @param handle シグナルハンドラ
+ * @param signum シグナル番号
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @param handle Signal handler.
+ * @param signum Signal number.
+ *
+ * @endif
+ */
+ SignalAction(SignalHandler handle, int signum);
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * デストラクタ。
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ ~SignalAction();
+
+ private:
+ SignalAction(const SignalAction&);
+ SignalAction& operator=(const SignalAction &);
+ SignalHandler m_handle;
+ int m_signum;
+ sigset_t* m_mask;
+ int m_flags;
+
+ };
+};
+#endif // COIL_SIGNAL_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,186 @@
+// -*- C++ -*-
+/*!
+ * @file Task_posix.cpp
+ * @brief Task class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/Task.h>
+
+namespace coil
+{
+
+ /*!
+ * @if jp
+ * @brief コンストラクタ
+ * @else
+ * @brief Constructor
+ * @endif
+ */
+ Task::Task()
+ : m_count(0)
+ {
+ ::pthread_attr_init(&m_attr);
+ }
+
+ /*!
+ * @if jp
+ * @brief デストラクタ
+ * @else
+ * @brief Destructor
+ * @endif
+ */
+ Task::~Task()
+ {
+ m_count = 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief タスクオープン
+ * @else
+ * @brief Task open
+ * @endif
+ */
+ int Task::open(void* args)
+ {
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief タスククローズ
+ * @else
+ * @brief Task close
+ * @endif
+ */
+ int Task::close(unsigned long flags)
+ {
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief スレッドを実行する
+ * @else
+ * @brief Execute thread
+ * @endif
+ */
+ int Task::svc()
+ {
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief スレッドを生成する
+ * @else
+ * @brief Create a thread
+ * @endif
+ */
+ void Task::activate()
+ {
+ if (m_count == 0)
+ {
+ ::pthread_create(&m_thread,
+ &m_attr,
+ (void* (*)(void*))Task::svc_run,
+ this);
+ ++m_count;
+ };
+ }
+
+ /*!
+ * @if jp
+ * @brief スレッド終了を待つ
+ * @else
+ * @brief Waiting for the thread terminate
+ * @endif
+ */
+ int Task::wait(void)
+ {
+ if (m_count > 0)
+ {
+ void* retval;
+ ::pthread_join(m_thread, &retval);
+ }
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief タスク実行を中断する
+ * @else
+ * @brief Suspending the task
+ * @endif
+ */
+ int Task::suspend(void)
+ {
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief 中断されているタスクを再開する
+ * @else
+ * @brief Resuming the suspended task
+ * @endif
+ */
+ int Task::resume(void)
+ {
+ return 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief タスク数リセット
+ * @else
+ * @brief Reset of task count
+ * @endif
+ */
+ void Task::reset()
+ {
+ m_count = 0;
+ }
+
+ /*!
+ * @if jp
+ * @brief タスク実行を終了する
+ * @else
+ * @brief Finalizing the task
+ * @endif
+ */
+ void Task::finalize()
+ {
+ reset();
+ }
+
+ /*!
+ * @if jp
+ * @brief スレッド実行を開始する
+ * @else
+ * @brief Start thread Execution
+ * @endif
+ */
+ void* Task::svc_run(void* args)
+ {
+ Task* t = (coil::Task*)args;
+ int status;
+ status = t->svc();
+ t->finalize();
+ return 0;
+ }
+};
+
+
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Task.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,267 @@
+// -*- C++ -*-
+/*!
+ * @file Task_posix.h
+ * @brief Task class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_TASK_H
+#define COIL_TASK_H
+
+#include <pthread.h>
+
+namespace coil
+{
+ /*!
+ * @if jp
+ *
+ * @class Task
+ * @brief Task クラス
+ *
+ * @else
+ *
+ * @class Task
+ * @brief Task class
+ *
+ * @endif
+ */
+ class Task
+ {
+ public:
+ /*!
+ * @if jp
+ *
+ * @brief コンストラクタ
+ *
+ * コンストラクタ
+ *
+ * @else
+ *
+ * @brief Constructor
+ *
+ * Constructor
+ *
+ * @endif
+ */
+ Task();
+
+ /*!
+ * @if jp
+ *
+ * @brief デストラクタ
+ *
+ * デストラクタ
+ *
+ * @else
+ *
+ * @brief Destructor
+ *
+ * Destructor
+ *
+ * @endif
+ */
+ virtual ~Task();
+
+ /*!
+ * @if jp
+ *
+ * @brief タスクオープン
+ *
+ * タスクオープン
+ *
+ * @param args 引数
+ *
+ * @else
+ *
+ * @brief Task open
+ *
+ * Task open
+ *
+ * @param args Arguments
+ *
+ * @endif
+ */
+ virtual int open(void* args = 0);
+
+ /*!
+ * @if jp
+ *
+ * @brief タスククローズ
+ *
+ * タスククローズ
+ *
+ * @param flags フラグ
+ *
+ * @else
+ *
+ * @brief Task close
+ *
+ * Task close
+ *
+ * @param flags Flags
+ *
+ * @endif
+ */
+ virtual int close(unsigned long flags = 0);
+
+ /*!
+ * @if jp
+ *
+ * @brief スレッドを実行する
+ *
+ * スレッドを実行する
+ *
+ * @else
+ *
+ * @brief Execute thread
+ *
+ * Execute thread
+ *
+ * @endif
+ */
+ virtual int svc();
+
+ /*!
+ * @if jp
+ *
+ * @brief スレッドを生成する
+ *
+ * スレッドを生成する
+ *
+ * @else
+ *
+ * @brief Create a thread
+ *
+ * Create a thread
+ *
+ * @endif
+ */
+ virtual void activate();
+
+ /*!
+ * @if jp
+ *
+ * @brief スレッド終了を待つ
+ *
+ * スレッド終了を待つ
+ *
+ * @else
+ *
+ * @brief Waiting for the thread terminate
+ *
+ * Waiting for the thread terminate
+ *
+ * @endif
+ */
+ virtual int wait(void);
+
+ /*!
+ * @if jp
+ *
+ * @brief タスク実行を中断する
+ *
+ * タスク実行を中断する
+ *
+ * @else
+ *
+ * @brief Suspending the task
+ *
+ * Suspending the task
+ *
+ * @endif
+ */
+ virtual int suspend(void);
+
+ /*!
+ * @if jp
+ *
+ * @brief 中断されているタスクを再開する
+ *
+ * 中断されているタスクを再開する
+ *
+ * @else
+ *
+ * @brief Resuming the suspended task
+ *
+ * Resuming the suspended task
+ *
+ * @endif
+ */
+ virtual int resume(void);
+
+ /*!
+ * @if jp
+ *
+ * @brief タスク数リセット
+ *
+ * タスク数リセット
+ *
+ * @else
+ *
+ * @brief Reset of task count
+ *
+ * Reset of task count
+ *
+ * @endif
+ */
+ virtual void reset();
+
+ /*!
+ * @if jp
+ *
+ * @brief タスク実行を終了する
+ *
+ * タスク実行を終了する
+ *
+ * @else
+ *
+ * @brief Finalizing the task
+ *
+ * Finalizing the task.
+ *
+ * @endif
+ */
+ virtual void finalize();
+
+ /*!
+ * @if jp
+ *
+ * @brief スレッド実行を開始する
+ *
+ * スレッド実行を開始する
+ *
+ * @param args スレッド引数
+ *
+ * @else
+ *
+ * @brief Start thread Execution
+ *
+ * Start thread Execution
+ *
+ * @param args Thread arguments
+ *
+ * @endif
+ */
+ static void* svc_run(void* args = 0);
+
+ private:
+ int m_count;
+ pthread_t m_thread;
+ pthread_attr_t m_attr;
+ void* m_args;
+
+ };
+};
+
+#endif // COIL_TASK_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,24 @@
+// -*- C++ -*-
+/*!
+ * @file Timevalue.h
+ * @brief Timevalue class
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/Time.h>
+
+namespace coil
+{
+ // no implementation
+};
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/Time.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,197 @@
+// -*- C++ -*-
+/*!
+ * @file Time_posix.h
+ * @brief Time functions
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_TIME_H
+#define COIL_TIME_H
+
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <time.h>
+#include <iostream>
+#include <coil/config_coil.h>
+#include <coil/TimeValue.h>
+
+namespace coil
+{
+
+ /*!
+ * @if jp
+ * @brief 指定された秒間は処理を休止する
+ *
+ * 指定された秒間は処理を休止する。
+ *
+ * @param seconds 秒数
+ *
+ * @return 0: 成功, >0: 失敗
+ *
+ * @else
+ * @brief Stop a processing at specified second time
+ *
+ * Stop a processing at specified second time.
+ *
+ * @param seconds Second time
+ *
+ * @return 0: successful, >0: failed
+ *
+ * @endif
+ */
+ inline unsigned int sleep(unsigned int seconds)
+ {
+ return ::sleep(seconds);
+ }
+
+ /*!
+ * @if jp
+ * @brief 指定された秒間は処理を休止する
+ *
+ * 指定された秒間は処理を休止する。
+ *
+ * @param interval TimeValueオブジェクト
+ *
+ * @return 0: 成功, >0: 失敗
+ *
+ * @else
+ * @brief Stop a processing at specified second time
+ *
+ * Stop a processing at specified second time.
+ *
+ * @param interval TimeValue object
+ *
+ * @return 0: successful, >0: failed
+ *
+ * @endif
+ */
+ inline int sleep(TimeValue interval)
+ {
+ timeval tv;
+ tv.tv_sec = interval.sec();
+ tv.tv_usec = interval.usec();
+ return ::select(0, 0, 0, 0, &tv);
+ }
+
+ /*!
+ * @if jp
+ * @brief 指定されたマイクロ秒間は処理を休止する
+ *
+ * 指定されたマイクロ秒間は処理を休止する。
+ *
+ * @param usec マイクロ秒数
+ *
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ * @brief Stop a processing at specified micro second time
+ *
+ * Stop a processing at specified micro second time.
+ *
+ * @param usec Micro second time
+ *
+ * @return 0: successful, -1: failed
+ *
+ * @endif
+ */
+ inline int usleep(useconds_t usec)
+ {
+ return ::usleep(usec);
+ }
+
+ /*!
+ * @if jp
+ * @brief 時刻とタイムゾーンを取得する
+ *
+ * 時刻とタイムゾーンを取得する。
+ *
+ * @param tv 時刻構造体
+ * @param tz タイムゾーン構造体
+ *
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ * @brief Get the time and timezone
+ *
+ * Get the time and timezone
+ *
+ * @param tv Structure of time
+ * @param tz Structure of timezone
+ *
+ * @return 0: successful, -1: failed
+ *
+ * @endif
+ */
+ inline int gettimeofday(struct timeval *tv, struct timezone *tz)
+ {
+ return ::gettimeofday(tv, tz);
+ }
+
+ /*!
+ * @if jp
+ * @brief 時刻を取得する
+ *
+ * 時刻を取得する。
+ *
+ * @return TimeValueオブジェクト
+ *
+ * @else
+ * @brief Get the time
+ *
+ * Get the time
+ *
+ * @return TimeValue object
+ *
+ * @endif
+ */
+ inline TimeValue gettimeofday()
+ {
+ timeval tv;
+ ::gettimeofday(&tv, 0);
+ return TimeValue(tv.tv_sec, tv.tv_usec);
+ }
+
+ /*!
+ * @if jp
+ * @brief 時刻とタイムゾーンを設定する
+ *
+ * 時刻とタイムゾーンを設定する。
+ *
+ * @param tv 時刻構造体
+ * @param tz タイムゾーン構造体
+ *
+ * @return 0: 成功, -1: 失敗
+ *
+ * @else
+ * @brief Set the time and timezone
+ *
+ * Set the time and timezone
+ *
+ * @param tv Structure of time
+ * @param tz Structure of timezone
+ *
+ * @return 0: successful, -1: failed
+ *
+ * @endif
+ */
+ inline int settimeofday(const struct timeval *tv , const struct timezone *tz)
+ {
+ return ::settimeofday(tv, tz);
+ }
+
+
+};
+
+#endif // COIL_TIME_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.cpp
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.cpp (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.cpp 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,128 @@
+// -*- C++ -*-
+/*!
+ * @file MutexPosix.h
+ * @brief RT-Middleware Service interface
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#include <coil/UUID.h>
+#include <iostream>
+#include <string.h>
+
+#ifdef COIL_OS_FREEBSD
+void error_code(uint32_t status)
+{
+ if (status == uuid_s_ok)
+ std::cout << "uuid_s_ok" << std::endl;
+ else if (status == uuid_s_bad_version)
+ std::cout << "uuid_s_bad_version" << std::endl;
+ else if (status == uuid_s_invalid_string_uuid)
+ std::cout << "uuid_s_invalid_string_uuid" << std::endl;
+ else if (status == uuid_s_no_memory)
+ std::cout << "uuid_s_no_memory" << std::endl;
+ else
+ std::cout << "other error" << std::endl;
+}
+
+void uuid_clear(uuid_t& uu)
+{
+ uint32_t status;
+ uuid_create_nil(&uu, &status);
+}
+void uuid_unparse(uuid_t& uu, char*& uuidstr)
+{
+ uint32_t status;
+ uuid_to_string(&uu, &uuidstr, &status);
+}
+void uuid_generate(uuid_t& out)
+{
+ uint32_t status;
+ uuid_create(&out, &status);
+}
+#endif
+
+namespace coil
+{
+
+#ifdef COIL_OS_FREEBSD
+ UUID::UUID()
+ : m_uuidstr(0)
+ {
+ ::uuid_clear(m_uuid);
+ }
+ UUID::UUID(const uuid_t& uuid)
+ : m_uuid(uuid), m_uuidstr(0)
+ {
+ }
+
+ UUID::~UUID()
+ {
+ free(m_uuidstr);
+ }
+
+ const char* UUID::to_string()
+ {
+ uuid_unparse(m_uuid, m_uuidstr);
+ return m_uuidstr;
+ }
+
+
+ UUID_Generator::UUID_Generator()
+ {
+ }
+
+ UUID_Generator::~UUID_Generator()
+ {
+ }
+
+ void UUID_Generator::init()
+ {
+ }
+
+ UUID* UUID_Generator::generateUUID(int n, int h)
+ {
+ uuid_t uuid;
+ uuid_generate(uuid);
+ return new UUID(uuid);
+ }
+#endif
+
+#if defined(COIL_OS_LINUX) || defined(COIL_OS_DARWIN) || defined(COIL_OS_CYGWIN)
+
+ UUID_Generator::UUID_Generator(){}
+
+ void UUID_Generator::init(){}
+ UUID* UUID_Generator::generateUUID(int varsion, int variant){
+ uuid_t uuid;
+
+ uuid_generate(uuid);
+ return new UUID(&uuid);
+ }
+
+ UUID::UUID(){
+ uuid_clear(this->_uuid);
+ }
+
+ UUID::UUID(uuid_t *uuid){
+ strncpy((char *)this->_uuid, (char *)(*uuid), sizeof(this->_uuid));
+ }
+
+ const char* UUID::to_string(){
+ uuid_unparse(this->_uuid, buf);
+ return buf;
+ }
+
+#endif
+};
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/UUID.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,77 @@
+// -*- C++ -*-
+/*!
+ * @file MutexPosix.h
+ * @brief RT-Middleware Service interface
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+
+#ifndef COIL_UUID_H
+#define COIL_UUID_H
+
+#include <coil/config_coil.h>
+#ifdef COIL_OS_FREEBSD
+#include <uuid.h>
+
+namespace coil
+{
+ class UUID
+ {
+ public:
+ UUID();
+ UUID(const uuid_t& uuid);
+ ~UUID();
+ const char* to_string();
+ private:
+ uuid_t m_uuid;
+ char* m_uuidstr;
+ };
+
+
+ class UUID_Generator
+ {
+ public:
+ UUID_Generator();
+ ~UUID_Generator();
+ void init();
+ coil::UUID* generateUUID(int n, int h);
+ };
+};
+#endif
+#if defined(COIL_OS_LINUX) || defined(COIL_OS_DARWIN) || defined(COIL_OS_CYGWIN)
+#include <uuid/uuid.h>
+namespace coil
+{
+ class UUID
+ {
+ uuid_t _uuid;
+ char buf[37];
+ public:
+ UUID();
+ UUID(uuid_t*);
+ const char* to_string();
+ };
+
+ class UUID_Generator
+ {
+ public:
+ UUID_Generator();
+
+ void init();
+ UUID* generateUUID(int n, int h);
+ };
+};
+#endif
+
+#endif // COIL_UUID_H
Added: trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/atomic.h
===================================================================
--- trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/atomic.h (rev 0)
+++ trunk/OpenRTM-aist/src/lib/coil/vxworks/coil/atomic.h 2017-03-22 05:30:53 UTC (rev 2976)
@@ -0,0 +1,66 @@
+// -*- C++ -*-
+/*!
+ * @file atomic.h
+ * @brief atomic add func
+ * @date $Date$
+ * @author Noriaki Ando <n-ando at aist.go.jp>
+ *
+ * Copyright (C) 2008
+ * Noriaki Ando
+ * Task-intelligence Research Group,
+ * Intelligent Systems Research Institute,
+ * National Institute of
+ * Advanced Industrial Science and Technology (AIST), Japan
+ * All rights reserved.
+ *
+ * $Id$
+ *
+ */
+#ifndef COIL_ATOMIC_H
+
+#ifdef COIL_HAS_ATOMIC_OP
+
+#include <bits/atomicity.h>
+
+#define COIL_USES_ATOMIC_OP
+#define atomic_add(x, y) __gnu_cxx::__atomic_add(x, y)
+#define atomic_incr(x) __gnu_cxx::__atomic_add(x, 1)
+#define atomic_decr(x) __gnu_cxx::__atomic_add(x, -1)
+#define atomic_exchange_add(x, y) __gnu_cxx::__exchange_and_add(x, y)
+#else
+
+#include <coil/Mutex.h>
+#include <coil/Guard.h>
+#define COIL_USES_ATOMIC_OP coil::Mutex __mutex;
+
+#define atomic_add(x, y) \
+ { \
+ coil::Guard<coil::Mutex> guard(__mutex); \
+ *x = *x + y; \
+ }
+
+#define atomic_incr(x) \
+ { \
+ coil::Guard<coil::Mutex> guard(__mutex); \
+ ++(*x); \
+ }
+
+#define atomic_decr(x) \
+ { \
+ coil::Guard<coil::Mutex> guard(__mutex); \
+ --(*x); \
+ }
+
+int exchange_add(int* x, int y, coil::Mutex* mutex)
+{
+ coil::Guard<coil::Mutex> guard(*mutex);
+ int tmp(*x);
+ *x = *x + y;
+ return tmp;
+}
+
+#define atomic_exchange_add(x, y) \
+ exchange_add(x, y, &__mutex)
+
+#endif // COIL_HAS_ATOMIC_ADD
+#endif // COIL_ATOMIC_H
openrtm-commit メーリングリストの案内