Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Test for the size of struct http_parser fails on 32 bit systems where there is padding/alignment for void* #526

Description

@frmichael

Bonjour,

Porting http-parser to AIX, where there are 32 and 64 bit environments, there is a test on sizeof (struct http_parser) which fails due to 8 byte reservation for void* on both 32 and 64 bit compiles.

A clean option might be to change the void data element of struct http_parser to be a union of uint64 and void.

But this may not work if the 32 bit size of struct http_parser must remain at a total of 28 bytes (and in which case the test is in correct).

However, supposing that this is an error in the test code, I provisionally used the following patch for the 32 bit build

--- ./test.c.ORIG       2020-11-27 22:02:53 +0100
+++ ./test.c    2020-11-27 22:57:18 +0100
@@ -4234,7 +4234,7 @@
   printf("http_parser v%u.%u.%u (0x%06lx)\n", major, minor, patch, version);
 
   printf("sizeof(http_parser) = %u\n", (unsigned int)sizeof(http_parser));
-  assert(sizeof(http_parser) == 4 + 4 + 8 + 2 + 2 + 4 + sizeof(void *));
+  assert(sizeof(http_parser) == 4 + 4 + 8 + 2 + 2 + 4 + 2*sizeof(void *));
 
   //// API
   test_preserve_data();

We would like to ask for your expert advice on how best to resolve this issue.

Thanks.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions