Skip to content

Commit

Permalink
feat (UV): support env variables
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloutsakis committed Nov 19, 2023
1 parent e48c70c commit 63622b3
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/uv/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ target_link_libraries(binuv

target_compile_options(binuv
PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-std=c++17>
PRIVATE $<$<COMPILE_LANGUAGE:C>:-std=c17>
)
45 changes: 37 additions & 8 deletions src/uv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,67 @@
/**
* @file main.c
* @author Stelios Kaloutsakis (kaloutsakis@gmail.com)
* @brief
* @brief
* @version 0.1.0
* @date 2023-05-05
*
*
* @copyright Copyright (c) 2023
*
*
*/

/**
* @brief Standard C Header Files
* @brief Standard C Header Files
*/
#include <errno.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/**
* @brief Platform Specific Header Files
* @brief Platform Specific Header Files
*/
#include <unistd.h>

/**
* @brief External Header Files
* @brief External Header Files
*/
#include <uv.h>

#include "ILogManager.h"

#define WRAP(func) \
do \
{ \
uv_log_manager_info("Entering %s", #func); \
func; \
uv_log_manager_info("Exiting %s", #func); \
} while (false)

#define RETURN(status) \
return uv_log_manager_goodbye(), (status)

#define RETURN2(level, status, format, ...) \
return uv_log_manager_ ## level(format, ##__VA_ARGS__), (status)
return uv_log_manager_##level(format, ##__VA_ARGS__), (status)

inline const char *getenv_safe(const char *key)
{
const char *value = getenv("NCORES");

void wait_for_a_while(uv_idle_t* handle) {
return (NULL == value ? "UNDEFINED" : value);
}

inline int do_nothing(int a, int b)
{
(void)a;
(void)b;

return (a + b);
}

void wait_for_a_while(uv_idle_t *handle)
{
static uint64_t counter = 0;

if (!(counter % 100000))
Expand All @@ -48,7 +73,11 @@ void wait_for_a_while(uv_idle_t* handle) {

int main(int argc, const char *argv[])
{
int status;
WRAP((status = do_nothing(2, 3)));

uv_log_manager_welcome();
uv_log_manager_info("NCORES = %s", getenv_safe("NCORES"));

uv_idle_t idler;

Expand Down

0 comments on commit 63622b3

Please sign in to comment.