Permalink
Browse files

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.
  • Loading branch information...
awilfox authored and vathpela committed Aug 19, 2017
1 parent be657aa commit e04281e60cf0de094f8372e8682d3c7d1aef4ee8
Showing with 9 additions and 0 deletions.
  1. +9 −0 src/makeguids.c
View
@@ -152,6 +152,15 @@ main(int argc, char *argv[])
fprintf(symout, "#include <efivar/efivar.h>\n");
fprintf(symout, "#include <endian.h>\n");
fprintf(symout, """\n\
#ifndef __bswap_constant_16\n\
#define __bswap_constant_16(x)\\\n\
((unsigned short int) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)))\n\
#endif\n\
#ifndef __bswap_constant_32\n\
#define __bswap_constant_32(x)\\\n\
((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \\\n\
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))\n\
#endif\n\
#if BYTE_ORDER == BIG_ENDIAN\n\
#define cpu_to_be32(n) (n)\n\
#define cpu_to_be16(n) (n)\n\

0 comments on commit e04281e

Please sign in to comment.