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

Re: [Minios-devel] [UNIKRAFT PATCH 4/9] include: Introduce <uk/prio.h>


  • To: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>, "minios-devel@xxxxxxxxxxxxx" <minios-devel@xxxxxxxxxxxxx>
  • From: Vlad-Andrei BĂDOIU (78692) <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>
  • Date: Thu, 30 Jan 2020 17:06:44 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=stud.acs.upb.ro; dmarc=pass action=none header.from=stud.acs.upb.ro; dkim=pass header.d=stud.acs.upb.ro; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=5Z4NRhW+4x0b3+sRdI1MuriaeWP6r/GIzPIqAb/UdFk=; b=FNuG8EfAL506syRi3Sbv6N0XClVry2mB/qQj+DfD0soRU1lf7kC1IumKVfswiYD3s1nXhVJwubg2TRHyl+iYA8dvIwg4JHj1gShaLxDAHV3bpS6zBM+P6eMtA6fjmN81r0sOzYGyNMj40KZzYrk6DkM0a7KoSr+UKh+rQbJGha+Dk+yc8gwYrYPh1KQ9eNyzlFfCpfFDsPvsGynMQwL2dWfCNXdMFoTXvAdbTUDup8tVZBzJuRAqkajqJXO/AOh0aESOGwLSKXYQPfX1JUW208ohzwm5wOOmFh+IOK0aXGQnFgwOjJ091UEhrzP55cf22ArbD6ylp6lw9BzQyh+CiQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eBiPC2gnsP4TcNm5YhCJ265VHF+RGqjweIfPK4fCRK+xtpVUpN1qiw3J7Tp+s2s70QgR1asaCJ2zNe8zSe+maQCoIJpApP1hmFiInIh0Yrx/Lym4vB0TvqDz3THtWnK8UBIU/sP2tq81lLquUpJpfVXSKgSfochZDRGl4DfBIbEt+kY/ii+eOHel7+ZaKWhvXHPvQXiJBM8dC2SZmx51n7gh20VSvMOftR4d98+62APbodghqSrUm9b60ebMCjbKBNekmQ733dLENmaiCKGcfFZ83zpp+fbyxdn1zOp4pGLIQAnONnaDPa0sJz/PfQnI4N+7xzrT81OB1Acxe+PvUA==
  • Authentication-results: spf=none (sender IP is ) smtp.mailfrom=vlad_andrei.badoiu@xxxxxxxxxxxxxxx;
  • Cc: Felipe Huici <felipe.huici@xxxxxxxxx>
  • Delivery-date: Thu, 30 Jan 2020 17:06:49 +0000
  • List-id: Mini-os development list <minios-devel.lists.xenproject.org>
  • Thread-index: AQHV1u38n4aE3OpbiUCFJLjLLd4jN6gDcW0A
  • Thread-topic: [UNIKRAFT PATCH 4/9] include: Introduce <uk/prio.h>

Hey Simon, this patch looks all right.

Reviewed-by: Vlad-Andrei Badoiu <vlad_andrei.badoiu@xxxxxxxxxxxxxxx>

On 29.01.2020 23:48, Simon Kuenzer wrote:
> This patch introduces <uk/prio.h>, helper macros for computing
> priority levels with the pre-processor.
> The macros can be used for Unikraft constructors and Unikraft init
> function priorities. Their intended use is to define initialization
> dependencies. Because the Constrcutor and Init function definitions are
> based on macros, standard C arithmetic operations do not work.
>
> Signed-off-by: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> ---
>   include/uk/ctors.h |  4 ++-
>   include/uk/init.h  | 14 ++++----
>   include/uk/prio.h  | 82 ++++++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 93 insertions(+), 7 deletions(-)
>   create mode 100644 include/uk/prio.h
>
> diff --git a/include/uk/ctors.h b/include/uk/ctors.h
> index d8a1c838..db98b664 100644
> --- a/include/uk/ctors.h
> +++ b/include/uk/ctors.h
> @@ -38,6 +38,7 @@
>   #define __UK_CTORS_H__
>   
>   #include <uk/essentials.h>
> +#include <uk/prio.h>
>   
>   #ifdef __cplusplus
>   extern "C" {
> @@ -64,6 +65,7 @@ extern const uk_ctor_func_t uk_ctortab_end;
>    *   Constructor function to be called
>    * @param prio
>    *   Priority level (0 (earliest) to 9 (latest))
> + *   Use the UK_PRIO_AFTER() helper macro for computing priority 
> dependencies.
>    *   Note: Any other value for level will be ignored
>    */
>   #define __UK_CTORTAB(fn, libname, prio)                     \
> @@ -80,7 +82,7 @@ extern const uk_ctor_func_t uk_ctortab_end;
>   /**
>    * Similar interface without priority.
>    */
> -#define UK_CTOR(fn) UK_CTOR_PRIO(fn, 9)
> +#define UK_CTOR(fn) UK_CTOR_PRIO(fn, UK_PRIO_LATEST)
>   
>   /* DELETEME: Compatibility wrapper for existing code, to be removed! */
>   #define UK_CTOR_FUNC(lvl, ctorf) \
> diff --git a/include/uk/init.h b/include/uk/init.h
> index 149b4926..1f26c504 100644
> --- a/include/uk/init.h
> +++ b/include/uk/init.h
> @@ -36,6 +36,7 @@
>   
>   #include <uk/config.h>
>   #include <uk/essentials.h>
> +#include <uk/prio.h>
>   
>   #ifdef __cplusplus
>   extern "C" {
> @@ -53,6 +54,7 @@ typedef int (*uk_init_func_t)(void);
>    *   Initialization class (1 (earliest) to 6 (latest))
>    * @param prio
>    *   Priority level (0 (earliest) to 9 (latest)), must be a constant.
> + *   Use the UK_PRIO_AFTER() helper macro for computing priority 
> dependencies.
>    *   Note: Any other value for level will be ignored
>    */
>   #define __UK_INITTAB(libname, fn, base, prio)                               
> \
> @@ -104,12 +106,12 @@ typedef int (*uk_init_func_t)(void);
>   /**
>    * Similar interface without priority.
>    */
> -#define uk_early_initcall(fn)     uk_early_initcall_prio(fn, 9)
> -#define uk_plat_initcall(fn)      uk_plat_initcall_prio(fn, 9)
> -#define uk_lib_initcall(fn)       uk_lib_initcall_prio(fn, 9)
> -#define uk_rootfs_initcall(fn)    uk_rootfs_initcall_prio(fn, 9)
> -#define uk_sys_initcall(fn)       uk_sys_initcall_prio(fn, 9)
> -#define uk_late_initcall(fn)      uk_late_initcall_prio(fn, 9)
> +#define uk_early_initcall(fn)     uk_early_initcall_prio(fn, UK_PRIO_LATEST)
> +#define uk_plat_initcall(fn)      uk_plat_initcall_prio(fn, UK_PRIO_LATEST)
> +#define uk_lib_initcall(fn)       uk_lib_initcall_prio(fn, UK_PRIO_LATEST)
> +#define uk_rootfs_initcall(fn)    uk_rootfs_initcall_prio(fn, UK_PRIO_LATEST)
> +#define uk_sys_initcall(fn)       uk_sys_initcall_prio(fn, UK_PRIO_LATEST)
> +#define uk_late_initcall(fn)      uk_late_initcall_prio(fn, UK_PRIO_LATEST)
>   
>   extern const uk_init_func_t uk_inittab_start[];
>   extern const uk_init_func_t uk_inittab_end;
> diff --git a/include/uk/prio.h b/include/uk/prio.h
> new file mode 100644
> index 00000000..c49b784f
> --- /dev/null
> +++ b/include/uk/prio.h
> @@ -0,0 +1,82 @@
> +/* SPDX-License-Identifier: BSD-3-Clause */
> +/*
> + * Authors: Simon Kuenzer <simon.kuenzer@xxxxxxxxx>
> + *
> + *
> + * Copyright (c) 2020, 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 __UK_PRIO_H__
> +#define __UK_PRIO_H__
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +/**
> + * Computes the priority level that has one lower priority than
> + * the given priority level. This macro can be used to state
> + * initialization dependencies. It is intended to be used for
> + * declaring macro constants.
> + * NOTE: This macro should only be used for Unikraft constructors
> + * (UK_CTOR_PRIO(), UK_CTOR()) and Unikraft init table entries.
> + *
> + * @param x
> + *  Given Unikraft priority level
> + * @return
> + *  Priority level that has one priority less than x
> + */
> +#define __UK_PRIO_AFTER_0 1
> +#define __UK_PRIO_AFTER_1 2
> +#define __UK_PRIO_AFTER_2 3
> +#define __UK_PRIO_AFTER_3 4
> +#define __UK_PRIO_AFTER_4 5
> +#define __UK_PRIO_AFTER_5 6
> +#define __UK_PRIO_AFTER_6 7
> +#define __UK_PRIO_AFTER_7 8
> +#define __UK_PRIO_AFTER_8 9
> +#define __UK_PRIO_AFTER_9 __UK_PRIO_OUT_OF_BOUNDS
> +#define __UK_PRIO_AFTER(x) __UK_PRIO_AFTER_##x
> +#define UK_PRIO_AFTER(x)   __UK_PRIO_AFTER(x)
> +
> +#define UK_PRIO_EARLIEST 0
> +#define UK_PRIO_LATEST   9
> +
> +/* Stop compilation if priority is getting out of bounds */
> +#ifdef __GNUC__
> +#pragma GCC poison __UK_PRIO_OUT_OF_BOUNDS
> +#else
> +#error Out of bounds pragma not defined
> +#endif
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* __UK_PRIO_H__ */
_______________________________________________
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®.