Skip to content

Commit e04281e

Browse files
awilfoxvathpela
authored andcommitted
makeguids: Ensure compatibility with other libcs
The musl libc does not provide __bswap_constant_XX. If <endian.h> does not provide these macros, use our own. This fixes issue #84.
1 parent be657aa commit e04281e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎src/makeguids.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,15 @@ main(int argc, char *argv[])
152152
fprintf(symout, "#include <efivar/efivar.h>\n");
153153
fprintf(symout, "#include <endian.h>\n");
154154
fprintf(symout, """\n\
155+
#ifndef __bswap_constant_16\n\
156+
#define __bswap_constant_16(x)\\\n\
157+
((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))\n\
158+
#endif\n\
159+
#ifndef __bswap_constant_32\n\
160+
#define __bswap_constant_32(x)\\\n\
161+
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \\\n\
162+
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))\n\
163+
#endif\n\
155164
#if BYTE_ORDER == BIG_ENDIAN\n\
156165
#define cpu_to_be32(n) (n)\n\
157166
#define cpu_to_be16(n) (n)\n\

0 commit comments

Comments
 (0)