Skip to content

Commit

Permalink
Merge pull request #491 from quodlibetor/fix-oldtime-tzset
Browse files Browse the repository at this point in the history
Fix call of extern tzset function
  • Loading branch information
quodlibetor authored Sep 30, 2020
2 parents 6a97d72 + fbc1b93 commit 597717f
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 2 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: All Tests and Builds

on:
push:
Expand Down Expand Up @@ -116,3 +116,19 @@ jobs:
env:
RUST_VERSION: stable
WASM: wasm_simple

cross-targets:
strategy:
matrix:
target:
- x86_64-sun-solaris

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install cross
run: bash ci/install-cross.sh

- name: Build static library
run: cross check --target ${{ matrix.target }}
43 changes: 43 additions & 0 deletions ci/install-cross.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env bash

set -euxo pipefail

main() {
local target=
if [[ "$(os)" == "ubuntu-latest" || "$(os)" == Linux ]]; then
target=x86_64-unknown-linux-musl
# shellcheck disable=SC2209
sort=sort
else
target=x86_64-apple-darwin
sort=gsort
fi

# This fetches latest stable release
local tag
tag=$(git ls-remote --tags --refs --exit-code https://github.com/rust-embedded/cross \
| cut -d/ -f3 \
| grep -E '^v[0.1.0-9.]+$' \
| $sort --version-sort \
| tail -n1)

curl -LSfs https://japaric.github.io/trust/install.sh | \
sh -s -- \
--force \
--git rust-embedded/cross \
--tag "$tag" \
--target $target

cross --version
}

# get an os name, either github's pre-set one or the result of uname
os() {
if [ -n "${OS_NAME:-}" ]; then
echo "$OS_NAME"
return
fi
uname
}

main
10 changes: 9 additions & 1 deletion src/sys/unix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ extern "C" {
static altzone: time_t;
}

#[cfg(any(target_os = "solaris", target_os = "illumos"))]
fn tzset() {
extern "C" {
fn tzset();
}
unsafe { tzset() }
}

fn rust_tm_to_tm(rust_tm: &Tm, tm: &mut libc::tm) {
tm.tm_sec = rust_tm.tm_sec;
tm.tm_min = rust_tm.tm_min;
Expand Down Expand Up @@ -78,7 +86,7 @@ pub fn time_to_local_tm(sec: i64, tm: &mut Tm) {
}
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
let gmtoff = {
::tzset();
tzset();
// < 0 means we don't know; assume we're not in DST.
if out.tm_isdst == 0 {
// timezone is seconds west of UTC, tm_gmtoff is seconds east
Expand Down

0 comments on commit 597717f

Please sign in to comment.