On Mon, Mar 30, 2020 at 9:41 AM Dmitry Kozlyuk <dmitry.kozl...@gmail.com> wrote:
>
> EAL common code uses file locking and truncation. Introduce
> OS-independent wrapeprs in order to support both POSIX and Windows:
>
> * eal_file_lock: lock or unlock an open file.
> * eal_file_truncate: enforce a given size for an open file.
>
> Wrappers follow POSIX semantics, but interface is not POSIX,
> so that it can be made more clean, e.g. by not mixing locking
> operation and behaviour on conflict.
>
> Signed-off-by: Dmitry Kozlyuk <dmitry.kozl...@gmail.com>
>
> WIP2
> ---
>  lib/librte_eal/common/eal_private.h | 45 ++++++++++++++++
>  lib/librte_eal/freebsd/eal/eal.c    | 40 ++++++++++++++
>  lib/librte_eal/linux/eal/eal.c      | 40 ++++++++++++++
>  lib/librte_eal/windows/eal/eal.c    | 83 +++++++++++++++++++++++++++++
>  4 files changed, 208 insertions(+)
>
> diff --git a/lib/librte_eal/common/eal_private.h 
> b/lib/librte_eal/common/eal_private.h
> index ddcfbe2e4..0130571e8 100644
> --- a/lib/librte_eal/common/eal_private.h
> +++ b/lib/librte_eal/common/eal_private.h
> @@ -443,4 +443,49 @@ rte_option_usage(void);
>  uint64_t
>  eal_get_baseaddr(void);
>
> +/** File locking operation. */
> +enum rte_flock_op {
> +       RTE_FLOCK_SHARED,    /**< Acquire a shared lock. */
> +       RTE_FLOCK_EXCLUSIVE, /**< Acquire an exclusive lock. */
> +       RTE_FLOCK_UNLOCK     /**< Release a previously taken lock. */
> +};
> +
> +/** Behavior on file locking conflict. */
> +enum rte_flock_mode {
> +       RTE_FLOCK_WAIT,  /**< Wait until the file gets unlocked to lock it. */
> +       RTE_FLOCK_RETURN /**< Return immediately if the file is locked. */
> +};
Avoid using RTE_ for internal symbols. IMO, EAL_FLOCK_* would be
enough for some something defined in eal_private.h.

Reply via email to