mirror of
https://github.com/adtools/clib2.git
synced 2025-12-08 14:59:05 +00:00
Compare commits
5 Commits
developmen
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c02665938f | ||
|
|
1e2863c5b8 | ||
|
|
e1da3dadfb | ||
|
|
b51c79577e | ||
|
|
975f949aa1 |
@@ -1,14 +0,0 @@
|
|||||||
---
|
|
||||||
engines:
|
|
||||||
duplication:
|
|
||||||
enabled: false
|
|
||||||
fixme:
|
|
||||||
enabled: true
|
|
||||||
markdownlint:
|
|
||||||
enabled: true
|
|
||||||
ratings:
|
|
||||||
paths:
|
|
||||||
- "**.c"
|
|
||||||
- "**.h"
|
|
||||||
- "**.l"
|
|
||||||
- "**.md"
|
|
||||||
54
.github/workflows/ci.yml
vendored
Normal file
54
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
name: CI
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
timeout-minutes: 480
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [os4, os3]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: setup dependencies
|
||||||
|
run: |
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update -y -qq || true
|
||||||
|
sudo apt-get -qq install libc6:i386
|
||||||
|
sudo ln -s /usr/lib/x86_64-linux-gnu/libmpfr.so.6 /usr/lib/x86_64-linux-gnu/libmpfr.so.4
|
||||||
|
|
||||||
|
- name: setup env
|
||||||
|
run : |
|
||||||
|
echo "GITHUB_SHA7=$(echo ${GITHUB_SHA::7})" >>$GITHUB_ENV
|
||||||
|
|
||||||
|
- name: install adtools build env
|
||||||
|
run: |
|
||||||
|
DOWNLOAD_PATH=https://github.com/adtools/adtools/releases/download/20170213
|
||||||
|
curl -L ${DOWNLOAD_PATH}/adtools-utils.tar.bz2 | sudo tar xj -C /
|
||||||
|
if [[ ${{ matrix.platform }} =~ os3 ]]; then curl -L ${DOWNLOAD_PATH}/adtools-m68k-amigaos.tar.bz2 | sudo tar xj -C / ; fi
|
||||||
|
if [[ ${{ matrix.platform }} =~ os4 ]]; then curl -L ${DOWNLOAD_PATH}/adtools-ppc-amigaos.tar.bz2 | sudo tar xj -C / ; fi
|
||||||
|
if [[ ${{ matrix.platform }} =~ mos ]]; then curl -L ${DOWNLOAD_PATH}/adtools-ppc-morphos.tar.bz2 | sudo tar xj -C / ; fi
|
||||||
|
if [[ ${{ matrix.platform }} =~ aros-ppc ]]; then curl -L ${DOWNLOAD_PATH}/adtools-ppc-aros.tar.bz2 | sudo tar xj -C / ; fi
|
||||||
|
if [[ ${{ matrix.platform }} =~ aros-i386 ]]; then curl -L ${DOWNLOAD_PATH}/adtools-i386-aros.tar.bz2 | sudo tar xj -C / ; fi
|
||||||
|
if [[ ${{ matrix.platform }} =~ aros-x86_64 ]]; then curl -L ${DOWNLOAD_PATH}/adtools-x86_64-aros.tar.bz2 | sudo tar xj -C / ; fi
|
||||||
|
|
||||||
|
- name: cleanup old action artifacts
|
||||||
|
run: .github/workflows/purge_artifacts.sh ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
#- name: remote debug tmate session
|
||||||
|
# uses: mxschmitt/action-tmate@v1
|
||||||
|
# if: matrix.platform == 'os4'
|
||||||
|
|
||||||
|
- name: build [${{ matrix.platform }}]
|
||||||
|
timeout-minutes: 480
|
||||||
|
run: |
|
||||||
|
export PATH=/usr/local/amiga/bin:/opt/m68k-amigaos/bin:/opt/ppc-amigaos/bin:/opt/ppc-morphos/bin:${PATH}
|
||||||
|
if [[ ${{ matrix.platform }} =~ os4 ]]; then make -C library -j1 -f GNUmakefile.os4 OS=os4 ; fi
|
||||||
|
if [[ ${{ matrix.platform }} =~ os3 ]]; then make -C library -j1 -f GNUmakefile.68k OS=os3 ; fi
|
||||||
55
.github/workflows/purge_artifacts.sh
vendored
Executable file
55
.github/workflows/purge_artifacts.sh
vendored
Executable file
@@ -0,0 +1,55 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Customize those three lines with your repository and credentials:
|
||||||
|
REPO=https://api.github.com/repos/${GITHUB_REPOSITORY}
|
||||||
|
GITHUB_USER=${GITHUB_REPOSITORY%%/*}
|
||||||
|
GITHUB_TOKEN=${1}
|
||||||
|
|
||||||
|
# Number of most recent versions to keep for each artifact:
|
||||||
|
KEEP=4
|
||||||
|
|
||||||
|
# A shortcut to call GitHub API.
|
||||||
|
ghapi() { curl --silent --location --user $GITHUB_USER:$GITHUB_TOKEN "$@"; }
|
||||||
|
|
||||||
|
# A temporary file which receives HTTP response headers.
|
||||||
|
TMPFILE=/tmp/tmp.$$
|
||||||
|
|
||||||
|
# An associative array, key: artifact name, value: number of artifacts of that name.
|
||||||
|
declare -A ARTCOUNT
|
||||||
|
|
||||||
|
# Process all artifacts on this repository, loop on returned "pages".
|
||||||
|
URL=$REPO/actions/artifacts
|
||||||
|
while [[ -n "$URL" ]]; do
|
||||||
|
|
||||||
|
# Get current page, get response headers in a temporary file.
|
||||||
|
JSON=$(ghapi --dump-header $TMPFILE "$URL")
|
||||||
|
|
||||||
|
# Get URL of next page. Will be empty if we are at the last page.
|
||||||
|
URL=$(grep '^Link:' "$TMPFILE" | tr ',' '\n' | grep 'rel="next"' | head -1 | sed -e 's/.*<//' -e 's/>.*//')
|
||||||
|
rm -f ${TMPFILE}
|
||||||
|
|
||||||
|
# Number of artifacts on this page:
|
||||||
|
COUNT=$(( $(jq <<<$JSON -r '.artifacts | length') ))
|
||||||
|
|
||||||
|
# Loop on all artifacts on this page.
|
||||||
|
for ((i=0; $i < $COUNT; i++)); do
|
||||||
|
|
||||||
|
# Get name of artifact and count instances of this name.
|
||||||
|
STR=$(jq <<<$JSON -r ".artifacts[$i].name?")
|
||||||
|
name=${STR%%-*}-${STR##*-}
|
||||||
|
ARTCOUNT[$name]=$(( $(( ${ARTCOUNT[$name]} )) + 1))
|
||||||
|
|
||||||
|
printf "Found '%s' #%d, " $STR ${ARTCOUNT[$name]}
|
||||||
|
# Check if we must delete this one.
|
||||||
|
if [[ ${ARTCOUNT[$name]} -gt $KEEP ]]; then
|
||||||
|
id=$(jq <<<$JSON -r ".artifacts[$i].id?")
|
||||||
|
size=$(( $(jq <<<$JSON -r ".artifacts[$i].size_in_bytes?") ))
|
||||||
|
printf "deleting %d bytes\n" $size
|
||||||
|
ghapi -X DELETE $REPO/actions/artifacts/$id
|
||||||
|
else
|
||||||
|
printf "OK\n"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
exit 0
|
||||||
36
.travis.yml
36
.travis.yml
@@ -1,36 +0,0 @@
|
|||||||
sudo: required
|
|
||||||
dist: trusty
|
|
||||||
|
|
||||||
language: c
|
|
||||||
|
|
||||||
# download and install our required cross compilers
|
|
||||||
install:
|
|
||||||
# Make sure we can install i386 packages as some adtools binaries
|
|
||||||
# requires i386 libraries being installed to work in the 64bit env
|
|
||||||
# of Travis
|
|
||||||
- sudo dpkg --add-architecture i386
|
|
||||||
- sudo apt-get -qq update || true
|
|
||||||
- sudo apt-get -qq install libc6:i386
|
|
||||||
# Install all adtools related stuff we need
|
|
||||||
- curl -L https://dl.bintray.com/jens-maus/adtools/adtools-utils.tar.bz2 | sudo tar xj -C /
|
|
||||||
- if [[ ${BUILD} =~ os3|release ]]; then curl -L https://dl.bintray.com/jens-maus/adtools/adtools-m68k-amigaos.tar.bz2 | sudo tar xj -C / ; fi
|
|
||||||
- if [[ ${BUILD} =~ os4|release ]]; then curl -L https://dl.bintray.com/jens-maus/adtools/adtools-ppc-amigaos.tar.bz2 | sudo tar xj -C / ; fi
|
|
||||||
- if [[ ${BUILD} =~ mos|release ]]; then curl -L https://dl.bintray.com/jens-maus/adtools/adtools-ppc-morphos.tar.bz2 | sudo tar xj -C / ; fi
|
|
||||||
- if [[ ${BUILD} =~ aros-ppc|release ]]; then curl -L https://dl.bintray.com/jens-maus/adtools/adtools-ppc-aros.tar.bz2 | sudo tar xj -C / ; fi
|
|
||||||
- if [[ ${BUILD} =~ aros-i386|release ]]; then curl -L https://dl.bintray.com/jens-maus/adtools/adtools-i386-aros.tar.bz2 | sudo tar xj -C / ; fi
|
|
||||||
- if [[ ${BUILD} =~ aros-x86_64|release ]]; then curl -L https://dl.bintray.com/jens-maus/adtools/adtools-x86_64-aros.tar.bz2 | sudo tar xj -C / ; fi
|
|
||||||
- if [[ ${BUILD} =~ mingw32|release ]]; then sudo apt-get -qq install binutils-mingw-w64-i686 gcc-mingw-w64-i686 ; fi
|
|
||||||
|
|
||||||
# set the PATH variable to the directories the cross compilers are installed.
|
|
||||||
before_script:
|
|
||||||
- export PATH=/usr/local/amiga/bin:/opt/m68k-amigaos/bin:/opt/ppc-amigaos/bin:/opt/ppc-morphos/bin:${PATH}
|
|
||||||
|
|
||||||
# specify a list of variables to test (here we test the build for our supported
|
|
||||||
# list of operating systems).
|
|
||||||
env:
|
|
||||||
- BUILD="-f GNUmakefile.68k OS=os3"
|
|
||||||
- BUILD="-f GNUmakefile.os4 OS=os4"
|
|
||||||
|
|
||||||
# the build command to execute for each test
|
|
||||||
script:
|
|
||||||
- make -C library -j1 ${BUILD}
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
# clib2 – An ISO 'C' (1994) compliant runtime library for AmigaOS
|
# clib2 – An ISO 'C' (1994) compliant runtime library for AmigaOS
|
||||||
|
|
||||||
[](https://travis-ci.org/adtools/clib2)
|
[](https://github.com/adtools/clib2/actions)
|
||||||
[](https://codeclimate.com/github/adtools/clib2)
|
|
||||||
[](https://opensource.org/licenses/BSD-3-Clause)
|
[](https://opensource.org/licenses/BSD-3-Clause)
|
||||||
[](https://github.com/adtools/clib2/issues)
|
|
||||||
|
|
||||||
## What is this?
|
## What is this?
|
||||||
|
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ extern int errno;
|
|||||||
|
|
||||||
#define EILSEQ 85 /* Encoding error detected */
|
#define EILSEQ 85 /* Encoding error detected */
|
||||||
|
|
||||||
|
#define ENOTSUP 86 /* Not supported */
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
|
|
||||||
static const char * error_table[EILSEQ - EPERM + 1] =
|
static const char * error_table[ENOTSUP - EPERM + 1] =
|
||||||
{
|
{
|
||||||
"Operation not permitted",
|
"Operation not permitted",
|
||||||
"No such file or directory",
|
"No such file or directory",
|
||||||
@@ -127,7 +127,8 @@ static const char * error_table[EILSEQ - EPERM + 1] =
|
|||||||
"Identifier removed",
|
"Identifier removed",
|
||||||
"No message of the desired type.",
|
"No message of the desired type.",
|
||||||
"Value too large to be stored in data type.",
|
"Value too large to be stored in data type.",
|
||||||
"Encoding error detected"
|
"Encoding error detected",
|
||||||
|
"Not supported"
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@@ -139,7 +140,7 @@ strerror_r(int number,char * buffer,size_t buffer_size)
|
|||||||
const char * str;
|
const char * str;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
if(number < EPERM || number > EILSEQ)
|
if(number < EPERM || number > ENOTSUP)
|
||||||
{
|
{
|
||||||
__set_errno(EINVAL);
|
__set_errno(EINVAL);
|
||||||
goto out;
|
goto out;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: time_mktime.c,v 1.10 2006-01-08 12:04:27 obarthel Exp $
|
* $Id: time_mktime.c,v 1.11 2015-06-26 11:22:00 obarthel Exp $
|
||||||
*
|
*
|
||||||
* :ts=4
|
* :ts=4
|
||||||
*
|
*
|
||||||
@@ -52,9 +52,10 @@ mktime(struct tm *tm)
|
|||||||
{
|
{
|
||||||
DECLARE_UTILITYBASE();
|
DECLARE_UTILITYBASE();
|
||||||
struct ClockData clock_data;
|
struct ClockData clock_data;
|
||||||
ULONG seconds, delta;
|
ULONG seconds;
|
||||||
time_t result = (time_t)-1;
|
time_t result = (time_t)-1;
|
||||||
int max_month_days;
|
LONG combined_seconds;
|
||||||
|
int month, year;
|
||||||
|
|
||||||
ENTER();
|
ENTER();
|
||||||
|
|
||||||
@@ -73,116 +74,63 @@ mktime(struct tm *tm)
|
|||||||
}
|
}
|
||||||
#endif /* CHECK_FOR_NULL_POINTERS */
|
#endif /* CHECK_FOR_NULL_POINTERS */
|
||||||
|
|
||||||
/* The month must be valid. */
|
/* Normalize the year and month. */
|
||||||
if(tm->tm_mon < 0 || tm->tm_mon > 11)
|
year = tm->tm_year + 1900;
|
||||||
|
month = tm->tm_mon + 1;
|
||||||
|
|
||||||
|
if(month < 0 || month > 12)
|
||||||
{
|
{
|
||||||
SHOWVALUE(tm->tm_mon);
|
int y;
|
||||||
SHOWMSG("invalid month");
|
|
||||||
goto out;
|
y = month / 12;
|
||||||
|
|
||||||
|
month -= y * 12;
|
||||||
|
year += y;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The day of the month must be valid. */
|
if(month < 1)
|
||||||
if(tm->tm_mday < 1 || tm->tm_mday > 31)
|
|
||||||
{
|
{
|
||||||
SHOWVALUE(tm->tm_mday);
|
month += 12;
|
||||||
SHOWMSG("invalid day of month");
|
year -= 1;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The year must be valid. */
|
/* The year must be valid. Amiga time begins with January 1st, 1978. */
|
||||||
if(tm->tm_year < 78)
|
if(year < 1978)
|
||||||
{
|
{
|
||||||
SHOWVALUE(tm->tm_year);
|
SHOWVALUE(year);
|
||||||
SHOWMSG("invalid year");
|
SHOWMSG("invalid year");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Is this the month of February? */
|
/* Convert the first day of the month in the given year
|
||||||
if(tm->tm_mon == 1)
|
into the corresponding number of seconds. */
|
||||||
{
|
memset(&clock_data, 0, sizeof(clock_data));
|
||||||
int year;
|
|
||||||
|
|
||||||
/* We need to have the full year number for the
|
|
||||||
leap year calculation below. */
|
|
||||||
year = tm->tm_year + 1900;
|
|
||||||
|
|
||||||
/* Now for the famous leap year calculation rules... In
|
|
||||||
the given year, how many days are there in the month
|
|
||||||
of February? */
|
|
||||||
if((year % 4) != 0)
|
|
||||||
max_month_days = 28;
|
|
||||||
else if ((year % 400) == 0)
|
|
||||||
max_month_days = 29;
|
|
||||||
else if ((year % 100) == 0)
|
|
||||||
max_month_days = 28;
|
|
||||||
else
|
|
||||||
max_month_days = 29;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
static const char days_per_month[12] =
|
|
||||||
{
|
|
||||||
31, 0,31,
|
|
||||||
30,31,30,
|
|
||||||
31,31,30,
|
|
||||||
31,30,31
|
|
||||||
};
|
|
||||||
|
|
||||||
max_month_days = days_per_month[tm->tm_mon];
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The day of the month must be valid. */
|
|
||||||
if(tm->tm_mday < 0 || tm->tm_mday > max_month_days)
|
|
||||||
{
|
|
||||||
SHOWVALUE(tm->tm_mday);
|
|
||||||
SHOWMSG("invalid day of month");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The hour must be valid. */
|
|
||||||
if(tm->tm_hour < 0 || tm->tm_hour > 23)
|
|
||||||
{
|
|
||||||
SHOWVALUE(tm->tm_hour);
|
|
||||||
SHOWMSG("invalid hour");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The minute must be valid. */
|
|
||||||
if(tm->tm_min < 0 || tm->tm_min > 59)
|
|
||||||
{
|
|
||||||
SHOWVALUE(tm->tm_min);
|
|
||||||
SHOWMSG("invalid minute");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Note: the number of seconds can be larger than 59
|
|
||||||
in order to account for leap seconds. */
|
|
||||||
if(tm->tm_sec < 0 || tm->tm_sec > 60)
|
|
||||||
{
|
|
||||||
SHOWVALUE(tm->tm_sec);
|
|
||||||
SHOWMSG("invalid seconds");
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
clock_data.sec = (tm->tm_sec > 59) ? 59 : tm->tm_sec;
|
|
||||||
clock_data.min = tm->tm_min;
|
|
||||||
clock_data.hour = tm->tm_hour;
|
|
||||||
clock_data.mday = tm->tm_mday;
|
|
||||||
clock_data.month = tm->tm_mon + 1;
|
|
||||||
clock_data.year = tm->tm_year + 1900;
|
|
||||||
|
|
||||||
seconds = Date2Amiga(&clock_data) + (tm->tm_sec - 59);
|
|
||||||
|
|
||||||
/* The AmigaOS "epoch" starts with January 1st, 1978, which was
|
|
||||||
a Sunday. */
|
|
||||||
tm->tm_wday = (seconds / (24 * 60 * 60)) % 7;
|
|
||||||
|
|
||||||
clock_data.mday = 1;
|
clock_data.mday = 1;
|
||||||
clock_data.month = 1;
|
clock_data.month = month;
|
||||||
|
clock_data.year = year;
|
||||||
|
|
||||||
delta = Date2Amiga(&clock_data);
|
seconds = Date2Amiga(&clock_data);
|
||||||
|
|
||||||
tm->tm_yday = (seconds - delta) / (24 * 60 * 60);
|
/* Put the combined number of seconds involved together,
|
||||||
|
covering the seconds/minutes/hours of the day as well
|
||||||
|
as the number of days of the month. This will be added
|
||||||
|
to the number of seconds for the date. */
|
||||||
|
combined_seconds = tm->tm_sec + 60 * (tm->tm_min + 60 * (tm->tm_hour + 24 * (tm->tm_mday-1)));
|
||||||
|
|
||||||
|
/* If the combined number of seconds is negative, adding it
|
||||||
|
* to the number of seconds for the date should not produce
|
||||||
|
* a negative value.
|
||||||
|
*/
|
||||||
|
if(combined_seconds < 0 && seconds < (ULONG)(-combined_seconds))
|
||||||
|
{
|
||||||
|
SHOWVALUE(seconds);
|
||||||
|
SHOWVALUE(combined_seconds);
|
||||||
|
SHOWMSG("invalid combined number of seconds");
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
seconds += combined_seconds;
|
||||||
|
|
||||||
__locale_lock();
|
__locale_lock();
|
||||||
|
|
||||||
@@ -193,10 +141,13 @@ mktime(struct tm *tm)
|
|||||||
|
|
||||||
__locale_unlock();
|
__locale_unlock();
|
||||||
|
|
||||||
/* Finally, adjust for the difference between the Unix and the
|
/* Adjust for the difference between the Unix and the
|
||||||
AmigaOS epochs, which differ by 8 years. */
|
AmigaOS epochs, which differ by 8 years. */
|
||||||
result = seconds + UNIX_TIME_OFFSET;
|
result = seconds + UNIX_TIME_OFFSET;
|
||||||
|
|
||||||
|
/* Finally, normalize the provided time and date information. */
|
||||||
|
localtime_r(&result, tm);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
||||||
RETURN(result);
|
RETURN(result);
|
||||||
|
|||||||
Reference in New Issue
Block a user