mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-14 23:50:19 +02:00
objcode type is an enumeration, not flags
* libguile/objcodes.h (SCM_OBJCODE_TYPE_MMAP) (SCM_OBJCODE_TYPE_BYTEVECTOR, SCM_OBJCODE_TYPE_SLICE) (SCM_OBJCODE_TYPE_STATIC): Enumerate objcode types instead of expressing them as flags. (SCM_OBJCODE_TYPE): Type is held in bits 8-15. (SCM_OBJCODE_FLAGS): Flags are now shifted by 16 bits, not 8. (SCM_MAKE_OBJCODE_TAG): New helper. * libguile/continuations.c (STATIC_OBJCODE_TAG): * libguile/control.c (STATIC_OBJCODE_TAG): * libguile/foreign.c (STATIC_OBJCODE_TAG): * libguile/gsubr.c (STATIC_OBJCODE_TAG): * libguile/smob.c (STATIC_OBJCODE_TAG): * libguile/objcodes.c (make_objcode_by_mmap, scm_c_make_objcode_slice) (scm_bytecode_to_objcode): : Use SCM_MAKE_OBJCODE_TAG.
This commit is contained in:
parent
9805ffdaf7
commit
f9654187b1
7 changed files with 25 additions and 22 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1995,1996,1998,2000,2001,2004, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 1995,1996,1998,2000,2001,2004, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -89,7 +89,7 @@ static const type sym##__unaligned[]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STATIC_OBJCODE_TAG \
|
#define STATIC_OBJCODE_TAG \
|
||||||
SCM_PACK (scm_tc7_objcode | (SCM_F_OBJCODE_IS_STATIC << 8))
|
SCM_PACK (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_STATIC, 0))
|
||||||
|
|
||||||
#define SCM_STATIC_OBJCODE(sym) \
|
#define SCM_STATIC_OBJCODE(sym) \
|
||||||
SCM_DECLARE_STATIC_ALIGNED_ARRAY (scm_t_uint8, sym##__bytecode); \
|
SCM_DECLARE_STATIC_ALIGNED_ARRAY (scm_t_uint8, sym##__bytecode); \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -99,7 +99,7 @@ static const type sym##__unaligned[]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define STATIC_OBJCODE_TAG \
|
#define STATIC_OBJCODE_TAG \
|
||||||
SCM_PACK (scm_tc7_objcode | (SCM_F_OBJCODE_IS_STATIC << 8))
|
SCM_PACK (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_STATIC, 0))
|
||||||
|
|
||||||
#define SCM_STATIC_OBJCODE(sym) \
|
#define SCM_STATIC_OBJCODE(sym) \
|
||||||
SCM_DECLARE_STATIC_ALIGNED_ARRAY (scm_t_uint8, sym##__bytecode); \
|
SCM_DECLARE_STATIC_ALIGNED_ARRAY (scm_t_uint8, sym##__bytecode); \
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 2010, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -734,7 +734,7 @@ static const struct
|
||||||
(setq i (1+ i)))))
|
(setq i (1+ i)))))
|
||||||
*/
|
*/
|
||||||
#define STATIC_OBJCODE_TAG \
|
#define STATIC_OBJCODE_TAG \
|
||||||
SCM_PACK (scm_tc7_objcode | (SCM_F_OBJCODE_IS_STATIC << 8))
|
SCM_PACK (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_STATIC, 0))
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2006, 2008, 2009, 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 1995,1996,1997,1998,1999,2000,2001, 2006, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -313,7 +313,7 @@ static const struct
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define STATIC_OBJCODE_TAG \
|
#define STATIC_OBJCODE_TAG \
|
||||||
SCM_PACK (scm_tc7_objcode | (SCM_F_OBJCODE_IS_STATIC << 8))
|
SCM_PACK (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_STATIC, 0))
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
|
|
|
@ -98,7 +98,7 @@ make_objcode_by_mmap (int fd)
|
||||||
+ data->metalen)));
|
+ data->metalen)));
|
||||||
}
|
}
|
||||||
|
|
||||||
sret = scm_double_cell (scm_tc7_objcode | (SCM_F_OBJCODE_IS_MMAP<<8),
|
sret = scm_double_cell (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_MMAP, 0),
|
||||||
(scm_t_bits)(addr + strlen (SCM_OBJCODE_COOKIE)),
|
(scm_t_bits)(addr + strlen (SCM_OBJCODE_COOKIE)),
|
||||||
SCM_UNPACK (SCM_BOOL_F),
|
SCM_UNPACK (SCM_BOOL_F),
|
||||||
(scm_t_bits)fd);
|
(scm_t_bits)fd);
|
||||||
|
@ -139,7 +139,7 @@ scm_c_make_objcode_slice (SCM parent, const scm_t_uint8 *ptr)
|
||||||
assert (SCM_C_OBJCODE_BASE (data) + data->len + data->metalen
|
assert (SCM_C_OBJCODE_BASE (data) + data->len + data->metalen
|
||||||
<= parent_base + parent_data->len + parent_data->metalen);
|
<= parent_base + parent_data->len + parent_data->metalen);
|
||||||
|
|
||||||
return scm_double_cell (scm_tc7_objcode | (SCM_F_OBJCODE_IS_SLICE<<8),
|
return scm_double_cell (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_SLICE, 0),
|
||||||
(scm_t_bits)data, SCM_UNPACK (parent), 0);
|
(scm_t_bits)data, SCM_UNPACK (parent), 0);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
@ -198,7 +198,7 @@ SCM_DEFINE (scm_bytecode_to_objcode, "bytecode->objcode", 1, 0, 0,
|
||||||
|
|
||||||
/* foolishly, we assume that as long as bytecode is around, that c_bytecode
|
/* foolishly, we assume that as long as bytecode is around, that c_bytecode
|
||||||
will be of the same length; perhaps a bad assumption? */
|
will be of the same length; perhaps a bad assumption? */
|
||||||
return scm_double_cell (scm_tc7_objcode | (SCM_F_OBJCODE_IS_BYTEVECTOR<<8),
|
return scm_double_cell (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_BYTEVECTOR, 0),
|
||||||
(scm_t_bits)data, SCM_UNPACK (bytecode), 0);
|
(scm_t_bits)data, SCM_UNPACK (bytecode), 0);
|
||||||
}
|
}
|
||||||
#undef FUNC_NAME
|
#undef FUNC_NAME
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 2001, 2009, 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 2001, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -35,10 +35,10 @@ struct scm_objcode
|
||||||
#define SCM_C_OBJCODE_BASE(obj) \
|
#define SCM_C_OBJCODE_BASE(obj) \
|
||||||
((scm_t_uint8 *)(obj) + sizeof (struct scm_objcode))
|
((scm_t_uint8 *)(obj) + sizeof (struct scm_objcode))
|
||||||
|
|
||||||
#define SCM_F_OBJCODE_IS_MMAP (1<<0)
|
#define SCM_OBJCODE_TYPE_MMAP (0)
|
||||||
#define SCM_F_OBJCODE_IS_BYTEVECTOR (1<<1)
|
#define SCM_OBJCODE_TYPE_BYTEVECTOR (1)
|
||||||
#define SCM_F_OBJCODE_IS_SLICE (1<<2)
|
#define SCM_OBJCODE_TYPE_SLICE (2)
|
||||||
#define SCM_F_OBJCODE_IS_STATIC (1<<3)
|
#define SCM_OBJCODE_TYPE_STATIC (3)
|
||||||
|
|
||||||
#define SCM_OBJCODE_P(x) (SCM_NIMP (x) && SCM_TYP7 (x) == scm_tc7_objcode)
|
#define SCM_OBJCODE_P(x) (SCM_NIMP (x) && SCM_TYP7 (x) == scm_tc7_objcode)
|
||||||
#define SCM_OBJCODE_DATA(x) ((struct scm_objcode *) SCM_CELL_WORD_1 (x))
|
#define SCM_OBJCODE_DATA(x) ((struct scm_objcode *) SCM_CELL_WORD_1 (x))
|
||||||
|
@ -49,10 +49,13 @@ struct scm_objcode
|
||||||
#define SCM_OBJCODE_TOTAL_LEN(x) (SCM_OBJCODE_LEN (x) + SCM_OBJCODE_META_LEN (x))
|
#define SCM_OBJCODE_TOTAL_LEN(x) (SCM_OBJCODE_LEN (x) + SCM_OBJCODE_META_LEN (x))
|
||||||
#define SCM_OBJCODE_BASE(x) (SCM_C_OBJCODE_BASE (SCM_OBJCODE_DATA (x)))
|
#define SCM_OBJCODE_BASE(x) (SCM_C_OBJCODE_BASE (SCM_OBJCODE_DATA (x)))
|
||||||
|
|
||||||
#define SCM_OBJCODE_FLAGS(x) (SCM_CELL_WORD_0 (x) >> 8)
|
#define SCM_MAKE_OBJCODE_TAG(type, flags) (scm_tc7_objcode | (type << 8) | (flags << 16))
|
||||||
#define SCM_OBJCODE_IS_MMAP(x) (SCM_OBJCODE_FLAGS (x) & SCM_F_OBJCODE_IS_MMAP)
|
#define SCM_OBJCODE_TYPE(x) ((SCM_CELL_WORD_0 (x) >> 8) & 0xff)
|
||||||
#define SCM_OBJCODE_IS_BYTEVECTOR(x) (SCM_OBJCODE_FLAGS (x) & SCM_F_OBJCODE_IS_BYTEVECTOR)
|
#define SCM_OBJCODE_FLAGS(x) (SCM_CELL_WORD_0 (x) >> 16)
|
||||||
#define SCM_OBJCODE_IS_SLICE(x) (SCM_OBJCODE_FLAGS (x) & SCM_F_OBJCODE_IS_SLICE)
|
#define SCM_OBJCODE_IS_MMAP(x) (SCM_OBJCODE_TYPE (x) == SCM_OBJCODE_TYPE_MMAP)
|
||||||
|
#define SCM_OBJCODE_IS_BYTEVECTOR(x) (SCM_OBJCODE_TYPE (x) == SCM_OBJCODE_TYPE_BYTEVECTOR)
|
||||||
|
#define SCM_OBJCODE_IS_SLICE(x) (SCM_OBJCODE_TYPE (x) == SCM_OBJCODE_TYPE_SLICE)
|
||||||
|
#define SCM_OBJCODE_IS_STATIC(x) (SCM_OBJCODE_TYPE (x) == SCM_OBJCODE_TYPE_STATIC)
|
||||||
|
|
||||||
SCM scm_c_make_objcode_slice (SCM parent, const scm_t_uint8 *ptr);
|
SCM scm_c_make_objcode_slice (SCM parent, const scm_t_uint8 *ptr);
|
||||||
SCM_API SCM scm_load_objcode (SCM file);
|
SCM_API SCM scm_load_objcode (SCM file);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2004, 2006, 2009, 2010 Free Software Foundation, Inc.
|
/* Copyright (C) 1995,1996,1998,1999,2000,2001, 2003, 2004, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public License
|
* modify it under the terms of the GNU Lesser General Public License
|
||||||
|
@ -255,7 +255,7 @@ static const struct
|
||||||
#undef META
|
#undef META
|
||||||
|
|
||||||
#define STATIC_OBJCODE_TAG \
|
#define STATIC_OBJCODE_TAG \
|
||||||
SCM_PACK (scm_tc7_objcode | (SCM_F_OBJCODE_IS_STATIC << 8))
|
SCM_PACK (SCM_MAKE_OBJCODE_TAG (SCM_OBJCODE_TYPE_STATIC, 0))
|
||||||
|
|
||||||
static const struct
|
static const struct
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue