Subject: Re: mysql and MIT-pthreads
To: None <port-amiga@NetBSD.ORG>
From: George Harvey <fr30@dial.pipex.com@am061.du.pipex.com>
List: port-amiga
Date: 03/03/1997 21:52:06
To follow up my own question...

I have been looking through the libc sources for inspiration and have 
now made some progress with the pthreads library:

+ I have fixed my thread-create problem.
+ Most of the thread test programs pass.
+ Mysql itself appears to be working.

However there are still some loose ends, in particular I haven't got
a clue how to implement the routines to save and restore the floating
point state (my 68000 assembler book does not cover the 68881/68882).
I have included the NetBSD-i386 version below and would appreciate
any ideas on how this should be done on a 680x0 (or even if it needs
to be done at all).


== begin extract from engine-i386-netbsd-1.0.c ==
/* =======================================================================
 * machdep_save_state()
 */
int machdep_save_float_state(struct pthread * pthread)
{
	char * fdata = (char *)pthread->machdep_data.machdep_float_state;

	__asm__ ("fsave %0"::"m" (*fdata));
}

/* =======================================================================
 * machdep_restore_float_state()
 */
int machdep_restore_float_state(void)
{
	char * fdata = (char *)pthread_run->machdep_data.machdep_float_state;

	__asm__ ("frstor %0"::"m" (*fdata));
}
== end extract ==

>
[ snip ]
> 
> I am attempting to compile the 'mysql' database package under
> NetBSD-1.2 on an Amiga 3000. Mysql requires POSIX threads to run
> and the current source distribution (http://www.tcx.se) includes 
> the MIT pthreads library for this purpose. Unfortunately, although 
> there is support for NetBSD, there is no support for the 680x0 
> processor (the pthreads library uses assembler code routines in
> a number of critical areas).
> 
> Here is where I have got to...
> 
> + Created a set of machine-dependent files for NetBSD-68k based
>   on the supplied NetBSD-i386 versions.
> + Replaced the i386 assembler code with what I hope is equivalent
>   680x0 code (my 68k assembler knowledge is very limited).
> + Fixed the configure script, makefiles etc. to recognise the 68k.
> + Successfully compiled and linked everything.
> 
> BUT, the pthreads library doesn't work, any attempt to create a thread
> causes the program to stick in an infinite loop somewhere. I know
> it is going to be a fault in my assembler code but I need to understand 
> how the registers are used in system calls in order to make any progress
> in this area. Is there any sort of guide anywhere to assembler
> programming for NetBSD on a 68k ?
> 

    George Harvey                  | Amiga A3000T, CyberStorm-II 040,
    email: fr30@dial.pipex.com     | Picasso-II, MFC-III