Skip to content

Commit

Permalink
fix makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
MLopez-Ibanez committed Nov 12, 2023
1 parent 25310e2 commit c0918e8
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 133 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/C.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
7z x gsl.zip
popd
echo "GSL_CFLAGS=-I${RUNNER_TEMP}/gsl-2.7/include" >> $GITHUB_ENV
echo "GSL_LIBS=-L"$(RUNNER_TEMP)/gsl-2.7/lib/x64" >> $GITHUB_ENV
echo "GSL_LIBS=-L$(RUNNER_TEMP)/gsl-2.7/lib/x64" >> $GITHUB_ENV
shell: bash

- run: cd src && ./configure
Expand Down
78 changes: 78 additions & 0 deletions .github/workflows/R.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,81 @@ jobs:
- uses: r-lib/actions/run-rchk@v2
with:
run-only: true

coverage:
needs: rchk
name: Coverage ${{ matrix.config.os }} (${{ matrix.config.r }})
runs-on: ${{ matrix.config.os }}
strategy:
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
CODECOV_TOKEN: ${{secrets.CODECOV_TOKEN}}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
needs: coverage
working-directory: 'R'

- name: Test coverage
env:
NOT_CRAN: false
run: |
setwd("R/")
covr::codecov(type="all", quiet=FALSE, commentDonttest = FALSE, commentDontrun = FALSE)
shell: Rscript {0}

pkgdown:
needs: R-CMD-check
if: contains('
refs/heads/master
refs/heads/main
', github.ref) && github.event_name == 'push'
name: pkgdown ${{ matrix.config.os }} (${{ matrix.config.r }})
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
use-public-rspm: true

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::pkgdown, local::.
needs: website
working-directory: 'R'

- name: Deploy package
if: success() && runner.os == 'Linux' && matrix.config.r == 'release' && github.event_name == 'push'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
setwd("R/")
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE, run_dont_run = TRUE)'
shell: bash {0}

71 changes: 0 additions & 71 deletions src/getrusage.c

This file was deleted.

26 changes: 0 additions & 26 deletions src/resource.h

This file was deleted.

118 changes: 88 additions & 30 deletions src/timer.c
Original file line number Diff line number Diff line change
@@ -1,42 +1,101 @@
/*************************************************************************
Simple timer functions.
Global timer functions.
---------------------------------------------------------------------
*************************************************************************/
#include <stddef.h>
#if DEBUG >= 1
#include <stdio.h>
#endif
#include <sys/time.h> /* for struct timeval */
#ifndef WIN32
#include <sys/resource.h> /* for getrusage */
#else
/*
getrusage
Implementation according to:
The Open Group Base Specifications Issue 6
IEEE Std 1003.1, 2004 Edition
Copyright (c) 2005, 2006, 2007 Manuel Lopez-Ibanez
TeX: \copyright 2005, 2006, 2007 Manuel L{\'o}pez-Ib{\'a}{\~n}ez
THIS SOFTWARE IS NOT COPYRIGHTED
This program is free software (software libre); you can redistribute
it and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This source code is offered for use in the public domain. You may
use, modify or distribute it freely.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
This code is distributed in the hope that it will be useful but
WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
DISCLAIMED. This includes but is not limited to warranties of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
You should have received a copy of the GNU General Public License
along with this program; if not, you can obtain a copy of the GNU
General Public License at:
http://www.gnu.org/copyleft/gpl.html
or by writing to:
Free Software Foundation, Inc., 59 Temple Place,
Suite 330, Boston, MA 02111-1307 USA
Contributed by:
Ramiro Polla <[email protected]>
----------------------------------------------------------------------
Modified by:
Manuel Lopez-Ibanez <[email protected]>
* Remove dependency with <sys/resources.h>
**************************************************************************/
/*
* resource.h
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the mingw-runtime package.
* No warranty is given; refer to the file DISCLAIMER within the package.
*
* Based on:
* http://www.opengroup.org/onlinepubs/000095399/basedefs/sys/resource.h.html
*/
#define RUSAGE_SELF (1<<0)
#define RUSAGE_CHILDREN (1<<1)

NOTES: based on source code from Thomas Stuetzle.
struct rusage
{
struct timeval ru_utime; /* user time used */
struct timeval ru_stime; /* system time used */
};

/* Include only the minimum from windows.h */
#define WIN32_LEAN_AND_MEAN
#include <errno.h>
#include <stdint.h>
#include <windows.h>

static void
FILETIME_to_timeval (struct timeval *tv, FILETIME *ft)
{
int64_t fulltime = ((((int64_t) ft->dwHighDateTime) << 32)
| ((int64_t) ft->dwLowDateTime));
fulltime /= 10LL; /* 100-ns -> us */
tv->tv_sec = fulltime / 1000000L;
tv->tv_usec = fulltime % 1000000L;
}
static int __cdecl
getrusage(int who, struct rusage *r_usage)
{
FILETIME starttime;
FILETIME exittime;
FILETIME kerneltime;
FILETIME usertime;

if (!r_usage) {
errno = EFAULT;
return -1;
}

*************************************************************************/
if (who != RUSAGE_SELF) {
errno = EINVAL;
return -1;
}

#include <stdio.h>
#include <sys/time.h> /* for struct timeval */
#ifndef WIN32
#include <sys/resource.h> /* for getrusage */
#else
#include "resource.h"
if (GetProcessTimes (GetCurrentProcess (),
&starttime, &exittime,
&kerneltime, &usertime) == 0) {
return -1;
}
FILETIME_to_timeval (&r_usage->ru_stime, &kerneltime);
FILETIME_to_timeval (&r_usage->ru_utime, &usertime);
return 0;
}
#endif

#include "timer.h"
Expand Down Expand Up @@ -95,10 +154,9 @@ double Timer_elapsed_virtual (void)

double Timer_elapsed_real (void)
{
double timer_tmp_time;

gettimeofday (&tp, NULL);
timer_tmp_time = TIMER_WALLTIME(tp) - real_time;
double timer_tmp_time = TIMER_WALLTIME(tp) - real_time;

#if DEBUG >= 2
if (timer_tmp_time < 0.0) {
Expand Down
5 changes: 0 additions & 5 deletions src/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,7 @@
#ifndef TIMER_H_
#define TIMER_H_

#include <float.h>

#define HUGE_TIME FLT_MAX

typedef enum type_timer {REAL_TIME, VIRTUAL_TIME} TIMER_TYPE;

void Timer_start(void);
double Timer_elapsed_virtual(void);
double Timer_elapsed_real(void);
Expand Down

0 comments on commit c0918e8

Please sign in to comment.