// filename:c2011-7-6-3-2-ex.c
// original examples and/or notes:
// 		(c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011
// http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf
// 			C2011 7.6.3.2 The fesetround function
// compile and output mechanism:
// 		(c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.29, 2013
// compile errors and/or wornings:
// 1	(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
// 			Target: x86_64-apple-darwin11.4.2 //Thread model: posix
// 		(c) LLVM 2003-2009 University of Illinois at Urbana-Champaign.
// 2    gcc-4.9 (GCC) 4.9.0 20131229 (experimental)
//      Copyright (C) 2013 Free Software Foundation, Inc.
#include <stdio.h>

// Example
#include <fenv.h>
#include <assert.h>
void f(int round_dir)
{
#pragma STDC FENV_ACCESS ON
int save_round;
int setround_ok;
save_round = fegetround();
setround_ok = fesetround(round_dir);
assert(setround_ok == 0);
/* ... */
fesetround(save_round);
/* ... */
}
int main(void)
{
	int i;
	f(i);
return printf("7.6.3.2 The fesetround function\n");
}
// warning((LLVM3.2) may be
//c2011-7-6-3-2-ex.c:18:14: warning: pragma STDC FENV_ACCESS ON is not supported, ignoring pragma [-Wunknown-pragmas]
//#pragma STDC FENV_ACCESS ON
//             ^
//1 warning generated.
// output(LLVM3.2 and GCC4.9) may be
//Assertion failed: (setround_ok == 0), function f, file c2011-7-6-3-2-ex.c, line 23.
//Abort trap: 6
