diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-08-26 07:24:44 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-08-26 07:24:44 -0700 |
commit | 821144757386da5178193874a2df7feaf940f1a8 (patch) | |
tree | 2545916a6f9e289a7683bb59786d6996e8688fa4 | |
parent | 00ce6b18a953b13954a5cad6a54bf4270c9ac275 (diff) | |
download | txr-821144757386da5178193874a2df7feaf940f1a8.tar.gz txr-821144757386da5178193874a2df7feaf940f1a8.tar.bz2 txr-821144757386da5178193874a2df7feaf940f1a8.zip |
itypes: provide a c_size function for size_t.
* itypes.[ch] (c_size): New function.
-rw-r--r-- | itypes.c | 15 | ||||
-rw-r--r-- | itypes.h | 2 |
2 files changed, 17 insertions, 0 deletions
@@ -29,6 +29,7 @@ #include <stddef.h> #include <wchar.h> #include <signal.h> +#include <stdlib.h> #include "config.h" #include "lib.h" #include "signal.h" @@ -262,3 +263,17 @@ unsigned long c_ulong(val n, val self) #error portme #endif } + +size_t c_size(val n, val self) +{ + switch (sizeof (size_t)) { + case sizeof (unsigned): + return c_uint(n, self); +#if SIZEOF_LONG != SIZEOF_INT + case sizeof (unsigned long): + return c_ulong(n, self); +#endif + default: + abort(); + } +} @@ -117,3 +117,5 @@ unsigned int c_uint(val, val self); long c_long(val, val self); unsigned long c_ulong(val, val self); + +size_t c_size(val, val self); |