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

Re: [Minios-devel] [UNIKRAFT PATCH v2 3/3] lib, plat/*: Update the existing constructor calls



Hello Vlad,

This patch seems fine functionally. There are some formatting issue reported by checkpatch.

Reviewed-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>

Thanks & Regards
Sharan

On 4/4/19 11:02 PM, Vlad-Andrei BĂDOIU (78692) wrote:
From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>

This patch updates the constructor register from all
Unikraft internal libraries to use the UKPLAT_CTOR_FUNC
call.

Signed-off-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
---
  lib/ukbus/include/uk/bus.h               | 11 ++++++++---
  lib/ukswrand/mwc.c                       |  8 +++++---
  lib/vfscore/fd.c                         |  5 ++++-
  lib/vfscore/main.c                       |  5 ++++-
  plat/common/include/pci/pci_bus.h        |  9 +++++++--
  plat/drivers/include/virtio/virtio_bus.h | 21 ++++++++++++++-------
  plat/xen/include/xenbus/xenbus.h         | 17 +++++++++++------
  7 files changed, 53 insertions(+), 23 deletions(-)

diff --git a/lib/ukbus/include/uk/bus.h b/lib/ukbus/include/uk/bus.h
index 231c8d79..633636ae 100644
--- a/lib/ukbus/include/uk/bus.h
+++ b/lib/ukbus/include/uk/bus.h
@@ -38,7 +38,7 @@
  #include <stddef.h>
  #include <uk/list.h>
  #include <uk/alloc.h>
-#include <uk/plat/ctors.h>
+#include <uk/ctors.h>
#ifdef __cplusplus
  extern "C" {
@@ -116,12 +116,17 @@ static inline unsigned int uk_bus_probe_all(void)
#define _UK_BUS_REGFNNAME(x, y) x##y +#define _UK_BUS_REGISTER_CTOR(CTOR) \
+       UK_CTOR_FUNC(0, CTOR)
+
+
  #define _UK_BUS_REGISTER(libname, b)                          \
-       static void __constructor_prio(102)                     \
+       static void                                             \
        _UK_BUS_REGFNNAME(libname, _uk_bus_register)(void)      \
        {                                                       \
                _uk_bus_register((b));                          \
-       }
+       }                                                       \
+       _UK_BUS_REGISTER_CTOR(_UK_BUS_REGFNNAME(libname, _uk_bus_register))
#ifdef __cplusplus
  }
diff --git a/lib/ukswrand/mwc.c b/lib/ukswrand/mwc.c
index 127cbe39..199247d3 100644
--- a/lib/ukswrand/mwc.c
+++ b/lib/ukswrand/mwc.c
@@ -36,18 +36,18 @@
  #include <uk/swrand.h>
  #include <uk/print.h>
  #include <uk/assert.h>
-#include <uk/plat/ctors.h>
+#include <uk/ctors.h>
/* https://stackoverflow.com/questions/9492581/c-random-number-generation-pure-c-code-no-libraries-or-functions */
  #define PHI 0x9e3779b9
-#define UK_SWRAND_CTOR_PRIO    (200U)
+#define UK_SWRAND_CTOR_PRIO    (1)
struct uk_swrand uk_swrand_def; /*
   * Declare the constructor function to initialize the swrand
   */
-static void _uk_swrand_ctor(void) __constructor_prio(UK_SWRAND_CTOR_PRIO);
+static void _uk_swrand_ctor(void);
void uk_swrand_init_r(struct uk_swrand *r, __u32 seed)
  {
@@ -95,3 +95,5 @@ static void _uk_swrand_ctor(void)
        uk_pr_info("Initialize random number generator...\n");
        uk_swrand_init_r(&uk_swrand_def, CONFIG_LIBUKSWRAND_INITIALSEED);
  }
+
+UK_CTOR_FUNC(UK_SWRAND_CTOR_PRIO, _uk_swrand_ctor);
diff --git a/lib/vfscore/fd.c b/lib/vfscore/fd.c
index 111b0229..f8b24020 100644
--- a/lib/vfscore/fd.c
+++ b/lib/vfscore/fd.c
@@ -40,6 +40,7 @@
  #include <vfscore/file.h>
  #include <uk/plat/lcpu.h>
  #include <errno.h>
+#include <uk/ctors.h>
#define FDTABLE_MAX_FILES (sizeof(uint64_t) * 8) @@ -175,7 +176,7 @@ exit: /* TODO: move this constructor to main.c */
-__constructor static void fdtable_init(void)
+static void fdtable_init(void)
  {
        memset(&fdtable, 0, sizeof(fdtable));
@@ -183,3 +184,5 @@ __constructor static void fdtable_init(void)
        fdtable.bitmap = 7;
        init_stdio();
  }
+
+UK_CTOR_FUNC(1, fdtable_init);
diff --git a/lib/vfscore/main.c b/lib/vfscore/main.c
index 47471339..403e2915 100644
--- a/lib/vfscore/main.c
+++ b/lib/vfscore/main.c
@@ -47,6 +47,7 @@
  #include <vfscore/mount.h>
  #include <vfscore/fs.h>
  #include <uk/errptr.h>
+#include <uk/ctors.h>
#ifdef DEBUG_VFS
  int   vfs_debug = VFSDB_FLAGS;
@@ -2040,7 +2041,7 @@ int chroot(const char *path __unused)
  }
static struct task _main_task_impl;
-__constructor static void vfscore_init(void)
+static void vfscore_init(void)
  {
        memset(&_main_task_impl, 0, sizeof(_main_task_impl));
        strcpy(_main_task_impl.t_cwd, "/");
@@ -2049,3 +2050,5 @@ __constructor static void vfscore_init(void)
        vnode_init();
        lookup_init();
  }
+
+UK_CTOR_FUNC(1, vfscore_init);
diff --git a/plat/common/include/pci/pci_bus.h 
b/plat/common/include/pci/pci_bus.h
index 1362032b..c8dbddae 100644
--- a/plat/common/include/pci/pci_bus.h
+++ b/plat/common/include/pci/pci_bus.h
@@ -68,6 +68,7 @@
#include <uk/bus.h>
  #include <uk/alloc.h>
+#include <uk/ctors.h>
/**
   * A structure describing an ID for a PCI driver. Each driver provides a
@@ -159,12 +160,16 @@ struct pci_device {
#define _PCI_REGFNNAME(x, y) x##y +#define PCI_REGISTER_CTOR(CTOR) \
+               UK_CTOR_FUNC(1, CTOR)
+
  #define _PCI_REGISTER_DRIVER(libname, b)                              \
-       static void __constructor_prio(103)                             \
+       static void                                             \
        _PCI_REGFNNAME(libname, _pci_register_driver)(void)             \
        {                                                               \
                _pci_register_driver((b));                              \
-       }
+       }                                                               \
+       PCI_REGISTER_CTOR(_PCI_REGFNNAME(libname, _pci_register_driver))
/* Do not use this function directly: */
  void _pci_register_driver(struct pci_driver *drv);
diff --git a/plat/drivers/include/virtio/virtio_bus.h 
b/plat/drivers/include/virtio/virtio_bus.h
index f846840c..fed8b4a5 100644
--- a/plat/drivers/include/virtio/virtio_bus.h
+++ b/plat/drivers/include/virtio/virtio_bus.h
@@ -43,6 +43,7 @@
  #include <uk/alloc.h>
  #include <virtio/virtio_config.h>
  #include <virtio/virtqueue.h>
+#include <uk/ctors.h>
#ifdef __cplusplus
  extern "C" {
@@ -307,17 +308,23 @@ static inline void virtio_dev_drv_up(struct virtio_dev 
*vdev)
        virtio_dev_status_update(vdev, VIRTIO_CONFIG_STATUS_DRIVER_OK);
  }
-#define VIRTIO_BUS_REGISTER_DRIVER(b) \
+#define VIRTIO_BUS_REGISTER_DRIVER(b)  \
        _VIRTIO_BUS_REGISTER_DRIVER(__LIBNAME__, b)
#define _VIRTIO_BUS_REGFNAME(x, y) x##y -#define _VIRTIO_BUS_REGISTER_DRIVER(libname, b) \
-           static void __constructor_prio(104)                         \
-       _VIRTIO_BUS_REGFNAME(libname, _virtio_register_driver)(void)    \
-       {                                                               \
-               _virtio_bus_register_driver((b));                       \
-       }
+#define _VIRTIO_REGISTER_CTOR(CTOR)    \
+       UK_CTOR_FUNC(1, CTOR)
+
+#define _VIRTIO_BUS_REGISTER_DRIVER(libname, b)                                
        \
+       static void                                                             
        \
+       _VIRTIO_BUS_REGFNAME(libname, _virtio_register_driver)(void)            
        \
+       {                                                                       
\
+               _virtio_bus_register_driver((b));                               
        \
+       }                                                                       
        \
+       _VIRTIO_REGISTER_CTOR(                                  \
+               _VIRTIO_BUS_REGFNAME(                           \
+               libname, _virtio_register_driver))
#ifdef __cplusplus
diff --git a/plat/xen/include/xenbus/xenbus.h b/plat/xen/include/xenbus/xenbus.h
index 3d3b5408..b93611d7 100644
--- a/plat/xen/include/xenbus/xenbus.h
+++ b/plat/xen/include/xenbus/xenbus.h
@@ -41,6 +41,7 @@
  #include <uk/wait.h>
  #include <xen/xen.h>
  #include <xen/io/xenbus.h>
+#include <uk/ctors.h>
/*
@@ -75,12 +76,16 @@ UK_TAILQ_HEAD(xenbus_driver_list, struct xenbus_driver);
#define _XENBUS_REGFNNAME(x, y) x##y -#define _XENBUS_REGISTER_DRIVER(libname, b) \
-       static void __constructor_prio(104) \
-       _XENBUS_REGFNNAME(libname, _xenbus_register_driver)(void) \
-       { \
-               _xenbus_register_driver((b)); \
-       }
+#define _XENBUS_REGISTER_CTOR(CTOR)  \
+       UK_CTOR_FUNC(1, CTOR)
+
+#define _XENBUS_REGISTER_DRIVER(libname, b)                                    
        \
+       static void                                                             
        \
+       _XENBUS_REGFNNAME(libname, _xenbus_register_driver)(void)               
        \
+       {                                                                       
        \
+               _xenbus_register_driver((b));                                   
        \
+       }                                                                       
        \
+       _XENBUS_REGISTER_CTOR(_XENBUS_REGFNNAME(libname, 
_xenbus_register_driver))
/* Do not use this function directly: */
  void _xenbus_register_driver(struct xenbus_driver *drv);


_______________________________________________
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®.