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

Re: [Minios-devel] [UNIKRAFT PATCH v3 5/7] include/essentials: Provide __constructor macro





On 23.05.2018 15:00, Sharan Santhanam wrote:
Hello Simon,


Please find my comments in line.


On 05/22/2018 02:20 PM, Simon Kuenzer wrote:
Provide a constructor attribure macro for marking a
function symbol as constructor. The linker/compiler
is going to populate a function pointer of it to
the init_array section of the binary.

Signed-off-by: Simon Kuenzer<simon.kuenzer@xxxxxxxxx>
---
  include/uk/essentials.h | 13 +++++++++++++
  1 file changed, 13 insertions(+)

diff --git a/include/uk/essentials.h b/include/uk/essentials.h
index f6cc6ea..3d1b705 100644
--- a/include/uk/essentials.h
+++ b/include/uk/essentials.h
@@ -73,6 +73,19 @@ extern "C" {
  #ifndef __align
  #define __align(bytes)         __attribute__((aligned(bytes)))
  #endif
+
+/**
+ * Mark a function as constructor
+ * The compiler/linker will populate a function pointer
+ * (sorted by priority) to the init_array section
+ *
+ * @param lvl
+ *   Priority level (101 (earliest)...onwards (latest))
+ */
+#ifndef __constructor
+#define __constructor(lvl) __attribute__ ((constructor (lvl)))
+#endif
The lvl parameter is an optional parameter. We are forcing the user to use constructor with priority as the default case. Is there any reason behind it?

I wanted to expose the richer functionality with the macro and making the programmer aware that there is a order in which constructors are called. The user can still use `__attribute__((constructor))` but this one would have lower priority than the ones with a level parameter.

I am fine if you say a macro for both should be there. Is this the case?

+
  #else
  /* TO BE DEFINED */
  #endif /* __GNUC__ */

Thanks & Regards
Sharan Santhanam

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