Re: [dpdk-dev] [PATCH v5 03/11] eal: introduce memory management wrappers
From: Thomas Monjalon <hidden>
Date: 2020-06-01 21:08:14
28/05/2020 13:26, Burakov, Anatoly:
On 25-May-20 1:37 AM, Dmitry Kozlyuk wrote:quoted
+/** + * Memory protection flags. + */ +enum rte_mem_prot { + RTE_PROT_READ = 1 << 0, /**< Read access. */ + RTE_PROT_WRITE = 1 << 1, /**< Write access. */ + RTE_PROT_EXECUTE = 1 << 2 /**< Code execution. */ +}; + +/** + * Additional flags for memory mapping. + */ +enum rte_map_flags { + /** Changes to the mapped memory are visible to other processes. */ + RTE_MAP_SHARED = 1 << 0, + /** Mapping is not backed by a regular file. */ + RTE_MAP_ANONYMOUS = 1 << 1, + /** Copy-on-write mapping, changes are invisible to other processes. */ + RTE_MAP_PRIVATE = 1 << 2, + /** + * Force mapping to the requested address. This flag should be used + * with caution, because to fulfill the request implementation + * may remove all other mappings in the requested region. However, + * it is not required to do so, thus mapping with this flag may fail. + */ + RTE_MAP_FORCE_ADDRESS = 1 << 3 +};I have no strong opinion on this, but it feels like the fact that these are enums is a relic from the times where you used enum everywhere :) i have a feeling that DPDK codebase prefers #define's for this usage, while what you have here is more of a C++ thing.
The benefit of using an enum is to explicitly name the type of the variables, serving documentation purpose. +1 for the enums