-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platform Abstraction Layer #208
base: master
Are you sure you want to change the base?
Conversation
@ncvicchi, thanks for the suggestion. There are some files that, perhaps because they are still empty, I did not fully understand. For example, "priv_pal_time.h" and "priv_pal_thread.h". If what we need is to provide an abstraction of time management, threads, etc., we had in mind to build small helper components, which would present a common interface (header) and an implementation for each platform. Greetings! |
5909139
to
22c281e
Compare
4ec30fa
to
23397ea
Compare
Here is an example of why I think a platform abstraction layer is way better than helpers:
We can avoid almost all #ifdef in source codes if we centralize them in a PAL. Helpers (IMHO) are useful to enclose several repetitive functionalities, not to avoid platform differences. A PAL seems to me a better way to keep tidier the code and simplifying debugging and testing. |
23397ea
to
946b787
Compare
NOTE: Currently the PAL proposed and described in this PR will be moved and restricted to the Inventory module only.
Platform Abstraction Layer (PAL)
The aim of this module is to provide a the tools necessary to independize wazuh agent's code from the platform it will be compile for.
Since we are currently using GNU C for Linux. AppleClang for MacOS and MSVC for Windows, this will be used to identify the correspoding platform during compile time.
Hierarchy
Usage
A commom public file named "pal.h" should be included in every file that will be platform dependant. No more includes should be necessary.
Thos definitions, prototypes, etc, provided by the PAL should be used in Wazuh agent's code, avoiding whenever possible the usage of pre-processor in higher level code.
If situations not considered in the PAL are found during development, it should be prioritized to extend the PAL than taking shortcuts as ad-hoc solutions, except if this option is no available for implementation reasons.