diff --git a/AUTHORS b/AUTHORS
new file mode 100644
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,1 @@
+Cetin Sert <cetin@sertcom.de>
diff --git a/COPYING b/COPYING
new file mode 100644
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,31 @@
+Copyright (c) 2009, Cetin Sert
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * The names of contributors may not be used to endorse or promote
+      products derived from this software without specific prior
+      written permission. 
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,31 @@
+Copyright (c) 2009, Cetin Sert
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+
+    * The names of contributors may not be used to endorse or promote
+      products derived from this software without specific prior
+      written permission. 
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README b/README
new file mode 100644
--- /dev/null
+++ b/README
@@ -0,0 +1,5 @@
+dedicated to An Le Thi Thanh
+
+----------------
+
+bindings to time.h: clock_gettime and clock_getres
diff --git a/Setup.hs b/Setup.hs
new file mode 100644
--- /dev/null
+++ b/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/System/CPUTime/Clock.hs b/System/CPUTime/Clock.hs
new file mode 100644
--- /dev/null
+++ b/System/CPUTime/Clock.hs
@@ -0,0 +1,87 @@
+module System.CPUTime.Clock (
+
+  Clock (Monotonic, Realtime, ProcessTime, ThreadTime),
+  TimeSpec (Time),
+
+  clock_gettime,
+  clock_getres,
+
+  sec,
+  nsec,  
+
+) where
+
+import GHC.Ptr
+--import System.IO.Unsafe
+import Foreign.Storable
+import Foreign.Marshal.Alloc (free)
+import Foreign.Marshal.Array
+
+-- Reader function
+type ReaderFunc = Ptr Int → IO ()
+
+-- Readers
+-- | 
+foreign import ccall clock_readtime_monotonic :: ReaderFunc
+foreign import ccall clock_readtime_realtime :: ReaderFunc
+foreign import ccall clock_readtime_processtime :: ReaderFunc
+foreign import ccall clock_readtime_threadtime :: ReaderFunc
+
+foreign import ccall clock_readres_monotonic :: ReaderFunc
+foreign import ccall clock_readres_realtime :: ReaderFunc
+foreign import ccall clock_readres_processtime :: ReaderFunc
+foreign import ccall clock_readres_threadtime :: ReaderFunc
+
+
+-- Clock types
+data Clock = Monotonic | Realtime | ProcessTime | ThreadTime
+
+-- Clock-to-time reading
+time :: Clock → ReaderFunc
+time Monotonic = clock_readtime_monotonic
+time Realtime  = clock_readtime_realtime
+time ProcessTime = clock_readtime_processtime
+time ThreadTime = clock_readtime_threadtime
+
+-- Clock-to-res reading
+res :: Clock → ReaderFunc
+res Monotonic = clock_readres_monotonic
+res Realtime  = clock_readres_realtime
+res ProcessTime = clock_readres_processtime
+res ThreadTime = clock_readres_threadtime
+
+-- TimeSpec structure
+data TimeSpec = Time Int Int deriving (Show, Read)
+sec  :: TimeSpec → Int
+nsec :: TimeSpec → Int
+sec  (Time s _) = s
+nsec (Time _ n) = n
+
+-- clock_gettime
+clock_gettime :: Clock → IO TimeSpec
+clock_gettime = call . time
+
+-- clock_getres
+clock_getres :: Clock → IO TimeSpec
+clock_getres = call . res
+
+-- core function
+call :: ReaderFunc → IO TimeSpec
+call read_ = do
+  t ← (2 ↑≣)
+  read_ t
+  s ← (t ≣→ 0)
+  n ← (t ≣→ 1)
+  (t ≣⊠)
+  return $ Time s n
+
+---------------------------------------------
+
+(↑≣) :: Storable a ⇒ Int → IO (Ptr a)
+(↑≣) = mallocArray
+
+(≣→) :: Storable a ⇒ Ptr a → Int → IO a
+(≣→) = peekElemOff
+
+(≣⊠) :: Ptr a → IO ()
+(≣⊠) = Foreign.Marshal.Alloc.free
diff --git a/clean b/clean
new file mode 100644
--- /dev/null
+++ b/clean
@@ -0,0 +1,2 @@
+cabal clean
+find | grep -iE ~$ | xargs -n 1 rm
diff --git a/clock.cabal b/clock.cabal
new file mode 100644
--- /dev/null
+++ b/clock.cabal
@@ -0,0 +1,20 @@
+Name:               clock
+Version:            0.1
+License:            BSD3
+License-file:       COPYING
+Copyright:          (c) 2009 Cetin Sert
+Author:             Cetin Sert <cetin@sertcom.de>
+Maintainer:         Cetin Sert <cetin@sertcom.de>
+Homepage:           http://sert.homedns.org/hs/clock/
+Category:           System
+Synopsis:           bindings to time.h: clock_gettime and clock_getres
+Description:        bindings to time.h: clock_gettime and clock_getres
+Stability:          Experimental
+Build-type:         Simple
+Build-depends:      base >= 2 && < 4.2
+Exposed-Modules:    System.CPUTime.Clock
+Extensions:         ForeignFunctionInterface
+C-sources:	        csec/clock.c
+Include-dirs:       csec
+Install-includes:   clock.h
+ghc-options:        -O2 -Wall -fglasgow-exts
diff --git a/csec/clock.c b/csec/clock.c
new file mode 100644
--- /dev/null
+++ b/csec/clock.c
@@ -0,0 +1,68 @@
+#include "clock.h"
+#include <time.h>
+
+void time_(clockid_t clock, long* t)
+{
+
+  struct timespec a;
+
+  clock_gettime(clock, &a);
+
+  t[0] = a.tv_sec ;
+  t[1] = a.tv_nsec;
+
+}
+
+void clock_readtime_monotonic(long* t)
+{
+  time_(CLOCK_MONOTONIC, t);
+}
+
+void clock_readtime_realtime(long* t)
+{
+  time_(CLOCK_REALTIME, t);
+}
+
+void clock_readtime_processtime(long* t)
+{
+  time_(CLOCK_PROCESS_CPUTIME_ID , t);
+}
+
+void clock_readtime_threadtime(long* t)
+{
+  time_(CLOCK_THREAD_CPUTIME_ID , t);
+}
+
+
+void res_(clockid_t clock, long* t)
+{
+
+  struct timespec a;
+
+  clock_getres(clock, &a);
+
+  t[0] = a.tv_sec ;
+  t[1] = a.tv_nsec;  
+
+}
+
+void clock_readres_monotonic(long* t)
+{
+  res_(CLOCK_MONOTONIC, t);
+}
+
+void clock_readres_realtime(long* t)
+{
+  res_(CLOCK_REALTIME, t);
+}
+
+void clock_readres_processtime(long* t)
+{
+  res_(CLOCK_PROCESS_CPUTIME_ID , t);
+}
+
+void clock_readres_threadtime(long* t)
+{
+  res_(CLOCK_THREAD_CPUTIME_ID , t);
+}
+
diff --git a/csec/clock.h b/csec/clock.h
new file mode 100644
--- /dev/null
+++ b/csec/clock.h
@@ -0,0 +1,5 @@
+void clock_readtime_monotonic(long* t);
+void clock_readtime_realtime(long* t);
+void clock_readtime_processtime(long* t);
+void clock_readtime_threadtime(long* t);
+void clock_readres(long* t);
diff --git a/edit b/edit
new file mode 100644
--- /dev/null
+++ b/edit
@@ -0,0 +1,1 @@
+gedit COPYING clock.cabal csec/*.c csec/*.h System/CPUTime/*.hs &
