vita-toolchain

git clone https://git.neptards.moe/neptards/vita-toolchain.git
Log | Files | Refs | README | LICENSE

fail-utils.h (935B)


      1 #ifndef FAIL_UTILS_H
      2 #define FAIL_UTILS_H
      3 
      4 #ifndef __MINGW32__
      5 #include <err.h>
      6 #else
      7 #include <stdio.h>
      8 #include <string.h>
      9 #define warnx(fmt, args...) fprintf(stderr, __FILE__ ": " fmt, ##args)
     10 #define warn(fmt, args...) warnx(fmt ": %s", ##args, strerror(errno))
     11 #define errx(retval, args...) do {warnx(args); exit(retval);} while (0)
     12 #define err(retval, args...) do {warn(args); exit(retval);} while (0)
     13 #endif
     14 
     15 #define FAIL_EX(label, function, fmt...) do { \
     16 	function(fmt); \
     17 	goto label; \
     18 } while (0)
     19 #define FAIL(fmt...) FAIL_EX(failure, warn, fmt)
     20 #define FAILX(fmt...) FAIL_EX(failure, warnx, fmt)
     21 #define FAILE(fmt, args...) FAIL_EX(failure, warnx, fmt ": %s", ##args, elf_errmsg(-1))
     22 #define ASSERT(condition) do { \
     23 	if (!(condition)) FAILX("Assertion failed: (" #condition ")"); \
     24 } while (0)
     25 
     26 #define SYS_ASSERT(cmd) if ((cmd) < 0) FAIL(#cmd " failed")
     27 #define ELF_ASSERT(cmd) if (!(cmd)) FAILE(#cmd " failed")
     28 
     29 #endif