lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On , you wrote:

>MIME-Version: 1.0
>Content-Type: text/plain; charset="us-ascii"
>Content-ID: <13810.1053350577.1@inf.puc-rio.br>
>Date: Mon, 19 May 2003 10:22:57 -0300
>From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
>Subject: Re: Lua on 16-bit systems 
>X-BeenThere: lua@bazar2.conectiva.com.br
>X-Mailman-Version: 2.1.1
>Precedence: list
>Reply-To: Lua list <lua@bazar2.conectiva.com.br>
>List-Id: Lua list <lua.bazar2.conectiva.com.br>
>List-Unsubscribe: <http://bazar2.conectiva.com.br/mailman/listinfo/lua>,
>	<mailto:lua-request@bazar2.conectiva.com.br?subject=unsubscribe>
>List-Archive: <http://bazar2.conectiva.com.br/mailman/private/lua>
>List-Post: <mailto:lua@bazar2.conectiva.com.br>
>List-Help: <mailto:lua-request@bazar2.conectiva.com.br?subject=help>
>List-Subscribe: <http://bazar2.conectiva.com.br/mailman/listinfo/lua>,
>	<mailto:lua-request@bazar2.conectiva.com.br?subject=subscribe>
>Sender: lua-bounces@bazar2.conectiva.com.br
>Errors-To: lua-bounces@bazar2.conectiva.com.br
>
>We often test Lua on 16-bit machines, and it runs without problems.
>Of course there can be problems on some platforms, but that is also
>true for 32-bit machines. Particularly, nowhere in the code we assume
>that "int" is a 32-bit value, or that a pointer fits in any particular
>integer type. We always use longs when we need 32 bits.
>

I am considering using lua on a PS2 (playstation 2), 
where long's are 64 bits. Will this be a problem ?

For clarification on the PS2:
	sizeof(int) 	= 4
	sizeof(long)	= 8
	sizeof(long int)	= 8
	sizeof(long long)	= 8
	sizeof(__int128)	= 16

My own personal recommendation, is to use derived types instead of
the usual int looking something like this

	typedef			char		S8;
	typedef	unsigned	char		U8;

	typedef			short		S16;
	typedef unsigned	short		U16;

	typedef			int		S32;
	typedef unsigned	int		U32;

#if defined(PS2)
	typedef			long long	S64;
	typedef unsigned	long long	U64;

#if defined(__MWERKS__)
	typedef			__int128	S128;
	typedef unsigned	__int128	U128;
#endif // __MWERKS__

#endif // PS2

These can be defined in a platform specific way, so S32 will be a 32
bit int regardless of what platform you are on.

But back to lua, has anyone run lua on the PS2 ???

Alex
The Code Monkeys

>
>> I have noticed that there is a define which determines the number of
>> bits in an integer and so for, this appears to be used for the virtual
>> machine stuff.
>
>This macro is used in some places where we assume that an int *may* be
>larger than 16 bits:
>
>  #if BITS_INT > 26
>  #define MAXBITS         24
>  #else
>  #define MAXBITS         (BITS_INT-2)
>  #endif
>
>and
>
>  #if SIZE_Bx < BITS_INT-1
>  #define MAXARG_Bx        ((1<<SIZE_Bx)-1)
>  #define MAXARG_sBx        (MAXARG_Bx>>1)         /* `sBx' is signed */
>  #else
>  #define MAXARG_Bx        MAX_INT
>  #define MAXARG_sBx        MAX_INT
>  #endif
>
>
>So, it avoids the assumption that our int has more than 26 (or 18) bits.
>
>-- Roberto