ext/numo/narray/numo/template.h in numo-narray-0.9.1.4 vs ext/numo/narray/numo/template.h in numo-narray-0.9.1.5
- old
+ new
@@ -1,9 +1,9 @@
/*
template.h
- Numerical Array Extension for Ruby
- (C) Copyright 1999-2017 by Masahiro TANAKA
+ Ruby/Numo::NArray - Numerical Array class for Ruby
+ Copyright (C) 1999-2019 Masahiro TANAKA
*/
#ifndef TEMPLATE_H
#define TEMPLATE_H
#define INIT_COUNTER( lp, c ) \
@@ -110,13 +110,12 @@
#define STORE_BIT(adr,pos,val) \
{ \
size_t dig = (pos) / NB; \
int bit = (pos) % NB; \
((BIT_DIGIT*)(adr))[dig] = \
- (((BIT_DIGIT*)(adr))[dig] & ~(1u<<(bit))) | ((val)<<(bit)); \
+ (((BIT_DIGIT*)(adr))[dig] & ~(1u<<(bit))) | (((val)&1u)<<(bit)); \
}
-// val -> val&1 ??
#define STORE_BIT_STEP( adr, pos, step, idx, val )\
{ \
size_t dig; int bit; \
if (idx) { \
@@ -127,12 +126,11 @@
dig = (pos) / NB; \
bit = (pos) % NB; \
pos += step; \
} \
((BIT_DIGIT*)(adr))[dig] = \
- (((BIT_DIGIT*)(adr))[dig] & ~(1u<<(bit))) | ((val)<<(bit)); \
+ (((BIT_DIGIT*)(adr))[dig] & ~(1u<<(bit))) | (((val)&1u)<<(bit)); \
}
-// val -> val&1 ??
static inline int
is_aligned(const void *ptr, const size_t alignment)
{
return ((size_t)(ptr) & ((alignment)-1)) == 0;