Ylva And Malin
Macros | Typedefs | Enumerations | Functions
ym_core

ym_core is responsible for core functionality within the ym project. More...

Macros

#define YM_ASSERT(expr, ym_errc, fmt, ...)
 Simple custom assert message that support different functionality depending on build settings. More...
 
#define YM_INLINE
 YM_INLINE is a platform independent macro that forces a function to be inlined. More...
 
#define YM_NO_INLINE
 YM_NO_INLINE is a platform independent macro that forces a function to never be inlined. More...
 
#define YM_PURE
 YM_PURE is a platform independent macro informing the compiler that a function is pure. More...
 
#define YM_RESTRICT   restrict
 YM_RESTRICT is a platform independent macro wrapper for C99 restrict functionality. More...
 
#define YM_UNUSED
 YM_UNUSED is a platform independent macro informing the compiler that a function/variable is intentionally unused. More...
 
#define YM_NO_DISCARD
 YM_NO_DISCARD is a platform independent macro informing the compiler to warn if a return value from a function is discarded. More...
 
#define YM_LIKELY(x)   (x)
 YM_LIKELY is a platform independent macro informing the compiler that in a branch this is the path that is most likely. More...
 
#define YM_UNLIKELY(x)   (x)
 YM_UNLIKELY is a platform independent macro informing the compiler that in a branch this is the path that is least likely. More...
 
#define TERMINAL_PAUSE
 Prints the specified error to stderr and terminates the program. More...
 
#define YM_WARN(fmt, ...)   ym_log(stderr, "WARN", YM_COLOR_FG_YELLOW, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
 Prints the specified warning to stderr. More...
 
#define YM_DEBUG(fmt, ...)   ym_log(stdout, "DEBUG", YM_COLOR_FG_CYAN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
 Prints debug information to stdout. More...
 
#define YM_INFO(fmt, ...)   ym_log(stdout, "INFO", YM_COLOR_FG_WHITE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);
 Prints regular info to stdout. More...
 

Typedefs

typedef atomic_schar atomic_int8_t
 Atomic signed 8-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_short atomic_int16_t
 Atomic signed 16-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_int atomic_int32_t
 Atomic signed 32-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_long atomic_int64_t
 Atomic signed 64-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_uchar atomic_uint8_t
 Atomic unsigned 8-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_ushort atomic_uint16_t
 Atomic unsigned 16-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_uint atomic_uint32_t
 Atomic unsigned 32-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 
typedef atomic_ulong atomic_uint64_t
 Atomic unsigned 64-bit integer. Supplied because C11 does not mandate fixed width atomic support. More...
 

Enumerations

enum  ym_errc {
  ym_errc_success = (0 << 0),
  ym_errc_invalid_input = (1 << 0),
  ym_errc_bad_alloc = (1 << 1),
  ym_errc_mem_leak = (1 << 2),
  ym_errc_uninitialized = (1 << 3),
  ym_errc_system_error = (1 << 4),
  ym_errc_gl_error = (1 << 5),
  ym_errc_out_of_memory = (1 << 6),
  ym_errc_container_full = (1 << 7)
}
 Used to indicate erroneous behavior within a a function. More...
 

Functions

void ym_raise_error (ym_errc errc)
 Sets the new global error within the ym project. Only used for handling errors when testing. More...
 
ym_errc ym_clear_error ()
 Clears the global error and gets back its previous values. Only used for handling errors when testing. More...
 
const char * ym_errc_str (ym_errc errc)
 Translates an ym_errc to a human readable string. More...
 

Detailed Description

ym_core is responsible for core functionality within the ym project.

Core functionality includes asserts, logging error's, and attributes.

Macro Definition Documentation

#define TERMINAL_PAUSE

Prints the specified error to stderr and terminates the program.

This error is supposed to be used for unrecoverable errors.

Note
Can be called concurrently.
#define YM_ASSERT (   expr,
  ym_errc,
  fmt,
  ... 
)

Simple custom assert message that support different functionality depending on build settings.

The YM_ASSERT has four different settings based on build defines.

YM_ASSERT_TERMINATE
With this setting each failed assertion will lead to a termination of the program.
YM_ASSERT_REPORT
With this setting each failed assertion will be a warning that is printed to the window.
YM_ASSERT_ERRC
With this setting each failed assertion will result in raising a global error. This behavior should not be used to recover from as it is mainly used to avoid termination when testing.
No definitions
In the case where there are no definitions the assert will be empty, and the checks are optimized out.
#define YM_DEBUG (   fmt,
  ... 
)    ym_log(stdout, "DEBUG", YM_COLOR_FG_CYAN, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);

Prints debug information to stdout.

Note
Can be called concurrently.
#define YM_INFO (   fmt,
  ... 
)    ym_log(stdout, "INFO", YM_COLOR_FG_WHITE, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);

Prints regular info to stdout.

Note
Can be called concurrently.
#define YM_INLINE

YM_INLINE is a platform independent macro that forces a function to be inlined.

#define YM_LIKELY (   x)    (x)

YM_LIKELY is a platform independent macro informing the compiler that in a branch this is the path that is most likely.

#define YM_NO_DISCARD

YM_NO_DISCARD is a platform independent macro informing the compiler to warn if a return value from a function is discarded.

#define YM_NO_INLINE

YM_NO_INLINE is a platform independent macro that forces a function to never be inlined.

#define YM_PURE

YM_PURE is a platform independent macro informing the compiler that a function is pure.

#define YM_RESTRICT   restrict

YM_RESTRICT is a platform independent macro wrapper for C99 restrict functionality.

#define YM_UNLIKELY (   x)    (x)

YM_UNLIKELY is a platform independent macro informing the compiler that in a branch this is the path that is least likely.

#define YM_UNUSED

YM_UNUSED is a platform independent macro informing the compiler that a function/variable is intentionally unused.

#define YM_WARN (   fmt,
  ... 
)    ym_log(stderr, "WARN", YM_COLOR_FG_YELLOW, __FILE__, __func__, __LINE__, fmt, ##__VA_ARGS__);

Prints the specified warning to stderr.

Note
Can be called concurrently.

Typedef Documentation

Atomic signed 16-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic signed 32-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic signed 64-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic signed 8-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic unsigned 16-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic unsigned 32-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic unsigned 64-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Atomic unsigned 8-bit integer. Supplied because C11 does not mandate fixed width atomic support.

Enumeration Type Documentation

enum ym_errc

Used to indicate erroneous behavior within a a function.

This type is either returned from a function, or in some cases it is sent in as an out parameter.

Enumerator
ym_errc_success 

Indicates a successful operation.

ym_errc_invalid_input 

Indicates that one of the parameters supplied to the function was invalid.

ym_errc_bad_alloc 

Indicates that requested memory could not be allocated.

ym_errc_mem_leak 

Indicates that memory has been leaked from a region.

ym_errc_uninitialized 
ym_errc_system_error 
ym_errc_gl_error 
ym_errc_out_of_memory 
ym_errc_container_full 

Function Documentation

ym_errc ym_clear_error ( )

Clears the global error and gets back its previous values. Only used for handling errors when testing.

const char* ym_errc_str ( ym_errc  errc)

Translates an ym_errc to a human readable string.

Returns
Pointer to human readable string of errc.

Here is the caller graph for this function:

void ym_raise_error ( ym_errc  errc)

Sets the new global error within the ym project. Only used for handling errors when testing.

Parameters
errcThe error code to raise.