Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detecting 64bit systems #48

Merged
merged 1 commit into from
Oct 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix detecting 64bit systems
Checking for 64bit systems can be made portably by checking the value of
UINTPTR_MAX. Also, there are 64bit bigendian systems out there :)
  • Loading branch information
sthibaul committed Aug 26, 2020
commit e819629b3ff1afb8ea0a879c526203edc94d45c0
11 changes: 9 additions & 2 deletions include/cst_val.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include "cst_alloc.h"
#include "cst_val_defs.h"

#include <stdint.h>

/* Only CONS can be an even number */
#define CST_VAL_TYPE_CONS 0
#define CST_VAL_TYPE_INT 1
Expand All @@ -61,10 +63,15 @@ typedef struct cst_val_cons_struct {

typedef struct cst_val_atom_struct {
#ifdef WORDS_BIGENDIAN
#if UINTPTR_MAX > 0xfffffffful
int ref_count;
int type; /* order is here important */
#else
short ref_count;
short type; /* order is here important */
#endif
#else
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
int type; /* order is here important */
int ref_count;
#else
Expand All @@ -74,7 +81,7 @@ typedef struct cst_val_atom_struct {
#endif
union
{
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
double fval;
long long ival;
void *vval;
Expand Down
27 changes: 22 additions & 5 deletions include/cst_val_const.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@

#include "cst_val_defs.h"

#include <stdint.h>

/* There is built-in int to string conversions here for numbers */
/* up to 20, note if you make this bigger you have to hand change */
/* other things too */
Expand Down Expand Up @@ -191,18 +193,23 @@ extern const cst_val val_string_24;
/* unquestionably doing the wrong thing */
typedef struct cst_val_atom_struct_float {
#ifdef WORDS_BIGENDIAN
#if UINTPTR_MAX > 0xfffffffful
int ref_count;
int type; /* order is here important */
#else
short ref_count;
short type; /* order is here important */
#endif
#else
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
int type; /* order is here important */
int ref_count;
#else
short type; /* order is here important */
short ref_count;
#endif
#endif
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
double fval;
#else
float fval;
Expand All @@ -211,18 +218,23 @@ typedef struct cst_val_atom_struct_float {

typedef struct cst_val_atom_struct_int {
#ifdef WORDS_BIGENDIAN
#if UINTPTR_MAX > 0xfffffffful
int ref_count;
int type; /* order is here important (and unintuitive) */
#else
short ref_count;
short type; /* order is here important (and unintuitive) */
#endif
#else
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
int type; /* order is here important */
int ref_count;
#else
short type; /* order is here important */
short ref_count;
#endif
#endif
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
long long ival;
#else
int ival;
Expand All @@ -231,10 +243,15 @@ typedef struct cst_val_atom_struct_int {

typedef struct cst_val_atom_struct_void {
#ifdef WORDS_BIGENDIAN
#if UINTPTR_MAX > 0xfffffffful
int ref_count;
int type; /* order is here important */
#else
short ref_count;
short type; /* order is here important */
#endif
#else
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
int type; /* order is here important */
int ref_count;
#else
Expand Down
2 changes: 1 addition & 1 deletion src/wavesynth/cst_units.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ void add_residual_pulse(int targ_size, unsigned char *targ_residual,
int unit_size, const unsigned char *unit_residual)
{
int i,m;
#if (defined(__x86_64__) || defined(_M_X64))
#if UINTPTR_MAX > 0xfffffffful
long long p;
/* Unit residual isn't a pointer its a number, the power for the
the sts, yes this is hackily casting the address to a number */
Expand Down