Fixed building with a bazel with hdrs_check fixed again.
Change-Id: I015f66cd6e02e07efa367b96edd775015ac0abca
diff --git a/aos/build/queues.bzl b/aos/build/queues.bzl
index 7c67a6b..47a1b68 100644
--- a/aos/build/queues.bzl
+++ b/aos/build/queues.bzl
@@ -102,6 +102,7 @@
'//aos/common:once',
'//aos/common:queues',
'//aos/common:queue_types',
+ '//aos/common/logging:logging_printf_formats',
],
visibility = visibility,
)
diff --git a/aos/common/BUILD b/aos/common/BUILD
index 06ba2c6..1691e22 100644
--- a/aos/common/BUILD
+++ b/aos/common/BUILD
@@ -10,6 +10,13 @@
)
cc_library(
+ name = 'math',
+ hdrs = [
+ 'commonmath.h',
+ ],
+)
+
+cc_library(
name = 'queue_testutils',
srcs = [
'queue_testutils.cc',
@@ -18,15 +25,30 @@
'queue_testutils.h',
],
deps = [
+ ':once',
+ ':queues',
'//aos/testing:googletest',
'//aos/common/logging',
- ':once',
'//aos/linux_code/ipc_lib:shared_mem',
'//aos/linux_code/ipc_lib:mutex',
],
)
cc_library(
+ name = 'macros',
+ hdrs = [
+ 'macros.h',
+ ],
+)
+
+cc_library(
+ name = 'type_traits',
+ hdrs = [
+ 'type_traits.h',
+ ],
+)
+
+cc_library(
name = 'time',
srcs = [
'time.cc',
@@ -37,6 +59,8 @@
deps = [
'//aos/common/logging:logging_interface',
'//aos/linux_code/ipc_lib:mutex',
+ ':macros',
+ '//aos/linux_code/ipc_lib:shared_mem',
],
)
@@ -65,21 +89,40 @@
)
cc_library(
+ name = 'event',
+ hdrs = [
+ 'event.h',
+ ],
+ deps = [
+ '//aos/linux_code/ipc_lib:aos_sync',
+ ],
+)
+
+cc_library(
+ name = 'unique_malloc_ptr',
+ hdrs = [
+ 'unique_malloc_ptr.h',
+ ],
+)
+
+cc_library(
name = 'queue_types',
srcs = [
'queue_types.cc',
':gen_print_field',
+ 'print_field_helpers.h',
],
hdrs = [
'queue_types.h',
],
deps = [
':generated_queue_headers',
- '//aos/common/logging:logging_interface',
'//aos/linux_code/ipc_lib:shared_mem',
'//aos/linux_code/ipc_lib:core_lib',
'//aos/linux_code/ipc_lib:mutex',
+ '//aos/common/logging:logging_printf_formats',
':time',
+ ':byteorder'
],
)
@@ -98,6 +141,20 @@
)
cc_library(
+ name = 'network_port',
+ hdrs = [
+ 'network_port.h',
+ ],
+)
+
+cc_library(
+ name = 'byteorder',
+ hdrs = [
+ 'byteorder.h',
+ ],
+)
+
+cc_library(
name = 'queues',
srcs = [
'queue.cc',
@@ -108,11 +165,17 @@
deps = [
'//aos/linux_code/ipc_lib:queue',
':time',
+ ':macros',
+ '//aos/linux_code:queue',
+ ':byteorder',
],
)
cc_library(
name = 'scoped_fd',
+ hdrs = [
+ 'scoped_fd.h',
+ ],
deps = [
'//aos/common/logging',
],
@@ -139,17 +202,28 @@
],
deps = [
'//aos/testing:googletest',
+ ':type_traits',
],
)
cc_library(
name = 'gtest_prod',
+ hdrs = [
+ 'gtest_prod.h',
+ ],
)
cc_library(
name = 'once',
+ hdrs = [
+ 'once.h',
+ ],
+ srcs = [
+ 'once-tmpl.h',
+ ],
deps = [
':gtest_prod',
+ ':type_traits',
],
)
@@ -186,6 +260,7 @@
'die.h',
],
deps = [
+ ':macros',
'//aos/common/libc:aos_strerror',
],
)
@@ -232,6 +307,13 @@
],
)
+cc_library(
+ name = 'condition',
+ hdrs = [
+ 'condition.h',
+ ],
+)
+
cc_test(
name = 'condition_test',
srcs = [
@@ -264,12 +346,26 @@
cc_library(
name = 'stl_mutex',
+ hdrs = [
+ 'stl_mutex.h',
+ ],
deps = [
'//aos/linux_code/ipc_lib:aos_sync',
'//aos/common/logging',
],
)
+cc_library(
+ name = 'mutex',
+ hdrs = [
+ 'mutex.h',
+ ],
+ deps = [
+ '//aos/linux_code/ipc_lib:aos_sync',
+ ':die',
+ ],
+)
+
cc_test(
name = 'stl_mutex_test',
srcs = [
diff --git a/aos/common/controls/BUILD b/aos/common/controls/BUILD
index 5c9ed5c..8b01386 100644
--- a/aos/common/controls/BUILD
+++ b/aos/common/controls/BUILD
@@ -4,6 +4,9 @@
cc_library(
name = 'replay_control_loop',
+ hdrs = [
+ 'replay_control_loop.h',
+ ],
deps = [
'//aos/common:queues',
':control_loop',
@@ -51,6 +54,7 @@
name = 'control_loop',
srcs = [
'control_loop.cc',
+ 'control_loop-tmpl.h',
],
hdrs = [
'control_loop.h',
diff --git a/aos/common/logging/BUILD b/aos/common/logging/BUILD
index 8bd59b9..9223c44 100644
--- a/aos/common/logging/BUILD
+++ b/aos/common/logging/BUILD
@@ -15,6 +15,7 @@
name = 'queue_logging',
srcs = [
'queue_logging.cc',
+ 'queue_logging-tmpl.h',
],
hdrs = [
'queue_logging.h',
@@ -27,9 +28,17 @@
)
cc_library(
+ name = 'sizes',
+ hdrs = [
+ 'sizes.h',
+ ],
+)
+
+cc_library(
name = 'matrix_logging',
srcs = [
'matrix_logging.cc',
+ 'matrix_logging-tmpl.h',
],
hdrs = [
'matrix_logging.h',
@@ -44,14 +53,45 @@
)
cc_library(
+ name = 'logging_printf_formats',
+ hdrs = [
+ 'logging_printf_formats.h',
+ ],
+ deps = [
+ '//aos/common:macros',
+ ],
+)
+
+cc_library(
name = 'logging_interface',
+ hdrs = [
+ 'logging.h',
+ 'logging_interface.h',
+ ],
srcs = [
'logging_interface.cc',
],
+ copts = [
+ # TODO(austin): This is wrong.
+ '-Wno-error=format-nonliteral'
+ ],
deps = [
- '//aos/linux_code/logging:linux_interface',
'//aos/common:die',
'//aos/common/libc:aos_strerror',
+ '//aos/linux_code/logging:linux_interface',
+ ],
+)
+
+cc_library(
+ name = 'context',
+ hdrs = [
+ 'context.h',
+ ],
+ srcs = [
+ 'context.cc',
+ ],
+ deps = [
+ ':sizes',
],
)
@@ -60,11 +100,12 @@
srcs = [
'logging_impl.cc',
],
+ hdrs = [
+ 'logging_impl.h',
+ ],
deps = [
- '//aos/linux_code/logging:linux_logging',
'//aos/common:time',
'//aos/common:once',
- ':logging_interface',
'//aos/common:queue_types',
],
)
diff --git a/aos/common/logging/context.cc b/aos/common/logging/context.cc
new file mode 100644
index 0000000..8874edb
--- /dev/null
+++ b/aos/common/logging/context.cc
@@ -0,0 +1,19 @@
+#include "aos/common/logging/context.h"
+
+#include <string.h>
+
+namespace aos {
+namespace logging {
+namespace internal {
+
+::std::atomic<LogImplementation *> global_top_implementation(NULL);
+
+Context::Context()
+ : implementation(global_top_implementation.load()),
+ sequence(0) {
+ cork_data.Reset();
+}
+
+} // namespace internal
+} // namespace logging
+} // namespace aos
diff --git a/aos/common/logging/context.h b/aos/common/logging/context.h
new file mode 100644
index 0000000..b7fee26
--- /dev/null
+++ b/aos/common/logging/context.h
@@ -0,0 +1,84 @@
+#ifndef AOS_COMMON_LOGGING_CONTEXT_H_
+#define AOS_COMMON_LOGGING_CONTEXT_H_
+
+#include <inttypes.h>
+#include <stddef.h>
+#include <sys/types.h>
+#include <limits.h>
+
+#include <atomic>
+
+#include "aos/common/logging/sizes.h"
+
+namespace aos {
+namespace logging {
+
+class LogImplementation;
+
+// This is where all of the code that is only used by actual LogImplementations
+// goes.
+namespace internal {
+
+extern ::std::atomic<LogImplementation *> global_top_implementation;
+
+// An separate instance of this class is accessible from each task/thread.
+// NOTE: It will get deleted in the child of a fork.
+//
+// Get() and Delete() are implemented in the platform-specific interface.cc
+// file.
+struct Context {
+ Context();
+
+ // Gets the Context object for this task/thread. Will create one the first
+ // time it is called.
+ //
+ // The implementation for each platform will lazily instantiate a new instance
+ // and then initialize name the first time.
+ // IMPORTANT: The implementation of this can not use logging.
+ static Context *Get();
+ // Deletes the Context object for this task/thread so that the next Get() is
+ // called it will create a new one.
+ // It is valid to call this when Get() has never been called.
+ // This also gets called after a fork(2) in the new process, where it should
+ // still work to clean up any state.
+ static void Delete();
+
+ // Which one to log to right now.
+ // Will be NULL if there is no logging implementation to use right now.
+ LogImplementation *implementation;
+
+ // A name representing this task/(process and thread).
+ char name[LOG_MESSAGE_NAME_LEN];
+ size_t name_size;
+
+ // What to assign LogMessage::source to in this task/thread.
+ pid_t source;
+
+ // The sequence value to send out with the next message.
+ uint16_t sequence;
+
+ // Contains all of the information related to implementing LOG_CORK and
+ // LOG_UNCORK.
+ struct {
+ char message[LOG_MESSAGE_LEN];
+ int line_min, line_max;
+ // Sets the data up to record a new series of corked logs.
+ void Reset() {
+ message[0] = '\0'; // make strlen of it 0
+ line_min = INT_MAX;
+ line_max = -1;
+ function = NULL;
+ }
+ // The function that the calls are in.
+ // REMEMBER: While the compiler/linker will probably optimize all of the
+ // identical strings to point to the same data, it might not, so using == to
+ // compare this with another value is a bad idea.
+ const char *function;
+ } cork_data;
+};
+
+} // namespace internal
+} // namespace logging
+} // namespace aos
+
+#endif // AOS_COMMON_LOGGING_CONTEXT_H_
diff --git a/aos/common/logging/logging.h b/aos/common/logging/logging.h
index 66b88c7..3182d1a 100644
--- a/aos/common/logging/logging.h
+++ b/aos/common/logging/logging.h
@@ -33,9 +33,6 @@
DECL_LEVELS;
#undef DECL_LEVEL
-// Not static const size_t for C code.
-#define LOG_MESSAGE_LEN 400
-
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/aos/common/logging/logging_impl.cc b/aos/common/logging/logging_impl.cc
index c776991..34c3816 100644
--- a/aos/common/logging/logging_impl.cc
+++ b/aos/common/logging/logging_impl.cc
@@ -1,10 +1,10 @@
#include "aos/common/logging/logging_impl.h"
#include <stdarg.h>
-
-#include "aos/common/time.h"
#include <inttypes.h>
+
#include "aos/common/once.h"
+#include "aos/common/time.h"
#include "aos/common/queue_types.h"
#include "aos/common/logging/logging_printf_formats.h"
diff --git a/aos/common/logging/logging_impl.h b/aos/common/logging/logging_impl.h
index 367c1a1..ab4b728 100644
--- a/aos/common/logging/logging_impl.h
+++ b/aos/common/logging/logging_impl.h
@@ -17,6 +17,10 @@
#include "aos/common/type_traits.h"
#include "aos/common/mutex.h"
#include "aos/common/macros.h"
+#include "aos/common/logging/sizes.h"
+#include "aos/common/logging/logging_interface.h"
+#include "aos/common/logging/context.h"
+#include "aos/common/once.h"
namespace aos {
@@ -58,7 +62,7 @@
uint16_t sequence;
Type type;
log_level level;
- char name[100];
+ char name[LOG_MESSAGE_NAME_LEN];
union {
char message[LOG_MESSAGE_LEN];
struct {
@@ -125,78 +129,6 @@
template <class T>
void DoLogMatrix(log_level, const ::std::string &, const T &);
-// Represents a system that can actually take log messages and do something
-// useful with them.
-// All of the code (transitively too!) in the DoLog here can make
-// normal LOG and LOG_DYNAMIC calls but can NOT call LOG_CORK/LOG_UNCORK. These
-// calls will not result in DoLog recursing. However, implementations must be
-// safe to call from multiple threads/tasks at the same time. Also, any other
-// overriden methods may end up logging through a given implementation's DoLog.
-class LogImplementation {
- public:
- LogImplementation() : next_(NULL) {}
-
- // The one that this one's implementation logs to.
- // NULL means that there is no next one.
- LogImplementation *next() { return next_; }
- // Virtual in case a subclass wants to perform checks. There will be a valid
- // logger other than this one available while this is called.
- virtual void set_next(LogImplementation *next) { next_ = next; }
-
- private:
- // Actually logs the given message. Implementations should somehow create a
- // LogMessage and then call internal::FillInMessage.
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
- virtual void DoLog(log_level level, const char *format, va_list ap) = 0;
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 4)))
- void DoLogVariadic(log_level level, const char *format, ...) {
- va_list ap;
- va_start(ap, format);
- DoLog(level, format, ap);
- va_end(ap);
- }
-
- // Logs the contents of an auto-generated structure. The implementation here
- // just converts it to a string with PrintMessage and then calls DoLog with
- // that, however some implementations can be a lot more efficient than that.
- // size and type are the result of calling Size() and Type() on the type of
- // the message.
- // serialize will call Serialize on the message.
- virtual void LogStruct(log_level level, const ::std::string &message,
- size_t size, const MessageType *type,
- const ::std::function<size_t(char *)> &serialize);
- // Similiar to LogStruct, except for matrixes.
- // type_id is the type of the elements of the matrix.
- // data points to rows*cols*type_id.Size() bytes of data in row-major order.
- virtual void LogMatrix(log_level level, const ::std::string &message,
- uint32_t type_id, int rows, int cols,
- const void *data);
-
- // These functions call similar methods on the "current" LogImplementation or
- // Die if they can't find one.
- // levels is how many LogImplementations to not use off the stack.
- static void DoVLog(log_level, const char *format, va_list ap, int levels)
- __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
- // This one is implemented in queue_logging.cc.
- static void DoLogStruct(log_level level, const ::std::string &message,
- size_t size, const MessageType *type,
- const ::std::function<size_t(char *)> &serialize,
- int levels);
- // This one is implemented in matrix_logging.cc.
- static void DoLogMatrix(log_level level, const ::std::string &message,
- uint32_t type_id, int rows, int cols,
- const void *data, int levels);
-
- // Friends so that they can access the static Do* functions.
- friend void VLog(log_level, const char *, va_list);
- friend void LogNext(log_level, const char *, ...);
- template <class T>
- friend void DoLogStruct(log_level, const ::std::string &, const T &);
- template <class T>
- friend void DoLogMatrix(log_level, const ::std::string &, const T &);
-
- LogImplementation *next_;
-};
// Implements all of the DoLog* methods in terms of a (pure virtual in this
// class) HandleMessage method that takes a pointer to the message.
@@ -252,64 +184,6 @@
// goes.
namespace internal {
-extern ::std::atomic<LogImplementation *> global_top_implementation;
-
-// An separate instance of this class is accessible from each task/thread.
-// NOTE: It will get deleted in the child of a fork.
-//
-// Get() and Delete() are implemented in the platform-specific interface.cc
-// file.
-struct Context {
- Context();
-
- // Gets the Context object for this task/thread. Will create one the first
- // time it is called.
- //
- // The implementation for each platform will lazily instantiate a new instance
- // and then initialize name the first time.
- // IMPORTANT: The implementation of this can not use logging.
- static Context *Get();
- // Deletes the Context object for this task/thread so that the next Get() is
- // called it will create a new one.
- // It is valid to call this when Get() has never been called.
- // This also gets called after a fork(2) in the new process, where it should
- // still work to clean up any state.
- static void Delete();
-
- // Which one to log to right now.
- // Will be NULL if there is no logging implementation to use right now.
- LogImplementation *implementation;
-
- // A name representing this task/(process and thread).
- char name[sizeof(LogMessage::name)];
- size_t name_size;
-
- // What to assign LogMessage::source to in this task/thread.
- pid_t source;
-
- // The sequence value to send out with the next message.
- uint16_t sequence;
-
- // Contains all of the information related to implementing LOG_CORK and
- // LOG_UNCORK.
- struct {
- char message[LOG_MESSAGE_LEN];
- int line_min, line_max;
- // Sets the data up to record a new series of corked logs.
- void Reset() {
- message[0] = '\0'; // make strlen of it 0
- line_min = INT_MAX;
- line_max = -1;
- function = NULL;
- }
- // The function that the calls are in.
- // REMEMBER: While the compiler/linker will probably optimize all of the
- // identical strings to point to the same data, it might not, so using == to
- // compare this with another value is a bad idea.
- const char *function;
- } cork_data;
-};
-
// Fills in all the parts of message according to the given inputs (with type
// kStruct).
void FillInMessageStructure(log_level level,
diff --git a/aos/common/logging/logging_interface.cc b/aos/common/logging/logging_interface.cc
index 0bec52c..0a6c968 100644
--- a/aos/common/logging/logging_interface.cc
+++ b/aos/common/logging/logging_interface.cc
@@ -1,11 +1,14 @@
-#include "aos/common/logging/logging_impl.h"
+#include "aos/common/logging/logging_interface.h"
#include <stdarg.h>
+#include <stdio.h>
#include <string.h>
#include <type_traits>
+#include <functional>
#include "aos/common/die.h"
+#include "aos/common/logging/context.h"
// This file only contains the code necessary to link (ie no implementations).
// See logging_impl.h for why this is necessary.
@@ -14,14 +17,6 @@
namespace logging {
namespace internal {
-::std::atomic<LogImplementation *> global_top_implementation(NULL);
-
-Context::Context()
- : implementation(global_top_implementation.load()),
- sequence(0) {
- cork_data.Reset();
-}
-
size_t ExecuteFormat(char *output, size_t output_size, const char *format,
va_list ap) {
static const char *const continued = "...\n";
diff --git a/aos/common/logging/logging_interface.h b/aos/common/logging/logging_interface.h
new file mode 100644
index 0000000..af591ee
--- /dev/null
+++ b/aos/common/logging/logging_interface.h
@@ -0,0 +1,96 @@
+#ifndef AOS_COMMON_LOGGING_LOGGING_INTERFACE_H_
+#define AOS_COMMON_LOGGING_LOGGING_INTERFACE_H_
+
+#include <stdarg.h>
+
+#include <string>
+#include <functional>
+
+#include "aos/common/logging/logging.h"
+
+namespace aos {
+
+struct MessageType;
+
+} // namespace aos
+
+namespace aos {
+namespace logging {
+
+// Represents a system that can actually take log messages and do something
+// useful with them.
+// All of the code (transitively too!) in the DoLog here can make
+// normal LOG and LOG_DYNAMIC calls but can NOT call LOG_CORK/LOG_UNCORK. These
+// calls will not result in DoLog recursing. However, implementations must be
+// safe to call from multiple threads/tasks at the same time. Also, any other
+// overriden methods may end up logging through a given implementation's DoLog.
+class LogImplementation {
+ public:
+ LogImplementation() : next_(NULL) {}
+
+ // The one that this one's implementation logs to.
+ // NULL means that there is no next one.
+ LogImplementation *next() { return next_; }
+ // Virtual in case a subclass wants to perform checks. There will be a valid
+ // logger other than this one available while this is called.
+ virtual void set_next(LogImplementation *next) { next_ = next; }
+
+ private:
+ // Actually logs the given message. Implementations should somehow create a
+ // LogMessage and then call internal::FillInMessage.
+ __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 0)))
+ virtual void DoLog(log_level level, const char *format, va_list ap) = 0;
+ __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 3, 4)))
+ void DoLogVariadic(log_level level, const char *format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ DoLog(level, format, ap);
+ va_end(ap);
+ }
+
+ // Logs the contents of an auto-generated structure. The implementation here
+ // just converts it to a string with PrintMessage and then calls DoLog with
+ // that, however some implementations can be a lot more efficient than that.
+ // size and type are the result of calling Size() and Type() on the type of
+ // the message.
+ // serialize will call Serialize on the message.
+ virtual void LogStruct(log_level level, const ::std::string &message,
+ size_t size, const MessageType *type,
+ const ::std::function<size_t(char *)> &serialize);
+ // Similiar to LogStruct, except for matrixes.
+ // type_id is the type of the elements of the matrix.
+ // data points to rows*cols*type_id.Size() bytes of data in row-major order.
+ virtual void LogMatrix(log_level level, const ::std::string &message,
+ uint32_t type_id, int rows, int cols,
+ const void *data);
+
+ // These functions call similar methods on the "current" LogImplementation or
+ // Die if they can't find one.
+ // levels is how many LogImplementations to not use off the stack.
+ static void DoVLog(log_level, const char *format, va_list ap, int levels)
+ __attribute__((format(GOOD_PRINTF_FORMAT_TYPE, 2, 0)));
+ // This one is implemented in queue_logging.cc.
+ static void DoLogStruct(log_level level, const ::std::string &message,
+ size_t size, const MessageType *type,
+ const ::std::function<size_t(char *)> &serialize,
+ int levels);
+ // This one is implemented in matrix_logging.cc.
+ static void DoLogMatrix(log_level level, const ::std::string &message,
+ uint32_t type_id, int rows, int cols,
+ const void *data, int levels);
+
+ // Friends so that they can access the static Do* functions.
+ friend void VLog(log_level, const char *, va_list);
+ friend void LogNext(log_level, const char *, ...);
+ template <class T>
+ friend void DoLogStruct(log_level, const ::std::string &, const T &);
+ template <class T>
+ friend void DoLogMatrix(log_level, const ::std::string &, const T &);
+
+ LogImplementation *next_;
+};
+
+} // namespace logging
+} // namespace aos
+
+#endif // AOS_COMMON_LOGGING_LOGGING_INTERFACE_H_
diff --git a/aos/common/logging/sizes.h b/aos/common/logging/sizes.h
new file mode 100644
index 0000000..6a4c7d5
--- /dev/null
+++ b/aos/common/logging/sizes.h
@@ -0,0 +1,9 @@
+#ifndef AOS_COMMON_LOGGING_SIZES_H_
+#define AOS_COMMON_LOGGING_SIZES_H_
+
+// This file exists so C code and context.h can both get at these constants...
+
+#define LOG_MESSAGE_LEN 400
+#define LOG_MESSAGE_NAME_LEN 100
+
+#endif // AOS_COMMON_LOGGING_SIZES_H_
diff --git a/aos/common/queue.h b/aos/common/queue.h
index 5f6adeb..15328fb 100644
--- a/aos/common/queue.h
+++ b/aos/common/queue.h
@@ -3,7 +3,6 @@
#include <assert.h>
-#include "aos/common/time.h"
#include "aos/common/macros.h"
#include "aos/linux_code/ipc_lib/queue.h"
#include "aos/common/time.h"
diff --git a/aos/common/util/BUILD b/aos/common/util/BUILD
index e2c6b8c..646f3bf 100644
--- a/aos/common/util/BUILD
+++ b/aos/common/util/BUILD
@@ -28,6 +28,9 @@
cc_library(
name = 'death_test_log_implementation',
+ hdrs = [
+ 'death_test_log_implementation.h',
+ ],
deps = [
'//aos/common/logging',
],
@@ -41,6 +44,10 @@
hdrs = [
'inet_addr.h',
],
+ deps = [
+ '//aos/common:byteorder',
+ '//aos/common:network_port',
+ ],
)
cc_library(
@@ -59,6 +66,9 @@
cc_library(
name = 'log_interval',
+ hdrs = [
+ 'log_interval.h',
+ ],
deps = [
'//aos/common:time',
'//aos/common/logging',
@@ -67,6 +77,9 @@
cc_library(
name = 'string_to_num',
+ hdrs = [
+ 'string_to_num.h',
+ ],
)
cc_test(
@@ -88,6 +101,10 @@
hdrs = [
'thread.h',
],
+ deps = [
+ '//aos/common:macros',
+ '//aos/common/logging:logging_interface',
+ ],
)
cc_library(
@@ -138,12 +155,20 @@
],
)
+cc_library(
+ name = 'options',
+ hdrs = [
+ 'options.h',
+ ],
+)
+
cc_test(
name = 'options_test',
srcs = [
'options_test.cc',
],
deps = [
+ ':options',
'//aos/testing:googletest',
],
)
diff --git a/aos/linux_code/BUILD b/aos/linux_code/BUILD
index de7f903..6c4d1e0 100644
--- a/aos/linux_code/BUILD
+++ b/aos/linux_code/BUILD
@@ -12,6 +12,14 @@
)
cc_library(
+ name = 'queue',
+ visibility = ['//aos/common:__pkg__'],
+ hdrs = [
+ 'queue-tmpl.h',
+ ],
+)
+
+cc_library(
name = 'complex_thread_local',
srcs = [
'complex_thread_local.cc',
@@ -50,7 +58,7 @@
deps = [
'//aos/linux_code/ipc_lib:shared_mem',
'//aos/common:die',
- '//aos/common/logging',
+ '//aos/linux_code/logging:linux_logging',
],
)
@@ -65,6 +73,7 @@
deps = [
'//aos/common:once',
'//aos/common/logging',
+ '//aos/common:unique_malloc_ptr',
],
)
diff --git a/aos/linux_code/ipc_lib/BUILD b/aos/linux_code/ipc_lib/BUILD
index 077968b..47b9e8e 100644
--- a/aos/linux_code/ipc_lib/BUILD
+++ b/aos/linux_code/ipc_lib/BUILD
@@ -11,6 +11,7 @@
deps = [
'//aos/common/logging:logging_interface',
'//aos/common:once',
+ '//aos/common:macros',
],
)
@@ -24,7 +25,7 @@
],
deps = [
':aos_sync',
- ':shared_mem',
+ ':shared_mem_types',
],
)
@@ -38,7 +39,22 @@
],
deps = [
':aos_sync',
+ ':core_lib',
+ ':shared_mem_types',
'//aos/common/logging:logging_interface',
+ '//debian:librt',
+ ],
+)
+
+cc_library(
+ # TODO(Brian): This should be shared_mem{,.h}, and the other one should be
+ # shared_mem_init{,.cc,.h}.
+ name = 'shared_mem_types',
+ hdrs = [
+ 'shared_mem_types.h',
+ ],
+ deps = [
+ ':aos_sync',
],
)
@@ -54,8 +70,10 @@
'//aos/linux_code/ipc_lib:condition',
'//aos/linux_code/ipc_lib:mutex',
':core_lib',
+ ':shared_mem',
'//aos/common/logging:logging_interface',
'//debian:librt',
+ '//aos/common/util:options',
],
)
@@ -112,6 +130,7 @@
],
deps = [
':mutex',
+ '//aos/common:condition',
':aos_sync',
'//aos/common/logging:logging_interface',
],
@@ -125,6 +144,8 @@
deps = [
':aos_sync',
'//aos/common/logging:logging_interface',
+ '//aos/common:type_traits',
+ '//aos/common:mutex',
],
)
@@ -136,5 +157,6 @@
deps = [
':aos_sync',
'//aos/common/logging:logging_interface',
+ '//aos/common:event',
],
)
diff --git a/aos/linux_code/ipc_lib/core_lib.c b/aos/linux_code/ipc_lib/core_lib.c
index de418a4..ddcd7f5 100644
--- a/aos/linux_code/ipc_lib/core_lib.c
+++ b/aos/linux_code/ipc_lib/core_lib.c
@@ -4,7 +4,7 @@
#include <stdlib.h>
#include <assert.h>
-#include "aos/linux_code/ipc_lib/shared_mem.h"
+#include "aos/linux_code/ipc_lib/shared_mem_types.h"
static uint8_t aos_8max(uint8_t l, uint8_t r) {
return (l > r) ? l : r;
diff --git a/aos/linux_code/ipc_lib/shared_mem.c b/aos/linux_code/ipc_lib/shared_mem.c
index c43bfa2..f0a2aee 100644
--- a/aos/linux_code/ipc_lib/shared_mem.c
+++ b/aos/linux_code/ipc_lib/shared_mem.c
@@ -12,6 +12,7 @@
#include "aos/linux_code/ipc_lib/core_lib.h"
#include "aos/common/logging/logging.h"
+#include "aos/linux_code/ipc_lib/aos_sync.h"
// the path for the shared memory segment. see shm_open(3) for restrictions
#define AOS_SHM_NAME "/aos_shared_mem"
diff --git a/aos/linux_code/ipc_lib/shared_mem.h b/aos/linux_code/ipc_lib/shared_mem.h
index 423fd0c..36acfd0 100644
--- a/aos/linux_code/ipc_lib/shared_mem.h
+++ b/aos/linux_code/ipc_lib/shared_mem.h
@@ -5,60 +5,12 @@
#include <unistd.h>
#include <time.h>
-#include "aos/linux_code/ipc_lib/aos_sync.h"
+#include "aos/linux_code/ipc_lib/shared_mem_types.h"
#ifdef __cplusplus
extern "C" {
#endif
-extern struct aos_core *global_core __attribute__((weak));
-
-// Where the shared memory segment starts in each process's address space.
-// Has to be the same in all of them so that stuff in shared memory
-// can have regular pointers to other stuff in shared memory.
-#define SHM_START 0x20000000
-
-// A structure that represents some kind of global pointer that everything
-// shares.
-typedef struct aos_global_pointer_t {
- struct aos_mutex lock;
- void *pointer;
-} aos_global_pointer;
-
-typedef struct aos_shm_core_t {
- // Gets 0-initialized at the start (as part of shared memory) and
- // the owner sets as soon as it finishes setting stuff up.
- aos_condition creation_condition;
-
- // An offset from CLOCK_REALTIME to times for all the code.
- // This is currently only set to non-zero by the log replay code.
- // There is no synchronization on this to avoid the overhead because it is
- // only updated with proper memory barriers when only a single task is
- // running.
- struct timespec time_offset;
-
- struct aos_mutex msg_alloc_lock;
- void *msg_alloc;
-
- // A pointer to the head of the linked list of queues.
- // pointer points to a ::aos::Queue.
- aos_global_pointer queues;
- // A pointer to the head of the linked list of queue message types.
- // pointer points to a ::aos::type_cache::ShmType.
- aos_global_pointer queue_types;
-} aos_shm_core;
-
-struct aos_core {
- // Non-0 if we "own" shared_mem and should shm_unlink(3) it when we're done.
- int owner;
- void *shared_mem;
- // How large the chunk of shared memory is.
- ptrdiff_t size;
- aos_shm_core *mem_struct;
- // For the owner to store the name of the file to unlink when closing.
- const char *shm_name;
-};
-
void init_shared_mem_core(aos_shm_core *shm_core);
ptrdiff_t aos_core_get_mem_usage(void);
diff --git a/aos/linux_code/ipc_lib/shared_mem_types.h b/aos/linux_code/ipc_lib/shared_mem_types.h
new file mode 100644
index 0000000..81fab60
--- /dev/null
+++ b/aos/linux_code/ipc_lib/shared_mem_types.h
@@ -0,0 +1,64 @@
+#ifndef AOS_LINUX_CODE_IPC_LIB_SHARED_MEM_TYPES_H_
+#define AOS_LINUX_CODE_IPC_LIB_SHARED_MEM_TYPES_H_
+
+#include <stddef.h>
+
+#include "aos/linux_code/ipc_lib/aos_sync.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern struct aos_core *global_core __attribute__((weak));
+
+// Where the shared memory segment starts in each process's address space.
+// Has to be the same in all of them so that stuff in shared memory
+// can have regular pointers to other stuff in shared memory.
+#define SHM_START 0x20000000
+
+// A structure that represents some kind of global pointer that everything
+// shares.
+typedef struct aos_global_pointer_t {
+ struct aos_mutex lock;
+ void *pointer;
+} aos_global_pointer;
+
+typedef struct aos_shm_core_t {
+ // Gets 0-initialized at the start (as part of shared memory) and
+ // the owner sets as soon as it finishes setting stuff up.
+ aos_condition creation_condition;
+
+ // An offset from CLOCK_REALTIME to times for all the code.
+ // This is currently only set to non-zero by the log replay code.
+ // There is no synchronization on this to avoid the overhead because it is
+ // only updated with proper memory barriers when only a single task is
+ // running.
+ struct timespec time_offset;
+
+ struct aos_mutex msg_alloc_lock;
+ void *msg_alloc;
+
+ // A pointer to the head of the linked list of queues.
+ // pointer points to a ::aos::Queue.
+ aos_global_pointer queues;
+ // A pointer to the head of the linked list of queue message types.
+ // pointer points to a ::aos::type_cache::ShmType.
+ aos_global_pointer queue_types;
+} aos_shm_core;
+
+struct aos_core {
+ // Non-0 if we "own" shared_mem and should shm_unlink(3) it when we're done.
+ int owner;
+ void *shared_mem;
+ // How large the chunk of shared memory is.
+ ptrdiff_t size;
+ aos_shm_core *mem_struct;
+ // For the owner to store the name of the file to unlink when closing.
+ const char *shm_name;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // AOS_LINUX_CODE_IPC_LIB_SHARED_MEM_TYPES_H_
diff --git a/aos/linux_code/logging/BUILD b/aos/linux_code/logging/BUILD
index 29c6d78..aea10f8 100644
--- a/aos/linux_code/logging/BUILD
+++ b/aos/linux_code/logging/BUILD
@@ -55,6 +55,7 @@
':binary_log_file',
'//aos/common:queue_types',
'//aos/linux_code:configuration',
+ '//aos/common/util:string_to_num',
],
)
@@ -80,17 +81,25 @@
deps = [
'//aos/linux_code:complex_thread_local',
'//aos/common:die',
+ '//aos/common/logging:context',
],
)
cc_library(
name = 'linux_logging',
- visibility = ['//aos/common/logging:__pkg__'],
+ visibility = [
+ '//aos/common/logging:__pkg__',
+ '//aos/linux_code:__subpackages__'
+ ],
+ hdrs = [
+ 'linux_logging.h',
+ ],
srcs = [
'linux_logging.cc',
],
deps = [
'//aos/linux_code/ipc_lib:queue',
'//aos/common:time',
+ '//aos/common/logging:logging',
],
)
diff --git a/aos/linux_code/logging/linux_interface.cc b/aos/linux_code/logging/linux_interface.cc
index b0a5c1b..dff48e1 100644
--- a/aos/linux_code/logging/linux_interface.cc
+++ b/aos/linux_code/logging/linux_interface.cc
@@ -1,6 +1,10 @@
-#include "aos/linux_code/logging/linux_logging.h"
+#include "aos/common/logging/context.h"
+#include <string>
+#include <string.h>
#include <sys/prctl.h>
+#include <sys/types.h>
+#include <unistd.h>
#include "aos/linux_code/complex_thread_local.h"
#include "aos/common/die.h"
diff --git a/aos/linux_code/logging/linux_logging.cc b/aos/linux_code/logging/linux_logging.cc
index b13a740..b73595b 100644
--- a/aos/linux_code/logging/linux_logging.cc
+++ b/aos/linux_code/logging/linux_logging.cc
@@ -13,7 +13,7 @@
#include <algorithm>
#include "aos/common/die.h"
-#include "aos/common/logging/logging_impl.h"
+#include "aos/common/logging/logging_interface.h"
#include "aos/linux_code/ipc_lib/queue.h"
#include "aos/common/time.h"
diff --git a/aos/linux_code/starter/BUILD b/aos/linux_code/starter/BUILD
index bccb7f5..5e3ac38 100644
--- a/aos/linux_code/starter/BUILD
+++ b/aos/linux_code/starter/BUILD
@@ -21,5 +21,6 @@
'//aos/common:time',
'//aos/common/libc:aos_strsignal',
'//aos/common/util:run_command',
+ '//aos/common:unique_malloc_ptr',
],
)