summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--itypes.c15
-rw-r--r--itypes.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/itypes.c b/itypes.c
index 76de9013..a72444e8 100644
--- a/itypes.c
+++ b/itypes.c
@@ -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();
+ }
+}
diff --git a/itypes.h b/itypes.h
index 35ef9c92..497486c7 100644
--- a/itypes.h
+++ b/itypes.h
@@ -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);