Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903777

jextract layout for enum with big constant values is wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • None
    • None
    • tools
    • None

      This was reported in jextract-dev alias

      https://mail.openjdk.org/pipermail/jextract-dev/2024-July/001843.html

      The test file struct.h

      #include <stdint.h>

      typedef enum
      {
          EnumDef_Undefined = -1,
          EnumDef_Big = 0x80000000

      } EnumDef;

      typedef struct structType
      {
              EnumDef someEnum;
              uint64_t bigNumber;
      } value;

      On Mac and Linux, the layout generated is as follows:

      private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
              foo_h.C_INT.withName("someEnum"),
              foo_h.C_LONG.withName("bigNumber")
          ).withName("structType");

      Layout on Windows is as follows:

      private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
              struct_h.C_INT.withName("someEnum"),
              MemoryLayout.paddingLayout(4),
              struct_h.C_LONG_LONG.withName("bigNumber")
          ).withName("structType");

            mcimadamore Maurizio Cimadamore
            sundar Sundararajan Athijegannathan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: