updates from changes in AoC 2022

This commit is contained in:
2023-06-20 21:27:49 +02:00
parent 7d98ab73a1
commit 128ea64816
3 changed files with 33 additions and 0 deletions

View File

@@ -44,11 +44,30 @@ typedef uint8_t u8;
/* convenience types /* convenience types
*/ */
typedef long long int llong;
typedef unsigned long long int ullong;
typedef unsigned long int ulong; typedef unsigned long int ulong;
typedef unsigned int uint; typedef unsigned int uint;
typedef unsigned short ushort; typedef unsigned short ushort;
typedef unsigned char uchar; typedef unsigned char uchar;
/* define common types sizes
*/
#define BITS_PER_CHAR 8
#ifndef BITS_PER_SHORT
#define BITS_PER_SHORT (BITS_PER_CHAR * sizeof (short))
#endif
#ifndef BITS_PER_INT
#define BITS_PER_INT (BITS_PER_CHAR * sizeof (int))
#endif
#ifndef BITS_PER_LONG
#define BITS_PER_LONG (BITS_PER_CHAR * sizeof (long))
#endif
#ifndef BITS_PER_LLONG
#define BITS_PER_LLONG (BITS_PER_CHAR * sizeof (long long))
#endif
/* count set bits: 10101000 -> 3 /* count set bits: 10101000 -> 3
* ^ ^ ^ * ^ ^ ^
*/ */

View File

@@ -18,6 +18,8 @@
#ifndef _BR_H #ifndef _BR_H
#define _BR_H #define _BR_H
#include "struct-group.h"
/* Indirect stringification. Doing two levels allows the parameter to be a /* Indirect stringification. Doing two levels allows the parameter to be a
* macro itself. For example, compile with -DFOO=bar, __stringify(FOO) * macro itself. For example, compile with -DFOO=bar, __stringify(FOO)
* converts to "bar". * converts to "bar".
@@ -31,6 +33,17 @@
#define __PASTE(x, y) ___PASTE(x, y) #define __PASTE(x, y) ___PASTE(x, y)
#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__) #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
/* unused/used parameters/functions
* https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute
* https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-unused-type-attribute
* https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute
* https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#index-unused-label-attribute
* https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-used-function-attribute
* https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute
*/
#define __unused __attribute__((__unused__))
#define __used __attribute__((__used__))
/* see https://lkml.org/lkml/2018/3/20/845 for explanation of this monster /* see https://lkml.org/lkml/2018/3/20/845 for explanation of this monster
*/ */
#define __is_constexpr(x) \ #define __is_constexpr(x) \

View File

@@ -25,6 +25,7 @@
#ifdef DEBUG_DEBUG #ifdef DEBUG_DEBUG
void debug_init(u32 level); void debug_init(u32 level);
void debug_level_set(u32 level); void debug_level_set(u32 level);
u32 debug_level_get(void);
void _printf debug(u32 level, bool timestamp, void _printf debug(u32 level, bool timestamp,
u32 indent, const char *src, u32 indent, const char *src,
u32 line, const char *, ...); u32 line, const char *, ...);