Jens Staal dixit:

> Apparently, by passing -L to Build.sh, ape/cc can build without a workaround.

That will build lksh, not mksh, which is an entirely different thing.

But that means we know more closely which of the assertions fail(s):

#ifndef MKSH_LEGACY_MODE
/* the next assertion is probably not really needed */
cta(ari_is_4_char, sizeof(mksh_ari_t) == 4);
/* but this is */
cta(ari_has_31_bit, 0 < (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 
1));
/* the next assertion is probably not really needed */
cta(uari_is_4_char, sizeof(mksh_uari_t) == 4);
/* but the next three are; we REQUIRE unsigned integer wraparound */
cta(uari_has_31_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 2 
+ 1));
cta(uari_has_32_bit, 0 < (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 
+ 3));
cta(uari_wrap_32_bit,
    (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3) >
    (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 4));
#endif

This means that either
– mksh_ari_t (typedef’d to int32_t which is most likely typedef’d
  to “signed int”) is not 4 chars wide,
– mksh_ari_t is not at least 31 bit plus sign bit wide,
– mksh_uari_t (same as mksh_ari_t except unsigned) is not 4 chars wide,
– mksh_uari_t has less or more than 32 bits.

> Does this mean that I should try to put in a test for "unknown" compiler on
> Plan9 early in the script and trigger "legacy"?

Absolutely not!

> The gcc port on Plan9 can build without any modifications to Build.sh (except
> the re-definitions for seteuid and setegid).

Interesting.

Try this, with both of them:

---------------------------------------------------------------->8
#include <stdio.h>
#ifdef attempt1
#include <stdint.h>
#endif

#ifdef attempt2
typedef u_int32_t uint32_t;
#endif
#ifdef attempt3
typedef signed int int32_t;
typedef unsigned int uint32_t;
#endif

typedef int32_t mksh_ari_t;
typedef uint32_t mksh_uari_t;

int
main(void)
{
        mksh_ari_t i;
        mksh_uari_t u, v;

        printf("sizes: %u %u\n", (unsigned)sizeof(mksh_ari_t), 
(unsigned)sizeof(mksh_uari_t));
        i = (mksh_ari_t)(((((mksh_ari_t)1 << 15) << 15) - 1) * 2 + 1);
        printf("ari_has_31_bit: 0 < %X = %d\n", (unsigned)i, 0 < i);
        u = (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 2 + 1);
        printf("uari_has_31_bit: 0 < %X = %d\n", (unsigned)u, 0 < u);
        u = (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 3);
        printf("uari_has_32_bit: 0 < %X = %d\n", (unsigned)u, 0 < u);
        v = (mksh_uari_t)(((((mksh_uari_t)1 << 15) << 15) - 1) * 4 + 4);
        printf("uari_wrap_32_bit: %X > %X = %d\n", (unsigned)u, (unsigned)v, u 
> v);

        return (0);
}
---------------------------------------------------------------->8

Define -Dattempt1 and, only if that doesn’t work, -Dattempt2 instead
or even -Dattempt3.

bye,
//mirabilos
-- 
In traditional syntax ' is ignored, but in c99 everything between two ' is
handled as character constant.  Therefore you cannot use ' in a preproces-
sing file in c99 mode.  -- Ragge
No faith left in ISO C99, undefined behaviour, etc.

Reply via email to