Skip to content

Commit

Permalink
vec8bit: turn some macros into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Feb 20, 2019
1 parent cdac8ae commit cc7a904
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "compiled.h"
#include "fibhash.h"
#include "hookintrprtr.h"
#include "vec8bit.h"

#ifdef HPCGAP
#include "hpc/guards.h"
Expand Down
56 changes: 37 additions & 19 deletions src/vec8bit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,36 @@
#ifndef GAP_VEC8BIT_H
#define GAP_VEC8BIT_H

#include "system.h"
#include "objects.h"
#include "opers.h"

/****************************************************************************
**
*F RewriteGF2Vec( <vec>, <q> ) . . .
** convert a GF(2) vector into a GF(2^k) vector in place
**
*/

void RewriteGF2Vec(Obj vec, UInt q);


/****************************************************************************
**
*F CopyVec8Bit( <list>, <mut> ) . . . . . . . . . . . . . . copying function
**
*/

Obj CopyVec8Bit(Obj list, UInt mut);


/****************************************************************************
**
*F IS_VEC8BIT_REP( <obj> ) . . . check that <obj> is in 8bit GFQ vector rep
*/
extern Obj IsVec8bitRep;

#define IS_VEC8BIT_REP(obj) \
(TNUM_OBJ(obj) == T_DATOBJ && True == DoFilter(IsVec8bitRep, obj))
EXPORT_INLINE int IS_VEC8BIT_REP(Obj obj)
{
return TNUM_OBJ(obj) == T_DATOBJ && True == DoFilter(IsVec8bitRep, obj);
}


/****************************************************************************
Expand All @@ -48,6 +51,7 @@ extern Obj IsVec8bitRep;
*/
void PlainVec8Bit(Obj list);


/****************************************************************************
**
*F ASS_VEC8BIT( <list>, <pos>, <elm> ) . . . . set an elm of an 8bit vector
Expand All @@ -63,12 +67,12 @@ void ASS_VEC8BIT(Obj list, Obj pos, Obj elm);
*/
Obj ZeroVec8Bit(UInt q, UInt len, UInt mut);


/****************************************************************************
**
** Low-level access, needed for meataxe64 package
**
*/

Obj GetFieldInfo8Bit(UInt q);


Expand All @@ -78,11 +82,12 @@ Obj GetFieldInfo8Bit(UInt q);
**
** 'LEN_VEC8BIT' returns the logical length of the 8bit GFQ vector <list>,
** as a C integer.
**
** Note that 'LEN_VEC8BIT' is a macro, so do not call it with arguments that
** have side effects.
*/
#define LEN_VEC8BIT(list) ((Int)(CONST_ADDR_OBJ(list)[1]))
EXPORT_INLINE UInt LEN_VEC8BIT(Obj list)
{
return (UInt)CONST_ADDR_OBJ(list)[1];
}


/****************************************************************************
**
Expand All @@ -92,30 +97,36 @@ Obj GetFieldInfo8Bit(UInt q);
** to the C integer <len>.
**
*/
#define SET_LEN_VEC8BIT(list, len) ((ADDR_OBJ(list)[1] = (Obj)(len)))
EXPORT_INLINE void SET_LEN_VEC8BIT(Obj list, UInt len)
{
ADDR_OBJ(list)[1] = (Obj)len;
}


/****************************************************************************
**
*F FIELD_VEC8BIT( <vec> ) . . . . . . . . . field size of an 8 bit GF vector
**
** 'FIELD_VEC8BIT' returns the field size Q of the 8bit GFQ vector <list>,
** as a C integer.
**
** Note that 'FIELD_VEC8BIT' is a macro, so do not call it with arguments
** that have side effects.
*/
EXPORT_INLINE UInt FIELD_VEC8BIT(Obj list)
{
return (UInt)CONST_ADDR_OBJ(list)[2];
}

#define FIELD_VEC8BIT(list) ((Int)(CONST_ADDR_OBJ(list)[2]))

/****************************************************************************
**
*F SET_FIELD_VEC8BIT( <vec>, <q> ) . . set field size of an 8 bit GF vector
**
** 'SET_FIELD_VEC8BIT' sets the field size of the 8bit GFQ vector <vec>,
** to the C integer <q>.
**
*/
#define SET_FIELD_VEC8BIT(list, q) ((ADDR_OBJ(list)[2] = (Obj)(q)))
EXPORT_INLINE void SET_FIELD_VEC8BIT(Obj list, UInt q)
{
ADDR_OBJ(list)[2] = (Obj)q;
}


/****************************************************************************
Expand All @@ -124,8 +135,15 @@ Obj GetFieldInfo8Bit(UInt q);
**
** returns a pointer to the start of the data of the 8bit GFQ vector
*/
#define BYTES_VEC8BIT(list) ((UInt1 *)(ADDR_OBJ(list) + 3))
#define CONST_BYTES_VEC8BIT(list) ((const UInt1 *)(CONST_ADDR_OBJ(list) + 3))
EXPORT_INLINE UInt1 * BYTES_VEC8BIT(Obj list)
{
return (UInt1 *)(ADDR_OBJ(list) + 3);
}

EXPORT_INLINE const UInt1 * CONST_BYTES_VEC8BIT(Obj list)
{
return (const UInt1 *)(CONST_ADDR_OBJ(list) + 3);
}


/****************************************************************************
Expand Down

0 comments on commit cc7a904

Please sign in to comment.