diff options
Diffstat (limited to 'include/rune/util')
-rw-r--r-- | include/rune/util/list.h | 22 | ||||
-rw-r--r-- | include/rune/util/util.h | 31 |
2 files changed, 41 insertions, 12 deletions
diff --git a/include/rune/util/list.h b/include/rune/util/list.h index ed6db5e..556e085 100644 --- a/include/rune/util/list.h +++ b/include/rune/util/list.h @@ -24,12 +24,20 @@ #include <stddef.h> -RAPI struct list_head { - struct list_head *next; - struct list_head *prev; +/** + * Linux-kernel combatible linked list implementation + */ +struct list_head { + struct list_head *next; ///< Next list element + struct list_head *prev; ///< Previous list element }; -RAPI static inline void list_add(struct list_head *new, struct list_head *head) { +/** + * \brief Add element to the end of a list + * \param[in] new Pointer to struct list_head, part of another struct + * \param[in] head Start point of the list to be added to + */ +static inline void list_add(struct list_head *new, struct list_head *head) { struct list_head *temp = head; while (temp->next != NULL) temp = temp->next; @@ -39,7 +47,11 @@ RAPI static inline void list_add(struct list_head *new, struct list_head *head) new->next = NULL; } -RAPI static inline void list_del(struct list_head *item) { +/** + * \brief Remove element from a list + * \param[in] item Pointer to struct list_head, part of another struct + */ +static inline void list_del(struct list_head *item) { struct list_head *next = item->next; struct list_head *prev = item->prev; if (next != NULL) diff --git a/include/rune/util/util.h b/include/rune/util/util.h index dcf45e4..1ba6781 100644 --- a/include/rune/util/util.h +++ b/include/rune/util/util.h @@ -23,32 +23,49 @@ #define RUNE_UTIL_UTIL_H #include <assert.h> +#include <stddef.h> #include <stdint.h> +/// Use the compiler-specific version of static_assert #if defined(__clang__) || defined(__gcc__) #define STATIC_ASSERT _Static_assert #else #define STATIC_ASSERT static_assert #endif +/// GLFW requires this to enable dynamic linking on Windows +#if _WIN32 +#define GLFW_DLL 1 +#endif -#ifdef REXPORT - #ifdef _MSC_VER +/// Make API functions visible outside of the library +#ifdef RAPI_EXPORT + #ifdef _WIN32 #define RAPI __declspec(dllexport) #else #define RAPI __attribute__((visibility("default"))) #endif #else - #ifdef _MSC_VER - #define RAPI __declspec(dllexport) + #ifdef _WIN32 + #define RAPI __declspec(dllimport) #else #define RAPI #endif #endif -static inline uint32_t clamp(uint32_t value, float min, float max) { - const uint32_t ret = value < min ? min : value; - return ret > max ? max : ret; +/** + * \brief Clamps a value between two floating point values + * \param[in] x Value to be clamped + * \param[in] min Floor value + * \param[in] max Ceiling value + * \return One of min, max or x + */ +static inline float clamp(float x, float min, float max) { + if (x < min) + return min; + if (x > max) + return max; + return x; } #endif |