Skip to content
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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ncvicchi
Copy link
Member

@ncvicchi ncvicchi commented Oct 8, 2024

Related issue
#167

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

pal
 ├── README.md
 ├── CMakeLists.txt
 ├── include 
 │   ├── Linux
 │   │    ├── pal_file.h
 │   │    ├── pal_thread.h
 │   │    ├── pal_time.h
 │   │    └── pal.h
 │   ├── macos
 │   │    ├── pal_file.h
 │   │    ├── pal_thread.h
 │   │    ├── pal_time.h
 │   │    └── pal.h
 │   └── windows
 │        ├── pal_file.h
 │        ├── pal_thread.h
 │        ├── pal_time.h
 │        └── pal.h
 └── src
     ├── Linux
     │    ├── pal_file.c
     │    ├── pal_thread.c
     │    ├── pal_time.c
     │    └── pal.c
     ├── macos
     │    ├── pal_file.c
     │    ├── pal_thread.c
     │    ├── pal_time.c
     │    └── pal.c
     └── windows
          ├── pal_file.c
          ├── pal_thread.c
          ├── pal_time.c
          └── pal.c

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.

@ncvicchi ncvicchi self-assigned this Oct 9, 2024
@cborla cborla linked an issue Oct 9, 2024 that may be closed by this pull request
5 tasks
@vikman90
Copy link
Member

@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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Compilation for Inventory Module on Windows Using MSVC
2 participants