Skip to content

Fixes for Watcom compiler and new CI test#8391

Merged
SparkiDev merged 2 commits intowolfSSL:masterfrom
dgarske:cmake_watcom
Feb 5, 2025
Merged

Fixes for Watcom compiler and new CI test#8391
SparkiDev merged 2 commits intowolfSSL:masterfrom
dgarske:cmake_watcom

Conversation

@dgarske
Copy link
Copy Markdown
Member

@dgarske dgarske commented Jan 29, 2025

Description

Fixes for Watcom compiler and new CI test

Testing

See new CI test

Checklist

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 29, 2025

Below is Github Action definition file modified to automate any host and any target with Open Watcom toolchain by matrix.
Linux build on Linux host and Windows build on Windows host is active, it will be possible to use it for testing.
OS/2 build on Windows host (cross-compile) is commented out, because WolfSSL codebase was not checked for this target now.

name: Build Watcom C

# START OF COMMON SECTION
on:
  push:
    branches: [ 'master', 'main', 'release/**' ]
  pull_request:
    branches: [ '*' ]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
# END OF COMMON SECTION

jobs:
  wolfssl_watcomc_windows:
    if: github.repository_owner == 'wolfssl'
    strategy:
      fail-fast: false
      matrix:
        platform:
          - title:   'Windows OW 2.0'
            system:   'Windows' 
            image:    'windows-latest'
            owimage:  '2.0'
          - title:   'Linux OW 2.0'
            system:   'Linux'
            image:    'ubuntu-latest'
            owimage:  '2.0'
          #- title:   'OS/2 OW 2.0'
          #  system:   'OS2' 
          #  image:    'windows-latest'
          #  owimage:  '2.0'
    runs-on: ${{ matrix.platform.image }}
    name: ${{ matrix.platform.title }}
    steps:
      - name: Setup Open Watcom ${{ matrix.platform.owimage }}
        uses: open-watcom/setup-watcom@v0
        with:
          version: ${{ matrix.platform.owimage }}

      - name: Checkout wolfSSL
        uses: actions/checkout@v4
        with:
          path: wolfssl

      - name: Build wolfSSL
        working-directory: wolfssl
        shell: bash
        run: |
          cmake -B build -G "Watcom WMake" -D CMAKE_VERBOSE_MAKEFILE=TRUE -D CMAKE_SYSTEM_NAME=${{ matrix.platform.system }} -D CMAKE_SYSTEM_PROCESSOR=x86 -D WOLFSSL_ASM=no -D WOLFSSL_SINGLE_THREADED=yes -D BUILD_SHARED_LIBS=no -D WOLFSSL_EXAMPLES=no -D WOLFSSL_CRYPT_TESTS=no
          cmake --build build

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Jan 29, 2025

Below is Github Action definition file modified to automate any host and any target with Open Watcom toolchain by matrix. Linux build on Linux host and Windows build on Windows host is active, it will be possible to use it for testing. OS/2 build on Windows host (cross-compile) is commented out, because WolfSSL codebase was not checked for this target now.

name: Build Watcom C

# START OF COMMON SECTION
on:
  push:
    branches: [ 'master', 'main', 'release/**' ]
  pull_request:
    branches: [ '*' ]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
# END OF COMMON SECTION

jobs:
  wolfssl_watcomc_windows:
    if: github.repository_owner == 'wolfssl'
    strategy:
      fail-fast: false
      matrix:
        platform:
          - title:   'Windows OW 2.0'
            system:   'Windows' 
            image:    'windows-latest'
            owimage:  '2.0'
          - title:   'Linux OW 2.0'
            system:   'Linux'
            image:    'ubuntu-latest'
            owimage:  '2.0'
          #- title:   'OS/2 OW 2.0'
          #  system:   'OS2' 
          #  image:    'windows-latest'
          #  owimage:  '2.0'
    runs-on: ${{ matrix.platform.image }}
    name: ${{ matrix.platform.title }}
    steps:
      - name: Setup Open Watcom ${{ matrix.platform.owimage }}
        uses: open-watcom/setup-watcom@v0
        with:
          version: ${{ matrix.platform.owimage }}

      - name: Checkout wolfSSL
        uses: actions/checkout@v4
        with:
          path: wolfssl

      - name: Build wolfSSL
        working-directory: wolfssl
        shell: bash
        run: |
          cmake -B build -G "Watcom WMake" -D CMAKE_VERBOSE_MAKEFILE=TRUE -D CMAKE_SYSTEM_NAME=${{ matrix.platform.system }} -D CMAKE_SYSTEM_PROCESSOR=x86 -D WOLFSSL_ASM=no -D WOLFSSL_SINGLE_THREADED=yes -D BUILD_SHARED_LIBS=no -D WOLFSSL_EXAMPLES=no -D WOLFSSL_CRYPT_TESTS=no
          cmake --build build

Wonderful! I'll give this a try. Thank you!

@dgarske dgarske removed their assignment Jan 30, 2025
Copy link
Copy Markdown
Contributor

@JacobBarthelmeh JacobBarthelmeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve merge conflict

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 30, 2025

Hi @dgarske,

I have prepared regular fixes for Open Watcom against current version of WolfSSL repository that All build of WolfSSL is going OK for Windows multi-threaded version (32-bit).
There are many fixes unrelated to Open Watcom but rather to C89 standard.
Is it acceptable to use C89 things for newer standards if no collision or must be guarded by WOLFSSL_C89?
What C standard should be used by default C99?
Please how I can submit it somewhere or I need create new PR?
I have no access to dgarske:cmake_watcom that I cannot submit it there.
Or I must create patch file and put it here.

Thanks

Jiri

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Jan 30, 2025

Hi Jiri,

We'd love to get it working with the C89 compliance level, since we have customers using that even with Watcom C.

I am about to rebase this PR and force push to resolve a merge conflict. You are welcome to share a patch and I can add it. OR
You can open a new PR once this one is merged. Now that you are setup as an approved contributor it's easy to accept works you submit.

Thanks,
David Garske, wolfSSL

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 30, 2025

OK I will separate fixes relate to C89, it is mainly initilization by non-constant values and sometimes definition of variables in code.
There is also issue related to mixing winsock.h and winsock2.h.
I don't know what you suppose somewhere are used header files which include winsock2.h that it looks like code should use only winsock2.h then blocking of winsock.h should be implemented.
Anyway I get full compile for Windows (multi-threaded) including all examples and test programs.
Is ti possiblu to run somehow these test programs to check results?

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Jan 30, 2025

OK I will separate fixes relate to C89, it is mainly initilization by non-constant values and sometimes definition of variables in code. There is also issue related to mixing winsock.h and winsock2.h. I don't know what you suppose somewhere are used header files which include winsock2.h that it looks like code should use only winsock2.h then blocking of winsock.h should be implemented. Anyway I get full compile for Windows (multi-threaded) including all examples and test programs. Is ti possiblu to run somehow these test programs to check results?

In your PR I recommend trying to remove the -DWOLFSSL_CRYPT_TESTS=no to enable the wolfcrypttest and running that at a minimum.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 30, 2025

OK I will try.
I enclosed 3 patch files divided by areas

  • C89 fixes, mostly test sources
  • winsock.h issue fixes
  • all Open Watcom fixes

Open Watcom fixes requires C89 fixes and winsock too or some alternative solution
c89-fixes.patch
watcom-build.patch
winsock-fixes.patch

Build tested with Open Watcom 1.9 and 2.0

!! it is fixes only for Windows target !!
Linux will be next. That now will be best to stop CI-build for Linux.

There is some duplication code for thread support, but it is prepared for OS/2 build changes. Now it is same as for Microsoft compilers with small differences.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 31, 2025

Sorry, one mistake.
It is patch
api.c.patch
latest version of api.c file

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Jan 31, 2025

@jmalak let me know if you have suggestions to fix:
https://github.com/wolfSSL/wolfssl/actions/runs/13063975498/job/36452955791?pr=8391

	wcc386 D:\a\wolfssl\wolfssl\wolfssl\wolfcrypt\src\hmac.c  -d+ -DBUILDING_WOLFSSL -DECC_SHAMIR -DECC_TIMING_RESISTANT -DGCM_TABLE_4BIT -DHAVE_AESGCM -DHAVE_CHACHA -DHAVE_CONFIG_H -DHAVE_DH_DEFAULT_PARAMS -DHAVE_ECC -DHAVE_ENCRYPT_THEN_MAC -DHAVE_EXTENDED_MASTER -DHAVE_FFDHE_2048 -DHAVE_HASHDRBG -DHAVE_HKDF -DHAVE_ONE_TIME_AUTH -DHAVE_POLY1305 -DHAVE_SNI -DHAVE_SUPPORTED_CURVES -DHAVE_THREAD_LS -DHAVE_TLS_EXTENSIONS -DNO_CHACHA_ASM -DNO_DES3 -DNO_DES3_TLS_SUITES -DNO_DSA -DNO_MD4 -DNO_PSK -DNO_RC4 -DSINGLE_THREADED -DTFM_ECC256 -DTFM_NO_ASM -DTFM_TIMING_RESISTANT -DWC_NO_ASYNC_THREADING -DWC_RSA_BLINDING -DWC_RSA_PSS -DWOLFSSL_HAVE_MIN -DWOLFSSL_HAVE_MAX -DNO_WRITEV -DWOLFSSL_IGNORE_FILE_WARN -DWOLFSSL_NO_ASM -DWOLFSSL_NO_SHAKE128 -DWOLFSSL_NO_SHAKE256 -DWOLFSSL_PSS_LONG_SALT -DWOLFSSL_SHA384 -DWOLFSSL_SHA512 -DWOLFSSL_SYS_CA_CERTS -DWOLFSSL_TLS13 -DWOLFSSL_USE_ALIGN -I"D:\a\wolfssl\wolfssl\wolfssl" -I"D:\a\wolfssl\wolfssl\wolfssl\build" -I"C:\Users\runneradmin\WATCOM\h" -I"C:\Users\runneradmin\WATCOM\h\nt" -w3 -bt=nt -dWIN32 -br -bm -wx -wcd=202 -d2 -foCMakeFiles\wolfssl.dir\wolfcrypt\src\hmac.c.obj
Open Watcom C x86 32-bit Optimizing Compiler
Version 2.0 beta Jan 29 2025 02:09:25 (32-bit)
Copyright (c) 2002-2025 The Open Watcom Contributors. All Rights Reserved.
Portions Copyright (c) 1984-2002 Sybase, Inc. All Rights Reserved.
Source code is available under the Sybase Open Watcom Public License.
See https://github.com/open-watcom/open-watcom-v2#readme for details.
D:\a\wolfssl\wolfssl\wolfssl\wolfssl\wolfcrypt\wc_port.h(981): Error! E1022: Missing or misspelled data type near 'WIN32_FIND_DATAA'
D:\a\wolfssl\wolfssl\wolfssl\wolfssl\wolfcrypt\wc_port.h(982): Error! E1022: Missing or misspelled data type near 'HANDLE'
D:\a\wolfssl\wolfssl\wolfssl\wolfcrypt\src\hmac.c: 1453 lines, included 46766, 0 warnings, 2 errors
Error: Unable to invoke "C:\Users\runneradmin\WATCOM\BINNT\wcc386.exe"
Error(E42): Last command making (CMakeFiles\wolfssl.dir\wolfcrypt\src\hmac.c.obj) returned a bad status
Error(E02): Make execution terminated
Error(E42): Last command making (CMakeFiles\wolfssl.dir\all) returned a bad status
Error(E02): Make execution terminated
Error(E42): Last command making (all) returned a bad status
Error(E02): Make execution terminated

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 31, 2025

I am running CMake by command

cmake -B build -G "Watcom WMake" -D CMAKE_VERBOSE_MAKEFILE=TRUE -D CMAKE_SYSTEM_NAME=Windows -D CMAKE_SYSTEM_PROCESSOR=x86 -D WOLFSSL_ASM=no -DCMAKE_BUILD_TYPE=Release

I will check with your setup, it looks like some mistake if single-thread configuration is used, I didn't check I am building multi-threaded version only on Windows

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 31, 2025

You should fix wc_port.h

to contains windows.h for both multi and single threaded build

/* THREADING/MUTEX SECTION */
#if defined(__WATCOMC__)
    #if !defined(SINGLE_THREADED)
        #if defined(WOLFSSL_PTHREADS)
            #include <pthread.h>
        #else
            #if defined(USE_WINDOWS_API)
                #define _WINSOCKAPI_
                #include <windows.h>
            #endif
            #include <process.h>
        #endif
    #else
        #if defined(USE_WINDOWS_API)
            #define _WINSOCKAPI_
            #include <windows.h>
        #endif
    #endif
#elif defined(SINGLE_THREADED) && defined(NO_FILESYSTEM)
    /* No system headers required for build. */

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 31, 2025

I got following results on Windows now

------------------------------------------------------------------------------
 wolfSSL version 5.7.6
------------------------------------------------------------------------------
error    test passed!
MEMORY   test passed!
base64   test passed!
asn      test passed!
RANDOM   test passed!
MD5      test passed!
SHA      test passed!
SHA-256  test passed!
SHA-384  test passed!
SHA-512  test passed!
SHA-512/224  test passed!
SHA-512/256  test passed!
Hash     test passed!
HMAC-MD5 test passed!
HMAC-SHA test passed!
HMAC-SHA256 test passed!
HMAC-SHA384 test passed!
HMAC-SHA512 test passed!
HMAC-KDF    test passed!
PRF         test passed!
TLSv1.3 KDF test passed!
GMAC     test passed!
Chacha   test passed!
POLY1[30](https://github.com/jmalak/wolfssl/actions/runs/13064840797/job/36455306981#step:7:31)5 test passed!
ChaCha20-Poly1305 AEAD test passed!
AES      test passed!
AES192   test passed!
AES256   test passed!
AES-CBC  test passed!
AES-GCM  test passed!
RSA      test passed!
DH       test passed!
PWDBASED test passed!
ECC      test passed!
logging  test passed!
time     test passed!
mutex    test passed!
memcb    test passed!
Test complete
Exiting main with return code: 0

and benchmarks

------------------------------------------------------------------------------
 wolfSSL version 5.7.6
------------------------------------------------------------------------------
wolfCrypt Benchmark (block bytes 1048576, min 1.0 sec each)
RNG                         25 MiB took 1.010 seconds,   24.747 MiB/s
AES-1[28](https://github.com/jmalak/wolfssl/actions/runs/13064840797/job/36455306981#step:8:29)-CBC-enc             55 MiB took 1.096 seconds,   50.191 MiB/s
AES-128-CBC-dec             55 MiB took 1.058 seconds,   51.980 MiB/s
AES-192-CBC-enc             50 MiB took 1.043 seconds,   47.946 MiB/s
AES-192-CBC-dec             50 MiB took 1.019 seconds,   49.073 MiB/s
AES-256-CBC-enc             50 MiB took 1.103 seconds,   45.333 MiB/s
AES-256-CBC-dec             50 MiB took 1.065 seconds,   46.970 MiB/s
AES-128-GCM-enc             40 MiB took 1.077 seconds,   37.127 MiB/s
AES-128-GCM-dec             40 MiB took 1.077 seconds,   37.139 MiB/s
AES-192-GCM-enc             40 MiB took 1.112 seconds,   35.962 MiB/s
AES-192-GCM-dec             40 MiB took 1.113 seconds,   35.926 MiB/s
AES-256-GCM-enc             35 MiB took 1.016 seconds,   34.465 MiB/s
AES-256-GCM-dec             35 MiB took 1.024 seconds,   34.174 MiB/s
GMAC Table 4-bit           127 MiB took 1.000 seconds,  126.950 MiB/s
CHACHA                     110 MiB took 1.008 seconds,  109.153 MiB/s
CHA-POLY                    35 MiB took 1.004 seconds,   34.857 MiB/s
MD5                        380 MiB took 1.003 seconds,  378.879 MiB/s
POLY1305                    50 MiB took 1.000 seconds,   49.998 MiB/s
SHA                        160 MiB took 1.004 seconds,  159.407 MiB/s
SHA-256                     60 MiB took 1.066 seconds,   56.276 MiB/s
SHA-384                     25 MiB took 1.009 seconds,   24.783 MiB/s
SHA-512                     25 MiB took 1.008 seconds,   24.800 MiB/s
SHA-512/224                 25 MiB took 1.008 seconds,   24.808 MiB/s
SHA-512/256                 25 MiB took 1.007 seconds,   24.815 MiB/s
HMAC-MD5                   380 MiB took 1.005 seconds,  377.952 MiB/s
HMAC-SHA                   160 MiB took 1.004 seconds,  159.353 MiB/s
HMAC-SHA256                 60 MiB took 1.064 seconds,   56.384 MiB/s
HMAC-SHA384                 25 MiB took 1.007 seconds,   24.814 MiB/s
HMAC-SHA512                 25 MiB took 1.005 seconds,   24.864 MiB/s
PBKDF2                       7 KiB took 1.002 seconds,    6.921 KiB/s
RSA     2048   public      1700 ops took 1.035 sec, avg 0.609 ms, 1642.0[29](https://github.com/jmalak/wolfssl/actions/runs/13064840797/job/36455306981#step:8:30) ops/sec
RSA     2048  private       100 ops took 3.817 sec, avg 38.172 ms, 26.197 ops/sec
DH      2048  key gen       131 ops took 1.004 sec, avg 7.668 ms, 1[30](https://github.com/jmalak/wolfssl/actions/runs/13064840797/job/36455306981#step:8:31).415 ops/sec
DH      2048    agree       100 ops took 1.778 sec, avg 17.781 ms, 56.240 ops/sec
ECC   [      SECP256R1]   256  key gen       200 ops took 1.004 sec, avg 5.019 ms, 199.234 ops/sec
ECDHE [      SECP256R1]   256    agree       200 ops took 1.005 sec, avg 5.026 ms, 198.957 ops/sec
ECDSA [      SECP256R1]   256     sign       200 ops took 1.012 sec, avg 5.062 ms, 197.540 ops/sec
ECDSA [      SECP256R1]   256   verify       400 ops took 1.[32](https://github.com/jmalak/wolfssl/actions/runs/13064840797/job/36455306981#step:8:33)1 sec, avg 3.303 ms, 302.725 ops/sec
Benchmark complete

It is pure C code without assembler code.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Jan 31, 2025

I am in trouble with Linux target.
It is little bit odd how _POSIX_THREADS macro is used in WolfSSL.
As C standard say this symbols is from compiler reserved name space, that it is control by implementation.
WolfSSL manipulate with this macro as user macro.
Now I have a problem with Open Watcom implementation which report multiple different definition of _POSIX_THREADS macro.

Why WolfSSL touch _POSIX_THREADS macro (it is not permitted by C standard) instead of create own macro with regards of _POSIX_THREADS macro value and without such collision.

JacobBarthelmeh
JacobBarthelmeh previously approved these changes Feb 1, 2025
@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 1, 2025

I did correction to your watcomc.yml to synchronize OW tools options with WolfSSL macros setup which is incorrect.
It means shared/static libraries and single/multi-threading version.

watcomc.yml.patch

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 3, 2025

Hi David,

I am in trouble with two general issues.

  • manipulation with _POSIX_THREADS macro in CMake script
if(NOT WOLFSSL_SINGLE_THREADED)
    if(CMAKE_USE_PTHREADS_INIT)
        list(APPEND WOLFSSL_LINK_LIBS Threads::Threads)
        set(HAVE_PTHREAD 1)
        list(APPEND WOLFSSL_DEFINITIONS
            "-DHAVE_PTHREAD"
            "-D_POSIX_THREADS")                <<<- incorrect should be removed, it is defined by POSIX standard in header
                                                                          files with appropriate value
    endif()
else()
    list(APPEND WOLFSSL_DEFINITIONS "-DSINGLE_THREADED")
endif()
  • problem with OFFSETOF macro which is defined in types.h
    #ifndef OFFSETOF
        #if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4))
            #define OFFSETOF(type, field) __builtin_offsetof(type, field)
        #else
            #define OFFSETOF(type, field) ((size_t)&(((type *)0)->field))
        #endif
    #endif

first it is same as C standard macro offsetof that it is redundant against C standard (any), it is in stddef.h that it could be replaced
It help me because standard OS/2 header file use it for different purpose with different number of parameters
Now I am not able to build any application because it is used in TCP/IP related header file
I cannot redefine it because it's definition is on the top of include files.

Is it possible to do these changes, I don't know reason why it was done this way, maybe on some platforms is necessary for some reason.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 3, 2025

here is latest patch
cmake_watcom.patch
to your branch which should fix remaining issues with pthreads and Linux build and start with OS/2 build.
I started implement OS/2 thread functions which are necessary to test.
There is defined all necessary functions that it compile now, but they have blank body.
As soon as I will finish OS/2 version and if pass tests on OS/2 then I send patch.
Now Windows and Linux is buildable in single-threaded and multi-threaded versions and pass all test.
I think it is OK now that I will continue only on OS/2 version.

Regards

Jiri

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 3, 2025

I enclosed fix for OFFSETOF macro issue which I am using
offsetof.patch

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Feb 3, 2025

I enclosed fix for OFFSETOF macro issue which I am using offsetof.patch

I am trying to avoid this refactor from OFFSETOF -> offsetof. My patching attempts have failed and still getting:

wolfcrypt/src/asn.c(6596): Warning! W1056: Too many parameters given for macro 'OFFSETOF'
wolfcrypt/src/asn.c(6596): Error! E1063: Missing operand

Can you explain why this patch doesn't work?
https://github.com/wolfSSL/wolfssl/pull/8391/files/eeba15cc78cb687a5821d08779e41607728a9894..0e055634e99eaab892d353b5ec68a734218e6ccf

I used the same OS2 offsetof macro in stddef.h.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 3, 2025

Problem is multiple definition of macro OFFSETOF
below is part of OS/2 system header file os2def.h (one of most important) which use it

#define FAR
#define NEAR

#define MAKEP( sel,off )   ((void *)(void * _Seg16)( (sel) << 16 | (off) ))
#define MAKE16P( sel,off ) ((void * _Seg16)( (sel) << 16 | (off) ))

#define SELECTOROF(ptr)    ((((ULONG)(ptr))>>13)|7)
#define OFFSETOF(p)        (((PUSHORT)&(p))[0])

#define MAKETYPE(v, type)  (*((type *)&v))

#define FIELDOFFSET(type, field)   ((SHORT)&(((type *)0)->field))

and current definition OFFSETOF in WolfSSL

    #ifndef OFFSETOF
        #ifdef __WATCOMC__
            /* macro from watcom c offsetof in stddef.h */
            #define OFFSETOF(__typ, __id) \
                ((size_t)((char *)&(((__typ*)0)->__id) - (char *)0))
        #elif defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4))
            #define OFFSETOF(type, field) __builtin_offsetof(type, field)
        #else
            #define OFFSETOF(type, field) ((size_t)&(((type *)0)->field))
        #endif
    #endif

But WolfSSL definition is always before OS/2 headers that it report different definition.

Problem is that I cannot rename Operating system definition of OFFSETOF to different name that only solution is rename it in WolfSSL because it is luckily internal macro and also it is same as C standard macro offsetof (stddef.h) which should be used instead OFFSETOF. offsetof macro must be defined in any toolchain because it is part of C from K&R epoch.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 4, 2025

by example gcc 11 and 12 has it defined on Linux as

#define offsetof(TYPE, MEMBER) __builtin_offsetof (TYPE, MEMBER)

in OW it is

#define offsetof(__typ,__id) ((size_t)((char )&(((__typ)0)->__id) - (char *)0))

every toolchain has own definition which cover defined function offset of member in structure as described in C standard.

Visual studio 2022

#if defined _MSC_VER && !defined _CRT_USE_BUILTIN_OFFSETOF
#ifdef __cplusplus
#define offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))
#else
#define offsetof(s,m) ((size_t)&(((s*)0)->m))
#endif
#else
#define offsetof(s,m) __builtin_offsetof(s,m)
#endif

* Correct cmake script to support Open Watcom toolchain (wolfSSL#8167)
* Fix thread start callback prototype for Open Watcom toolchain (wolfSSL#8175)
* Added GitHub CI action for Windows/Linux/OS2
* Improvements for C89 compliance.
Thank you @jmalak for your contributions.
Comment thread CMakeLists.txt
Comment thread CMakeLists.txt
Comment thread src/ssl_load.c Outdated
@dgarske dgarske requested a review from jmalak February 4, 2025 23:22
@dgarske dgarske assigned wolfSSL-Bot and unassigned dgarske Feb 4, 2025
@dgarske dgarske requested review from SparkiDev and removed request for jmalak February 4, 2025 23:33
@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 5, 2025

I enclosed new OFFSETOF patch, which could be acceptable.
OFFSETOF.patch

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Feb 5, 2025

I enclosed new OFFSETOF patch, which could be acceptable. OFFSETOF.patch

This could work, but I'll need to make sure there aren't any customers overriding OFFSETOF.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 5, 2025

I add also support for Open Watcom 1.9 and add apropriate tests.
cmake_watcom.patch
it doesn't have POSIX threads for Linux .that only single-threaded version is build on Linux.

@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Feb 5, 2025

I add also support for Open Watcom 1.9 and add apropriate tests. cmake_watcom.patch it doesn't have POSIX threads for Linux .that only single-threaded version is build on Linux.

Very nice work! I'll need a bit of time to integrate these changes. Thank you again @jmalak

@dgarske dgarske assigned dgarske and unassigned wolfSSL-Bot Feb 5, 2025
@SparkiDev SparkiDev merged commit e6ceb40 into wolfSSL:master Feb 5, 2025
@dgarske
Copy link
Copy Markdown
Member Author

dgarske commented Feb 5, 2025

I add also support for Open Watcom 1.9 and add apropriate tests. cmake_watcom.patch it doesn't have POSIX threads for Linux .that only single-threaded version is build on Linux.

Very nice work! I'll need a bit of time to integrate these changes. Thank you again @jmalak

Well the PR got merged in. If you want to open a followup PR with those proposed changes, feel free to. I hadn't updated the PR with your patch. I think the OFFSETOF changes will be okay.

@jmalak
Copy link
Copy Markdown
Contributor

jmalak commented Feb 6, 2025

OK I will include it with other OS/2 changes when I will finish (still not finished implementation), because it is showstopper for OS/2 version only not for other targets.

Regards Jiri

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants