about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2018-12-08 17:36:18 +0000
committerEric Wong <e@80x24.org>2018-12-11 01:43:09 +0000
commit9d02f36ecf5d5f9b2e14adf0cab7b8b3ddcb3099 (patch)
tree7daa5ea1998fe1d3a44fea79d9f1b82b1a90f4fd
parentc8b5c585bc7f1369070f1a9a00752db36fb31552 (diff)
downloadsleepy_penguin-9d02f36ecf5d5f9b2e14adf0cab7b8b3ddcb3099.tar.gz
4GB thread-local-storage should be enough for anyone, right?
-rw-r--r--ext/sleepy_penguin/init.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/ext/sleepy_penguin/init.c b/ext/sleepy_penguin/init.c
index 27aada4..76fa77a 100644
--- a/ext/sleepy_penguin/init.c
+++ b/ext/sleepy_penguin/init.c
@@ -101,15 +101,13 @@ static struct rb_sp_tlsbuf *alloc_tlsbuf(size_t size)
         size_t bytes = size + sizeof(struct rb_sp_tlsbuf);
         struct rb_sp_tlsbuf *buf;
         void *ptr;
-        int err = posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes);
 
-        if (err) {
-                errno = err;
+        if (size >= UINT32_MAX ||
+            posix_memalign(&ptr, rb_sp_l1_cache_line_size, bytes))
                 rb_memerror(); /* fatal */
-        }
 
         buf = ptr;
-        buf->capa = size;
+        buf->capa = (uint32_t)size;
 
         return buf;
 }