summaryrefslogtreecommitdiff
path: root/lib/freertos-posix/include
diff options
context:
space:
mode:
authorAditya Naik2020-08-03 14:42:06 -0400
committerAditya Naik2020-08-03 14:42:06 -0400
commit11a52e4e88bcad1e6bddcf02f78e1cc5eaaec508 (patch)
treed7f725c30e618994a0650607ede73ab3efc72c67 /lib/freertos-posix/include
parent81b3f3d5336eab67e8eb21bb4011e552f3895a4e (diff)
RTOS skeleton with (UNIX) POSIX calls. Reorg of stream files
Diffstat (limited to 'lib/freertos-posix/include')
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/errno.h95
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/fcntl.h79
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/mqueue.h250
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/pthread.h501
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/sched.h84
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/semaphore.h143
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/signal.h70
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/sys/types.h191
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/time.h258
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/unistd.h61
-rwxr-xr-xlib/freertos-posix/include/FreeRTOS_POSIX/utils.h155
-rwxr-xr-xlib/freertos-posix/include/private/iot_doubly_linked_list.h242
12 files changed, 2129 insertions, 0 deletions
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/errno.h b/lib/freertos-posix/include/FreeRTOS_POSIX/errno.h
new file mode 100755
index 0000000..136e04b
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/errno.h
@@ -0,0 +1,95 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file errno.h
+ * @brief System error numbers.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/errno.h.html
+ *
+ * The values defined in this file may not be compatible with the strerror
+ * function provided by this system.
+ */
+
+#ifndef _FREERTOS_POSIX_ERRNO_H_
+#define _FREERTOS_POSIX_ERRNO_H_
+
+/* Undefine all errnos to avoid redefinition errors with system errnos. */
+#undef EPERM
+#undef ENOENT
+#undef EBADF
+#undef EAGAIN
+#undef ENOMEM
+#undef EEXIST
+#undef EBUSY
+#undef EINVAL
+#undef ENOSPC
+#undef ERANGE
+#undef ENAMETOOLONG
+#undef EDEADLK
+#undef EOVERFLOW
+#undef ENOSYS
+#undef EMSGSIZE
+#undef ENOTSUP
+#undef ETIMEDOUT
+
+/**
+ * @name Definition of POSIX errnos.
+ */
+/**@{ */
+#define EPERM 1 /**< Operation not permitted. */
+#define ENOENT 2 /**< No such file or directory. */
+#define EBADF 9 /**< Bad file descriptor. */
+#define EAGAIN 11 /**< Resource unavailable, try again. */
+#define ENOMEM 12 /**< Not enough space. */
+#define EEXIST 17 /**< File exists. */
+#define EBUSY 16 /**< Device or resource busy. */
+#define EINVAL 22 /**< Invalid argument. */
+#define ENOSPC 28 /**< No space left on device. */
+#define ERANGE 34 /**< Result too large. */
+#define ENAMETOOLONG 36 /**< File name too long. */
+#define EDEADLK 45 /**< Resource deadlock would occur. */
+#define EOVERFLOW 75 /**< Value too large to be stored in data type. */
+#define ENOSYS 88 /**< Function not supported. */
+#define EMSGSIZE 90 /**< Message too long. */
+#define ENOTSUP 95 /**< Operation not supported. */
+#define ETIMEDOUT 116 /**< Connection timed out. */
+/**@} */
+
+/**
+ * @name System Variable
+ *
+ * @brief Define FreeRTOS+POSIX errno, if enabled.
+ * Set configUSE_POSIX_ERRNO to enable, and clear to disable. See FreeRTOS.h.
+ *
+ * @{
+ */
+#if ( configUSE_POSIX_ERRNO == 1 )
+ extern int FreeRTOS_errno;
+ #define errno FreeRTOS_errno
+#endif
+/**@} */
+
+#endif /* ifndef _FREERTOS_POSIX_ERRNO_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/fcntl.h b/lib/freertos-posix/include/FreeRTOS_POSIX/fcntl.h
new file mode 100755
index 0000000..1e921ce
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/fcntl.h
@@ -0,0 +1,79 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file fcntl.h
+ * @brief File control options.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_FCNTL_H_
+#define _FREERTOS_POSIX_FCNTL_H_
+
+/**
+ * @name File creation flags for use in the oflag value to open() and openat().
+ */
+/**@{ */
+#define O_CLOEXEC 0x0001 /**< Close the file descriptor upon exec(). */
+#define O_CREAT 0x0002 /**< Create file if it does not exist. */
+#define O_DIRECTORY 0x0004 /**< Fail if file is a non-directory file. */
+#define O_EXCL 0x0008 /**< Exclusive use flag. */
+#define O_NOCTTY 0x0010 /**< Do not assign controlling terminal. */
+#define O_NOFOLLOW 0x0020 /**< Do not follow symbolic links. */
+#define O_TRUNC 0x0040 /**< Truncate flag. */
+#define O_TTY_INIT 0x0080 /**< termios structure provides conforming behavior. */
+/**@} */
+
+/**
+ * @name File status flags for open(), openat(), and fcntl().
+ */
+/**@{ */
+#define O_APPEND 0x0100 /**< Set append mode. */
+#define O_DSYNC 0x0200 /**< Write according to synchronized I/O data integrity completion. */
+#define O_NONBLOCK 0x0400 /**< Non-blocking mode. */
+#define O_RSYNC 0x0800 /**< Synchronized read I/O operations. */
+#define O_SYNC 0x0200 /**< Write according to synchronized I/O file integrity completion. */
+/**@} */
+
+/**
+ * @name Mask for file access modes.
+ */
+/**@{ */
+#define O_ACCMODE 0xF000
+/**@} */
+
+/**
+ * @name File access modes for open(), openat(), and fcntl().
+ */
+/**@{ */
+#define O_EXEC 0x1000 /**< Open for execute only (non-directory files). */
+#define O_RDONLY 0x2000 /**< Open for reading only. */
+#define O_RDWR 0xA000 /**< Open for reading and writing. */
+#define O_SEARCH 0x4000 /**< Open directory for search only. */
+#define O_WRONLY 0x8000 /**< Open for writing only. */
+/**@} */
+
+#endif /* ifndef _FREERTOS_POSIX_FCNTL_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/mqueue.h b/lib/freertos-posix/include/FreeRTOS_POSIX/mqueue.h
new file mode 100755
index 0000000..7cbf01c
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/mqueue.h
@@ -0,0 +1,250 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file mqueue.h
+ * @brief Message queues.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/mqueue.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_MQUEUE_H_
+#define _FREERTOS_POSIX_MQUEUE_H_
+
+/* FreeRTOS+POSIX includes. */
+#include "FreeRTOS_POSIX/time.h"
+
+/**
+ * @brief Message queue descriptor.
+ */
+typedef void * mqd_t;
+
+/**
+ * @brief Message queue attributes.
+ */
+struct mq_attr
+{
+ long mq_flags; /**< Message queue flags. */
+ long mq_maxmsg; /**< Maximum number of messages. */
+ long mq_msgsize; /**< Maximum message size. */
+ long mq_curmsgs; /**< Number of messages currently queued. */
+};
+
+/**
+ * @brief Close a message queue.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_close.html
+ *
+ * @retval 0 - Upon successful completion
+ * @retval -1 - A error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EBADF - The mqdes argument is not a valid message queue descriptor.
+ */
+int mq_close( mqd_t mqdes );
+
+/**
+ * @brief Get message queue attributes.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_getattr.html
+ *
+ * @retval 0 - Upon successful completion
+ * @retval -1 - A error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * DBADF - The mqdes argument is not a valid message queue descriptor.
+ */
+int mq_getattr( mqd_t mqdes,
+ struct mq_attr * mqstat );
+
+/**
+ * @brief Open a message queue.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html
+ *
+ * @note Supported name pattern: leading &lt;slash&gt; character in name is always required;
+ * the maximum length (excluding null-terminator) of the name argument can be NAME_MAX.
+ * The default value of NAME_MAX in FreeRTOS_POSIX_portable_default.h is 64, which can be
+ * overwritten by user.
+ * @note mode argument is not supported.
+ * @note Supported oflags: O_RDWR, O_CREAT, O_EXCL, and O_NONBLOCK.
+ *
+ * @retval Message queue descriptor -- Upon successful completion
+ * @retval (mqd_t) - 1 -- An error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EINVAL - name argument is invalid (not following name pattern),
+ * OR if O_CREAT is specified in oflag with attr argument not NULL and either mq_maxmsg or mq_msgsize is equal to or less than zero,
+ * OR either O_CREAT or O_EXCL is not set and a queue with the same name is unlinked but pending to be removed.
+ * <br>
+ * EEXIST - O_CREAT and O_EXCL are set and the named message queue already exists.
+ * <br>
+ * ENOSPC - There is insufficient space for the creation of the new message queue.
+ * <br>
+ * ENOENT - O_CREAT is not set and the named message queue does not exist.
+ */
+mqd_t mq_open( const char * name,
+ int oflag,
+ mode_t mode,
+ struct mq_attr * attr );
+
+/**
+ * @brief Receive a message from a message queue.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html
+ *
+ * @note msg_prio argument is not supported. Messages are not checked for corruption.
+ *
+ * @retval The length of the selected message in bytes - Upon successful completion.
+ * The message is removed from the queue
+ * @retval -1 - An error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EBADF - The mqdes argument is not a valid message queue descriptor open for reading.
+ * <br>
+ * EMSGSIZE - The specified message buffer size, msg_len, is less than the message size attribute of the message queue.
+ * <br>
+ * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened,
+ * but no message arrived on the queue before the specified timeout expired.
+ * <br>
+ * EAGAIN - O_NONBLOCK was set in the message description associated with mqdes, and the specified message queue is empty.
+ */
+ssize_t mq_receive( mqd_t mqdes,
+ char * msg_ptr,
+ size_t msg_len,
+ unsigned int * msg_prio );
+
+/**
+ * @brief Send a message to a message queue.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html
+ *
+ * @note msg_prio argument is not supported.
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval -1 - An error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EBADF - The mqdes argument is not a valid message queue descriptor open for writing.
+ * <br>
+ * EMSGSIZE - The specified message length, msg_len, exceeds the message size attribute of the message queue,
+ * OR insufficient memory for the message to be sent.
+ * <br>
+ * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened,
+ * but the timeout expired before the message could be added to the queue.
+ * <br>
+ * EAGAIN - The O_NONBLOCK flag is set in the message queue description associated with mqdes,
+ * and the specified message queue is full.
+ */
+int mq_send( mqd_t mqdes,
+ const char * msg_ptr,
+ size_t msg_len,
+ unsigned msg_prio );
+
+/**
+ * @brief Receive a message from a message queue with timeout.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedreceive.html
+ *
+ * @note msg_prio argument is not supported. Messages are not checked for corruption.
+ *
+ * @retval The length of the selected message in bytes - Upon successful completion.
+ * The message is removed from the queue
+ * @retval -1 - An error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EBADF - The mqdes argument is not a valid message queue descriptor open for reading.
+ * <br>
+ * EMSGSIZE - The specified message buffer size, msg_len, is less than the message size attribute of the message queue.
+ * <br>
+ * EINVAL - The process or thread would have blocked, and the abstime parameter specified a nanoseconds field value
+ * less than zero or greater than or equal to 1000 million.
+ * <br>
+ * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened,
+ * but no message arrived on the queue before the specified timeout expired.
+ * <br>
+ * EAGAIN - O_NONBLOCK was set in the message description associated with mqdes, and the specified message queue is empty.
+ */
+ssize_t mq_timedreceive( mqd_t mqdes,
+ char * msg_ptr,
+ size_t msg_len,
+ unsigned * msg_prio,
+ const struct timespec * abstime );
+
+/**
+ * @brief Send a message to a message queue with timeout.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedsend.html
+ *
+ * @note msg_prio argument is not supported.
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval -1 - An error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EBADF - The mqdes argument is not a valid message queue descriptor open for writing.
+ * <br>
+ * EMSGSIZE - The specified message length, msg_len, exceeds the message size attribute of the message queue,
+ * OR insufficient memory for the message to be sent.
+ * <br>
+ * EINVAL - The process or thread would have blocked, and the abstime parameter specified a nanoseconds field
+ * value less than zero or greater than or equal to 1000 million.
+ * <br>
+ * ETIMEDOUT - The O_NONBLOCK flag was not set when the message queue was opened,
+ * but the timeout expired before the message could be added to the queue.
+ * <br>
+ * EAGAIN - The O_NONBLOCK flag is set in the message queue description associated with mqdes,
+ * and the specified message queue is full.
+ */
+int mq_timedsend( mqd_t mqdes,
+ const char * msg_ptr,
+ size_t msg_len,
+ unsigned msg_prio,
+ const struct timespec * abstime );
+
+/**
+ * @brief Remove a message queue.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_unlink.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval -1 - An error occurred. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EINVAL - name argument is invalid. Refer to requirements on name argument in mq_open().
+ * <br>
+ * ENOENT - The named message queue does not exist.
+ */
+int mq_unlink( const char * name );
+
+#endif /* ifndef _FREERTOS_POSIX_MQUEUE_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/pthread.h b/lib/freertos-posix/include/FreeRTOS_POSIX/pthread.h
new file mode 100755
index 0000000..77f949a
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/pthread.h
@@ -0,0 +1,501 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file pthread.h
+ * @brief Threads.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/pthread.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_PTHREAD_H_
+#define _FREERTOS_POSIX_PTHREAD_H_
+
+/* FreeRTOS+POSIX includes. POSIX states that this header shall make symbols
+ * defined in sched.h and time.h visible. */
+#include "FreeRTOS_POSIX/sched.h"
+#include "FreeRTOS_POSIX/time.h"
+
+/**
+ * @name pthread detach state.
+ */
+/**@{ */
+#define PTHREAD_CREATE_DETACHED 0 /**< Detached. */
+#define PTHREAD_CREATE_JOINABLE 1 /**< Joinable (default). */
+/**@} */
+
+/**
+ * @name Returned to a single thread after a successful pthread_barrier_wait.
+ *
+ * @brief POSIX specifies that "The constant PTHREAD_BARRIER_SERIAL_THREAD is defined in
+ * <pthread.h> and its value shall be distinct from any other value returned by pthread_barrier_wait()."
+ * So it's defined as negative to distinguish it from the errnos, which are positive.
+ */
+#define PTHREAD_BARRIER_SERIAL_THREAD ( -2 )
+
+/**
+ * @name Mutex types.
+ */
+/**@{ */
+#ifndef PTHREAD_MUTEX_NORMAL
+ #define PTHREAD_MUTEX_NORMAL 0 /**< Non-robust, deadlock on relock, does not remember owner. */
+#endif
+#ifndef PTHREAD_MUTEX_ERRORCHECK
+ #define PTHREAD_MUTEX_ERRORCHECK 1 /**< Non-robust, error on relock, remembers owner. */
+#endif
+#ifndef PTHREAD_MUTEX_RECURSIVE
+ #define PTHREAD_MUTEX_RECURSIVE 2 /**< Non-robust, recursive relock, remembers owner. */
+#endif
+#ifndef PTHREAD_MUTEX_DEFAULT
+ #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL /**< PTHREAD_MUTEX_NORMAL (default). */
+#endif
+/**@} */
+
+/**
+ * @name Compile-time initializers.
+ *
+ * @brief To use PTHREAD_COND_INITIALIZER, posixconfigENABLE_PTHREAD_COND_T needs to be set to 1
+ * in port specific POSIX config file.
+ *
+ * To use PTHREAD_MUTEX_INITIALIZER, posixconfigENABLE_PTHREAD_MUTEX_T needs to be set to 1 in
+ * port specific POSIX config file.
+ */
+/**@{ */
+#if posixconfigENABLE_PTHREAD_COND_T == 1
+ #define PTHREAD_COND_INITIALIZER FREERTOS_POSIX_COND_INITIALIZER /**< pthread_cond_t. */
+#endif
+
+#if posixconfigENABLE_PTHREAD_MUTEX_T == 1
+ #define PTHREAD_MUTEX_INITIALIZER FREERTOS_POSIX_MUTEX_INITIALIZER /**< pthread_mutex_t. */
+#endif
+
+/**@} */
+
+/**
+ * @brief Destroy the thread attributes object.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_destroy.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_attr_destroy( pthread_attr_t * attr );
+
+/**
+ * @brief Get detachstate attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getdetachstate.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_attr_getdetachstate( const pthread_attr_t * attr,
+ int * detachstate );
+
+/**
+ * @brief Get schedparam attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getschedparam.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_attr_getschedparam( const pthread_attr_t * attr,
+ struct sched_param * param );
+
+/**
+ * @brief Get stacksize attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_getstacksize.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_attr_getstacksize( const pthread_attr_t * attr,
+ size_t * stacksize );
+
+/**
+ * @brief Initialize the thread attributes object.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_init.html
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @note Currently, only stack size, sched_param, and detach state attributes
+ * are supported. Also see pthread_attr_get*() and pthread_attr_set*().
+ */
+int pthread_attr_init( pthread_attr_t * attr );
+
+/**
+ * @brief Set detachstate attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setdetachstate.html
+ *
+ * @retval 0 - Upon successful completion
+ * @retval EINVAL - The value of detachstate is not valid. Currently, supported detach states are --
+ * PTHREAD_CREATE_DETACHED and PTHREAD_CREATE_JOINABLE.
+ */
+int pthread_attr_setdetachstate( pthread_attr_t * attr,
+ int detachstate );
+
+/**
+ * @brief Set schedparam attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedparam.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The value of param is not valid.
+ * @retval ENOTSUP - An attempt was made to set the attribute to an unsupported value.
+ */
+int pthread_attr_setschedparam( pthread_attr_t * attr,
+ const struct sched_param * param );
+
+/**
+ * @brief Set the schedpolicy attribute.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setschedpolicy.html
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @warning This function is a stub and always returns 0.
+ */
+int pthread_attr_setschedpolicy( pthread_attr_t * attr,
+ int policy );
+
+/**
+ * @brief Set stacksize attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_attr_setstacksize.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The value of stacksize is less than {PTHREAD_STACK_MIN}.
+ */
+int pthread_attr_setstacksize( pthread_attr_t * attr,
+ size_t stacksize );
+
+/**
+ * @brief Destroy a barrier object.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_destroy.html
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @note This function does not validate whether there is any thread blocking on the barrier before destroying.
+ */
+int pthread_barrier_destroy( pthread_barrier_t * barrier );
+
+/**
+ * @brief Initialize a barrier object.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_init.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The value specified by count is equal to zero.
+ * @retval ENOMEM - count cannot fit into FreeRTOS event group type OR insufficient memory exists to initialize the barrier.
+ *
+ * @note attr is ignored.
+ *
+ * @note pthread_barrier_init() is implemented with FreeRTOS event group.
+ * To ensure count fits in event group, count may be at most 8 when configUSE_16_BIT_TICKS is 1;
+ * it may be at most 24 otherwise. configUSE_16_BIT_TICKS is configured in application FreeRTOSConfig.h
+ * file, which defines how many bits tick count type has. See further details and limitation about event
+ * group and configUSE_16_BIT_TICKS in FreeRTOS site.
+ */
+int pthread_barrier_init( pthread_barrier_t * barrier,
+ const pthread_barrierattr_t * attr,
+ unsigned count );
+
+/**
+ * @brief Synchronize at a barrier.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_barrier_wait.html
+ *
+ * @retval PTHREAD_BARRIER_SERIAL_THREAD - Upon successful completion, the first thread.
+ * @retval 0 - Upon successful completion, other thread(s).
+ */
+int pthread_barrier_wait( pthread_barrier_t * barrier );
+
+/**
+ * @brief Thread creation.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_create.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EAGAIN - Insufficient memory for either thread structure or task creation.
+ */
+int pthread_create( pthread_t * thread,
+ const pthread_attr_t * attr,
+ void *( *startroutine )( void * ),
+ void * arg );
+
+/**
+ * @brief Broadcast a condition.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_broadcast.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_cond_broadcast( pthread_cond_t * cond );
+
+/**
+ * @brief Destroy condition variables.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_destroy.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_cond_destroy( pthread_cond_t * cond );
+
+/**
+ * @brief Initialize condition variables.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_init.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval ENOMEM - Insufficient memory exists to initialize the condition variable.
+ *
+ * @note attr is ignored and treated as NULL. Default setting is always used.
+ */
+int pthread_cond_init( pthread_cond_t * cond,
+ const pthread_condattr_t * attr );
+
+/**
+ * @brief Signal a condition.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_signal.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_cond_signal( pthread_cond_t * cond );
+
+/**
+ * @brief Wait on a condition with a timeout.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_timedwait.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The abstime argument passed in does not refer to an initialized structure OR
+ * the abstime parameter specified a nanoseconds field value less than zero or
+ * greater than or equal to 1000 million.
+ * @retval ETIMEDOUT - The time specified by abstime to pthread_cond_timedwait() has passed.
+ */
+int pthread_cond_timedwait( pthread_cond_t * cond,
+ pthread_mutex_t * mutex,
+ const struct timespec * abstime );
+
+/**
+ * @brief Wait on a condition.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_cond_wait.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_cond_wait( pthread_cond_t * cond,
+ pthread_mutex_t * mutex );
+
+/**
+ * @brief Compare thread IDs.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_equal.html
+ *
+ * @retval 0 - t1 and t2 are both not NULL && equal.
+ * @retval non-zero - otherwise.
+ */
+int pthread_equal( pthread_t t1,
+ pthread_t t2 );
+
+/**
+ * @brief Thread termination.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_exit.html
+ *
+ * @retval void - this function cannot return to its caller.
+ */
+void pthread_exit( void * value_ptr );
+
+/**
+ * @brief Dynamic thread scheduling parameters access.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_getschedparam.html
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @note policy is always set to SCHED_OTHER by this function.
+ */
+int pthread_getschedparam( pthread_t thread,
+ int * policy,
+ struct sched_param * param );
+
+/**
+ * @brief Wait for thread termination.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EDEADLK - The value specified by the thread argument to pthread_join() does not refer
+ * to a joinable thread OR multiple simultaneous calls to pthread_join()
+ * specifying the same target thread OR the value specified by the thread argument
+ * to pthread_join() refers to the calling thread.
+ */
+int pthread_join( pthread_t thread,
+ void ** retval );
+
+/**
+ * @brief Destroy a mutex.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_destroy.html
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @note If there exists a thread holding this mutex, this function returns 0 with mutex not being destroyed.
+ */
+int pthread_mutex_destroy( pthread_mutex_t * mutex );
+
+/**
+ * @brief Initialize a mutex.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_init.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval ENOMEM - Insufficient memory exists to initialize the mutex structure.
+ * @retval EAGAIN - Unable to initialize the mutex structure member(s).
+ */
+int pthread_mutex_init( pthread_mutex_t * mutex,
+ const pthread_mutexattr_t * attr );
+
+/**
+ * @brief Lock a mutex.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_lock.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - the abstime parameter specified a nanoseconds field value less than zero
+ * or greater than or equal to 1000 million.
+ * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already
+ * owns the mutex.
+ */
+int pthread_mutex_lock( pthread_mutex_t * mutex );
+
+/**
+ * @brief Lock a mutex with timeout.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_timedlock.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The abstime argument passed in does not refer to an initialized structure OR
+ * the abstime parameter specified a nanoseconds field value less than zero or
+ * greater than or equal to 1000 million.
+ * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already owns the mutex.
+ * @retval ETIMEDOUT - The mutex could not be locked before the specified timeout expired.
+ */
+int pthread_mutex_timedlock( pthread_mutex_t * mutex,
+ const struct timespec * abstime );
+
+/**
+ * @brief Attempt to lock a mutex. Fail immediately if mutex is already locked.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_trylock.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - the abstime parameter specified a nanoseconds field value less than zero
+ * or greater than or equal to 1000 million.
+ * @retval EDEADLK - The mutex type is PTHREAD_MUTEX_ERRORCHECK and the current thread already
+ * owns the mutex.
+ * @retval EBUSY - The mutex could not be acquired because it was already locked.
+ */
+int pthread_mutex_trylock( pthread_mutex_t * mutex );
+
+/**
+ * @brief Unlock a mutex.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutex_unlock.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EPERM - The mutex type is PTHREAD_MUTEX_ERRORCHECK or PTHREAD_MUTEX_RECURSIVE, and
+ * the current thread does not own the mutex.
+ */
+int pthread_mutex_unlock( pthread_mutex_t * mutex );
+
+/**
+ * @brief Destroy the mutex attributes object.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_destroy.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_mutexattr_destroy( pthread_mutexattr_t * attr );
+
+/**
+ * @brief Get the mutex type attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_gettype.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_mutexattr_gettype( const pthread_mutexattr_t * attr,
+ int * type );
+
+/**
+ * @brief Initialize the mutex attributes object.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_init.html
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @note Currently, only the type attribute is supported. Also see pthread_mutexattr_settype()
+ * and pthread_mutexattr_gettype().
+ */
+int pthread_mutexattr_init( pthread_mutexattr_t * attr );
+
+/**
+ * @brief Set the mutex type attribute.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_settype.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The value type is invalid.
+ */
+int pthread_mutexattr_settype( pthread_mutexattr_t * attr,
+ int type );
+
+/**
+ * @brief Get the calling thread ID.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_self.html
+ *
+ * @retval the thread ID of the calling thread.
+ */
+pthread_t pthread_self( void );
+
+/**
+ * @brief Dynamic thread scheduling parameters access.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_setschedparam.html
+ *
+ * @note policy is ignored; only priority (param.sched_priority) may be changed.
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int pthread_setschedparam( pthread_t thread,
+ int policy,
+ const struct sched_param * param );
+
+#endif /* _FREERTOS_POSIX_PTHREAD_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/sched.h b/lib/freertos-posix/include/FreeRTOS_POSIX/sched.h
new file mode 100755
index 0000000..5a72c44
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/sched.h
@@ -0,0 +1,84 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file sched.h
+ * @brief Execution scheduling.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sched.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_SCHED_H_
+#define _FREERTOS_POSIX_SCHED_H_
+
+/**
+ * @name Scheduling Policies
+ */
+/**@{ */
+#define SCHED_OTHER 0 /**< Another scheduling policy. */
+/**@} */
+
+/**
+ * @brief Scheduling parameters required for implementation of each supported
+ * scheduling policy.
+ */
+struct sched_param
+{
+ int sched_priority; /**< Process or thread execution scheduling priority. */
+};
+
+/**
+ * @brief Get priority limit (max).
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_max.html
+ *
+ * @note policy is ignored.
+ *
+ * @return the maximum priority value (0-based) system configuration allows.
+ * <br>
+ * e.g. if configMAX_PRIORITIES == 7, this function returns (configMAX_PRIORITIES - 1).
+ * configMAX_PRIORITIES is configured in application FreeRTOSConfig.h file.
+ */
+int sched_get_priority_max( int policy );
+
+/**
+ * @brief Get priority limit (min).
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_get_priority_min.html
+ *
+ * @note policy is ignored.
+ */
+int sched_get_priority_min( int policy );
+
+/**
+ * @brief Yield the processor.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sched_yield.html
+ *
+ * @retval 0 - Upon successful completion
+ */
+int sched_yield( void );
+
+#endif /* ifndef _FREERTOS_POSIX_SCHED_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/semaphore.h b/lib/freertos-posix/include/FreeRTOS_POSIX/semaphore.h
new file mode 100755
index 0000000..fa1da91
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/semaphore.h
@@ -0,0 +1,143 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file semaphore.h
+ * @brief Semaphores.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/semaphore.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_SEMAPHORE_H_
+#define _FREERTOS_POSIX_SEMAPHORE_H_
+
+/* FreeRTOS+POSIX includes. */
+#include "FreeRTOS_POSIX/time.h"
+#include "FreeRTOS_POSIX_types.h"
+
+/**
+ * @brief Semaphore type.
+ */
+typedef PosixSemType_t sem_t;
+
+/**
+ * @brief Destroy an unnamed semaphore.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_destroy.html
+ *
+ * @retval 0 - upon successful completion
+ *
+ * @note Semaphore is destroyed regardless of whether there is any thread currently blocked on this semaphore.
+ */
+int sem_destroy( sem_t * sem );
+
+/**
+ * @brief Get the value of a semaphore.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_getvalue.html
+ *
+ * @retval 0 - Upon successful completion
+ *
+ * @note If sem is locked, then the object to which sval points is set to zero.
+ */
+int sem_getvalue( sem_t * sem,
+ int * sval );
+
+/**
+ * @brief Initialize an unnamed semaphore.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_init.html
+ *
+ * @note pshared is ignored. Semaphores will always be considered "shared".
+ *
+ * @retval 0 - upon successful completion
+ * @retval -1 - otherwise. System error variable errno is also set in this case.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EINVAL - The value argument exceeds {SEM_VALUE_MAX}.
+ * <br>
+ * ENOSPC - A resource required to initialize the semaphore has been exhausted.
+ */
+int sem_init( sem_t * sem,
+ int pshared,
+ unsigned value );
+
+/**
+ * @brief Unlock a semaphore.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_post.html
+ *
+ * @retval 0 - upon successful completion
+ */
+int sem_post( sem_t * sem );
+
+/**
+ * @brief Lock a semaphore with timeout.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_timedwait.html
+ *
+ * @retval 0 - upon successful completion
+ * @retval -1 - otherwise. System error variable errno is also set in this case.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EINVAL - parameter specified a nanoseconds field value less than zero or greater
+ * than or equal to 1000 million
+ * <br>
+ * ETIMEDOUT - The semaphore could not be locked before the specified timeout expired.
+ *
+ * @note Deadlock detection is not implemented.
+ */
+int sem_timedwait( sem_t * sem,
+ const struct timespec * abstime );
+
+/**
+ * @brief Lock a semaphore if available.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_trywait.html
+ *
+ * @retval 0 - upon successful completion
+ * @retval -1 - otherwise. System error variable errno is also set in this case.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EAGAIN - The semaphore was already locked, so it cannot be immediately locked by the sem_trywait() operation.
+ */
+int sem_trywait( sem_t * sem );
+
+/**
+ * @brief Lock a semaphore.
+ *
+ * @see http://pubs.opengroup.org/onlinepubs/9699919799/functions/sem_wait.html
+ *
+ * @retval 0 - upon successful completion
+ * @retval -1 - otherwise. System error variable errno is also set in this case.
+ *
+ * @note Deadlock detection is not implemented.
+ */
+int sem_wait( sem_t * sem );
+
+#endif /* ifndef _FREERTOS_POSIX_SEMAPHORE_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/signal.h b/lib/freertos-posix/include/FreeRTOS_POSIX/signal.h
new file mode 100755
index 0000000..8f9cc6d
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/signal.h
@@ -0,0 +1,70 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file signal.h
+ * @brief Signals.
+ *
+ * Signals are currently not implemented in FreeRTOS+POSIX. This header only
+ * defines the signal data structures used elsewhere.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html
+ */
+
+
+#ifndef _FREERTOS_POSIX_SIGNAL_H_
+#define _FREERTOS_POSIX_SIGNAL_H_
+
+/**
+ * @name Values of sigev_notify.
+ */
+/**@{ */
+#define SIGEV_NONE 0 /**< No asynchronous notification is delivered when the event of interest occurs. */
+#define SIGEV_SIGNAL 1 /**< A queued signal, with an application-defined value, is generated when the event of interest occurs. Not supported. */
+#define SIGEV_THREAD 2 /**< A notification function is called to perform notification. */
+/**@} */
+
+/**
+ * @brief Signal value.
+ */
+union sigval
+{
+ int sival_int; /**< Integer signal value. */
+ void * sival_ptr; /**< Pointer signal value. */
+};
+
+/**
+ * @brief Signal event structure.
+ */
+struct sigevent
+{
+ int sigev_notify; /**< Notification type. A value of SIGEV_SIGNAL is not supported. */
+ int sigev_signo; /**< Signal number. This member is ignored. */
+ union sigval sigev_value; /**< Signal value. Only the sival_ptr member is used. */
+ void ( * sigev_notify_function )( union sigval ); /**< Notification function. */
+ pthread_attr_t * sigev_notify_attributes; /**< Notification attributes. */
+};
+
+#endif /* ifndef _FREERTOS_POSIX_SIGNAL_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/sys/types.h b/lib/freertos-posix/include/FreeRTOS_POSIX/sys/types.h
new file mode 100755
index 0000000..9cb3428
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/sys/types.h
@@ -0,0 +1,191 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file sys/types.h
+ * @brief Data types.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_TYPES_H_
+#define _FREERTOS_POSIX_TYPES_H_
+
+/* C standard library includes. */
+#include <stdint.h>
+
+/* FreeRTOS types include */
+#include "FreeRTOS_POSIX_types.h"
+
+/**
+ * @brief Used for system times in clock ticks or CLOCKS_PER_SEC.
+ *
+ * Enabled/disabled by posixconfigENABLE_CLOCK_T.
+ */
+#if !defined( posixconfigENABLE_CLOCK_T ) || ( posixconfigENABLE_CLOCK_T == 1 )
+ typedef uint32_t clock_t;
+#endif
+
+/**
+ * @brief Used for clock ID type in the clock and timer functions.
+ *
+ * Enabled/disabled by posixconfigENABLE_CLOCKID_T.
+ */
+#if !defined( posixconfigENABLE_CLOCKID_T ) || ( posixconfigENABLE_CLOCKID_T == 1 )
+ typedef int clockid_t;
+#endif
+
+/**
+ * @brief Used for some file attributes.
+ *
+ * Enabled/disabled by posixconfigENABLE_MODE_T.
+ */
+#if !defined( posixconfigENABLE_MODE_T ) || ( posixconfigENABLE_MODE_T == 1 )
+ typedef int mode_t;
+#endif
+
+/**
+ * @brief Used for process IDs and process group IDs.
+ *
+ * Enabled/disabled by posixconfigENABLE_PID_T.
+ */
+#if !defined( posixconfigENABLE_PID_T ) || ( posixconfigENABLE_PID_T == 1 )
+ typedef int pid_t;
+#endif
+
+/**
+ * @brief Used to identify a thread attribute object.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_ATTR_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_ATTR_T ) || ( posixconfigENABLE_PTHREAD_ATTR_T == 1 )
+ typedef PthreadAttrType_t pthread_attr_t;
+#endif
+
+/**
+ * @brief Used to identify a barrier.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_BARRIER_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_BARRIER_T ) || ( posixconfigENABLE_PTHREAD_BARRIER_T == 1 )
+ typedef PthreadBarrierType_t pthread_barrier_t;
+#endif
+
+/**
+ * @brief Used to define a barrier attributes object.
+ */
+typedef void * pthread_barrierattr_t;
+
+/**
+ * @brief Used for condition variables.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_COND_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_COND_T ) || ( posixconfigENABLE_PTHREAD_COND_T == 1 )
+ typedef PthreadCondType_t pthread_cond_t;
+#endif
+
+/**
+ * @brief Used to identify a condition attribute object.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_CONDATTR_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_CONDATTR_T ) || ( posixconfigENABLE_PTHREAD_CONDATTR_T == 1 )
+ typedef void * pthread_condattr_t;
+#endif
+
+/**
+ * @brief Used for mutexes.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEX_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_MUTEX_T ) || ( posixconfigENABLE_PTHREAD_MUTEX_T == 1 )
+ typedef PthreadMutexType_t pthread_mutex_t;
+#endif
+
+/**
+ * @brief Used to identify a mutex attribute object.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_MUTEXATTR_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_MUTEXATTR_T ) || ( posixconfigENABLE_PTHREAD_MUTEXATTR_T == 1 )
+ typedef PthreadMutexAttrType_t pthread_mutexattr_t;
+#endif
+
+/**
+ * @brief Used to identify a thread.
+ *
+ * Enabled/disabled by posixconfigENABLE_PTHREAD_T.
+ */
+#if !defined( posixconfigENABLE_PTHREAD_T ) || ( posixconfigENABLE_PTHREAD_T == 1 )
+ typedef void * pthread_t;
+#endif
+
+/**
+ * @brief Used for a count of bytes or an error indication.
+ *
+ * Enabled/disabled by posixconfigENABLE_SSIZE_T.
+ */
+#if !defined( posixconfigENABLE_SSIZE_T ) || ( posixconfigENABLE_SSIZE_T == 1 )
+ typedef int ssize_t;
+#endif
+
+/**
+ * @brief Used for time in seconds.
+ *
+ * Enabled/disabled by posixconfigENABLE_TIME_T.
+ */
+#if !defined( posixconfigENABLE_TIME_T ) || ( posixconfigENABLE_TIME_T == 1 )
+ typedef int64_t time_t;
+#endif
+
+/**
+ * @brief Used for timer ID returned by timer_create().
+ *
+ * Enabled/disabled by posixconfigENABLE_TIMER_T.
+ */
+#if !defined( posixconfigENABLE_TIMER_T ) || ( posixconfigENABLE_TIMER_T == 1 )
+ typedef void * timer_t;
+#endif
+
+/**
+ * @brief Used for time in microseconds.
+ *
+ * Enabled/disabled by posixconfigENABLE_USECONDS_T.
+ */
+#if !defined( posixconfigENABLE_USECONDS_T ) || ( posixconfigENABLE_USECONDS_T == 1 )
+ typedef unsigned long useconds_t;
+#endif
+
+/**
+ * @brief Used for file sizes.
+ *
+ * Enabled/disabled by posixconfigENABLE_OFF_T.
+ */
+#if !defined( posixconfigENABLE_OFF_T ) || ( posixconfigENABLE_OFF_T == 1 )
+ typedef long int off_t;
+#endif
+
+#endif /* ifndef _FREERTOS_POSIX_TYPES_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/time.h b/lib/freertos-posix/include/FreeRTOS_POSIX/time.h
new file mode 100755
index 0000000..d04de0f
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/time.h
@@ -0,0 +1,258 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file time.h
+ * @brief Time types.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_TIME_H_
+#define _FREERTOS_POSIX_TIME_H_
+
+/* FreeRTOS+POSIX includes. */
+#include "FreeRTOS_POSIX/sys/types.h"
+#include "FreeRTOS_POSIX/signal.h"
+
+/**
+ * @name Unit conversion constants.
+ */
+/**@{ */
+#define MICROSECONDS_PER_SECOND ( 1000000LL ) /**< Microseconds per second. */
+#define NANOSECONDS_PER_SECOND ( 1000000000LL ) /**< Nanoseconds per second. */
+#define NANOSECONDS_PER_TICK ( NANOSECONDS_PER_SECOND / configTICK_RATE_HZ ) /**< Nanoseconds per FreeRTOS tick. */
+/**@} */
+
+/**
+ * @name Clock identifiers.
+ */
+/**@{ */
+#define CLOCK_REALTIME 0 /**< The identifier of the system-wide clock measuring real time. */
+#define CLOCK_MONOTONIC 1 /**< The identifier for the system-wide monotonic clock.*/
+/**@} */
+
+/**
+ * @name A number used to convert the value returned by the clock() function into seconds.
+ */
+/**@{ */
+#define CLOCKS_PER_SEC ( ( clock_t ) configTICK_RATE_HZ )
+/**@} */
+
+/**
+ * @name Flag indicating time is absolute.
+ *
+ * For functions taking timer objects, this refers to the clock associated with the timer.
+ */
+/**@{ */
+#define TIMER_ABSTIME 0x01
+/**@} */
+
+#if !defined( posixconfigENABLE_TIMESPEC ) || ( posixconfigENABLE_TIMESPEC == 1 )
+
+/**
+ * @brief represents an elapsed time
+ */
+ struct timespec
+ {
+ time_t tv_sec; /**< Seconds. */
+ long tv_nsec; /**< Nanoseconds. */
+ };
+#endif
+
+#if !defined( posixconfigENABLE_ITIMERSPEC ) || ( posixconfigENABLE_ITIMERSPEC == 1 )
+
+/**
+ * @brief timer
+ */
+ struct itimerspec
+ {
+ struct timespec it_interval; /**< Timer period. */
+ struct timespec it_value; /**< Timer expiration. */
+ };
+#endif
+
+/**
+ * @brief Report CPU time used.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html
+ *
+ * @return The number of FreeRTOS ticks since the scheduler
+ * was started minus the ticks spent in the idle task.
+ *
+ * @note This function does NOT report the number of ticks spent by the calling thread.
+ */
+clock_t clock( void );
+
+/**
+ * @brief Access a process CPU-time clock.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getcpuclockid.html
+ *
+ * @retval EPERM
+ *
+ * @note This function is currently unsupported.
+ *
+ */
+int clock_getcpuclockid( pid_t pid,
+ clockid_t * clock_id );
+
+/**
+ * @brief Returns the resolution of a clock.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
+ *
+ * @note clock_id is ignored
+ * @note This function stores the resolution of the FreeRTOS tick count in the object res points to.
+ *
+ * @retval 0 - Upon successful execution
+ */
+int clock_getres( clockid_t clock_id,
+ struct timespec * res );
+
+/**
+ * @brief Returns the current value for the specified clock, clock_id.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_gettime.html
+ *
+ * @note clock_id is ignored
+ * @note this function does not check for overflows of time_t.
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int clock_gettime( clockid_t clock_id,
+ struct timespec * tp );
+
+/**
+ * @brief High resolution sleep with specifiable clock.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_nanosleep.html
+ *
+ * @note clock_id is ignored, as this function uses the FreeRTOS tick count as its clock.
+ * @note flags is ignored, if INCLUDE_vTaskDelayUntil is 0. i.e. the FreeRTOS function vTaskDelayUntil isn't available.
+ * @note rmtp is also ignored, as signals are not implemented.
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval EINVAL - The rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.
+ */
+int clock_nanosleep( clockid_t clock_id,
+ int flags,
+ const struct timespec * rqtp,
+ struct timespec * rmtp );
+
+/**
+ * @brief Sets the time for the specified clock.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_settime.html
+ *
+ * @retval -1 with errno set to EPERM.
+ *
+ * @note This function is currently unsupported, as FreeRTOS does not provide a function to modify the tick count.
+ */
+int clock_settime( clockid_t clock_id,
+ const struct timespec * tp );
+
+/**
+ * @brief High resolution sleep.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/nanosleep.html
+ *
+ * @note rmtp is ignored, as signals are not implemented.
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval -1 - The rqtp argument is invalid OR the rqtp argument specified a nanosecond value less than zero or greater than or equal to 1000 million.
+ *
+ */
+int nanosleep( const struct timespec * rqtp,
+ struct timespec * rmtp );
+
+/**
+ * @brief Create a per-process timer.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html
+ *
+ * @note clock_id is ignored, as this function used the FreeRTOS tick count as its clock.
+ * @note evp.sigev_notify must be set to SIGEV_THREAD, since signals are currently not supported.
+ *
+ * @retval 0 - Upon successful completion, with location referenced by timerid updated.
+ * @retval -1 - If an error occurs. errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * ENOTSUP - If evp is NULL OR evp->sigen_notify == SIGEV_SIGNAL.
+ * <br>
+ * EAGAIN - The system lacks sufficient signal queuing resources to honor the request.
+ */
+int timer_create( clockid_t clockid,
+ struct sigevent * evp,
+ timer_t * timerid );
+
+/**
+ * @brief Delete a per-process timer.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int timer_delete( timer_t timerid );
+
+/**
+ * @brief Get the timer overrun count.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html
+ *
+ * @retval 0 - Always return 0, since signals are not supported.
+ */
+int timer_getoverrun( timer_t timerid );
+
+/**
+ * @brief Get the amount of time until the timer expires.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.html
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int timer_gettime( timer_t timerid,
+ struct itimerspec * value );
+
+/**
+ * @brief Set the time until the next expiration of the timer.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html
+ *
+ * @retval 0 - Upon successful completion.
+ * @retval -1 - An error occurred, errno is also set.
+ *
+ * @sideeffect Possible errno values
+ * <br>
+ * EINVAL - A value structure specified a nanosecond value less than zero or greater than or equal to 1000 million,
+ * AND the it_value member of that structure did not specify zero seconds and nanoseconds.
+ */
+int timer_settime( timer_t timerid,
+ int flags,
+ const struct itimerspec * value,
+ struct itimerspec * ovalue );
+
+#endif /* ifndef _FREERTOS_POSIX_TIME_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/unistd.h b/lib/freertos-posix/include/FreeRTOS_POSIX/unistd.h
new file mode 100755
index 0000000..3b8af22
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/unistd.h
@@ -0,0 +1,61 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file unistd.h
+ * @brief Standard symbolic constants and types
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html
+ */
+
+#ifndef _FREERTOS_POSIX_UNISTD_H_
+#define _FREERTOS_POSIX_UNISTD_H_
+
+#include "FreeRTOS_POSIX/sys/types.h"
+
+/**
+ * @brief Suspend execution for an interval of time.
+ *
+ * http://pubs.opengroup.org/onlinepubs/9699919799/functions/sleep.html
+ *
+ * @param[in] seconds The number of seconds to suspend execution.
+ *
+ * @retval 0 - Upon successful completion.
+ *
+ * @note Return value of a positive number is not yet supported.
+ */
+unsigned sleep( unsigned seconds );
+
+/**
+ * @brief Suspend execution for microsecond intervals.
+ *
+ * This is a useful, non-POSIX function.
+ * @param[in] usec The number of microseconds to suspend execution.
+ *
+ * @retval 0 - Upon successful completion.
+ */
+int usleep( useconds_t usec );
+
+#endif /* ifndef _FREERTOS_POSIX_UNISTD_H_ */
diff --git a/lib/freertos-posix/include/FreeRTOS_POSIX/utils.h b/lib/freertos-posix/include/FreeRTOS_POSIX/utils.h
new file mode 100755
index 0000000..c893a95
--- /dev/null
+++ b/lib/freertos-posix/include/FreeRTOS_POSIX/utils.h
@@ -0,0 +1,155 @@
+/*
+ * Amazon FreeRTOS POSIX V1.1.0
+ * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file utils.h
+ * @brief Utility functions used by FreeRTOS+POSIX.
+ */
+
+#ifndef _FREERTOS_POSIX_UTILS_
+#define _FREERTOS_POSIX_UTILS_
+
+/* C standard library includes. */
+#include <stdbool.h>
+#include <stdint.h>
+
+/* FreeRTOS+POSIX includes. */
+#include "FreeRTOS_POSIX/time.h"
+
+/**
+ * @brief Calculates the length of pcString, up to xMaxLength.
+ *
+ * @param[in] pcString The string to find the length of.
+ * @param[in] xMaxLength The limit when searching for the end of pcString.
+ *
+ * @return 0 if pcString is NULL; otherwise, the length of pcString or xMaxLength,
+ * whichever is smaller.
+ */
+size_t UTILS_strnlen( const char * const pcString,
+ size_t xMaxLength );
+
+/**
+ * @brief Calculates the number of ticks between now and a given timespec.
+ *
+ * @param[in] pxAbsoluteTime A time in the future, specified as seconds and
+ * nanoseconds since CLOCK_REALTIME's 0.
+ * @param[in] pxCurrentTime current time, specified as seconds and
+ * nanoseconds.
+ * @param[out] pxResult Where the result of the conversion is stored. The result
+ * is rounded up for fractional ticks.
+ *
+ * @return 0 on success. Otherwise, ETIMEDOUT if pxAbsoluteTime is in the past,
+ * or EINVAL for invalid parameters.
+ */
+int UTILS_AbsoluteTimespecToDeltaTicks( const struct timespec * const pxAbsoluteTime,
+ const struct timespec * const pxCurrentTime,
+ TickType_t * const pxResult );
+
+/**
+ * @brief Converts a struct timespec to FreeRTOS ticks.
+ *
+ * @param[in] pxTimespec The timespec to convert.
+ * @param[out] Where the result of the conversion is stored. The result is rounded
+ * up for fractional ticks.
+ *
+ * @return 0 on success. Otherwise, EINVAL for invalid parameters.
+ */
+int UTILS_TimespecToTicks( const struct timespec * const pxTimespec,
+ TickType_t * const pxResult );
+
+/**
+ * @brief Converts an integer value to a timespec.
+ *
+ * @param[in] llSource The value to convert.
+ * @param[out] pxDestination Where to store the converted value.
+ *
+ * @return No return value.
+ */
+void UTILS_NanosecondsToTimespec( int64_t llSource,
+ struct timespec * const pxDestination );
+
+/**
+ * @brief Calculates pxResult = x + y.
+ *
+ * @param[in] x The first argument for addition.
+ * @param[in] y The second argument for addition.
+ * @param[out] pxResult Where the result of the calculation is stored.
+ *
+ * @return -1 if any argument was NULL; 1 if result is negative (overflow); otherwise, 0.
+ */
+int UTILS_TimespecAdd( const struct timespec * const x,
+ const struct timespec * const y,
+ struct timespec * const pxResult );
+
+/**
+ * @brief Calculates pxResult = x + ( struct timespec ) nanosec.
+ *
+ * @param[in] x The first argument for addition.
+ * @param[in] llNanoseconds The second argument for addition.
+ * @param[out] pxResult Where the result of the calculation is stored.
+ *
+ * @return -1 if pxResult or x was NULL; 1 if result is negative; otherwise, 0.
+ */
+int UTILS_TimespecAddNanoseconds( const struct timespec * const x,
+ int64_t llNanoseconds,
+ struct timespec * const pxResult );
+
+/**
+ * @brief Calculates pxResult = x - y. If the result is negative contents of
+ * pResult are undefined
+ *
+ * @param[in] x The first argument for subtraction.
+ * @param[in] y The second argument for subtraction.
+ * @param[out] pxResult Where the result of the calculation is stored.
+ *
+ * @return -1 if any argument was NULL; 1 if result is negative; otherwise, 0.
+ */
+int UTILS_TimespecSubtract( const struct timespec * const x,
+ const struct timespec * const y,
+ struct timespec * const pxResult );
+
+/**
+ * @brief Compare x == y.
+ *
+ * @param[in] x The first argument for comparison.
+ * @param[in] y The second argument for comparison.
+ *
+ * @return 0 if x == y; 1 if x > y; -1 if x < y or any argument was NULL
+ */
+int UTILS_TimespecCompare( const struct timespec * const x,
+ const struct timespec * const y );
+
+/**
+ * @brief Checks that a timespec conforms to POSIX.
+ *
+ * A valid timespec must have 0 <= tv_nsec < 1000000000.
+ *
+ * @param[in] pxTimespec The timespec to validate.
+ *
+ * @return true if the pxTimespec is valid, false otherwise.
+ */
+bool UTILS_ValidateTimespec( const struct timespec * const pxTimespec );
+
+#endif /* ifndef _FREERTOS_POSIX_UTILS_ */
diff --git a/lib/freertos-posix/include/private/iot_doubly_linked_list.h b/lib/freertos-posix/include/private/iot_doubly_linked_list.h
new file mode 100755
index 0000000..338c539
--- /dev/null
+++ b/lib/freertos-posix/include/private/iot_doubly_linked_list.h
@@ -0,0 +1,242 @@
+/*
+ * Amazon FreeRTOS Common V1.0.0
+ * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+ * the Software, and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * http://aws.amazon.com/freertos
+ * http://www.FreeRTOS.org
+ */
+
+/**
+ * @file iot_doubly_linked_list.h
+ * @brief Doubly Linked List implementation.
+ *
+ * A generic implementation of circular Doubly Linked List which consists of a
+ * list head and some list entries (zero in case of an empty list).
+ *
+ * To start with, a structure of type Link_t should be embedded in the structure
+ * which is to be organized as doubly linked list.
+ * @code
+ * typedef struct UserStruct
+ * {
+ * uint32_t ulField1;
+ * uint32_t ulField2;
+ * Link_t xLink;
+ * } UserStruct_t;
+ * @endcode
+ *
+ * A List head should then be defined and initialized.
+ * @code
+ * Link_t xListHead;
+ * listINIT_HEAD( &xListHead );
+ * @endcode
+ *
+ * listADD can then be used to add nodes to the list.
+ * @code
+ * listADD( &( xListHead ), &( pxUserStruct->xLink ) );
+ * @endcode
+ *
+ * listFOR_EACH can be used for traversing the list.
+ * @code
+ * Link_t *pxLink;
+ * UserStruct_t *pxUserStruct;
+ * listFOR_EACH( pxLink, &( xListHead ) )
+ * {
+ * pxUserStruct = listCONTAINER( pxLink, UserStruct_t, xLink );
+ * }
+ * @endcode
+ *
+ * listFOR_EACH_SAFE should be used if you want to perform destructive operations
+ * (like free) on nodes while traversing the list.
+ * @code
+ * Link_t *pxLink, *pxTempLink;
+ * UserStruct_t *pxUserStruct;
+ * listFOR_EACH( pxLink, pxTempLink, &( xListHead ) )
+ * {
+ * pxUserStruct = listCONTAINER( pxLink, UserStruct_t, xLink );
+ * free( pxUserStruct );
+ * }
+ * @endcode
+ */
+
+#ifndef _AWS_DOUBLY_LINKED_LIST_H_
+#define _AWS_DOUBLY_LINKED_LIST_H_
+
+#include <stddef.h>
+#include <stdint.h>
+
+/**
+ * @brief Struct embedded in any struct to make it a doubly linked
+ * list.
+ *
+ * pxNext in the head points to the first node in the list and pxPrev
+ * in the head points to the last node in the list. In case of empty
+ * list, both pxPrev and pxNext in the head point to the head node itself.
+ */
+typedef struct Link
+{
+ struct Link * pxPrev; /**< Pointer to the previous node. */
+ struct Link * pxNext; /**< Pointer to the next node. */
+} Link_t;
+
+/**
+ * @brief Initializes the given list head to an empty list.
+ *
+ * @param[in] pxHead The given list head to initialize.
+ */
+#define listINIT_HEAD( pxHead ) \
+ { \
+ ( pxHead )->pxPrev = ( pxHead ); \
+ ( pxHead )->pxNext = ( pxHead ); \
+ }
+
+/**
+ * @brief Adds the given new node to the given list.
+ *
+ * @param[in] pxHead The head of the given list.
+ * @param[in] pxLink The given new node to be added to the given
+ * list.
+ */
+#define listADD( pxHead, pxLink ) \
+ { \
+ Link_t * pxPrevLink = ( pxHead ); \
+ Link_t * pxNextLink = ( ( pxHead )->pxNext ); \
+ \
+ ( pxLink )->pxNext = pxNextLink; \
+ pxNextLink->pxPrev = ( pxLink ); \
+ pxPrevLink->pxNext = ( pxLink ); \
+ ( pxLink )->pxPrev = ( pxPrevLink ); \
+ }
+
+/**
+ * @brief Removes the given node from the list it is part of.
+ *
+ * If the given node is not a part of any list (i.e. next and previous
+ * nodes are NULL), nothing happens.
+ *
+ * @param[in] pxLink The given node to remove from the list.
+ */
+#define listREMOVE( pxLink ) \
+ { \
+ /* If the link is part of a list, remove it from the list. */ \
+ if( ( pxLink )->pxNext != NULL && ( pxLink )->pxPrev != NULL ) \
+ { \
+ ( pxLink )->pxPrev->pxNext = ( pxLink )->pxNext; \
+ ( pxLink )->pxNext->pxPrev = ( pxLink )->pxPrev; \
+ } \
+ \
+ /* Make sure that this link is not part of any list anymore. */ \
+ ( pxLink )->pxPrev = NULL; \
+ ( pxLink )->pxNext = NULL; \
+ }
+
+/**
+ * @brief Given the head of a list, checks if the list is empty.
+ *
+ * @param[in] pxHead The head of the given list.
+ */
+#define listIS_EMPTY( pxHead ) ( ( ( pxHead ) == NULL ) || ( ( pxHead )->pxNext == ( pxHead ) ) )
+
+/**
+ * @brief Removes the first node from the given list and returns it.
+ *
+ * Removes the first node from the given list and assigns it to the
+ * pxLink parameter. If the list is empty, it assigns NULL to the
+ * pxLink.
+ *
+ * @param[in] pxHead The head of the list from which to remove the
+ * first node.
+ * @param[out] pxLink The output parameter to receive the removed
+ * node.
+ */
+#define listPOP( pxHead, pxLink ) \
+ { \
+ if( listIS_EMPTY( ( pxHead ) ) ) \
+ { \
+ ( pxLink ) = NULL; \
+ } \
+ else \
+ { \
+ ( pxLink ) = ( pxHead )->pxNext; \
+ /* If the link is part of a list, remove it from the list. */ \
+ if( ( pxLink )->pxNext != NULL && ( pxLink )->pxPrev != NULL ) \
+ { \
+ ( pxLink )->pxPrev->pxNext = ( pxLink )->pxNext; \
+ ( pxLink )->pxNext->pxPrev = ( pxLink )->pxPrev; \
+ } \
+ \
+ /* Make sure that this link is not part of any list anymore. */ \
+ ( pxLink )->pxPrev = NULL; \
+ ( pxLink )->pxNext = NULL; \
+ } \
+ }
+
+/**
+ * @brief Merges a list into a given list.
+ *
+ * @param[in] pxHeadResultList The head of the given list into which the
+ * other list should be merged.
+ * @param[in] pxHeadListToMerge The head of the list to be merged into the
+ * given list.
+ */
+#define listMERGE( pxHeadResultList, pxHeadListToMerge ) \
+ { \
+ if( !listIS_EMPTY( ( pxHeadListToMerge ) ) ) \
+ { \
+ /* Setup links between last node of listToMerge and first node of resultList. */ \
+ ( pxHeadListToMerge )->pxPrev->pxNext = ( pxHeadResultList )->pxNext; \
+ ( pxHeadResultList )->pxNext->pxPrev = ( pxHeadListToMerge )->pxPrev; \
+ \
+ /* Setup links between first node of listToMerge and the head of resultList. */ \
+ ( pxHeadListToMerge )->pxNext->pxPrev = ( pxHeadResultList ); \
+ ( pxHeadResultList )->pxNext = ( pxHeadListToMerge )->pxNext; \
+ /* Empty the merged list. */ \
+ listINIT_HEAD( ( pxHeadListToMerge ) ); \
+ } \
+ }
+
+/**
+ * @brief Helper macro to iterate over a list. pxLink contains the link node
+ * in each iteration.
+ */
+#define listFOR_EACH( pxLink, pxHead ) \
+ for( ( pxLink ) = ( pxHead )->pxNext; \
+ ( pxLink ) != ( pxHead ); \
+ ( pxLink ) = ( pxLink )->pxNext )
+
+/**
+ * @brief Helper macro to iterate over a list. It is safe to destroy/free the
+ * nodes while iterating. pxLink contains the link node in each iteration.
+ */
+#define listFOR_EACH_SAFE( pxLink, pxTempLink, pxHead ) \
+ for( ( pxLink ) = ( pxHead )->pxNext, ( pxTempLink ) = ( pxLink )->pxNext; \
+ ( pxLink ) != ( pxHead ); \
+ ( pxLink ) = ( pxTempLink ), ( pxTempLink ) = ( pxLink )->pxNext )
+
+/**
+ * @brief Given the pointer to the link member (of type Link_t) in a struct,
+ * extracts the pointer to the containing struct.
+ *
+ * @param[in] pxLink The pointer to the link member.
+ * @param[in] type The type of the containing struct.
+ * @param[in] member Name of the link member in the containing struct.
+ */
+#define listCONTAINER( pxLink, type, member ) ( ( type * ) ( ( uint8_t * ) ( pxLink ) - ( uint8_t * ) ( &( ( type * ) 0 )->member ) ) )
+
+#endif /* _AWS_DOUBLY_LINKED_LIST_H_ */