[Ecls-list] Alpha/Sparc architectures broken

Alexander Sigbjorn Kjeldaas astor at fast.no
Mon Oct 27 08:25:06 UTC 2003


On Mon, Oct 27, 2003 at 04:49:47PM +0100, Juan Jose Garcia-Ripoll wrote:
> Dear all,
> 
> I have verified that ECL does not work on non-intel platforms. The reason is 
> the C code of the lisp interpreter (and maybe some other parts which I 
> haven't checked yet). GCC is producing weird results failing to compile 
> things like (macro-expanded code from src/c/intepreter.d)
> 	char *vector;
> 	...
> 	int n = *(((int16_t *)vector)++);
> 	...
> Well, actually it compiles it, but the variable "n" gets a trashed value. I 
> have tried several variations like
> 	int n = ((int16_t *)vector)[0]; vector += sizeof(int16_t);
> and some other splittings. All of them failed until I used
> 	int16_t n = ((int16_t *)vector)[0]; vector += sizeof(int16_t);
> I still must decide what to do.
> 

Non-intel platforms might signal a SIGBUS or similar on code like that
unless you can guarantee that vector is int16_t-aligned.

int n;
memcpy(&n, vector, sizeof(int16_t));
vector += sizeof(int16_t);

or

int n;
memcpy(&n, ((int16_t *)vector)++, sizeof(int16_t);

is legal.  On linux, it should be optimized to

n = *((int16_t *)vector)++

(look at /usr/include/bits/string*.h)

astor




More information about the ecl-devel mailing list