alicelinux

A lightweight musl + clang/llvm + libressl + busybox distro
git clone https://codeberg.org/emmett1/alicelinux
Log | Files | Refs | README | LICENSE

nasm-3.01-musl.patch (3760B)


      1 https://github.com/netwide-assembler/nasm/commit/44e89ba9b650b5e1533bca43682e167f51a3511f
      2 From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
      3 Date: Sun, 12 Oct 2025 12:48:32 -0700
      4 Subject: [PATCH] compiler.h: drop the stupid C++-style cast-to-bool hack
      5 
      6 The C++-style cast-to-bool hack was broken in concept that it doesn't help the
      7 fundamental problem -- implicit conversions are broken for the
      8 backwards compatibility enum definition -- as well as in
      9 implementation, as it misspelled __STDC_VERSION__ as __STDC_VERSION.
     10 
     11 The #ifdef bool test *should* have prevented this problem, but
     12 apparently several compilers do define "bool" in <stdbool.h> even when
     13 it is a keyword, in violation of the C23 spec.
     14 
     15 Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
     16 --- a/include/compiler.h
     17 +++ b/include/compiler.h
     18 @@ -181,19 +181,10 @@ size_t strlcpy(char *, const char *, size_t);
     19  char * pure_func strrchrnul(const char *, int);
     20  #endif
     21 
     22 -#if !defined(__cplusplus) || (__STDC_VERSION >= 202311L)
     23  /* C++ and C23 have bool, false, and true as proper keywords */
     24 +#if !defined(__cplusplus) || (__STDC_VERSION__ >= 202311L)
     25  # ifdef HAVE_STDBOOL_H
     26 -/* If <stdbool.h> exists, include it explicitly to prevent it from
     27 -   begin included later, causing the "bool" macro to be defined. */
     28  #  include <stdbool.h>
     29 -#  ifdef bool
     30 -/* Force bool to be a typedef instead of a macro. What a "clever" hack
     31 -   this is... */
     32 -    typedef bool                /* The macro definition of bool */
     33 -#  undef bool
     34 -        bool;                   /* No longer the macro definition */
     35 -#  endif
     36  # elif defined(HAVE___BOOL)
     37     typedef _Bool bool;
     38  #  define false 0
     39 @@ -201,14 +192,10 @@ char * pure_func strrchrnul(const char *, int);
     40  # else
     41  /* This is a bit dangerous, because casting to this ersatz bool
     42     will not produce the same result as the standard (bool) cast.
     43 -   Instead, use the bool() constructor-style macro defined below. */
     44 +   Instead, use the explicit construct !!x instead of relying on
     45 +   implicit conversions or casts. */
     46  typedef enum bool { false, true } bool;
     47  # endif
     48 -/* This amounts to a C++-style conversion cast to bool.  This works
     49 -   because C ignores an argument-taking macro when used without an
     50 -   argument and because bool was redefined as a typedef if it previously
     51 -   was defined as a macro (see above.) */
     52 -# define bool(x) ((bool)!!(x))
     53  #endif
     54 
     55  /* Create a NULL pointer of the same type as the address of
     56 @@ -321,11 +308,11 @@ static inline void *mempset(void *dst, int c, size_t n)
     57   * less likely to be taken.
     58   */
     59  #ifdef HAVE___BUILTIN_EXPECT
     60 -# define likely(x)	__builtin_expect(bool(x), true)
     61 -# define unlikely(x)	__builtin_expect(bool(x), false)
     62 +# define likely(x)	__builtin_expect(!!(x), true)
     63 +# define unlikely(x)	__builtin_expect(!!(x), false)
     64  #else
     65 -# define likely(x)	bool(x)
     66 -# define unlikely(x)	bool(x)
     67 +# define likely(x)	(!!(x))
     68 +# define unlikely(x)	(!!(x))
     69  #endif
     70 
     71  #ifdef HAVE___BUILTIN_PREFETCH
     72 
     73 https://github.com/netwide-assembler/nasm/commit/746e7c9efa37cec9a44d84a1e96b8c38f385cc1f
     74 From: "H. Peter Anvin (Intel)" <hpa@zytor.com>
     75 Date: Sun, 12 Oct 2025 13:05:55 -0700
     76 Subject: [PATCH] compiler.h: the test for "neither C++ nor C23" still wrong
     77 
     78 The test needs to test for neither nor; as it was it tested "(not C++)
     79 or C23" which was not at all what was intended...
     80 
     81 Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
     82 --- a/include/compiler.h
     83 +++ b/include/compiler.h
     84 @@ -182,7 +182,7 @@ char * pure_func strrchrnul(const char *, int);
     85  #endif
     86 
     87  /* C++ and C23 have bool, false, and true as proper keywords */
     88 -#if !defined(__cplusplus) || (__STDC_VERSION__ >= 202311L)
     89 +#if !defined(__cplusplus) && (__STDC_VERSION__ < 202311L)
     90  # ifdef HAVE_STDBOOL_H
     91  #  include <stdbool.h>
     92  # elif defined(HAVE___BOOL)