On Wed, 22 May 2002, Yan Fitterer wrote:

> Hi,
> 
> Thanks very much for all the help so far. I'm now kind of stuck trying to get 
> something to compile for tomsrtbt.
> 
> I've got the libc5 stuff, but no headers, include, and the like, so my compiler 
>can't 
> really be asked to complie for that - can it? ;-)

In Debian it's just a matter of 

apt-get install altgcc libc5-altdev 

(Debian is for lazy guys like me -- apt makes life really hassle-free if
you have a decent inet connection) and then use gcc and g++ from these
packages (they reside in /usr/i486-linuxlibc1/bin). There process is lined
out somewhere in Debian FAQs.

Never tried it on a RH box. You should be able to use .deb-s on RH with
alien (util name :), no extraterrestial activity involved), so you could
just grab the abovementioned packages + libc5 from packages.debian.org and
convert these with it. But I guess an equivalent solution exists for RH --
search the FAQs.

A minimalistic version of rand (you can't set the seed, it's set from
current time, should be secure enough for your needs, but theoretically if
someone knows the time exatly (gee, milllisec precision!), (s)he can
reproduce the byte stream):

-- rand.c --
#include <time.h>
#include <unistd.h>
#include <stdlib.h>
#define SIZE 1024

int i, buff[SIZE];

void fillbuf(void){
        for(i=0; i < SIZE; i++)
                buff[i]=rand();
}

int main(){
        srand(time(0));//assume that time() doesn't fail - no check
        fillbuf();
        while ((write (1, buff, SIZE*sizeof(int))) > 0 )
                fillbuf();
        return 0;
}
------------

You can strip the symbols at compile time with -s and turn on optimisation
with -O2, -fomit-frame-pointer and 486 optimisation with -m486, eg with 
(-Wall turns on all warnings):

i486-linuxlibc1-gcc -O2 -fomit-frame-pointer -m486 -s rand.c -Wall -o rand

(i486-linuxlibc1-gcc is gcc from the libc5 .debs. Result is a 2756-byte
binary.)

Experimenting with -ffast-math might help to gain speed (dubious really
and it should be mutually exclusive with -O*, check gcc man or doc at
gcc.gnu.org). Also experiment with buffer size and dd buffer size (buffer
size could be easily added as a command-line argument like seed was in my
previous example). I guess SIZE >= 2*(dd obs) should be OK, so 1024 is a 
safe minimum.

Beware with console output: this thing splits out raw data as cat 
/dev/[u]random does, including control characters etc.

Regards,
Mart S�mermaa

Reply via email to