Browse Source

macro 'NNMARK' (mark for non-number values using the NaN trick)

pull/9/head
Roberto Ierusalimschy 14 years ago
parent
commit
35391d9b1a
  1. 10
      lobject.h

10
lobject.h

@ -1,5 +1,5 @@
/*
** $Id: lobject.h,v 2.57 2011/06/02 19:31:40 roberto Exp roberto $
** $Id: lobject.h,v 2.58 2011/06/07 19:02:33 roberto Exp roberto $
** Type definitions for Lua objects
** See Copyright Notice in lua.h
*/
@ -266,10 +266,12 @@ typedef struct lua_TValue TValue;
/*
** numbers are represented in the 'd_' field. All other values have the
** value (0x7ff70000 | tag) in 'tt_'. A number with such pattern would be
** value (NNMARK | tag) in 'tt_'. A number with such pattern would be
** a "signaled NaN", which is never generated by regular operations by
** the CPU (nor by 'strtod')
*/
#define NNMARK 0x7FF7A500
#undef TValuefields
#define TValuefields \
union { struct { Value v_; int tt_; } i; double d_; } u
@ -279,9 +281,9 @@ typedef struct lua_TValue TValue;
/* basic check to distinguish numbers from non-numbers */
#undef ttisnumber
#define ttisnumber(o) (((o)->u.i.tt_ & 0x7fff0000) != 0x7ff70000)
#define ttisnumber(o) (((o)->u.i.tt_ & 0x7fffff00) != NNMARK)
#define tag2tt(t) (0x7ff70000 | (t))
#define tag2tt(t) (NNMARK | (t))
#undef NILCONSTANT
#define NILCONSTANT {{{NULL}, tag2tt(LUA_TNIL)}}

Loading…
Cancel
Save