Jump to content

Host introspection: Difference between revisions

(→‎{{header|TXR}}: New section.)
Line 1,022:
 
=={{header|TXR}}==
 
Interactive session:
 
Which word? Pointer size or size of <code>int</code>? Let's get both:
 
<pre>This is the TXR Lisp interactive listener of TXR 177.
Use the :quit command or type Ctrl-D on empty line to exit.
1> (sizeof (ptr char))
8
2> (sizeof int)
4</pre>
 
Endianness: what we can do is put the integer 1 into a buffer as a <code>uint32</code>, the 32 bit unsigned integer type in the local representation. We then retrieve it as a <code>le-uint32</code>: little-endian <code>uint32</code>:
 
<pre>3> (ffi-put 1 (ffi uint32))
#b'01000000'
4> (ffi-get *3 (ffi le-uint32))
1</pre>
 
The extracted value 1 matches, so the machine must be little endian. Here is a transcript from a big-endian PPC64 machine:
 
<pre>1> (ffi-put 1 (ffi uint32))
#b'00000001'
2> (ffi-get *1 (ffi le-uint32))
16777216</pre>
 
No match, so big endian.
 
=={{header|XPL0}}==
543

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.