File: modf-np.c

package info (click to toggle)
avr-libc 1%3A1.6.2.cvs20080610-2
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 14,848 kB
  • ctags: 55,619
  • sloc: ansic: 92,267; asm: 6,692; sh: 4,131; makefile: 2,481; python: 976; pascal: 426; perl: 116
file content (29 lines) | stat: -rw-r--r-- 498 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* Test of modf() function. NULL pointer.
   $Id: modf-np.c,v 1.1 2007/02/05 21:35:58 dmix Exp $
 */
#include <math.h>
#include <stdlib.h>

int main ()
{
    double z;

    {
#ifdef	__AVR__
	/* Address of R1 is 0x0001	*/
	unsigned char r1;
	z = modf (257.5, 0);		/* 257 == 0x0101	*/
	asm ("mov %0,r1 \n\t clr r1" : "=r"(r1));
	if (r1)
	    exit (__LINE__);
#else
	/* Skip NULL pointer testing.	*/
	double v;
	z = modf (257.5, & v);
#endif
    }
    if (z != 0.5)
	exit (__LINE__);

    return 0;
}