[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Minios-devel] [UNIKRAFT PATCH v3 4/4] include: Merge ctors.h with plat/ctors.h



Hey, overall this looks good. I am reformatting some comments while upstreaming in order to make checkpatch happy.

Thanks!

Reviewed-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>

On 29.08.19 18:19, Vlad-Andrei BĂDOIU (78692) wrote:
We merge the two headers because they share the same purpose. This patch
moves the content of include/uk/plat/ctors.h to include/uk/ctors.h,
adapts the naming from ukplat_ctor_* to uk_ctor_* and adapts the boot.c
files to work with the new changes.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
---
  include/uk/ctors.h      | 24 +++++++++++++
  include/uk/plat/ctors.h | 75 -----------------------------------------
  lib/ukboot/boot.c       |  7 ++--
  3 files changed, 27 insertions(+), 79 deletions(-)
  delete mode 100644 include/uk/plat/ctors.h

diff --git a/include/uk/ctors.h b/include/uk/ctors.h
index 8572cc4b..188f0aa2 100644
--- a/include/uk/ctors.h
+++ b/include/uk/ctors.h
@@ -44,6 +44,13 @@ extern "C" {
  #endif
typedef void (*uk_ctor_func_t)(void);
+
+/* Function pointer arrays of constructors; provided by
+ * the platform's linker script */
+extern const uk_ctor_func_t __preinit_array_start[];
+extern const uk_ctor_func_t __preinit_array_end;
+extern const uk_ctor_func_t __init_array_start[];
+extern const uk_ctor_func_t __init_array_end;
  extern const uk_ctor_func_t uk_ctortab[];
  extern const uk_ctor_func_t uk_ctortab_end;
@@ -62,6 +69,23 @@ extern const uk_ctor_func_t uk_ctortab_end;
                __uk_ctab ## lvl ## _ ## ctorf = (ctorf)
  #define UK_CTOR_FUNC(lvl, ctorf) __UK_CTOR_FUNC(lvl, ctorf)
+/**
+ * Helper macro for iterating over constructor pointer arrays
+ * Please note that the array may contain NULL pointer entries
+ *
+ * @param arr_start
+ *   Start address of pointer array (type: const ukplat_ctor_func_t const [])
+ * @param arr_end
+ *   End address of pointer array
+ * @param i
+ *   Iterator variable (integer) which should be used to access the
+ *   individual fields
+ */
+#define uk_ctor_foreach(arr_start, arr_end, i)                    \
+       for ((i)=0;                                                        \
+            &((arr_start)[i]) < &(arr_end); \
+            ++(i))
+
  #ifdef __cplusplus
  }
  #endif
diff --git a/include/uk/plat/ctors.h b/include/uk/plat/ctors.h
deleted file mode 100644
index a15d0b86..00000000
--- a/include/uk/plat/ctors.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause */
-/*
- * Authors: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
- *
- *
- * Copyright (c) 2018, NEC Europe Ltd., NEC Corporation. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the copyright holder nor the names of its
- *    contributors may be used to endorse or promote products derived from
- *    this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- *
- * THIS HEADER MAY NOT BE EXTRACTED OR MODIFIED IN ANY WAY.
- */
-
-#ifndef __UKPLAT_CTORS_H__
-#define __UKPLAT_CTORS_H__
-
-#include <uk/essentials.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef void (*ukplat_ctor_func_t)(void);
-
-/* Function pointer arrays of constructors; provided by
- * the platform's linker script */
-extern const ukplat_ctor_func_t __preinit_array_start[];
-extern const ukplat_ctor_func_t __preinit_array_end;
-extern const ukplat_ctor_func_t __init_array_start[];
-extern const ukplat_ctor_func_t __init_array_end;
-
-/**
- * Helper macro for iterating over constructor pointer arrays
- * Please note that the array may contain NULL pointer entries
- *
- * @param arr_start
- *   Start address of pointer array (type: const ukplat_ctor_func_t const [])
- * @param arr_end
- *   End address of pointer array
- * @param i
- *   Iterator variable (integer) which should be used to access the
- *   individual fields
- */
-#define ukplat_ctor_foreach(arr_start, arr_end, i)                        \
-       for ((i)=0;                                                        \
-            &((arr_start)[i]) < &(arr_end); \
-            ++(i))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __UKPLAT_CTORS_H__ */
diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
index 910cd61d..3b8d641f 100644
--- a/lib/ukboot/boot.c
+++ b/lib/ukboot/boot.c
@@ -49,7 +49,6 @@
  #endif
  #include <uk/arch/lcpu.h>
  #include <uk/plat/bootstrap.h>
-#include <uk/plat/ctors.h>
  #include <uk/plat/memory.h>
  #include <uk/plat/lcpu.h>
  #include <uk/plat/irq.h>
@@ -85,7 +84,7 @@ static void main_thread_func(void *arg)
uk_pr_info("Pre-init table at %p - %p\n",
                   __preinit_array_start, &__preinit_array_end);
-       ukplat_ctor_foreach(__preinit_array_start, __preinit_array_end, i) {
+       uk_ctor_foreach(__preinit_array_start, __preinit_array_end, i) {
                if (__preinit_array_start[i]) {
                        uk_pr_debug("Call pre-init constructor (entry %d (%p): 
%p())...\n",
                                    i, &__preinit_array_start[i],
@@ -96,7 +95,7 @@ static void main_thread_func(void *arg)
uk_pr_info("Constructor table at %p - %p\n",
                        __init_array_start, &__init_array_end);
-       ukplat_ctor_foreach(__init_array_start, __init_array_end, i) {
+       uk_ctor_foreach(__init_array_start, __init_array_end, i) {
                if (__init_array_start[i]) {
                        uk_pr_debug("Call constructor (entry %d (%p): 
%p())...\n",
                                        i, &__init_array_start[i],
@@ -182,7 +181,7 @@ void ukplat_entry(int argc, char *argv[])
  #endif
uk_pr_info("Unikraft constructors table at %p\n", uk_ctortab);
-       ukplat_ctor_foreach(uk_ctortab, uk_ctortab_end, i) {
+       uk_ctor_foreach(uk_ctortab, uk_ctortab_end, i) {
                uk_pr_debug("Call constructor %p\n", uk_ctortab[i]);
                uk_ctortab[i]();
        }


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.