Implement fmod

Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
Reviewed-by: Tom Stellard <tom@stellard.net>
Reviewed-by: Aaron Watry <awatry@gmail.com>

git-svn-id: https://llvm.org/svn/llvm-project/libclc/trunk@219087 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/generic/include/clc/clc.h b/generic/include/clc/clc.h
index 2afbcfd..ff63fb0 100644
--- a/generic/include/clc/clc.h
+++ b/generic/include/clc/clc.h
@@ -47,6 +47,7 @@
 #include <clc/math/fma.h>
 #include <clc/math/fmax.h>
 #include <clc/math/fmin.h>
+#include <clc/math/fmod.h>
 #include <clc/math/hypot.h>
 #include <clc/math/log.h>
 #include <clc/math/log2.h>
diff --git a/generic/include/clc/math/fmod.h b/generic/include/clc/math/fmod.h
new file mode 100644
index 0000000..4906867
--- /dev/null
+++ b/generic/include/clc/math/fmod.h
@@ -0,0 +1,2 @@
+#define __CLC_BODY <clc/math/fmod.inc>
+#include <clc/math/gentype.inc>
diff --git a/generic/include/clc/math/fmod.inc b/generic/include/clc/math/fmod.inc
new file mode 100644
index 0000000..39d9153
--- /dev/null
+++ b/generic/include/clc/math/fmod.inc
@@ -0,0 +1 @@
+_CLC_OVERLOAD _CLC_DECL __CLC_GENTYPE fmod(__CLC_GENTYPE a, __CLC_GENTYPE b);
diff --git a/generic/lib/SOURCES b/generic/lib/SOURCES
index f7b3adf..5918989 100644
--- a/generic/lib/SOURCES
+++ b/generic/lib/SOURCES
@@ -61,6 +61,7 @@
 math/exp10.cl
 math/fmax.cl
 math/fmin.cl
+math/fmod.cl
 math/hypot.cl
 math/mad.cl
 math/mix.cl
diff --git a/generic/lib/math/fmod.cl b/generic/lib/math/fmod.cl
new file mode 100644
index 0000000..f9a4e31
--- /dev/null
+++ b/generic/lib/math/fmod.cl
@@ -0,0 +1,12 @@
+#include <clc/clc.h>
+#include "../clcmacro.h"
+
+_CLC_DEFINE_BINARY_BUILTIN(float, fmod, __builtin_fmodf, float, float)
+
+#ifdef cl_khr_fp64
+
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+_CLC_DEFINE_BINARY_BUILTIN(double, fmod, __builtin_fmod, double, double)
+
+#endif