# HG changeset patch # User Josef 'Jeff' Sipek # Date 1608997422 18000 # Node ID 562d1c61194e882e82e335a458405eead9df1ac1 # Parent ccb955138113a2b0a0e78e9c8a7b58d8db39ca91 val: add INT_STATIC_INITIALIZER and STATIC_INT macros Signed-off-by: Josef 'Jeff' Sipek diff -r ccb955138113 -r 562d1c61194e include/jeffpc/val.h --- a/include/jeffpc/val.h Fri Oct 30 17:58:24 2020 -0400 +++ b/include/jeffpc/val.h Sat Dec 26 10:43:42 2020 -0500 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2018 Josef 'Jeff' Sipek + * Copyright (c) 2014-2020 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -376,6 +376,13 @@ #define SYM_STATIC_INITIALIZER(v) \ _STATIC_STR_INITIALIZER(VT_SYM, (v)) +#define INT_STATIC_INITIALIZER(v) \ + { \ + .type = VT_INT, \ + .static_struct = true, \ + .i = (v), \ + } + /* evaluates to a struct str *, so it can be used as a value */ #define STATIC_STR(s) \ ({ \ @@ -390,6 +397,13 @@ &_s; \ }) +/* evaluates to a struct val *, so it can be used as a value */ +#define STATIC_INT(v) \ + ({ \ + static struct val _v = INT_STATIC_INITIALIZER(v); \ + &_v; \ + }) + /* * Allocation wrappers. These call the identically named functions and * assert that there was no error.