~ubuntu-branches/ubuntu/trusty/haskell-llvm-base/trusty-proposed

« back to all changes in this revision

Viewing changes to LLVM/Target/Native.hs

  • Committer: Package Import Robot
  • Author(s): Joachim Breitner
  • Date: 2012-03-11 15:44:32 UTC
  • Revision ID: package-import@ubuntu.com-20120311154432-oewynu19bajz4ccb
Tags: upstream-3.0.0.0
ImportĀ upstreamĀ versionĀ 3.0.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{-# LANGUAGE CPP #-}
 
2
module LLVM.Target.Native(initializeNativeTarget) where
 
3
import Control.Monad
 
4
import Control.Concurrent.MVar
 
5
import System.IO.Unsafe
 
6
 
 
7
-- TARGET is expanded by CPP to the native target architecture.
 
8
import LLVM.Target.TARGET
 
9
 
 
10
-- | Initialize jitter to the native target.
 
11
-- The operation is idempotent.
 
12
initializeNativeTarget :: IO ()
 
13
initializeNativeTarget = do
 
14
    done <- takeMVar refDone
 
15
    when (not done) initializeTarget
 
16
    putMVar refDone True
 
17
 
 
18
-- UNSAFE: global variable to keep track of initialization state.
 
19
refDone :: MVar Bool
 
20
refDone = unsafePerformIO $ newMVar False