Skip to content

Proposal: drop configuration flags for types defined in C99

Currently we detect whether types defined in C99 are available in the compiler and hide them behind ifdef:

  • {u}int{8,16,32,64}_t
  • long long int
  • unsigned long long int

Moreover we could use intptr_t and uintptr_t to hold cl_fixnum and cl_index unambiguously without crude tests in configure.

Motivation:

these types are almost certainly defined by c89 compilers in use anyway, while we already mandate c99 standard. We maintain separate define branches for long long conversions that could be simplified. Moreover I want to add support for types intmax_t and uintmax_t and that should solve a few kludges (most notably casting off_t to and from lisp), and its implementation could be used as an ultimate fallback for all C integer types. Maintaining that behind ifdefs would be rather tedious, i.e

#if defined(ecl_ulong_long_t)
# if defined(ecl_uint32_t) && ECL_LONG_LONG_BITS == 32
# else
#  if defined(ecl_uint64_t) && ECL_LONG_LONG_BITS == 64
#  else
#  endif
# else
#  if defined(ecl_max_t)
#  else
# endif
#endif

becomes

#if ECL_LONG_BITS == 32
  int32_t_ops
#elif ECL_LONG_BITS == 64
  int64_t_ops
#else 
  intmax_t_ops
#endif

After that I want to introduce bignum_maxint implementation of bignums that is similar in spirit to big_ll, but handling correctly overflows (namely signaling a storage-condition) as a type in range [-UINTMAX_MAX-1; UINTMAX_MAX], that is capable of representing whole range of C integers. This alternative (non-default) implementation is meant for future experiments with minimized ecl builds.

Cost: deprecated compilers may stop compiling ECL Gain: simpler code that is easier to modify, easier cross-compilation (no need to specify some flags)

Edited by Daniel Kochmański