From 5f9f67deeec937058fb2318842da0878d5ad8a25 Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Wed, 9 Feb 2022 03:14:09 -0500 Subject: [PATCH 1/6] set up Windows CI --- .github/workflows/build.yml | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 545198d9..f191ca49 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,7 +6,7 @@ name: ci jobs: build: - name: Build + name: Build Linux runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -17,3 +17,42 @@ jobs: - name: test working-directory: tests run: env METAMATH=../metamath ./run_test.sh *.in + + build-win-msvc: + name: Build Windows (MSVC) + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + - uses: ilammy/msvc-dev-cmd@v1 + + - name: build + working-directory: src + run: cl.exe *.c + + - name: run + working-directory: src + run: ./metamath.exe + + - name: test + working-directory: tests + shell: bash + run: env METAMATH=../src/metamath.exe ./run_test.sh *.in + + build-win-gcc: + name: Build Windows (GCC) + runs-on: windows-latest + steps: + - uses: actions/checkout@v2 + + - name: build + working-directory: src + run: gcc *.c -o metamath.exe + + - name: run + working-directory: src + run: ./metamath.exe + + - name: test + working-directory: tests + shell: bash + run: env METAMATH=../src/metamath.exe ./run_test.sh *.in From 9437b41caf69f292ee5eb3818f01452c90fcaaf5 Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Wed, 9 Feb 2022 03:17:21 -0500 Subject: [PATCH 2/6] fix pointer cast --- src/mmpars.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mmpars.c b/src/mmpars.c index a48cedc8..4c1e1e16 100644 --- a/src/mmpars.c +++ b/src/mmpars.c @@ -162,8 +162,8 @@ char *readRawSource(vstring fileBuf, long *size) { if (fbPtr != fileBuf + charCount) { /* To help debugging: */ - printf("fbPtr=%ld fileBuf=%ld charCount=%ld diff=%ld\n", - (long)fbPtr, (long)fileBuf, charCount, fbPtr - fileBuf - charCount); + printf("fbPtr=%p fileBuf=%p charCount=%ld diff=%ld\n", + (void*)fbPtr, (void*)fileBuf, charCount, fbPtr - fileBuf - charCount); bug(1704); } From 180c46d63d2619d97854a9e369aa4d98ef5c9d70 Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Wed, 9 Feb 2022 03:20:29 -0500 Subject: [PATCH 3/6] fix cast --- src/mmpars.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mmpars.c b/src/mmpars.c index 4c1e1e16..938c6070 100644 --- a/src/mmpars.c +++ b/src/mmpars.c @@ -163,7 +163,7 @@ char *readRawSource(vstring fileBuf, long *size) { if (fbPtr != fileBuf + charCount) { /* To help debugging: */ printf("fbPtr=%p fileBuf=%p charCount=%ld diff=%ld\n", - (void*)fbPtr, (void*)fileBuf, charCount, fbPtr - fileBuf - charCount); + (void*)fbPtr, (void*)fileBuf, charCount, (long)(fbPtr - fileBuf) - charCount); bug(1704); } From 6bea545527f03d6a061acac0ef5a66c59ce192b0 Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Wed, 9 Feb 2022 03:22:29 -0500 Subject: [PATCH 4/6] test --- src/metamath.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/metamath.c b/src/metamath.c index 7c774ac7..46ebfd31 100644 --- a/src/metamath.c +++ b/src/metamath.c @@ -725,7 +725,7 @@ void command(int argc, char *argv[]); * \param argc int number of commandline parameters * \param argv (char*)[] array of \a argc commandline parameters, followed by NULL * \return success 0 else failure - * + * * Running metamath * ./metamath 'read set.mm' 'verify proof *' * will start main with \a argc set to 2, argv[0] to "read set.mm", argv[1] @@ -752,6 +752,8 @@ int main(int argc, char *argv[]) { g_toolsMode = g_listMode; + printf("Testing basic printing functionality\n"); + if (!g_listMode) { /*print2("Metamath - Version %s\n", MVERSION);*/ print2("Metamath - Version %s%s", MVERSION, space(27 - (long)strlen(MVERSION))); From 959672d2937016916ccacb615865ff287d816427 Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Wed, 9 Feb 2022 03:48:32 -0500 Subject: [PATCH 5/6] fix for 4 byte long --- src/mmdata.c | 15 ++++++++------- src/mmdata.h | 14 +++++++------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/mmdata.c b/src/mmdata.c index f50c5c47..a5dc9564 100644 --- a/src/mmdata.c +++ b/src/mmdata.c @@ -2410,20 +2410,21 @@ temp_pntrString *pntrCat(const pntrString *string1,...) { } +#define pntrPoolLoc(s) (size_t)((s)[-3]) +#define pntrAllocSize(s) (size_t)((s)[-2]) +#define pntrActualSize(s) (size_t)((s)[-1]) /* Find out the length of a pntrString */ long pntrLen(const pntrString *s) { /* Assume it's been allocated with poolMalloc. */ - return ((((const long *)s)[-1] - (long)(sizeof(pntrString))) - / (long)(sizeof(pntrString))); + return (pntrActualSize(s) - sizeof(pntrString)) / sizeof(pntrString); } /* Find out the allocated length of a pntrString */ long pntrAllocLen(const pntrString *s) { - return ((((long *)s)[-2] - (long)(sizeof(pntrString))) - / (long)(sizeof(pntrString))); + return (pntrAllocSize(s) - sizeof(pntrString)) / sizeof(pntrString); } /* Set the actual size field in a pntrString allocated with poolFixedMalloc() */ @@ -2435,12 +2436,12 @@ long pntrAllocLen(const pntrString *s) { /* ???Note that pntrZapLen's not moving string to used pool wastes potential space when called by the routines in this module. Effect should be minor. */ void pntrZapLen(pntrString *s, long length) { - if (((long *)s)[-3] != -1) { + if (pntrPoolLoc(s) != (size_t)-1) { /* It's already in the used pool, so adjust free space tally */ - poolTotalFree = poolTotalFree + ((long *)s)[-1] + poolTotalFree = poolTotalFree + (long)pntrActualSize(s) - (length + 1) * (long)(sizeof(pntrString)); } - ((long *)s)[-1] = (length + 1) * (long)(sizeof(pntrString)); + ((size_t *)s)[-1] = (size_t)(length + 1) * sizeof(pntrString); /*E*/if(db9)getPoolStats(&i1,&j1_,&k1); if(db9)printf("l: pool %ld stat %ld\n",poolTotalFree,i1+j1_); } diff --git a/src/mmdata.h b/src/mmdata.h index ca83b17b..4106e77a 100644 --- a/src/mmdata.h +++ b/src/mmdata.h @@ -21,7 +21,7 @@ */ typedef char flag; -/*! +/*! * \var flag g_listMode. * Obsolete. Now fixed to 0. Historically the metamath sources were also used * for other purposes than maintaining Metamath files. One such application, a @@ -259,22 +259,22 @@ extern struct nullNmbrStruct g_NmbrNull; /*! * \struct nullPntrStruct * describing a block of memory of pntrString containing only the - * null pointer. * + * null pointer. * */ /* Null pntrString -- NULL flags the end of a pntrString */ struct nullPntrStruct { /*! - * + * */ - long poolLoc; + size_t poolLoc; /*! allocated size of the memory block containing the \a pntrString. * Note: this is the number of bytes, not elements! */ - long allocSize; + size_t allocSize; /*! currently used size of the memory block containing the \a pntrString. * Note: this is the number of bytes, not elements! */ - long actualSize; + size_t actualSize; pntrString nullElement; }; extern struct nullPntrStruct g_PntrNull; #define NULL_PNTRSTRING &(g_PntrNull.nullElement) @@ -476,7 +476,7 @@ temp_pntrString *pntrPSpace(long n); /*! * \fn long pntrLen(const pntrString* s) Determine the length of a pntrString * \param s \a pntrString array of pointers from its hidden structure. - * \pre s has a hidden structure, see \a pntrString + * \pre s has a hidden structure, see \a pntrString */ long pntrLen(const pntrString *s); long pntrAllocLen(const pntrString *s); From 048532b9aeddcfd6f112d9940cad418202502123 Mon Sep 17 00:00:00 2001 From: Mario Carneiro Date: Wed, 9 Feb 2022 05:02:24 -0500 Subject: [PATCH 6/6] test --- src/metamath.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/metamath.c b/src/metamath.c index 46ebfd31..4c9ce6cd 100644 --- a/src/metamath.c +++ b/src/metamath.c @@ -752,7 +752,8 @@ int main(int argc, char *argv[]) { g_toolsMode = g_listMode; - printf("Testing basic printing functionality\n"); + printf("sizeof(long) = %ld\n", sizeof(long)); + printf("len(null) = %ld\n", pntrLen(NULL_PNTRSTRING)); if (!g_listMode) { /*print2("Metamath - Version %s\n", MVERSION);*/