Floating point exceptions with -pthread

Marc Olzheim marcolz at stack.nl
Wed May 4 12:52:43 PDT 2005

On Wed, May 04, 2005 at 03:15:06PM -0400, Daniel Eischen wrote:
> > It seems to me like something about the floorf() assembly might have
> > something to do with it.
> Yeah, I was just trying to narrow down the problem a bit more.

I've attached one that's built very tight around floorf().

-------------- next part --------------
all: fpu6 fpu6th

fpu6th:	fpu6.c
	cc -O3 -Wall -W -Werror -Wno-unused -g -Wcast-qual  -DWITH_THR -fstrict-aliasing -pthread fpu6.c -o fpu6th -lm

fpu6:	fpu6.c
	cc -O3 -Wall -W -Werror -Wno-unused -g -Wcast-qual  -fstrict-aliasing fpu6.c -o fpu6 -lm

	rm -f fpu6 fpu6th fpu6th.core core
-------------- next part --------------
/* Blame it in Marc Olzheim (Zlo) */

#ifdef		WITH_THR
#include	<pthread.h>
#endif		/* WITH_THR */

#include	<err.h>
#include	<math.h>
#include	<stdio.h>
#include	<unistd.h>

void *
calc_thread(void *arg)
	float		f;

	for (;;) {
		f = floorf((float)1.0 / (float)((long)arg + 1L));

		if (f > (float)1.0)	/* Never true, but needed to use f. */
			printf("\r%f", (double)f);

	return NULL;

main(int argc, char *argv[])
#ifdef		WITH_THR
	pthread_t	thread;

	if (pthread_create(&thread , NULL, calc_thread, (void *)1L))
		err(1, "pthread_create()");
#else		/* ! WITH_THR */
	(void)calc_thread((void *)1L);
#endif		/* ! WITH_THR */

	for (;;)

	return 0;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-threads/attachments/20050504/88e7aa39/attachment.bin

More information about the freebsd-threads mailing list