You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/09/20 12:39:47 UTC

[GitHub] andrzej-kaczmarek closed pull request #1409: kernel/os: Make os_time ms<->ticks conversions static inline

andrzej-kaczmarek closed pull request #1409:  kernel/os: Make os_time ms<->ticks conversions static inline 
URL: https://github.com/apache/mynewt-core/pull/1409
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/hw/mcu/nordic/nrf52xxx-compat/include/mcu/cortex_m4.h b/hw/mcu/nordic/nrf52xxx-compat/include/mcu/cortex_m4.h
index b635eaf917..94a3d5a143 100644
--- a/hw/mcu/nordic/nrf52xxx-compat/include/mcu/cortex_m4.h
+++ b/hw/mcu/nordic/nrf52xxx-compat/include/mcu/cortex_m4.h
@@ -20,8 +20,6 @@
 #ifndef __MCU_CORTEX_M4_H__
 #define __MCU_CORTEX_M4_H__
 
-#include "os/mynewt.h"
-
 #include "nrf.h"
 
 #ifdef __cplusplus
diff --git a/hw/mcu/nordic/nrf52xxx-compat/src/hal_system.c b/hw/mcu/nordic/nrf52xxx-compat/src/hal_system.c
index 01cc8958d9..4cfd860054 100644
--- a/hw/mcu/nordic/nrf52xxx-compat/src/hal_system.c
+++ b/hw/mcu/nordic/nrf52xxx-compat/src/hal_system.c
@@ -18,6 +18,7 @@
  */
 
 #include <mcu/cortex_m4.h>
+#include "syscfg/syscfg.h"
 #include "hal/hal_system.h"
 #include "nrf.h"
 
diff --git a/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h b/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
index b635eaf917..94a3d5a143 100644
--- a/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
+++ b/hw/mcu/nordic/nrf52xxx/include/mcu/cortex_m4.h
@@ -20,8 +20,6 @@
 #ifndef __MCU_CORTEX_M4_H__
 #define __MCU_CORTEX_M4_H__
 
-#include "os/mynewt.h"
-
 #include "nrf.h"
 
 #ifdef __cplusplus
diff --git a/hw/mcu/nordic/nrf52xxx/src/hal_system.c b/hw/mcu/nordic/nrf52xxx/src/hal_system.c
index 01cc8958d9..9721152872 100644
--- a/hw/mcu/nordic/nrf52xxx/src/hal_system.c
+++ b/hw/mcu/nordic/nrf52xxx/src/hal_system.c
@@ -17,7 +17,7 @@
  * under the License.
  */
 
-#include <mcu/cortex_m4.h>
+#include "syscfg/syscfg.h"
 #include "hal/hal_system.h"
 #include "nrf.h"
 
diff --git a/kernel/os/include/os/arch/cortex_m0/os/os_arch.h b/kernel/os/include/os/arch/cortex_m0/os/os_arch.h
index 86f2625e72..1801b3c94a 100644
--- a/kernel/os/include/os/arch/cortex_m0/os/os_arch.h
+++ b/kernel/os/include/os/arch/cortex_m0/os/os_arch.h
@@ -21,7 +21,8 @@
 #define _OS_ARCH_ARM_H
 
 #include <stdint.h>
-#include <mcu/cortex_m0.h>
+#include "syscfg/syscfg.h"
+#include "mcu/cortex_m0.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/kernel/os/include/os/arch/cortex_m3/os/os_arch.h b/kernel/os/include/os/arch/cortex_m3/os/os_arch.h
index 45da2d5b36..6f235f2bcc 100644
--- a/kernel/os/include/os/arch/cortex_m3/os/os_arch.h
+++ b/kernel/os/include/os/arch/cortex_m3/os/os_arch.h
@@ -21,6 +21,7 @@
 #define _OS_ARCH_ARM_H
 
 #include <stdint.h>
+#include "syscfg/syscfg.h"
 #include "mcu/cortex_m3.h"
 
 #ifdef __cplusplus
diff --git a/kernel/os/include/os/arch/cortex_m4/os/os_arch.h b/kernel/os/include/os/arch/cortex_m4/os/os_arch.h
index cae4f6c3d4..c0e6ac4bd5 100644
--- a/kernel/os/include/os/arch/cortex_m4/os/os_arch.h
+++ b/kernel/os/include/os/arch/cortex_m4/os/os_arch.h
@@ -21,6 +21,7 @@
 #define _OS_ARCH_ARM_H
 
 #include <stdint.h>
+#include "syscfg/syscfg.h"
 #include "mcu/cortex_m4.h"
 
 #ifdef __cplusplus
diff --git a/kernel/os/include/os/arch/cortex_m7/os/os_arch.h b/kernel/os/include/os/arch/cortex_m7/os/os_arch.h
index 99d6f3839f..cd291786f1 100644
--- a/kernel/os/include/os/arch/cortex_m7/os/os_arch.h
+++ b/kernel/os/include/os/arch/cortex_m7/os/os_arch.h
@@ -21,6 +21,7 @@
 #define _OS_ARCH_ARM_H
 
 #include <stdint.h>
+#include "syscfg/syscfg.h"
 #include "mcu/cortex_m7.h"
 
 #ifdef __cplusplus
diff --git a/kernel/os/include/os/os_time.h b/kernel/os/include/os/os_time.h
index 86742f25ea..6763de3557 100644
--- a/kernel/os/include/os/os_time.h
+++ b/kernel/os/include/os/os_time.h
@@ -62,6 +62,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include "os/os_arch.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -242,7 +243,15 @@ int os_time_ticks_to_ms(os_time_t ticks, uint32_t *out_ms);
  *
  * @return                      result on success
  */
-os_time_t os_time_ms_to_ticks32(uint32_t ms);
+static inline os_time_t
+os_time_ms_to_ticks32(uint32_t ms)
+{
+#if OS_TICKS_PER_SEC == 1000
+    return ms;
+#else
+    return ((uint64_t)ms * OS_TICKS_PER_SEC) / 1000;
+#endif
+}
 
 /**
  * Converts OS ticks to milliseconds.
@@ -254,7 +263,15 @@ os_time_t os_time_ms_to_ticks32(uint32_t ms);
  *
  * @return                      result on success
  */
-uint32_t os_time_ticks_to_ms32(os_time_t ticks);
+static inline uint32_t
+os_time_ticks_to_ms32(os_time_t ticks)
+{
+#if OS_TICKS_PER_SEC == 1000
+    return ticks;
+#else
+    return ((uint64_t)ticks * 1000) / OS_TICKS_PER_SEC;
+#endif
+}
 
 #ifdef __cplusplus
 }
diff --git a/kernel/os/src/os_time.c b/kernel/os/src/os_time.c
index 01e00c3a46..51ae7d6a11 100644
--- a/kernel/os/src/os_time.c
+++ b/kernel/os/src/os_time.c
@@ -229,23 +229,3 @@ os_time_ticks_to_ms(os_time_t ticks, uint32_t *out_ms)
 
     return 0;
 }
-
-os_time_t
-os_time_ms_to_ticks32(uint32_t ms)
-{
-#if OS_TICKS_PER_SEC == 1000
-    return ms;
-#else
-    return ((uint64_t)ms * OS_TICKS_PER_SEC) / 1000;
-#endif
-}
-
-uint32_t
-os_time_ticks_to_ms32(os_time_t ticks)
-{
-#if OS_TICKS_PER_SEC == 1000
-    return ticks;
-#else
-    return ((uint64_t)ticks * 1000) / OS_TICKS_PER_SEC;
-#endif
-}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services