Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use base CClockId as ClockId type #209

Merged
merged 2 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/ci.wasm32.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ci-wasm32

on:
push:
pull_request:

jobs:

ci-wasm32:
name: ci-wasm32
runs-on: ubuntu-20.04
steps:

- name: setup-proot
run: |
sudo apt install -y proot

- name: setup-ghc-wasm32-wasi
run: |
pushd $(mktemp -d)
curl -L https://github.com/tweag/ghc-wasm32-wasi/archive/refs/heads/master.tar.gz | tar xz --strip-components=1
./setup.sh
~/.ghc-wasm32-wasi/add_to_github_path.sh
popd

- name: checkout
uses: actions/checkout@v3

- name: build
run: |
sed -i '/tasty/d' time.cabal

echo "package QuickCheck" >> cabal.project.local
echo " flags: -templatehaskell" >> cabal.project.local

autoreconf -i

wasmtime-run wasm32-wasi-cabal run ShowDefaultTZAbbreviations
wasmtime-run wasm32-wasi-cabal run ShowTime
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ AC_CHECK_HEADERS([time.h])
AC_CHECK_FUNCS([gmtime_r localtime_r])

AC_CHECK_FUNCS([clock_gettime])
AC_CHECK_FUNCS([tzset])

AC_STRUCT_TM
AC_STRUCT_TIMEZONE
Expand Down
5 changes: 3 additions & 2 deletions lib/Data/Time/Clock/Internal/CTimespec.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ module Data.Time.Clock.Internal.CTimespec where
import Foreign
import Foreign.C
import System.IO.Unsafe
import System.Posix.Types

#include <time.h>

type ClockID = #{type clockid_t}
type ClockID = CClockId

data CTimespec = MkCTimespec CTime CLong

Expand Down Expand Up @@ -51,7 +52,7 @@ clockGetTime clockid = alloca (\ptspec -> do
peek ptspec
)

foreign import capi unsafe "time.h value CLOCK_REALTIME" clock_REALTIME :: ClockID
foreign import capi unsafe "HsTime.h value HS_CLOCK_REALTIME" clock_REALTIME :: ClockID

clock_TAI :: Maybe ClockID
clock_TAI =
Expand Down
2 changes: 1 addition & 1 deletion lib/cbits/HsTime.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ long int get_current_timezone_seconds (time_t t,int* pdst,char const* * pname)
// as Microsoft considers the POSIX named `tzset()` function
// deprecated (see http://msdn.microsoft.com/en-us/library/ms235384.aspx)
_tzset();
#else
#elif defined(HAVE_TZSET)
tzset();
#endif

Expand Down
2 changes: 2 additions & 0 deletions lib/include/HsTime.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <time.h>
#endif

#define HS_CLOCK_REALTIME (uintptr_t)(CLOCK_REALTIME)

long int get_current_timezone_seconds (time_t,int* pdst,char const* * pname);

#endif