Skip to content

Commit

Permalink
kernel: define SIZEOF_VOID_P in header, not via autoconf
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Oct 17, 2021
1 parent 0eb851e commit 34d7bb1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
14 changes: 14 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@

#include "debug.h"

// check if we are on a 64 or 32 bit machine; in the former
// case, define SYS_IS_64_BIT.
// also define SIZEOF_VOID_P for backwards compatibility with some
// GAP packages that expect it
#if INTPTR_MAX == INT64_MAX
#define SYS_IS_64_BIT 1
#define SIZEOF_VOID_P 8
#elif INTPTR_MAX == INT32_MAX
#undef SYS_IS_64_BIT
#define SIZEOF_VOID_P 4
#else
#error Unknown pointer size or missing size macros!
#endif

// check that the pointer size detected by configure matches that of the
// current compiler; this helps prevent kernel extensions from being
// compiled with the wrong ABI
Expand Down
5 changes: 3 additions & 2 deletions src/intobj.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ EXPORT_INLINE Obj prod_intobjs(Int l, Int r)
#else

#ifdef SYS_IS_64_BIT
typedef Int4 HalfInt;
#define HalfInt Int4
#else
typedef Int2 HalfInt;
#define HalfInt Int2
#endif

EXPORT_INLINE Obj prod_intobjs(Int l, Int r)
Expand All @@ -256,6 +256,7 @@ EXPORT_INLINE Obj prod_intobjs(Int l, Int r)

return (Obj)0;
}
#undef HalfInt
#endif

#define PROD_INTOBJS(o, l, r) ((o) = prod_intobjs((Int)(l), (Int)(r)))
Expand Down
8 changes: 0 additions & 8 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@
#include "common.h"


/* check if we are on a 64 bit machine */
#if SIZEOF_VOID_P == 8
# define SYS_IS_64_BIT 1
#elif !defined(SIZEOF_VOID_P)
# error Something is wrong with this GAP installation: SIZEOF_VOID_P not defined
#endif


/****************************************************************************
**
*S GAP_PATH_MAX . . . . . . . . . . . . size for buffers storing file paths
Expand Down

0 comments on commit 34d7bb1

Please sign in to comment.